|
@@ -27,17 +27,21 @@ type
|
|
FImageList: TImageList;
|
|
FImageList: TImageList;
|
|
procedure IconSizeItemClick(Sender: TObject);
|
|
procedure IconSizeItemClick(Sender: TObject);
|
|
procedure IconSizeMenuClick(Sender: TObject);
|
|
procedure IconSizeMenuClick(Sender: TObject);
|
|
|
|
+ procedure Script_Click(Sender: TObject);
|
|
procedure SetDarkTheme(AValue: boolean);
|
|
procedure SetDarkTheme(AValue: boolean);
|
|
protected
|
|
protected
|
|
FInstance: TLazPaintCustomInstance;
|
|
FInstance: TLazPaintCustomInstance;
|
|
|
|
+ FInstalledScripts: TStringList;
|
|
procedure AddMenus(AMenu: TMenuItem; AActionList: TActionList; AActionsCommaText: string; AIndex: integer = -1); overload;
|
|
procedure AddMenus(AMenu: TMenuItem; AActionList: TActionList; AActionsCommaText: string; AIndex: integer = -1); overload;
|
|
procedure AddMenus(AMenuName: string; AActionsCommaText: string); overload;
|
|
procedure AddMenus(AMenuName: string; AActionsCommaText: string); overload;
|
|
|
|
+ procedure AddInstalledScripts(AMenu: TMenuItem; AIndex: integer = -1);
|
|
procedure ApplyShortcuts;
|
|
procedure ApplyShortcuts;
|
|
procedure ActionShortcut(AName: string; AShortcut: TUTF8Char);
|
|
procedure ActionShortcut(AName: string; AShortcut: TUTF8Char);
|
|
procedure ApplyTheme;
|
|
procedure ApplyTheme;
|
|
function GetIndividualToolbarHeight: integer;
|
|
function GetIndividualToolbarHeight: integer;
|
|
public
|
|
public
|
|
constructor Create(AInstance: TLazPaintCustomInstance; AActionList: TActionList);
|
|
constructor Create(AInstance: TLazPaintCustomInstance; AActionList: TActionList);
|
|
|
|
+ destructor Destroy; override;
|
|
procedure PredefinedMainMenus(const AMainMenus: array of TMenuItem);
|
|
procedure PredefinedMainMenus(const AMainMenus: array of TMenuItem);
|
|
procedure Toolbars(const AToolbars: array of TPanel; AToolbarBackground: TPanel);
|
|
procedure Toolbars(const AToolbars: array of TPanel; AToolbarBackground: TPanel);
|
|
procedure CycleTool(var ATool: TPaintToolType; var AShortCut: TUTF8Char);
|
|
procedure CycleTool(var ATool: TPaintToolType; var AShortCut: TUTF8Char);
|
|
@@ -53,7 +57,8 @@ implementation
|
|
|
|
|
|
uses UResourceStrings, BGRAUTF8, LCScaleDPI, ComCtrls, Graphics,
|
|
uses UResourceStrings, BGRAUTF8, LCScaleDPI, ComCtrls, Graphics,
|
|
StdCtrls, BGRAText, math, udarktheme,
|
|
StdCtrls, BGRAText, math, udarktheme,
|
|
- ugraph, BGRABitmapTypes, LCVectorialFillControl;
|
|
|
|
|
|
+ ugraph, BGRABitmapTypes, LCVectorialFillControl,
|
|
|
|
+ UPython;
|
|
|
|
|
|
{ TMainFormMenu }
|
|
{ TMainFormMenu }
|
|
|
|
|
|
@@ -68,6 +73,19 @@ begin
|
|
menu.Items[i].Checked := (menu.Items[i].Tag = iconSize);
|
|
menu.Items[i].Checked := (menu.Items[i].Tag = iconSize);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TMainFormMenu.Script_Click(Sender: TObject);
|
|
|
|
+var
|
|
|
|
+ item: TMenuItem;
|
|
|
|
+ scriptIndex: integer;
|
|
|
|
+begin
|
|
|
|
+ if Assigned(FInstalledScripts) then
|
|
|
|
+ begin
|
|
|
|
+ item := Sender as TMenuItem;
|
|
|
|
+ scriptIndex := item.Tag;
|
|
|
|
+ FInstance.RunScript(FInstalledScripts[scriptIndex]);
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TMainFormMenu.SetDarkTheme(AValue: boolean);
|
|
procedure TMainFormMenu.SetDarkTheme(AValue: boolean);
|
|
begin
|
|
begin
|
|
if FDarkTheme=AValue then Exit;
|
|
if FDarkTheme=AValue then Exit;
|
|
@@ -124,6 +142,11 @@ begin
|
|
AIndex := -1;
|
|
AIndex := -1;
|
|
Continue;
|
|
Continue;
|
|
end;
|
|
end;
|
|
|
|
+ if actions[i]='InstalledScripts' then
|
|
|
|
+ begin
|
|
|
|
+ AddInstalledScripts(AMenu, AIndex);
|
|
|
|
+ continue;
|
|
|
|
+ end;
|
|
item := TMenuItem.Create(nil);
|
|
item := TMenuItem.Create(nil);
|
|
if trim(actions[i]) = '-' then
|
|
if trim(actions[i]) = '-' then
|
|
item.Caption := cLineCaption
|
|
item.Caption := cLineCaption
|
|
@@ -216,6 +239,43 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TMainFormMenu.AddInstalledScripts(AMenu: TMenuItem; AIndex: integer);
|
|
|
|
+var
|
|
|
|
+ path, fullname, header, title: String;
|
|
|
|
+ searchRec: TSearchRec;
|
|
|
|
+ t: textFile;
|
|
|
|
+ item: TMenuItem;
|
|
|
|
+begin
|
|
|
|
+ if FInstalledScripts = nil then FInstalledScripts := TStringList.Create;
|
|
|
|
+ path := TPythonScript.DefaultScriptDirectory;
|
|
|
|
+ if FindFirstUTF8(path+PathDelim+'*.py', faAnyFile, searchRec)=0 then
|
|
|
|
+ begin
|
|
|
|
+ try
|
|
|
|
+ repeat
|
|
|
|
+ fullname := path+PathDelim+searchRec.Name;
|
|
|
|
+ if FileExistsUTF8(fullname) then
|
|
|
|
+ begin
|
|
|
|
+ assignFile(t, fullname);
|
|
|
|
+ reset(t);
|
|
|
|
+ readln(t, header);
|
|
|
|
+ closefile(t);
|
|
|
|
+ if header.StartsWith('#') then
|
|
|
|
+ begin
|
|
|
|
+ title := header.Substring(1).Trim;
|
|
|
|
+ item := TMenuItem.Create(AMenu);
|
|
|
|
+ item.Caption := title;
|
|
|
|
+ item.Tag := FInstalledScripts.Add(fullname);
|
|
|
|
+ item.OnClick:=@Script_Click;
|
|
|
|
+ AMenu.Add(item);
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+ until FindNextUTF8(searchRec)<>0;
|
|
|
|
+ finally
|
|
|
|
+ FindCloseUTF8(searchRec);
|
|
|
|
+ end;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TMainFormMenu.ActionShortcut(AName: string; AShortcut: TUTF8Char);
|
|
procedure TMainFormMenu.ActionShortcut(AName: string; AShortcut: TUTF8Char);
|
|
var foundAction: TBasicAction;
|
|
var foundAction: TBasicAction;
|
|
ShortcutStr: string;
|
|
ShortcutStr: string;
|
|
@@ -280,6 +340,12 @@ begin
|
|
FToolbarsHeight := 0;
|
|
FToolbarsHeight := 0;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+destructor TMainFormMenu.Destroy;
|
|
|
|
+begin
|
|
|
|
+ FInstalledScripts.Free;
|
|
|
|
+ inherited Destroy;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TMainFormMenu.PredefinedMainMenus(const AMainMenus: array of TMenuItem);
|
|
procedure TMainFormMenu.PredefinedMainMenus(const AMainMenus: array of TMenuItem);
|
|
var i: NativeInt;
|
|
var i: NativeInt;
|
|
begin
|
|
begin
|
|
@@ -343,7 +409,7 @@ begin
|
|
with FActionList.Actions[i] as TAction do
|
|
with FActionList.Actions[i] as TAction do
|
|
if (Caption = '') and (Hint <> '') then Caption := Hint;
|
|
if (Caption = '') and (Hint <> '') then Caption := Hint;
|
|
|
|
|
|
- AddMenus('MenuFile', 'FileNew,FileOpen,LayerFromFile,FileChooseEntry,FileReload,MenuRecentFiles,-,FileSave,FileSaveAsInSameFolder,FileSaveAs,FileExport,-,FileRunScript,FileImport3D,-,FilePrint,-,'+ImageBrowser+'FileRememberSaveFormat,ForgetDialogAnswers,MenuLanguage,*');
|
|
|
|
|
|
+ AddMenus('MenuFile', 'FileNew,FileOpen,LayerFromFile,FileChooseEntry,FileReload,MenuRecentFiles,-,FileSave,FileSaveAsInSameFolder,FileSaveAs,FileExport,-,FileImport3D,-,FilePrint,-,'+ImageBrowser+'FileRememberSaveFormat,ForgetDialogAnswers,MenuLanguage,*');
|
|
AddMenus('MenuEdit', 'EditUndo,EditRedo,-,EditCut,EditCopy,EditPaste,EditPasteAsNew,EditPasteAsNewLayer,EditDeleteSelection,-,EditMoveUp,EditMoveToFront,EditMoveDown,EditMoveToBack,EditShapeAlign,EditShapeToCurve');
|
|
AddMenus('MenuEdit', 'EditUndo,EditRedo,-,EditCut,EditCopy,EditPaste,EditPasteAsNew,EditPasteAsNewLayer,EditDeleteSelection,-,EditMoveUp,EditMoveToFront,EditMoveDown,EditMoveToBack,EditShapeAlign,EditShapeToCurve');
|
|
AddMenus('MenuSelect', 'EditSelection,FileLoadSelection,FileSaveSelectionAs,-,EditSelectAll,EditInvertSelection,EditSelectionFit,EditDeselect,-,ToolSelectRect,ToolSelectEllipse,ToolSelectPoly,ToolSelectSpline,-,ToolMoveSelection,ToolRotateSelection,SelectionHorizontalFlip,SelectionVerticalFlip,-,ToolSelectPen,ToolMagicWand');
|
|
AddMenus('MenuSelect', 'EditSelection,FileLoadSelection,FileSaveSelectionAs,-,EditSelectAll,EditInvertSelection,EditSelectionFit,EditDeselect,-,ToolSelectRect,ToolSelectEllipse,ToolSelectPoly,ToolSelectSpline,-,ToolMoveSelection,ToolRotateSelection,SelectionHorizontalFlip,SelectionVerticalFlip,-,ToolSelectPen,ToolMagicWand');
|
|
AddMenus('MenuView', 'ViewGrid,ViewZoomOriginal,ViewZoomIn,ViewZoomOut,ViewZoomFit,-,ViewToolBox,ViewColors,ViewPalette,ViewLayerStack,ViewImageList,ViewStatusBar,-,*,-,ViewDarkTheme,ViewWorkspaceColor,MenuIconSize');
|
|
AddMenus('MenuView', 'ViewGrid,ViewZoomOriginal,ViewZoomIn,ViewZoomOut,ViewZoomFit,-,ViewToolBox,ViewColors,ViewPalette,ViewLayerStack,ViewImageList,ViewStatusBar,-,*,-,ViewDarkTheme,ViewWorkspaceColor,MenuIconSize');
|
|
@@ -354,6 +420,7 @@ begin
|
|
AddMenus('MenuColors', 'ColorCurves,ColorPosterize,ColorColorize,ColorShiftColors,FilterComplementaryColor,ColorIntensity,-,ColorLightness,FilterNegative,FilterLinearNegative,FilterNormalize,FilterGrayscale');
|
|
AddMenus('MenuColors', 'ColorCurves,ColorPosterize,ColorColorize,ColorShiftColors,FilterComplementaryColor,ColorIntensity,-,ColorLightness,FilterNegative,FilterLinearNegative,FilterNormalize,FilterGrayscale');
|
|
AddMenus('MenuTool', 'ToolHand,ToolHotSpot,ToolColorPicker,-,ToolPen,ToolBrush,ToolEraser,ToolFloodFill,ToolClone,-,ToolEditShape,ToolRect,ToolEllipse,ToolPolyline,ToolOpenedCurve,ToolPolygon,ToolSpline,ToolGradient,ToolPhong,ToolText,-,ToolDeformation,ToolTextureMapping');
|
|
AddMenus('MenuTool', 'ToolHand,ToolHotSpot,ToolColorPicker,-,ToolPen,ToolBrush,ToolEraser,ToolFloodFill,ToolClone,-,ToolEditShape,ToolRect,ToolEllipse,ToolPolyline,ToolOpenedCurve,ToolPolygon,ToolSpline,ToolGradient,ToolPhong,ToolText,-,ToolDeformation,ToolTextureMapping');
|
|
AddMenus('MenuRender', 'RenderPerlinNoise,RenderCyclicPerlinNoise,-,RenderWater,RenderCustomWater,RenderSnowPrint,RenderWood,RenderWoodVertical,RenderMetalFloor,RenderPlastik,RenderStone,RenderRoundStone,RenderMarble,RenderCamouflage,-,RenderClouds,FilterRain');
|
|
AddMenus('MenuRender', 'RenderPerlinNoise,RenderCyclicPerlinNoise,-,RenderWater,RenderCustomWater,RenderSnowPrint,RenderWood,RenderWoodVertical,RenderMetalFloor,RenderPlastik,RenderStone,RenderRoundStone,RenderMarble,RenderCamouflage,-,RenderClouds,FilterRain');
|
|
|
|
+ AddMenus('MenuScript', 'FileRunScript,-,InstalledScripts');
|
|
AddMenus('MenuHelp', 'HelpIndex,-,HelpAbout');
|
|
AddMenus('MenuHelp', 'HelpIndex,-,HelpAbout');
|
|
for i := 0 to high(FMainMenus) do
|
|
for i := 0 to high(FMainMenus) do
|
|
if FMainMenus[i].Count = 0 then FMainMenus[i].visible := false;
|
|
if FMainMenus[i].Count = 0 then FMainMenus[i].visible := false;
|