Fix iconic button sizes on widgets (paint modes and gcode viewer buttons) (#13365)

* init

* update
This commit is contained in:
yw4z
2026-05-05 19:07:15 +03:00
committed by GitHub
parent 1433521f98
commit c2ac0baa05
7 changed files with 145 additions and 98 deletions

View File

@@ -516,13 +516,15 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
} }
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding , 3.f * m_scale); ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding , 3.f * m_scale);
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(.5f, .5f)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding , ImVec2(2.f, 2.f) * m_scale);
ImGui::PushStyleColor(ImGuiCol_Button , ImVec4(0, 0, 0, 0)); ImGui::PushStyleColor(ImGuiCol_Button , ImVec4(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered , ImVec4(84 / 255.f, 84 / 255.f, 90 / 255.f, 1.f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered , ImVec4(84 / 255.f, 84 / 255.f, 90 / 255.f, 1.f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive , ImVec4(84 / 255.f, 84 / 255.f, 90 / 255.f, 1.f)); ImGui::PushStyleColor(ImGuiCol_ButtonActive , ImVec4(84 / 255.f, 84 / 255.f, 90 / 255.f, 1.f));
const float main_wnd_height = ImGui::GetWindowHeight(); const float main_wnd_height = ImGui::GetWindowHeight();
if (ImGui::Button(into_u8(properties_shown ? ImGui::UnfoldButtonIcon : ImGui::FoldButtonIcon).c_str(), ImVec2(24.f, 24.f) * m_scale)) { // ORCA use glyph based button for fixing button sizes changing depends on used font size on platform
const wchar_t foldIcon = properties_shown ? ImGui::UnfoldButtonIcon : ImGui::FoldButtonIcon;
if (imgui.glyph_button(foldIcon, ImVec2(16.f, 16.f) * m_scale)) {
properties_shown = !properties_shown; properties_shown = !properties_shown;
static float main_wnd_height_temp = ImGui::GetWindowHeight(); static float main_wnd_height_temp = ImGui::GetWindowHeight();
static float first_click = true; static float first_click = true;
@@ -537,6 +539,7 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
ImGui::SameLine(); ImGui::SameLine();
if(!properties_shown)
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - ImGui::GetStyle().FramePadding.y); // aligns button with next group ImGui::SetCursorPosY(ImGui::GetCursorPosY() - ImGui::GetStyle().FramePadding.y); // aligns button with next group
ImGui::BeginGroup(); // group contents to make information area more compact ImGui::BeginGroup(); // group contents to make information area more compact
@@ -3327,29 +3330,26 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
ImGui::Dummy({ window_padding, window_padding }); ImGui::Dummy({ window_padding, window_padding });
ImGui::Dummy({ window_padding, window_padding }); ImGui::Dummy({ window_padding, window_padding });
ImGui::SameLine(window_padding * 2); // ORCA Ignores item spacing to get perfect window margins since since this part uses dummies for window padding ImGui::SameLine(window_padding * 2); // ORCA Ignores item spacing to get perfect window margins since since this part uses dummies for window padding
std::wstring btn_name;
if (m_fold)
btn_name = ImGui::UnfoldButtonIcon;
else
btn_name = ImGui::FoldButtonIcon;
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(84 / 255.f, 84 / 255.f, 90 / 255.f, 1.f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(84 / 255.f, 84 / 255.f, 90 / 255.f, 1.f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(84 / 255.f, 84 / 255.f, 90 / 255.f, 1.f)); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(84 / 255.f, 84 / 255.f, 90 / 255.f, 1.f));
float calc_padding = (ImGui::GetFrameHeight() - 16 * m_scale) / 2; // ORCA calculated padding for 16x16 icon ImGui::PushStyleVar(ImGuiStyleVar_FramePadding , ImVec2(2.f, 2.f) * m_scale);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(calc_padding, calc_padding)); // ORCA Center icon with frame padding
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f * m_scale); // ORCA Match button style with combo box ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f * m_scale); // ORCA Match button style with combo box
float button_width = 16 * m_scale + calc_padding * 2; // ORCA match buttons height with combo box // ORCA use glyph based button for fixing button sizes changing depends on used font size on platform
if (ImGui::Button(into_u8(btn_name).c_str(), ImVec2(button_width, button_width))) { const wchar_t foldIcon = m_fold ? ImGui::UnfoldButtonIcon : ImGui::FoldButtonIcon;
if (imgui.glyph_button(foldIcon, ImVec2(16.f, 16.f) * m_scale)) {
m_fold = !m_fold; m_fold = !m_fold;
} }
ImGui::SameLine(); ImGui::SameLine();
const wchar_t gCodeToggle = ImGui::gCodeButtonIcon; const wchar_t gCodeToggle = ImGui::gCodeButtonIcon;
if (ImGui::Button(into_u8(gCodeToggle).c_str(), ImVec2(button_width, button_width))) { if (imgui.glyph_button(gCodeToggle, ImVec2(16.f, 16.f) * m_scale)) {
wxGetApp().toggle_show_gcode_window(); wxGetApp().toggle_show_gcode_window();
wxGetApp().plater()->get_current_canvas3D()->post_event(SimpleEvent(wxEVT_PAINT)); wxGetApp().plater()->get_current_canvas3D()->post_event(SimpleEvent(wxEVT_PAINT));
} }
ImGui::PopStyleColor(3); ImGui::PopStyleColor(3);
ImGui::PopStyleVar(2); ImGui::PopStyleVar(2);

View File

@@ -191,6 +191,12 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
if (! m_c->selection_info()->model_object()) if (! m_c->selection_info()->model_object())
return; return;
float scale = m_parent.get_scale();
#ifdef WIN32
int dpi = get_dpi_for_window(wxGetApp().GetTopWindow());
scale *= (float) dpi / (float) DPI_DEFAULT;
#endif // WIN32
// BBS // BBS
wchar_t old_tool = m_current_tool; wchar_t old_tool = m_current_tool;
@@ -258,30 +264,24 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
std::array<wxString, 4> tool_tips = { _L("Circle"), _L("Sphere"), _L("Fill"), _L("Gap Fill") }; std::array<wxString, 4> tool_tips = { _L("Circle"), _L("Sphere"), _L("Fill"), _L("Gap Fill") };
for (int i = 0; i < tool_ids.size(); i++) { for (int i = 0; i < tool_ids.size(); i++) {
std::string str_label = std::string("##"); //std::string str_label = std::string("##");
std::wstring btn_name = icons[i] + boost::nowide::widen(str_label); //std::wstring btn_name = icons[i] + boost::nowide::widen(str_label);
if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(1.3f)); if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(1.3f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0); bool is_active = m_current_tool == tool_ids[i];
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.f, 0.f, 0.f)); // ORCA Removes button background on dark mode ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.f);
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f)); // ORCA: Fixes icon rendered without colors while using Light theme ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding , 3.f * scale);
if (m_current_tool == tool_ids[i]) { ImGui::PushStyleVar(ImGuiStyleVar_FramePadding , ImVec2(4.f * scale, 4.f * scale));
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush ImGui::PushStyleColor(ImGuiCol_Text , ImVec4(1,1,1,1)); // ORCA Fixes icon rendered without colors while using Light theme
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush ImGui::PushStyleColor(ImGuiCol_Button , is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(0,0,0,0)); // ORCA
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.59f, 0.53f, 0.30f)); // ORCA use orca color for selected tool / brush ImGui::PushStyleColor(ImGuiCol_ButtonHovered, is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(.6f,.6f,.6f,.2f)); // ORCA
ImGui::PushStyleColor(ImGuiCol_Border, ImGuiWrapper::COL_ORCA); // ORCA use orca color for border on selected tool / brush ImGui::PushStyleColor(ImGuiCol_ButtonActive , is_active ? ImVec4(0.f, .59f, .53f, .30f) : ImVec4(0,0,0,0)); // ORCA
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0); ImGui::PushStyleColor(ImGuiCol_Border , is_active ? ImGuiWrapper::COL_ORCA : ImVec4(0,0,0,0)); // ORCA
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0); ImGui::PushStyleColor(ImGuiCol_BorderActive , is_active ? ImGuiWrapper::COL_ORCA : ImVec4(0,0,0,0)); // ORCA matched color for fixing flicker on click
} bool btn_clicked = m_imgui->glyph_button(icons[i], ImVec2(16.f * scale, 16.f * scale)); // ORCA glyph_button for fixing unequal paddings
bool btn_clicked = ImGui::Button(into_u8(btn_name).c_str()); ImGui::PopStyleColor(6);
if (m_current_tool == tool_ids[i]) ImGui::PopStyleVar(3);
{
ImGui::PopStyleColor(4);
ImGui::PopStyleVar(2);
}
ImGui::PopStyleColor(2);
ImGui::PopStyleVar(1);
if (btn_clicked && m_current_tool != tool_ids[i]) { if (btn_clicked && m_current_tool != tool_ids[i]) {
m_current_tool = tool_ids[i]; m_current_tool = tool_ids[i];

View File

@@ -117,6 +117,12 @@ void GLGizmoFuzzySkin::on_render_input_window(float x, float y, float bottom_lim
if (!mo) if (!mo)
return; return;
float scale = m_parent.get_scale();
#ifdef WIN32
int dpi = get_dpi_for_window(wxGetApp().GetTopWindow());
scale *= (float) dpi / (float) DPI_DEFAULT;
#endif // WIN32
const DynamicPrintConfig &obj_cfg = mo->config.get(); const DynamicPrintConfig &obj_cfg = mo->config.get();
const float approx_height = m_imgui->scaled(22.f); const float approx_height = m_imgui->scaled(22.f);
@@ -192,29 +198,24 @@ void GLGizmoFuzzySkin::on_render_input_window(float x, float y, float bottom_lim
icons = { ImGui::CircleButtonIcon, ImGui::SphereButtonIcon, ImGui::TriangleButtonIcon, ImGui::FillButtonIcon }; icons = { ImGui::CircleButtonIcon, ImGui::SphereButtonIcon, ImGui::TriangleButtonIcon, ImGui::FillButtonIcon };
std::array<wxString, 4> tool_tips = { _L("Circle"), _L("Sphere"), _L("Triangle"), _L("Fill") }; std::array<wxString, 4> tool_tips = { _L("Circle"), _L("Sphere"), _L("Triangle"), _L("Fill") };
for (int i = 0; i < tool_ids.size(); i++) { for (int i = 0; i < tool_ids.size(); i++) {
std::string str_label = std::string(""); //std::string str_label = std::string("");
std::wstring btn_name = icons[i] + boost::nowide::widen(str_label); //std::wstring btn_name = icons[i] + boost::nowide::widen(str_label);
if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(1.5f)); if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(1.5f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.f, 0.f, 0.f)); // ORCA Removes button background on dark mode bool is_active = m_current_tool == tool_ids[i];
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f)); // ORCA Fixes icon rendered without colors while using Light theme ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.f);
if (m_current_tool == tool_ids[i]) { ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding , 3.f * scale);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush ImGui::PushStyleVar(ImGuiStyleVar_FramePadding , ImVec2(4.f * scale, 4.f * scale));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush ImGui::PushStyleColor(ImGuiCol_Text , ImVec4(1,1,1,1)); // ORCA Fixes icon rendered without colors while using Light theme
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.59f, 0.53f, 0.30f)); // ORCA use orca color for selected tool / brush ImGui::PushStyleColor(ImGuiCol_Button , is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(0,0,0,0)); // ORCA
ImGui::PushStyleColor(ImGuiCol_Border, ImGuiWrapper::COL_ORCA); // ORCA use orca color for border on selected tool / brush ImGui::PushStyleColor(ImGuiCol_ButtonHovered, is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(.6f,.6f,.6f,.2f)); // ORCA
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0); ImGui::PushStyleColor(ImGuiCol_ButtonActive , is_active ? ImVec4(0.f, .59f, .53f, .30f) : ImVec4(0,0,0,0)); // ORCA
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0); ImGui::PushStyleColor(ImGuiCol_Border , is_active ? ImGuiWrapper::COL_ORCA : ImVec4(0,0,0,0)); // ORCA
} ImGui::PushStyleColor(ImGuiCol_BorderActive , is_active ? ImGuiWrapper::COL_ORCA : ImVec4(0,0,0,0)); // ORCA matched color for fixing flicker on click
bool btn_clicked = ImGui::Button(into_u8(btn_name).c_str()); bool btn_clicked = m_imgui->glyph_button(icons[i], ImVec2(16.f * scale, 16.f * scale)); // ORCA glyph_button for fixing unequal paddings
if (m_current_tool == tool_ids[i]) ImGui::PopStyleColor(6);
{ ImGui::PopStyleVar(3);
ImGui::PopStyleColor(4);
ImGui::PopStyleVar(2);
}
ImGui::PopStyleColor(2);
ImGui::PopStyleVar(1);
if (btn_clicked && m_current_tool != tool_ids[i]) { if (btn_clicked && m_current_tool != tool_ids[i]) {
m_current_tool = tool_ids[i]; m_current_tool = tool_ids[i];

View File

@@ -483,29 +483,24 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott
icons = { ImGui::CircleButtonIcon, ImGui::SphereButtonIcon, ImGui::TriangleButtonIcon, ImGui::HeightRangeIcon, ImGui::FillButtonIcon, ImGui::GapFillIcon }; icons = { ImGui::CircleButtonIcon, ImGui::SphereButtonIcon, ImGui::TriangleButtonIcon, ImGui::HeightRangeIcon, ImGui::FillButtonIcon, ImGui::GapFillIcon };
std::array<wxString, 6> tool_tips = { _L("Circle"), _L("Sphere"), _L("Triangle"), _L("Height Range"), _L("Fill"), _L("Gap Fill") }; std::array<wxString, 6> tool_tips = { _L("Circle"), _L("Sphere"), _L("Triangle"), _L("Height Range"), _L("Fill"), _L("Gap Fill") };
for (int i = 0; i < tool_ids.size(); i++) { for (int i = 0; i < tool_ids.size(); i++) {
std::string str_label = std::string(""); //std::string str_label = std::string("");
std::wstring btn_name = icons[i] + boost::nowide::widen(str_label); //std::wstring btn_name = icons[i] + boost::nowide::widen(str_label);
if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(1.5f)); if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(1.5f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.f, 0.f, 0.f)); // ORCA Removes button background on dark mode bool is_active = m_current_tool == tool_ids[i];
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f)); // ORCA Fixes icon rendered without colors while using Light theme ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.f);
if (m_current_tool == tool_ids[i]) { ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding , 3.f * scale);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush ImGui::PushStyleVar(ImGuiStyleVar_FramePadding , ImVec2(4.f * scale, 4.f * scale));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush ImGui::PushStyleColor(ImGuiCol_Text , ImVec4(1,1,1,1)); // ORCA Fixes icon rendered without colors while using Light theme
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.59f, 0.53f, 0.30f)); // ORCA use orca color for selected tool / brush ImGui::PushStyleColor(ImGuiCol_Button , is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(0,0,0,0)); // ORCA
ImGui::PushStyleColor(ImGuiCol_Border, ImGuiWrapper::COL_ORCA); // ORCA use orca color for border on selected tool / brush ImGui::PushStyleColor(ImGuiCol_ButtonHovered, is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(.6f,.6f,.6f,.2f)); // ORCA
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0); ImGui::PushStyleColor(ImGuiCol_ButtonActive , is_active ? ImVec4(0.f, .59f, .53f, .30f) : ImVec4(0,0,0,0)); // ORCA
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0); ImGui::PushStyleColor(ImGuiCol_Border , is_active ? ImGuiWrapper::COL_ORCA : ImVec4(0,0,0,0)); // ORCA
} ImGui::PushStyleColor(ImGuiCol_BorderActive , is_active ? ImGuiWrapper::COL_ORCA : ImVec4(0,0,0,0)); // ORCA matched color for fixing flicker on click
bool btn_clicked = ImGui::Button(into_u8(btn_name).c_str()); bool btn_clicked = m_imgui->glyph_button(icons[i], ImVec2(16.f * scale, 16.f * scale)); // ORCA glyph_button for fixing unequal paddings
if (m_current_tool == tool_ids[i]) ImGui::PopStyleColor(6);
{ ImGui::PopStyleVar(3);
ImGui::PopStyleColor(4);
ImGui::PopStyleVar(2);
}
ImGui::PopStyleColor(2);
ImGui::PopStyleVar(1);
if (btn_clicked && m_current_tool != tool_ids[i]) { if (btn_clicked && m_current_tool != tool_ids[i]) {
m_current_tool = tool_ids[i]; m_current_tool = tool_ids[i];

View File

@@ -121,6 +121,12 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
if (! m_c->selection_info()->model_object()) if (! m_c->selection_info()->model_object())
return; return;
float scale = m_parent.get_scale();
#ifdef WIN32
int dpi = get_dpi_for_window(wxGetApp().GetTopWindow());
scale *= (float) dpi / (float) DPI_DEFAULT;
#endif // WIN32
const float approx_height = m_imgui->scaled(12.5f); const float approx_height = m_imgui->scaled(12.5f);
y = std::min(y, bottom_limit - approx_height); y = std::min(y, bottom_limit - approx_height);
//BBS: GUI refactor: move gizmo to the right //BBS: GUI refactor: move gizmo to the right
@@ -170,29 +176,25 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
icons = { ImGui::CircleButtonIcon, ImGui::SphereButtonIcon }; icons = { ImGui::CircleButtonIcon, ImGui::SphereButtonIcon };
std::array<wxString, 2> tool_tips = { _L("Circle"), _L("Sphere")}; std::array<wxString, 2> tool_tips = { _L("Circle"), _L("Sphere")};
for (int i = 0; i < tool_ids.size(); i++) { for (int i = 0; i < tool_ids.size(); i++) {
std::string str_label = std::string("##"); //std::string str_label = std::string("##");
std::wstring btn_name = icons[i] + boost::nowide::widen(str_label); //std::wstring btn_name = icons[i] + boost::nowide::widen(str_label);
if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(1.3f)); if (i != 0) ImGui::SameLine((empty_button_width + m_imgui->scaled(1.75f)) * i + m_imgui->scaled(1.3f));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.f, 0.f, 0.f)); // ORCA Removes button background on dark mode bool is_active = m_current_tool == tool_ids[i];
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f)); // ORCA: Fixes icon rendered without colors while using Light theme ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.f);
if (m_current_tool == tool_ids[i]) { ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding , 3.f * scale);
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush ImGui::PushStyleVar(ImGuiStyleVar_FramePadding , ImVec2(4.f * scale, 4.f * scale));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush ImGui::PushStyleColor(ImGuiCol_Text , ImVec4(1,1,1,1)); // ORCA Fixes icon rendered without colors while using Light theme
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.59f, 0.53f, 0.30f)); // ORCA use orca color for selected tool / brush ImGui::PushStyleColor(ImGuiCol_Button , is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(0,0,0,0)); // ORCA
ImGui::PushStyleColor(ImGuiCol_Border, ImGuiWrapper::COL_ORCA); // ORCA use orca color for border on selected tool / brush ImGui::PushStyleColor(ImGuiCol_ButtonHovered, is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(.6f,.6f,.6f,.2f)); // ORCA
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0); ImGui::PushStyleColor(ImGuiCol_ButtonActive , is_active ? ImVec4(0.f, .59f, .53f, .30f) : ImVec4(0,0,0,0)); // ORCA
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0); ImGui::PushStyleColor(ImGuiCol_Border , is_active ? ImGuiWrapper::COL_ORCA : ImVec4(0,0,0,0)); // ORCA
} ImGui::PushStyleColor(ImGuiCol_BorderActive , is_active ? ImGuiWrapper::COL_ORCA : ImVec4(0,0,0,0)); // ORCA matched color for fixing flicker on click
bool btn_clicked = ImGui::Button(into_u8(btn_name).c_str()); bool btn_clicked = m_imgui->glyph_button(icons[i], ImVec2(16.f * scale, 16.f * scale)); // ORCA glyph_button for fixing unequal paddings
if (m_current_tool == tool_ids[i]) ImGui::PopStyleColor(6);
{ ImGui::PopStyleVar(3);
ImGui::PopStyleColor(4);
ImGui::PopStyleVar(2);
}
ImGui::PopStyleColor(2);
ImGui::PopStyleVar(1);
if (btn_clicked && m_current_tool != tool_ids[i]) { if (btn_clicked && m_current_tool != tool_ids[i]) {
m_current_tool = tool_ids[i]; m_current_tool = tool_ids[i];
for (auto& triangle_selector : m_triangle_selectors) { for (auto& triangle_selector : m_triangle_selectors) {

View File

@@ -908,6 +908,54 @@ bool ImGuiWrapper::button(const wxString& label, const ImVec2 &size, bool enable
return (enable) ? res : false; return (enable) ? res : false;
} }
// ORCA Glyph based button for correctly rendering icon size based Glyph
// excludes spacings after Glyph and centers icon properly
// compared to image_button this supports styling
bool ImGuiWrapper::glyph_button(wchar_t icon_char, ImVec2 icon_size)
{
ImDrawList* draw_list = ImGui::GetWindowDrawList();
ImFont* font = ImGui::GetFont();
ImGuiStyle& style = ImGui::GetStyle();
ImVec2 padding = style.FramePadding;
float border_w = style.FrameBorderSize;
float rounding = style.FrameRounding;
std::string icon_str = into_u8(icon_char);
const char* icon = icon_str.c_str();
float width = icon_size.x + (padding.x + border_w) * 2.f;
float height = icon_size.y + (padding.y + border_w) * 2.f;
ImVec2 rc_min = ImGui::GetCursorScreenPos();
ImVec2 rc_max = ImVec2(rc_min.x + width, rc_min.y + height);
ImGui::Dummy(ImVec2(width, height));
ImGuiCol bg_color = ImGuiCol_Button;
ImGuiCol border_color = ImGuiCol_Border;
bool clicked = false;
if (ImGui::IsMouseHoveringRect(rc_min, rc_max)) {
bg_color = ImGuiCol_ButtonHovered;
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
bg_color = ImGuiCol_ButtonActive;
border_color = ImGuiCol_BorderShadow;
clicked = true;
}
}
draw_list->AddRectFilled(rc_min, rc_max, ImGui::GetColorU32(bg_color), rounding);
if (border_w > 0.f)
draw_list->AddRect(rc_min, rc_max, ImGui::GetColorU32(border_color), rounding, 0, border_w);
ImVec2 text_pos = ImVec2(
rc_min.x + (width - font->FontSize) * .5f,
rc_min.y + (height - font->FontSize) * .5f
);
draw_list->AddText(font, font->FontSize, text_pos, ImGui::GetColorU32(ImGuiCol_Text), icon);
return clicked;
}
bool ImGuiWrapper::radio_button(const wxString &label, bool active) bool ImGuiWrapper::radio_button(const wxString &label, bool active)
{ {
auto label_utf8 = into_u8(label); auto label_utf8 = into_u8(label);

View File

@@ -133,6 +133,7 @@ public:
bool bbl_button(const wxString &label, const wxString& tooltip = {}); bool bbl_button(const wxString &label, const wxString& tooltip = {});
bool button(const wxString& label, float width, float height); bool button(const wxString& label, float width, float height);
bool button(const wxString& label, const ImVec2 &size, bool enable); // default size = ImVec2(0.f, 0.f) bool button(const wxString& label, const ImVec2 &size, bool enable); // default size = ImVec2(0.f, 0.f)
bool glyph_button(wchar_t icon_char, ImVec2 icon_size); // ORCA
bool radio_button(const wxString &label, bool active); bool radio_button(const wxString &label, bool active);
static ImVec4 to_ImVec4(const ColorRGB &color); static ImVec4 to_ImVec4(const ColorRGB &color);
bool input_double(const std::string &label, const double &value, const std::string &format = "%.3f"); bool input_double(const std::string &label, const double &value, const std::string &format = "%.3f");