mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 18:59:19 +02:00
lcl: toolbar improvements
- correctly restore button position after width change (bug #0012031) - don't allocate width for invisible controls on the toolbar, notify toolbar when toolbutton visibility changes (mentioned in the bug #0012031) git-svn-id: trunk@18482 -
This commit is contained in:
parent
6fd6f8e904
commit
7fd30ae31e
@ -1402,6 +1402,7 @@ type
|
|||||||
procedure SetWrap(Value: Boolean);
|
procedure SetWrap(Value: Boolean);
|
||||||
procedure SetMouseInControl(NewMouseInControl: Boolean);
|
procedure SetMouseInControl(NewMouseInControl: Boolean);
|
||||||
procedure CMEnabledChanged(var Message: TLMEssage); message CM_ENABLEDCHANGED;
|
procedure CMEnabledChanged(var Message: TLMEssage); message CM_ENABLEDCHANGED;
|
||||||
|
procedure CMVisibleChanged(var Message: TLMessage); message CM_VISIBLECHANGED;
|
||||||
procedure CMHitTest(var Message: TCMHitTest); message CM_HITTEST;
|
procedure CMHitTest(var Message: TCMHitTest); message CM_HITTEST;
|
||||||
protected
|
protected
|
||||||
FToolBar: TToolBar;
|
FToolBar: TToolBar;
|
||||||
|
@ -36,27 +36,14 @@ begin
|
|||||||
|
|
||||||
Row1 := (Control1.Top + HalfBtnHeight) div BtnHeight;
|
Row1 := (Control1.Top + HalfBtnHeight) div BtnHeight;
|
||||||
Row2 := (Control2.Top + HalfBtnHeight) div BtnHeight;
|
Row2 := (Control2.Top + HalfBtnHeight) div BtnHeight;
|
||||||
if Row1 < Row2 then
|
Result := CompareValue(Row1, Row2);
|
||||||
Result := -1
|
if Result = 0 then
|
||||||
else
|
Result := CompareValue(Control1.Left, Control2.Left);
|
||||||
if Row1 > Row2 then
|
if Result = 0 then
|
||||||
Result :=1
|
|
||||||
else
|
|
||||||
if Control1.Left < Control2.Left then
|
|
||||||
Result := -1
|
|
||||||
else
|
|
||||||
if Control1.Left > Control2.Left then
|
|
||||||
Result := 1
|
|
||||||
else
|
|
||||||
begin
|
begin
|
||||||
Row1 := ToolBar.GetControlIndex(Control1);
|
Row1 := ToolBar.GetControlIndex(Control1);
|
||||||
Row2 := ToolBar.GetControlIndex(Control2);
|
Row2 := ToolBar.GetControlIndex(Control2);
|
||||||
// buttons order is reversed, iow last addeted button will be first
|
Result := CompareValue(Row1, Row2);
|
||||||
if Row1 < Row2 then
|
|
||||||
Result := 1
|
|
||||||
else
|
|
||||||
if Row1 > Row2 then
|
|
||||||
Result := -1
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -580,11 +567,11 @@ begin
|
|||||||
StartX:=ARect.Left;
|
StartX:=ARect.Left;
|
||||||
x:=StartX;
|
x:=StartX;
|
||||||
y:=ARect.Top;
|
y:=ARect.Top;
|
||||||
i:=0;
|
for i := 0 to OrderedControls.Count - 1 do
|
||||||
while i<OrderedControls.Count do
|
|
||||||
begin
|
begin
|
||||||
CurControl := TControl(OrderedControls[i]);
|
CurControl := TControl(OrderedControls[i]);
|
||||||
|
if not CurControl.Visible then
|
||||||
|
Continue;
|
||||||
CalculatePosition;
|
CalculatePosition;
|
||||||
//DebugLn('WrapButtons ',CurControl.Name,':',CurControl.ClassName,' ',x,',',y,',',CurControl.Width,',',CurControl.Height);
|
//DebugLn('WrapButtons ',CurControl.Name,':',CurControl.ClassName,' ',x,',',y,',',CurControl.Width,',',CurControl.Height);
|
||||||
if ButtonHeight <= 0
|
if ButtonHeight <= 0
|
||||||
@ -622,8 +609,6 @@ begin
|
|||||||
x:=StartX;
|
x:=StartX;
|
||||||
inc(y,ButtonHeight);
|
inc(y,ButtonHeight);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
inc(i);
|
|
||||||
end;
|
end;
|
||||||
FRealizedButtonHeight:=FButtonHeight;
|
FRealizedButtonHeight:=FButtonHeight;
|
||||||
finally
|
finally
|
||||||
|
@ -620,6 +620,12 @@ begin
|
|||||||
invalidate;
|
invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TToolButton.CMVisibleChanged(var Message: TLMessage);
|
||||||
|
begin
|
||||||
|
if FToolBar <> nil then
|
||||||
|
RefreshControl;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TToolButton.BeginUpdate;
|
procedure TToolButton.BeginUpdate;
|
||||||
begin
|
begin
|
||||||
Inc(FUpdateCount);
|
Inc(FUpdateCount);
|
||||||
|
Loading…
Reference in New Issue
Block a user