mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-14 00:52:04 +00:00
Fix iconic button sizes on widgets (paint modes and gcode viewer buttons) (#13365)
* init * update
This commit is contained in:
@@ -516,13 +516,15 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
|
||||
}
|
||||
|
||||
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_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));
|
||||
|
||||
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;
|
||||
static float main_wnd_height_temp = ImGui::GetWindowHeight();
|
||||
static float first_click = true;
|
||||
@@ -537,6 +539,7 @@ void GCodeViewer::SequentialView::Marker::render_position_window(const libvgcode
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if(!properties_shown)
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() - ImGui::GetStyle().FramePadding.y); // aligns button with next group
|
||||
|
||||
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::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_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));
|
||||
float calc_padding = (ImGui::GetFrameHeight() - 16 * m_scale) / 2; // ORCA calculated padding for 16x16 icon
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(calc_padding, calc_padding)); // ORCA Center icon with frame padding
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding , ImVec2(2.f, 2.f) * m_scale);
|
||||
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
|
||||
if (ImGui::Button(into_u8(btn_name).c_str(), ImVec2(button_width, button_width))) {
|
||||
// ORCA use glyph based button for fixing button sizes changing depends on used font size on platform
|
||||
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;
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
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().plater()->get_current_canvas3D()->post_event(SimpleEvent(wxEVT_PAINT));
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor(3);
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
|
||||
@@ -191,6 +191,12 @@ void GLGizmoFdmSupports::on_render_input_window(float x, float y, float bottom_l
|
||||
if (! m_c->selection_info()->model_object())
|
||||
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
|
||||
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") };
|
||||
for (int i = 0; i < tool_ids.size(); i++) {
|
||||
std::string str_label = std::string("##");
|
||||
std::wstring btn_name = icons[i] + boost::nowide::widen(str_label);
|
||||
//std::string str_label = std::string("##");
|
||||
//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));
|
||||
|
||||
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
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f)); // ORCA: Fixes icon rendered without colors while using Light theme
|
||||
if (m_current_tool == tool_ids[i]) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.59f, 0.53f, 0.30f)); // ORCA use orca color for selected tool / brush
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, ImGuiWrapper::COL_ORCA); // ORCA use orca color for border on selected tool / brush
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0);
|
||||
}
|
||||
bool btn_clicked = ImGui::Button(into_u8(btn_name).c_str());
|
||||
if (m_current_tool == tool_ids[i])
|
||||
{
|
||||
ImGui::PopStyleColor(4);
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::PopStyleVar(1);
|
||||
bool is_active = m_current_tool == tool_ids[i];
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding , 3.f * scale);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding , ImVec2(4.f * scale, 4.f * scale));
|
||||
ImGui::PushStyleColor(ImGuiCol_Text , ImVec4(1,1,1,1)); // ORCA Fixes icon rendered without colors while using Light theme
|
||||
ImGui::PushStyleColor(ImGuiCol_Button , is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(0,0,0,0)); // ORCA
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(.6f,.6f,.6f,.2f)); // ORCA
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive , is_active ? ImVec4(0.f, .59f, .53f, .30f) : ImVec4(0,0,0,0)); // ORCA
|
||||
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 = m_imgui->glyph_button(icons[i], ImVec2(16.f * scale, 16.f * scale)); // ORCA glyph_button for fixing unequal paddings
|
||||
ImGui::PopStyleColor(6);
|
||||
ImGui::PopStyleVar(3);
|
||||
|
||||
if (btn_clicked && m_current_tool != tool_ids[i]) {
|
||||
m_current_tool = tool_ids[i];
|
||||
|
||||
@@ -117,6 +117,12 @@ void GLGizmoFuzzySkin::on_render_input_window(float x, float y, float bottom_lim
|
||||
if (!mo)
|
||||
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 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 };
|
||||
std::array<wxString, 4> tool_tips = { _L("Circle"), _L("Sphere"), _L("Triangle"), _L("Fill") };
|
||||
for (int i = 0; i < tool_ids.size(); i++) {
|
||||
std::string str_label = std::string("");
|
||||
std::wstring btn_name = icons[i] + boost::nowide::widen(str_label);
|
||||
//std::string str_label = std::string("");
|
||||
//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));
|
||||
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
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f)); // ORCA Fixes icon rendered without colors while using Light theme
|
||||
if (m_current_tool == tool_ids[i]) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.59f, 0.53f, 0.30f)); // ORCA use orca color for selected tool / brush
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, ImGuiWrapper::COL_ORCA); // ORCA use orca color for border on selected tool / brush
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0);
|
||||
}
|
||||
bool btn_clicked = ImGui::Button(into_u8(btn_name).c_str());
|
||||
if (m_current_tool == tool_ids[i])
|
||||
{
|
||||
ImGui::PopStyleColor(4);
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::PopStyleVar(1);
|
||||
|
||||
bool is_active = m_current_tool == tool_ids[i];
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding , 3.f * scale);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding , ImVec2(4.f * scale, 4.f * scale));
|
||||
ImGui::PushStyleColor(ImGuiCol_Text , ImVec4(1,1,1,1)); // ORCA Fixes icon rendered without colors while using Light theme
|
||||
ImGui::PushStyleColor(ImGuiCol_Button , is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(0,0,0,0)); // ORCA
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(.6f,.6f,.6f,.2f)); // ORCA
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive , is_active ? ImVec4(0.f, .59f, .53f, .30f) : ImVec4(0,0,0,0)); // ORCA
|
||||
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 = m_imgui->glyph_button(icons[i], ImVec2(16.f * scale, 16.f * scale)); // ORCA glyph_button for fixing unequal paddings
|
||||
ImGui::PopStyleColor(6);
|
||||
ImGui::PopStyleVar(3);
|
||||
|
||||
if (btn_clicked && m_current_tool != tool_ids[i]) {
|
||||
m_current_tool = tool_ids[i];
|
||||
|
||||
@@ -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 };
|
||||
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++) {
|
||||
std::string str_label = std::string("");
|
||||
std::wstring btn_name = icons[i] + boost::nowide::widen(str_label);
|
||||
//std::string str_label = std::string("");
|
||||
//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));
|
||||
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
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f)); // ORCA Fixes icon rendered without colors while using Light theme
|
||||
if (m_current_tool == tool_ids[i]) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.59f, 0.53f, 0.30f)); // ORCA use orca color for selected tool / brush
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, ImGuiWrapper::COL_ORCA); // ORCA use orca color for border on selected tool / brush
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0);
|
||||
}
|
||||
bool btn_clicked = ImGui::Button(into_u8(btn_name).c_str());
|
||||
if (m_current_tool == tool_ids[i])
|
||||
{
|
||||
ImGui::PopStyleColor(4);
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::PopStyleVar(1);
|
||||
|
||||
bool is_active = m_current_tool == tool_ids[i];
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding , 3.f * scale);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding , ImVec2(4.f * scale, 4.f * scale));
|
||||
ImGui::PushStyleColor(ImGuiCol_Text , ImVec4(1,1,1,1)); // ORCA Fixes icon rendered without colors while using Light theme
|
||||
ImGui::PushStyleColor(ImGuiCol_Button , is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(0,0,0,0)); // ORCA
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(.6f,.6f,.6f,.2f)); // ORCA
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive , is_active ? ImVec4(0.f, .59f, .53f, .30f) : ImVec4(0,0,0,0)); // ORCA
|
||||
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 = m_imgui->glyph_button(icons[i], ImVec2(16.f * scale, 16.f * scale)); // ORCA glyph_button for fixing unequal paddings
|
||||
ImGui::PopStyleColor(6);
|
||||
ImGui::PopStyleVar(3);
|
||||
|
||||
if (btn_clicked && m_current_tool != tool_ids[i]) {
|
||||
m_current_tool = tool_ids[i];
|
||||
|
||||
@@ -121,6 +121,12 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit)
|
||||
if (! m_c->selection_info()->model_object())
|
||||
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);
|
||||
y = std::min(y, bottom_limit - approx_height);
|
||||
//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 };
|
||||
std::array<wxString, 2> tool_tips = { _L("Circle"), _L("Sphere")};
|
||||
for (int i = 0; i < tool_ids.size(); i++) {
|
||||
std::string str_label = std::string("##");
|
||||
std::wstring btn_name = icons[i] + boost::nowide::widen(str_label);
|
||||
//std::string str_label = std::string("##");
|
||||
//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));
|
||||
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
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 1.f)); // ORCA: Fixes icon rendered without colors while using Light theme
|
||||
if (m_current_tool == tool_ids[i]) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.f, 0.59f, 0.53f, 0.25f)); // ORCA use orca color for selected tool / brush
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.59f, 0.53f, 0.30f)); // ORCA use orca color for selected tool / brush
|
||||
ImGui::PushStyleColor(ImGuiCol_Border, ImGuiWrapper::COL_ORCA); // ORCA use orca color for border on selected tool / brush
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.0);
|
||||
}
|
||||
bool btn_clicked = ImGui::Button(into_u8(btn_name).c_str());
|
||||
if (m_current_tool == tool_ids[i])
|
||||
{
|
||||
ImGui::PopStyleColor(4);
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
ImGui::PopStyleColor(2);
|
||||
ImGui::PopStyleVar(1);
|
||||
|
||||
bool is_active = m_current_tool == tool_ids[i];
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding , 3.f * scale);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding , ImVec2(4.f * scale, 4.f * scale));
|
||||
ImGui::PushStyleColor(ImGuiCol_Text , ImVec4(1,1,1,1)); // ORCA Fixes icon rendered without colors while using Light theme
|
||||
ImGui::PushStyleColor(ImGuiCol_Button , is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(0,0,0,0)); // ORCA
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, is_active ? ImVec4(0.f, .59f, .53f, .25f) : ImVec4(.6f,.6f,.6f,.2f)); // ORCA
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive , is_active ? ImVec4(0.f, .59f, .53f, .30f) : ImVec4(0,0,0,0)); // ORCA
|
||||
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 = m_imgui->glyph_button(icons[i], ImVec2(16.f * scale, 16.f * scale)); // ORCA glyph_button for fixing unequal paddings
|
||||
ImGui::PopStyleColor(6);
|
||||
ImGui::PopStyleVar(3);
|
||||
|
||||
if (btn_clicked && m_current_tool != tool_ids[i]) {
|
||||
m_current_tool = tool_ids[i];
|
||||
for (auto& triangle_selector : m_triangle_selectors) {
|
||||
|
||||
@@ -908,6 +908,54 @@ bool ImGuiWrapper::button(const wxString& label, const ImVec2 &size, bool enable
|
||||
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)
|
||||
{
|
||||
auto label_utf8 = into_u8(label);
|
||||
|
||||
@@ -133,6 +133,7 @@ public:
|
||||
bool bbl_button(const wxString &label, const wxString& tooltip = {});
|
||||
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 glyph_button(wchar_t icon_char, ImVec2 icon_size); // ORCA
|
||||
bool radio_button(const wxString &label, bool active);
|
||||
static ImVec4 to_ImVec4(const ColorRGB &color);
|
||||
bool input_double(const std::string &label, const double &value, const std::string &format = "%.3f");
|
||||
|
||||
Reference in New Issue
Block a user