Skip to content

Commit b0d3806

Browse files
authored
Merge pull request jvcleave#49 from hamoid/master
Allow setting ImGuiWindowFlags in BeginWindow
2 parents c21928f + 2bd5e82 commit b0d3806

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/Helpers.cpp

+21-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ bool ofxImGui::BeginWindow(const string& name, Settings& settings, bool collapse
7272
return ImGui::Begin(name.c_str(), open, ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize | (collapse ? 0 : ImGuiWindowFlags_NoCollapse));
7373
}
7474

75+
//--------------------------------------------------------------
76+
bool ofxImGui::BeginWindow(const string& name, Settings& settings, ImGuiWindowFlags flags, bool * open)
77+
{
78+
if (settings.windowBlock)
79+
{
80+
ofLogWarning(__FUNCTION__) << "Already inside a window block!";
81+
return false;
82+
}
83+
84+
settings.windowBlock = true;
85+
86+
// Push a new list of names onto the stack.
87+
windowOpen.usedNames.push(std::vector<std::string>());
88+
89+
ImGui::SetNextWindowPos(settings.windowPos, ImGuiSetCond_Appearing);
90+
ImGui::SetNextWindowSize(settings.windowSize, ImGuiSetCond_Appearing);
91+
ImGui::SetNextWindowCollapsed(!(flags & ImGuiWindowFlags_NoCollapse), ImGuiSetCond_Appearing);
92+
return ImGui::Begin(name.c_str(), open, flags);
93+
}
94+
7595
//--------------------------------------------------------------
7696
void ofxImGui::EndWindow(Settings& settings)
7797
{
@@ -563,4 +583,4 @@ void ofxImGui::AddImage(ofTexture& texture, const ofVec2f& size)
563583
{
564584
ImTextureID textureID = (ImTextureID)(uintptr_t)texture.texData.textureID;
565585
ImGui::Image(textureID, size);
566-
}
586+
}

src/Helpers.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace ofxImGui
3838
void SetNextWindow(Settings& settings);
3939
bool BeginWindow(ofParameter<bool>& parameter, Settings& settings, bool collapse = true);
4040
bool BeginWindow(const string& name, Settings& settings, bool collapse = true, bool * open = nullptr);
41+
bool BeginWindow(const string& name, Settings& settings, ImGuiWindowFlags flags, bool * open = nullptr);
4142
void EndWindow(Settings& settings);
4243

4344
bool BeginTree(ofAbstractParameter& parameter, Settings& settings);
@@ -157,4 +158,4 @@ bool ofxImGui::AddValues(const string& name, vector<DataType>& values, DataType
157158
}
158159
}
159160
return result;
160-
}
161+
}

0 commit comments

Comments
 (0)