mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 10:39:20 +02:00
LCL: issue #0027030: proper button size in vertical mode
(conctrls.pp,toolbar.inc,toolbutton.inc) IDEINTF: same issue - componenteditors.pas git-svn-id: trunk@46800 -
This commit is contained in:
parent
19ecf0127e
commit
447003f6d6
@ -1252,8 +1252,6 @@ begin
|
||||
NewToolButton.Caption := NewName;
|
||||
NewToolButton.Name := NewName;
|
||||
NewToolButton.Style := NewStyle;
|
||||
if NewStyle = tbsDivider then
|
||||
NewToolButton.Width := 3;
|
||||
// position the button next to the last button
|
||||
if CurToolBar.ButtonCount > 0 then
|
||||
begin
|
||||
|
@ -1953,7 +1953,7 @@ type
|
||||
end;
|
||||
|
||||
TToolButtonActionLinkClass = class of TToolButtonActionLink;
|
||||
|
||||
|
||||
TToolBar = class;
|
||||
|
||||
TToolButton = class(TGraphicControl)
|
||||
@ -1976,6 +1976,7 @@ type
|
||||
function GetIndex: Integer;
|
||||
function GetTextSize: TSize;
|
||||
function IsCheckedStored: Boolean;
|
||||
function IsHeightStored: Boolean;
|
||||
function IsImageIndexStored: Boolean;
|
||||
function IsWidthStored: Boolean;
|
||||
procedure SetDown(Value: Boolean);
|
||||
@ -1992,6 +1993,9 @@ type
|
||||
procedure CMEnabledChanged(var Message: TLMEssage); message CM_ENABLEDCHANGED;
|
||||
procedure CMVisibleChanged(var Message: TLMessage); message CM_VISIBLECHANGED;
|
||||
procedure CMHitTest(var Message: TCMHitTest); message CM_HITTEST;
|
||||
protected const
|
||||
cDefSeparatorWidth = 10;
|
||||
cDefDividerWidth = 5;
|
||||
protected
|
||||
FToolBar: TToolBar;
|
||||
class procedure WSRegisterClass; override;
|
||||
@ -2045,7 +2049,7 @@ type
|
||||
property DropdownMenu: TPopupMenu read FDropdownMenu write SetDropdownMenu;
|
||||
property Enabled;
|
||||
property Grouped: Boolean read FGrouped write SetGrouped default False;
|
||||
property Height stored False;
|
||||
property Height stored IsHeightStored;
|
||||
property ImageIndex: TImageIndex read FImageIndex write SetImageIndex stored IsImageIndexStored default -1;
|
||||
property Indeterminate: Boolean read FIndeterminate write SetIndeterminate default False;
|
||||
property Marked: Boolean read FMarked write SetMarked default False;
|
||||
@ -2149,7 +2153,11 @@ type
|
||||
procedure MoveSubMenuItems(SrcMenuItem, DestMenuItem: TMenuItem);
|
||||
procedure AddButton(Button: TToolButton);
|
||||
procedure RemoveButton(Button: TToolButton);
|
||||
protected const
|
||||
cDefButtonWidth = 23;
|
||||
cDefButtonHeight = 22;
|
||||
protected
|
||||
FPrevVertical: Boolean;
|
||||
function IsVertical: Boolean; virtual;
|
||||
class procedure WSRegisterClass; override;
|
||||
procedure AdjustClientRect(var ARect: TRect); override;
|
||||
@ -2191,8 +2199,8 @@ type
|
||||
property AutoSize;
|
||||
property BorderSpacing;
|
||||
property BorderWidth;
|
||||
property ButtonHeight: Integer read FButtonHeight write SetButtonHeight default 22;
|
||||
property ButtonWidth: Integer read FButtonWidth write SetButtonWidth default 23;
|
||||
property ButtonHeight: Integer read FButtonHeight write SetButtonHeight default cDefButtonHeight;
|
||||
property ButtonWidth: Integer read FButtonWidth write SetButtonWidth default cDefButtonWidth;
|
||||
property Caption;
|
||||
property ChildSizing;
|
||||
property Constraints;
|
||||
|
@ -89,8 +89,8 @@ begin
|
||||
csDoubleClicks, csMenuEvents, csSetCaption, csParentBackground, csOpaque];
|
||||
FFlat := True;
|
||||
Height := 32;
|
||||
FButtonWidth := 23;
|
||||
FButtonHeight := 22;
|
||||
FButtonWidth := cDefButtonWidth;
|
||||
FButtonHeight := cDefButtonHeight;
|
||||
Details := ThemeServices.GetElementDetails(ttbSplitButtonDropDownNormal);
|
||||
FDropDownWidth := ThemeServices.GetDetailSize(Details).cx;
|
||||
FNewStyle := True;
|
||||
@ -833,8 +833,24 @@ begin
|
||||
SeparatorWidthChange := (CurControl is TToolButton) and
|
||||
(TToolButton(CurControl).Style in [tbsSeparator, tbsDivider]);
|
||||
if SeparatorWidthChange then begin
|
||||
SeparatorWidthChange := (w <> CurControl.Width);
|
||||
w := CurControl.Width;
|
||||
if not Vertical then begin
|
||||
SeparatorWidthChange := (w <> CurControl.Width);
|
||||
w := CurControl.Width;
|
||||
end else begin
|
||||
SeparatorWidthChange := (h <> CurControl.Height);
|
||||
h := CurControl.Height;
|
||||
end;
|
||||
end;
|
||||
if Vertical <> FPrevVertical then //swap h/w when orientation changed
|
||||
begin
|
||||
if (CurControl is TToolButton) and
|
||||
(TToolButton(CurControl).Style in [tbsSeparator, tbsDivider]) then
|
||||
begin
|
||||
if not Vertical then
|
||||
w := CurControl.Height
|
||||
else
|
||||
h := CurControl.Width;
|
||||
end;
|
||||
end;
|
||||
if (CurControl.Left <> x) or (CurControl.Top <> y) or
|
||||
(CurControl.Width <> w) or (CurControl.Height <> h) then
|
||||
@ -893,6 +909,7 @@ begin
|
||||
FullSizeObstacleControls.Free;
|
||||
EndUpdate;
|
||||
EnableAlign;
|
||||
FPrevVertical := Vertical;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -630,6 +630,18 @@ procedure TToolButton.SetStyle(Value: TToolButtonStyle);
|
||||
begin
|
||||
if FStyle = Value then exit;
|
||||
FStyle := Value;
|
||||
if Width = TToolBar.cDefButtonWidth then begin
|
||||
case Value of
|
||||
tbsSeparator: begin
|
||||
Width := cDefSeparatorWidth;
|
||||
Height := cDefSeparatorWidth;
|
||||
end;
|
||||
tbsDivider: begin
|
||||
Width := cDefDividerWidth;
|
||||
Height := cDefDividerWidth;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
InvalidatePreferredSize;
|
||||
if IsControlVisible then
|
||||
UpdateVisibleToolbar;
|
||||
@ -808,6 +820,11 @@ begin
|
||||
Result := (ActionLink = nil) or not TToolButtonActionLink(ActionLink).IsCheckedLinked;
|
||||
end;
|
||||
|
||||
function TToolButton.IsHeightStored: Boolean;
|
||||
begin
|
||||
Result := Style in [tbsSeparator, tbsDivider];
|
||||
end;
|
||||
|
||||
function TToolButton.IsImageIndexStored: Boolean;
|
||||
begin
|
||||
Result := (ActionLink = nil) or not TToolButtonActionLink(ActionLink).IsImageIndexLinked;
|
||||
@ -875,11 +892,19 @@ begin
|
||||
FToolBar := nil;
|
||||
if AParent is TToolBar then
|
||||
begin
|
||||
if Style in [tbsButton,tbsDropDown,tbsCheck] then
|
||||
NewWidth := TToolBar(AParent).ButtonWidth
|
||||
else
|
||||
NewWidth := Width;
|
||||
NewHeight := TToolBar(AParent).ButtonHeight;
|
||||
if not TToolBar(AParent).IsVertical then begin
|
||||
if Style in [tbsButton,tbsDropDown,tbsCheck] then
|
||||
NewWidth := TToolBar(AParent).ButtonWidth
|
||||
else
|
||||
NewWidth := Width;
|
||||
NewHeight := TToolBar(AParent).ButtonHeight;
|
||||
end else begin
|
||||
if Style in [tbsButton,tbsDropDown,tbsCheck] then
|
||||
NewHeight := TToolBar(AParent).ButtonHeight
|
||||
else
|
||||
NewHeight := Height;
|
||||
NewWidth := TToolBar(AParent).ButtonWidth;
|
||||
end;
|
||||
SetBoundsKeepBase(Left, Top, NewWidth, NewHeight);
|
||||
end;
|
||||
|
||||
@ -1032,15 +1057,15 @@ begin
|
||||
else
|
||||
if Style = tbsDivider then
|
||||
if FToolBar.IsVertical then
|
||||
PreferredHeight := 5
|
||||
PreferredHeight := cDefDividerWidth
|
||||
else
|
||||
PreferredWidth := 5
|
||||
PreferredWidth := cDefDividerWidth
|
||||
else
|
||||
if Style = tbsSeparator then
|
||||
if FToolBar.IsVertical then
|
||||
PreferredHeight := 10
|
||||
PreferredHeight := cDefSeparatorWidth
|
||||
else
|
||||
PreferredWidth := 10;
|
||||
PreferredWidth := cDefSeparatorWidth;
|
||||
end;
|
||||
//DebugLn(['TToolButton.CalculatePreferredSize ',DbgSName(Self),' ',PreferredWidth,',',PreferredHeight,' Caption=',Caption]);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user