OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::GLGizmoUtils Namespace Reference

Functions

void render_tooltip_button (ImGuiWrapper *imgui_wrapper, const GLCanvas3D &canvas, const std::vector< std::pair< wxString, wxString > > &shortcuts, float x, float y)
bool render_wiki_guide_button (const GLCanvas3D &canvas, float scale, const char *url)
bool render_video_guide_button (const GLCanvas3D &canvas, float scale, const char *url)
bool toolbar_circular_button (ImTextureID textureID, const char *id, float scale)
void begin_right_aligned_buttons (const std::vector< wxString > &labels)
void push_orca_button_style ()
void pop_orca_button_style ()
void render_wiki_buttons (ImGuiWrapper *imgui_wrapper, const GLCanvas3D &canvas, const char *wiki_url, const char *video_url="")

Function Documentation

◆ begin_right_aligned_buttons()

void Slic3r::GUI::GLGizmoUtils::begin_right_aligned_buttons ( const std::vector< wxString > & labels)
136 {
137 float total_width = 0.0f;
138 ImGuiStyle& style = ImGui::GetStyle();
139 float spacing = style.ItemSpacing.x;
140 float padding = style.FramePadding.x * 2.0f;
141
142 // Calculate width
143 for (size_t i = 0; i < labels.size(); ++i) {
144 total_width += ImGuiWrapper::calc_text_size(labels[i]).x + padding;
145 if (i < labels.size() - 1)
146 total_width += spacing;
147 }
148
149 float avail = ImGui::GetContentRegionAvail().x;
150
151 // Handle Overlap: If the total width of the buttons exceeds available space, move to a new line
152 if (total_width > avail) {
153 ImGui::NewLine();
154 avail = ImGui::GetContentRegionAvail().x; // Reset to full window width
155 }
156
157 float posX = ImGui::GetCursorPosX() + std::max(0.0f, avail - total_width);
158 ImGui::SetCursorPosX(posX);
159 }
#define style
Definition WipeTowerDialog.cpp:101
static ImVec2 calc_text_size(std::string_view text, bool hide_text_after_double_hash=false, float wrap_width=-1.0f)
Extend ImGui::CalcTextSize to use string_view.
Definition ImGuiWrapper.cpp:667

References Slic3r::GUI::ImGuiWrapper::calc_text_size(), and style.

Referenced by Slic3r::GUI::GizmoObjectManipulation::do_render_move_window(), Slic3r::GUI::GizmoObjectManipulation::do_render_rotate_window(), Slic3r::GUI::GizmoObjectManipulation::do_render_scale_input_window(), Slic3r::GUI::GLGizmoEmboss::draw_window(), Slic3r::GUI::GLGizmoAssembly::on_render_input_window(), Slic3r::GUI::GLGizmoBrimEars::on_render_input_window(), Slic3r::GUI::GLGizmoFdmSupports::on_render_input_window(), Slic3r::GUI::GLGizmoFuzzySkin::on_render_input_window(), Slic3r::GUI::GLGizmoMeasure::on_render_input_window(), Slic3r::GUI::GLGizmoMmuSegmentation::on_render_input_window(), Slic3r::GUI::GLGizmoSeam::on_render_input_window(), Slic3r::GUI::GLGizmoCut3D::render_connectors_input_window(), Slic3r::GUI::GLGizmoCut3D::render_cut_plane_input_window(), and Slic3r::GUI::GLCanvas3D::LayersEditing::render_variable_layer_height_dialog().

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

◆ pop_orca_button_style()

void Slic3r::GUI::GLGizmoUtils::pop_orca_button_style ( )
188 {
189 ImGui::PopStyleVar(1);
190 ImGui::PopStyleColor(4);
191 }

Referenced by Slic3r::GUI::GLGizmoCut3D::render_connectors_input_window(), and Slic3r::GUI::GLGizmoCut3D::render_cut_plane_input_window().

Here is the caller graph for this function:

◆ push_orca_button_style()

void Slic3r::GUI::GLGizmoUtils::push_orca_button_style ( )
162 {
163 ImVec4 base_orca = ImGuiWrapper::COL_ORCA;
164
165 float h, s, v;
166 ImGui::ColorConvertRGBtoHSV(base_orca.x, base_orca.y, base_orca.z, h, s, v);
167
168 ImVec4 hover, active;
169
170 // Lighter variant for Hover (Increase Value by ~12%)
171 ImGui::ColorConvertHSVtoRGB(h, s, std::min(v + 0.12f, 1.0f), hover.x, hover.y, hover.z);
172 hover.w = base_orca.w;
173
174 // Darker variant for Active (Decrease Value by ~12%)
175 ImGui::ColorConvertHSVtoRGB(h, s, std::max(v - 0.12f, 0.0f), active.x, active.y, active.z);
176 active.w = base_orca.w;
177
178 ImGui::PushStyleColor(ImGuiCol_Button, base_orca);
179 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, hover);
180 ImGui::PushStyleColor(ImGuiCol_ButtonActive, active);
181
182 ImGui::PushStyleColor(ImGuiCol_Text, ImGuiWrapper::COL_WINDOW_BG);
183
184 ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
185 }
static const ImVec4 COL_ORCA
Definition ImGuiWrapper.hpp:408
static const ImVec4 COL_WINDOW_BG
Definition ImGuiWrapper.hpp:402

References Slic3r::GUI::ImGuiWrapper::COL_ORCA, and Slic3r::GUI::ImGuiWrapper::COL_WINDOW_BG.

Referenced by Slic3r::GUI::GLGizmoCut3D::render_connectors_input_window(), and Slic3r::GUI::GLGizmoCut3D::render_cut_plane_input_window().

Here is the caller graph for this function:

◆ render_tooltip_button()

void Slic3r::GUI::GLGizmoUtils::render_tooltip_button ( ImGuiWrapper * imgui_wrapper,
const GLCanvas3D & canvas,
const std::vector< std::pair< wxString, wxString > > & shortcuts,
float x,
float y )
50 {
51 float caption_y = ImGui::GetContentRegionMax().y + ImGui::GetFrameHeight() + y;
52 float caption_x_max = 0.f;
53 for (const auto& item : shortcuts) {
54 caption_x_max = std::max(caption_x_max, imgui_wrapper->calc_text_size(item.first).x);
55 }
56 caption_x_max += imgui_wrapper->calc_text_size(": "sv).x + 35.f;
57
58 auto& gizmos_manager = canvas.get_gizmos_manager();
60
61 float scale = canvas.get_scale();
62#ifdef WIN32
63 int dpi = get_dpi_for_window(wxGetApp().GetTopWindow());
64 scale *= (float)dpi / (float)DPI_DEFAULT;
65#endif
66
67 toolbar_circular_button(normal_id, "##tooltip_btn", scale);
68 if (ImGui::IsItemHovered()) {
69 ImGui::BeginTooltip2(ImVec2(x, caption_y));
70 for (const auto& item : shortcuts) {
71 imgui_wrapper->text_colored(ImGuiWrapper::COL_ACTIVE, item.first + ": ");
72 ImGui::SameLine(caption_x_max);
73 imgui_wrapper->text_colored(ImGuiWrapper::COL_WINDOW_BG, item.second);
74 }
75 ImGui::EndTooltip();
76 }
77 }
int scale(const int val)
Definition WipeTowerDialog.cpp:58
const GLGizmosManager & get_gizmos_manager() const
Definition GLCanvas3D.hpp:1031
const float get_scale() const
Definition GLCanvas3D.cpp:1811
@ IC_TOOLBAR_TOOLTIP
Definition GLGizmosManager.hpp:184
void * get_icon_texture_id(MENU_ICON_NAME icon)
Definition GLGizmosManager.hpp:313
static void text_colored(const ImVec4 &color, const char *label)
Definition ImGuiWrapper.cpp:1157
static const ImVec4 COL_ACTIVE
Definition ImGuiWrapper.hpp:400
bool toolbar_circular_button(ImTextureID textureID, const char *id, float scale)
Definition GLGizmoUtils.cpp:113
int get_dpi_for_window(const wxWindow *window)
Definition GUI_Utils.cpp:234
@ DPI_DEFAULT
Definition GUI_Utils.hpp:92

References Slic3r::GUI::ImGuiWrapper::calc_text_size(), Slic3r::GUI::ImGuiWrapper::COL_ACTIVE, Slic3r::GUI::ImGuiWrapper::COL_WINDOW_BG, Slic3r::GUI::DPI_DEFAULT, Slic3r::GUI::get_dpi_for_window(), Slic3r::GUI::GLCanvas3D::get_gizmos_manager(), Slic3r::GUI::GLGizmosManager::get_icon_texture_id(), Slic3r::GUI::GLCanvas3D::get_scale(), Slic3r::GUI::GLGizmosManager::IC_TOOLBAR_TOOLTIP, scale(), Slic3r::GUI::ImGuiWrapper::text_colored(), and toolbar_circular_button().

Referenced by Slic3r::GUI::GLCanvas3D::_render_assembly_tooltip_button(), Slic3r::GUI::GLCanvas3D::_render_section_view_panel(), Slic3r::GUI::GizmoObjectManipulation::do_render_move_window(), Slic3r::GUI::GizmoObjectManipulation::do_render_rotate_window(), Slic3r::GUI::GizmoObjectManipulation::do_render_scale_input_window(), Slic3r::GUI::GLGizmoEmboss::draw_window(), Slic3r::GUI::GLGizmoAssembly::on_render_input_window(), Slic3r::GUI::GLGizmoBrimEars::on_render_input_window(), Slic3r::GUI::GLGizmoMeasure::on_render_input_window(), Slic3r::GUI::GLGizmoSeam::on_render_input_window(), Slic3r::GUI::GLGizmoCut3D::render_tooltip_button(), Slic3r::GUI::GLGizmoFdmSupports::render_tooltip_button(), Slic3r::GUI::GLGizmoFuzzySkin::render_tooltip_button(), Slic3r::GUI::GLGizmoMmuSegmentation::render_tooltip_button(), and Slic3r::GUI::GLCanvas3D::LayersEditing::render_variable_layer_height_dialog().

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

◆ render_video_guide_button()

bool Slic3r::GUI::GLGizmoUtils::render_video_guide_button ( const GLCanvas3D & canvas,
float scale,
const char * url )
98 {
99 auto& gm = canvas.get_gizmos_manager();
101 bool clicked = toolbar_circular_button(icon, "##video_guide_btn", scale);
102 if (url && *url && clicked)
103 wxLaunchDefaultBrowser(wxString::FromUTF8(url));
104 if (ImGui::IsItemHovered()){
105 if(url && *url)
106 wxGetApp().imgui()->tooltip(_u8L("Video Guide") + "\n" + url, -1.f);
107 else
108 wxGetApp().imgui()->tooltip(_u8L("Video Guide"), -1.f);
109 }
110 return clicked; // for dynamically generated links
111 }
@ IC_TOOLBAR_VIDEO_GUIDE
Definition GLGizmosManager.hpp:186
#define _u8L(s)
Definition I18N.hpp:11

References _u8L, Slic3r::GUI::GLCanvas3D::get_gizmos_manager(), Slic3r::GUI::GLGizmosManager::get_icon_texture_id(), Slic3r::GUI::GLGizmosManager::IC_TOOLBAR_VIDEO_GUIDE, scale(), and toolbar_circular_button().

Here is the call graph for this function:

◆ render_wiki_buttons()

void Slic3r::GUI::GLGizmoUtils::render_wiki_buttons ( ImGuiWrapper * imgui_wrapper,
const GLCanvas3D & canvas,
const char * wiki_url,
const char * video_url = "" )

References scale().

Here is the call graph for this function:

◆ render_wiki_guide_button()

bool Slic3r::GUI::GLGizmoUtils::render_wiki_guide_button ( const GLCanvas3D & canvas,
float scale,
const char * url )
80 {
81 auto& gm = canvas.get_gizmos_manager();
83 bool clicked = toolbar_circular_button(icon, "##wiki_guide_btn", scale);
84 if (url && *url && clicked)
85 wxLaunchDefaultBrowser(wxString::FromUTF8(url));
86 // ImGuiWrapper::tooltip keeps the text readable on the dark tooltip background whatever text colour the
87 // host window pushed; a negative wrap position keeps the URL on one line.
88 if (ImGui::IsItemHovered()){
89 if(url && *url)
90 wxGetApp().imgui()->tooltip(_u8L("Wiki Guide") + "\n" + url, -1.f);
91 else
92 wxGetApp().imgui()->tooltip(_u8L("Wiki Guide"), -1.f);
93 }
94 return clicked; // for dynamically generated links
95 }
@ IC_TOOLBAR_WIKI_GUIDE
Definition GLGizmosManager.hpp:185

References _u8L, Slic3r::GUI::GLCanvas3D::get_gizmos_manager(), Slic3r::GUI::GLGizmosManager::get_icon_texture_id(), Slic3r::GUI::GLGizmosManager::IC_TOOLBAR_WIKI_GUIDE, scale(), and toolbar_circular_button().

Referenced by Slic3r::GUI::GCodeViewer::render_legend_color_arr_recommen().

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

◆ toolbar_circular_button()

bool Slic3r::GUI::GLGizmoUtils::toolbar_circular_button ( ImTextureID textureID,
const char * id,
float scale )
114 {
115 ImVec2 btn_sz = ImVec2(21 * scale, 21 * scale);
116 ImVec2 icon_sz = ImVec2(15 * scale, 15 * scale);
117 float btn_pad = (btn_sz.x - icon_sz.x) * .5f;
118
119 ImVec2 p = ImGui::GetCursorScreenPos();
120 bool clicked = ImGui::InvisibleButton(id, btn_sz);
121 ImDrawList* dl = ImGui::GetWindowDrawList();
122 bool is_dark = ImGuiWrapper::COL_WINDOW_BG.x != ImGui::GetStyleColorVec4(ImGuiCol_WindowBg).x;
125 dl->AddCircleFilled(
126 ImVec2(p.x + btn_sz.x * .5f, p.y + btn_sz.y * .5f),
127 btn_sz.x * .5f,
128 ImGui::ColorConvertFloat4ToU32((ImGui::IsItemActive()||ImGui::IsItemHovered()) ? col_hvr : col)
129 );
130 dl->AddImage(textureID, ImVec2(p.x + btn_pad, p.y + btn_pad), ImVec2(p.x + btn_sz.x - btn_pad, p.y + btn_sz.y - btn_pad));
131
132 return clicked;
133 }
static bool is_dark()
Definition TextureImportDialog.cpp:85
static const ImVec4 COL_ORCA_HOVER
Definition ImGuiWrapper.hpp:410
static const ImVec4 COL_ORCA_HOVER_DARK
Definition ImGuiWrapper.hpp:411
static const ImVec4 COL_ORCA_DARK
Definition ImGuiWrapper.hpp:409

References Slic3r::GUI::ImGuiWrapper::COL_ORCA, Slic3r::GUI::ImGuiWrapper::COL_ORCA_DARK, Slic3r::GUI::ImGuiWrapper::COL_ORCA_HOVER, Slic3r::GUI::ImGuiWrapper::COL_ORCA_HOVER_DARK, Slic3r::GUI::ImGuiWrapper::COL_WINDOW_BG, is_dark(), and scale().

Referenced by render_tooltip_button(), render_video_guide_button(), and render_wiki_guide_button().

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