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

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

Inheritance diagram for Slic3r::GUI::OG_CustomCtrl:
Collaboration diagram for Slic3r::GUI::OG_CustomCtrl:

Classes

struct  CtrlLine

Public Member Functions

 OG_CustomCtrl (wxWindow *parent, OptionsGroup *og, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, const wxValidator &val=wxDefaultValidator, const wxString &name=wxEmptyString)
 ~OG_CustomCtrl ()
void OnPaint (wxPaintEvent &)
void OnMotion (wxMouseEvent &event)
void OnLeftDown (wxMouseEvent &event)
void OnLeaveWin (wxMouseEvent &event)
void init_ctrl_lines ()
bool update_visibility (ConfigOptionMode mode)
void correct_window_position (wxWindow *win, const Line &line, Field *field=nullptr)
void correct_widgets_position (wxSizer *widget, const Line &line, Field *field=nullptr)
void init_max_win_width ()
void set_max_win_width (int max_win_width)
int get_max_win_width ()
int get_title_width ()
void fixup_items_positions ()
void msw_rescale ()
void sys_color_changed ()
wxPoint get_pos (const Line &line, Field *field=nullptr)
int get_height (const Line &line)

Public Attributes

OptionsGroup * opt_group

Private Attributes

wxFont m_font
int m_v_gap
int m_v_gap2
int m_h_gap
int m_em_unit
wxSize m_bmp_mode_sz
wxSize m_bmp_blinking_sz
ScalableBitmap m_bmp_multi_extruder
int m_max_win_width {0}
std::vector< CtrlLine > ctrl_lines

Detailed Description

Constructor & Destructor Documentation

◆ OG_CustomCtrl()

Slic3r::GUI::OG_CustomCtrl::OG_CustomCtrl ( wxWindow * parent,
OptionsGroup * og,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
const wxValidator & val = wxDefaultValidator,
const wxString & name = wxEmptyString )
62 :
63 wxPanel(parent, wxID_ANY, pos, size, /*wxWANTS_CHARS |*/ wxBORDER_NONE | wxTAB_TRAVERSAL),
64 opt_group(og)
65{
66 if (!wxOSX)
67 SetDoubleBuffered(true);// SetDoubleBuffered exists on Win and Linux/GTK, but is missing on OSX
68 SetBackgroundColour(parent->GetBackgroundColour());
69
70 // BBS: new font
72 SetFont(m_font);
73 m_em_unit = em_unit(m_parent);
74 m_v_gap = lround(1.2 * m_em_unit);
75 m_v_gap2 = lround(0.8 * m_em_unit);
76 m_h_gap = lround(0.2 * m_em_unit);
77
78 //m_bmp_mode_sz = get_bitmap_size(create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12));
80
81 init_ctrl_lines();// from og.lines()
82
83 this->Bind(wxEVT_PAINT, &OG_CustomCtrl::OnPaint, this);
84 this->Bind(wxEVT_MOTION, &OG_CustomCtrl::OnMotion, this);
85 this->Bind(wxEVT_LEFT_DOWN, &OG_CustomCtrl::OnLeftDown, this);
86 this->Bind(wxEVT_LEAVE_WINDOW, &OG_CustomCtrl::OnLeaveWin, this);
87}
#define wxOSX
Definition Field.cpp:94
static wxFont Body_14
Definition Label.hpp:53
void OnLeaveWin(wxMouseEvent &event)
Definition OG_CustomCtrl.cpp:498
void OnMotion(wxMouseEvent &event)
Definition OG_CustomCtrl.cpp:371
int m_v_gap
Definition OG_CustomCtrl.hpp:48
int m_h_gap
Definition OG_CustomCtrl.hpp:50
int m_em_unit
Definition OG_CustomCtrl.hpp:51
OptionsGroup * opt_group
Definition OG_CustomCtrl.hpp:134
int m_v_gap2
Definition OG_CustomCtrl.hpp:49
wxFont m_font
Definition OG_CustomCtrl.hpp:47
wxSize m_bmp_blinking_sz
Definition OG_CustomCtrl.hpp:54
void OnPaint(wxPaintEvent &)
Definition OG_CustomCtrl.cpp:346
void init_ctrl_lines()
Definition OG_CustomCtrl.cpp:89
void OnLeftDown(wxMouseEvent &event)
Definition OG_CustomCtrl.cpp:451
static wxSize get_bitmap_size(const wxBitmap &bmp)
Definition OG_CustomCtrl.cpp:48
int em_unit(wxWindow *win)
Definition wxExtensions.cpp:424
wxBitmap create_scaled_bitmap(const std::string &bmp_name_in, wxWindow *win, const int px_cnt, const bool grayscale, const std::string &new_color, const bool menu_bitmap, const bool resize, const bool bitmap2, const std::vector< std::string > &array_new_color)
Definition wxExtensions.cpp:448

References Label::Body_14, create_scaled_bitmap(), em_unit(), Slic3r::GUI::get_bitmap_size(), init_ctrl_lines(), m_bmp_blinking_sz, m_em_unit, m_font, m_h_gap, m_v_gap, m_v_gap2, OnLeaveWin(), OnLeftDown(), OnMotion(), OnPaint(), opt_group, and wxOSX.

Referenced by Slic3r::GUI::OG_CustomCtrl::CtrlLine::CtrlLine().

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

◆ ~OG_CustomCtrl()

Slic3r::GUI::OG_CustomCtrl::~OG_CustomCtrl ( )
inline
108{}

Member Function Documentation

◆ correct_widgets_position()

void Slic3r::GUI::OG_CustomCtrl::correct_widgets_position ( wxSizer * widget,
const Line & line,
Field * field = nullptr )
567 {
568 auto children = widget->GetChildren();
569 wxPoint line_pos = get_pos(line, field);
570 int line_height = get_height(line);
571 for (auto child : children)
572 if (child->IsWindow()) {
573 wxPoint pos = line_pos;
574 wxSize sz = child->GetWindow()->GetSize();
575 pos.y += std::max(0, int(0.5 * (line_height - sz.y)));
576 if (line.extra_widget_sizer && widget == line.extra_widget_sizer)
577 pos.x += m_h_gap;
578 child->GetWindow()->SetPosition(pos);
579 line_pos.x += sz.x + m_h_gap;
580 }
581};
wxPoint get_pos(const Line &line, Field *field=nullptr)
Definition OG_CustomCtrl.cpp:145
int get_height(const Line &line)
Definition OG_CustomCtrl.cpp:136
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16

References Slic3r::GUI::Line::extra_widget_sizer, get_height(), get_pos(), and m_h_gap.

Here is the call graph for this function:

◆ correct_window_position()

void Slic3r::GUI::OG_CustomCtrl::correct_window_position ( wxWindow * win,
const Line & line,
Field * field = nullptr )
556{
557 wxPoint pos = get_pos(line, field);
558 int line_height = get_height(line);
559 if (opt_group->split_multi_line) { // BBS
560 if (line.get_options().size() > 1)
561 line_height = (line_height - m_v_gap + m_v_gap2) / line.get_options().size();
562 }
563 pos.y += std::max(0, int(0.5 * (line_height - win->GetSize().y)));
564 win->SetPosition(pos);
565};

References get_height(), Slic3r::GUI::Line::get_options(), get_pos(), m_v_gap, m_v_gap2, and opt_group.

Here is the call graph for this function:

◆ fixup_items_positions()

void Slic3r::GUI::OG_CustomCtrl::fixup_items_positions ( )
547{
548 if (GetParent() == nullptr || GetPosition().y + GetSize().y < GetParent()->GetSize().y)
549 return;
550 for (CtrlLine& line : ctrl_lines) {
551 line.correct_items_positions();
552 }
553}
std::vector< CtrlLine > ctrl_lines
Definition OG_CustomCtrl.hpp:99
Definition OG_CustomCtrl.hpp:60

References ctrl_lines.

◆ get_height()

int Slic3r::GUI::OG_CustomCtrl::get_height ( const Line & line)
137{
138 for (auto ctrl_line : ctrl_lines)
139 if (&ctrl_line.og_line == &line)
140 return ctrl_line.height;
141
142 return 0;
143}

References ctrl_lines.

Referenced by correct_widgets_position(), and correct_window_position().

Here is the caller graph for this function:

◆ get_max_win_width()

int Slic3r::GUI::OG_CustomCtrl::get_max_win_width ( )
inline
121{ return m_max_win_width; }
int m_max_win_width
Definition OG_CustomCtrl.hpp:58

References m_max_win_width.

◆ get_pos()

wxPoint Slic3r::GUI::OG_CustomCtrl::get_pos ( const Line & line,
Field * field = nullptr )

To correct translation by context have to use wxGETTEXT_IN_CONTEXT macro from wxWidget 3.1.1

istead of (opt != option_set.back())

146{
147 // BBS: new layout
148 wxCoord v_pos = 0;
149 wxCoord h_pos = get_title_width() * m_em_unit;
150
151 auto correct_line_height = [](int& line_height, wxWindow* win)
152 {
153 int win_height = win->GetSize().GetHeight();
154 if (line_height < win_height)
155 line_height = win_height;
156 };
157
158 auto correct_horiz_pos = [this](int& h_pos, Field* field) {
159 if (m_max_win_width > 0 && field->getWindow()) {
160 int win_width = field->getWindow()->GetSize().GetWidth();
161 if (dynamic_cast<CheckBox*>(field))
162 win_width *= 0.5;
163 h_pos += m_max_win_width - win_width;
164 }
165 };
166
167 auto add_label_width = [&h_pos, this](CtrlLine &ctrl_line, wxString const & label, int label_width) {
168 wxClientDC dc(this);
169 dc.SetFont(m_font);
170 wxString multiline_text;
171 auto size = Label::split_lines(dc, label_width, label, multiline_text);
172 if (label_width > 0) size.x = label_width;
173 h_pos += size.x + m_h_gap;
174 if (ctrl_line.height < size.y)
175 ctrl_line.height = size.y;
176 };
177
178 auto add_buttons_width = [&h_pos] (int blinking_button_width) {
179#ifndef DISABLE_BLINKING
180# ifndef DISABLE_UNDO_SYS
181 h_pos += 3 * blinking_button_width;
182# else
183 h_pos += 2 * blinking_button_width;
184# endif
185#else
186# ifndef DISABLE_UNDO_SYS
187 h_pos += 2 * blinking_button_width;
188# else
189 h_pos += 1 * blinking_button_width;
190# endif
191#endif
192 };
193
194 for (CtrlLine& ctrl_line : ctrl_lines) {
195 if (&ctrl_line.og_line == &line)
196 {
197 // BBS: new layout
198 // h_pos = m_bmp_mode_sz.GetWidth() + m_h_gap;
199 if (line.near_label_widget_win) {
200 wxSize near_label_widget_sz = line.near_label_widget_win->GetSize();
201 if (field_in)
202 h_pos += near_label_widget_sz.GetWidth() + m_h_gap;
203 else {
204 h_pos += m_h_gap; // ORCA fixes alignment of checkboxes on Setting Overrides page
205 break;
206 }
207 }
208 wxString label = line.label;
209 if (opt_group->label_width != 0)
210 add_label_width(ctrl_line, label, opt_group->label_width * m_em_unit);
211
212 int blinking_button_width = m_bmp_blinking_sz.GetWidth() + m_h_gap;
213
214 if (line.widget) {
215#ifndef DISABLE_BLINKING
216 h_pos += (line.has_undo_ui() ? 3 : 1) * blinking_button_width;
217#else
218 // When blinking is disabled, widget lines still need to honour
219 // option_label_at_right the same way regular lines do below.
220 if (opt_group->option_label_at_right)
221 add_buttons_width(blinking_button_width);
222#endif
223
224 for (auto child : line.widget_sizer->GetChildren())
225 if (child->IsWindow())
226 correct_line_height(ctrl_line.height, child->GetWindow());
227 break;
228 }
229
230 if (opt_group->option_label_at_right) // BBS: position buttons at right
231 add_buttons_width(blinking_button_width);
232
233 // If we have a single option with no sidetext
234 const std::vector<Option>& option_set = line.get_options();
235 if (option_set.size() == 1 && option_set.front().opt.sidetext.size() == 0 &&
236 option_set.front().side_widget == nullptr && line.get_extra_widgets().size() == 0)
237 {
238 // BBS: new layout
239 // h_pos += 3 * blinking_button_width;
240 Field* field = opt_group->get_field(option_set.front().opt_id);
241 correct_line_height(ctrl_line.height, field->getWindow());
242 correct_horiz_pos(h_pos, field);
243 break;
244 }
245
246 bool is_multioption_line = option_set.size() > 1;
247 for (auto opt : option_set) {
248 Field* field = opt_group->get_field(opt.opt_id);
249 correct_line_height(ctrl_line.height, field->getWindow());
250
251 if (!opt_group->option_label_at_right) { // BBS: position option label at right
252 ConfigOptionDef option = opt.opt;
253 // add label if any
254 if (is_multioption_line && !option.label.empty()) {
256 auto label = (option.label == L_CONTEXT("Top", "Layers") || option.label == L_CONTEXT("Bottom", "Layers")) ? _L_CONTEXT(option.label, "Layers") :
257 _(option.label);
258 // BBS
259 // label += ":";
260 add_label_width(ctrl_line, label, opt_group->sublabel_width * m_em_unit);
261 h_pos += 8;
262 }
263
264 }
265
266 if (field == field_in) {
267 correct_horiz_pos(h_pos, field);
268 break;
269 }
270 if (opt_group->split_multi_line) {// BBS
271 v_pos += (ctrl_line.height - m_v_gap + m_v_gap2) / option_set.size();
272 } else {
273 // BBS: new layout
274 h_pos += field->getWindow()->GetSize().x;
275 add_buttons_width(blinking_button_width);
276 if (option_set.size() == 1 && option_set.front().opt.full_width)
277 break;
278
279 // add sidetext if any
280 if (!field->combine_side_text() && (!opt.opt.sidetext.empty() || opt_group->sidetext_width > 0))
281 h_pos += opt_group->sidetext_width * m_em_unit + m_h_gap;
282
283 if (opt.opt_id != option_set.back().opt_id)
284 h_pos += lround(0.6 * m_em_unit);
285 }
286 }
287 break;
288 }
289 if (ctrl_line.is_visible)
290 v_pos += ctrl_line.height;
291 }
292
293 return wxPoint(h_pos, v_pos);
294}
#define _(s)
Definition 3mf.cpp:306
#define L_CONTEXT(s, context)
Definition DesignOffer.hpp:17
static wxSize split_lines(wxDC &dc, int width, const wxString &text, wxString &multiline_text, int max_count=0)
Definition Label.cpp:293
int get_title_width()
Definition OG_CustomCtrl.cpp:593
#define _L_CONTEXT(s, ctx)
Definition I18N.hpp:15

References _, _L_CONTEXT, Slic3r::GUI::Field::combine_side_text(), ctrl_lines, Slic3r::GUI::Line::get_extra_widgets(), Slic3r::GUI::Line::get_options(), get_title_width(), Slic3r::GUI::Field::getWindow(), Slic3r::GUI::UndoValueUIManager::has_undo_ui(), L_CONTEXT, Slic3r::ConfigOptionDef::label, Slic3r::GUI::Line::label, m_bmp_blinking_sz, m_em_unit, m_font, m_h_gap, m_max_win_width, m_v_gap, m_v_gap2, Slic3r::GUI::Line::near_label_widget_win, opt_group, Label::split_lines(), Slic3r::GUI::Line::widget, and Slic3r::GUI::Line::widget_sizer.

Referenced by correct_widgets_position(), and correct_window_position().

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

◆ get_title_width()

int Slic3r::GUI::OG_CustomCtrl::get_title_width ( )
594{
595 if (!GetLabel().IsEmpty())
596 return titleWidth;
597 else
598 return 2;
599}
constexpr int titleWidth
Definition OG_CustomCtrl.cpp:36

References Slic3r::GUI::titleWidth.

Referenced by get_pos(), msw_rescale(), OnPaint(), and update_visibility().

Here is the caller graph for this function:

◆ init_ctrl_lines()

void Slic3r::GUI::OG_CustomCtrl::init_ctrl_lines ( )
90{
91 const std::vector<Line>& og_lines = opt_group->get_lines();
92 for (const Line& line : og_lines)
93 {
94 if (line.is_separator()) {
95 ctrl_lines.emplace_back(CtrlLine(0, this, line));
96 continue;
97 }
98
99 if (line.full_width && (
100 // description line
101 line.widget != nullptr ||
102 // description line with widget (button)
103 !line.get_extra_widgets().empty())
104 )
105 continue;
106
107 const std::vector<Option>& option_set = line.get_options();
108 wxCoord height;
109
110 // if we have a single option with no label, no sidetext just add it directly to sizer
111 if (option_set.size() == 1 && opt_group->label_width == 0 && option_set.front().opt.full_width &&
112 option_set.front().opt.sidetext.size() == 0 && option_set.front().side_widget == nullptr &&
113 line.get_extra_widgets().size() == 0)
114 {
115 height = m_bmp_blinking_sz.GetHeight() + m_v_gap;
116 ctrl_lines.emplace_back(CtrlLine(height, this, line, true));
117 }
118 else if (opt_group->label_width != 0 && (!line.label.IsEmpty() || option_set.front().opt.gui_type == ConfigOptionDef::GUIType::legend) )
119 {
120 wxSize label_sz = GetTextExtent(line.label);
121 if (opt_group->split_multi_line) {
122 if (option_set.size() > 1) // BBS
123 height = (label_sz.y + m_v_gap2) * option_set.size() + m_v_gap - m_v_gap2;
124 else
125 height = label_sz.y * (label_sz.GetWidth() > int(opt_group->label_width * m_em_unit) ? 2 : 1) + m_v_gap;
126 } else {
127 height = label_sz.y * (label_sz.GetWidth() > int(opt_group->label_width * m_em_unit) ? 2 : 1) + m_v_gap;
128 }
129 ctrl_lines.emplace_back(CtrlLine(height, this, line, false, opt_group->staticbox));
130 }
131 else
132 assert(false);
133 }
134}
@ legend
Definition Config.hpp:2331
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185

References ctrl_lines, Slic3r::ConfigOptionDef::legend, m_bmp_blinking_sz, m_em_unit, m_v_gap, m_v_gap2, and opt_group.

Referenced by OG_CustomCtrl().

Here is the caller graph for this function:

◆ init_max_win_width()

void Slic3r::GUI::OG_CustomCtrl::init_max_win_width ( )
584{
585 if (opt_group->ctrl_horiz_alignment == wxALIGN_RIGHT && m_max_win_width == 0)
586 for (CtrlLine& line : ctrl_lines) {
587 if (int max_win_width = line.get_max_win_width();
588 m_max_win_width < max_win_width)
589 m_max_win_width = max_win_width;
590 }
591}

References ctrl_lines, m_max_win_width, and opt_group.

◆ msw_rescale()

void Slic3r::GUI::OG_CustomCtrl::msw_rescale ( )
614{
615#ifdef __WXOSX__
616 return;
617#endif
618 // BBS: new font
620 SetFont(m_font);
621 m_em_unit = em_unit(m_parent);
622 m_v_gap = lround(1.2 * m_em_unit);
623 m_v_gap2 = lround(0.8 * m_em_unit);
624 m_h_gap = lround(0.2 * m_em_unit);
625
626 //m_bmp_mode_sz = create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12).GetSize();
627 m_bmp_blinking_sz = create_scaled_bitmap("blank_16", this).GetSize();
628 if (m_bmp_multi_extruder.bmp().IsOk())
629 m_bmp_multi_extruder.msw_rescale();
630
631 m_max_win_width = 0;
632
633 wxCoord h_pos = (ctrlWidth + get_title_width() - titleWidth) * m_em_unit;
634 wxCoord h_pos2 = get_title_width() * m_em_unit;
635 wxCoord v_pos = 0;
636 for (CtrlLine& line : ctrl_lines) {
637 line.msw_rescale();
638 if (line.is_visible)
639 v_pos += (wxCoord)line.height;
640 }
641 // BBS: multi-line title
642 SetFont(Label::Head_16);
643 wxSize label_sz = GetTextExtent(GetLabel());
644 SetFont(m_font);
645 auto lineHeight = label_sz.y;
646 while (label_sz.x > h_pos2) {
647 label_sz.x -= h_pos2;
648 label_sz.y += lineHeight;
649 }
650 if (v_pos < label_sz.y) v_pos = label_sz.y;
651 // BBS: new layout
652 this->SetMinSize(wxSize(h_pos, v_pos));
653
654 GetParent()->Layout();
655}
static wxFont Head_16
Definition Label.hpp:43
ScalableBitmap m_bmp_multi_extruder
Definition OG_CustomCtrl.hpp:56
constexpr int ctrlWidth
Definition OG_CustomCtrl.cpp:37

References Label::Body_14, create_scaled_bitmap(), ctrl_lines, Slic3r::GUI::ctrlWidth, em_unit(), get_title_width(), Label::Head_16, m_bmp_blinking_sz, m_bmp_multi_extruder, m_em_unit, m_font, m_h_gap, m_max_win_width, m_v_gap, m_v_gap2, and Slic3r::GUI::titleWidth.

Here is the call graph for this function:

◆ OnLeaveWin()

void Slic3r::GUI::OG_CustomCtrl::OnLeaveWin ( wxMouseEvent & event)
499{
500 for (CtrlLine& line : ctrl_lines)
501 line.is_focused = false;
502
503 // BBS: markdown tip
504 MarkdownTip::ShowTip("", "", {});
505
506 Refresh();
507 Update();
508 event.Skip();
509}
static bool ShowTip(std::string const &tip, std::string const &tooltip, wxPoint pos)
Definition MarkdownTip.cpp:310

References ctrl_lines, Slic3r::GUI::MarkdownTip::ShowTip(), and Slic3r::GUI::wxMouseEvent.

Referenced by OG_CustomCtrl().

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

◆ OnLeftDown()

void Slic3r::GUI::OG_CustomCtrl::OnLeftDown ( wxMouseEvent & event)
452{
453 const wxPoint pos = event.GetLogicalPosition(wxClientDC(this));
454
455 for (const CtrlLine& line : ctrl_lines) {
456 if (!line.is_visible) continue;
457 if (line.launch_browser())
458 return;
459 size_t undo_icons_cnt = line.rects_undo_icon.size();
460 assert(line.rects_undo_icon.size() == line.rects_undo_to_sys_icon.size());
461
462 const std::vector<Option>& option_set = line.og_line.get_options();
463 for (size_t opt_idx = 0; opt_idx < undo_icons_cnt; opt_idx++) {
464 const std::string& opt_key = option_set[opt_idx].opt_id;
465 if (is_point_in_rect(pos, line.rects_undo_icon[opt_idx])) {
466 if (line.og_line.has_undo_ui()) {
467 if (ConfigOptionsGroup* conf_OG = dynamic_cast<ConfigOptionsGroup*>(line.ctrl->opt_group))
468 conf_OG->back_to_initial_value(opt_key);
469 }
470 else if (Field* field = opt_group->get_field(opt_key))
471 field->on_back_to_initial_value();
472 event.Skip();
473 return;
474 }
475 if (is_point_in_rect(pos, line.rects_undo_to_sys_icon[opt_idx])) {
476 if (line.og_line.has_undo_ui()) {
477 if (ConfigOptionsGroup* conf_OG = dynamic_cast<ConfigOptionsGroup*>(line.ctrl->opt_group))
478 conf_OG->back_to_sys_value(opt_key);
479 }
480 else if (Field* field = opt_group->get_field(opt_key))
481 field->on_back_to_sys_value();
482 event.Skip();
483 return;
484 }
485
486 if (opt_idx < line.rects_edit_icon.size() && is_point_in_rect(pos, line.rects_edit_icon[opt_idx])) {
487 if (Field* field = opt_group->get_field(opt_key))
488 field->on_edit_value();
489 event.Skip();
490 return;
491 }
492 }
493 }
494
495 SetFocusIgnoringChildren();
496}
static bool is_point_in_rect(const wxPoint &pt, const wxRect &rect)
Definition OG_CustomCtrl.cpp:42

References ctrl_lines, Slic3r::GUI::is_point_in_rect(), opt_group, and Slic3r::GUI::wxMouseEvent.

Referenced by OG_CustomCtrl().

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

◆ OnMotion()

void Slic3r::GUI::OG_CustomCtrl::OnMotion ( wxMouseEvent & event)
372{
373 const wxPoint pos = event.GetLogicalPosition(wxClientDC(this));
374 wxString tooltip;
375 std::string markdowntip;
376
377 // BBS: markdown tip
378 CtrlLine* focusedLine = nullptr;
379 // BBS
380
381 bool suppress_hyperlinks = false;
382
383 for (CtrlLine& line : ctrl_lines) {
384 if (!line.is_visible) continue;
385 line.is_focused = is_point_in_rect(pos, line.rect_label);
386 if (line.is_focused) {
387 if (!suppress_hyperlinks && !line.og_line.label_path.empty())
388 tooltip = OptionsGroup::get_url(line.og_line.label_path) + "\n\n";
389 tooltip += line.og_line.label_tooltip;
390 // BBS: markdown tip
391 focusedLine = &line;
392 markdowntip = line.og_line.label.empty()
393 ? line.og_line.get_options().front().opt_id : into_u8(line.og_line.label);
394 markdowntip.erase(0, markdowntip.find_last_of('#') + 1);
395 // BBS
396 break;
397 }
398
399 size_t undo_icons_cnt = line.rects_undo_icon.size();
400 assert(line.rects_undo_icon.size() == line.rects_undo_to_sys_icon.size());
401 const std::vector<Option>& option_set = line.og_line.get_options();
402 for (size_t opt_idx = 0; opt_idx < undo_icons_cnt; opt_idx++) {
403 const std::string& opt_key = option_set[opt_idx].opt_id;
404 if (is_point_in_rect(pos, line.rects_undo_icon[opt_idx])) {
405 if (line.og_line.has_undo_ui())
406 tooltip = *line.og_line.undo_tooltip();
407 else if (Field* field = opt_group->get_field(opt_key))
408 tooltip = *field->undo_tooltip();
409 break;
410 }
411 if (is_point_in_rect(pos, line.rects_undo_to_sys_icon[opt_idx])) {
412 if (line.og_line.has_undo_ui())
413 tooltip = *line.og_line.undo_to_sys_tooltip();
414 else if (Field* field = opt_group->get_field(opt_key))
415 tooltip = *field->undo_to_sys_tooltip();
416 break;
417 }
418 if (opt_idx < line.rects_edit_icon.size() && is_point_in_rect(pos, line.rects_edit_icon[opt_idx])) {
419 if (Field* field = opt_group->get_field(opt_key); field && field->has_edit_ui())
420 tooltip = *field->edit_tooltip();
421 break;
422 }
423 }
424 if (!tooltip.IsEmpty())
425 break;
426 }
427
428 // Set tooltips with information for each icon
429 // BBS: markdown tip
430 if (!markdowntip.empty()) {
431 wxWindow* window = GetGrandParent();
432 assert(focusedLine);
433 wxPoint pos2 = { 250, focusedLine->rect_label.y };
434 pos2 = ClientToScreen(pos2);
435 if (MarkdownTip::ShowTip(markdowntip, into_u8(tooltip), pos2)) {
436 tooltip.clear();
437 }
438 }
439 else {
440 MarkdownTip::ShowTip(markdowntip, "", {tooltip.empty() ? 0 : 1, 0});
441 }
442 if (GetToolTipText() != tooltip)
443 this->SetToolTip(tooltip);
444 // BBS
445
446 Refresh();
447 Update();
448 event.Skip();
449}
static wxString get_url(const std::string &path_end)
Definition OptionsGroup.cpp:1404
std::string into_u8(const wxString &str)
Definition GUI.cpp:549

References ctrl_lines, Slic3r::GUI::OptionsGroup::get_url(), Slic3r::GUI::into_u8(), Slic3r::GUI::is_point_in_rect(), opt_group, Slic3r::GUI::OG_CustomCtrl::CtrlLine::rect_label, Slic3r::GUI::MarkdownTip::ShowTip(), and Slic3r::GUI::wxMouseEvent.

Referenced by OG_CustomCtrl().

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

◆ OnPaint()

void Slic3r::GUI::OG_CustomCtrl::OnPaint ( wxPaintEvent & )
347{
348 // case, when custom controll is destroyed but doesn't deleted from the evet loop
349 if(!this->opt_group->custom_ctrl)
350 return;
351
352 wxPaintDC dc(this);
353
354 wxCoord h_pos = get_title_width() * m_em_unit + 4; // ORCA Align label with group title. StaticLine.cpp uses 18px for icon 5px for spacing. Spacing doesnt scales on messureSize()
355 wxCoord v_pos = 0;
356 // BBS: new layout
357 if (!GetLabel().IsEmpty()) {
358 dc.SetFont(Label::Head_16);
359 wxColour color = StateColor::darkModeColorFor("#283436");
360 draw_title(dc, {0, v_pos}, GetLabel(), &color, h_pos);
361 dc.SetFont(m_font);
362 }
363 for (CtrlLine& line : ctrl_lines) {
364 if (!line.is_visible)
365 continue;
366 line.render(dc, h_pos, v_pos);
367 v_pos += line.height;
368 }
369}
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219
static void draw_title(wxDC &dc, wxPoint pos, const wxString &text, const wxColour *color, int width)
Definition OG_CustomCtrl.cpp:297

References ctrl_lines, StateColor::darkModeColorFor(), Slic3r::GUI::draw_title(), get_title_width(), Label::Head_16, m_em_unit, m_font, and opt_group.

Referenced by OG_CustomCtrl().

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

◆ set_max_win_width()

void Slic3r::GUI::OG_CustomCtrl::set_max_win_width ( int max_win_width)
602{
603 if (m_max_win_width == max_win_width)
604 return;
605 m_max_win_width = max_win_width;
606 for (CtrlLine& line : ctrl_lines)
607 line.correct_items_positions();
608
609 GetParent()->Layout();
610}

References ctrl_lines, and m_max_win_width.

◆ sys_color_changed()

void Slic3r::GUI::OG_CustomCtrl::sys_color_changed ( )
658{
659 if (m_bmp_multi_extruder.bmp().IsOk())
660 m_bmp_multi_extruder.msw_rescale();
661}

References m_bmp_multi_extruder.

◆ update_visibility()

bool Slic3r::GUI::OG_CustomCtrl::update_visibility ( ConfigOptionMode mode)
512{
513 // BBS: new layout
514 wxCoord h_pos = (ctrlWidth + get_title_width() - titleWidth) * m_em_unit;
515 wxCoord h_pos2 = get_title_width() * m_em_unit;
516 wxCoord v_pos = 0;
517
518 bool has_visible_lines = false;
519 for (CtrlLine& line : ctrl_lines) {
520 line.update_visibility(mode);
521 if (line.is_visible) {
522 v_pos += (wxCoord)line.height;
523
524 if (!line.is_separator()) { // Ignore separators
525 has_visible_lines = true;
526 }
527 }
528 }
529 // BBS: multi-line title
530 SetFont(Label::Head_16);
531 wxSize label_sz = GetTextExtent(GetLabel());
532 SetFont(m_font);
533 auto lineHeight = label_sz.y;
534 while (label_sz.x > h_pos2) {
535 label_sz.x -= h_pos2;
536 label_sz.y += lineHeight;
537 }
538 if (v_pos < label_sz.y) v_pos = label_sz.y;
539
540 this->SetMinSize(wxSize(h_pos, v_pos));
541
542 return has_visible_lines;
543}

References ctrl_lines, Slic3r::GUI::ctrlWidth, get_title_width(), Label::Head_16, m_em_unit, m_font, and Slic3r::GUI::titleWidth.

Here is the call graph for this function:

Member Data Documentation

◆ ctrl_lines

◆ m_bmp_blinking_sz

wxSize Slic3r::GUI::OG_CustomCtrl::m_bmp_blinking_sz
private

◆ m_bmp_mode_sz

wxSize Slic3r::GUI::OG_CustomCtrl::m_bmp_mode_sz
private

◆ m_bmp_multi_extruder

ScalableBitmap Slic3r::GUI::OG_CustomCtrl::m_bmp_multi_extruder
private

Referenced by msw_rescale(), and sys_color_changed().

◆ m_em_unit

int Slic3r::GUI::OG_CustomCtrl::m_em_unit
private

◆ m_font

wxFont Slic3r::GUI::OG_CustomCtrl::m_font
private

◆ m_h_gap

int Slic3r::GUI::OG_CustomCtrl::m_h_gap
private

◆ m_max_win_width

int Slic3r::GUI::OG_CustomCtrl::m_max_win_width {0}
private

◆ m_v_gap

int Slic3r::GUI::OG_CustomCtrl::m_v_gap
private

◆ m_v_gap2

int Slic3r::GUI::OG_CustomCtrl::m_v_gap2
private

◆ opt_group


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