MeshLib Documentation
Loading...
Searching...
No Matches
MRRibbonMenuItem.h
Go to the documentation of this file.
1
#pragma once
2
#include "
MRISceneStateCheck.h
"
3
#include <string>
4
#include <memory>
5
6
namespace
MR
7
{
8
9
using
MenuItemsList
= std::vector<std::string>;
10
11
enum class
RibbonItemType
12
{
13
Button
,
14
ButtonWithDrop
15
};
16
17
// class to hold menu items
18
// some information stored in json (icons path, tab name, subtab name)
19
class
RibbonMenuItem
:
virtual
public
ISceneStateCheck
20
{
21
public
:
22
MR_DELETE_MOVE
(
RibbonMenuItem
);
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
42
void
setRibbonItemType
(
RibbonItemType
type
) {
type_
=
type
; }
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
60
protected
:
61
RibbonItemType
type_
{
RibbonItemType::Button
};
62
DropItemsList
dropList_
;
63
64
private
:
65
std::string name_;
// key to find in holder and json
66
};
67
68
}
// namespace MR
MRISceneStateCheck.h
MR::ISceneStateCheck
Definition
MRISceneStateCheck.h:14
MR::RibbonMenuItem
Definition
MRRibbonMenuItem.h:20
MR::RibbonMenuItem::type_
RibbonItemType type_
Definition
MRRibbonMenuItem.h:61
MR::RibbonMenuItem::dropItems
virtual const DropItemsList & dropItems() const
Definition
MRRibbonMenuItem.h:55
MR::RibbonMenuItem::type
virtual RibbonItemType type() const
Definition
MRRibbonMenuItem.h:45
MR::RibbonMenuItem::dropList_
DropItemsList dropList_
Definition
MRRibbonMenuItem.h:62
MR::RibbonMenuItem::uiName
virtual const std::string & uiName() const
Definition
MRRibbonMenuItem.h:40
MR::RibbonMenuItem::isActive
virtual bool isActive() const
Definition
MRRibbonMenuItem.h:31
MR::RibbonMenuItem::DropItemsList
std::vector< std::shared_ptr< RibbonMenuItem > > DropItemsList
Definition
MRRibbonMenuItem.h:47
MR::RibbonMenuItem::action
virtual bool action()=0
MR::RibbonMenuItem::getDynamicTooltip
virtual std::string getDynamicTooltip() const
Definition
MRRibbonMenuItem.h:58
MR::RibbonMenuItem::MR_DELETE_MOVE
MR_DELETE_MOVE(RibbonMenuItem)
MR::RibbonMenuItem::setRibbonItemType
void setRibbonItemType(RibbonItemType type)
Definition
MRRibbonMenuItem.h:42
MR::RibbonMenuItem::name
const std::string & name() const
Definition
MRRibbonMenuItem.h:35
MR::RibbonMenuItem::~RibbonMenuItem
virtual ~RibbonMenuItem()=default
MR::RibbonMenuItem::blocking
virtual bool blocking() const
Definition
MRRibbonMenuItem.h:33
MR::RibbonMenuItem::RibbonMenuItem
MRVIEWER_API RibbonMenuItem(std::string name)
MR::RibbonMenuItem::setDropItemsFromItemList
MRVIEWER_API void setDropItemsFromItemList(const MenuItemsList &itemsList)
MR
Definition
MRCameraOrientationPlugin.h:8
MR::RibbonItemType
RibbonItemType
Definition
MRRibbonMenuItem.h:12
MR::RibbonItemType::ButtonWithDrop
@ ButtonWithDrop
MR::RibbonItemType::Button
@ Button
MR::MenuItemsList
std::vector< std::string > MenuItemsList
Definition
MRRibbonMenuItem.h:9
MeshLib
source
MRViewer
MRRibbonMenuItem.h
Generated by
1.11.0