Skip to content

Commit 17c3ef5

Browse files
committed
semi-fix for inspector auto-width adjustment
1 parent bb42757 commit 17c3ef5

File tree

7 files changed

+20
-3
lines changed

7 files changed

+20
-3
lines changed

src/PatchObject.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ PatchObject::PatchObject(const std::string& _customUID ) : ofxVPHasUID(_customUI
6565
y = 0.0f;
6666
fontSize = 12;
6767

68+
configMenuWidth = 246.0f;
69+
6870
canvasScale = 1;
6971
scaleFactor = 1.0f;
7072

@@ -96,6 +98,7 @@ void PatchObject::setup(shared_ptr<ofAppGLFWWindow> &mainWindow){
9698
headerHeight *= 2;
9799
fontSize = 16;
98100
scaleFactor = 2.0f;
101+
configMenuWidth *= 2;
99102
}
100103

101104
setupObjectContent(mainWindow);

src/PatchObject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class PatchObject : public ofxVPHasUID {
168168
float getObjectHeight() { return height; }
169169
int getOutputWidth() { return output_width; }
170170
int getOutputHeight() { return output_height; }
171+
float getConfigmenuWidth() { return configMenuWidth; }
171172

172173
string getFilepath() { return filepath; }
173174

@@ -217,6 +218,7 @@ class PatchObject : public ofxVPHasUID {
217218
int fontSize;
218219
ImVec2 canvasTranslation;
219220
float canvasScale;
221+
float configMenuWidth;
220222
float scaleFactor;
221223

222224
// Core vars

src/objects/gui/moValuePlotter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ void moValuePlotter::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
144144

145145
drawObjectNodeConfig();
146146

147+
this->configMenuWidth = ImGui::GetWindowWidth();
148+
147149
ImGui::EndMenu();
148150
}
149151

src/objects/math/Smooth.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ void Smooth::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
122122

123123
drawObjectNodeConfig();
124124

125+
this->configMenuWidth = ImGui::GetWindowWidth();
126+
125127
ImGui::EndMenu();
126128
}
127129

src/objects/scripting/ShaderObject.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ void ShaderObject::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
324324

325325
drawObjectNodeConfig();
326326

327+
this->configMenuWidth = ImGui::GetWindowWidth();
328+
327329
ImGui::EndMenu();
328330
}
329331

src/ofxVisualProgramming.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ ofxVisualProgramming::ofxVisualProgramming(){
8282
profilerActive = false;
8383
inspectorActive = false;
8484
inspectorTitle = "";
85+
lastInspectorWidth = 0.0f;
8586

8687
inited = false;
8788

@@ -372,21 +373,25 @@ void ofxVisualProgramming::draw(){
372373
//--------------------------------------------------------------
373374
void ofxVisualProgramming::drawInspector(){
374375

375-
ImGui::SetNextWindowSize(ImVec2(246*scaleFactor,ofGetWindowHeight()-(26*scaleFactor)), ImGuiCond_Always );
376-
ImGui::SetNextWindowPos(ImVec2(ofGetWindowWidth()-246*scaleFactor,26*scaleFactor), ImGuiCond_Always);
376+
ImGui::SetNextWindowSize(ImVec2(lastInspectorWidth,ofGetWindowHeight()-(26*scaleFactor)), ImGuiCond_Always );
377+
ImGui::SetNextWindowPos(ImVec2(ofGetWindowWidth()-lastInspectorWidth,26*scaleFactor), ImGuiCond_Always);
377378

378379
if(patchObjects.find(nodeCanvas.getActiveNode()) != patchObjects.end()){
379380
inspectorTitle = "Inspector | "+patchObjects[nodeCanvas.getActiveNode()]->getDisplayName()+" | id: "+ofToString(nodeCanvas.getActiveNode());
380381
}else{
381382
inspectorTitle = "Inspector";
382383
}
383-
ImGui::Begin(inspectorTitle.c_str(), 0, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
384+
ImGui::Begin(inspectorTitle.c_str(), 0, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize);
384385

385386
// if object id exists
386387
if(patchObjects.find(nodeCanvas.getActiveNode()) != patchObjects.end()){
388+
387389
patchObjects[nodeCanvas.getActiveNode()]->drawImGuiNodeConfig();
390+
391+
lastInspectorWidth = patchObjects[nodeCanvas.getActiveNode()]->getConfigmenuWidth();
388392
}
389393

394+
390395
ImGui::End();
391396
}
392397

src/ofxVisualProgramming.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class ofxVisualProgramming : public pdsp::Wrapper {
160160

161161
// GUI
162162
string inspectorTitle;
163+
float lastInspectorWidth;
163164
bool isHoverMenu;
164165
bool isHoverLogger;
165166
bool isHoverCodeEditor;

0 commit comments

Comments
 (0)