Skip to content

Commit

Permalink
Use real_font_size for padding
Browse files Browse the repository at this point in the history
  • Loading branch information
flightlessmango committed Sep 23, 2020
1 parent 8b4df2a commit cb8d992
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/overlay.cpp
Expand Up @@ -13,6 +13,7 @@

struct benchmark_stats benchmark;
struct fps_limit fps_limit_stats {};
ImVec2 real_font_size;

void update_hw_info(struct swapchain_stats& sw_stats, struct overlay_params& params, uint32_t vendorID)
{
Expand Down
1 change: 1 addition & 0 deletions src/overlay.h
Expand Up @@ -79,6 +79,7 @@ extern struct fps_limit fps_limit_stats;
extern int32_t deviceID;

extern struct benchmark_stats benchmark;
extern ImVec2 real_font_size;

void position_layer(struct swapchain_stats& data, struct overlay_params& params, ImVec2 window_size);
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, bool is_vulkan);
Expand Down
3 changes: 2 additions & 1 deletion src/overlay_params.cpp
Expand Up @@ -616,5 +616,6 @@ parse_overlay_config(struct overlay_params *params,
#endif
if(!params->output_file.empty())
printf("MANGOHUD: output_file is Deprecated, use output_folder instead\n");

auto real_size = params->font_size * params->font_scale;
real_font_size = ImVec2(real_size, real_size / 2);
}
10 changes: 5 additions & 5 deletions src/vulkan.cpp
Expand Up @@ -850,7 +850,7 @@ static void render_mpris_metadata(struct overlay_params& params, mutexed_metadat

void render_benchmark(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, unsigned height, Clock::time_point now){
// TODO, FIX LOG_DURATION FOR BENCHMARK
int benchHeight = (2 + benchmark.percentile_data.size()) * params.font_size + 10.0f + 58;
int benchHeight = (2 + benchmark.percentile_data.size()) * real_font_size.x + 10.0f + 58;
ImGui::SetNextWindowSize(ImVec2(window_size.x, benchHeight), ImGuiCond_Always);
if (height - (window_size.y + data.main_window_pos.y + 5) < benchHeight)
ImGui::SetNextWindowPos(ImVec2(data.main_window_pos.x, data.main_window_pos.y - benchHeight - 5), ImGuiCond_Always);
Expand Down Expand Up @@ -1236,7 +1236,7 @@ void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2&
}
}
if (params.enabled[OVERLAY_PARAM_ENABLED_frame_timing]){
ImGui::Dummy(ImVec2(0.0f, params.font_size * params.font_scale / 2));
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
ImGui::PushFont(data.font1);
ImGui::TextColored(data.colors.engine, "%s", "Frametime");
ImGui::PopFont();
Expand All @@ -1253,12 +1253,12 @@ void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2&
ImGui::PlotHistogram(hash, get_time_stat, &data,
ARRAY_SIZE(data.frames_stats), 0,
NULL, min_time, max_time,
ImVec2(ImGui::GetContentRegionAvailWidth() - params.font_size * params.font_scale * 2.2, 50));
ImVec2(ImGui::GetContentRegionAvailWidth() - real_font_size.x * 2.2, 50));
} else {
ImGui::PlotLines(hash, get_time_stat, &data,
ARRAY_SIZE(data.frames_stats), 0,
NULL, min_time, max_time,
ImVec2(ImGui::GetContentRegionAvailWidth() - params.font_size * params.font_scale * 2.2, 50));
ImVec2(ImGui::GetContentRegionAvailWidth() - real_font_size.x * 2.2, 50));
}
ImGui::PopStyleColor();
}
Expand Down Expand Up @@ -2101,7 +2101,7 @@ void convert_colors(bool do_conv, struct swapchain_stats& sw_stats, struct overl
style.Colors[ImGuiCol_PlotHistogram] = convert(params.frametime_color);
style.Colors[ImGuiCol_WindowBg] = convert(params.background_color);
style.Colors[ImGuiCol_Text] = convert(params.text_color);
style.CellPadding.y = -0.085 * params.font_size;
style.CellPadding.y = -0.085 * real_font_size.y;
}

// TODO probably needs colorspace check too
Expand Down

0 comments on commit cb8d992

Please sign in to comment.