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

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

Collaboration diagram for Slic3r::GUI::DailyTipsPanel:

Public Member Functions

 DailyTipsPanel (bool can_expand=true, DailyTipsLayout layout=DailyTipsLayout::Vertical)
void set_position (const ImVec2 &pos)
void set_size (const ImVec2 &size)
void set_can_expand (bool can_expand)
ImVec2 get_size ()
void render ()
void retrieve_data_from_hint_database (HintDataNavigation nav)
void expand (bool expand=true)
void collapse ()
bool is_expanded ()
void on_change_color_mode (bool is_dark)
void set_fade_opacity (float opacity)

Protected Member Functions

void render_controller_buttons (const ImVec2 &pos, const ImVec2 &size)
void push_styles ()
void pop_styles ()

Private Attributes

std::unique_ptr< DailyTipsDataRenderer > m_dailytips_renderer
size_t m_page_index { 0 }
int m_pages_count
bool m_is_expanded { true }
bool m_can_expand { true }
ImVec2 m_pos
float m_width
float m_height
float m_content_height
float m_footer_height
int m_uid
bool m_first_enter { false }
bool m_is_dark { false }
float m_fade_opacity { 1.0f }

Static Private Attributes

static int uid = 0

Detailed Description

Constructor & Destructor Documentation

◆ DailyTipsPanel()

Slic3r::GUI::DailyTipsPanel::DailyTipsPanel ( bool can_expand = true,
DailyTipsLayout layout = DailyTipsLayout::Vertical )
258 : m_pos(ImVec2(0, 0)),
259 m_width(0),
260 m_height(0),
261 m_can_expand(can_expand),
263 m_dailytips_renderer(std::make_unique<DailyTipsDataRenderer>(layout))
264{
265 ImGuiWrapper& imgui = *wxGetApp().imgui();
266 float scale = imgui.get_font_size() / 15.0f;
267 m_footer_height = 30.0f * scale;
268 m_is_expanded = wxGetApp().app_config->get("show_hints") == "true";
269}
int scale(const int val)
Definition WipeTowerDialog.cpp:58
ImVec2 m_pos
Definition DailyTips.hpp:48
bool m_can_expand
Definition DailyTips.hpp:47
static int uid
Definition DailyTips.hpp:22
std::unique_ptr< DailyTipsDataRenderer > m_dailytips_renderer
Definition DailyTips.hpp:43
int m_uid
Definition DailyTips.hpp:53
float m_footer_height
Definition DailyTips.hpp:52
float m_height
Definition DailyTips.hpp:50
bool m_is_expanded
Definition DailyTips.hpp:46
float m_width
Definition DailyTips.hpp:49

References DailyTipsPanel(), Slic3r::GUI::ImGuiWrapper::get_font_size(), m_can_expand, m_dailytips_renderer, m_footer_height, m_height, m_is_expanded, m_pos, m_uid, m_width, Slic3r::make_unique(), scale(), and uid.

Referenced by DailyTipsPanel().

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

Member Function Documentation

◆ collapse()

void Slic3r::GUI::DailyTipsPanel::collapse ( )
373{
374 if (!m_can_expand)
375 return;
376 m_is_expanded = false;
377 wxGetApp().app_config->set_bool("show_hints", false);
378}

References m_can_expand, and m_is_expanded.

Referenced by render_controller_buttons().

Here is the caller graph for this function:

◆ expand()

void Slic3r::GUI::DailyTipsPanel::expand ( bool expand = true)
365{
366 if (!m_can_expand)
367 return;
369 wxGetApp().app_config->set_bool("show_hints", expand);
370}
void expand(bool expand=true)
Definition DailyTips.cpp:364

References expand(), m_can_expand, and m_is_expanded.

Referenced by expand(), and render_controller_buttons().

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

◆ get_size()

ImVec2 Slic3r::GUI::DailyTipsPanel::get_size ( )
290{
291 return ImVec2(m_width, m_height);
292}

References m_height, and m_width.

◆ is_expanded()

bool Slic3r::GUI::DailyTipsPanel::is_expanded ( )
381{
382 return m_is_expanded;
383}

References m_is_expanded.

◆ on_change_color_mode()

void Slic3r::GUI::DailyTipsPanel::on_change_color_mode ( bool is_dark)
386{
388 m_dailytips_renderer->on_change_color_mode(is_dark);
389}
static bool is_dark()
Definition TextureImportDialog.cpp:85
bool m_is_dark
Definition DailyTips.hpp:55

References is_dark(), m_dailytips_renderer, and m_is_dark.

Here is the call graph for this function:

◆ pop_styles()

void Slic3r::GUI::DailyTipsPanel::pop_styles ( )
protected
566{
567 ImGuiWrapper& imgui = *wxGetApp().imgui();
568 imgui.pop_common_window_style();
569 ImGui::PopStyleVar(6);
570 ImGui::PopStyleColor(4);
571}

References Slic3r::GUI::ImGuiWrapper::pop_common_window_style().

Referenced by render().

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

◆ push_styles()

void Slic3r::GUI::DailyTipsPanel::push_styles ( )
protected
548{
549 ImGuiWrapper& imgui = *wxGetApp().imgui();
550 float scale = imgui.get_font_size() / 15.0f;
551 imgui.push_common_window_style(scale);
552 ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
553 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
554 // framePadding cannot be zero. Otherwise, there is a problem with icon font button display
555 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(1.0f, 1.0f));
556 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f));
557 ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2(0.0f, 0.0f));
558 ImGui::PushStyleVar(ImGuiStyleVar_ScrollbarSize, 4.0f * scale);
559 ImGui::PushStyleColor(ImGuiCol_ScrollbarBg, m_is_dark ? ImGuiWrapper::COL_WINDOW_BG_DARK : ImGuiWrapper::COL_WINDOW_BG);
560 ImGui::PushStyleColor(ImGuiCol_ScrollbarGrab, ImVec4(0.42f, 0.42f, 0.42f, 1.00f));
561 ImGui::PushStyleColor(ImGuiCol_ScrollbarGrabHovered, ImVec4(0.93f, 0.93f, 0.93f, 1.00f));
562 ImGui::PushStyleColor(ImGuiCol_ScrollbarGrabActive, ImVec4(0.93f, 0.93f, 0.93f, 1.00f));
563}
static const ImVec4 COL_WINDOW_BG_DARK
Definition ImGuiWrapper.hpp:403
static const ImVec4 COL_WINDOW_BG
Definition ImGuiWrapper.hpp:402

References Slic3r::GUI::ImGuiWrapper::COL_WINDOW_BG, Slic3r::GUI::ImGuiWrapper::COL_WINDOW_BG_DARK, Slic3r::GUI::ImGuiWrapper::get_font_size(), m_is_dark, Slic3r::GUI::ImGuiWrapper::push_common_window_style(), and scale().

Referenced by render().

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

◆ render()

void Slic3r::GUI::DailyTipsPanel::render ( )
295{
296 ImGuiWrapper& imgui = *wxGetApp().imgui();
297 float scale = imgui.get_font_size() / 15.0f;
298
299 if (!m_first_enter) {
301 m_first_enter = true;
302 }
303
304 push_styles();
305 if (m_can_expand) {
306 if (m_is_expanded) {
308 }
309 else {
311 }
312 }
313 ImGui::SetNextWindowPos(m_pos);
314 ImGui::SetNextWindowSizeConstraints(ImVec2(m_width, m_height), ImVec2(m_width, m_height));
315 int window_flags = ImGuiWindowFlags_NoTitleBar
316 | ImGuiWindowFlags_NoCollapse
317 | ImGuiWindowFlags_NoMove
318 | ImGuiWindowFlags_NoResize
319 | ImGuiWindowFlags_NoScrollbar
320 | ImGuiWindowFlags_NoScrollWithMouse;
321 if (ImGui::BeginChild((std::string("##DailyTipsPanel") + std::to_string(m_uid)).c_str(), ImVec2(m_width, m_height), false, window_flags)) {
322 if (m_can_expand) {
323 if (m_is_expanded) {
326 }
327 else {
329 }
330 }
331 else {
334 }
335
336 //{// for debug
337 // ImVec2 vMin = ImGui::GetWindowContentRegionMin();
338 // ImVec2 vMax = ImGui::GetWindowContentRegionMax();
339 // vMin += ImGui::GetWindowPos();
340 // vMax += ImGui::GetWindowPos();
341 // ImGui::GetForegroundDrawList()->AddRect(vMin, vMax, IM_COL32(180, 180, 255, 255));
342 //}
343 }
344 ImGui::EndChild();
345 pop_styles();
346}
bool m_first_enter
Definition DailyTips.hpp:54
void push_styles()
Definition DailyTips.cpp:547
void pop_styles()
Definition DailyTips.cpp:565
float m_content_height
Definition DailyTips.hpp:51
void render_controller_buttons(const ImVec2 &pos, const ImVec2 &size)
Definition DailyTips.cpp:414
void retrieve_data_from_hint_database(HintDataNavigation nav)
Definition DailyTips.cpp:348
@ Curr
Definition HintNotification.hpp:35

References Slic3r::GUI::Curr, Slic3r::GUI::ImGuiWrapper::get_font_size(), m_can_expand, m_content_height, m_dailytips_renderer, m_first_enter, m_footer_height, m_height, m_is_expanded, m_pos, m_uid, m_width, pop_styles(), push_styles(), render_controller_buttons(), retrieve_data_from_hint_database(), and scale().

Here is the call graph for this function:

◆ render_controller_buttons()

void Slic3r::GUI::DailyTipsPanel::render_controller_buttons ( const ImVec2 & pos,
const ImVec2 & size )
protected
415{
416 ImGuiWrapper& imgui = *wxGetApp().imgui();
417 float scale = imgui.get_font_size() / 15.0f;
418 ImGuiWindow* parent_window = ImGui::GetCurrentWindow();
419 int window_flags = parent_window->Flags;
420 std::string name = "##DailyTipsPanelControllers" + std::to_string(parent_window->ID);
421 ImGui::SetNextWindowPos(pos);
422 if (ImGui::BeginChild(name.c_str(), size, false, window_flags)) {
423 ImVec2 button_size = ImVec2(38.0f, 38.0f) * scale;
424 float button_margin_x = 8.0f * scale;
425 std::wstring button_text;
426
427 // collapse / expand
428 ImVec2 btn_pos = pos + ImVec2(0, (size.y - ImGui::CalcTextSize("A").y) / 2);
429 ImGui::SetCursorScreenPos(btn_pos);
430 if (m_can_expand) {
431 if (m_is_expanded) {
432 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f));
433 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(.0f, .0f, .0f, .0f));
434 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(.0f, .0f, .0f, .0f));
435 ImGui::PushStyleColor(ImGuiCol_Text, ImColor(144, 144, 144, (int)(255 * m_fade_opacity)).Value);
436
437 button_text = ImGui::CollapseArrowIcon;
438 imgui.button((_L("Collapse") + button_text));
439 ImVec2 collapse_btn_size = ImGui::CalcTextSize((_u8L("Collapse")).c_str());
440 collapse_btn_size.x += button_size.x / 2.0f;
441 if (ImGui::IsMouseHoveringRect(btn_pos, btn_pos + collapse_btn_size, true))
442 {
443 //underline
444 ImVec2 lineEnd = ImGui::GetItemRectMax();
445 lineEnd.x -= ImGui::CalcTextSize("A").x / 2;
446 lineEnd.y -= 2;
447 ImVec2 lineStart = lineEnd;
448 lineStart.x = ImGui::GetItemRectMin().x;
449 ImGui::GetWindowDrawList()->AddLine(lineStart, lineEnd, ImColor(144, 144, 144));
450
451 if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
452 collapse();
453 }
454
455 ImGui::PopStyleColor(4);
456 }
457 else {
458 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f));
459 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(.0f, .0f, .0f, .0f));
460 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(.0f, .0f, .0f, .0f));
461 ImGui::PushStyleColor(ImGuiCol_Text, m_is_dark ? ImColor(230, 230, 230, (int)(255 * m_fade_opacity)).Value : ImColor(38, 46, 48, (int)(255 * m_fade_opacity)).Value);
462
463 // for bold font text, split text and icon-font button
464 imgui.push_bold_font();
465 imgui.button((_L("Daily Tips")));
466 imgui.pop_bold_font();
467 ImVec2 expand_btn_size = ImGui::CalcTextSize((_u8L("Daily Tips")).c_str());
468 ImGui::SetCursorScreenPos(ImVec2(btn_pos.x + expand_btn_size.x + ImGui::CalcTextSize(" ").x, btn_pos.y));
469 button_text = ImGui::ExpandArrowIcon;
470 imgui.button(button_text.c_str());
471 expand_btn_size.x += 19.0f * scale;
472 if (ImGui::IsMouseHoveringRect(btn_pos, btn_pos + expand_btn_size, true))
473 {
474 //underline
475 ImVec2 lineEnd = ImGui::GetItemRectMax();
476 lineEnd.x -= ImGui::CalcTextSize("A").x / 2;
477 lineEnd.y -= 2;
478 ImVec2 lineStart = lineEnd;
479 lineStart.x = ImGui::GetItemRectMin().x - expand_btn_size.x;
480 ImGui::GetWindowDrawList()->AddLine(lineStart, lineEnd, m_is_dark ? ImColor(230, 230, 230, (int)(255 * m_fade_opacity)) : ImColor(38, 46, 48, (int)(255 * m_fade_opacity)));
481
482 if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
483 expand();
484 }
485
486 ImGui::PopStyleColor(4);
487
488 ImGui::EndChild();
489 return;
490 }
491 }
492
493 // page index
496 std::string text_str = std::to_string(m_page_index) + "/" + std::to_string(m_pages_count);
497 float text_item_width = ImGui::CalcTextSize(text_str.c_str()).x;
498 ImGui::PushItemWidth(text_item_width);
499 float text_pos_x = (pos + size).x - button_margin_x * 2 - button_size.x * 2 - text_item_width;
500 float text_pos_y = pos.y + (size.y - ImGui::CalcTextSize("A").y) / 2;
501 ImGui::SetCursorScreenPos(ImVec2(text_pos_x, text_pos_y));
502 ImGui::PushStyleColor(ImGuiCol_Text, m_is_dark ? ImColor(230, 230, 230, (int)(255 * m_fade_opacity)).Value : ImColor(38, 46, 48, (int)(255 * m_fade_opacity)).Value);
503 imgui.text(text_str);
504 ImGui::PopStyleColor();
505 ImGui::PopItemWidth();
506
507 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f));
508 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(.0f, .0f, .0f, .0f));
509 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(.0f, .0f, .0f, .0f));
510 ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(.0f, .0f, .0f, .0f));
511
512 // prev button
513 ImColor button_text_color = m_is_dark ? ImColor(228, 228, 228, (int)(255 * m_fade_opacity)) : ImColor(38, 46, 48, (int)(255 * m_fade_opacity));
514 ImVec2 prev_button_pos = pos + size + ImVec2(-button_margin_x - button_size.x * 2, -size.y + (size.y - button_size.y) / 2);
515 ImGui::SetCursorScreenPos(prev_button_pos);
516 button_text = ImGui::PrevArrowBtnIcon;
517 if (ImGui::IsMouseHoveringRect(prev_button_pos, prev_button_pos + button_size, true))
518 {
519 button_text_color = ImColor(0, 150, 136, (int)(255 * m_fade_opacity));
520 if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
522 }
523 ImGui::PushStyleColor(ImGuiCol_Text, button_text_color.Value);// for icon-font button
524 imgui.button(button_text.c_str());
525 ImGui::PopStyleColor();
526
527 // next button
528 button_text_color = m_is_dark ? ImColor(228, 228, 228, (int)(255 * m_fade_opacity)) : ImColor(38, 46, 48, (int)(255 * m_fade_opacity));
529 ImVec2 next_button_pos = pos + size + ImVec2(-button_size.x, -size.y + (size.y - button_size.y) / 2);
530 ImGui::SetCursorScreenPos(next_button_pos);
531 button_text = ImGui::NextArrowBtnIcon;
532 if (ImGui::IsMouseHoveringRect(next_button_pos, next_button_pos + button_size, true))
533 {
534 button_text_color = ImColor(0, 150, 136, (int)(255 * m_fade_opacity));
535 if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
537 }
538 ImGui::PushStyleColor(ImGuiCol_Text, button_text_color.Value);// for icon-font button
539 imgui.button(button_text.c_str());
540 ImGui::PopStyleColor();
541
542 ImGui::PopStyleColor(4);
543 }
544 ImGui::EndChild();
545}
#define _L(s)
Definition OBJ.cpp:34
void collapse()
Definition DailyTips.cpp:372
float m_fade_opacity
Definition DailyTips.hpp:56
int m_pages_count
Definition DailyTips.hpp:45
size_t m_page_index
Definition DailyTips.hpp:44
size_t get_index()
Definition HintNotification.hpp:61
static HintDatabase & get_instance()
Definition HintNotification.hpp:44
size_t get_count()
Definition HintNotification.hpp:62
@ Next
Definition HintNotification.hpp:37
@ Prev
Definition HintNotification.hpp:36
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16
#define _u8L(s)
Definition I18N.hpp:11

References _L, _u8L, Slic3r::GUI::ImGuiWrapper::button(), collapse(), expand(), Slic3r::GUI::HintDatabase::get_count(), Slic3r::GUI::ImGuiWrapper::get_font_size(), Slic3r::GUI::HintDatabase::get_index(), Slic3r::GUI::HintDatabase::get_instance(), m_can_expand, m_fade_opacity, m_is_dark, m_is_expanded, m_page_index, m_pages_count, Slic3r::GUI::Next, Slic3r::GUI::ImGuiWrapper::pop_bold_font(), Slic3r::GUI::Prev, Slic3r::GUI::ImGuiWrapper::push_bold_font(), retrieve_data_from_hint_database(), scale(), and Slic3r::GUI::ImGuiWrapper::text().

Referenced by render().

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

◆ retrieve_data_from_hint_database()

void Slic3r::GUI::DailyTipsPanel::retrieve_data_from_hint_database ( HintDataNavigation nav)
349{
350 HintData* hint_data = HintDatabase::get_instance().get_hint(nav);
351 if (hint_data != nullptr)
352 {
353 DailyTipsData data{ hint_data->text,
354 hint_data->documentation_link,
355 hint_data->image_url,
356 hint_data->follow_text,
357 hint_data->hypertext,
358 hint_data->callback
359 };
360 m_dailytips_renderer->update_data(data);
361 }
362}
HintData * get_hint(HintDataNavigation nav)
Definition HintNotification.cpp:505

References Slic3r::GUI::HintData::callback, Slic3r::GUI::HintData::documentation_link, Slic3r::GUI::HintData::follow_text, Slic3r::GUI::HintDatabase::get_hint(), Slic3r::GUI::HintDatabase::get_instance(), Slic3r::GUI::HintData::hypertext, Slic3r::GUI::HintData::image_url, m_dailytips_renderer, and Slic3r::GUI::HintData::text.

Referenced by render(), render_controller_buttons(), and Slic3r::GUI::NotificationManager::update_slicing_notif_dailytips().

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

◆ set_can_expand()

void Slic3r::GUI::DailyTipsPanel::set_can_expand ( bool can_expand)
285{
286 m_can_expand = can_expand;
287}

References m_can_expand.

◆ set_fade_opacity()

void Slic3r::GUI::DailyTipsPanel::set_fade_opacity ( float opacity)
392{
393 m_fade_opacity = opacity;
394 m_dailytips_renderer->set_fade_opacity(opacity);
395}

References m_dailytips_renderer, and m_fade_opacity.

◆ set_position()

void Slic3r::GUI::DailyTipsPanel::set_position ( const ImVec2 & pos)
272{
273 m_pos = pos;
274}

References m_pos.

◆ set_size()

void Slic3r::GUI::DailyTipsPanel::set_size ( const ImVec2 & size)
277{
278 m_width = size.x;
279 //Orca: Keep the requested content height so expanding a collapsed panel restores its full size.
282}

References m_can_expand, m_content_height, m_footer_height, m_height, m_is_expanded, and m_width.

Member Data Documentation

◆ m_can_expand

bool Slic3r::GUI::DailyTipsPanel::m_can_expand { true }
private

◆ m_content_height

float Slic3r::GUI::DailyTipsPanel::m_content_height
private

Referenced by render(), and set_size().

◆ m_dailytips_renderer

std::unique_ptr<DailyTipsDataRenderer> Slic3r::GUI::DailyTipsPanel::m_dailytips_renderer
private

◆ m_fade_opacity

float Slic3r::GUI::DailyTipsPanel::m_fade_opacity { 1.0f }
private
56{ 1.0f };

Referenced by render_controller_buttons(), and set_fade_opacity().

◆ m_first_enter

bool Slic3r::GUI::DailyTipsPanel::m_first_enter { false }
private
54{ false };

Referenced by render().

◆ m_footer_height

float Slic3r::GUI::DailyTipsPanel::m_footer_height
private

Referenced by DailyTipsPanel(), render(), and set_size().

◆ m_height

float Slic3r::GUI::DailyTipsPanel::m_height
private

◆ m_is_dark

bool Slic3r::GUI::DailyTipsPanel::m_is_dark { false }
private

◆ m_is_expanded

bool Slic3r::GUI::DailyTipsPanel::m_is_expanded { true }
private

◆ m_page_index

size_t Slic3r::GUI::DailyTipsPanel::m_page_index { 0 }
private
44{ 0 };

Referenced by render_controller_buttons().

◆ m_pages_count

int Slic3r::GUI::DailyTipsPanel::m_pages_count
private

◆ m_pos

ImVec2 Slic3r::GUI::DailyTipsPanel::m_pos
private

◆ m_uid

int Slic3r::GUI::DailyTipsPanel::m_uid
private

Referenced by DailyTipsPanel(), and render().

◆ m_width

float Slic3r::GUI::DailyTipsPanel::m_width
private

◆ uid

int Slic3r::GUI::DailyTipsPanel::uid = 0
staticprivate

Referenced by DailyTipsPanel().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/DailyTips.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/DailyTips.cpp