Преглед изворни кода

First hiding right-most Custom Commands toolbar commands that do not fit

(cherry picked from commit 47e8178c0a62fbc673e1bd4e3e498ba5f3d55102)

Source commit: a1b752d8e3405f594903cef1678fa82295766cf9
Martin Prikryl пре 3 година
родитељ
комит
3825991092

+ 15 - 0
source/forms/NonVisual.cpp

@@ -1100,6 +1100,17 @@ void __fastcall TNonVisualDataModule::CustomCommandsCustomize(TObject *)
   PreferencesDialog(pmCustomCommands);
 }
 //---------------------------------------------------------------------------
+static void GiveItemPriority(TTBCustomItem * Item)
+{
+  DebugAssert(Item->GetTopComponent() != NULL);
+  TTBCustomToolbar * ToolbarComponent = dynamic_cast<TTBCustomToolbar *>(Item->GetTopComponent());
+  if (ToolbarComponent != NULL)
+  {
+    TTBItemViewer * Viewer = ToolbarComponent->View->Find(Item);
+    ToolbarComponent->View->GivePriority(Viewer);
+  }
+}
+//---------------------------------------------------------------------------
 void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
   TTBCustomItem * Menu, bool OnFocused, bool Toolbar, TCustomCommandListType ListType, TStrings * HiddenCommands)
 {
@@ -1112,6 +1123,7 @@ void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
     Item = new TTBXItem(Menu);
     Item->Action = OnFocused ? CustomCommandsEnterFocusedAction : CustomCommandsEnterAction;
     Menu->Add(Item);
+    GiveItemPriority(Item);
 
     Item = new TTBXItem(Menu);
     Item->Action = OnFocused ? CustomCommandsLastFocusedAction : CustomCommandsLastAction;
@@ -1120,6 +1132,7 @@ void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
       Item->Caption = EscapeHotkey(StripHotkey(LoadStr(CUSTOM_COMMAND_LAST_SHORT)));
     }
     Menu->Add(Item);
+    GiveItemPriority(Item);
   }
 
   TTBXSeparatorItem * Separator = AddMenuSeparator(Menu);
@@ -1150,6 +1163,7 @@ void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
     Item = new TTBXItem(Menu);
     Item->Action = CustomCommandsBandAction;
     Menu->Add(Item);
+    GiveItemPriority(Item);
   }
 
   Item = new TTBXItem(Menu);
@@ -1160,6 +1174,7 @@ void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
     Item->OnClick = CustomCommandsCustomize;
   }
   Menu->Add(Item);
+  GiveItemPriority(Item);
 }
 //---------------------------------------------------------------------------
 void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(

+ 1 - 0
source/forms/ScpCommander.dfm

@@ -1028,6 +1028,7 @@ inherited ScpCommanderForm: TScpCommanderForm
       Left = 299
       Top = 129
       Caption = 'Custom Commands'
+      ChevronPriorityForNewItems = tbcpLowest
       DockPos = 168
       DockRow = 7
       Images = GlyphsModule.ExplorerImages

+ 1 - 0
source/forms/ScpExplorer.dfm

@@ -1021,6 +1021,7 @@ inherited ScpExplorerForm: TScpExplorerForm
       Left = 299
       Top = 182
       Caption = 'Custom Commands'
+      ChevronPriorityForNewItems = tbcpLowest
       DockPos = 193
       DockRow = 7
       Images = GlyphsModule.ExplorerImages

+ 7 - 0
source/packages/tb2k/TB2Item.pas

@@ -230,6 +230,7 @@ type
     destructor Destroy; override;
     function HasParent: Boolean; override;
     function GetParentComponent: TComponent; override;
+    function GetTopComponent: TComponent;
 
     procedure Add(AItem: TTBCustomItem);
     procedure Clear;
@@ -1421,6 +1422,12 @@ begin
     Result := FParent;
 end;
 
+function TTBCustomItem.GetTopComponent: TComponent;
+begin
+  if Parent <> nil then Result := Parent.GetTopComponent
+    else Result := FParentComponent;
+end;
+
 procedure TTBCustomItem.SetName(const NewName: TComponentName);
 begin
   if Name <> NewName then begin