MeshLib C++ Docs
Loading...
Searching...
No Matches
MRSceneObjectsListDrawer.h
Go to the documentation of this file.
1#pragma once
2
3#include "exports.h"
4#include "MRSceneReorder.h"
5#include <memory>
6#include <string>
7#include <unordered_map>
8
9namespace MR
10{
13
14
15class Object;
16
18class MRVIEWER_CLASS SceneObjectsListDrawer
19{
20public:
21 virtual ~SceneObjectsListDrawer() = default;
22
25 MRVIEWER_API virtual void draw( float height );
26
28 void setShowNewSelectedObjects( bool show ) { showNewSelectedObjects_ = show; };
30 bool getShowNewSelectedObjects() { return showNewSelectedObjects_; };
31
33 void setDeselectNewHiddenObjects( bool deselect ) { deselectNewHiddenObjects_ = deselect; }
35 bool getDeselectNewHiddenObjects() { return deselectNewHiddenObjects_; }
36
40 MRVIEWER_API void changeSelection( bool isDown, bool isShift );
43 MRVIEWER_API void changeVisible( bool isDown );
44
46 MRVIEWER_API void selectAllObjects();
47
49 MRVIEWER_API void setLeavesVisibility( bool visible );
50
52 MRVIEWER_API void setObjectTreeState( const Object* obj, bool open );
53
55 MRVIEWER_API void expandObjectTreeAndScroll( const Object* obj );
56
58 MRVIEWER_API void allowSceneReorder( bool allow );
59
61 MRVIEWER_API void setNextFrameFixScroll( int skipFrames = 1 );
62protected:
66 MRVIEWER_API virtual void drawCustomObjectPrefixInScene_( const Object&, bool )
67 {}
70 MRVIEWER_API virtual void drawSceneContextMenu_( const std::vector<std::shared_ptr<Object>>& , const std::string& )
71 {}
72
76 MRVIEWER_API virtual float drawCustomTreeObjectProperties_( Object& obj, bool onlyCalcHeight );
77
78 typedef int ImGuiTreeNodeFlags;
80 MRVIEWER_API virtual bool collapsingHeader_( const std::string& uniqueName, ImGuiTreeNodeFlags flags );
81
82 MRVIEWER_API virtual std::string objectLineStrId_( const Object& object, const std::string& uniqueStr );
83
85 MRVIEWER_API virtual bool drawObject_( Object& object, const std::string& uniqueStr, int depth );
87 MRVIEWER_API virtual bool drawSkippedObject_( Object& object, const std::string& uniqueStr, int depth );
88
90 MRVIEWER_API bool drawObjectCollapsingHeader_( Object& object, const std::string& uniqueStr, bool hasRealChildren );
91
93 MRVIEWER_API void processItemClick_( Object& object, const std::vector<std::shared_ptr<Object>>& selected );
94
96 MRVIEWER_API void makeDragDropSource_( const std::vector<std::shared_ptr<Object>>& payload );
97
99 MRVIEWER_API bool needDragDropTarget_();
100
104 MRVIEWER_API void makeDragDropTarget_( Object& target, bool before, bool betweenLine, const std::string& uniqueStr );
105
107 MRVIEWER_API void drawObjectVisibilityCheckbox_( Object& object, const std::string& uniqueStr );
108
109 bool showNewSelectedObjects_ = true;
110 bool deselectNewHiddenObjects_ = false;
111private:
112 void drawObjectsList_();
113
114 float getDrawDropTargetHeight_() const;
115 void reorderSceneIfNeeded_();
116
118 MRVIEWER_API virtual void updateSceneWindowScrollIfNeeded_();
119
120 std::vector<Object*> getPreSelection_( Object* meshclicked,
121 bool isShift, bool isCtrl,
122 const std::vector<std::shared_ptr<Object>>& selected,
123 const std::vector<std::shared_ptr<Object>>& all );
124 void updateSelection_( Object* objPtr, const std::vector<std::shared_ptr<Object>>& selected, const std::vector<std::shared_ptr<Object>>& all );
125
126 bool clickTrigger_ = false;
127 bool allowSceneReorder_ = true;
128
130 struct MoveAndScrollData
131 {
132 int index = -1;
133 float posY = -1.f;
134 bool needScroll = false;
135 };
136 MoveAndScrollData upFirstSelected_;
137 MoveAndScrollData downLastSelected_;
138 MoveAndScrollData nextVisible_;
139
140 SceneReorder sceneReorderCommand_;
143 struct ScrollPositionPreservation
144 {
145 float relativeMousePos{ 0.0f };
146 float absLinePosRatio{ 0.0f };
147 } prevScrollInfo_;
149 int framesTillFixScroll_ = 0;
151 bool dragObjectsMode_{ false };
153 bool dragModeTrigger_{ false };
154
155protected:
156 std::unordered_map<const Object*, bool> sceneOpenCommands_;
157};
158
159constexpr inline int sDefaultGroupState = 0;
160
161}
named object in the data model
Definition MRObject.h:62
class for drawing a list of scene objects (and handling interaction with it)
Definition MRSceneObjectsListDrawer.h:19
MRVIEWER_API void selectAllObjects()
select all selectable objects
virtual MRVIEWER_API float drawCustomTreeObjectProperties_(Object &obj, bool onlyCalcHeight)
MRVIEWER_API void allowSceneReorder(bool allow)
set possibility change object order
MRVIEWER_API void expandObjectTreeAndScroll(const Object *obj)
expands all objs parents in tree and scroll scene tree window so selection becomes visible
MRVIEWER_API void setNextFrameFixScroll(int skipFrames=1)
helper method for fix scroll position after change available height
virtual MRVIEWER_API void drawSceneContextMenu_(const std::vector< std::shared_ptr< Object > > &, const std::string &)
Definition MRSceneObjectsListDrawer.h:70
std::unordered_map< const Object *, bool > sceneOpenCommands_
Definition MRSceneObjectsListDrawer.h:156
MRVIEWER_API void setObjectTreeState(const Object *obj, bool open)
set object collapse state (hiding children)
virtual MRVIEWER_API std::string objectLineStrId_(const Object &object, const std::string &uniqueStr)
virtual MRVIEWER_API void draw(float height)
MRVIEWER_API void setLeavesVisibility(bool visible)
set visible flag all selectable objects
MRVIEWER_API void makeDragDropSource_(const std::vector< std::shared_ptr< Object > > &payload)
payload object will be moved
virtual MRVIEWER_API bool drawSkippedObject_(Object &object, const std::string &uniqueStr, int depth)
draw dummy container for skipped object
void setShowNewSelectedObjects(bool show)
set flag of the object visibility activation after selection
Definition MRSceneObjectsListDrawer.h:28
bool getDeselectNewHiddenObjects()
get flag of deselect object after hidden
Definition MRSceneObjectsListDrawer.h:35
MRVIEWER_API void processItemClick_(Object &object, const std::vector< std::shared_ptr< Object > > &selected)
function that do click logic on object line (select/deselect/rename/open context)
MRVIEWER_API void changeSelection(bool isDown, bool isShift)
virtual MRVIEWER_API bool collapsingHeader_(const std::string &uniqueName, ImGuiTreeNodeFlags flags)
override this to customize CollapsingHeader draw
MRVIEWER_API bool needDragDropTarget_()
checking the need to draw a target
bool getShowNewSelectedObjects()
get flag of the object visibility activation after selection
Definition MRSceneObjectsListDrawer.h:30
MRVIEWER_API void makeDragDropTarget_(Object &target, bool before, bool betweenLine, const std::string &uniqueStr)
void setDeselectNewHiddenObjects(bool deselect)
set flag of deselect object after hidden
Definition MRSceneObjectsListDrawer.h:33
MRVIEWER_API bool drawObjectCollapsingHeader_(Object &object, const std::string &uniqueStr, bool hasRealChildren)
function that draws collapsing header and process click on it
constexpr int sDefaultGroupState
Definition MRSceneObjectsListDrawer.h:159
int ImGuiTreeNodeFlags
Definition MRSceneObjectsListDrawer.h:78
MRVIEWER_API void drawObjectVisibilityCheckbox_(Object &object, const std::string &uniqueStr)
draw visibility checkbox and call ImGui::SameLine at the end
virtual MRVIEWER_API void drawCustomObjectPrefixInScene_(const Object &, bool)
Definition MRSceneObjectsListDrawer.h:66
MRVIEWER_API void changeVisible(bool isDown)
virtual MRVIEWER_API bool drawObject_(Object &object, const std::string &uniqueStr, int depth)
override this to customize whole object line
virtual ~SceneObjectsListDrawer()=default
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRSceneReorder.h:13