diff options
| author | yum <yum.food.vr@gmail.com> | 2022-12-16 16:04:33 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2022-12-16 16:05:43 -0800 |
| commit | f368e34070331c5c7900d98e10fddccf7c9fd0ff (patch) | |
| tree | 406d940430044ae3bcc244a1cc4ada8a2bc1ef43 | |
| parent | 16ce2bb119c8e6f6d1e48eaa40fb468adc736528 (diff) | |
Add logo
* GUI now shows logo
* Add package.ps1 to generate distributable application bundle
* Rename ~GUI to GUI
* Add ScopeGuard class
| -rw-r--r-- | GUI/.gitignore | 2 | ||||
| -rw-r--r-- | GUI/GUI/.gitignore (renamed from ~GUI/GUI/.gitignore) | 0 | ||||
| -rw-r--r-- | GUI/GUI/GUI.sln (renamed from ~GUI/GUI/GUI.sln) | 0 | ||||
| -rw-r--r-- | GUI/GUI/GUI/.gitignore (renamed from ~GUI/GUI/GUI/.gitignore) | 0 | ||||
| -rw-r--r-- | GUI/GUI/GUI/GUI.vcxproj (renamed from ~GUI/GUI/GUI/GUI.vcxproj) | 7 | ||||
| -rw-r--r-- | GUI/GUI/GUI/GUI.vcxproj.filters (renamed from ~GUI/GUI/GUI/GUI.vcxproj.filters) | 5 | ||||
| -rw-r--r-- | GUI/GUI/GUI/GUI.vcxproj.user (renamed from ~GUI/GUI/GUI/GUI.vcxproj.user) | 0 | ||||
| -rw-r--r-- | GUI/GUI/GUI/ScopeGuard.h | 32 | ||||
| -rw-r--r-- | GUI/GUI/GUI/main.cpp (renamed from ~GUI/GUI/GUI/main.cpp) | 42 | ||||
| -rw-r--r-- | GUI/Libraries/.gitignore (renamed from ~GUI/Libraries/.gitignore) | 0 | ||||
| -rw-r--r-- | GUI/Libraries/fetch.sh (renamed from ~GUI/Libraries/fetch.sh) | 0 | ||||
| -rw-r--r-- | GUI/README.md (renamed from ~GUI/README.md) | 1 | ||||
| -rw-r--r-- | GUI/package.ps1 | 11 | ||||
| -rw-r--r-- | Images/logo.png | bin | 0 -> 194967 bytes |
14 files changed, 79 insertions, 21 deletions
diff --git a/GUI/.gitignore b/GUI/.gitignore new file mode 100644 index 0000000..f327245 --- /dev/null +++ b/GUI/.gitignore @@ -0,0 +1,2 @@ +# ignore generated package directory +TaSTT diff --git a/~GUI/GUI/.gitignore b/GUI/GUI/.gitignore index 7082b1d..7082b1d 100644 --- a/~GUI/GUI/.gitignore +++ b/GUI/GUI/.gitignore diff --git a/~GUI/GUI/GUI.sln b/GUI/GUI/GUI.sln index 5ef5534..5ef5534 100644 --- a/~GUI/GUI/GUI.sln +++ b/GUI/GUI/GUI.sln diff --git a/~GUI/GUI/GUI/.gitignore b/GUI/GUI/GUI/.gitignore index 86c78ae..86c78ae 100644 --- a/~GUI/GUI/GUI/.gitignore +++ b/GUI/GUI/GUI/.gitignore diff --git a/~GUI/GUI/GUI/GUI.vcxproj b/GUI/GUI/GUI/GUI.vcxproj index a19fc5c..e97523c 100644 --- a/~GUI/GUI/GUI/GUI.vcxproj +++ b/GUI/GUI/GUI/GUI.vcxproj @@ -80,6 +80,7 @@ <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
+ <LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -94,6 +95,7 @@ <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
+ <LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -108,6 +110,7 @@ <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
+ <LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -122,6 +125,7 @@ <SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
+ <LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -133,6 +137,9 @@ <ItemGroup>
<ClCompile Include="main.cpp" />
</ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="ScopeGuard.h" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/~GUI/GUI/GUI/GUI.vcxproj.filters b/GUI/GUI/GUI/GUI.vcxproj.filters index 56d4d70..beb1941 100644 --- a/~GUI/GUI/GUI/GUI.vcxproj.filters +++ b/GUI/GUI/GUI/GUI.vcxproj.filters @@ -19,4 +19,9 @@ <Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="ScopeGuard.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ </ItemGroup>
</Project>
\ No newline at end of file diff --git a/~GUI/GUI/GUI/GUI.vcxproj.user b/GUI/GUI/GUI/GUI.vcxproj.user index 0f14913..0f14913 100644 --- a/~GUI/GUI/GUI/GUI.vcxproj.user +++ b/GUI/GUI/GUI/GUI.vcxproj.user diff --git a/GUI/GUI/GUI/ScopeGuard.h b/GUI/GUI/GUI/ScopeGuard.h new file mode 100644 index 0000000..601061c --- /dev/null +++ b/GUI/GUI/GUI/ScopeGuard.h @@ -0,0 +1,32 @@ +#pragma once
+
+#include <functional>
+#include <utility>
+
+class ScopeGuard {
+public:
+ ScopeGuard(std::function<void()>&& cb) : cb_(std::move(cb)), active_(true) {}
+ ~ScopeGuard() {
+ Invoke();
+ }
+
+ ScopeGuard() = delete;
+ ScopeGuard(ScopeGuard&) = delete;
+ ScopeGuard(const ScopeGuard&) = delete;
+ ScopeGuard(ScopeGuard&&) = delete;
+ ScopeGuard& operator=(ScopeGuard&) = delete;
+ ScopeGuard& operator=(const ScopeGuard&) = delete;
+
+ void Cancel() { active_ = false; }
+
+ void Invoke() {
+ if (active_) {
+ cb_();
+ active_ = false;
+ }
+ }
+
+private:
+ const std::function<void()> cb_;
+ bool active_;
+};
diff --git a/~GUI/GUI/GUI/main.cpp b/GUI/GUI/GUI/main.cpp index 491b546..c2e0222 100644 --- a/~GUI/GUI/GUI/main.cpp +++ b/GUI/GUI/GUI/main.cpp @@ -1,12 +1,15 @@ // wxWidgets "Hello World" Program
-// For compilers that support precompilation, includes "wx/wx.h".
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
+#include "ScopeGuard.h"
+
+#include <filesystem>
+
class MyApp : public wxApp
{
public:
@@ -19,6 +22,8 @@ public: MyFrame();
private:
+ wxPNGHandler png_handler_;
+
void OnHello(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
@@ -35,33 +40,28 @@ bool MyApp::OnInit() {
MyFrame* frame = new MyFrame();
frame->Show(true);
+
return true;
}
MyFrame::MyFrame()
- : wxFrame(nullptr, wxID_ANY, "Hello World")
+ : wxFrame(nullptr, wxID_ANY, "TaSTT")
{
- wxMenu* menuFile = new wxMenu;
- menuFile->Append(ID_Hello, "&Hello...\tCtrl-H",
- "Help string shown in status bar for this menu item");
- menuFile->AppendSeparator();
- menuFile->Append(wxID_EXIT);
-
- wxMenu* menuHelp = new wxMenu;
- menuHelp->Append(wxID_ABOUT);
-
- wxMenuBar* menuBar = new wxMenuBar;
- menuBar->Append(menuFile, "&File");
- menuBar->Append(menuHelp, "&Help");
-
- SetMenuBar(menuBar);
-
- CreateStatusBar();
- SetStatusText("Welcome to wxWidgets!");
-
Bind(wxEVT_MENU, &MyFrame::OnHello, this, ID_Hello);
Bind(wxEVT_MENU, &MyFrame::OnAbout, this, wxID_ABOUT);
Bind(wxEVT_MENU, &MyFrame::OnExit, this, wxID_EXIT);
+
+ // wx needs this to be able to load PNGs.
+ wxImage::AddHandler(&png_handler_);
+
+ const std::string logo_path = "Resources/logo.png";
+ if (!std::filesystem::exists(logo_path)) {
+ wxLogFatalError("Logo is missing from %s", logo_path.c_str());
+ }
+ wxBitmap icon_img("Resources/logo.png", wxBITMAP_TYPE_PNG);
+ wxIcon icon;
+ icon.CopyFromBitmap(icon_img);
+ SetIcon(icon);
}
void MyFrame::OnExit(wxCommandEvent& event)
@@ -77,6 +77,6 @@ void MyFrame::OnAbout(wxCommandEvent& event) void MyFrame::OnHello(wxCommandEvent& event)
{
- wxLogMessage("Hello world from wxWidgets!");
+ //wxLogMessage("Hello world from wxWidgets!");
}
diff --git a/~GUI/Libraries/.gitignore b/GUI/Libraries/.gitignore index 214bffb..214bffb 100644 --- a/~GUI/Libraries/.gitignore +++ b/GUI/Libraries/.gitignore diff --git a/~GUI/Libraries/fetch.sh b/GUI/Libraries/fetch.sh index dcf096c..dcf096c 100644 --- a/~GUI/Libraries/fetch.sh +++ b/GUI/Libraries/fetch.sh diff --git a/~GUI/README.md b/GUI/README.md index 5d60af3..51440a0 100644 --- a/~GUI/README.md +++ b/GUI/README.md @@ -7,4 +7,5 @@ 4. Build x64/Release. 5. Open GUI/GUI.sln with Visual Studio 2022. 6. Build x64/Release. +7. Run package.ps1 from powershell. diff --git a/GUI/package.ps1 b/GUI/package.ps1 new file mode 100644 index 0000000..639848d --- /dev/null +++ b/GUI/package.ps1 @@ -0,0 +1,11 @@ +$install_dir = "TaSTT"
+
+if (Test-Path $install_dir) {
+ rm -Recurse $install_dir
+}
+
+mkdir $install_dir > $null
+mkdir $install_dir/Resources > $null
+cp ../Images/logo.png TaSTT/Resources
+cp GUI/x64/Release/GUI.exe TaSTT/TaSTT.exe
+
diff --git a/Images/logo.png b/Images/logo.png Binary files differnew file mode 100644 index 0000000..4d86109 --- /dev/null +++ b/Images/logo.png |
