Skip to content

Commit

Permalink
help boxes fix sizes. Layout presets engine fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
moebiussurfing committed May 18, 2024
1 parent 67443bf commit 7c575d6
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 58 deletions.
11 changes: 5 additions & 6 deletions Examples_3_Engines/35_LayoutsEngine/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void ofApp::setupImGui()

// NOTICE that
// To enable the "Layout Presets Engine"
// is mandatory to pass IM_GUI_MODE_INSTANTIATED_DOCKING as argument !
// it requires to pass IM_GUI_MODE_INSTANTIATED_DOCKING as argument!
ui.setup(IM_GUI_MODE_INSTANTIATED_DOCKING);

//-
Expand All @@ -46,7 +46,7 @@ void ofApp::setupImGui()
// to handle the show/hide window states.
// Notice that is important to remember the index sorting when queuing!

ui.addWindowSpecial("Main"); // remember index 0
ui.addWindowSpecial("Main"); // index 0 (remember)
ui.addWindowSpecial("Audio"); // index 1
ui.addWindowSpecial("Video1"); // index 2
ui.addWindowSpecial("Video2"); // index 3
Expand Down Expand Up @@ -135,8 +135,7 @@ void ofApp::draw()

ui.Begin();
{
//TODO: currently required but not used.
// should remove to simplify.
// Required to call as ImGui workflow requires.
drawImGuiDocking();

//--
Expand All @@ -162,8 +161,8 @@ void ofApp::draw()
//----------------------------------------------------------
void ofApp::drawImGuiDocking()
{
//TODO: this cant be removed for the moment...
// Should allow to disable!
// This requeriment can be removed
// using IM_GUI_MODE_INSTANTIATED_DOCKING_RAW_AUTOHANDLER as setup mode

// Here (between beginDocking/endDocking)
// we can access all the docking space.
Expand Down
12 changes: 9 additions & 3 deletions Examples_3_Engines/35_LayoutsEngine/src/ofApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

/*
This example shows how to use the
LAYOUT PRESETS ENGINE
This example shows how to use
the layout presets engine
Activate Help toggle to read the floating help box info.
*/
Expand All @@ -26,7 +26,13 @@ class ofApp : public ofBaseApp
void drawWindow3();
void drawWindow4();

// Another approach using toggle params instead of just names.
//--

// Another better approach using toggle params instead of just names:
// ui.addWindowSpecial("Main");
// ui.addWindowSpecial("Audio");
// //...
// This would be passing param booleans/toggles instead of just names.
//ofParameter<bool> bGui_Main{"Main", false};
//ofParameter<bool> bGui_Audio{"Audio", false};
//ofParameter<bool> bGui_Video1{"Video1", false};
Expand Down
91 changes: 51 additions & 40 deletions src/SurfingImGui/SurfingGuiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void SurfingGuiManager::setup(ofxImGuiSurfing::SurfingGuiMode mode) {

switch (surfingImGuiMode) {
case ofxImGuiSurfing::IM_GUI_MODE_UNKNOWN:
// Nothing to custom setup
// Nothing to custom setup
break;

//--
Expand Down Expand Up @@ -1949,7 +1949,8 @@ void SurfingGuiManager::updateLayout() {
void SurfingGuiManager::drawLayoutsManager() {
ImGuiWindowFlags flagsMng = ImGuiWindowFlags_None;

// Exclude from imgui.ini settings
// Exclude from imgui.ini settings.
// will be independent from layout presets.
flagsMng |= ImGuiWindowFlags_NoSavedSettings;

if (bAutoResize) flagsMng |= ImGuiWindowFlags_AlwaysAutoResize;
Expand Down Expand Up @@ -1987,7 +1988,9 @@ void SurfingGuiManager::drawLayoutsManager() {
} else {
}

//-
//--

// 1. Layouts window

if (bGui_LayoutsManager) {
//IMGUI_SUGAR__WINDOWS_CONSTRAINTSW_SMALL;
Expand Down Expand Up @@ -2024,7 +2027,7 @@ void SurfingGuiManager::drawLayoutsManager() {

//--

// Panels
// 1. Panels window

// Show a mini version when the main panel is hidden!

Expand All @@ -2037,15 +2040,13 @@ void SurfingGuiManager::drawLayoutsManager() {
this->AddSpacing();

// All the queued special windows aka panels

for (int i = 0; i < windows.size(); i++) {
AddToggleRoundedButton(windows[i].bGui);
}

this->AddSpacing();

// All, None

float _w2 = ofxImGuiSurfing::getWidgetsWidth(2);
if (ImGui::Button("All", ImVec2(_w2, _h / 2))) {
this->setShowAllPanels(true);
Expand All @@ -2062,8 +2063,9 @@ void SurfingGuiManager::drawLayoutsManager() {

//--

// Window Layouts
// 2. Layout/Manager windows

// Layouts tree
if (ImGui::TreeNode("LAYOUTS")) {
this->refreshLayout();
Add(bAutoResize_PresetsWindows, OFX_IM_TOGGLE_ROUNDED_SMALL);
Expand All @@ -2074,10 +2076,7 @@ void SurfingGuiManager::drawLayoutsManager() {

this->AddSpacingSeparated();

//--

// Window Panels

// Panels tree
ImGui::PushID("##PANELS2");
if (ImGui::TreeNode("PANELS")) {
this->refreshLayout();
Expand Down Expand Up @@ -2111,7 +2110,7 @@ void SurfingGuiManager::drawLayoutsManager() {
this->AddSpacingSeparated();

// a toggle that expands the other widgets
DrawAdvancedBundle();
this->DrawAdvancedBundle();
}

this->EndWindow();
Expand All @@ -2129,6 +2128,7 @@ void SurfingGuiManager::drawLayoutsPresetsEngine() {
// How to make all windows dockeable in the same space ?

// Main Layout Presets clicker
// and Manager linked windows
if (bGui_LayoutsPresetsSelector) {
drawLayoutsLayoutPresets();

Expand Down Expand Up @@ -2526,6 +2526,7 @@ void SurfingGuiManager::Begin() {
// Extra Tools / Engines

// 1. Layout Presets Engine
// Layout and Panels windows.

if (bDockingLayoutPresetsEngine) drawLayoutPresetsEngine();
// false by default as/when docking has not been initiated.
Expand Down Expand Up @@ -2684,14 +2685,14 @@ void SurfingGuiManager::End() {
//TODO: Maybe it's an ofxImGui feature..
if (!bAutoDraw) gui.draw();

//--
//--

//#ifdef SURFING__DOCKING_WORKFLOW_HANDLER_AUTODOCKING
// //workflow
// if (!bModeDockingAutohandler) {
// if (bDoneBeginDocking && bDoneEndDocking) bModeDockingAutohandler = true;
// }
//#endif
//#ifdef SURFING__DOCKING_WORKFLOW_HANDLER_AUTODOCKING
// //workflow
// if (!bModeDockingAutohandler) {
// if (bDoneBeginDocking && bDoneEndDocking) bModeDockingAutohandler = true;
// }
//#endif
}

//--
Expand Down Expand Up @@ -4254,7 +4255,7 @@ void SurfingGuiManager::drawLayoutsPanels() {
float ww = 450;
float hh = 300;

// set variable sizes to make all text (all/none) visible!
// set variable sizes to make all the text visible! (specially all/none)
if (NUM_WIDGETS > 5) {
ww = 600 + 200;
hh = 450;
Expand All @@ -4267,23 +4268,22 @@ void SurfingGuiManager::drawLayoutsPanels() {
}

// Landscape
if (_bLandscape) ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(ww, 100));

//if (_bLandscape) ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(450, 100));
//if (_bLandscape) ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(700, 150));
if (_bLandscape)
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(ww, 100));
//ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(450, 100));
//ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(700, 150));

// Portrait
else
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(95, hh));

//else ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(95, 300));
//else ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(105, 300));
//ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(95, 300));
//ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(105, 300));

#endif

//--

// Reset window
// Reset window trigger

ImGuiCond pnCond = ImGuiCond_None;
pnCond += ImGuiCond_Appearing;
Expand All @@ -4306,7 +4306,8 @@ void SurfingGuiManager::drawLayoutsPanels() {
const int i = 1;

if (bGui_LayoutsPanels) {
ImGui::SetNextWindowPos(ofVec2f(rectangles_Windows[i].get().getX(), rectangles_Windows[i].get().getY()),
ImGui::SetNextWindowPos(ofVec2f(rectangles_Windows[i].get().getX(),
rectangles_Windows[i].get().getY()),
pnCond);
ImGui::SetNextWindowSize(ofVec2f(rectangles_Windows[i].get().getWidth(),
rectangles_Windows[i].get().getHeight()),
Expand All @@ -4317,7 +4318,8 @@ void SurfingGuiManager::drawLayoutsPanels() {

// Draw window

if (this->BeginWindow(bGui_LayoutsPanels, flags_wPanels)) {
if (this->BeginWindow(bGui_LayoutsPanels, flags_wPanels))
{
const int i = 1;
rectangles_Windows[i].setWithoutEventNotifications(ofRectangle(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y,
ImGui::GetWindowWidth(),
Expand Down Expand Up @@ -4381,7 +4383,8 @@ void SurfingGuiManager::drawLayoutsPanels() {

//-

// 1. Populate all windows (aka panels) toggles
// 1. Panels big toggles
// Populate all windows (aka panels)

for (int i = 0; i < windows.size(); i++) {
ofxImGuiSurfing::AddBigToggle(windows[i].bGui, _w, _h);
Expand All @@ -4394,17 +4397,13 @@ void SurfingGuiManager::drawLayoutsPanels() {
float _w50;

// Landscape

if (_bLandscape) {
ImGui::SameLine();
_w100 = _w;
_w50 = (_w - _spcx) / 2.0f;
}

//-

// Portrait

else {
//this->AddSpacing();
this->AddSeparator();
Expand All @@ -4417,16 +4416,16 @@ void SurfingGuiManager::drawLayoutsPanels() {
//-

// Landscape

if (_bLandscape) {
ImGui::NextColumn();
ImGui::SetColumnWidth(1, _w100 + 2 * _spcx);
}

//-
//--

// 2. Extra widgets
// 2. More extra widgets

// all
if (ImGui::Button("All", ImVec2(_w50, _hWid))) {
// workflow
if (bSolo) bSolo.set(false);
Expand All @@ -4437,14 +4436,16 @@ void SurfingGuiManager::drawLayoutsPanels() {

ImGui::SameLine();

// none
if (ImGui::Button("None", ImVec2(_w50, _hWid))) {
bool b = false;
this->setShowAllPanels(b);
}

ofxImGuiSurfing::AddBigToggle(bSolo, _w100, _hWid, true);
// solo
ofxImGuiSurfing::AddBigToggle(bSolo, _w100, _hWid, true, true);

//-
//--

// 3. Panels Toggles

Expand Down Expand Up @@ -4484,6 +4485,16 @@ void SurfingGuiManager::drawLayoutsPanels() {
ImGui::Columns();
}

//--

//TODO
// weird layout fixes for looped resizing..
if (bAutoResize_Panels) {
this->AddSpacing();
this->AddSpacing();
this->AddSpacing();
}

this->EndWindow();
}

Expand Down
14 changes: 9 additions & 5 deletions src/SurfingImGui/SurfingGuiManager.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#pragma once

/*
* SurfingImGui\SurfingGuiManager.h
This is the main class that instantiates ofxImGui.
This is the main class
that instantiates ofxImGui internally.
So ImGui context "is here".
Handles the API workflow too,
helping populating windows and widgets.
Handles some internal params too, like minimize, auto resize... or extra booleans.
Handles some internal params too,
like minimize, auto resize... or extra booleans.
Docking helpers and Layout Presets operate here too.
*/

#pragma once

#include "ofMain.h"

#define IMGUI_DEFINE_MATH_OPERATORS // Access to math operators
Expand Down Expand Up @@ -3178,7 +3182,7 @@ class SurfingGuiManager {
if (bSeparator) ImGui::Separator();
ImGui::Spacing();

this->Add(bAdvanced, OFX_IM_TOGGLE_BUTTON_ROUNDED_MEDIUM);
this->Add(bAdvanced, OFX_IM_TOGGLE_BUTTON_ROUNDED);

DrawAdvancedSubPanel();
}
Expand Down
8 changes: 4 additions & 4 deletions src/SurfingImGui/widgets/HelpTextWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "ofMain.h"

/*
TODO
- make simpler Example.
*/
Expand Down Expand Up @@ -84,13 +84,13 @@ class HelpTextWidget
}
}

// Adapt window size to font size
// Adapt window size to font sizes and mono types
//if (!bResponsive)
{
switch (fontIndex)
{
case 0: case 4: IMGUI_SUGAR__WINDOWS_CONSTRAINTSW; break;//default
//case 0: case 4: IMGUI_SUGAR__WINDOWS_CONSTRAINTSW_MEDIUM; break;//default
//case 0: case 4: IMGUI_SUGAR__WINDOWS_CONSTRAINTSW; break;//default
case 0: case 4: IMGUI_SUGAR__WINDOWS_CONSTRAINTSW_MEDIUM; break;//default. better for big text examples
case 1: case 5: IMGUI_SUGAR__WINDOWS_CONSTRAINTSW_BIG; break;//big
case 2: case 6: IMGUI_SUGAR__WINDOWS_CONSTRAINTSW_FULL; break;//huge
case 3: case 7: IMGUI_SUGAR__WINDOWS_CONSTRAINTSW_MAX; break;//hugeXXL
Expand Down

0 comments on commit 7c575d6

Please sign in to comment.