From 92ca2965ac5fafe8c0c8a21aadc64f28f4087c91 Mon Sep 17 00:00:00 2001 From: KoroLion Date: Fri, 4 Sep 2020 11:34:06 +0300 Subject: [PATCH 1/2] Build script for macOS --- .gitignore | 7 ++++- build.mac.sh | 17 +++++++++++ src/gui/gui.pas | 81 +++++++++++++++++++++++++------------------------ 3 files changed, 64 insertions(+), 41 deletions(-) create mode 100755 build.mac.sh diff --git a/.gitignore b/.gitignore index 30d850f..2949329 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,12 @@ +.DS_Store + +build/gui +build/function_imaging +build/multibrot_imaging images/* *.o *.ppu *.exe *.out -*.pdf \ No newline at end of file +*.pdf diff --git a/build.mac.sh b/build.mac.sh new file mode 100755 index 0000000..c8e2935 --- /dev/null +++ b/build.mac.sh @@ -0,0 +1,17 @@ +rm ./build/multibrot_imaging +rm ./build/function_imaging +rm ./build/gui + +cd ./src +fpc multibrot_imaging.pas +mv multibrot_imaging ../build/ +fpc function_imaging.pas +mv function_imaging ../build/ +rm *.o +rm *.ppu + +cd ./gui +fpc gui.pas -Fu/usr/local/Cellar/fpc/3.0.4_1/lib/fpc/3.0.4/units/x86_64-darwin/fv +mv gui ../../build/ +rm *.o +rm *.ppu diff --git a/src/gui/gui.pas b/src/gui/gui.pas index 329a185..7e265af 100644 --- a/src/gui/gui.pas +++ b/src/gui/gui.pas @@ -14,7 +14,7 @@ type centerX: string[64]; centerY: string[64]; end; - + PFnGenerateData = ^TFnGenerateData; TFnGenerateData = record path: string[128]; @@ -25,50 +25,50 @@ type centerX: string[64]; centerY: string[64]; end; - + PGeneratorWindow = ^TGeneratorWindow; TGeneratorWindow = object(TDialog) pGeneratingBtn: PButton; winRect: TRect; curY: integer; - + procedure addField(caption: string; maxLength: integer); function addButton(caption: string; command: integer): PButton; end; - + PMbGeneratorWindow = ^TMbGeneratorWindow; TMbGeneratorWindow = object(TGeneratorWindow) constructor Init; end; - + PFnGeneratorWindow = ^TFnGeneratorWindow; TFnGeneratorWindow = object(TGeneratorWindow) constructor Init; end; - + TMSApp = object(TApplication) MbGeneratorWindow: PMbGeneratorWindow; FnGeneratorWindow: PFnGeneratorWindow; - + procedure InitStatusLine; virtual; procedure InitMenuBar; virtual; procedure HandleEvent(var Event: TEvent); virtual; - + procedure NewMbWindow(); procedure NewFnWindow(); - + procedure GenerateMultibrotSetImage(); procedure GenerateFunctionImage(); - + procedure ShowAbout(); procedure ShowSuccess(fname: string; t: extended); end; - + var MSApp: TMSApp; MbGenerateData: TMbGenerateData; FnGenerateData: TFnGenerateData; - + procedure TMSApp.GenerateMultibrotSetImage(); var s: AnsiString; @@ -77,7 +77,7 @@ var begin MbGeneratorWindow^.GetData(MbGenerateData); startTime := getTimestamp(); - + MbGeneratorWindow^.pGeneratingBtn^.show(); with MbGenerateData do begin success := RunCommand('./multibrot_imaging', [ @@ -91,14 +91,14 @@ begin ], s); end; MbGeneratorWindow^.pGeneratingBtn^.hide(); - + if (success) then begin ShowSuccess(s, (getTimestamp() - startTime) / 1000); end else begin MessageBox( #3'Error'#13 + #3'Unable to execute generator!'#13, - nil, + nil, mfInformation or mfOkButton ); end; @@ -112,7 +112,7 @@ var begin FnGeneratorWindow^.GetData(FnGenerateData); startTime := getTimestamp(); - + FnGeneratorWindow^.pGeneratingBtn^.show(); with FnGenerateData do begin success := RunCommand('./function_imaging', [ @@ -126,14 +126,14 @@ begin ], s); end; FnGeneratorWindow^.pGeneratingBtn^.hide(); - + if (success) then begin ShowSuccess(s, (getTimestamp() - startTime) / 1000); end else begin MessageBox( #3'Error'#13 + #3'Unable to execute generator!'#13, - nil, + nil, mfInformation or mfOkButton ); end; @@ -151,7 +151,7 @@ begin Insert(il); r.assign(2, curY, 13, curY + 1); Insert(New(PLabel, Init(r, caption, il))); - + curY := curY + 2; end; @@ -163,12 +163,12 @@ begin r.assign(3, curY, winRect.b.x - 1, curY + 1); pbtn := New(PButton, Init(r, caption, command, bfNormal)); Insert(pbtn); - + curY := curY + 2; - + addButton := pbtn; end; - + constructor TMbGeneratorWindow.Init(); var r: TRect; @@ -177,10 +177,10 @@ begin inherited Init(r, 'Multibrot generator'); Options := Options or ofCentered; HelpCtx := $F000; - + winRect := r; curY := 2; - + with MbGenerateData do begin path := './multibrot_images'; width := '512'; @@ -190,7 +190,7 @@ begin centerX := '0'; centerY := '0'; end; - + addField('Path:', 128); addField('Width:', 16); addField('Height:', 16); @@ -198,7 +198,7 @@ begin addField('Zoom:', 64); addField('Center X:', 64); addField('Center Y:', 64); - + addButton('Generate', cmMbGenerate); curY := curY - 2; pGeneratingBtn := addButton('Generating...', 0); @@ -213,10 +213,10 @@ begin inherited Init(r, 'Function generator'); Options := Options or ofCentered; HelpCtx := $F000; - + winRect := r; curY := 2; - + with FnGenerateData do begin path := './function_images'; width := '512'; @@ -226,7 +226,7 @@ begin centerX := '0'; centerY := '0'; end; - + addField('Path:', 128); addField('Width:', 16); addField('Height:', 16); @@ -234,7 +234,7 @@ begin addField('Zoom:', 64); addField('Center X:', 64); addField('Center Y:', 64); - + addButton('Generate', cmFnGenerate); curY := curY - 2; pGeneratingBtn := addButton('Generating...', 0); @@ -247,21 +247,21 @@ begin FnGeneratorWindow^.SetData(FnGenerateData); InsertWindow(FnGeneratorWindow); end; - + procedure TMSApp.NewMbWindow(); begin MbGeneratorWindow := New(PMbGeneratorWindow, Init); MbGeneratorWindow^.SetData(MbGenerateData); InsertWindow(MbGeneratorWindow); end; - + procedure TMSApp.ShowAbout(); begin MessageBox( #3'Math images generator'#13 + #3'Developed by Artem K.'#13 + - #3'MF BMSTU 2019 - 2020', - nil, + #3'MF BMSTU 2019 - 2020', + nil, mfInformation or mfOkButton ); end; @@ -272,15 +272,15 @@ begin #3'Image was generated!'#13 + 'File name: ' + fname + #13 + 'Time spent: ' + FloatToStr(t) + ' s', - nil, + nil, mfInformation or mfOkButton ); end; - + procedure TMSApp.HandleEvent(var Event: TEvent); begin inherited HandleEvent(Event); - + if Event.What = evCommand then begin case Event.Command of cmMbNew: begin @@ -316,9 +316,10 @@ begin New(StatusLine, Init(r, NewStatusDef(0, $EFFF, NewStatusKey('~Alt+X~ Exit', kbAltX, cmQuit, - NewStatusKey('~F3~ New', kbF3, cmMbNew, - nil - )), nil) + NewStatusKey('~F3~ New Mb', kbF3, cmMbNew, + NewStatusKey('~F4~ New Fn', kbF4, cmFnNew, + nil + ))), nil) )); end; From 09db08cbd95fe83e3e85739aed9b80b1bd40abb4 Mon Sep 17 00:00:00 2001 From: KoroLion Date: Fri, 4 Sep 2020 11:41:07 +0300 Subject: [PATCH 2/2] Changed quit hotkey (better for macOS, altx doesnt work) --- src/gui/gui.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/gui.pas b/src/gui/gui.pas index 7e265af..15e9d5b 100644 --- a/src/gui/gui.pas +++ b/src/gui/gui.pas @@ -315,7 +315,7 @@ begin r.a.y := r.b.y - 1; New(StatusLine, Init(r, NewStatusDef(0, $EFFF, - NewStatusKey('~Alt+X~ Exit', kbAltX, cmQuit, + NewStatusKey('~F2~ Exit', kbF2, cmQuit, NewStatusKey('~F3~ New Mb', kbF3, cmMbNew, NewStatusKey('~F4~ New Fn', kbF4, cmFnNew, nil