Skip to content

Commit ab9187e

Browse files
committed
switched ofxImgui to fine tuned fork by @Daandelange
1 parent e2e0db3 commit ab9187e

File tree

7 files changed

+32
-21
lines changed

7 files changed

+32
-21
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ In order to build ofxVisualProgramming, you'll need this addons:
7979

8080
#### [ofxHapPlayer](https://github.com/d3cod3/ofxHapPlayer)
8181

82-
#### [ofxImGui](https://github.com/d3cod3/ofxImGui)
82+
#### [ofxImGui](https://github.com/Daandelange/ofxImGui)
8383

8484
#### [ofxInfiniteCanvas](https://github.com/d3cod3/ofxInfiniteCanvas)
8585

@@ -128,7 +128,7 @@ git clone https://github.com/d3cod3/ofxFFmpegRecorder
128128
git clone https://github.com/Akira-Hayasaka/ofxGLEditor
129129
git clone https://github.com/jeffcrouse/ofxJSON
130130
git clone https://github.com/d3cod3/ofxHapPlayer
131-
git clone https://github.com/d3cod3/ofxImGui
131+
git clone https://github.com/Daandelange/ofxImGui
132132
git clone https://github.com/d3cod3/ofxInfiniteCanvas
133133
git clone --branch=of-0.10.0 https://github.com/d3cod3/ofxLua
134134
git clone https://github.com/danomatika/ofxMidi

src/PatchObject.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ void PatchObject::drawImGuiNode(ImGuiEx::NodeCanvas& _nodeCanvas, map<int,shared
270270

271271
}
272272

273+
// Draw Node content and handle
273274
if(isNodeVisible){
274275

275276
// save node state on click

src/core/FileBrowser/ImGuiFileBrowser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ namespace imgui_addons
704704
input_combobox_sz.y = std::min((inputcb_filter_files.size() + 1) * frame_height + style.WindowPadding.y * 2.0f,
705705
8 * ImGui::GetFrameHeight() + style.WindowPadding.y * 2.0f);
706706

707-
if(show_inputbar_combobox && ( ImGui::GetFocusScopeID() == focus_scope_id || ImGui::GetCurrentContext()->ActiveIdIsAlive == input_id ))
707+
if(show_inputbar_combobox && ( ImGui::GetFocusedFocusScope() == focus_scope_id || ImGui::GetCurrentContext()->ActiveIdIsAlive == input_id ))
708708
{
709709
ImGuiWindowFlags popupFlags = ImGuiWindowFlags_NoTitleBar |
710710
ImGuiWindowFlags_NoResize |
@@ -723,7 +723,7 @@ namespace imgui_addons
723723
ImGui::BeginChild("##InputBarComboBox", input_combobox_sz, true, popupFlags);
724724

725725
ImVec2 listbox_size = input_combobox_sz - ImGui::GetStyle().WindowPadding * 2.0f;
726-
if(ImGui::ListBoxHeader("##InputBarComboBoxList", listbox_size))
726+
if(ImGui::BeginListBox("##InputBarComboBoxList", listbox_size))
727727
{
728728
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 1.0f,1.0f));
729729
ImGui::PushFocusScope(focus_scope_id);
@@ -747,7 +747,7 @@ namespace imgui_addons
747747
}
748748
ImGui::PopFocusScope();
749749
ImGui::PopStyleColor(1);
750-
ImGui::ListBoxFooter();
750+
ImGui::EndListBox();
751751
}
752752
ImGui::EndChild();
753753
ImGui::PopStyleColor(2);

src/core/imgui_controls.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ bool EnvelopeEditor(ImDrawList* drawList, float width, float height, float *_a,
2020
ImGuiWindow* Window = ImGui::GetCurrentWindow();
2121

2222
// prepare canvas
23-
const float dim = width > 0 ? width : ImGui::GetContentRegionAvailWidth();
23+
const float dim = width > 0 ? width : ImGui::GetContentRegionAvail().x;
2424
ImVec2 Canvas(dim, height);
2525

2626
ImRect bb(Window->DC.CursorPos, Window->DC.CursorPos + Canvas);
@@ -223,7 +223,7 @@ bool Pad2D(ImDrawList* drawList, float width, float height,float *_x, float *_y)
223223
ImGuiWindow* Window = ImGui::GetCurrentWindow();
224224

225225
// prepare canvas
226-
const float dim = width > 0 ? width : ImGui::GetContentRegionAvailWidth();
226+
const float dim = width > 0 ? width : ImGui::GetContentRegionAvail().x;
227227
ImVec2 Canvas(dim, height);
228228

229229
ImRect bb(Window->DC.CursorPos, Window->DC.CursorPos + Canvas);

src/core/imgui_node_canvas.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ void ImGuiEx::NodeCanvas::End(){
231231
IM_ASSERT(isDrawingCanvas == true); // // Begin() wasn't called
232232
IM_ASSERT(isDrawingNode == false); // Forgot to call EndNode()
233233

234-
isAnyCanvasNodeHovered = ImGui::IsAnyWindowHovered(); // not really needed anymore...
234+
isAnyCanvasNodeHovered = ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow); // not really needed anymore...
235235

236236
// reset cursor pos to canvas window
237237
ImGui::SetCursorPos(ImGui::GetWindowContentRegionMin());
@@ -556,10 +556,10 @@ bool ImGuiEx::NodeCanvas::BeginNode( int nId, const char* _id, std::string name,
556556
// The combination of a cliprect and columns allows us to set a clipping space for node widgets while reserving drawable space for pins, without having to add an extra window / childframe.
557557
ImGui::PushClipRect( curNodeData.leftPins.region.Min, curNodeData.rightPins.region.Max, true); // Inner space + Node Spaces
558558
ImGui::BeginColumns("innerNode", 3,
559-
ImGuiColumnsFlags_NoBorder
560-
| ImGuiColumnsFlags_NoResize
561-
//| ImGuiColumnsFlags_NoPreserveWidths
562-
| ImGuiColumnsFlags_NoForceWithinWindow // important so there's no weird auto adjustments.
559+
ImGuiOldColumnFlags_NoBorder
560+
| ImGuiOldColumnFlags_NoResize
561+
//| ImGuiOldColumnFlags_NoPreserveWidths
562+
| ImGuiOldColumnFlags_NoForceWithinWindow // important so there's no weird auto adjustments.
563563
);
564564
// Column layout
565565
// Note: A column of 0 width will probably cause crashes
@@ -768,7 +768,7 @@ ImGuiEx::NodeConnectData ImGuiEx::NodeCanvas::AddNodePin( const int nodeID, cons
768768
auto connectingColor = ImGui::ColorConvertU32ToFloat4(_color);
769769
connectingColor.w = 0.4f;
770770
const LinkBezierData link_data = get_link_renderable(pinLayout.curDrawPos + ImVec2( IMGUI_EX_NODE_PIN_WIDTH*scaleFactor * -.5f, pinLayout.pinSpace.y * .5f),ImGui::GetMousePos(),IMGUI_EX_NODE_LINK_LINE_SEGMENTS_PER_LENGTH);
771-
canvasDrawList->AddBezierCurve(link_data.bezier.p0,link_data.bezier.p1,link_data.bezier.p2,link_data.bezier.p3,ImGui::ColorConvertFloat4ToU32(connectingColor),IMGUI_EX_NODE_LINK_THICKNESS,link_data.num_segments);
771+
canvasDrawList->AddBezierCubic(link_data.bezier.p0,link_data.bezier.p1,link_data.bezier.p2,link_data.bezier.p3,ImGui::ColorConvertFloat4ToU32(connectingColor),IMGUI_EX_NODE_LINK_THICKNESS,link_data.num_segments);
772772

773773
// add link info
774774
std::string _temp = _type+" "+_gui_label;
@@ -792,7 +792,7 @@ ImGuiEx::NodeConnectData ImGuiEx::NodeCanvas::AddNodePin( const int nodeID, cons
792792
auto connectingColor = ImGui::ColorConvertU32ToFloat4(_color);
793793
connectingColor.w = 0.4f;
794794
const LinkBezierData link_data = get_link_renderable(canvasView.translation+(_linksData.at(0)._toPinPosition*canvasView.scale),ImGui::GetMousePos(),IMGUI_EX_NODE_LINK_LINE_SEGMENTS_PER_LENGTH);
795-
canvasDrawList->AddBezierCurve(link_data.bezier.p0,link_data.bezier.p1,link_data.bezier.p2,link_data.bezier.p3,ImGui::ColorConvertFloat4ToU32(connectingColor),IMGUI_EX_NODE_LINK_THICKNESS,link_data.num_segments);
795+
canvasDrawList->AddBezierCubic(link_data.bezier.p0,link_data.bezier.p1,link_data.bezier.p2,link_data.bezier.p3,ImGui::ColorConvertFloat4ToU32(connectingColor),IMGUI_EX_NODE_LINK_THICKNESS,link_data.num_segments);
796796

797797
// add link info
798798
std::string _temp = _type+" "+_linksData.at(0)._linkLabel;
@@ -829,7 +829,7 @@ ImGuiEx::NodeConnectData ImGuiEx::NodeCanvas::AddNodePin( const int nodeID, cons
829829
connectData.toInletPinID = pinID;
830830

831831
// reset selected links
832-
for(int i=0;i<_linksData.size();i++){
832+
for(unsigned int i=0;i<_linksData.size();i++){
833833
std::vector<int>::iterator it = std::find(selected_links.begin(), selected_links.end(),_linksData.at(i)._linkID);
834834
if (it!=selected_links.end()){
835835
selected_links.erase(it);
@@ -871,6 +871,7 @@ ImGuiEx::NodeConnectData ImGuiEx::NodeCanvas::AddNodePin( const int nodeID, cons
871871
if( curNodeData.zoomName != ImGuiExNodeZoom_Invisible ){
872872
nodeDrawList->AddCircleFilled(inletPinsPositions[nodeID][pinID], pinSpace * .5f, _color, 6);
873873

874+
// Interactivity
874875
if(ImGui::GetMousePos().x > inletPinsPositions[nodeID][pinID].x-(pinLayout.pinSpace.x*.5f) && ImGui::GetMousePos().x < inletPinsPositions[nodeID][pinID].x+(pinLayout.pinSpace.x*.5f) && ImGui::GetMousePos().y > inletPinsPositions[nodeID][pinID].y-(pinLayout.pinSpace.y*.5f) && ImGui::GetMousePos().y < inletPinsPositions[nodeID][pinID].y+(pinLayout.pinSpace.y*.5f)){
875876
if(activePinType == _type || activePinType == ""){
876877
nodeDrawList->AddCircle(inletPinsPositions[nodeID][pinID],pinSpace * 0.9f, _color, 6);
@@ -881,6 +882,7 @@ ImGuiEx::NodeConnectData ImGuiEx::NodeCanvas::AddNodePin( const int nodeID, cons
881882

882883
}
883884

885+
// Draw Connected Appearance
884886
if(_connected){
885887
nodeDrawList->AddCircle(inletPinsPositions[nodeID][pinID],pinSpace * 0.9f, _color, 6);
886888
}
@@ -920,7 +922,7 @@ ImGuiEx::NodeConnectData ImGuiEx::NodeCanvas::AddNodePin( const int nodeID, cons
920922
_tempColor = IM_COL32(255,0,0,255);
921923
}
922924

923-
canvasDrawList->AddBezierCurve(link_data.bezier.p0, link_data.bezier.p1, link_data.bezier.p2, link_data.bezier.p3, _tempColor, IMGUI_EX_NODE_LINK_THICKNESS, link_data.num_segments);
925+
canvasDrawList->AddBezierCubic(link_data.bezier.p0, link_data.bezier.p1, link_data.bezier.p2, link_data.bezier.p3, _tempColor, IMGUI_EX_NODE_LINK_THICKNESS, link_data.num_segments);
924926
}
925927

926928
// Draw pin
@@ -961,7 +963,7 @@ ImGuiEx::NodeConnectData ImGuiEx::NodeCanvas::AddNodePin( const int nodeID, cons
961963
}
962964

963965
// remove link if drag from connected inlet and drop on canvas
964-
if(ImGui::GetIO().MouseReleased[0] && !ImGui::IsAnyItemHovered() && !ImGui::IsAnyItemActive() && !ImGui::IsAnyItemFocused() && !ImGui::IsAnyWindowHovered() && connectType == 2){
966+
if(ImGui::GetIO().MouseReleased[0] && !ImGui::IsAnyItemHovered() && !ImGui::IsAnyItemActive() && !ImGui::IsAnyItemFocused() && !ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow) && connectType == 2){
965967
connectData.connectType = 3;
966968
connectData.linkID = linkID;
967969

src/core/imgui_plot.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ void VUMeter(ImDrawList* drawList, float width, float height,float _vol, bool ho
368368

369369
if(horizontal){
370370
// prepare canvas
371-
const float dim = width > 0 ? width : ImGui::GetContentRegionAvailWidth();
371+
const float dim = width > 0 ? width : ImGui::GetContentRegionAvail().x;
372372
ImVec2 Canvas(dim, height);
373373

374374
ImRect bb(Window->DC.CursorPos, Window->DC.CursorPos + Canvas);
@@ -413,15 +413,15 @@ void PlotBands(ImDrawList* drawList, float width, float height, std::vector<floa
413413
ImGuiWindow* Window = ImGui::GetCurrentWindow();
414414

415415
// prepare canvas
416-
const float dim = width > 0 ? width : ImGui::GetContentRegionAvailWidth();
416+
const float dim = width > 0 ? width : ImGui::GetContentRegionAvail().x;
417417
ImVec2 Canvas(dim, height);
418418

419419
ImRect bb(Window->DC.CursorPos, Window->DC.CursorPos + Canvas);
420420
ImGui::ItemSize(bb);
421421

422422
float bin_w = Canvas.x / data->size();
423423

424-
for(int i=0;i<data->size();i++){
424+
for(unsigned int i=0;i<data->size();i++){
425425
drawList->AddRect(ImVec2( bb.Min.x + (bin_w*i), bb.Min.y+(Canvas.y*(max-data->at(i)) )),ImVec2(bb.Min.x + (bin_w*i) + bin_w, bb.Max.y),color);
426426
}
427427

src/ofxVisualProgramming.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,15 @@ void ofxVisualProgramming::setup(ofxImGui::Gui* _guiRef, string release){
135135
ofxVPGui = _guiRef;
136136
// Dummy call to IO which will crash if _guiRef is not initialised.
137137
ImGui::GetIO();
138-
//ImGui::SetCurrentContext();
138+
// Ensure ImGui gets loaded correctly
139+
if(ImGui::GetCurrentContext()==nullptr || !ImGui::GetCurrentContext()->Initialized){
140+
ofxVPGui->setup();
141+
}
142+
// Manually force shared mode
143+
else {
144+
ofxVPGui->setSharedMode(true);
145+
}
146+
139147
//ofLogError("ofxVP") << "Setting up ImGui from reference instance." << (ImGui::GetCurrentContext()->Initialized?'1':'0');
140148
}
141149

0 commit comments

Comments
 (0)