MeshLib Documentation
Loading...
Searching...
No Matches
MRRibbonMenuItem.h
Go to the documentation of this file.
1#pragma once
3#include <string>
4#include <memory>
5
6namespace MR
7{
8
9using MenuItemsList = std::vector<std::string>;
10
12{
13 Button,
15};
16
17// class to hold menu items
18// some information stored in json (icons path, tab name, subtab name)
19class RibbonMenuItem : virtual public ISceneStateCheck
20{
21public:
23
24 MRVIEWER_API RibbonMenuItem( std::string name );
25
26 virtual ~RibbonMenuItem() = default;
27
28 // returns true if state of item changed
29 virtual bool action() = 0;
30 // for state items returns true if activated
31 virtual bool isActive() const { return false; }
32 // true if this item is blocking (only one blocking item can be active at once)
33 virtual bool blocking() const { return false; }
34
35 const std::string& name() const { return name_; }
36
37 // can be overridden by some plugins with ui
38 // it is used for highlighting active and closing plugins by Esc key
39 // note that it is not RibbonSchema caption
40 virtual const std::string& uiName() const { return name_; }
41
43
44 // type of this item, base RibbonMenuItem can be only button
45 virtual RibbonItemType type() const { return type_; }
46
47 using DropItemsList = std::vector<std::shared_ptr<RibbonMenuItem>>;
48
49 // set drop list by found in RibbonSchema items
50 // !note also set type_ to ButtonWithDrop
51 MRVIEWER_API void setDropItemsFromItemList( const MenuItemsList& itemsList );
52
53 // returns list of stored ribbon items to drop
54 // !note that this function can be called each frame for opened drop list
55 virtual const DropItemsList& dropItems() const { return dropList_; }
56
57 // return not-empty string with tooltip that shall replace the static tooltip from json
58 virtual std::string getDynamicTooltip() const { return {}; }
59
60protected:
63
64private:
65 std::string name_; // key to find in holder and json
66};
67
68} // namespace MR
Definition MRISceneStateCheck.h:14
Definition MRRibbonMenuItem.h:20
RibbonItemType type_
Definition MRRibbonMenuItem.h:61
virtual const DropItemsList & dropItems() const
Definition MRRibbonMenuItem.h:55
virtual RibbonItemType type() const
Definition MRRibbonMenuItem.h:45
DropItemsList dropList_
Definition MRRibbonMenuItem.h:62
virtual const std::string & uiName() const
Definition MRRibbonMenuItem.h:40
virtual bool isActive() const
Definition MRRibbonMenuItem.h:31
std::vector< std::shared_ptr< RibbonMenuItem > > DropItemsList
Definition MRRibbonMenuItem.h:47
virtual bool action()=0
virtual std::string getDynamicTooltip() const
Definition MRRibbonMenuItem.h:58
MR_DELETE_MOVE(RibbonMenuItem)
void setRibbonItemType(RibbonItemType type)
Definition MRRibbonMenuItem.h:42
const std::string & name() const
Definition MRRibbonMenuItem.h:35
virtual ~RibbonMenuItem()=default
virtual bool blocking() const
Definition MRRibbonMenuItem.h:33
MRVIEWER_API RibbonMenuItem(std::string name)
MRVIEWER_API void setDropItemsFromItemList(const MenuItemsList &itemsList)
Definition MRCameraOrientationPlugin.h:8
RibbonItemType
Definition MRRibbonMenuItem.h:12
std::vector< std::string > MenuItemsList
Definition MRRibbonMenuItem.h:9