OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::DesignRowList Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/CAD/DesignRowList.hpp>

Inheritance diagram for Slic3r::GUI::DesignRowList:
Collaboration diagram for Slic3r::GUI::DesignRowList:

Classes

struct  Action
struct  Row
struct  Hit

Public Member Functions

 DesignRowList (wxWindow *parent, int max_visible, bool selectable=true, long style=wxBORDER_SIMPLE)
void set_rows (std::vector< Row > rows)
int selection () const
void select (int row)
void unselect ()
void begin_rename (int row)
void Rescale ()
bool AcceptsFocus () const override

Public Attributes

std::function< void()> on_select
std::function< void()> on_activate
std::function< void(int row, int id)> on_action
std::function< void(int row, const wxPoint &screen)> on_menu
std::function< void(int row, const wxString &name)> on_rename

Static Public Attributes

static constexpr const char * hover_chip = "#D4D4D4"

Protected Member Functions

void OnDrawItem (wxDC &dc, const wxRect &rect, size_t n) const override
void OnDrawBackground (wxDC &dc, const wxRect &rect, size_t n) const override
wxCoord OnMeasureItem (size_t n) const override

Private Member Functions

Hit hit_test (const wxPoint &pt) const
wxRect cell_rect (const wxRect &row, size_t count, size_t i) const
wxRect label_rect (const wxRect &row, const Row &r) const
const ScalableBitmap * icon (const std::string &name) const
void load_icons ()
void set_hover (const Hit &h)
void open_editor (int row)
void end_rename (bool commit)
void measure_row ()
void fit_rows ()

Private Attributes

std::vector< Row > m_rows
std::map< std::string, ScalableBitmap > m_icons
int m_max_visible
bool m_selectable
int m_row_h {0}
Hit m_hover
Hit m_pressed
wxTextCtrl * m_editor {nullptr}
int m_edit_row {wxNOT_FOUND}

Detailed Description


Class Documentation

◆ Slic3r::GUI::DesignRowList::Action

struct Slic3r::GUI::DesignRowList::Action
Collaboration diagram for Slic3r::GUI::DesignRowList::Action:
Class Members
string icon
int id
wxString tip

◆ Slic3r::GUI::DesignRowList::Row

struct Slic3r::GUI::DesignRowList::Row
Collaboration diagram for Slic3r::GUI::DesignRowList::Row:
Class Members
vector< Action > actions
wxColour colour
wxString edit_text
string icon
wxString label

Constructor & Destructor Documentation

◆ DesignRowList()

Slic3r::GUI::DesignRowList::DesignRowList ( wxWindow * parent,
int max_visible,
bool selectable = true,
long style = wxBORDER_SIMPLE )
35 : wxVListBox(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style)
36 , m_max_visible(std::max(max_visible, 1))
38{
39 // A non-selectable list takes no focus: from the mouse because it consumes the presses that
40 // would focus it, below, and from the keyboard through AcceptsFocus(). wxGTK reads that once,
41 // while the base class is being built, before the override exists, so it is told here.
42 if (!m_selectable)
43 SetCanFocus(false);
44
45 Bind(wxEVT_LISTBOX, [this](wxCommandEvent&) { if (on_select) on_select(); });
46 Bind(wxEVT_LISTBOX_DCLICK, [this](wxCommandEvent&) { if (on_activate) on_activate(); });
47
48 Bind(wxEVT_MOTION, [this](wxMouseEvent& e) {
49 set_hover(hit_test(e.GetPosition()));
50 e.Skip();
51 });
52 Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& e) {
53 set_hover(Hit{});
54 m_pressed = Hit{};
55 e.Skip();
56 });
57 // A press on an action cell is remembered and skipped, so the list still selects the row. A
58 // non-selectable list keeps every press from wxVListBox, which would select the row and take
59 // the focus.
60 Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
61 const Hit h = hit_test(e.GetPosition());
62 m_pressed = h.cell >= 0 ? h : Hit{};
63 if (m_selectable) e.Skip();
64 });
65 // The second press of a double-click on a cell is a press too, and is not skipped: the list
66 // would otherwise turn it into a row double-click, so a quick double toggle of the eye would
67 // also open the feature for editing.
68 Bind(wxEVT_LEFT_DCLICK, [this](wxMouseEvent& e) {
69 const Hit h = hit_test(e.GetPosition());
70 if (h.cell < 0) { m_pressed = Hit{}; if (m_selectable) e.Skip(); return; }
71 m_pressed = h;
72 });
73 Bind(wxEVT_LEFT_UP, [this](wxMouseEvent& e) {
74 e.Skip();
75 const Hit pressed = m_pressed;
76 m_pressed = Hit{};
77 if (pressed.cell < 0 || hit_test(e.GetPosition()) != pressed)
78 return;
79 const int id = m_rows[pressed.row].actions[pressed.cell].id;
80 // After the click has finished dispatching: the action may rebuild these rows. The row
81 // must still exist and still be the selected one, or the click is dropped rather than
82 // applied to whatever row took its place. A non-selectable list has no selected row.
83 CallAfter([this, row = pressed.row, id] {
84 if (row < int(GetItemCount()) && (!m_selectable || row == GetSelection()) && on_action)
85 on_action(row, id);
86 });
87 });
88 // Right-click targets the row under the pointer. Skipped, because on MSW a handled right
89 // press suppresses the wxEVT_CONTEXT_MENU that follows it.
90 Bind(wxEVT_RIGHT_DOWN, [this](wxMouseEvent& e) {
91 const Hit h = hit_test(e.GetPosition());
92 if (m_selectable && h.row != wxNOT_FOUND) select(h.row);
93 e.Skip();
94 });
95 Bind(wxEVT_CONTEXT_MENU, [this](wxContextMenuEvent& e) {
96 wxPoint screen = e.GetPosition(); // screen coordinates; wxDefaultPosition from the keyboard
97 int row = GetSelection();
98 if (screen == wxDefaultPosition) {
99 if (row == wxNOT_FOUND) return;
100 screen = ClientToScreen(GetItemRect(row).GetBottomLeft());
101 } else {
102 row = VirtualHitTest(ScreenToClient(screen).y);
103 }
104 if (row == wxNOT_FOUND || row >= int(m_rows.size()))
105 return;
106 // On MSW the menu comes with the button's release, and the pointer may have moved to
107 // another row since the press selected one: the menu is for the row it opens over.
108 if (m_selectable) select(row);
109 if (on_menu) on_menu(row, screen);
110 });
111 // wxVListBox takes every wheel event, even with nothing to scroll, so a short list would stop
112 // the sidebar it sits in from scrolling under the pointer. Hand it on instead. Not on GTK,
113 // where the sidebar scrolls natively and passes on an unhandled wheel by itself.
114 Bind(wxEVT_MOUSEWHEEL, [this](wxMouseEvent& e) {
115 end_rename(true);
116#ifndef __WXGTK__
117 if (GetVisibleRowsBegin() == 0 && GetVisibleRowsEnd() >= GetItemCount()) {
118 for (wxWindow* w = GetParent(); w != nullptr; w = w->GetParent())
119 if (auto* sw = dynamic_cast<wxScrolledWindow*>(w)) {
120 wxMouseEvent fwd(e);
121 fwd.SetEventObject(sw);
122 sw->GetEventHandler()->ProcessEvent(fwd);
123 return;
124 }
125 }
126#endif
127 e.Skip();
128 });
129 Bind(wxEVT_SIZE, [this](wxSizeEvent& e) {
130 end_rename(true); // the editor sits on a row position the new size may have moved
131 e.Skip();
132 });
133 measure_row();
134 fit_rows();
135}
#define style
Definition WipeTowerDialog.cpp:101
std::function< void()> on_activate
Definition DesignRowList.hpp:74
void measure_row()
Definition DesignRowList.cpp:139
Hit hit_test(const wxPoint &pt) const
Definition DesignRowList.cpp:318
Hit m_pressed
Definition DesignRowList.hpp:119
bool m_selectable
Definition DesignRowList.hpp:116
std::vector< Row > m_rows
Definition DesignRowList.hpp:113
void set_hover(const Hit &h)
Definition DesignRowList.cpp:371
int m_max_visible
Definition DesignRowList.hpp:115
void end_rename(bool commit)
Definition DesignRowList.cpp:239
void select(int row)
Definition DesignRowList.cpp:158
std::function< void(int row, const wxPoint &screen)> on_menu
Definition DesignRowList.hpp:82
std::function< void()> on_select
Definition DesignRowList.hpp:73
void fit_rows()
Definition DesignRowList.cpp:168
wxMouseEvent
Definition CameraPopup.cpp:47
static bool selectable(const char *label, bool selected, ImGuiSelectableFlags flags=0, const ImVec2 &size_arg=ImVec2(0, 0), bool *out_hovered=nullptr)
Definition ImGuiWrapper.cpp:1484
Definition DesignRowList.hpp:95

References Slic3r::GUI::DesignRowList::Hit::cell, end_rename(), fit_rows(), hit_test(), m_max_visible, m_pressed, m_rows, m_selectable, measure_row(), on_activate, on_menu, on_select, Slic3r::GUI::DesignRowList::Hit::row, select(), Slic3r::GUI::selectable(), set_hover(), style, and Slic3r::GUI::wxMouseEvent.

Here is the call graph for this function:

Member Function Documentation

◆ AcceptsFocus()

bool Slic3r::GUI::DesignRowList::AcceptsFocus ( ) const
inlineoverride
87{ return m_selectable && wxVListBox::AcceptsFocus(); }

References m_selectable.

◆ begin_rename()

void Slic3r::GUI::DesignRowList::begin_rename ( int row)
190{
191 CallAfter([this, row] { open_editor(row); });
192}
void open_editor(int row)
Definition DesignRowList.cpp:194

References open_editor().

Here is the call graph for this function:

◆ cell_rect()

wxRect Slic3r::GUI::DesignRowList::cell_rect ( const wxRect & row,
size_t count,
size_t i ) const
private
335{
336 const int side = FromDIP(kCellDip);
337 const int x = row.GetRight() + 1 - FromDIP(kPadDip) - int(count - i) * side;
338 return wxRect(x, row.y + (row.height - side) / 2, side, side);
339}
static unsigned int count
Definition AuxiliaryDataViewModel.cpp:246
static constexpr int kCellDip
Definition DesignRowList.cpp:28
static constexpr int kPadDip
Definition DesignRowList.cpp:29

References count, Slic3r::GUI::kCellDip, and Slic3r::GUI::kPadDip.

Referenced by hit_test(), label_rect(), and OnDrawItem().

Here is the caller graph for this function:

◆ end_rename()

void Slic3r::GUI::DesignRowList::end_rename ( bool commit)
private
240{
241 if (m_edit_row == wxNOT_FOUND)
242 return;
243 // Cleared first: hiding the focused editor moves the focus, whose kill-focus comes back here.
244 const int row = m_edit_row;
245 wxString text = m_editor->GetValue();
246 m_edit_row = wxNOT_FOUND;
247 m_editor->Hide();
248 text.Trim(true).Trim(false);
249 if (commit && on_rename && !text.empty()) // a nameless row is worse than a badly named one
250 CallAfter([this, row, text] {
251 if (on_rename && row < int(GetItemCount()))
252 on_rename(row, text);
253 });
254}
int m_edit_row
Definition DesignRowList.hpp:121
std::function< void(int row, const wxString &name)> on_rename
Definition DesignRowList.hpp:85
wxTextCtrl * m_editor
Definition DesignRowList.hpp:120

References m_edit_row, m_editor, and on_rename.

Referenced by DesignRowList(), open_editor(), and set_rows().

Here is the caller graph for this function:

◆ fit_rows()

void Slic3r::GUI::DesignRowList::fit_rows ( )
private
169{
170 const int shown = std::clamp(int(GetItemCount()), 1, m_max_visible);
171 // Plus the frame, so the last row is not clipped by it.
172 const int h = shown * m_row_h + (GetSize().y - GetClientSize().y);
173 SetMinSize(wxSize(-1, h));
174 SetMaxSize(wxSize(-1, h));
175}
int m_row_h
Definition DesignRowList.hpp:117

References m_max_visible, and m_row_h.

Referenced by DesignRowList(), Rescale(), and set_rows().

Here is the caller graph for this function:

◆ hit_test()

DesignRowList::Hit Slic3r::GUI::DesignRowList::hit_test ( const wxPoint & pt) const
private
319{
320 Hit h;
321 h.row = VirtualHitTest(pt.y);
322 if (h.row == wxNOT_FOUND || h.row >= int(m_rows.size()))
323 return Hit{};
324 const wxRect rect = GetItemRect(h.row);
325 const auto& acts = m_rows[h.row].actions;
326 for (size_t i = 0; i < acts.size(); ++i)
327 if (!acts[i].icon.empty() && cell_rect(rect, acts.size(), i).Contains(pt)) {
328 h.cell = int(i);
329 break;
330 }
331 return h;
332}
wxRect cell_rect(const wxRect &row, size_t count, size_t i) const
Definition DesignRowList.cpp:334
const ScalableBitmap * icon(const std::string &name) const
Definition DesignRowList.cpp:352
int row
Definition DesignRowList.hpp:96

References Slic3r::GUI::DesignRowList::Hit::cell, cell_rect(), icon(), m_rows, and Slic3r::GUI::DesignRowList::Hit::row.

Referenced by DesignRowList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ icon()

const ScalableBitmap * Slic3r::GUI::DesignRowList::icon ( const std::string & name) const
private
353{
354 const auto it = m_icons.find(name);
355 return it == m_icons.end() ? nullptr : &it->second;
356}
std::map< std::string, ScalableBitmap > m_icons
Definition DesignRowList.hpp:114

References m_icons.

Referenced by hit_test(), label_rect(), and OnDrawItem().

Here is the caller graph for this function:

◆ label_rect()

wxRect Slic3r::GUI::DesignRowList::label_rect ( const wxRect & row,
const Row & r ) const
private
342{
343 int left = row.x + FromDIP(kPadDip);
344 if (const ScalableBitmap* bmp = icon(r.icon))
345 left += bmp->GetBmpSize().x + FromDIP(kGapDip);
346 const int right = r.actions.empty() ? row.GetRight() + 1 - FromDIP(kPadDip)
347 : cell_rect(row, r.actions.size(), 0).x - FromDIP(kPadDip);
348 return wxRect(left, row.y, std::max(right - left, 0), row.height);
349}
static constexpr int kGapDip
Definition DesignRowList.cpp:30
@ right
Definition MarchingSquares.hpp:190
@ left
Definition MarchingSquares.hpp:188

References Slic3r::GUI::DesignRowList::Row::actions, cell_rect(), icon(), Slic3r::GUI::DesignRowList::Row::icon, Slic3r::GUI::kGapDip, and Slic3r::GUI::kPadDip.

Referenced by OnDrawItem(), open_editor(), and set_hover().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_icons()

void Slic3r::GUI::DesignRowList::load_icons ( )
private
359{
360 auto load = [this](const std::string& name) {
361 if (!name.empty() && m_icons.find(name) == m_icons.end())
362 m_icons.emplace(name, ScalableBitmap(this, name, kIconPx));
363 };
364 for (const Row& r : m_rows) {
365 load(r.icon);
366 for (const Action& a : r.actions)
367 load(a.icon);
368 }
369}
void load(Archive &archive, wxString &d)
Definition GLGizmoEmboss.cpp:3405
Definition DesignRowList.hpp:39
Definition DesignRowList.hpp:44
static constexpr int kIconPx
Definition DesignRowList.cpp:27

References Slic3r::GUI::DesignRowList::Action::icon, Slic3r::GUI::kIconPx, load(), m_icons, and m_rows.

Referenced by Rescale(), and set_rows().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ measure_row()

void Slic3r::GUI::DesignRowList::measure_row ( )
private
140{
141 m_row_h = std::max(GetCharHeight() + 8, FromDIP(kCellDip + 2));
142}

References Slic3r::GUI::kCellDip, and m_row_h.

Referenced by DesignRowList(), and Rescale().

Here is the caller graph for this function:

◆ OnDrawBackground()

void Slic3r::GUI::DesignRowList::OnDrawBackground ( wxDC & dc,
const wxRect & rect,
size_t n ) const
overrideprotected
262{
263 // ObjectList's selection teal, and the dropdowns' lighter hover teal; both are dark-mapped.
264 wxColour bg;
265 if (IsSelected(n))
266 bg = StateColor::darkModeColorFor(wxColour("#BFE1DE"));
267 else if (m_selectable && int(n) == m_hover.row) // a non-selectable row lights only its icons
268 bg = StateColor::darkModeColorFor(wxColour("#E5F0EE"));
269 if (!bg.IsOk())
270 return; // the list already cleared to its background colour
271 dc.SetPen(*wxTRANSPARENT_PEN);
272 dc.SetBrush(wxBrush(bg));
273 dc.DrawRectangle(rect);
274}
Hit m_hover
Definition DesignRowList.hpp:118
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References StateColor::darkModeColorFor(), m_hover, and m_selectable.

Here is the call graph for this function:

◆ OnDrawItem()

void Slic3r::GUI::DesignRowList::OnDrawItem ( wxDC & dc,
const wxRect & rect,
size_t n ) const
overrideprotected
277{
278 if (n >= m_rows.size())
279 return;
280 const Row& r = m_rows[n];
281
282 if (const ScalableBitmap* bmp = icon(r.icon)) {
283 const wxSize sz = bmp->GetBmpSize();
284 dc.DrawBitmap(bmp->bmp(), rect.x + FromDIP(kPadDip), rect.y + (rect.height - sz.y) / 2, true);
285 }
286
287 const wxRect lr = label_rect(rect, r);
288 dc.SetFont(GetFont());
289 dc.SetTextForeground(r.colour.IsOk() ? r.colour : GetForegroundColour());
290 const wxString text = wxControl::Ellipsize(r.label, dc, wxELLIPSIZE_END, std::max(lr.width, 0));
291 dc.DrawText(text, lr.x, lr.y + (lr.height - dc.GetCharHeight()) / 2);
292
293 for (size_t i = 0; i < r.actions.size(); ++i) {
294 const wxRect cell = cell_rect(rect, r.actions.size(), i);
295 if (m_hover.row == int(n) && m_hover.cell == int(i)) {
296 // Drawn through a graphics context so the rounded corners are anti-aliased on MSW too,
297 // and released before the icon goes on top.
298 const wxColour chip = StateColor::darkModeColorFor(wxColour(hover_chip));
299 const double rad = FromDIP(4);
300 std::unique_ptr<wxGraphicsContext> gc(wxGraphicsContext::CreateFromUnknownDC(dc));
301 if (gc) {
302 gc->SetPen(*wxTRANSPARENT_PEN);
303 gc->SetBrush(wxBrush(chip));
304 gc->DrawRoundedRectangle(cell.x, cell.y, cell.width, cell.height, rad);
305 } else {
306 dc.SetPen(*wxTRANSPARENT_PEN);
307 dc.SetBrush(wxBrush(chip));
308 dc.DrawRoundedRectangle(cell, rad);
309 }
310 }
311 if (const ScalableBitmap* bmp = icon(r.actions[i].icon)) {
312 const wxSize sz = bmp->GetBmpSize();
313 dc.DrawBitmap(bmp->bmp(), cell.x + (cell.width - sz.x) / 2, cell.y + (cell.height - sz.y) / 2, true);
314 }
315 }
316}
static constexpr const char * hover_chip
Definition DesignRowList.hpp:54
wxRect label_rect(const wxRect &row, const Row &r) const
Definition DesignRowList.cpp:341
double rad(double deg)
Definition DesignSketchTool.cpp:7748

References Slic3r::GUI::DesignRowList::Row::actions, cell_rect(), Slic3r::GUI::DesignRowList::Row::colour, StateColor::darkModeColorFor(), hover_chip, icon(), Slic3r::GUI::DesignRowList::Row::icon, Slic3r::GUI::kPadDip, Slic3r::GUI::DesignRowList::Row::label, label_rect(), m_hover, and m_rows.

Here is the call graph for this function:

◆ OnMeasureItem()

wxCoord Slic3r::GUI::DesignRowList::OnMeasureItem ( size_t n) const
overrideprotected
257{
258 return m_row_h;
259}

References m_row_h.

◆ open_editor()

void Slic3r::GUI::DesignRowList::open_editor ( int row)
private
195{
196 if (row < 0 || row >= int(m_rows.size()))
197 return;
198 end_rename(false);
199 if (m_editor == nullptr) {
200 // A raw wxTextCtrl, as wxTreeCtrl's own label editor is: it is a transient overlay on one
201 // row, not a form field, and ::TextInput's frame would not fit inside the row.
202 m_editor = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
203 wxTE_PROCESS_ENTER | wxBORDER_SIMPLE);
204 m_editor->Hide();
205 m_editor->Bind(wxEVT_TEXT_ENTER, [this](wxCommandEvent&) {
206 end_rename(true);
207 SetFocus();
208 });
209 // Esc must stop here. CHAR_HOOK reaches the focused editor before its ancestors, and the
210 // Design panel's own hook answers Esc whatever holds focus, so a skipped Esc would close
211 // the open tool as well as the editor.
212 m_editor->Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) {
213 if (e.GetKeyCode() != WXK_ESCAPE) { e.Skip(); return; }
214 end_rename(false);
215 SetFocus();
216 });
217 m_editor->Bind(wxEVT_KILL_FOCUS, [this](wxFocusEvent& e) {
218 e.Skip();
219 end_rename(true);
220 });
221 }
222 if (!IsRowVisible(row))
223 ScrollToRow(row);
224 const Row& r = m_rows[row];
225 const wxRect rc = label_rect(GetItemRect(row), r);
226 m_editor->SetFont(GetFont());
227 m_editor->SetBackgroundColour(GetBackgroundColour());
228 m_editor->SetForegroundColour(r.colour.IsOk() ? r.colour : GetForegroundColour());
229 m_editor->SetValue(r.edit_text.empty() ? r.label : r.edit_text);
230 const int h = std::max(rc.height, m_editor->GetBestSize().y);
231 const int y = std::clamp(rc.y + (rc.height - h) / 2, 0, std::max(0, GetClientSize().y - h));
232 m_editor->SetSize(rc.x - FromDIP(2), y, rc.width + FromDIP(2), h);
233 m_edit_row = row;
234 m_editor->Show();
235 m_editor->SetFocus();
236 m_editor->SelectAll();
237}

References Slic3r::GUI::DesignRowList::Row::colour, Slic3r::GUI::DesignRowList::Row::edit_text, end_rename(), Slic3r::GUI::DesignRowList::Row::label, label_rect(), m_edit_row, m_editor, and m_rows.

Referenced by begin_rename().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Rescale()

void Slic3r::GUI::DesignRowList::Rescale ( )
178{
179 m_icons.clear();
180 load_icons();
181 measure_row();
182 // The scrollbar's total is only recomputed when the item count is set; RefreshAll() alone
183 // would leave it at the old scale.
184 SetItemCount(GetItemCount());
185 fit_rows();
186 Refresh();
187}
void load_icons()
Definition DesignRowList.cpp:358

References fit_rows(), load_icons(), m_icons, and measure_row().

Here is the call graph for this function:

◆ select()

void Slic3r::GUI::DesignRowList::select ( int row)
159{
160 if (row < 0 || row >= int(GetItemCount()))
161 row = wxNOT_FOUND;
162 if (row == GetSelection())
163 return;
164 SetSelection(row);
165 if (on_select) on_select();
166}

References on_select.

Referenced by DesignRowList(), and unselect().

Here is the caller graph for this function:

◆ selection()

int Slic3r::GUI::DesignRowList::selection ( ) const
inline
63{ return GetSelection(); }

◆ set_hover()

void Slic3r::GUI::DesignRowList::set_hover ( const Hit & h)
private
372{
373 if (h == m_hover)
374 return;
375 const int old = m_hover.row;
376 m_hover = h;
377 if (old != wxNOT_FOUND && old < int(GetItemCount()))
378 RefreshRow(old);
379 if (h.row != wxNOT_FOUND && h.row != old)
380 RefreshRow(h.row);
381
382 // The tip names the icon under the pointer, or the whole label where the row cuts it short.
383 wxString tip;
384 if (h.row != wxNOT_FOUND) {
385 const Row& r = m_rows[h.row];
386 if (h.cell >= 0)
387 tip = r.actions[h.cell].tip;
388 else if (GetTextExtent(r.label).x > label_rect(GetItemRect(h.row), r).width)
389 tip = r.label;
390 }
391 if (tip.empty())
392 UnsetToolTip();
393 else if (tip != GetToolTipText())
394 SetToolTip(tip);
395}

References Slic3r::GUI::DesignRowList::Row::actions, Slic3r::GUI::DesignRowList::Hit::cell, Slic3r::GUI::DesignRowList::Row::label, label_rect(), m_hover, m_rows, and Slic3r::GUI::DesignRowList::Hit::row.

Referenced by DesignRowList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_rows()

void Slic3r::GUI::DesignRowList::set_rows ( std::vector< Row > rows)
145{
146 end_rename(false); // the row it names may no longer be that row
147 SetSelection(wxNOT_FOUND);
148 m_rows = std::move(rows);
149 m_hover = Hit{};
150 m_pressed = Hit{};
151 UnsetToolTip();
152 load_icons();
153 SetItemCount(m_rows.size());
154 fit_rows();
155 Refresh();
156}

References end_rename(), fit_rows(), load_icons(), m_hover, m_pressed, and m_rows.

Here is the call graph for this function:

◆ unselect()

void Slic3r::GUI::DesignRowList::unselect ( )
inline
66{ select(wxNOT_FOUND); }

References select().

Here is the call graph for this function:

Member Data Documentation

◆ hover_chip

const char* Slic3r::GUI::DesignRowList::hover_chip = "#D4D4D4"
staticconstexpr

◆ m_edit_row

int Slic3r::GUI::DesignRowList::m_edit_row {wxNOT_FOUND}
private
121{wxNOT_FOUND};

Referenced by end_rename(), and open_editor().

◆ m_editor

wxTextCtrl* Slic3r::GUI::DesignRowList::m_editor {nullptr}
private
120{nullptr}; // created on the first rename, then reused

Referenced by end_rename(), and open_editor().

◆ m_hover

Hit Slic3r::GUI::DesignRowList::m_hover
private

◆ m_icons

std::map<std::string, ScalableBitmap> Slic3r::GUI::DesignRowList::m_icons
private

Referenced by icon(), load_icons(), and Rescale().

◆ m_max_visible

int Slic3r::GUI::DesignRowList::m_max_visible
private

Referenced by DesignRowList(), and fit_rows().

◆ m_pressed

Hit Slic3r::GUI::DesignRowList::m_pressed
private

Referenced by DesignRowList(), and set_rows().

◆ m_row_h

int Slic3r::GUI::DesignRowList::m_row_h {0}
private
117{0}; // every row's height, from measure_row()

Referenced by fit_rows(), measure_row(), and OnMeasureItem().

◆ m_rows

std::vector<Row> Slic3r::GUI::DesignRowList::m_rows
private

◆ m_selectable

bool Slic3r::GUI::DesignRowList::m_selectable
private

◆ on_action

std::function<void(int row, int id)> Slic3r::GUI::DesignRowList::on_action

◆ on_activate

std::function<void()> Slic3r::GUI::DesignRowList::on_activate

Referenced by DesignRowList().

◆ on_menu

std::function<void(int row, const wxPoint& screen)> Slic3r::GUI::DesignRowList::on_menu

Referenced by DesignRowList().

◆ on_rename

std::function<void(int row, const wxString& name)> Slic3r::GUI::DesignRowList::on_rename

Referenced by end_rename().

◆ on_select

std::function<void()> Slic3r::GUI::DesignRowList::on_select

Referenced by DesignRowList(), and select().


The documentation for this class was generated from the following files: