Use overlay_new/end_frame to push/pop custom ImGui styles

pull/771/head
jackun 2 years ago
parent f78107e662
commit 753dd96325
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -214,10 +214,11 @@ void imgui_render(unsigned int width, unsigned int height)
ImGui::NewFrame();
{
std::lock_guard<std::mutex> lk(notifier.mutex);
overlay_new_frame(params);
position_layer(sw_stats, params, window_size);
render_imgui(sw_stats, params, window_size, false);
overlay_end_frame();
}
ImGui::PopStyleVar(3);
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());

@ -274,6 +274,18 @@ float get_time_stat(void *_data, int _idx)
return data->frames_stats[idx].stats[data->stat_selector] / data->time_dividor;
}
void overlay_new_frame(const struct overlay_params& params)
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8,-3));
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, params.alpha);
}
void overlay_end_frame()
{
ImGui::PopStyleVar(3);
}
void position_layer(struct swapchain_stats& data, const struct overlay_params& params, const ImVec2& window_size)
{
unsigned width = ImGui::GetIO().DisplaySize.x;
@ -284,9 +296,6 @@ void position_layer(struct swapchain_stats& data, const struct overlay_params& p
ImGui::SetNextWindowBgAlpha(params.background_alpha);
ImGui::SetNextWindowSize(window_size, ImGuiCond_Always);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8,-3));
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, params.alpha);
switch (params.position) {
case LAYER_POSITION_TOP_LEFT:
data.main_window_pos = ImVec2(margin + params.offset_x, margin + params.offset_y);

@ -152,6 +152,8 @@ extern bool steam_focused;
extern int fan_speed;
void init_spdlog();
void overlay_new_frame(const struct overlay_params& params);
void overlay_end_frame();
void position_layer(struct swapchain_stats& data, const struct overlay_params& params, const ImVec2& window_size);
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, bool is_vulkan);
void update_hud_info(struct swapchain_stats& sw_stats, const struct overlay_params& params, uint32_t vendorID);

@ -443,11 +443,11 @@ static void compute_swapchain_display(struct swapchain_data *data)
ImGui::NewFrame();
{
::scoped_lock lk(instance_data->notifier.mutex);
overlay_new_frame(instance_data->params);
position_layer(data->sw_stats, instance_data->params, data->window_size);
render_imgui(data->sw_stats, instance_data->params, data->window_size, true);
overlay_end_frame();
}
ImGui::PopStyleVar(3);
ImGui::EndFrame();
ImGui::Render();

Loading…
Cancel
Save