Skip to content

Commit 1fc49c6

Browse files
committed
run make udpate
1 parent 4836dd8 commit 1fc49c6

Some content is hidden

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

57 files changed

+86126
-2
lines changed

cwrappers/ImGuizmo/GraphEditor.cpp

Lines changed: 1111 additions & 0 deletions
Large diffs are not rendered by default.

cwrappers/ImGuizmo/GraphEditor.h

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
// https://github.com/CedricGuillemet/ImGuizmo
2+
// v1.91.3 WIP
3+
//
4+
// The MIT License(MIT)
5+
//
6+
// Copyright(c) 2021 Cedric Guillemet
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files(the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions :
14+
//
15+
// The above copyright notice and this permission notice shall be included in all
16+
// copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
// SOFTWARE.
25+
//
26+
#pragma once
27+
28+
#include <vector>
29+
#include <stdint.h>
30+
#include <string>
31+
#include "imgui.h"
32+
#include "imgui_internal.h"
33+
34+
namespace GraphEditor {
35+
36+
typedef size_t NodeIndex;
37+
typedef size_t SlotIndex;
38+
typedef size_t LinkIndex;
39+
typedef size_t TemplateIndex;
40+
41+
// Force the view to be respositionned and zoom to fit nodes with Show function.
42+
// Parameter value will be changed to Fit_None by the function.
43+
enum FitOnScreen
44+
{
45+
Fit_None,
46+
Fit_AllNodes,
47+
Fit_SelectedNodes
48+
};
49+
50+
// Display options and colors
51+
struct Options
52+
{
53+
ImRect mMinimap{{0.75f, 0.8f, 0.99f, 0.99f}}; // rectangle coordinates of minimap
54+
ImU32 mBackgroundColor{ IM_COL32(40, 40, 40, 255) }; // full background color
55+
ImU32 mGridColor{ IM_COL32(0, 0, 0, 60) }; // grid lines color
56+
ImU32 mGridColor2{ IM_COL32(0, 0, 0, 160) }; // grid lines color every 10th
57+
ImU32 mSelectedNodeBorderColor{ IM_COL32(255, 130, 30, 255) }; // node border color when it's selected
58+
ImU32 mNodeBorderColor{ IM_COL32(100, 100, 100, 0) }; // node border color when it's not selected
59+
ImU32 mQuadSelection{ IM_COL32(255, 32, 32, 64) }; // quad selection inside color
60+
ImU32 mQuadSelectionBorder{ IM_COL32(255, 32, 32, 255) }; // quad selection border color
61+
ImU32 mDefaultSlotColor{ IM_COL32(128, 128, 128, 255) }; // when no color is provided in node template, use this value
62+
ImU32 mFrameFocus{ IM_COL32(64, 128, 255, 255) }; // rectangle border when graph editor has focus
63+
float mLineThickness{ 5 }; // links width in pixels when zoom value is 1
64+
float mGridSize{ 64.f }; // background grid size in pixels when zoom value is 1
65+
float mRounding{ 3.f }; // rounding at node corners
66+
float mZoomRatio{ 0.1f }; // factor per mouse wheel delta
67+
float mZoomLerpFactor{ 0.25f }; // the smaller, the smoother
68+
float mBorderSelectionThickness{ 6.f }; // thickness of selection border around nodes
69+
float mBorderThickness{ 6.f }; // thickness of selection border around nodes
70+
float mNodeSlotRadius{ 8.f }; // circle radius for inputs and outputs
71+
float mNodeSlotHoverFactor{ 1.2f }; // increase size when hovering
72+
float mMinZoom{ 0.2f }, mMaxZoom { 1.1f };
73+
float mSnap{ 5.f };
74+
bool mDisplayLinksAsCurves{ true }; // false is straight and 45deg lines
75+
bool mAllowQuadSelection{ true }; // multiple selection using drag and drop
76+
bool mRenderGrid{ true }; // grid or nothing
77+
bool mDrawIONameOnHover{ true }; // only draw node input/output when hovering
78+
};
79+
80+
// View state: scroll position and zoom factor
81+
struct ViewState
82+
{
83+
ImVec2 mPosition{0.0f, 0.0f}; // scroll position
84+
float mFactor{ 1.0f }; // current zoom factor
85+
float mFactorTarget{ 1.0f }; // targeted zoom factor interpolated using Options.mZoomLerpFactor
86+
};
87+
88+
struct Template
89+
{
90+
ImU32 mHeaderColor;
91+
ImU32 mBackgroundColor;
92+
ImU32 mBackgroundColorOver;
93+
ImU8 mInputCount;
94+
const char** mInputNames; // can be nullptr. No text displayed.
95+
ImU32* mInputColors; // can be nullptr, default slot color will be used.
96+
ImU8 mOutputCount;
97+
const char** mOutputNames; // can be nullptr. No text displayed.
98+
ImU32* mOutputColors; // can be nullptr, default slot color will be used.
99+
};
100+
101+
struct Node
102+
{
103+
const char* mName;
104+
TemplateIndex mTemplateIndex;
105+
ImRect mRect;
106+
bool mSelected{ false };
107+
};
108+
109+
struct Link
110+
{
111+
NodeIndex mInputNodeIndex;
112+
SlotIndex mInputSlotIndex;
113+
NodeIndex mOutputNodeIndex;
114+
SlotIndex mOutputSlotIndex;
115+
};
116+
117+
struct Delegate
118+
{
119+
virtual bool AllowedLink(NodeIndex from, NodeIndex to) = 0;
120+
121+
virtual void SelectNode(NodeIndex nodeIndex, bool selected) = 0;
122+
virtual void MoveSelectedNodes(const ImVec2 delta) = 0;
123+
124+
virtual void AddLink(NodeIndex inputNodeIndex, SlotIndex inputSlotIndex, NodeIndex outputNodeIndex, SlotIndex outputSlotIndex) = 0;
125+
virtual void DelLink(LinkIndex linkIndex) = 0;
126+
127+
// user is responsible for clipping
128+
virtual void CustomDraw(ImDrawList* drawList, ImRect rectangle, NodeIndex nodeIndex) = 0;
129+
130+
// use mouse position to open context menu
131+
// if nodeIndex != -1, right click happens on the specified node
132+
virtual void RightClick(NodeIndex nodeIndex, SlotIndex slotIndexInput, SlotIndex slotIndexOutput) = 0;
133+
134+
virtual const size_t GetTemplateCount() = 0;
135+
virtual const Template GetTemplate(TemplateIndex index) = 0;
136+
137+
virtual const size_t GetNodeCount() = 0;
138+
virtual const Node GetNode(NodeIndex index) = 0;
139+
140+
virtual const size_t GetLinkCount() = 0;
141+
virtual const Link GetLink(LinkIndex index) = 0;
142+
143+
virtual ~Delegate() = default;
144+
};
145+
146+
void Show(Delegate& delegate, const Options& options, ViewState& viewState, bool enabled, FitOnScreen* fit = nullptr);
147+
void GraphEditorClear();
148+
149+
bool EditOptions(Options& options);
150+
151+
} // namespace

0 commit comments

Comments
 (0)