Tab module for imgui. Should be relatively forwardly compatible.

Overview

imgui_tabs

Tab module for imgui. Should be relatively forwardly compatible.

Code like this:

fullScreen.value; if(ImGui::Checkbox("Fullscreen Mode",&fullscreen)){ mGUICfg->toggleFullscreenMode = true; } if(ImGui::Checkbox("Enable Multisampling",&mGUICfg->enableMultisampling.value)){ mGUICfg->settingsChanged = true; } if(ImGui::SliderInt("MSAA Count",(int*)&mGUICfg->multisampleCount.value,mGUICfg->multisampleCount.lowerLimit,mGUICfg->multisampleCount.upperLimit)) mGUICfg->settingsChanged = true; } if (ImGui::AddTab("GUI")){ ImGui::Text("Tab 2"); } if (ImGui::AddTab("Tab Name")){ ImGui::Text("Tab 3"); } if (ImGui::AddTab("Tab Name")){ ImGui::Text("Tab 4"); } ImGui::EndTabBar(); ImGui::Dummy(ImVec2(0,20)); ImGui::BeginTabBar("#Additional Parameters"); float value = 0.0f; // ericb 2017_07_21 : draw the tabs background BEFORE to fill it, to avoid a "colored overlay" ImGui::DrawTabsBackground(); if (ImGui::AddTab("Tab Name2")){ ImGui::SliderFloat("Slider",&value,0,1.0f); } if (ImGui::AddTab("Tab Name3")){ ImGui::Text("Tab 2"); } if (ImGui::AddTab("Tab Name4")){ ImGui::Text("Tab 3"); } if (ImGui::AddTab("Tab Name5")){ ImGui::Text("Tab 4"); } ImGui::EndTabBar();">
ImGui::BeginTabBar("Settings#left_tabs_bar");

// ericb 2017_07_21 : draw the tabs background BEFORE to fill it, to avoid a "colored overlay"
ImGui::DrawTabsBackground();

if (ImGui::AddTab("General")){
    bool fullscreen = mGUICfg->fullScreen.value;
    if(ImGui::Checkbox("Fullscreen Mode",&fullscreen)){
        mGUICfg->toggleFullscreenMode = true;
    }
    if(ImGui::Checkbox("Enable Multisampling",&mGUICfg->enableMultisampling.value)){
        mGUICfg->settingsChanged = true;
    }

    if(ImGui::SliderInt("MSAA Count",(int*)&mGUICfg->multisampleCount.value,mGUICfg->multisampleCount.lowerLimit,mGUICfg->multisampleCount.upperLimit))
        mGUICfg->settingsChanged = true;
}
if (ImGui::AddTab("GUI")){
    ImGui::Text("Tab 2");
}
if (ImGui::AddTab("Tab Name")){
    ImGui::Text("Tab 3");
}
if (ImGui::AddTab("Tab Name")){
    ImGui::Text("Tab 4");
}
ImGui::EndTabBar();

ImGui::Dummy(ImVec2(0,20));

ImGui::BeginTabBar("#Additional Parameters");
float value = 0.0f;

// ericb 2017_07_21 : draw the tabs background BEFORE to fill it, to avoid a "colored overlay"
ImGui::DrawTabsBackground();

if (ImGui::AddTab("Tab Name2")){
    ImGui::SliderFloat("Slider",&value,0,1.0f);
}
if (ImGui::AddTab("Tab Name3")){
    ImGui::Text("Tab 2");
}
if (ImGui::AddTab("Tab Name4")){
    ImGui::Text("Tab 3");
}
if (ImGui::AddTab("Tab Name5")){
    ImGui::Text("Tab 4");
}
ImGui::EndTabBar();

Yields results like this:

alt text

Usage:

} -> This is much like collapsing header. If the tab is active, then AddTab will return true, allowing drawing to occur. End the tab bar by using ImGui::EndTabBar() And that's it! You can dynamically add or remove tabs, the bar will reset the ID and tab label vectors appropriately, but it DOESN'T continuously allocate/deallocate them in memory every time (unless the CRC32 hashes of the tab or tab bar change, computed from their respective labels). Notes: * You can change the rounding by altering: "static constexpr const float rounding = 6.0f;" in the _drawTabBarTop function. Alternatively, you can add it as a parameter, but to save on memory being passed around, and since I will be using 6 as a constant, I didn't include this. * The constexpr: "static constexpr const float shrink = 1.0f;" in the _drawTabBarTop function needs to be set to the width of your borders. * I added custom colors and a new prototype for GetColorU32() to acquire these colors. You can change them here. * I added extra operator functions for ImVec2 and ImVec4, _YOU MUST_ define IMGUI_DEFINE_MATH_OPERATORS in imgui_internal.h for this to work. * Please attribute my work if used or added, along with the original ImGui license/attribution.">
 To start a tab bar, use: ImGui::BeginTabBar(const char* label)
      -> The label can be blank if you want, but you MUST!! pass a string of some length. Use the '#' character to
          give it an ID without a label.

  Add tabs by using:
      if (ImGui::AddTab("Tab Name")){
             < Insert other draw commands here >
      }
      -> This is much like collapsing header. If the tab is active, then AddTab will return true, allowing drawing
          to occur.

  End the tab bar by using ImGui::EndTabBar()

  And that's it! You can dynamically add or remove tabs, the bar will reset the ID and tab label vectors appropriately,
  but it DOESN'T continuously allocate/deallocate them in memory every time (unless the CRC32 hashes of the tab or tab bar change,
  computed from their respective labels).

  Notes:
      * You can change the rounding by altering:
              "static constexpr const float rounding = 6.0f;"
         in the _drawTabBarTop function. Alternatively, you can add it as a parameter, but to save on memory being passed
         around, and since I will be using 6 as a constant, I didn't include this.

      * The constexpr:
              "static constexpr const float shrink = 1.0f;"
         in the _drawTabBarTop function needs to be set to the width of your borders.

      * I added custom colors and a new prototype for GetColorU32() to acquire these colors. You can change them here.

      * I added extra operator functions for ImVec2 and ImVec4, _YOU MUST_ define IMGUI_DEFINE_MATH_OPERATORS in
         imgui_internal.h for this to work.

      * Please attribute my work if used or added, along with the original ImGui license/attribution.
Issues
  • does not work

    does not work

    With the latest imgui it does not build Here is the error log

    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(38): error C2676: binary '*': 'ImVec4' does not define this operator or a conversion to a type acceptable to the predefined operator [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(39): error C2676: binary '*': 'ImVec4' does not define this operator or a conversion to a type acceptable to the predefined operator [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(40): error C2676: binary '*': 'ImVec4' does not define this operator or a conversion to a type acceptable to the predefined operator [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(106): error C2039: 'PathFill': is not a member of 'ImDrawList' [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(111): error C2039: 'PathFill': is not a member of 'ImDrawList' [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(191): error C2676: binary '+': 'ImVec2' does not define this operator or a conversion to a type acceptable to the predefined operator [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(191): error C2088: '+': illegal for struct [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(204): error C2065: 'ImGuiCorner_TopLeft': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(204): error C2065: 'ImGuiCorner_TopRight': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(206): error C2065: 'ImGuiCorner_TopLeft': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(206): error C2065: 'ImGuiCorner_TopRight': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(207): error C2660: 'ImGui::_drawPartialRect': function does not take 6 arguments [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(210): error C2676: binary '+': 'ImVec2' does not define this operator or a conversion to a type acceptable to the predefined operator [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(232): error C2676: binary '+': 'ImVec2' does not define this operator or a conversion to a type acceptable to the predefined operator [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(232): error C2088: '+': illegal for struct [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(234): error C2065: 'ImGuiCorner_TopLeft': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(234): error C2065: 'ImGuiCorner_TopRight': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(236): error C2065: 'ImGuiCorner_TopLeft': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(236): error C2065: 'ImGuiCorner_TopRight': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(238): error C2065: 'ImGuiCorner_TopLeft': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(238): error C2065: 'ImGuiCorner_TopRight': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(240): error C2664: 'void ImGui::_drawPartialRect(const ImVec2,const ImVec2,const float,const int,ImDrawList *,const ImGui::_EdgeType,const ImU32,const bool,const ImGui::_EdgeType,const float,const float)': cannot convert argument 4 from 'ImDrawList *' to 'const int' [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(243): error C2676: binary '+': 'ImVec2' does not define this operator or a conversion to a type acceptable to the predefined operator [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(244): error C2676: binary '+': 'const ImVec2' does not define this operator or a conversion to a type acceptable to the predefined operator [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(247): error C2676: binary '+=': 'ImVec2' does not define this operator or a conversion to a type acceptable to the predefined operator [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(248): error C2676: binary '-': 'ImVec2' does not define this operator or a conversion to a type acceptable to the predefined operator [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(271): error C2065: 'ImGuiCorner_BottomLeft': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(271): error C2065: 'ImGuiCorner_BottomRight': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(273): error C2065: 'ImGuiCorner_BottomLeft': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(273): error C2065: 'ImGuiCorner_TopRight': undeclared identifier [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(275): error C2676: binary '+=': 'ImVec2' does not define this operator or a conversion to a type acceptable to the predefined operator [D:\Programming\bak\gui_project\build\cloud_commander_ui.vcxproj]
    [build]          D:\Programming\bak\gui_project\imgui_tabs\imgui_tabs.cpp(297): error C2039: 'cerr': is not a member of 'std' 
    
    opened by kenkit 1
  • Which version of Imgui will we use ?

    Which version of Imgui will we use ?

    It seems with 1.65 version there are errors and as a newbie to imgui i couldn't track all of them. Will you update this or which version of imgui should we use ?

    opened by geekowll 0
  • Fix function calls and add missing includes

    Fix function calls and add missing includes

    In order for this library to work for me, I had to change some names of function calls (they may have changed with new versions of imgui) and there were missing includes (string and iostream).

    opened by kim366 0
  • "colored" overlay

    First, thanks a lot for your tabs, they are working very well on my side, excepted one issue I think I found the why (maybe my fix is just a bad hack, please apologies).

    To reproduce the issue, have a look at the screenshot I provived in https://github.com/ocornut/imgui/issues/1083 : just below the active tab, "Aide", you'll see the white ( alpha = 0.15) background. The problem is that this background is drawn on top of the tabs contents (sort of "overlay"), and e.g. when one tab is a frame coming from a webcam, the colors are plain wrong. This issue is true for every tab in fact.

    Second issue (linked) : when you move the window containing the tabs, or resize it, the background is modified, means probably does not use the right coordinates. This should be fixed too in the proposed code.

    As workaround, I modified your code to draw the background before to fill it with the content.

    Please see the commit I did there : https://github.com/ebachard/imgui_tabs

    Last but not least, I'll attach a screenshot with what I got now.

    Feel free to use the proposed code under the license you prefer, that's no problem for me ;-) imgui tabslayout_2017_07_21

    opened by ebachard 0
Owner
Scott Mudge
Senior Software Engineer working in computer vision, 3D reconstruction, artificial intelligence, and medical imaging.
Scott Mudge
Edited and relatively up-to-date xenos injector

Xenos Windows dll injector. Based on Blackbone library - https://github.com/DarthTon/Blackbone Changes from the original repository Up-to-date blackbo

null 5 Apr 18, 2022
Clean tab-less browser based on webkit2 and GTK4.

Rose Browser Simple browser based on webkit2-5.0/GTK4. Showcase Requirements In order to build rose you need gtk4 and webkit2gtk-5.0. In order to use

Rosé 259 Aug 3, 2022
This was the first ever Computer Science project that I made back in Class XII (2016). I thought I should upload it on GitHub so that it does not get lost. :)

First Ever Project This was the first ever Computer Science project that I made back in Class XII (2016). I thought I should upload it on github so th

Kshitiz Srivastava 3 Jun 7, 2021
Any one can add their programs here ,but program should not be repeated.

Hactoberfest2021 To All the Beginners Guys Don't Forget to give star to this repo. Any one can add their programs here ,but program should not be repe

Varun.py 22 Jun 12, 2022
Müsli USB Pmod-compatible module

Müsli USB Pmod™ compatible module Overview Müsli is a 12-pin Pmod™ compatible module with a RP2040 MCU and a USB type A port. Müsli can be configured

Machdyne 6 Apr 14, 2022
api & source menu base import imgui from imgui-js

onetap v4 crack https://discord.gg/AXCtxVH4PB people asking me for otv4 source "bin2h" (meaning binary to hex) large hexadecimal array deleted all the

h4xr0x#1337 8 Jun 25, 2022
Dear ImGui Addons Branch = plain unmodified dear imgui plus some extra addon.

Dear ImGui (This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addit

Flix 348 Jul 23, 2022
Arduino firmware for DIY haptic gloves. Officially compatible with LucidVR gloves.

lucidgloves-firmware This repo contains the arduino firmware as well as the STL files for Prototype 3 of the LucidVR glove prototype. This is a finger

null 1.4k Aug 3, 2022
Single-header, ranges-compatible generator type built on C++20 coroutines

generator Single-header, ranges-compatible generator type built with C++20 coroutines. A generator allows implementing sequence producers which are te

Sy Brand 28 Jul 23, 2022
ESP32 firmware to read and control EMS and Heatronic compatible equipment such as boilers, thermostats, solar modules, and heat pumps

EMS-ESP is an open-source firmware for the Espressif ESP8266 and ESP32 microcontroller that communicates with EMS (Energy Management System) based equipment from manufacturers like Bosch, Buderus, Nefit, Junkers, Worcester and Sieger.

EMS-ESP 163 Aug 3, 2022
Flashrom/serprog compatible firmware for the Raspberry Pi Pico

pico-serprog This is a very basic flashrom/serprog compatible SPI flash reader/writer for the Raspberry Pi Pico. It does not require a custom version

stacksmashing 24 Jul 6, 2022
This is the Arduino® compatible port of the AIfES machine learning framework, developed and maintained by Fraunhofer Institute for Microelectronic Circuits and Systems.

AIfES for Arduino® AIfES (Artificial Intelligence for Embedded Systems) is a platform-independent and standalone AI software framework optimized for e

null 138 Jul 14, 2022
ESP32 S2 C++ host library compatible with arduino, esp-idf.

Info I would like to announce USB host library for esp32 S2 compatible with arduino, esp-idf and PIO (when pio will be updated to most recent esp-idf)

null 15 Jun 2, 2022
Arduino/ESP32 firmware for DIY haptic gloves. Officially compatible with LucidVR gloves.

Arduino/ESP32 firmware for DIY haptic gloves. Officially compatible with LucidVR gloves.

null 1.4k Aug 8, 2022
Arduino-compatible development platform whose primary function is a clock

MakeTime Arduino-compatible development platform whose primary function is a clock Description MakeTime is a clock that uses a ring of 24 RGB LEDs to

null 3 Oct 11, 2021
Adafruit GFX compatible arduino library for using cat thermal printers with the ESP32

CatGFX This library offers a Adafruit GFX "driver" for ESP32 and the cheap cat (or rabbit?) BLE thermal printers like this one: For usage information

Claus Näveke 2 Jul 15, 2022
A simple example for 'Arduino' compatible boards to interface with I2C to the MPU-6050, a 6-axis micro-electromechanical IC

Arduino-MPU-6050 A simple example for 'Arduino' compatible boards to interface with I2C to the MPU-6050, a 6-axis micro-electromechanical IC ==About==

Ivan 1 Oct 19, 2021
Header-only ECMAScript (JavaScript) compatible regular expression engine

SRELL (std::regex-like library) is a regular expression template library for C++ and has native support for UTF-8, UTF-16, and UTF-32. This is up-to-d

Dmitry Atamanov 4 Mar 11, 2022