mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 19:33:47 +00:00
Require less clicks to change filament in object list (#12603)
* reduces number of clicks to change filament in objectlist * dont set minimum width in dropdown if use_content_width == true --------- Co-authored-by: Hanno Witzleb <hannowitzleb@gmail.com> Co-authored-by: yw4z <ywsyildiz@gmail.com>
This commit is contained in:
@@ -235,7 +235,7 @@ bool BitmapTextRenderer::GetValueFromEditorCtrl(wxWindow* ctrl, wxVariant& value
|
|||||||
|
|
||||||
// The icon can't be edited so get its old value and reuse it.
|
// The icon can't be edited so get its old value and reuse it.
|
||||||
wxVariant valueOld;
|
wxVariant valueOld;
|
||||||
GetView()->GetModel()->GetValue(valueOld, m_item, /*colName*/0);
|
GetView()->GetModel()->GetValue(valueOld, m_item, Slic3r::GUI::ColumnNumber::colName);
|
||||||
|
|
||||||
DataViewBitmapText bmpText;
|
DataViewBitmapText bmpText;
|
||||||
bmpText << valueOld;
|
bmpText << valueOld;
|
||||||
@@ -265,13 +265,10 @@ bool BitmapChoiceRenderer::GetValue(wxVariant& value) const
|
|||||||
|
|
||||||
bool BitmapChoiceRenderer::Render(wxRect rect, wxDC* dc, int state)
|
bool BitmapChoiceRenderer::Render(wxRect rect, wxDC* dc, int state)
|
||||||
{
|
{
|
||||||
// int xoffset = 0;
|
|
||||||
|
|
||||||
const wxBitmap& icon = m_value.GetBitmap();
|
const wxBitmap& icon = m_value.GetBitmap();
|
||||||
if (icon.IsOk())
|
if (icon.IsOk())
|
||||||
{
|
{
|
||||||
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
|
dc->DrawBitmap(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
|
||||||
// xoffset = icon.GetWidth() + 4;
|
|
||||||
|
|
||||||
if (rect.height == 0)
|
if (rect.height == 0)
|
||||||
rect.height = icon.GetHeight();
|
rect.height = icon.GetHeight();
|
||||||
@@ -299,7 +296,6 @@ wxSize BitmapChoiceRenderer::GetSize() const
|
|||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxWindow* BitmapChoiceRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value)
|
wxWindow* BitmapChoiceRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelRect, const wxVariant& value)
|
||||||
{
|
{
|
||||||
if (can_create_editor_ctrl && !can_create_editor_ctrl())
|
if (can_create_editor_ctrl && !can_create_editor_ctrl())
|
||||||
@@ -328,18 +324,19 @@ wxWindow* BitmapChoiceRenderer::CreateEditorCtrl(wxWindow* parent, wxRect labelR
|
|||||||
else
|
else
|
||||||
c_editor->SetSelection(atoi(data.GetText().c_str()) - 1);
|
c_editor->SetSelection(atoi(data.GetText().c_str()) - 1);
|
||||||
|
|
||||||
#ifdef __linux__
|
// Open the dropdown immediately when the editor is focused.
|
||||||
|
c_editor->Bind(wxEVT_SET_FOCUS, [c_editor](wxFocusEvent& evt) {
|
||||||
|
c_editor->ForceDropdownOpen();
|
||||||
|
evt.Skip();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Close editor after selection is made
|
||||||
c_editor->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
|
c_editor->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
|
||||||
// to avoid event propagation to other sidebar items
|
|
||||||
evt.StopPropagation();
|
evt.StopPropagation();
|
||||||
// FinishEditing grabs new selection and triggers config update. We better call
|
// FinishEditing grabs new selection and triggers config update. We better call
|
||||||
// it explicitly, automatic update on KILL_FOCUS didn't work on Linux.
|
// it explicitly, automatic update on KILL_FOCUS didn't work on Linux.
|
||||||
this->FinishEditing();
|
this->FinishEditing();
|
||||||
});
|
});
|
||||||
#else
|
|
||||||
// to avoid event propagation to other sidebar items
|
|
||||||
c_editor->Bind(wxEVT_COMBOBOX, [](wxCommandEvent& evt) { evt.StopPropagation(); });
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return c_editor;
|
return c_editor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,13 +132,9 @@ private:
|
|||||||
class BitmapChoiceRenderer : public wxDataViewCustomRenderer
|
class BitmapChoiceRenderer : public wxDataViewCustomRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BitmapChoiceRenderer(wxDataViewCellMode mode =
|
BitmapChoiceRenderer(
|
||||||
//#ifdef __WXOSX__
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_EDITABLE,
|
||||||
// wxDATAVIEW_CELL_INERT
|
int align = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL
|
||||||
//#else
|
|
||||||
wxDATAVIEW_CELL_EDITABLE
|
|
||||||
//#endif
|
|
||||||
, int align = wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL
|
|
||||||
) : wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align) {}
|
) : wxDataViewCustomRenderer(wxT("DataViewBitmapText"), mode, align) {}
|
||||||
|
|
||||||
bool SetValue(const wxVariant& value) override;
|
bool SetValue(const wxVariant& value) override;
|
||||||
|
|||||||
@@ -460,6 +460,15 @@ void ObjectList::create_objects_ctrl()
|
|||||||
AppendBitmapColumn(" ", colEditing, wxOSX ? wxDATAVIEW_CELL_EDITABLE : wxDATAVIEW_CELL_INERT, m_columns_width[colEditing] * em,
|
AppendBitmapColumn(" ", colEditing, wxOSX ? wxDATAVIEW_CELL_EDITABLE : wxDATAVIEW_CELL_INERT, m_columns_width[colEditing] * em,
|
||||||
wxALIGN_CENTER_HORIZONTAL, 0);
|
wxALIGN_CENTER_HORIZONTAL, 0);
|
||||||
|
|
||||||
|
|
||||||
|
// Open filament editor faster
|
||||||
|
this->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [this](wxDataViewEvent& event) {
|
||||||
|
if (event.GetColumn() == colFilament) {
|
||||||
|
// Trigger the editor opening manually
|
||||||
|
this->EditItem(event.GetItem(), GetColumn(colFilament));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//for (int cn = colName; cn < colCount; cn++) {
|
//for (int cn = colName; cn < colCount; cn++) {
|
||||||
// GetColumn(cn)->SetResizeable(cn == colName);
|
// GetColumn(cn)->SetResizeable(cn == colName);
|
||||||
//}
|
//}
|
||||||
|
|||||||
@@ -241,6 +241,23 @@ void ComboBox::DoDeleteOneItem(unsigned int pos)
|
|||||||
drop.Invalidate(true);
|
drop.Invalidate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComboBox::ForceDropdownOpen()
|
||||||
|
{
|
||||||
|
if (!IsEnabled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!drop_down) {
|
||||||
|
drop.need_sync = true;
|
||||||
|
drop.messureSize();
|
||||||
|
drop.autoPosition();
|
||||||
|
drop_down = true;
|
||||||
|
drop.Popup(&drop);
|
||||||
|
|
||||||
|
wxCommandEvent e(wxEVT_COMBOBOX_DROPDOWN);
|
||||||
|
GetEventHandler()->ProcessEvent(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int ComboBox::GetCount() const { return items.size(); }
|
unsigned int ComboBox::GetCount() const { return items.size(); }
|
||||||
|
|
||||||
void ComboBox::set_replace_text(wxString text, wxString image_name)
|
void ComboBox::set_replace_text(wxString text, wxString image_name)
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ public:
|
|||||||
void SetItemBitmap(unsigned int n, wxBitmap const &bitmap);
|
void SetItemBitmap(unsigned int n, wxBitmap const &bitmap);
|
||||||
bool is_drop_down(){return drop_down;}
|
bool is_drop_down(){return drop_down;}
|
||||||
void DeleteOneItem(unsigned int pos) { DoDeleteOneItem(pos); }
|
void DeleteOneItem(unsigned int pos) { DoDeleteOneItem(pos); }
|
||||||
|
|
||||||
|
void ForceDropdownOpen();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int DoInsertItems(const wxArrayStringsAdapter &items,
|
virtual int DoInsertItems(const wxArrayStringsAdapter &items,
|
||||||
unsigned int pos,
|
unsigned int pos,
|
||||||
|
|||||||
@@ -525,7 +525,7 @@ void DropDown::messureSize()
|
|||||||
}
|
}
|
||||||
if (!align_icon) iconSize.x = 0;
|
if (!align_icon) iconSize.x = 0;
|
||||||
wxSize szContent = textSize;
|
wxSize szContent = textSize;
|
||||||
if (szContent.x < FromDIP(120))
|
if (szContent.x < FromDIP(120) && !use_content_width)
|
||||||
szContent.x = FromDIP(120);
|
szContent.x = FromDIP(120);
|
||||||
szContent.x += 10;
|
szContent.x += 10;
|
||||||
if (check_bitmap.bmp().IsOk()) {
|
if (check_bitmap.bmp().IsOk()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user