无边框窗口

This commit is contained in:
daiqingshuang 2024-02-20 17:59:12 +08:00
parent ca01bf072c
commit 8c2bc80e05
3 changed files with 26 additions and 4 deletions

View File

@ -50,10 +50,6 @@ void application::init(const window_params& in_window_params, int argc, char** a
int application::run() {
while (!g_exit_requested) {
glfwPollEvents();
g_exit_requested = glfwWindowShouldClose(window_);
if (g_exit_requested)
break;
renderer_->new_frame(window_);
draw_gui();
renderer_->end_frame(window_);
@ -108,6 +104,7 @@ void application::init_glfw() {
spdlog::error("Failed to initialize GLFW");
return;
}
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
}
void application::init_imgui() {
@ -119,6 +116,8 @@ void application::init_imgui() {
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
io.ConfigViewportsNoAutoMerge = true;
io.ConfigViewportsNoTaskBarIcon = false;
ImGui::StyleColorsDark();
//ImGui::StyleColorsLight();
}

View File

@ -49,6 +49,11 @@ public:
virtual void shutdown();
void request_exit() {
glfwSetWindowShouldClose(window_, GLFW_TRUE);
g_exit_requested = true;
}
virtual void draw_gui() = 0;
virtual const char* get_shader_path() = 0;

18
core/widget/uilts.h Normal file
View File

@ -0,0 +1,18 @@
#pragma once
#include "extern.h"
#include "imgui.h"
#include "imgui_internal.h"
extern "C" {
void HideTabBar();
}
namespace ImGui {
inline void HideTabBar()
{
ImGuiWindowClass window_class;
window_class.DockNodeFlagsOverrideSet = ImGuiDockNodeFlags_NoWindowMenuButton;
// window_class.DockNodeFlagsOverrideSet = ImGuiDockNodeFlags_NoTabBar;
SetNextWindowClass(&window_class);
}
}