Skip to content

Commit 49cca5e

Browse files
committed
added objects/nodes inspector, close #30
1 parent 504a04e commit 49cca5e

File tree

266 files changed

+3422
-2459
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

266 files changed

+3422
-2459
lines changed

src/PatchObject.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void PatchObject::drawImGuiNode(ImGuiEx::NodeCanvas& _nodeCanvas, map<int,shared
167167
ImVec2 imPos( this->getPos() );
168168
ImVec2 imSize( this->width, this->height );
169169

170-
if(_nodeCanvas.BeginNode( PatchObject::getUID().c_str(), PatchObject::getDisplayName(), imPos, imSize, this->getNumInlets(), this->getNumOutlets(), this->getIsResizable(), this->getIsTextureObject() )){
170+
if(_nodeCanvas.BeginNode( nId, PatchObject::getUID().c_str(), PatchObject::getDisplayName(), imPos, imSize, this->getNumInlets(), this->getNumOutlets(), this->getIsResizable(), this->getIsTextureObject() )){
171171

172172
// save node state on click
173173
if(ImGui::IsWindowHovered() && ImGui::IsMouseReleased(0)){
@@ -302,6 +302,11 @@ void PatchObject::drawImGuiNode(ImGuiEx::NodeCanvas& _nodeCanvas, map<int,shared
302302

303303
}
304304

305+
//--------------------------------------------------------------
306+
void PatchObject::drawImGuiNodeConfig(){
307+
drawObjectNodeConfig();
308+
}
309+
305310
//--------------------------------------------------------------
306311
void PatchObject::move(int _x, int _y){
307312
int px = _x;

src/PatchObject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class PatchObject : public ofxVPHasUID {
8585
void update(map<int,shared_ptr<PatchObject>> &patchObjects, pdsp::Engine &engine);
8686
void draw(ofxFontStash *font);
8787
void drawImGuiNode(ImGuiEx::NodeCanvas& _nodeCanvas, map<int,shared_ptr<PatchObject>> &patchObjects);
88+
void drawImGuiNodeConfig();
8889

8990
// Virtual Methods
9091
virtual void newObject() {}
@@ -98,6 +99,7 @@ class PatchObject : public ofxVPHasUID {
9899
virtual void updateAudioObjectContent(pdsp::Engine &engine) {}
99100
virtual void drawObjectContent(ofxFontStash *font, shared_ptr<ofBaseGLRenderer>& glRenderer) {}
100101
virtual void drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ) {}
102+
virtual void drawObjectNodeConfig() {}
101103
virtual void removeObjectContent(bool removeFileFromData=false) {}
102104

103105
virtual void audioInObject(ofSoundBuffer &inputBuffer) {}

src/core/imgui_node_canvas.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ void ImGuiEx::NodeCanvas::DrawFrameBorder(const bool& _drawOnForeground) const {
269269

270270

271271
// always use EndNode() even if returns false. Like ImGui Windows.
272-
bool ImGuiEx::NodeCanvas::BeginNode( const char* _id, std::string name, ImVec2& _pos, ImVec2& _size, const int& _numLeftPins, const int& _numRightPins, const bool& canResize, const bool& isTextureNode ){
272+
bool ImGuiEx::NodeCanvas::BeginNode( int nId, const char* _id, std::string name, ImVec2& _pos, ImVec2& _size, const int& _numLeftPins, const int& _numRightPins, const bool& canResize, const bool& isTextureNode ){
273273
// Check callstack
274274
IM_ASSERT(isDrawingCanvas == true); // forgot to End();
275275
IM_ASSERT(canDrawNode == true); // Don't call if Begin() returned false
@@ -388,11 +388,19 @@ bool ImGuiEx::NodeCanvas::BeginNode( const char* _id, std::string name, ImVec2&
388388
}
389389

390390
// Draw HeaderBar BG
391-
nodeDrawList->AddRectFilled(
392-
curNodeData.outerContentBox.Min,
393-
curNodeData.outerContentBox.Min+ImVec2(curNodeData.outerContentBox.GetSize().x, IMGUI_EX_NODE_HEADER_HEIGHT*scaleFactor),
394-
ImGui::GetColorU32(ImGuiCol_Header)
395-
);
391+
if(nId == activeNode){
392+
nodeDrawList->AddRectFilled(
393+
curNodeData.outerContentBox.Min,
394+
curNodeData.outerContentBox.Min+ImVec2(curNodeData.outerContentBox.GetSize().x, IMGUI_EX_NODE_HEADER_HEIGHT*scaleFactor),
395+
IM_COL32(90,90,90,200)
396+
);
397+
}else{
398+
nodeDrawList->AddRectFilled(
399+
curNodeData.outerContentBox.Min,
400+
curNodeData.outerContentBox.Min+ImVec2(curNodeData.outerContentBox.GetSize().x, IMGUI_EX_NODE_HEADER_HEIGHT*scaleFactor),
401+
ImGui::GetColorU32(ImGuiCol_Header)
402+
);
403+
}
396404

397405
// Draw footer
398406
nodeDrawList->AddRectFilled(
@@ -418,6 +426,10 @@ bool ImGuiEx::NodeCanvas::BeginNode( const char* _id, std::string name, ImVec2&
418426
static ImVec2 mouseOffset(0,0);
419427
static bool isDraggingHeader = false;
420428

429+
if(ImGui::IsItemActive() && ImGui::IsItemClicked(0)){
430+
activeNode = nId;
431+
}
432+
421433
if(ImGui::IsItemActive() && ImGui::IsMouseDragging(0)){
422434
if(!isDraggingHeader){
423435
mouseOffset = ImGui::GetMousePos()-curNodeData.outerContentBox.Min;

src/core/imgui_node_canvas.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ struct NodeCanvas {
221221

222222
// Draw Child windows (aka Nodes) on the canvas.
223223
// position and size may change be updated after function call.
224-
bool BeginNode( const char* id, std::string name, ImVec2& _pos, ImVec2& _size, const int& _numLeftPins, const int& _numRightPins, const bool& canResize, const bool& isTextureNode );
224+
bool BeginNode( int nId, const char* id, std::string name, ImVec2& _pos, ImVec2& _size, const int& _numLeftPins, const int& _numRightPins, const bool& canResize, const bool& isTextureNode );
225225
void EndNode();
226226

227227
// Adds an inlet and sets its position on screen so you can do more graphic stuff with it.
@@ -292,6 +292,10 @@ struct NodeCanvas {
292292
// Returns selected links
293293
std::vector<int> getSelectedLinks(){ return selected_links; }
294294

295+
// Returns active node
296+
int getActiveNode() { return activeNode; }
297+
void setActiveNode(int objID) { activeNode = objID; }
298+
295299
ImVec2 getInletPosition(int objID, int pinID) {
296300
for(std::map<int,std::map<int,ImVec2>>::iterator it = inletPinsPositions.begin(); it != inletPinsPositions.end(); it++ ){
297301
if(it->first == objID){
@@ -342,6 +346,7 @@ struct NodeCanvas {
342346
std::vector<int> selected_links; // for delete links (one or multiple) -- IMPLEMENTED
343347
std::string activePin;
344348
std::string activePinType;
349+
int activeNode = 0; // for node inspector
345350

346351
// retina stuff
347352
bool isRetina = false;

src/objects/audio_analysis/AudioAnalyzer.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,8 @@ void AudioAnalyzer::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
216216
if (ImGui::BeginMenu("CONFIG"))
217217
{
218218

219-
ImGuiEx::ObjectInfo(
220-
"This object is an audio analysis station which transmits a vector with all the analyzed data. Each type of audio data is available in the different extractor objects inside the same category.",
221-
"https://mosaic.d3cod3.org/reference.php?r=audio-analyzer", scaleFactor);
219+
drawObjectNodeConfig();
220+
222221

223222

224223
ImGui::EndMenu();
@@ -256,6 +255,13 @@ void AudioAnalyzer::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
256255

257256
}
258257

258+
//--------------------------------------------------------------
259+
void AudioAnalyzer::drawObjectNodeConfig(){
260+
ImGuiEx::ObjectInfo(
261+
"This object is an audio analysis station which transmits a vector with all the analyzed data. Each type of audio data is available in the different extractor objects inside the same category.",
262+
"https://mosaic.d3cod3.org/reference.php?r=audio-analyzer", scaleFactor);
263+
}
264+
259265
//--------------------------------------------------------------
260266
void AudioAnalyzer::removeObjectContent(bool removeFileFromData){
261267
//audioAnalyzer.exit();

src/objects/audio_analysis/AudioAnalyzer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class AudioAnalyzer : public PatchObject {
5454

5555
void drawObjectContent(ofxFontStash *font, shared_ptr<ofBaseGLRenderer>& glRenderer) override;
5656
void drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ) override;
57+
void drawObjectNodeConfig() override;
5758

5859

5960
void removeObjectContent(bool removeFileFromData=false) override;

src/objects/audio_analysis/BPMExtractor.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@ void BPMExtractor::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
142142
if (ImGui::BeginMenu("CONFIG"))
143143
{
144144

145-
ImGuiEx::ObjectInfo(
146-
"Get the beat, the average bmp over a period of time, and the beat time period in milliseconds",
147-
"https://mosaic.d3cod3.org/reference.php?r=bpm-extractor", scaleFactor);
145+
drawObjectNodeConfig();
146+
148147

149148

150149
ImGui::EndMenu();
@@ -174,6 +173,13 @@ void BPMExtractor::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
174173

175174
}
176175

176+
//--------------------------------------------------------------
177+
void BPMExtractor::drawObjectNodeConfig(){
178+
ImGuiEx::ObjectInfo(
179+
"Get the beat, the average bmp over a period of time, and the beat time period in milliseconds",
180+
"https://mosaic.d3cod3.org/reference.php?r=bpm-extractor", scaleFactor);
181+
}
182+
177183
//--------------------------------------------------------------
178184
void BPMExtractor::removeObjectContent(bool removeFileFromData){
179185

src/objects/audio_analysis/BPMExtractor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class BPMExtractor : public PatchObject {
5050

5151
void drawObjectContent(ofxFontStash *font, shared_ptr<ofBaseGLRenderer>& glRenderer) override;
5252
void drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ) override;
53+
void drawObjectNodeConfig() override;
5354

5455
void removeObjectContent(bool removeFileFromData=false) override;
5556

src/objects/audio_analysis/CentroidExtractor.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,8 @@ void CentroidExtractor::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
129129
if (ImGui::BeginMenu("CONFIG"))
130130
{
131131

132-
ImGuiEx::ObjectInfo(
133-
"Extracts the center of gravity of the spectral energy, its power.",
134-
"https://mosaic.d3cod3.org/reference.php?r=centroid-extractor", scaleFactor);
132+
drawObjectNodeConfig();
133+
135134

136135
ImGui::EndMenu();
137136
}
@@ -148,6 +147,13 @@ void CentroidExtractor::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
148147
}
149148
}
150149

150+
//--------------------------------------------------------------
151+
void CentroidExtractor::drawObjectNodeConfig(){
152+
ImGuiEx::ObjectInfo(
153+
"Extracts the center of gravity of the spectral energy, its power.",
154+
"https://mosaic.d3cod3.org/reference.php?r=centroid-extractor", scaleFactor);
155+
}
156+
151157
//--------------------------------------------------------------
152158
void CentroidExtractor::removeObjectContent(bool removeFileFromData){
153159

src/objects/audio_analysis/CentroidExtractor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class CentroidExtractor : public PatchObject {
5050

5151
void drawObjectContent(ofxFontStash *font, shared_ptr<ofBaseGLRenderer>& glRenderer) override;
5252
void drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ) override;
53+
void drawObjectNodeConfig() override;
5354

5455
void removeObjectContent(bool removeFileFromData=false) override;
5556

0 commit comments

Comments
 (0)