diff --git a/src/gui.cpp b/src/gui.cpp index 0171b059..6a039de7 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -1999,3 +1999,9 @@ void gui_set_current_pos_x(float x) { ImGui::SetCursorPosX(x); } + +float gui_get_item_height(void) +{ + ImGuiStyle& style = ImGui::GetStyle(); + return style.FramePadding.y * 2 + ImGui::GetFontSize(); +} diff --git a/src/gui.h b/src/gui.h index 93156349..c011eef2 100644 --- a/src/gui.h +++ b/src/gui.h @@ -200,5 +200,6 @@ void gui_context_menu_button(const char *label, int icon); */ float gui_get_current_pos_x(void); void gui_set_current_pos_x(float x); +float gui_get_item_height(void); #endif // GUI_H diff --git a/src/gui/app.c b/src/gui/app.c index 5a22ebf4..45c4e9d9 100644 --- a/src/gui/app.c +++ b/src/gui/app.c @@ -40,9 +40,6 @@ #define INITIAL_FILTER_OFFSET 10 #define RELATIVE_FILTER_OFFSET 40 -// Note: duplicated from gui.cpp! To remove. -static const float ITEM_HEIGHT = 18; - void gui_edit_panel(void); void gui_menu(void); void gui_tools_panel(void); @@ -199,6 +196,7 @@ void gui_app(void) int flags; int i; filter_layout_state_t filter_layout_state; + const float item_height = gui_get_item_height(); goxel.show_export_viewport = false; @@ -211,7 +209,7 @@ void gui_app(void) render_hints(goxel.hints); gui_menu_bar_end(); } - y = ITEM_HEIGHT + 2; + y = item_height + 2; } gui_window_begin("Top Bar", x, y, 0, 0, 0); @@ -259,5 +257,5 @@ void gui_app(void) (goxel.gui.current_panel == PANEL_RENDER || PANELS[PANEL_RENDER].detached); - gui_view_cube(goxel.gui.viewport[2] - 128, ITEM_HEIGHT + 2, 128, 128); + gui_view_cube(goxel.gui.viewport[2] - 128, item_height + 2, 128, 128); }