Added BETA api for Tab Bar/Tabs widgets. (#261, #351) (merged this feature from the from Docking branch so it can be used earlier as as standalone feature)
- Added BeginTabBar(), EndTabBar(), BeginTabItem(), EndTabItem(), SetTabItemClosed() API.
- Added ImGuiTabBarFlags flags for BeginTabBar().
- Added ImGuiTabItemFlags flags for BeginTabItem().
- Style: Added ImGuiCol_Tab, ImGuiCol_TabHovered, ImGuiCol_TabActive, ImGuiCol_TabUnfocused, ImGuiCol_TabUnfocusedActive colors.
- Demo: Added Layout->Tabs demo code.
- Demo: Added "Documents" example app showcasing possible use for tabs.
ScrollbarRounding=9.0f;// Radius of grab corners rounding for scrollbar
GrabMinSize=10.0f;// Minimum width/height of a grab box for slider/scrollbar
GrabRounding=0.0f;// Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
TabRounding=4.0f;// Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
TabBorderSize=0.0f;// Thickness of border around tabs.
ButtonTextAlign=ImVec2(0.5f,0.5f);// Alignment of button text when button is larger than text.
DisplayWindowPadding=ImVec2(19,19);// Window position are clamped to be visible within the display area by at least this amount. Only applies to regular windows.
DisplaySafeAreaPadding=ImVec2(3,3);// If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
IMGUI_APIvoidSetColumnOffset(intcolumn_index,floatoffset_x);// set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column
IMGUI_APIintGetColumnsCount();
// Tab Bars, Tabs
// [BETA API] API may evolve!
IMGUI_APIboolBeginTabBar(constchar*str_id,ImGuiTabBarFlagsflags=0);// create and append into a TabBar
IMGUI_APIvoidEndTabBar();
IMGUI_APIboolBeginTabItem(constchar*label,bool*p_open=NULL,ImGuiTabItemFlagsflags=0);// create a Tab. Returns true if the Tab is selected.
IMGUI_APIvoidEndTabItem();// only call EndTabItem() if BeginTabItem() returns true!
IMGUI_APIvoidSetTabItemClosed(constchar*tab_or_docked_window_label);// notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name.
// Logging/Capture: all text output from interface is captured to tty/file/clipboard. By default, tree nodes are automatically opened during logging.
IMGUI_APIvoidLogToTTY(intmax_depth=-1);// start logging to tty
IMGUI_APIvoidLogToFile(intmax_depth=-1,constchar*filename=NULL);// start logging to file
ImGuiTabBarFlags_Reorderable=1<<0,// Allow manually dragging tabs to re-order them + New tabs are appended at the end of list
ImGuiTabBarFlags_AutoSelectNewTabs=1<<1,// Automatically select new tabs when they appear
ImGuiTabBarFlags_NoCloseWithMiddleMouseButton=1<<2,// Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
ImGuiTabBarFlags_NoTabListPopupButton=1<<3,
ImGuiTabBarFlags_NoTabListScrollingButtons=1<<4,
ImGuiTabBarFlags_FittingPolicyResizeDown=1<<5,// Resize tabs when they don't fit
ImGuiTabBarFlags_FittingPolicyScroll=1<<6,// Add scroll buttons when tabs don't fit
ImGuiTabItemFlags_UnsavedDocument=1<<0,// Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. Also: tab is selected on closure and closure is deferred by one frame to allow code to undo it without flicker.
ImGuiTabItemFlags_SetSelected=1<<1,// Trigger flag to programatically make the tab selected when calling BeginTabItem()
ImGuiTabItemFlags_NoCloseWithMiddleMouseButton=1<<2,// Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false.
ImGuiTabItemFlags_NoPushId=1<<3// Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem()
floatScrollbarRounding;// Radius of grab corners for scrollbar.
floatGrabMinSize;// Minimum width/height of a grab box for slider/scrollbar.
floatGrabRounding;// Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
floatTabRounding;// Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
floatTabBorderSize;// Thickness of border around tabs.
ImVec2ButtonTextAlign;// Alignment of button text when button is larger than text. Defaults to (0.5f,0.5f) for horizontally+vertically centered.
ImVec2DisplayWindowPadding;// Window position are clamped to be visible within the display area by at least this amount. Only applies to regular windows.
ImVec2DisplaySafeAreaPadding;// If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly!
ImGui::TextWrapped("(Using ImGui::BeginGroup()/EndGroup() to layout items. BeginGroup() basically locks the horizontal position. EndGroup() bundles the whole group so that you can use functions such as IsItemHovered() on it.)");
ImGui::SliderFloat2("ButtonTextAlign",(float*)&style.ButtonTextAlign,0.0f,1.0f,"%.2f");ImGui::SameLine();ShowHelpMarker("Alignment applies when a button is larger than its text content.");
//if ((ImGui::GetFrameCount() % 30) == 0) docs[1].Open ^= 1; // [DEBUG] Automatically show/hide a tab. Test various interactions e.g. dragging with this on.
//if (ImGui::GetIO().KeyCtrl) ImGui::SetTabItemSelected(docs[1].Name); // [DEBUG] Test SetTabItemSelected(), probably not very useful as-is anyway..
structImGuiPopupRef;// Storage for current popup stack
structImGuiSettingsHandler;// Storage for one type registered in the .ini file
structImGuiStyleMod;// Stacked style modifier, backup of modified data so we can restore it
structImGuiTabBar;// Storage for a tab bar
structImGuiTabItem;// Storage for a tab item (within a tab bar)
structImGuiWindow;// Storage for one window
structImGuiWindowTempData;// Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame)
structImGuiWindowSettings;// Storage for window settings stored in .ini file (we keep one of those even if the actual window wasn't instanced during this session)
ImGuiTabBarFlags_DockNode=1<<20,// [Docking: Unused in Master Branch] Part of a dock node
ImGuiTabBarFlags_DockNodeIsDockSpace=1<<21,// [Docking: Unused in Master Branch] Part of an explicit dockspace node node
ImGuiTabBarFlags_IsFocused=1<<22,
ImGuiTabBarFlags_SaveSettings=1<<23// FIXME: Settings are handled by the docking system, this only request the tab bar to mark settings dirty when reordering tabs
};
// Storage for one active tab item (sizeof() 26~32 bytes)
structImGuiTabItem
{
ImGuiIDID;
ImGuiTabItemFlagsFlags;
intLastFrameVisible;
intLastFrameSelected;// This allows us to infer an ordered list of the last activated tabs with little maintenance
floatOffset;// Position relative to beginning of tab
floatWidth;// Width currently displayed
floatWidthContents;// Width of actual contents, stored during BeginTabItem() call
// AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION. THOSE FUNCTIONS ARE A MESS. THEIR SIGNATURE AND BEHAVIOR WILL CHANGE, THEY NEED TO BE REFACTORED INTO SOMETHING DECENT.
// NB: All position are in absolute pixels coordinates (we are never using window coordinates internally)
// Restore the last visible height if no tab is visible, this reduce vertical flicker/movement when a tabs gets removed without calling SetTabItemClosed().
// Refresh tab width immediately if we can (for manual tab bar, WidthContent will lag by one frame which is mostly noticeable when changing style.FramePadding.x)
// Additionally, when using TabBarAddTab() to manipulate tab bar order we occasionally insert new tabs that don't have a width yet,
// and we cannot wait for the next BeginTabItem() call. We cannot compute this width within TabBarAddTab() because font size depends on the active window.
floatmargin=g.FontSize*1.0f;// When to scroll to make Tab N+1 visible always make a bit of N visible to suggest more scrolling area (since we don't have a scrollbar)
tab_to_select=&tab_bar->Tabs[(target_order>=0&&target_order<tab_bar->Tabs.Size)?target_order:selected_order];// If we are at the end of the list, still scroll to make our tab visible
// If the user called us with *p_open == false, we early out and don't render. We make a dummy call to ItemAdd() so that attempts to use a contextual popup menu with an implicit ID won't use an older ID.
// We don't have CPU clipping primitives to clip the CloseButton (until it becomes a texture), so need to add an extra draw call (temporary in the case of vertical animation)
// While rendering tabs, we trim 1 pixel off the top of our bounding box so they can fit within a regular frame height while looking "detached" from it.
// We are relying on a subtle and confusing distinction between 'hovered' and 'g.HoveredId' which happens because we are using ImGuiButtonFlags_AllowOverlapMode + SetItemAllowOverlap()
// 'hovered' will be true when hovering the Tab but NOT when hovering the close button
// 'g.HoveredId==id' will be true when hovering the Tab including when hovering the close button
// 'g.ActiveId==close_button_id' will be true when we are holding on the close button, in which case both hovered booleans are false