mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 04:39:22 +02:00
IdeIntf: Improve Graphic Property Editor layout. Issue #29618, patch from Alexey Torgashin.
git-svn-id: trunk@51553 -
This commit is contained in:
parent
c440bfd8e0
commit
0c558e2b3c
@ -1,7 +1,7 @@
|
|||||||
object GraphicPropertyEditorForm: TGraphicPropertyEditorForm
|
object GraphicPropertyEditorForm: TGraphicPropertyEditorForm
|
||||||
Left = 277
|
Left = 389
|
||||||
Height = 381
|
Height = 381
|
||||||
Top = 147
|
Top = 166
|
||||||
Width = 436
|
Width = 436
|
||||||
ActiveControl = LoadButton
|
ActiveControl = LoadButton
|
||||||
Caption = 'Load Image Dialog'
|
Caption = 'Load Image Dialog'
|
||||||
@ -11,38 +11,37 @@ object GraphicPropertyEditorForm: TGraphicPropertyEditorForm
|
|||||||
Constraints.MinWidth = 200
|
Constraints.MinWidth = 200
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
LCLVersion = '0.9.31'
|
LCLVersion = '1.7'
|
||||||
object GroupBox1: TGroupBox
|
object GroupBox1: TGroupBox
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 337
|
Height = 334
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 424
|
Width = 424
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
Caption = 'Picture'
|
Caption = 'Picture'
|
||||||
ClientHeight = 319
|
ClientHeight = 315
|
||||||
ClientWidth = 420
|
ClientWidth = 420
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object ScrollBox: TScrollBox
|
object ScrollBox: TScrollBox
|
||||||
AnchorSideRight.Control = GroupBox1
|
AnchorSideRight.Control = GroupBox1
|
||||||
AnchorSideBottom.Control = GroupBox1
|
AnchorSideBottom.Control = GroupBox1
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 307
|
Height = 303
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 322
|
Width = 322
|
||||||
HorzScrollBar.Page = 318
|
HorzScrollBar.Page = 100
|
||||||
HorzScrollBar.Tracking = True
|
HorzScrollBar.Tracking = True
|
||||||
VertScrollBar.Page = 303
|
VertScrollBar.Page = 100
|
||||||
VertScrollBar.Tracking = True
|
VertScrollBar.Tracking = True
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
ClientHeight = 303
|
ClientHeight = 301
|
||||||
ClientWidth = 318
|
ClientWidth = 320
|
||||||
Color = clWindow
|
|
||||||
ParentColor = False
|
|
||||||
ParentShowHint = False
|
ParentShowHint = False
|
||||||
ShowHint = True
|
ShowHint = True
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
|
OnResize = ScrollBoxResize
|
||||||
object ImagePreview: TImage
|
object ImagePreview: TImage
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 100
|
Height = 100
|
||||||
@ -50,70 +49,100 @@ object GraphicPropertyEditorForm: TGraphicPropertyEditorForm
|
|||||||
Width = 100
|
Width = 100
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
Center = True
|
Center = True
|
||||||
|
OnPaintBackground = ImagePreviewPaintBackground
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object LoadSaveBtnPanel: TPanel
|
object LoadSaveBtnPanel: TPanel
|
||||||
Left = 334
|
Left = 334
|
||||||
Height = 319
|
Height = 315
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 86
|
Width = 86
|
||||||
Align = alRight
|
Align = alRight
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 319
|
ClientHeight = 315
|
||||||
ClientWidth = 86
|
ClientWidth = 86
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
object LoadButton: TButton
|
object LoadButton: TButton
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 25
|
Height = 29
|
||||||
Top = 6
|
Top = 6
|
||||||
Width = 74
|
Width = 74
|
||||||
Action = FileOpenAction
|
Action = FileOpenAction
|
||||||
Align = alTop
|
Align = alTop
|
||||||
|
AutoSize = True
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object SaveButton: TButton
|
object SaveButton: TButton
|
||||||
|
AnchorSideLeft.Control = LoadButton
|
||||||
|
AnchorSideTop.Control = LoadButton
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
AnchorSideRight.Control = LoadButton
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 25
|
Height = 29
|
||||||
Top = 37
|
Top = 41
|
||||||
Width = 74
|
Width = 74
|
||||||
Action = FileSaveAction
|
Action = FileSaveAction
|
||||||
Align = alTop
|
Align = alTop
|
||||||
|
AutoSize = True
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object ClearButton: TButton
|
object ClearButton: TButton
|
||||||
|
AnchorSideLeft.Control = LoadButton
|
||||||
|
AnchorSideTop.Control = SaveButton
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
AnchorSideRight.Control = LoadButton
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 25
|
Height = 29
|
||||||
Top = 68
|
Top = 76
|
||||||
Width = 74
|
Width = 74
|
||||||
Action = ClearAction
|
Action = ClearAction
|
||||||
Align = alTop
|
Align = alTop
|
||||||
|
AutoSize = True
|
||||||
BorderSpacing.Around = 6
|
BorderSpacing.Around = 6
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
object CopyButton: TButton
|
object CopyButton: TButton
|
||||||
|
AnchorSideLeft.Control = LoadButton
|
||||||
|
AnchorSideTop.Control = ClearButton
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
AnchorSideRight.Control = LoadButton
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 25
|
Height = 29
|
||||||
Top = 112
|
Top = 111
|
||||||
Width = 74
|
Width = 74
|
||||||
Action = CopyAction
|
Action = CopyAction
|
||||||
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Top = 6
|
||||||
TabOrder = 3
|
TabOrder = 3
|
||||||
end
|
end
|
||||||
object PasteButton: TButton
|
object PasteButton: TButton
|
||||||
|
AnchorSideLeft.Control = LoadButton
|
||||||
|
AnchorSideTop.Control = CopyButton
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
AnchorSideRight.Control = LoadButton
|
||||||
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 25
|
Height = 29
|
||||||
Top = 143
|
Top = 146
|
||||||
Width = 74
|
Width = 74
|
||||||
Action = PasteAction
|
Action = PasteAction
|
||||||
|
Anchors = [akTop, akLeft, akRight]
|
||||||
|
AutoSize = True
|
||||||
|
BorderSpacing.Top = 6
|
||||||
TabOrder = 4
|
TabOrder = 4
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
object OkCancelButtonPanel: TButtonPanel
|
object OkCancelButtonPanel: TButtonPanel
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 26
|
Height = 29
|
||||||
Top = 349
|
Top = 346
|
||||||
Width = 424
|
Width = 424
|
||||||
OKButton.Name = 'OKButton'
|
OKButton.Name = 'OKButton'
|
||||||
OKButton.DefaultCaption = True
|
OKButton.DefaultCaption = True
|
||||||
|
@ -46,6 +46,8 @@ type
|
|||||||
ScrollBox: TScrollBox;
|
ScrollBox: TScrollBox;
|
||||||
procedure CopyActionExecute(Sender: TObject);
|
procedure CopyActionExecute(Sender: TObject);
|
||||||
procedure CopyActionUpdate(Sender: TObject);
|
procedure CopyActionUpdate(Sender: TObject);
|
||||||
|
procedure ImagePreviewPaintBackground(ASender: TObject; ACanvas: TCanvas;
|
||||||
|
ARect: TRect);
|
||||||
procedure PasteActionExecute(Sender: TObject);
|
procedure PasteActionExecute(Sender: TObject);
|
||||||
procedure PasteActionUpdate(Sender: TObject);
|
procedure PasteActionUpdate(Sender: TObject);
|
||||||
procedure ClearActionExecute(Sender: TObject);
|
procedure ClearActionExecute(Sender: TObject);
|
||||||
@ -54,6 +56,7 @@ type
|
|||||||
procedure FileSaveActionExecute(Sender: TObject);
|
procedure FileSaveActionExecute(Sender: TObject);
|
||||||
procedure FileSaveActionUpdate(Sender: TObject);
|
procedure FileSaveActionUpdate(Sender: TObject);
|
||||||
procedure PictureChanged(Sender: TObject);
|
procedure PictureChanged(Sender: TObject);
|
||||||
|
procedure ScrollBoxResize(Sender: TObject);
|
||||||
private
|
private
|
||||||
FFileName: String;
|
FFileName: String;
|
||||||
FModified: Boolean;
|
FModified: Boolean;
|
||||||
@ -104,6 +107,34 @@ begin
|
|||||||
CopyAction.Enabled := ImagePreview.Picture.Graphic <> nil;
|
CopyAction.Enabled := ImagePreview.Picture.Graphic <> nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TGraphicPropertyEditorForm.ImagePreviewPaintBackground(
|
||||||
|
ASender: TObject; ACanvas: TCanvas; ARect: TRect);
|
||||||
|
const
|
||||||
|
cell=8; //8 pixels is usual checkers size
|
||||||
|
var
|
||||||
|
bmp: TBitmap;
|
||||||
|
i, j: integer;
|
||||||
|
begin
|
||||||
|
//Paint checkers BG picture for transparent image
|
||||||
|
bmp:= TBitmap.Create;
|
||||||
|
try
|
||||||
|
bmp.PixelFormat:= pf24bit;
|
||||||
|
bmp.SetSize(ARect.Right-ARect.Left, ARect.Bottom-ARect.Top);
|
||||||
|
bmp.Canvas.Brush.Color:= clWhite;
|
||||||
|
bmp.Canvas.FillRect(0, 0, bmp.Width, bmp.Height);
|
||||||
|
bmp.Canvas.Brush.Color:= clLtGray;
|
||||||
|
|
||||||
|
for i:= 0 to bmp.Width div cell do
|
||||||
|
for j:= 0 to bmp.Height div cell do
|
||||||
|
if not (Odd(i) xor Odd(j)) then
|
||||||
|
bmp.Canvas.FillRect(i*cell, j*cell, (i+1)*cell, (j+1)*cell);
|
||||||
|
|
||||||
|
ACanvas.CopyRect(ARect, bmp.Canvas, Rect(0, 0, bmp.Width, bmp.Height));
|
||||||
|
finally
|
||||||
|
FreeAndNil(bmp);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TGraphicPropertyEditorForm.FileSaveActionUpdate(Sender: TObject);
|
procedure TGraphicPropertyEditorForm.FileSaveActionUpdate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
(Sender as TAction).Enabled := (Graphic <> nil) and (not Graphic.Empty);
|
(Sender as TAction).Enabled := (Graphic <> nil) and (not Graphic.Empty);
|
||||||
@ -147,6 +178,21 @@ begin
|
|||||||
ScrollBox.Hint := Graphic.ClassName
|
ScrollBox.Hint := Graphic.ClassName
|
||||||
else
|
else
|
||||||
ScrollBox.Hint := '';
|
ScrollBox.Hint := '';
|
||||||
|
|
||||||
|
ScrollBoxResize(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGraphicPropertyEditorForm.ScrollBoxResize(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if ImagePreview.Width<ScrollBox.ClientWidth then
|
||||||
|
ImagePreview.Left:= (ScrollBox.ClientWidth-ImagePreview.Width) div 2
|
||||||
|
else
|
||||||
|
ImagePreview.Left:= 0;
|
||||||
|
|
||||||
|
if ImagePreview.Height<ScrollBox.ClientHeight then
|
||||||
|
ImagePreview.Top:= (ScrollBox.ClientHeight-ImagePreview.Height) div 2
|
||||||
|
else
|
||||||
|
ImagePreview.Top:= 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGraphicPropertyEditorForm.FileSaveActionExecute(Sender: TObject);
|
procedure TGraphicPropertyEditorForm.FileSaveActionExecute(Sender: TObject);
|
||||||
|
Loading…
Reference in New Issue
Block a user