mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-06-01 09:27:34 +08:00
Try to use PrusaIconTextRenderer(CustomRenderer) for IconText Rendering
+ experiments with button's color + removed "strange control part" from topLeft corner of the right panel
This commit is contained in:
parent
9c433f8e08
commit
e3bb829e42
@ -1232,11 +1232,11 @@ void enable_action_buttons(bool enable)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Update background colour for buttons
|
// Update background colour for buttons
|
||||||
// const wxColour bgrd_color = enable ? wxColour(255, 96, 0) : wxColour(204, 204, 204);
|
const wxColour bgrd_color = enable ? wxColour(224, 224, 224/*255, 96, 0*/) : wxColour(204, 204, 204);
|
||||||
|
|
||||||
for (auto btn : g_buttons) {
|
for (auto btn : g_buttons) {
|
||||||
btn->Enable(enable);
|
btn->Enable(enable);
|
||||||
// btn->SetBackgroundColour(bgrd_color);
|
btn->SetBackgroundColour(bgrd_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,8 +249,12 @@ void create_objects_ctrl(wxWindow* win, wxBoxSizer*& objects_sz)
|
|||||||
#endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE
|
#endif // wxUSE_DRAG_AND_DROP && wxUSE_UNICODE
|
||||||
|
|
||||||
// column 0(Icon+Text) of the view control:
|
// column 0(Icon+Text) of the view control:
|
||||||
m_objects_ctrl->AppendIconTextColumn(_(L("Name")), 0, wxDATAVIEW_CELL_INERT, 200,
|
wxDataViewColumn *ret = new wxDataViewColumn(_(L("Name")),
|
||||||
wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE);
|
new PrusaIconTextRenderer(wxT("PrusaDataViewIconText")),
|
||||||
|
0, 200, wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE);
|
||||||
|
m_objects_ctrl->AppendColumn(ret);
|
||||||
|
// m_objects_ctrl->AppendIconTextColumn(_(L("Name")), 0, wxDATAVIEW_CELL_INERT, 200,
|
||||||
|
// wxALIGN_LEFT, wxDATAVIEW_COL_RESIZABLE);
|
||||||
|
|
||||||
// column 1 of the view control:
|
// column 1 of the view control:
|
||||||
m_objects_ctrl->AppendTextColumn(_(L("Copy")), 1, wxDATAVIEW_CELL_INERT, 45,
|
m_objects_ctrl->AppendTextColumn(_(L("Copy")), 1, wxDATAVIEW_CELL_INERT, 45,
|
||||||
@ -1014,7 +1018,6 @@ void get_settings_choice(wxMenu *menu, int id, bool is_part)
|
|||||||
const auto item = m_objects_ctrl->GetSelection();
|
const auto item = m_objects_ctrl->GetSelection();
|
||||||
if (item) {
|
if (item) {
|
||||||
const auto settings_item = m_objects_model->HasSettings(item);
|
const auto settings_item = m_objects_model->HasSettings(item);
|
||||||
settings_item ? printf("settings_item exist\n") : printf("settings_item will be created\n");
|
|
||||||
m_objects_ctrl->Select(settings_item ? settings_item :
|
m_objects_ctrl->Select(settings_item ? settings_item :
|
||||||
m_objects_model->AddSettingsChild(item));
|
m_objects_model->AddSettingsChild(item));
|
||||||
#ifndef __WXOSX__
|
#ifndef __WXOSX__
|
||||||
@ -1553,7 +1556,6 @@ void part_selection_changed()
|
|||||||
wxString object_name = wxEmptyString;
|
wxString object_name = wxEmptyString;
|
||||||
if (item)
|
if (item)
|
||||||
{
|
{
|
||||||
printf("item exists\n");
|
|
||||||
const bool is_settings_item = m_objects_model->IsSettingsItem(item);
|
const bool is_settings_item = m_objects_model->IsSettingsItem(item);
|
||||||
bool is_part = false;
|
bool is_part = false;
|
||||||
wxString og_name = wxEmptyString;
|
wxString og_name = wxEmptyString;
|
||||||
|
@ -161,8 +161,10 @@ public:
|
|||||||
ogDrawFlag flag = ogDEFAULT, column_t extra_clmn = nullptr) :
|
ogDrawFlag flag = ogDEFAULT, column_t extra_clmn = nullptr) :
|
||||||
m_parent(_parent), title(title), m_show_modified_btns(is_tab_opt),
|
m_parent(_parent), title(title), m_show_modified_btns(is_tab_opt),
|
||||||
staticbox(title!=""), m_flag(flag), extra_column(extra_clmn){
|
staticbox(title!=""), m_flag(flag), extra_column(extra_clmn){
|
||||||
stb = new wxStaticBox(_parent, wxID_ANY, title);
|
if (staticbox) {
|
||||||
stb->SetFont(bold_font());
|
stb = new wxStaticBox(_parent, wxID_ANY, title);
|
||||||
|
stb->SetFont(bold_font());
|
||||||
|
}
|
||||||
sizer = (staticbox ? new wxStaticBoxSizer(stb, wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
|
sizer = (staticbox ? new wxStaticBoxSizer(stb, wxVERTICAL) : new wxBoxSizer(wxVERTICAL));
|
||||||
auto num_columns = 1U;
|
auto num_columns = 1U;
|
||||||
if (label_width != 0) num_columns++;
|
if (label_width != 0) num_columns++;
|
||||||
|
@ -473,9 +473,6 @@ wxDataViewItem PrusaObjectDataViewModel::AddSettingsChild(const wxDataViewItem &
|
|||||||
// notify control
|
// notify control
|
||||||
const wxDataViewItem child((void*)node);
|
const wxDataViewItem child((void*)node);
|
||||||
ItemAdded(parent_item, child);
|
ItemAdded(parent_item, child);
|
||||||
|
|
||||||
if (child)
|
|
||||||
printf("SettingsChild is created\n");
|
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -849,6 +846,52 @@ void PrusaObjectDataViewModel::UpdateSettingsDigest(const wxDataViewItem &item,
|
|||||||
ItemChanged(item);
|
ItemChanged(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
// PrusaIconTextRenderer
|
||||||
|
// ---------------------------------------------------------
|
||||||
|
|
||||||
|
bool PrusaIconTextRenderer::SetValue(const wxVariant &value)
|
||||||
|
{
|
||||||
|
m_value << value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PrusaIconTextRenderer::GetValue(wxVariant& WXUNUSED(value)) const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PrusaIconTextRenderer::Render(wxRect rect, wxDC *dc, int state)
|
||||||
|
{
|
||||||
|
int xoffset = 0;
|
||||||
|
|
||||||
|
const wxIcon& icon = m_value.GetIcon();
|
||||||
|
if (icon.IsOk())
|
||||||
|
{
|
||||||
|
dc->DrawIcon(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2);
|
||||||
|
xoffset = icon.GetWidth() + 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderText(m_value.GetText(), xoffset, rect, dc, state);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize PrusaIconTextRenderer::GetSize() const
|
||||||
|
{
|
||||||
|
if (!m_value.GetText().empty())
|
||||||
|
{
|
||||||
|
wxSize size = GetTextExtent(m_value.GetText());
|
||||||
|
|
||||||
|
if (m_value.GetIcon().IsOk())
|
||||||
|
size.x += m_value.GetIcon().GetWidth() + 4;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
return wxSize(80, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// PrusaDoubleSlider
|
// PrusaDoubleSlider
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -415,6 +415,29 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// PrusaIconTextRenderer
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class PrusaIconTextRenderer : public wxDataViewCustomRenderer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PrusaIconTextRenderer( const wxString &varianttype = wxT("PrusaDataViewIconText"),
|
||||||
|
wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT,
|
||||||
|
int align = wxDVR_DEFAULT_ALIGNMENT) {}
|
||||||
|
|
||||||
|
bool SetValue(const wxVariant &value);
|
||||||
|
bool GetValue(wxVariant &value) const;
|
||||||
|
|
||||||
|
virtual bool Render(wxRect cell, wxDC *dc, int state);
|
||||||
|
virtual wxSize GetSize() const;
|
||||||
|
|
||||||
|
virtual bool HasEditorCtrl() const { return false; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxDataViewIconText m_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// MyCustomRenderer
|
// MyCustomRenderer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user