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

View File

@ -6,7 +6,7 @@ interface
uses
LCLIntf, LCLType, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ComCtrls, Buttons, Spin,
Dialogs, ExtCtrls, StdCtrls, ComCtrls, Buttons, Spin, LCLVersion,
SpkGUITools, SpkXMLParser, SpkToolbar,
spkt_Buttons, spkt_Pane, spkt_Tab, spkt_Appearance;
@ -218,12 +218,15 @@ type
procedure cbLinkItemClick(Sender: TObject);
procedure cbLinkPaneClick(Sender: TObject);
procedure cbLinkTabClick(Sender: TObject);
procedure edItemHotTrackBrightnessChangeChange(Sender: TObject);
procedure edPaneHotTrackBrightnessChangeChange(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure LbAppearanceStyleClick(Sender: TObject);
procedure pActiveTabHeaderFontClick(Sender: TObject);
@ -296,8 +299,14 @@ type
Shift: TShiftState; X, Y: integer);
private
procedure PositionControls;
procedure UpdateImages;
procedure UpdateSizes;
protected
{$IF lcl_fullversion >= 1080000}
procedure DoAutoAdjustLayout(const AMode: TLayoutAdjustmentPolicy;
const AXProportion, AYProportion: Double); override;
{$ENDIF}
public
property Appearance : TSpkToolbarAppearance read GetAppearance write SetAppearance;
@ -318,6 +327,14 @@ var
{ 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);
begin
tbPreview.Appearance.Assign(Value);
@ -826,7 +843,7 @@ end;
procedure TfrmAppearanceEditWindow.FormActivate(Sender: TObject);
begin
UpdateImages;
PositionControls;
UpdateSizes;
end;
procedure TfrmAppearanceEditWindow.FormCloseQuery(Sender: TObject;
@ -1315,56 +1332,6 @@ begin
FScreenshotForm.ModalResult := mrOK;
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;
var
imglist: TImageList;
@ -1441,6 +1408,89 @@ begin
imglist.GetBitmap(0, bItemActiveInnerLightColor.Glyph);
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.