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 {
22 };
31
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:
39 RibbonIcons();
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;
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
auto width(const Box< V > &box)
returns size along x axis
Definition MRBox.h:354
HashMap< std::string, SizedIcons > map
Definition MRRibbonIcons.h:80
AvailableColor availableColor
Definition MRRibbonIcons.h:79
IconType
Definition MRRibbonIcons.h:24
std::pair< Sizes, Sizes > minMaxSizes
first - min size, second - max size
Definition MRRibbonIcons.h:78
static 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
static void load()
this should be called once on start of program (called in RibbonMenu::init)
std::unique_ptr< ImGuiImage > white
Definition MRRibbonIcons.h:47
static void free()
this should be called once before program stops (called in RibbonMenu::shutdown)
AvailableColor
Definition MRRibbonIcons.h:70
std::filesystem::path pathDirectory
Definition MRRibbonIcons.h:76
ColorType
Definition MRRibbonIcons.h:19
std::unique_ptr< ImGuiImage > colored
Definition MRRibbonIcons.h:46
phmap::flat_hash_map< K, V, Hash, Eq > HashMap
Definition MRMeshFwd.h:606
@ Logos
have two sizes
Definition MRRibbonIcons.h:28
@ RibbonItemIcon
Definition MRRibbonIcons.h:25
@ IndependentIcons
have two sizes
Definition MRRibbonIcons.h:27
@ Count
have two sizes
Definition MRRibbonIcons.h:29
@ ObjectTypeIcon
have four sizes
Definition MRRibbonIcons.h:26
@ Colored
Definition MRRibbonIcons.h:72
@ White
Definition MRRibbonIcons.h:71
@ Colored
Definition MRRibbonIcons.h:20
@ White
Definition MRRibbonIcons.h:21
only for bindings generation
Definition MRCameraOrientationPlugin.h:8