diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9f1e0072f..187811c48 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -147,7 +147,7 @@ include_directories(${Boost_INCLUDE_DIRS}) set(wxWidgets_USE_STATIC OFF) set(wxWidgets_USE_UNICODE ON) -find_package(wxWidgets COMPONENTS base aui core) +find_package(wxWidgets COMPONENTS base aui core html) IF(CMAKE_HOST_UNIX) #set(Boost_LIBRARIES bsystem bthread bfilesystem) @@ -165,6 +165,7 @@ IF(wxWidgets_FOUND) ${GUI_LIBDIR}/MainFrame.cpp ${GUI_LIBDIR}/GUI.cpp ${GUI_LIBDIR}/Settings.cpp + ${GUI_LIBDIR}/AboutDialog.cpp ${GUI_LIBDIR}/misc_ui.cpp ) #only build GUI lib if building with wx diff --git a/src/GUI/AboutDialog.cpp b/src/GUI/AboutDialog.cpp new file mode 100644 index 000000000..91a7b224a --- /dev/null +++ b/src/GUI/AboutDialog.cpp @@ -0,0 +1,98 @@ +#include "AboutDialog.hpp" + +namespace Slic3r { namespace GUI { + +static void link_clicked(wxHtmlLinkEvent& e) +{ + wxLaunchDefaultBrowser(e.GetLinkInfo().GetHref()); + e.Skip(0); +} + +AboutDialog::AboutDialog(wxWindow* parent) : wxDialog(parent, -1, _("About Slic3r"), wxDefaultPosition, wxSize(600, 460), wxCAPTION) +{ + auto hsizer { new wxBoxSizer(wxHORIZONTAL) } ; + + auto vsizer { new wxBoxSizer(wxVERTICAL) } ; + + // logo + auto logo { new AboutDialogLogo(this) }; + hsizer->Add(logo, 0, wxEXPAND | wxLEFT | wxRIGHT, 30); + + // title + auto title { new wxStaticText(this, -1, "Slic3r", wxDefaultPosition, wxDefaultSize) }; + auto title_font { wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; + + title_font.SetWeight(wxFONTWEIGHT_BOLD); + title_font.SetFamily(wxFONTFAMILY_ROMAN); + title_font.SetPointSize(24); + title->SetFont(title_font); + + vsizer->Add(title, 0, wxALIGN_LEFT | wxTOP, 30); + + // version + + auto version {new wxStaticText(this, -1, wxString("Version ") + wxString(SLIC3R_VERSION), wxDefaultPosition, wxDefaultSize) }; + auto version_font { wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT) }; + version_font.SetPointSize((the_os == OS::Windows ? 9 : 11)); + version->SetFont(version_font); + vsizer->Add(version, 0, wxALIGN_LEFT | wxBOTTOM, 10); + + // text + + wxString text {""}; + text << "" + << "" + << "Copyright © 2011-2017 Alessandro Ranellucci.
" + << "Slic3r is licensed under the " + << "GNU Affero General Public License, version 3." + << "


" + << "Contributions by Henrik Brix Andersen, Vojtech Bubnik, Nicolas Dandrimont, Mark Hindess, " + << "Petr Ledvina, Joseph Lenox, Y. Sapir, Mike Sheldrake, Kliment Yanev and numerous others. " + << "Manual by Gary Hodgson. Inspired by the RepRap community.
" + << "Slic3r logo designed by Corey Daniels, Silk Icon Set designed by Mark James. " + << "

" + << "Built on " << build_date << " at git version " << git_version << "." + << "" + << ""; + auto html {new wxHtmlWindow(this, -1, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_NEVER)}; + html->SetBorders(2); + html->SetPage(text); + + html->Bind(wxEVT_HTML_LINK_CLICKED, [=](wxHtmlLinkEvent& e){ link_clicked(e); }); + + vsizer->Add(html, 1, wxEXPAND | wxALIGN_LEFT | wxRIGHT | wxBOTTOM, 20); + // buttons + auto buttons = this->CreateStdDialogButtonSizer(wxOK); + this->SetEscapeId(wxID_CLOSE); + + vsizer->Add(buttons, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3); + + hsizer->Add(vsizer, 1, wxEXPAND, 0); + this->SetSizer(hsizer); + + }; + +AboutDialogLogo::AboutDialogLogo(wxWindow* parent) : + wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize) +{ + this->logo = wxBitmap(var("Slic3r_192px.png"), wxBITMAP_TYPE_PNG); + this->SetMinSize(wxSize(this->logo.GetWidth(), this->logo.GetHeight())); + + this->Bind(wxEVT_PAINT, [=](wxPaintEvent& e) { this->repaint(e);}); +} + +void AboutDialogLogo::repaint(wxPaintEvent& event) +{ + auto dc { new wxPaintDC(this) }; + + dc->SetBackgroundMode(wxPENSTYLE_TRANSPARENT); + + const auto size {this->GetSize()}; + const auto logo_w {this->logo.GetWidth()}; + const auto logo_h {this->logo.GetHeight()}; + + dc->DrawBitmap(this->logo, (size.GetWidth() - logo_w) / 2, (size.GetHeight() - logo_h) / 2, 1); + event.Skip(); +} + +}} // namespace Slic3r::GUI diff --git a/src/GUI/AboutDialog.hpp b/src/GUI/AboutDialog.hpp new file mode 100644 index 000000000..40637a091 --- /dev/null +++ b/src/GUI/AboutDialog.hpp @@ -0,0 +1,41 @@ +#ifndef ABOUTDIALOG_HPP +#define ABOUTDIALOG_HPP +#include +#include +#include +#include +#include +#include +#include + +#include "libslic3r.h" +#include "misc_ui.hpp" + +#ifndef SLIC3R_BUILD_COMMIT +#define SLIC3R_BUILD_COMMIT "(Unknown revision)" +#endif + +namespace Slic3r { namespace GUI { + +const wxString build_date {__DATE__}; +const wxString git_version {SLIC3R_BUILD_COMMIT}; + +class AboutDialogLogo : public wxPanel { +private: + wxBitmap logo; +public: + AboutDialogLogo(wxWindow* parent); + void repaint(wxPaintEvent& event); +}; + +class AboutDialog : public wxDialog { +public: + /// Build and show the About popup. + AboutDialog(wxWindow* parent); +}; + + + +}} // namespace Slic3r::GUI + +#endif // ABOUTDIALOG_HPP diff --git a/src/GUI/MainFrame.cpp b/src/GUI/MainFrame.cpp index f006423b1..6c0221687 100644 --- a/src/GUI/MainFrame.cpp +++ b/src/GUI/MainFrame.cpp @@ -3,6 +3,8 @@ #include #include +#include "AboutDialog.hpp" + namespace Slic3r { namespace GUI { wxBEGIN_EVENT_TABLE(MainFrame, wxFrame) @@ -151,6 +153,9 @@ void MainFrame::init_menubar() }); append_menu_item(menuHelp, _("&About Slic3r"), _("Show about dialog"), [=](wxCommandEvent& e) { + auto about = new AboutDialog(nullptr); + about->ShowModal(); + about->Destroy(); }, wxID_ABOUT); }