Added ImGuiWindowFlags_NoCollapse flag

This commit is contained in:
ocornut 2015-02-02 09:49:12 +00:00
parent 4169d2c8db
commit 5df28b101d
2 changed files with 35 additions and 19 deletions

View File

@ -2607,7 +2607,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
// Collapse window by double-clicking on title bar
if (!(window->Flags & ImGuiWindowFlags_NoTitleBar))
{
if (g.HoveredWindow == window && IsMouseHoveringBox(title_bar_aabb) && g.IO.MouseDoubleClicked[0])
if (!(window->Flags & ImGuiWindowFlags_NoCollapse) && g.HoveredWindow == window && IsMouseHoveringBox(title_bar_aabb) && g.IO.MouseDoubleClicked[0])
{
window->Collapsed = !window->Collapsed;
if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings))
@ -2803,12 +2803,17 @@ bool ImGui::Begin(const char* name, bool* p_opened, ImVec2 size, float fill_alph
// Title bar
if (!(window->Flags & ImGuiWindowFlags_NoTitleBar))
{
RenderCollapseTriangle(window->Pos + style.FramePadding, !window->Collapsed, 1.0f, true);
if (p_opened != NULL)
CloseWindowButton(p_opened);
ImVec2 text_min = window->Pos + style.FramePadding;
if (!(window->Flags & ImGuiWindowFlags_NoCollapse))
{
RenderCollapseTriangle(window->Pos + style.FramePadding, !window->Collapsed, 1.0f, true);
text_min.x += window->FontSize() + style.ItemInnerSpacing.x;
}
const ImVec2 text_size = CalcTextSize(name, NULL, true);
const ImVec2 text_min = window->Pos + style.FramePadding + ImVec2(window->FontSize() + style.ItemInnerSpacing.x, 0.0f);
const ImVec2 text_max = window->Pos + ImVec2(window->Size.x - (p_opened ? (title_bar_aabb.GetHeight()-3) : style.FramePadding.x), style.FramePadding.y + text_size.y);
const bool clip_title = text_size.x > (text_max.x - text_min.x); // only push a clip rectangle if we need to, because it may turn into a separate draw call
if (clip_title)
@ -7685,10 +7690,18 @@ void ImGui::ShowTestWindow(bool* opened)
static bool no_resize = false;
static bool no_move = false;
static bool no_scrollbar = false;
static bool no_collapse = false;
static float fill_alpha = 0.65f;
const ImGuiWindowFlags layout_flags = (no_titlebar ? ImGuiWindowFlags_NoTitleBar : 0) | (no_border ? 0 : ImGuiWindowFlags_ShowBorders) | (no_resize ? ImGuiWindowFlags_NoResize : 0) | (no_move ? ImGuiWindowFlags_NoMove : 0) | (no_scrollbar ? ImGuiWindowFlags_NoScrollbar : 0);
if (!ImGui::Begin("ImGui Test", opened, ImVec2(550,680), fill_alpha, layout_flags))
// Demonstrate the various window flags. Typically you would just use the default.
ImGuiWindowFlags window_flags = 0;
if (no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar;
if (!no_border) window_flags |= ImGuiWindowFlags_ShowBorders;
if (no_resize) window_flags |= ImGuiWindowFlags_NoResize;
if (no_move) window_flags |= ImGuiWindowFlags_NoMove;
if (no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar;
if (no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse;
if (!ImGui::Begin("ImGui Test", opened, ImVec2(550,680), fill_alpha, window_flags))
{
// Early out if the window is collapsed, as an optimization.
ImGui::End();
@ -7713,7 +7726,8 @@ void ImGui::ShowTestWindow(bool* opened)
ImGui::Checkbox("no border", &no_border); ImGui::SameLine(300);
ImGui::Checkbox("no resize", &no_resize);
ImGui::Checkbox("no move", &no_move); ImGui::SameLine(150);
ImGui::Checkbox("no scrollbar", &no_scrollbar);
ImGui::Checkbox("no scrollbar", &no_scrollbar); ImGui::SameLine(300);
ImGui::Checkbox("no collapse", &no_collapse);
ImGui::SliderFloat("fill alpha", &fill_alpha, 0.0f, 1.0f);
if (ImGui::TreeNode("Style"))

28
imgui.h
View File

@ -343,19 +343,21 @@ namespace ImGui
enum ImGuiWindowFlags_
{
// Default: 0
ImGuiWindowFlags_ShowBorders = 1 << 0,
ImGuiWindowFlags_NoTitleBar = 1 << 1,
ImGuiWindowFlags_NoResize = 1 << 2,
ImGuiWindowFlags_NoMove = 1 << 3,
ImGuiWindowFlags_NoScrollbar = 1 << 4,
ImGuiWindowFlags_NoScrollWithMouse = 1 << 5,
ImGuiWindowFlags_AlwaysAutoResize = 1 << 6,
ImGuiWindowFlags_NoSavedSettings = 1 << 7, // Never load/save settings in .ini file
ImGuiWindowFlags_ChildWindow = 1 << 8, // For internal use by BeginChild()
ImGuiWindowFlags_ChildWindowAutoFitX = 1 << 9, // For internal use by BeginChild()
ImGuiWindowFlags_ChildWindowAutoFitY = 1 << 10, // For internal use by BeginChild()
ImGuiWindowFlags_ComboBox = 1 << 11, // For internal use by ComboBox()
ImGuiWindowFlags_Tooltip = 1 << 12 // For internal use by Render() when using Tooltip
ImGuiWindowFlags_NoTitleBar = 1 << 0, // Disable title-bar
ImGuiWindowFlags_NoResize = 1 << 1, // Disable user resizing with the lower-right grip
ImGuiWindowFlags_NoMove = 1 << 2, // Disable user moving the window
ImGuiWindowFlags_NoScrollbar = 1 << 3, // Disable scroll bar (window can still scroll with mouse or programatically)
ImGuiWindowFlags_NoScrollWithMouse = 1 << 4, // Disable user scrolling with mouse wheel
ImGuiWindowFlags_NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it
ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame
ImGuiWindowFlags_ShowBorders = 1 << 7, // Show borders around windows and items
ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file
// [Internal]
ImGuiWindowFlags_ChildWindow = 1 << 9, // For internal use by BeginChild()
ImGuiWindowFlags_ChildWindowAutoFitX = 1 << 10, // For internal use by BeginChild()
ImGuiWindowFlags_ChildWindowAutoFitY = 1 << 11, // For internal use by BeginChild()
ImGuiWindowFlags_ComboBox = 1 << 12, // For internal use by ComboBox()
ImGuiWindowFlags_Tooltip = 1 << 13 // For internal use by BeginTooltip()
};
// Flags for ImGui::InputText()