Default presets are visible only if it's selected from Preferences

This commit is contained in:
YuSanka 2018-04-09 12:41:25 +02:00
parent e33db203d8
commit affaeef2ab
3 changed files with 16 additions and 9 deletions

View File

@ -45,9 +45,9 @@ void Tab::create_preset_tab(PresetBundle *preset_bundle)
{ {
// FIXME If the following line is removed, the combo box popup list will not react to mouse clicks. // FIXME If the following line is removed, the combo box popup list will not react to mouse clicks.
// On the other side, with this line the combo box popup cannot be closed by clicking on the combo button on Windows 10. // On the other side, with this line the combo box popup cannot be closed by clicking on the combo button on Windows 10.
m_cc_presets_choice->UseAltPopupWindow(); // m_cc_presets_choice->UseAltPopupWindow();
m_cc_presets_choice->EnablePopupAnimation(false); // m_cc_presets_choice->EnablePopupAnimation(false);
m_cc_presets_choice->SetPopupControl(popup); m_cc_presets_choice->SetPopupControl(popup);
popup->SetStringValue(from_u8("Text1")); popup->SetStringValue(from_u8("Text1"));
@ -2150,8 +2150,11 @@ void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible)
if (popup != nullptr) if (popup != nullptr)
{ {
popup->DeleteAllItems(); popup->DeleteAllItems();
auto root_1 = popup->AppendContainer(wxDataViewItem(0), _(L("Root 1")));
auto root_sys = popup->AppendContainer(wxDataViewItem(0), _(L("System presets"))); auto root_sys = popup->AppendContainer(wxDataViewItem(0), _(L("System presets")));
auto root_def = popup->AppendContainer(wxDataViewItem(0), _(L("Default presets"))); auto show_def = get_app_config()->get("no_defaults")[0] != '1';
wxDataViewItem root_def;
if (show_def) root_def = popup->AppendContainer(wxDataViewItem(0), _(L("Default presets")));
for (size_t i = presets.front().is_visible ? 0 : 1; i < presets.size(); ++i) { for (size_t i = presets.front().is_visible ? 0 : 1; i < presets.size(); ++i) {
const Preset &preset = presets[i]; const Preset &preset = presets[i];
@ -2161,11 +2164,15 @@ void Tab::update_tab_presets(wxComboCtrl* ui, bool show_incompatible)
auto preset_name = wxString::FromUTF8((preset.name + (preset.is_dirty ? suffix_modified : "")).c_str()); auto preset_name = wxString::FromUTF8((preset.name + (preset.is_dirty ? suffix_modified : "")).c_str());
wxDataViewItem item; wxDataViewItem item;
if (preset.is_system || preset.is_default) if (preset.is_system)
item = popup->AppendItem(preset.is_system ? root_sys : root_def, preset_name, item = popup->AppendItem(root_sys, preset_name,
preset.is_compatible ? icon_compatible : icon_incompatible);
else if (show_def && preset.is_default)
item = popup->AppendItem(root_def, preset_name,
preset.is_compatible ? icon_compatible : icon_incompatible); preset.is_compatible ? icon_compatible : icon_incompatible);
else { else {
item = popup->AppendItem(root_1, preset_name,
preset.is_compatible ? icon_compatible : icon_incompatible);
} }
cnt_items++; cnt_items++;

View File

@ -121,7 +121,7 @@ bool wxDataViewTreeCtrlComboPopup::Create(wxWindow* parent)
{ {
return wxDataViewTreeCtrl::Create(parent, wxID_HIGHEST + 1, wxPoint(0, 0), wxSize(270, -1)); return wxDataViewTreeCtrl::Create(parent, wxID_HIGHEST + 1, wxPoint(0, 0), wxSize(270, -1));
} }
/*
wxSize wxDataViewTreeCtrlComboPopup::GetAdjustedSize(int minWidth, int prefHeight, int maxHeight) wxSize wxDataViewTreeCtrlComboPopup::GetAdjustedSize(int minWidth, int prefHeight, int maxHeight)
{ {
// matches owner wxComboCtrl's width // matches owner wxComboCtrl's width
@ -140,7 +140,7 @@ wxSize wxDataViewTreeCtrlComboPopup::GetAdjustedSize(int minWidth, int prefHeigh
else else
return wxSize(DefaultWidth, DefaultHeight); return wxSize(DefaultWidth, DefaultHeight);
} }
*/
void wxDataViewTreeCtrlComboPopup::OnKeyEvent(wxKeyEvent& evt) void wxDataViewTreeCtrlComboPopup::OnKeyEvent(wxKeyEvent& evt)
{ {
// filters out all the keys which are not working properly // filters out all the keys which are not working properly

View File

@ -43,7 +43,7 @@ public:
virtual wxWindow* GetControl() { return this; } virtual wxWindow* GetControl() { return this; }
virtual void SetStringValue(const wxString& value) { m_text = value; } virtual void SetStringValue(const wxString& value) { m_text = value; }
virtual wxString GetStringValue() const { return m_text; } virtual wxString GetStringValue() const { return m_text; }
virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight); // virtual wxSize GetAdjustedSize(int minWidth, int prefHeight, int maxHeight);
virtual void OnKeyEvent(wxKeyEvent& evt); virtual void OnKeyEvent(wxKeyEvent& evt);
void OnDataViewTreeCtrlSelection(wxCommandEvent& evt); void OnDataViewTreeCtrlSelection(wxCommandEvent& evt);