mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Fixed display on OSX and improved responsive scaling (highDPI and
proportionnal alignment)
This commit is contained in:
@@ -111,11 +111,11 @@ void ImGuiToolkit::ButtonSwitch(const char* label, bool* toggle, const char* hel
|
|||||||
|
|
||||||
// draw the label right aligned
|
// draw the label right aligned
|
||||||
const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true);
|
const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true);
|
||||||
ImVec2 text_pos = draw_pos + ImVec2(frame_width -120.f -label_size.x, 0.f);
|
ImVec2 text_pos = draw_pos + ImVec2(frame_width -3.5f * ImGui::GetTextLineHeightWithSpacing() -label_size.x, 0.f);
|
||||||
ImGui::RenderText(text_pos, label);
|
ImGui::RenderText(text_pos, label);
|
||||||
|
|
||||||
// draw switch after the text
|
// draw switch after the text
|
||||||
ImVec2 p = draw_pos + ImVec2(frame_width - 100.f, 0.f);
|
ImVec2 p = draw_pos + ImVec2(frame_width -3.1f * ImGui::GetTextLineHeightWithSpacing(), 0.f);
|
||||||
draw_list->AddRectFilled(p, ImVec2(p.x + width, p.y + height), col_bg, height * 0.5f);
|
draw_list->AddRectFilled(p, ImVec2(p.x + width, p.y + height), col_bg, height * 0.5f);
|
||||||
draw_list->AddCircleFilled(ImVec2(p.x + radius + t * (width - radius * 2.0f), p.y + radius), radius - 1.5f, IM_COL32(255, 255, 255, 250));
|
draw_list->AddCircleFilled(ImVec2(p.x + radius + t * (width - radius * 2.0f), p.y + radius), radius - 1.5f, IM_COL32(255, 255, 255, 250));
|
||||||
|
|
||||||
@@ -777,6 +777,8 @@ void ImGuiToolkit::ShowStats(bool *p_open, int* p_corner)
|
|||||||
ImGui::Text("Mouse <invalid>");
|
ImGui::Text("Mouse <invalid>");
|
||||||
|
|
||||||
ImGui::Text("Window (%.1f,%.1f)", io.DisplaySize.x, io.DisplaySize.y);
|
ImGui::Text("Window (%.1f,%.1f)", io.DisplaySize.x, io.DisplaySize.y);
|
||||||
|
ImGui::Text("HiDPI (retina) %s", io.DisplayFramebufferScale.x > 1.f ? "on" : "off");
|
||||||
|
// ImGui::Text("DPI Scale (%.1f,%.1f)", io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y);
|
||||||
ImGui::Text("Rendering %.1f FPS", io.Framerate);
|
ImGui::Text("Rendering %.1f FPS", io.Framerate);
|
||||||
ImGui::PopFont();
|
ImGui::PopFont();
|
||||||
|
|
||||||
|
|||||||
@@ -142,8 +142,9 @@ bool UserInterface::Init()
|
|||||||
IMGUI_CHECKVERSION();
|
IMGUI_CHECKVERSION();
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // TODO Enable Keyboard Controls?
|
||||||
io.MouseDrawCursor = true;
|
io.MouseDrawCursor = true;
|
||||||
|
io.FontGlobalScale = Settings::application.scale;
|
||||||
|
|
||||||
// Setup Platform/Renderer bindings
|
// Setup Platform/Renderer bindings
|
||||||
ImGui_ImplGlfw_InitForOpenGL(Rendering::manager().main_window_, true);
|
ImGui_ImplGlfw_InitForOpenGL(Rendering::manager().main_window_, true);
|
||||||
@@ -152,16 +153,20 @@ bool UserInterface::Init()
|
|||||||
// Setup Dear ImGui style
|
// Setup Dear ImGui style
|
||||||
ImGuiToolkit::SetAccentColor(static_cast<ImGuiToolkit::accent_color>(Settings::application.accent_color));
|
ImGuiToolkit::SetAccentColor(static_cast<ImGuiToolkit::accent_color>(Settings::application.accent_color));
|
||||||
|
|
||||||
// Load Fonts (using resource manager, a temporary copy of the raw data is necessary)
|
// Load Fonts (using resource manager, NB: a temporary copy of the raw data is necessary)
|
||||||
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_DEFAULT, "Roboto-Regular", 22);
|
int base_font_size = int ( Rendering::manager().Height() / 110.f );
|
||||||
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_BOLD, "Roboto-Bold", 22);
|
// Log::Info("Base font size %d / %f", base_font_size, Rendering::manager().Height() );
|
||||||
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_ITALIC, "Roboto-Italic", 22);
|
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_DEFAULT, "Roboto-Regular", base_font_size);
|
||||||
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_MONO, "Hack-Regular", 20);
|
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_BOLD, "Roboto-Bold", base_font_size);
|
||||||
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_LARGE, "Hack-Regular", 40);
|
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_ITALIC, "Roboto-Italic", base_font_size);
|
||||||
io.FontGlobalScale = Settings::application.scale;
|
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_MONO, "Hack-Regular", base_font_size - 2);
|
||||||
|
// font for Navigator = 1.5 x base size, and less than 38 (unknown imgui bug for fonts larger than 40)
|
||||||
|
ImGuiToolkit::SetFont(ImGuiToolkit::FONT_LARGE, "Hack-Regular", MIN(base_font_size+base_font_size/2, 38) );
|
||||||
|
|
||||||
// Style
|
// Style
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
|
||||||
|
Log::Info("DPI Scale (%.1f,%.1f)", ImGui::GetIO().DisplayFramebufferScale.x, ImGui::GetIO().DisplayFramebufferScale.y);
|
||||||
style.WindowPadding.x = 12.f;
|
style.WindowPadding.x = 12.f;
|
||||||
style.WindowPadding.y = 6.f;
|
style.WindowPadding.y = 6.f;
|
||||||
style.FramePadding.x = 10.f;
|
style.FramePadding.x = 10.f;
|
||||||
@@ -864,11 +869,12 @@ void Navigator::Render()
|
|||||||
ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, ImVec2(0.50f, 0.50f));
|
ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, ImVec2(0.50f, 0.50f));
|
||||||
|
|
||||||
// calculate size of items based on text size and display dimensions
|
// calculate size of items based on text size and display dimensions
|
||||||
width = 2.f * ImGui::GetTextLineHeightWithSpacing();
|
width = 2.f * ImGui::GetTextLineHeightWithSpacing(); // dimension of left bar depends on FONT_LARGE
|
||||||
padding_width = 2.f * style.WindowPadding.x;
|
pannel_width = 5.f * width; // pannel is 5x the bar
|
||||||
height = io.DisplaySize.y;
|
padding_width = 2.f * style.WindowPadding.x; // panning for alighment
|
||||||
sourcelist_height = height - 6 * ImGui::GetTextLineHeight();
|
height = io.DisplaySize.y; // cover vertically
|
||||||
float icon_width = width - 2.f * style.WindowPadding.x;
|
sourcelist_height = height - 6.f * ImGui::GetTextLineHeight(); // space for 3 icons of view
|
||||||
|
float icon_width = width - 2.f * style.WindowPadding.x; // icons keep padding
|
||||||
ImVec2 iconsize(icon_width, icon_width);
|
ImVec2 iconsize(icon_width, icon_width);
|
||||||
|
|
||||||
// Left bar top
|
// Left bar top
|
||||||
@@ -1142,7 +1148,7 @@ void Navigator::RenderMainPannel()
|
|||||||
ImGui::Text(" ");
|
ImGui::Text(" ");
|
||||||
ImGui::Text("Appearance");
|
ImGui::Text("Appearance");
|
||||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||||
if ( ImGui::SliderFloat("Scale", &Settings::application.scale, 0.8f, 1.2f, "%.1f"))
|
if ( ImGui::DragFloat("Scale", &Settings::application.scale, 0.01, 0.8f, 1.2f, "%.1f"))
|
||||||
ImGui::GetIO().FontGlobalScale = Settings::application.scale;
|
ImGui::GetIO().FontGlobalScale = Settings::application.scale;
|
||||||
|
|
||||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
#define IMGUI_TITLE_SHADEREDITOR ICON_FA_CODE " Shader Editor"
|
#define IMGUI_TITLE_SHADEREDITOR ICON_FA_CODE " Shader Editor"
|
||||||
#define IMGUI_TITLE_PREVIEW ICON_FA_LAPTOP " Preview"
|
#define IMGUI_TITLE_PREVIEW ICON_FA_LAPTOP " Preview"
|
||||||
#define IMGUI_TITLE_DELETE ICON_FA_BROOM " Delete?"
|
#define IMGUI_TITLE_DELETE ICON_FA_BROOM " Delete?"
|
||||||
#define IMGUI_RIGHT_ALIGN -100
|
#define IMGUI_RIGHT_ALIGN -3.5f * ImGui::GetTextLineHeightWithSpacing()
|
||||||
|
|
||||||
#define COLOR_BGROUND 0.2f, 0.2f, 0.2f
|
#define COLOR_BGROUND 0.2f, 0.2f, 0.2f
|
||||||
#define COLOR_NAVIGATOR 0.1f, 0.1f, 0.1f
|
#define COLOR_NAVIGATOR 0.1f, 0.1f, 0.1f
|
||||||
|
|||||||
Reference in New Issue
Block a user