MeshLib
 
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{
10
11// this class holds icons for ribbon items
12class MRVIEWER_CLASS RibbonIcons
13{
14public:
15 enum class ColorType
16 {
17 Colored,
18 White,
19 };
20 enum class IconType
21 {
22 RibbonItemIcon, // have four sizes
23 ObjectTypeIcon, // have two sizes
24 IndependentIcons, // have two sizes
25 Logos, // have two sizes
26 Count,
27 };
28 // this should be called once on start of program (called in RibbonMenu::init)
29 MRVIEWER_API static void load();
30 // this should be called once before program stops (called in RibbonMenu::shutdown)
31 MRVIEWER_API static void free();
32 // finds icon with best fitting size, if there is no returns nullptr
33 MRVIEWER_API static const ImGuiImage* findByName( const std::string& name, float width,
34 ColorType colorType, IconType iconType );
35private:
37 ~RibbonIcons() = default;
38
39 static RibbonIcons& instance_();
40
41 struct Icons
42 {
43 std::unique_ptr<ImGuiImage> colored;
44 std::unique_ptr<ImGuiImage> white;
45 };
46
47 enum class Sizes
48 {
49 X0_5,
50 X0_75,
51 X1,
52 X3,
53 Count,
54 };
55
56 using SizedIcons = std::array<Icons, size_t( Sizes::Count )>;
57
58 static const char* sizeSubFolder_( Sizes sz );
59
60 const ImGuiImage* findRequiredSize_( const SizedIcons& icons, float width, ColorType colorType, IconType iconType ) const;
61
62 void load_( IconType type );
63
64 struct IconTypeData
65 {
66 enum class AvailableColor
67 {
68 White = 1 << 0,
69 Colored = 1 << 1,
70 };
71 MR_MAKE_FLAG_OPERATORS_IN_CLASS( AvailableColor )
72
73 std::filesystem::path pathDirectory;
74 // first - min size, second - max size
75 std::pair<Sizes, Sizes> minMaxSizes;
76 AvailableColor availableColor = AvailableColor::White;
77 HashMap<std::string, SizedIcons> map;
78 };
79
80 std::array<IconTypeData, size_t( IconType::Count )> data_;
81};
82
83}
#define MR_MAKE_FLAG_OPERATORS_IN_CLASS(T)
Definition MRFlagOperators.h:9
Definition MRImGuiImage.h:14
Definition MRRibbonIcons.h:13
IconType
Definition MRRibbonIcons.h:21
static MRVIEWER_API const ImGuiImage * findByName(const std::string &name, float width, ColorType colorType, IconType iconType)
static MRVIEWER_API void load()
ColorType
Definition MRRibbonIcons.h:16
static MRVIEWER_API void free()
Definition MRCameraOrientationPlugin.h:7