Browse Source

Commands that do not fit on Custom Commands toolbar are presented in drop down menu, instead of a horizontal bar

Implementation of Bug 554: Improve layout of custom commands toolbar for large number of commands

Source commit: d1afec6d9c83c98b0b35cdc5696b145ed1badc6f
Martin Prikryl 3 years ago
parent
commit
2f2644f47d

+ 1 - 0
source/forms/ScpCommander.dfm

@@ -1056,6 +1056,7 @@ inherited ScpCommanderForm: TScpCommanderForm
       Left = 299
       Top = 129
       Caption = 'Custom Commands'
+      ChevronMenu = True
       ChevronPriorityForNewItems = tbcpLowest
       DockPos = 168
       DockRow = 7

+ 1 - 0
source/forms/ScpExplorer.dfm

@@ -1027,6 +1027,7 @@ inherited ScpExplorerForm: TScpExplorerForm
       Left = 299
       Top = 182
       Caption = 'Custom Commands'
+      ChevronMenu = True
       ChevronPriorityForNewItems = tbcpLowest
       DockPos = 193
       DockRow = 7

+ 10 - 3
source/packages/tb2k/TB2Item.pas

@@ -883,7 +883,7 @@ function ProcessDoneAction(const DoneActionData: TTBDoneActionData;
 implementation
 
 uses
-  MMSYSTEM, TB2Consts, TB2Common, IMM, TB2Acc, Winapi.oleacc, Types, PasTools, Generics.Collections;
+  MMSYSTEM, TB2Consts, TB2Common, IMM, TB2Acc, Winapi.oleacc, Types, PasTools, Generics.Collections, TB2Toolbar;
 
 var
   LastPos: TPoint;
@@ -1929,6 +1929,7 @@ var
   EventItem, ParentItem: TTBCustomItem;
   Opposite: Boolean;
   ChevronParentView: TTBView;
+  ChevronMenu: Boolean;
   X, Y, W, H: Integer;
   P: TPoint;
   ParentItemRect: TRect;
@@ -1942,10 +1943,16 @@ begin
   DoPopup(Self, False);
 
   ChevronParentView := GetChevronParentView;
+  ChevronMenu := False; // shut up
   if ChevronParentView = nil then
     ParentItem := Self
-  else
+  else begin
     ParentItem := ChevronParentView.FParentItem;
+    Assert(ParentItem.ParentComponent is TTBCustomToolbar);
+    ChevronMenu :=
+      (ParentItem.ParentComponent is TTBCustomToolbar) and
+      TTBCustomToolbar(ParentItem.ParentComponent).ChevronMenu;
+  end;
 
   Opposite := Assigned(ParentView) and (vsOppositePopup in ParentView.FState);
   Result := GetPopupWindowClass.CreatePopupWindow(nil, ParentView, ParentItem,
@@ -1954,7 +1961,7 @@ begin
     if Assigned(ChevronParentView) then begin
       ChevronParentView.FreeNotification(Result.View);
       Result.View.FChevronParentView := ChevronParentView;
-      Result.View.FIsToolbar := True;
+      Result.View.FIsToolbar := not ChevronMenu;
       Result.View.Style := Result.View.Style +
         (ChevronParentView.Style * [vsAlwaysShowHints]);
       Result.Color := clBtnFace;

+ 4 - 0
source/packages/tb2k/TB2Toolbar.pas

@@ -68,6 +68,7 @@ type
     FBaseSize: TPoint;
     FChevronItem: TTBChevronItem;
     FChevronMoveItems: Boolean;
+    FChevronMenu: Boolean;
     FChevronPriorityForNewItems: TTBChevronPriorityForNewItems;
     FDisableAlignArrange: Integer;
     FFloatingWidth: Integer;
@@ -179,6 +180,7 @@ type
 
     property ChevronHint: String read GetChevronHint write SetChevronHint stored IsChevronHintStored;
     property ChevronMoveItems: Boolean read FChevronMoveItems write SetChevronMoveItems default True;
+    property ChevronMenu: Boolean read FChevronMenu write FChevronMenu default False;
     property ChevronPriorityForNewItems: TTBChevronPriorityForNewItems read FChevronPriorityForNewItems
       write SetChevronPriorityForNewItems default tbcpHighest;
     property FloatingWidth: Integer read FFloatingWidth write SetFloatingWidth default 0;
@@ -208,6 +210,7 @@ type
     property Caption;
     property ChevronHint;
     property ChevronMoveItems;
+    property ChevronMenu;
     property ChevronPriorityForNewItems;
     property CloseButton;
     property CloseButtonWhenDocked;
@@ -549,6 +552,7 @@ begin
   FChevronItem := GetChevronItemClass.Create(Self);
   FChevronItem.LinkSubitems := FItem;
   FChevronMoveItems := True;
+  FChevronMenu := False;
   FView := GetViewClass.CreateView(Self, nil, FItem, Self, True, False,
     not(csDesigning in ComponentState));
   // This might as well go to TTBToolbarView.Create

+ 8 - 1
source/packages/tbx/TBX.pas

@@ -350,6 +350,7 @@ type
     property Caption;
     property ChevronHint;
     property ChevronMoveItems;
+    property ChevronMenu;
     property ChevronPriorityForNewItems;
     property CloseButton;
     property CloseButtonWhenDocked;
@@ -2036,7 +2037,13 @@ begin
     HorzLine := (IsVertical xor LineSep) or View.IsPopup;
     if (((ViewType and VT_POPUP) = VT_POPUP) and
       ((ViewType and PVT_CHEVRONMENU) = PVT_CHEVRONMENU)) then
-      HorzLine := (HorzLine and LineSep);
+    begin
+      if (not (Item.GetTopComponent is TTBCustomToolbar)) or
+         (not TTBCustomToolbar(Item.GetTopComponent).ChevronMenu) then
+      begin
+        HorzLine := (HorzLine and LineSep);
+      end;
+    end;
   end;
   CurrentTheme.PaintSeparator(Canvas, R, ItemInfo, HorzLine, LineSep);
 end;