Viewport: Popups, Tooltips can individually request no task bar icons to the platform layer. (#1542)

This commit is contained in:
omar 2018-04-10 19:15:44 +02:00
parent 0eaddb4dcd
commit 0d5042f0f3
12 changed files with 25 additions and 20 deletions

View File

@ -118,7 +118,7 @@ int main(int, char**)
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_EnableViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarForViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarIconsForViewports;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
ImGui_ImplWin32_Init(hwnd);

View File

@ -136,7 +136,7 @@ int main(int, char**)
io.ConfigFlags |= ImGuiConfigFlags_EnableViewports;
io.ConfigFlags |= ImGuiConfigFlags_EnableDpiScaleFonts;
io.ConfigFlags |= ImGuiConfigFlags_EnableDpiScaleViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarForViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarIconsForViewports;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
ImGui_ImplWin32_Init(hwnd);

View File

@ -410,8 +410,7 @@ static void ImGui_ImplGlfw_ShowWindow(ImGuiViewport* viewport)
#if defined(_WIN32)
// GLFW hack: Hide icon from task bar
HWND hwnd = glfwGetWin32Window(data->Window);
ImGuiIO& io = ImGui::GetIO();
if (io.ConfigFlags & ImGuiConfigFlags_NoTaskBarForViewports)
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
{
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
ex_style &= ~WS_EX_APPWINDOW;

View File

@ -353,8 +353,7 @@ static void ImGui_ImplSDL2_ShowWindow(ImGuiViewport* viewport)
// SDL hack: Hide icon from task bar
// Note: SDL 2.0.6+ has a SDL_WINDOW_SKIP_TASKBAR flag which is supported under Windows but the way it create the window breaks our seamless transition.
ImGuiIO& io = ImGui::GetIO();
if (io.ConfigFlags & ImGuiConfigFlags_NoTaskBarForViewports)
if (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon)
{
LONG ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
ex_style &= ~WS_EX_APPWINDOW;

View File

@ -377,18 +377,17 @@ static void ImGui_ImplWin32_CreateWindow(ImGuiViewport* viewport)
ImGuiViewportDataWin32* data = IM_NEW(ImGuiViewportDataWin32)();
viewport->PlatformUserData = data;
ImGuiIO& io = ImGui::GetIO();
bool no_decoration = (viewport->Flags & ImGuiViewportFlags_NoDecoration) != 0;
bool no_task_bar = (io.ConfigFlags & ImGuiConfigFlags_NoTaskBarForViewports) != 0;
bool no_task_bar_icon = (viewport->Flags & ImGuiViewportFlags_NoTaskBarIcon) != 0;
if (no_decoration)
{
data->DwStyle = WS_POPUP;
data->DwExStyle = no_task_bar ? WS_EX_TOOLWINDOW : WS_EX_APPWINDOW;
data->DwExStyle = no_task_bar_icon ? WS_EX_TOOLWINDOW : WS_EX_APPWINDOW;
}
else
{
data->DwStyle = WS_OVERLAPPEDWINDOW;
data->DwExStyle = no_task_bar ? WS_EX_TOOLWINDOW : WS_EX_APPWINDOW;
data->DwExStyle = no_task_bar_icon ? WS_EX_TOOLWINDOW : WS_EX_APPWINDOW;
}
// Create window

View File

@ -31,7 +31,7 @@ int main(int, char**)
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_EnableViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarForViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarIconsForViewports;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL2_Init();

View File

@ -36,7 +36,7 @@ int main(int, char**)
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_EnableViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarForViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarIconsForViewports;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls

View File

@ -38,7 +38,7 @@ int main(int, char**)
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_EnableViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarForViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarIconsForViewports;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
ImGui_ImplSDL2_Init(window, gl_context);

View File

@ -335,7 +335,7 @@ int main(int, char**)
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_EnableViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarForViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarIconsForViewports;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
// Setup SDL binding

View File

@ -347,7 +347,7 @@ int main(int, char**)
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_EnableViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarForViewports;
io.ConfigFlags |= ImGuiConfigFlags_NoTaskBarIconsForViewports;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
// Setup GLFW binding

View File

@ -3549,6 +3549,13 @@ void ImGui::UpdatePlatformWindows()
continue;
}
// Update ImGuiViewportFlags_NoTaskBarIcon flag
if (viewport->Window != NULL)
{
bool no_task_bar_icon = (g.IO.ConfigFlags & ImGuiConfigFlags_NoTaskBarIconsForViewports) != 0 || (viewport->Window->Flags & (ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) != 0;
viewport->Flags = no_task_bar_icon ? (viewport->Flags | ImGuiViewportFlags_NoTaskBarIcon) : (viewport->Flags & ~ImGuiViewportFlags_NoTaskBarIcon);
}
bool is_new_window = (viewport->PlatformHandle == NULL && viewport->PlatformUserData == NULL && viewport->RendererUserData == NULL);
if (is_new_window && viewport->PlatformHandle == NULL && viewport->PlatformUserData == NULL)
g.PlatformIO.Platform_CreateWindow(viewport);

11
imgui.h
View File

@ -798,10 +798,10 @@ enum ImGuiConfigFlags_
ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct back-end to not alter mouse cursor shape and visibility.
// [BETA] Viewports
ImGuiConfigFlags_EnableViewports = 1 << 10, // Viewport enable flags (require both ImGuiConfigFlags_PlatformHasViewports + ImGuiConfigFlags_RendererHasViewports set by the respective back-ends)
ImGuiConfigFlags_EnableDpiScaleViewports= 1 << 11,
ImGuiConfigFlags_EnableDpiScaleFonts = 1 << 12,
ImGuiConfigFlags_NoTaskBarForViewports = 1 << 13,
ImGuiConfigFlags_EnableViewports = 1 << 10, // Viewport enable flags (require both ImGuiConfigFlags_PlatformHasViewports + ImGuiConfigFlags_RendererHasViewports set by the respective back-ends)
ImGuiConfigFlags_EnableDpiScaleViewports = 1 << 11,
ImGuiConfigFlags_EnableDpiScaleFonts = 1 << 12,
ImGuiConfigFlags_NoTaskBarIconsForViewports = 1 << 13,
// User storage (to allow your back-end/engine to communicate to code that may be shared between multiple projects. Those flags are not used by core ImGui)
ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware.
@ -1924,7 +1924,8 @@ enum ImGuiViewportFlags_
ImGuiViewportFlags_NoDecoration = 1 << 0, // Platform Window: Disable platform title bar, borders, etc.
ImGuiViewportFlags_NoFocusOnAppearing = 1 << 1, // Platform Window: Don't take focus when created.
ImGuiViewportFlags_NoInputs = 1 << 2, // Platform Window: Make mouse pass through so we can drag this window while peaking behind it.
ImGuiViewportFlags_NoRendererClear = 1 << 3 // Platform Window: Renderer doesn't need to clear the framebuffer ahead.
ImGuiViewportFlags_NoTaskBarIcon = 1 << 3, // Platform Window: Disable platform task bar icon (for popups, menus, or all windows if ImGuiConfigFlags_NoTaskBarIconsForViewports if set)
ImGuiViewportFlags_NoRendererClear = 1 << 4 // Platform Window: Renderer doesn't need to clear the framebuffer ahead.
};
// The viewports created and managed by imgui. The role of the platform back-end is to create the platform/OS windows corresponding to each viewport.