Skip to content

Commit

Permalink
fix preferences gui
Browse files Browse the repository at this point in the history
also search & mode colors
  • Loading branch information
supermerill committed Jul 19, 2024
1 parent 0a444c6 commit 36e86c7
Show file tree
Hide file tree
Showing 33 changed files with 327 additions and 321 deletions.
4 changes: 2 additions & 2 deletions src/slic3r/GUI/AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ CopyrightsDialog::CopyrightsDialog()
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, format_wxstr("%1% - %2%"
, wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME
, _L("Portions copyright")),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, "about")
{
this->SetFont(wxGetApp().normal_font());
#ifdef _WIN32
Expand Down Expand Up @@ -235,7 +235,7 @@ void CopyrightsDialog::onCloseDialog(wxEvent &)

AboutDialog::AboutDialog()
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, format_wxstr(_L("About %s"), wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME), wxDefaultPosition,
wxDefaultSize, /*wxCAPTION*/wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
wxDefaultSize, /*wxCAPTION*/wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, "about2")
{
SetFont(wxGetApp().normal_font());

Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/BedShapeDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void BedShape::apply_optgroup_values(ConfigOptionsGroupShp optgroup)
}

BedShapeDialog::BedShapeDialog(wxWindow* parent) : DPIDialog(parent, wxID_ANY, _(L("Bed Shape")),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) {}
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, "bedshape") {}

void BedShapeDialog::build_dialog(const ConfigOptionPoints& default_pt, const ConfigOptionString& custom_texture, const ConfigOptionString& custom_model)
{
Expand Down
8 changes: 5 additions & 3 deletions src/slic3r/GUI/BitmapCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,14 @@ void BitmapCache::nsvgGetDataFromFileWithReplace(const char* filename, std::stri
wxBitmapBundle* BitmapCache::from_svg(const std::string& bitmap_name, unsigned target_width, unsigned target_height,
/*const bool dark_mode, */ColorReplaces& color_changes /*= ""*/)
{
//create hash from ColorReplaces
uint32_t color_change_hash = 0;
for (size_t i = 0; i < color_changes.changes.size(); ++i) {
color_change_hash |= rgb2int(color_changes.changes[i].color_to_replace) << uint8_t(i%8);
color_change_hash |= rgb2int(color_changes.changes[i].new_color) << uint8_t(i%8);
color_change_hash ^= rgb2int(color_changes.changes[i].color_to_replace) << uint8_t((i + 4) % 8);
color_change_hash ^= rgb2int(color_changes.changes[i].new_color) << uint8_t(i % 8);
}
color_change_hash = ((color_change_hash >> 16) & 0x0000FFFF) | (color_change_hash & 0x0000FFFF);
//reduce hash to 16b
color_change_hash = ((color_change_hash >> 16) & 0x0000FFFF) ^ (color_change_hash & 0x0000FFFF);

if (target_width == 0)
target_width = target_height;
Expand Down
5 changes: 3 additions & 2 deletions src/slic3r/GUI/CalibrationAbstractDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ namespace GUI {
CalibrationAbstractDialog::CalibrationAbstractDialog(GUI_App* app, MainFrame* mainframe, std::string name)
: DPIDialog(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _(L(name)),
#if ENABLE_SCROLLABLE
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
#else
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
#endif // ENABLE_SCROLLABLE
, "calibration")
{
this->gui_app = app;
this->main_frame = mainframe;
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/ConfigSnapshotDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static wxString generate_html_page(const Config::SnapshotDB &snapshot_db, const
ConfigSnapshotDialog::ConfigSnapshotDialog(const Config::SnapshotDB &snapshot_db, const wxString &on_snapshot)
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, _(L("Configuration Snapshots")), wxDefaultPosition,
wxSize(45 * wxGetApp().em_unit(), 40 * wxGetApp().em_unit()),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX)
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX, "snapshotcal")
{
this->SetFont(wxGetApp().normal_font());
#ifdef _WIN32
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/ConfigWizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3396,7 +3396,7 @@ bool ConfigWizard::priv::check_sla_selected()
// Public

ConfigWizard::ConfigWizard(wxWindow *parent)
: DPIDialog(parent, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _(name()), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
: DPIDialog(parent, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _(name()), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, "configwizard")
, p(new priv(this))
{
#ifdef __APPLE__
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/CreateMMUTiledCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ namespace GUI {
}


GetRPlaceDialog(wxWindow* p, wxWindowID id, const wxString& title) : DPIDialog(p, id, title, wxDefaultPosition, wxDefaultSize){
GetRPlaceDialog(wxWindow* p, wxWindowID id, const wxString& title) : DPIDialog(p, id, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, "getrplace"){
int spin_options = wxTE_PROCESS_ENTER | wxSP_ARROW_KEYS
#ifdef _WIN32
| wxBORDER_SIMPLE
Expand Down Expand Up @@ -884,7 +884,7 @@ void CreateMMUTiledCanvas::load_config()
CreateMMUTiledCanvas::CreateMMUTiledCanvas(GUI_App* app, MainFrame* mainframe)
: DPIDialog(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Creating Mosaic tiled canvas"),
//#if ENABLE_SCROLLABLE
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, "createmmu")
//#else
// wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
//#endif // ENABLE_SCROLLABLE
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/EditGCodeDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace GUI {

EditGCodeDialog::EditGCodeDialog(wxWindow* parent, const std::string& key, const std::string& value) :
// TRN: This is title of a dialog. The argument is the name of the currently edited custom G-code.
DPIDialog(parent, wxID_ANY, format_wxstr(_L("Edit Custom G-code (%1%)"), key), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
DPIDialog(parent, wxID_ANY, format_wxstr(_L("Edit Custom G-code (%1%)"), key), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, "editgcode")
{
SetFont(wxGetApp().normal_font());
wxGetApp().UpdateDarkUI(this);
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/ExtruderSequenceDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace GUI {

ExtruderSequenceDialog::ExtruderSequenceDialog(const DoubleSlider::ExtrudersSequence& sequence)
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _(L("Set extruder sequence")),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, "extrudersequence"),
m_sequence(sequence)
{
#ifdef _WIN32
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/FileArchiveDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ ArchiveViewCtrl::~ArchiveViewCtrl()
FileArchiveDialog::FileArchiveDialog(wxWindow* parent_window, mz_zip_archive* archive, std::vector<std::pair<boost::filesystem::path, size_t>>& selected_paths_w_size)
: DPIDialog(parent_window, wxID_ANY, _(L("Archive preview")), wxDefaultPosition,
wxSize(45 * wxGetApp().em_unit(), 40 * wxGetApp().em_unit()),
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX)
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX, "filearchive")
, m_selected_paths_w_size (selected_paths_w_size)
{
#ifdef _WIN32
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/FirmwareDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ const char* FirmwareDialog::priv::avr109_dev_name(Avr109Pid usb_pid) {
// Public

FirmwareDialog::FirmwareDialog(wxWindow *parent) :
GUI::DPIDialog(parent, wxID_ANY, _(L("Firmware flasher")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
GUI::DPIDialog(parent, wxID_ANY, _(L("Firmware flasher")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, "firmware"),
p(new priv(this))
{
const int em = GUI::wxGetApp().em_unit();
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/FreeCADDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ FreeCADDialog::~FreeCADDialog() {
FreeCADDialog::FreeCADDialog(GUI_App* app, MainFrame* mainframe)
: DPIDialog(NULL, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("FreePySCAD : script engine for FreeCAD"),
//#if ENABLE_SCROLLABLE
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, "freecad")
//#else
// wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
//#endif // ENABLE_SCROLLABLE
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/GUI_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2989,9 +2989,9 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
menu->Append(local_menu, _L("&Configuration"));
}

void GUI_App::open_preferences(const std::string& highlight_option /*= std::string()*/, const std::string& tab_name/*= std::string()*/)
void GUI_App::open_preferences(const std::string& highlight_option /*= std::string()*/, const std::string& group_name/*= std::string()*/)
{
mainframe->preferences_dialog->show(highlight_option, tab_name);
mainframe->preferences_dialog->show(highlight_option, group_name);

if (mainframe->preferences_dialog->recreate_GUI())
recreate_GUI(_L("Restart application") + dots);
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/GUI_App.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class GUI_App : public wxApp
wxString current_language_code_safe() const;
bool is_localized() const { return m_wxLocale->GetLocale() != "English"; }

void open_preferences(const std::string& highlight_option = std::string(), const std::string& tab_name = std::string());
void open_preferences(const std::string& highlight_option = std::string(), const std::string& group_name = std::string());

virtual bool OnExceptionInMainLoop() override;
// Calls wxLaunchDefaultBrowser if user confirms in dialog.
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/GalleryDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ bool GalleryDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& f


GalleryDialog::GalleryDialog(wxWindow* parent) :
DPIDialog(parent, wxID_ANY, _L("Shape Gallery"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
DPIDialog(parent, wxID_ANY, _L("Shape Gallery"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, "gallery")
{
#ifndef _WIN32
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/KBShortcutsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace GUI {

KBShortcutsDialog::KBShortcutsDialog()
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, wxString(wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME) + " - " + _L("Keyboard Shortcuts"),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, "kbshortcut")
{
// fonts
const wxFont& font = wxGetApp().normal_font();
Expand Down
9 changes: 8 additions & 1 deletion src/slic3r/GUI/OG_CustomCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ void OG_CustomCtrl::init_ctrl_lines()
!line.get_extra_widgets().empty())
)
continue;
if (line.is_separator())
continue;

const std::vector<Option>& option_set = line.get_options();
wxCoord height;
Expand Down Expand Up @@ -834,16 +836,21 @@ wxCoord OG_CustomCtrl::CtrlLine::draw_mode_bmp(wxDC& dc, wxCoord v_pos)
return ctrl->m_h_gap;

ConfigOptionMode mode = og_line.get_options()[0].opt.mode;
int pix_cnt = wxOSX ? 10 : 12;

if (mode == ConfigOptionMode::comNone)
return pix_cnt + ctrl->m_h_gap;

//get all tags
for (int i = 1; i < og_line.get_options().size(); i++)
mode |= og_line.get_options()[i].opt.mode;
int pix_cnt = wxOSX ? 10 : 12;
wxBitmapBundle* bmp = get_bmp_bundle("mode", pix_cnt, pix_cnt, wxGetApp().get_first_mode_btn_color(mode));
wxCoord y_draw = v_pos + lround((height - get_bitmap_size(bmp, ctrl).GetHeight()) / 2);

if (og_line.get_options().front().opt.gui_type != ConfigOptionDef::GUIType::legend)
dc.DrawBitmap(bmp->GetBitmapFor(ctrl), 0, y_draw);

assert(get_bitmap_size(bmp, ctrl).GetWidth() == pix_cnt);
return get_bitmap_size(bmp, ctrl).GetWidth() + ctrl->m_h_gap;
}

Expand Down
6 changes: 3 additions & 3 deletions src/slic3r/GUI/OptionsGroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class OptionsGroup {
protected:
wxStaticBox* stb {nullptr};
public:
const bool staticbox {true};
const bool staticbox {true}; // false if title is empty.
const wxString title;
int title_width = 20;// {200};
bool no_title = false;
Expand Down Expand Up @@ -291,8 +291,8 @@ class ConfigOptionsGroup: public OptionsGroup {
ConfigOptionsGroup( wxWindow* parent, const wxString& title, ModelConfig* config,
bool is_tab_opt = false, column_t extra_clmn = nullptr) :
OptionsGroup(parent, title, is_tab_opt, extra_clmn), m_config(&config->get()), m_modelconfig(config), m_config_mutable(nullptr) {}
ConfigOptionsGroup( wxWindow* parent) :
OptionsGroup(parent, wxEmptyString, true, nullptr) {}
ConfigOptionsGroup( wxWindow* parent, const wxString& title, bool is_tab_opt) :
OptionsGroup(parent, title, is_tab_opt, nullptr) {}
~ConfigOptionsGroup() override = default;

const wxString& config_category() const throw() { return m_config_category; }
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/PhysicalPrinterDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void PresetForPrinter::on_sys_color_changed()
//------------------------------------------

PhysicalPrinterDialog::PhysicalPrinterDialog(wxWindow* parent, wxString printer_name) :
DPIDialog(parent, wxID_ANY, _L("Physical Printer"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), -1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
DPIDialog(parent, wxID_ANY, _L("Physical Printer"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), -1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, "physicalprinter"),
m_printer("", wxGetApp().preset_bundle->physical_printers.default_config())
{
SetFont(wxGetApp().normal_font());
Expand Down
6 changes: 3 additions & 3 deletions src/slic3r/GUI/Plater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ void Sidebar::jump_to_option(size_t selected)
{
const Search::Option& opt = p->searcher.get_option(selected);
if (opt.type == Preset::TYPE_PREFERENCES)
wxGetApp().open_preferences(boost::nowide::narrow(opt.key), boost::nowide::narrow(opt.group));
wxGetApp().open_preferences(opt.opt_key(), boost::nowide::narrow(opt.group));
else {
ConfigOptionMode mode = wxGetApp().get_mode();
if ((opt.tags & mode) != mode) {
Expand Down Expand Up @@ -5985,7 +5985,7 @@ class LoadProjectsDialog : public DPIDialog
LoadProjectsDialog::LoadProjectsDialog(const std::vector<fs::path>& paths)
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY,
format_wxstr(_L("%1% - Multiple projects file"), SLIC3R_APP_NAME), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
wxDefaultSize, wxDEFAULT_DIALOG_STYLE, "loadproject")
{
SetFont(wxGetApp().normal_font());

Expand Down Expand Up @@ -6376,7 +6376,7 @@ class ProjectDropDialog : public DPIDialog
ProjectDropDialog::ProjectDropDialog(const std::string& filename)
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY,
format_wxstr("%1% - %2%", SLIC3R_APP_NAME, _L("Load project file")), wxDefaultPosition,
wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
wxDefaultSize, wxDEFAULT_DIALOG_STYLE, "projectdrop")
{
SetFont(wxGetApp().normal_font());

Expand Down
Loading

0 comments on commit 36e86c7

Please sign in to comment.