spktoolbar: improved scaling of Appearance Editor form for Laz <1.8

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5981 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-07-08 15:08:34 +00:00
parent 3b2bc7db66
commit 9eb490f7e4
2 changed files with 144 additions and 95 deletions

View File

@ -1,11 +1,11 @@
object frmAppearanceEditWindow: TfrmAppearanceEditWindow object frmAppearanceEditWindow: TfrmAppearanceEditWindow
Left = 554 Left = 664
Height = 568 Height = 555
Top = 248 Top = 224
Width = 558 Width = 552
Caption = 'Toolbar appearance editor' Caption = 'Toolbar appearance editor'
ClientHeight = 568 ClientHeight = 555
ClientWidth = 558 ClientWidth = 552
Color = clBtnFace Color = clBtnFace
Font.Color = clWindowText Font.Color = clWindowText
OnActivate = FormActivate OnActivate = FormActivate
@ -18,17 +18,17 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
Left = 0 Left = 0
Height = 132 Height = 132
Top = 0 Top = 0
Width = 558 Width = 552
Align = alTop Align = alTop
AutoSize = True AutoSize = True
Caption = ' Preview ' Caption = ' Preview '
ClientHeight = 112 ClientHeight = 112
ClientWidth = 554 ClientWidth = 548
TabOrder = 0 TabOrder = 0
object tbPreview: TSpkToolbar object tbPreview: TSpkToolbar
Left = 0 Left = 0
Top = 0 Top = 0
Width = 554 Width = 548
Color = clBtnFace Color = clBtnFace
Appearance.Tab.TabHeaderFont.Color = 9126421 Appearance.Tab.TabHeaderFont.Color = 9126421
Appearance.Tab.TabHeaderFont.Height = -13 Appearance.Tab.TabHeaderFont.Height = -13
@ -324,17 +324,17 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
end end
object PageControl1: TPageControl object PageControl1: TPageControl
Left = 0 Left = 0
Height = 387 Height = 382
Top = 132 Top = 132
Width = 558 Width = 552
ActivePage = TabSheet1 ActivePage = TabSheet2
Align = alClient Align = alClient
TabIndex = 0 TabIndex = 1
TabOrder = 1 TabOrder = 1
object TabSheet1: TTabSheet object TabSheet1: TTabSheet
Caption = 'Tab' Caption = 'Tab'
ClientHeight = 359 ClientHeight = 360
ClientWidth = 550 ClientWidth = 544
object sTabRectangle: TShape object sTabRectangle: TShape
AnchorSideLeft.Control = LblInactiveTabHeaderFontColor AnchorSideLeft.Control = LblInactiveTabHeaderFontColor
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
@ -700,8 +700,8 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
end end
object TabSheet2: TTabSheet object TabSheet2: TTabSheet
Caption = 'Pane' Caption = 'Pane'
ClientHeight = 359 ClientHeight = 354
ClientWidth = 550 ClientWidth = 544
ImageIndex = 1 ImageIndex = 1
object Label8: TLabel object Label8: TLabel
AnchorSideTop.Control = pPaneBorderDark AnchorSideTop.Control = pPaneBorderDark
@ -985,6 +985,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
Width = 127 Width = 127
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6 BorderSpacing.Top = 6
BorderSpacing.Bottom = 6
ItemHeight = 15 ItemHeight = 15
ItemIndex = 1 ItemIndex = 1
Items.Strings = ( Items.Strings = (
@ -1187,8 +1188,8 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
end end
object TabSheet3: TTabSheet object TabSheet3: TTabSheet
Caption = 'Item' Caption = 'Item'
ClientHeight = 359 ClientHeight = 355
ClientWidth = 550 ClientWidth = 544
ImageIndex = 2 ImageIndex = 2
object sItemRectangle: TShape object sItemRectangle: TShape
AnchorSideLeft.Control = LblLinkInnerLightColor AnchorSideLeft.Control = LblLinkInnerLightColor
@ -2219,8 +2220,8 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
end end
object TabSheet4: TTabSheet object TabSheet4: TTabSheet
Caption = 'Import / export' Caption = 'Import / export'
ClientHeight = 359 ClientHeight = 355
ClientWidth = 550 ClientWidth = 544
ImageIndex = 3 ImageIndex = 3
object bImport: TButton object bImport: TButton
AnchorSideLeft.Control = bExportToXML AnchorSideLeft.Control = bExportToXML
@ -2261,9 +2262,9 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
AnchorSideBottom.Control = TabSheet4 AnchorSideBottom.Control = TabSheet4
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 4 Left = 4
Height = 322 Height = 318
Top = 33 Top = 33
Width = 542 Width = 536
Anchors = [akTop, akLeft, akRight, akBottom] Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Left = 4 BorderSpacing.Left = 4
BorderSpacing.Top = 4 BorderSpacing.Top = 4
@ -2294,7 +2295,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
AnchorSideTop.Control = TabSheet4 AnchorSideTop.Control = TabSheet4
AnchorSideRight.Control = TabSheet4 AnchorSideRight.Control = TabSheet4
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 492 Left = 486
Height = 25 Height = 25
Top = 4 Top = 4
Width = 54 Width = 54
@ -2309,8 +2310,8 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
end end
object TabSheet5: TTabSheet object TabSheet5: TTabSheet
Caption = 'Tools' Caption = 'Tools'
ClientHeight = 359 ClientHeight = 357
ClientWidth = 550 ClientWidth = 544
ImageIndex = 4 ImageIndex = 4
object Label17: TLabel object Label17: TLabel
AnchorSideLeft.Control = TabSheet5 AnchorSideLeft.Control = TabSheet5
@ -2348,21 +2349,24 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
object ButtonPanel: TPanel object ButtonPanel: TPanel
Left = 8 Left = 8
Height = 33 Height = 33
Top = 527 Top = 518
Width = 542 Width = 535
Align = alBottom Align = alBottom
AutoSize = True AutoSize = True
BorderSpacing.Around = 8 BorderSpacing.Left = 8
BorderSpacing.Top = 4
BorderSpacing.Right = 9
BorderSpacing.Bottom = 4
BevelOuter = bvNone BevelOuter = bvNone
ClientHeight = 33 ClientHeight = 33
ClientWidth = 542 ClientWidth = 535
TabOrder = 2 TabOrder = 2
object bOK: TButton object bOK: TButton
AnchorSideTop.Control = bCancel AnchorSideTop.Control = bCancel
AnchorSideRight.Control = bCancel AnchorSideRight.Control = bCancel
AnchorSideBottom.Control = bCancel AnchorSideBottom.Control = bCancel
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 432 Left = 425
Height = 25 Height = 25
Top = 4 Top = 4
Width = 42 Width = 42
@ -2378,7 +2382,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = ButtonPanel AnchorSideRight.Control = ButtonPanel
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 480 Left = 473
Height = 25 Height = 25
Top = 4 Top = 4
Width = 62 Width = 62
@ -2457,8 +2461,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
object Images_200: TImageList object Images_200: TImageList
Height = 32 Height = 32
Width = 32 Width = 32
left = 56 left = 344
top = 464
Bitmap = { Bitmap = {
4C69010000002000000020000000000000000000000000000000000000000000 4C69010000002000000020000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000
@ -2592,8 +2595,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
} }
end end
object Images_100: TImageList object Images_100: TImageList
left = 200 left = 488
top = 464
Bitmap = { Bitmap = {
4C69010000001000000010000000000000000000000000000000000000000000 4C69010000001000000010000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000032537266325372FF3253 0000000000000000000000000000000000000000000032537266325372FF3253
@ -2633,8 +2635,7 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
object Images_150: TImageList object Images_150: TImageList
Height = 24 Height = 24
Width = 24 Width = 24
left = 128 left = 416
top = 464
Bitmap = { Bitmap = {
4C69010000001800000018000000000000000000000000000000000000000000 4C69010000001800000018000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000
@ -2714,11 +2715,9 @@ object frmAppearanceEditWindow: TfrmAppearanceEditWindow
object LargeImages: TImageList object LargeImages: TImageList
Height = 32 Height = 32
Width = 32 Width = 32
left = 56 left = 192
top = 408
end end
object SmallImages: TImageList object SmallImages: TImageList
left = 128 left = 272
top = 408
end end
end end

View File

@ -6,7 +6,7 @@ interface
uses uses
LCLIntf, LCLType, SysUtils, Variants, Classes, Graphics, Controls, Forms, LCLIntf, LCLType, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ComCtrls, Buttons, Spin, Dialogs, ExtCtrls, StdCtrls, ComCtrls, Buttons, Spin, LCLVersion,
SpkGUITools, SpkXMLParser, SpkToolbar, SpkGUITools, SpkXMLParser, SpkToolbar,
spkt_Buttons, spkt_Pane, spkt_Tab, spkt_Appearance; spkt_Buttons, spkt_Pane, spkt_Tab, spkt_Appearance;
@ -218,12 +218,15 @@ type
procedure cbLinkItemClick(Sender: TObject); procedure cbLinkItemClick(Sender: TObject);
procedure cbLinkPaneClick(Sender: TObject); procedure cbLinkPaneClick(Sender: TObject);
procedure cbLinkTabClick(Sender: TObject); procedure cbLinkTabClick(Sender: TObject);
procedure edItemHotTrackBrightnessChangeChange(Sender: TObject); procedure edItemHotTrackBrightnessChangeChange(Sender: TObject);
procedure edPaneHotTrackBrightnessChangeChange(Sender: TObject); procedure edPaneHotTrackBrightnessChangeChange(Sender: TObject);
procedure FormActivate(Sender: TObject); procedure FormActivate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean); procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure LbAppearanceStyleClick(Sender: TObject); procedure LbAppearanceStyleClick(Sender: TObject);
procedure pActiveTabHeaderFontClick(Sender: TObject); procedure pActiveTabHeaderFontClick(Sender: TObject);
@ -296,8 +299,14 @@ type
Shift: TShiftState; X, Y: integer); Shift: TShiftState; X, Y: integer);
private private
procedure PositionControls;
procedure UpdateImages; procedure UpdateImages;
procedure UpdateSizes;
protected
{$IF lcl_fullversion >= 1080000}
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); override;
{$ENDIF}
public public
property Appearance : TSpkToolbarAppearance read GetAppearance write SetAppearance; property Appearance : TSpkToolbarAppearance read GetAppearance write SetAppearance;
@ -318,6 +327,14 @@ var
{ TForm3 } { TForm3 }
{$IF lcl_fullversion >= 1080000}
procedure TfrmAppearanceEditWindow.DoAutoAdjustLayout(
const AMode: TLayoutAdjustmentPolicy; const AXProportion, AYProportion: Double);
begin
inherited;
end;
{$ENDIF}
procedure TfrmAppearanceEditWindow.SetAppearance(const Value: TSpkToolbarAppearance); procedure TfrmAppearanceEditWindow.SetAppearance(const Value: TSpkToolbarAppearance);
begin begin
tbPreview.Appearance.Assign(Value); tbPreview.Appearance.Assign(Value);
@ -826,7 +843,7 @@ end;
procedure TfrmAppearanceEditWindow.FormActivate(Sender: TObject); procedure TfrmAppearanceEditWindow.FormActivate(Sender: TObject);
begin begin
UpdateImages; UpdateImages;
PositionControls; UpdateSizes;
end; end;
procedure TfrmAppearanceEditWindow.FormCloseQuery(Sender: TObject; procedure TfrmAppearanceEditWindow.FormCloseQuery(Sender: TObject;
@ -1315,56 +1332,6 @@ begin
FScreenshotForm.ModalResult := mrOK; FScreenshotForm.ModalResult := mrOK;
end; end;
procedure TfrmAppearanceEditWindow.PositionControls;
var
w, h, dist: Integer;
begin
// Update layout of controls
bOK.AutoSize := false;
bOK.Width := bCancel.Width;
ColorView.Width := ColorView.Height;
h := CbTabGradientKind.Height;
w := SpkScaleX(pTabFrame.Width, 96);
// h := SpkScaleY(pTabFrame.Height, 96);
pTabFrame.Width := w;
pTabFrame.Height := h;
pTabGradientFrom.Height := h;
pTabGradientTo.Height := h;
pActiveTabHeaderFont.Height := h;
pInactiveTabHeaderFont.Height := h;
pTabHeaderFont.Height := h;
pPaneBorderDark.Width := w;
pPaneBorderDark.Height := h;
pPaneBorderLight.Height := h;
pPaneGradientFrom.Height := h;
pPaneGradientTo.Height := h;
pPaneCaptionBackground.Height := h;
pPaneCaptionFontColor.Height := h;
pPaneCaptionFont.Height := h;
pItemIdleFrame.Width := w;
pItemHotTrackFrame.Width := w;
pItemActiveFrame.Width := w;
pItemIdleFrame.Height := h;
pItemIdleGradientFrom.Height := h;
pItemIdleGradientTo.Height := h;
pItemIdleCaptionColor.Height := h;
pItemIdleInnerDark.Height := h;
pItemIdleInnerLight.Height := h;
pItemFont.Height := h;
// Adjust width and height
Width := SpkScaleX(Width, 96);
h := Height - TabSheet1.ClientHeight;
dist := pTabHeaderFont.Top - (pInactiveTabHeaderFont.Top + pInactiveTabHeaderFont.Height);
Height := cbPaneStyle.Top + cbPanestyle.Height + dist + h;
Position := poScreenCenter;
end;
procedure TfrmAppearanceEditWindow.UpdateImages; procedure TfrmAppearanceEditWindow.UpdateImages;
var var
imglist: TImageList; imglist: TImageList;
@ -1441,6 +1408,89 @@ begin
imglist.GetBitmap(0, bItemActiveInnerLightColor.Glyph); imglist.GetBitmap(0, bItemActiveInnerLightColor.Glyph);
end; end;
procedure TfrmAppearanceEditWindow.UpdateSizes;
var
w, h, dist: Integer;
procedure AddToHeight(var AHeight: Integer; AControl: TControl);
begin
inc(AHeight, AControl.Height);
with AControl.BorderSpacing do
inc(AHeight, Top + Bottom + Around);
end;
begin
// Update layout of controls
bOK.AutoSize := false;
bOK.Width := bCancel.Width;
ColorView.Width := ColorView.Height;
h := CbTabGradientKind.Height;
{$IF lcl_fullversion < 1080000}
w := SpkScaleX(pTabFrame.Width, 96);
{$ELSE}
w := pTabFrame.Width;
{$ENDIF}
// h := SpkScaleY(pTabFrame.Height, 96);
pTabFrame.Width := w;
pTabFrame.Height := h;
pTabGradientFrom.Height := h;
pTabGradientTo.Height := h;
pActiveTabHeaderFont.Height := h;
pInactiveTabHeaderFont.Height := h;
pTabHeaderFont.Height := h;
pPaneBorderDark.Width := w;
pPaneBorderDark.Height := h;
pPaneBorderLight.Height := h;
pPaneGradientFrom.Height := h;
pPaneGradientTo.Height := h;
pPaneCaptionBackground.Height := h;
pPaneCaptionFontColor.Height := h;
pPaneCaptionFont.Height := h;
pItemIdleFrame.Width := w;
pItemHotTrackFrame.Width := w;
pItemActiveFrame.Width := w;
pItemIdleFrame.Height := h;
pItemIdleGradientFrom.Height := h;
pItemIdleGradientTo.Height := h;
pItemIdleCaptionColor.Height := h;
pItemIdleInnerDark.Height := h;
pItemIdleInnerLight.Height := h;
pItemFont.Height := h;
// TabSheet2 requires the largest height
h := Height - TabSheet2.ClientHeight; // This is the height outside the tabsheet
// Add the heights of all controls
AddToHeight(h, cbLinkPane);
AddToHeight(h, pPaneBorderDark);
AddToHeight(h, pPaneBorderLight);
AddToHeight(h, pPaneGradientFrom);
AddToHeight(h, pPaneGradientTo);
AddToHeight(h, cbPaneGradientKind);
AddToHeight(h, pPaneCaptionBackground);
AddToHeight(h, edPaneHotTrackBrightnessChange);
AddToHeight(h, pPaneCaptionFontColor);
AddToHeight(h, pPaneCaptionFont);
AddToHeight(h, cbPaneStyle);
// Adjust width and height
{$IF lcl_fullversion < 1080000}
Width := SpkScaleX(Width, 96);
Height := SpkScaleY(Height, 96);
// Height := h;
{$ENDIF}
(*
Constraints.MinHeight := h;
Height := 0; *)
Position := poScreenCenter;
end;
end. end.