mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 00:37:51 -06:00
Set DoubleBuffered state for the Tabs (under MSW)
+ Some improvements/experiments for the presets selection from the Plater + Some fix of a sidebar layout
This commit is contained in:
parent
03beb1870b
commit
a6dcbc8791
6 changed files with 54 additions and 49 deletions
|
@ -198,9 +198,9 @@ bool GUI_App::OnInit()
|
|||
});
|
||||
|
||||
load_current_presets();
|
||||
update_mode(); // update view mode after fix of the object_list size
|
||||
|
||||
mainframe->Show(true);
|
||||
update_mode(); // update view mode after fix of the object_list size
|
||||
m_initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -524,6 +524,7 @@ struct Sidebar::priv
|
|||
Plater *plater;
|
||||
|
||||
wxScrolledWindow *scrolled;
|
||||
wxPanel* presets_panel; // Used for MSW better layouts
|
||||
|
||||
PrusaModeSizer *mode_sizer;
|
||||
wxFlexGridSizer *sizer_presets;
|
||||
|
@ -578,9 +579,6 @@ Sidebar::Sidebar(Plater *parent)
|
|||
p->scrolled = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(40 * wxGetApp().em_unit(), -1));
|
||||
p->scrolled->SetScrollbars(0, 20, 1, 2);
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
p->scrolled->SetDoubleBuffered(true);
|
||||
#endif //__WINDOWS__
|
||||
|
||||
// Sizer in the scrolled area
|
||||
auto *scrolled_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
@ -593,12 +591,25 @@ Sidebar::Sidebar(Plater *parent)
|
|||
p->sizer_presets = new wxFlexGridSizer(10, 1, 1, 2);
|
||||
p->sizer_presets->AddGrowableCol(0, 1);
|
||||
p->sizer_presets->SetFlexibleDirection(wxBOTH);
|
||||
|
||||
bool is_msw = false;
|
||||
#ifdef __WINDOWS__
|
||||
p->scrolled->SetDoubleBuffered(true);
|
||||
|
||||
p->presets_panel = new wxPanel(p->scrolled, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
p->presets_panel->SetSizer(p->sizer_presets);
|
||||
|
||||
is_msw = true;
|
||||
#else
|
||||
presets_panel = p->scrolled;
|
||||
#endif //__WINDOWS__
|
||||
|
||||
p->sizer_filaments = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
auto init_combo = [this](PresetComboBox **combo, wxString label, Preset::Type preset_type, bool filament) {
|
||||
auto *text = new wxStaticText(p->scrolled, wxID_ANY, label+" :");
|
||||
auto *text = new wxStaticText(p->presets_panel, wxID_ANY, label + " :");
|
||||
text->SetFont(wxGetApp().small_font());
|
||||
*combo = new PresetComboBox(p->scrolled, preset_type);
|
||||
*combo = new PresetComboBox(p->presets_panel, preset_type);
|
||||
|
||||
auto *sizer_presets = this->p->sizer_presets;
|
||||
auto *sizer_filaments = this->p->sizer_filaments;
|
||||
|
@ -657,6 +668,8 @@ Sidebar::Sidebar(Plater *parent)
|
|||
|
||||
// Sizer in the scrolled area
|
||||
scrolled_sizer->Add(p->mode_sizer, 0, wxALIGN_CENTER_HORIZONTAL/*RIGHT | wxBOTTOM | wxRIGHT, 5*/);
|
||||
is_msw ?
|
||||
scrolled_sizer->Add(p->presets_panel, 0, wxEXPAND | wxLEFT, margin_5) :
|
||||
scrolled_sizer->Add(p->sizer_presets, 0, wxEXPAND | wxLEFT, margin_5);
|
||||
scrolled_sizer->Add(p->sizer_params, 1, wxEXPAND | wxLEFT, margin_5);
|
||||
scrolled_sizer->Add(p->object_info, 0, wxEXPAND | wxTOP | wxLEFT, margin_5);
|
||||
|
@ -695,7 +708,7 @@ Sidebar::Sidebar(Plater *parent)
|
|||
Sidebar::~Sidebar() {}
|
||||
|
||||
void Sidebar::init_filament_combo(PresetComboBox **combo, const int extr_idx) {
|
||||
*combo = new PresetComboBox(p->scrolled, Slic3r::Preset::TYPE_FILAMENT);
|
||||
*combo = new PresetComboBox(p->presets_panel, Slic3r::Preset::TYPE_FILAMENT);
|
||||
// # copy icons from first choice
|
||||
// $choice->SetItemBitmap($_, $choices->[0]->GetItemBitmap($_)) for 0..$#presets;
|
||||
|
||||
|
@ -757,7 +770,7 @@ void Sidebar::update_presets(Preset::Type preset_type)
|
|||
|
||||
case Preset::TYPE_PRINTER:
|
||||
{
|
||||
wxWindowUpdateLocker noUpdates_scrolled(p->scrolled);
|
||||
// wxWindowUpdateLocker noUpdates_scrolled(p->scrolled);
|
||||
|
||||
// Update the print choosers to only contain the compatible presets, update the dirty flags.
|
||||
if (print_tech == ptFFF)
|
||||
|
@ -819,6 +832,11 @@ wxScrolledWindow* Sidebar::scrolled_panel()
|
|||
return p->scrolled;
|
||||
}
|
||||
|
||||
wxPanel* Sidebar::presets_panel()
|
||||
{
|
||||
return p->presets_panel;
|
||||
}
|
||||
|
||||
ConfigOptionsGroup* Sidebar::og_freq_chng_params(const bool is_fff)
|
||||
{
|
||||
return p->frequently_changed_parameters->get_og(is_fff);
|
||||
|
@ -2392,7 +2410,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||
//! instead of
|
||||
//! combo->GetStringSelection().ToUTF8().data());
|
||||
|
||||
std::string selected_string = combo->GetString(combo->GetSelection()).ToUTF8().data();
|
||||
const std::string& selected_string = combo->GetString(combo->GetSelection()).ToUTF8().data();
|
||||
|
||||
if (preset_type == Preset::TYPE_FILAMENT) {
|
||||
wxGetApp().preset_bundle->set_filament_preset(idx, selected_string);
|
||||
|
@ -2404,12 +2422,8 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
|
|||
wxGetApp().preset_bundle->update_platter_filament_ui(idx, combo);
|
||||
}
|
||||
else {
|
||||
for (Tab* tab : wxGetApp().tabs_list) {
|
||||
if (tab->type() == preset_type) {
|
||||
tab->select_preset(selected_string);
|
||||
break;
|
||||
}
|
||||
}
|
||||
wxWindowUpdateLocker noUpdates(sidebar->presets_panel());
|
||||
wxGetApp().get_tab(preset_type)->select_preset(selected_string);
|
||||
}
|
||||
|
||||
// update plater with new config
|
||||
|
@ -3313,8 +3327,10 @@ void Plater::on_extruders_change(int num_extruders)
|
|||
{
|
||||
auto& choices = sidebar().combos_filament();
|
||||
|
||||
if (num_extruders == choices.size())
|
||||
return;
|
||||
|
||||
wxWindowUpdateLocker noUpdates_scrolled_panel(&sidebar()/*.scrolled_panel()*/);
|
||||
// sidebar().scrolled_panel()->Freeze();
|
||||
|
||||
int i = choices.size();
|
||||
while ( i < num_extruders )
|
||||
|
|
|
@ -51,6 +51,8 @@ public:
|
|||
int get_extruder_idx() const { return extruder_idx; }
|
||||
void check_selection();
|
||||
|
||||
std::string selected_preset_name;
|
||||
|
||||
private:
|
||||
typedef std::size_t Marker;
|
||||
enum { LABEL_ITEM_MARKER = 0x4d };
|
||||
|
@ -81,6 +83,7 @@ public:
|
|||
ObjectList* obj_list();
|
||||
ObjectSettings* obj_settings();
|
||||
wxScrolledWindow* scrolled_panel();
|
||||
wxPanel* presets_panel();
|
||||
|
||||
ConfigOptionsGroup* og_freq_chng_params(const bool is_fff);
|
||||
wxButton* get_wiping_dialog_button();
|
||||
|
|
|
@ -879,8 +879,10 @@ size_t PresetCollection::update_compatible_internal(const Preset &active_printer
|
|||
// Hide the
|
||||
void PresetCollection::update_platter_ui(GUI::PresetComboBox *ui)
|
||||
{
|
||||
if (ui == nullptr)
|
||||
if (ui == nullptr ||
|
||||
ui->selected_preset_name == this->get_selected_preset().name)
|
||||
return;
|
||||
|
||||
// Otherwise fill in the list from scratch.
|
||||
ui->Freeze();
|
||||
ui->Clear();
|
||||
|
@ -949,6 +951,8 @@ void PresetCollection::update_platter_ui(GUI::PresetComboBox *ui)
|
|||
ui->SetSelection(selected_preset_item);
|
||||
ui->SetToolTip(ui->GetString(selected_preset_item));
|
||||
ui->Thaw();
|
||||
|
||||
ui->selected_preset_name = this->get_selected_preset().name;
|
||||
}
|
||||
|
||||
size_t PresetCollection::update_tab_ui(wxBitmapComboBox *ui, bool show_incompatible)
|
||||
|
|
|
@ -1436,7 +1436,8 @@ bool PresetBundle::parse_color(const std::string &scolor, unsigned char *rgb_out
|
|||
void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, GUI::PresetComboBox *ui)
|
||||
{
|
||||
if (ui == nullptr || this->printers.get_edited_preset().printer_technology() == ptSLA ||
|
||||
this->filament_presets.size() <= idx_extruder )
|
||||
this->filament_presets.size() <= idx_extruder ||
|
||||
ui->selected_preset_name == this->filaments.find_preset(this->filament_presets[idx_extruder])->name)
|
||||
return;
|
||||
|
||||
unsigned char rgb[3];
|
||||
|
@ -1525,6 +1526,8 @@ void PresetBundle::update_platter_filament_ui(unsigned int idx_extruder, GUI::Pr
|
|||
ui->SetSelection(selected_preset_item);
|
||||
ui->SetToolTip(ui->GetString(selected_preset_item));
|
||||
ui->Thaw();
|
||||
|
||||
ui->selected_preset_name = this->filaments.find_preset(this->filament_presets[idx_extruder])->name;
|
||||
}
|
||||
|
||||
void PresetBundle::set_default_suppressed(bool default_suppressed)
|
||||
|
|
|
@ -73,6 +73,10 @@ void Tab::set_type()
|
|||
// sub new
|
||||
void Tab::create_preset_tab()
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
SetDoubleBuffered(true);
|
||||
#endif //__WINDOWS__
|
||||
|
||||
m_preset_bundle = wxGetApp().preset_bundle;
|
||||
|
||||
// Vertical sizer to hold the choice menu and the rest of the page.
|
||||
|
@ -787,25 +791,6 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
|
|||
wxGetApp().plater()->on_extruders_change(boost::any_cast<size_t>(value));
|
||||
|
||||
update();
|
||||
|
||||
// #ys_FIXME_to_delete
|
||||
// Post event to the Plater after updating of the all dirty options
|
||||
// It helps to avoid needless schedule_background_processing
|
||||
// if (update_completed())
|
||||
// if (m_update_stack.empty())
|
||||
// {
|
||||
// // wxCommandEvent event(EVT_TAB_VALUE_CHANGED);
|
||||
// // event.SetEventObject(this);
|
||||
// // event.SetString(opt_key);
|
||||
// // if (opt_key == "extruders_count")
|
||||
// // {
|
||||
// // const int val = boost::any_cast<size_t>(value);
|
||||
// // event.SetInt(val);
|
||||
// // }
|
||||
// //
|
||||
// // wxPostEvent(this, event);
|
||||
// wxGetApp().mainframe->on_value_changed(m_config);
|
||||
// }
|
||||
}
|
||||
|
||||
// Show/hide the 'purging volumes' button
|
||||
|
@ -828,9 +813,13 @@ void Tab::update_wiping_button_visibility() {
|
|||
// To update the content of the selection boxes,
|
||||
// to update the filament colors of the selection boxes,
|
||||
// to update the "dirty" flags of the selection boxes,
|
||||
// to uddate number of "filament" selection boxes when the number of extruders change.
|
||||
// to update number of "filament" selection boxes when the number of extruders change.
|
||||
void Tab::on_presets_changed()
|
||||
{
|
||||
// Instead of PostEvent (EVT_TAB_PRESETS_CHANGED) just call update_presets
|
||||
wxGetApp().plater()->sidebar().update_presets(m_type);
|
||||
update_preset_description_line();
|
||||
|
||||
// Printer selected at the Printer tab, update "compatible" marks at the print and filament selectors.
|
||||
for (auto t: m_dependent_tabs)
|
||||
{
|
||||
|
@ -841,16 +830,6 @@ void Tab::on_presets_changed()
|
|||
// clear m_dependent_tabs after first update from select_preset()
|
||||
// to avoid needless preset loading from update() function
|
||||
m_dependent_tabs.clear();
|
||||
|
||||
// #ys_FIXME_to_delete
|
||||
// wxCommandEvent event(EVT_TAB_PRESETS_CHANGED);
|
||||
// event.SetEventObject(this);
|
||||
// wxPostEvent(this, event);
|
||||
|
||||
// Instead of PostEvent (EVT_TAB_PRESETS_CHANGED) just call update_presets
|
||||
wxGetApp().plater()->sidebar().update_presets(m_type);
|
||||
|
||||
update_preset_description_line();
|
||||
}
|
||||
|
||||
void Tab::update_preset_description_line()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue