MeshLib Documentation
Loading...
Searching...
No Matches
MRToolbar.h
Go to the documentation of this file.
1#pragma once
2#include "MRMesh/MRMeshFwd.h"
3#include "MRMesh/MRColor.h"
4#include "MRPch/MRJson.h"
5#include "exports.h"
6
7namespace MR
8{
9using MenuItemsList = std::vector<std::string>;
10using MenuItemsListMigration = std::function<void ( MenuItemsList& )>;
11using MenuItemsListMigrations = std::map<int, MenuItemsListMigration>;
12
13class RibbonMenu;
14
16class MRVIEWER_CLASS Toolbar
17{
18public:
20 MRVIEWER_API void setRibbonMenu( RibbonMenu* ribbonMenu );
21
24 MRVIEWER_API void drawToolbar();
27 MRVIEWER_API float getCurrentToolbarWidth() const { return currentWidth_; }
28 // enable toolbar customize window rendering
29 MRVIEWER_API void openCustomize();
32 MRVIEWER_API void drawCustomize();
33
35 MRVIEWER_API void readItemsList( const Json::Value& root );
38 MRVIEWER_API void resetItemsList();
40 MRVIEWER_API const MenuItemsList& getItemsList() const { return itemsList_; }
42 MRVIEWER_API int getItemsListVersion() const { return itemsListVersion_; }
44 MRVIEWER_API void setItemsListVersion( int version ) { itemsListVersion_ = version; }
46 MRVIEWER_API void setItemsListMigrations( const MenuItemsListMigrations& migrations ) { itemsListMigrations_ = migrations; }
47
48 MRVIEWER_API void setScaling( float scale ) { scaling_ = scale; }
49
50private:
52 void drawCustomizeModal_();
54 void drawCustomizeTabsList_();
56 void drawCustomizeItemsList_();
57
58 void dashedLine_( const Vector2f& org, const Vector2f& dest, float periodLength = 10.f, float fillRatio = 0.5f, const Color& color = Color::gray(), float periodStart = 0.f );
59 void dashedRect_( const Vector2f& leftTop, const Vector2f& rightBottom, float periodLength = 10.f, float fillRatio = 0.5f, const Color& color = Color::gray() );
60
61 RibbonMenu* ribbonMenu_;
62
63 float scaling_ = 1.f;
64
65 MenuItemsList itemsList_; // toolbar items list
66 MenuItemsList itemsListCustomize_; // toolbar preview items list for Toolbar Customize window
67 int itemsListVersion_{ 1 }; // items list version
68 MenuItemsListMigrations itemsListMigrations_; // items list's upgrade rules
69
70 float currentWidth_{ 0.0f };
71 bool dragDrop_ = false; // active drag&drop in Toolbar Customize window
72 bool openCustomizeFlag_ = false; // flag to open Toolbar Customize window
73 int customizeTabNum_ = 0; // number active tab
74 std::string searchString_;
75 std::vector<std::vector<std::string>> searchResult_;
76};
77
78}
Definition MRRibbonMenu.h:32
class to draw toolbar and toolbar customize windows
Definition MRToolbar.h:17
MRVIEWER_API int getItemsListVersion() const
get item list version
Definition MRToolbar.h:42
MRVIEWER_API void readItemsList(const Json::Value &root)
read toolbar items from json
MRVIEWER_API void drawToolbar()
MRVIEWER_API void setItemsListMigrations(const MenuItemsListMigrations &migrations)
set item list's upgrade rules
Definition MRToolbar.h:46
MRVIEWER_API void openCustomize()
MRVIEWER_API void setRibbonMenu(RibbonMenu *ribbonMenu)
set pointer on ribbon menu to access it
MRVIEWER_API const MenuItemsList & getItemsList() const
get acces to items
Definition MRToolbar.h:40
MRVIEWER_API void setScaling(float scale)
Definition MRToolbar.h:48
MRVIEWER_API void drawCustomize()
MRVIEWER_API void setItemsListVersion(int version)
set item list version
Definition MRToolbar.h:44
MRVIEWER_API float getCurrentToolbarWidth() const
Definition MRToolbar.h:27
MRVIEWER_API void resetItemsList()
Definition MRCameraOrientationPlugin.h:8
std::function< void(MenuItemsList &)> MenuItemsListMigration
Definition MRToolbar.h:10
std::vector< std::string > MenuItemsList
Definition MRRibbonMenuItem.h:9
std::map< int, MenuItemsListMigration > MenuItemsListMigrations
Definition MRToolbar.h:11
Definition MRColor.h:9