MeshLib C++ Docs
Loading...
Searching...
No Matches
MRRibbonIcons.h
Go to the documentation of this file.
1#pragma once
3#include "MRMesh/MRphmap.h"
4#include "MRViewerFwd.h"
5#include <array>
6#include <filesystem>
7
8namespace MR
9{
12
13
15class MRVIEWER_CLASS RibbonIcons
16{
17public:
18 enum class ColorType
19 {
20 Colored,
21 White,
22 };
23 enum class IconType
24 {
25 RibbonItemIcon,
26 ObjectTypeIcon,
27 IndependentIcons,
28 Logos,
29 Count,
30 };
32 MRVIEWER_API static void load();
34 MRVIEWER_API static void free();
36 MRVIEWER_API static const ImGuiImage* findByName( const std::string& name, float width,
37 ColorType colorType, IconType iconType );
38private:
40 ~RibbonIcons() = default;
41
42 static RibbonIcons& instance_();
43
44 struct Icons
45 {
46 std::unique_ptr<ImGuiImage> colored;
47 std::unique_ptr<ImGuiImage> white;
48 };
49
50 enum class Sizes
51 {
52 X0_5,
53 X0_75,
54 X1,
55 X3,
56 Count,
57 };
58
59 using SizedIcons = std::array<Icons, size_t( Sizes::Count )>;
60
61 static const char* sizeSubFolder_( Sizes sz );
62
63 const ImGuiImage* findRequiredSize_( const SizedIcons& icons, float width, ColorType colorType, IconType iconType ) const;
64
65 void load_( IconType type );
66
67 struct IconTypeData
68 {
69 enum class AvailableColor
70 {
71 White = 1 << 0,
72 Colored = 1 << 1,
73 };
74 MR_MAKE_FLAG_OPERATORS_IN_CLASS( AvailableColor )
75
76 std::filesystem::path pathDirectory;
78 std::pair<Sizes, Sizes> minMaxSizes;
79 AvailableColor availableColor = AvailableColor::White;
80 HashMap<std::string, SizedIcons> map;
81 };
82
83 std::array<IconTypeData, size_t( IconType::Count )> data_;
84};
85
86}
#define MR_MAKE_FLAG_OPERATORS_IN_CLASS(T)
Generates operators for a enum (at class scope).
Definition MRFlagOperators.h:9
Definition MRImGuiImage.h:18
this class holds icons for ribbon items
Definition MRRibbonIcons.h:16
IconType
Definition MRRibbonIcons.h:24
std::unique_ptr< ImGuiImage > white
Definition MRRibbonIcons.h:47
static MRVIEWER_API const ImGuiImage * findByName(const std::string &name, float width, ColorType colorType, IconType iconType)
finds icon with best fitting size, if there is no returns nullptr
AvailableColor
Definition MRRibbonIcons.h:70
static MRVIEWER_API void load()
this should be called once on start of program (called in RibbonMenu::init)
ColorType
Definition MRRibbonIcons.h:19
std::unique_ptr< ImGuiImage > colored
Definition MRRibbonIcons.h:46
static MRVIEWER_API void free()
this should be called once before program stops (called in RibbonMenu::shutdown)
only for bindings generation
Definition MRCameraOrientationPlugin.h:8