فهرست منبع

fix dynamic menu creation

circular17 3 سال پیش
والد
کامیت
c8c46f1fb1
2فایلهای تغییر یافته به همراه13 افزوده شده و 15 حذف شده
  1. 0 9
      lazpaint/lazpaintmainform.lfm
  2. 13 6
      lazpaint/umenu.pas

+ 0 - 9
lazpaint/lazpaintmainform.lfm

@@ -5537,11 +5537,9 @@ object FMain: TFMain
     end
     object MenuEdit: TMenuItem
       Caption = 'Edit'
-      Visible = False
     end
     object MenuSelect: TMenuItem
       Caption = 'Select'
-      Visible = False
     end
     object MenuView: TMenuItem
       Caption = 'View'
@@ -5562,7 +5560,6 @@ object FMain: TFMain
     end
     object MenuImage: TMenuItem
       Caption = 'Image'
-      Visible = False
       object MenuRemoveTransparency: TMenuItem
         Caption = 'Remove transparency'
         Visible = False
@@ -5570,15 +5567,12 @@ object FMain: TFMain
     end
     object MenuColors: TMenuItem
       Caption = 'Colors'
-      Visible = False
     end
     object MenuTool: TMenuItem
       Caption = 'Tools'
-      Visible = False
     end
     object MenuFilter: TMenuItem
       Caption = 'Filter'
-      Visible = False
       object MenuRadialBlur: TMenuItem
         Caption = 'Radial blur'
         Visible = False
@@ -5586,15 +5580,12 @@ object FMain: TFMain
     end
     object MenuRender: TMenuItem
       Caption = 'Render'
-      Visible = False
     end
     object MenuScript: TMenuItem
       Caption = 'Script'
-      Visible = False
     end
     object MenuHelp: TMenuItem
       Caption = 'Help'
-      Visible = False
     end
   end
   object TimerHidePenPreview: TTimer

+ 13 - 6
lazpaint/umenu.pas

@@ -17,7 +17,10 @@ type
   private
     FActionList: TActionList;
     FDarkTheme: boolean;
-    FMainMenus: array of TMenuItem;
+    FMainMenus: array of record
+                  menu: TMenuItem;
+                  used: boolean;
+                end;
     FToolsShortcuts: array[TPaintToolType] of TUTF8Char;
     FToolbars: array of record
                  tb: TPanel;
@@ -237,10 +240,10 @@ begin
       break;
     end;
   for i := 0 to high(FMainMenus) do
-    if FMainMenus[i].Name = AMenuName then
+    if FMainMenus[i].menu.Name = AMenuName then
     begin
-      AddMenus(FMainMenus[i], FActionList, AActionsCommaText);
-      FMainMenus[i].Visible := true;
+      AddMenus(FMainMenus[i].menu, FActionList, AActionsCommaText);
+      FMainMenus[i].used := true;
     end;
 end;
 
@@ -388,7 +391,10 @@ var i: NativeInt;
 begin
   setlength(FMainMenus, length(AMainMenus));
   for i := 0 to high(AMainMenus) do
-    FMainMenus[i] := AMainMenus[i];
+  begin
+    FMainMenus[i].menu := AMainMenus[i];
+    FMainMenus[i].used := false;
+  end;
 end;
 
 procedure TMainFormMenu.Toolbars(const AToolbars: array of TPanel; AToolbarBackground: TPanel);
@@ -469,7 +475,8 @@ begin
   AddMenus('MenuScript', 'FileRunScript,-,InstalledScripts');
   AddMenus('MenuHelp',   'HelpIndex,-,HelpAbout');
   for i := 0 to high(FMainMenus) do
-    if FMainMenus[i].Count = 0 then FMainMenus[i].visible := false;
+    if not FMainMenus[i].used then
+       FMainMenus[i].menu.Visible := false;
 
   ApplyShortcuts;