Przeglądaj źródła

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

Source commit: 38bac3cd25805291ee1d256725cf47a59c02f1b2
Martin Prikryl 3 lat temu
rodzic
commit
47e8178c0a

+ 15 - 0
source/forms/NonVisual.cpp

@@ -1145,6 +1145,17 @@ void __fastcall TNonVisualDataModule::CustomCommandsCustomize(TObject *)
   PreferencesDialog(pmCustomCommands);
   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(
 void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
   TTBCustomItem * Menu, bool OnFocused, bool Toolbar, TCustomCommandListType ListType, TStrings * HiddenCommands)
   TTBCustomItem * Menu, bool OnFocused, bool Toolbar, TCustomCommandListType ListType, TStrings * HiddenCommands)
 {
 {
@@ -1157,6 +1168,7 @@ void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
     Item = new TTBXItem(Menu);
     Item = new TTBXItem(Menu);
     Item->Action = OnFocused ? CustomCommandsEnterFocusedAction : CustomCommandsEnterAction;
     Item->Action = OnFocused ? CustomCommandsEnterFocusedAction : CustomCommandsEnterAction;
     Menu->Add(Item);
     Menu->Add(Item);
+    GiveItemPriority(Item);
 
 
     Item = new TTBXItem(Menu);
     Item = new TTBXItem(Menu);
     Item->Action = OnFocused ? CustomCommandsLastFocusedAction : CustomCommandsLastAction;
     Item->Action = OnFocused ? CustomCommandsLastFocusedAction : CustomCommandsLastAction;
@@ -1165,6 +1177,7 @@ void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
       Item->Caption = EscapeHotkey(StripHotkey(LoadStr(CUSTOM_COMMAND_LAST_SHORT)));
       Item->Caption = EscapeHotkey(StripHotkey(LoadStr(CUSTOM_COMMAND_LAST_SHORT)));
     }
     }
     Menu->Add(Item);
     Menu->Add(Item);
+    GiveItemPriority(Item);
   }
   }
 
 
   TTBXSeparatorItem * Separator = AddMenuSeparator(Menu);
   TTBXSeparatorItem * Separator = AddMenuSeparator(Menu);
@@ -1195,6 +1208,7 @@ void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
     Item = new TTBXItem(Menu);
     Item = new TTBXItem(Menu);
     Item->Action = CustomCommandsBandAction;
     Item->Action = CustomCommandsBandAction;
     Menu->Add(Item);
     Menu->Add(Item);
+    GiveItemPriority(Item);
   }
   }
 
 
   Item = new TTBXItem(Menu);
   Item = new TTBXItem(Menu);
@@ -1205,6 +1219,7 @@ void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
     Item->OnClick = CustomCommandsCustomize;
     Item->OnClick = CustomCommandsCustomize;
   }
   }
   Menu->Add(Item);
   Menu->Add(Item);
+  GiveItemPriority(Item);
 }
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
 void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(

+ 1 - 0
source/forms/ScpCommander.dfm

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

+ 1 - 0
source/forms/ScpExplorer.dfm

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

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

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