MeshLib C++ Docs
Loading...
Searching...
No Matches
MRRibbonIcons.h
Go to the documentation of this file.
1#pragma once
3#include "MRMesh/MRphmap.h"
5#include "MRViewerFwd.h"
6#include <array>
7#include <filesystem>
8
9namespace MR
10{
13
14
16class MRVIEWER_CLASS RibbonIcons
17{
18public:
19 enum class ColorType
20 {
23 };
32
35 MRVIEWER_API static void load();
37 MRVIEWER_API static void free();
39 MRVIEWER_API static const ImGuiImage* findByName( const std::string& name, float width,
40 ColorType colorType, IconType iconType );
41private:
42 RibbonIcons();
43 ~RibbonIcons() = default;
44
45 static RibbonIcons& instance_();
46
47 struct Icons
48 {
49 std::unique_ptr<ImGuiImage> colored;
50 std::unique_ptr<ImGuiImage> white;
51 };
52
53 enum class Sizes
54 {
55 X0_5,
56 X0_75,
57 X1,
58 X3,
59 Count,
60 };
61
62 using SizedIcons = std::array<Icons, size_t( Sizes::Count )>;
63
64 static const char* sizeSubFolder_( Sizes sz );
65
66 const ImGuiImage* findRequiredSize_( const SizedIcons& icons, float width, ColorType colorType, IconType iconType ) const;
67
68 void load_( IconType type );
70 bool loadZips_();
71
72 struct IconTypeData;
74 struct Textures
75 {
77 };
78 static Textures makeTextures_( const IconTypeData& data, int sz, Image&& image );
79 static void addIcon_( IconTypeData& data, int sz, const std::string& name, Textures&& textures );
80
81 struct IconTypeData
82 {
83 enum class AvailableColor
84 {
85 White = 1 << 0,
86 Colored = 1 << 1,
87 };
88 MR_MAKE_FLAG_OPERATORS_IN_CLASS( AvailableColor )
89
90 std::filesystem::path pathDirectory;
92 std::pair<Sizes, Sizes> minMaxSizes;
94 HashMap<std::string, SizedIcons> map;
95 bool loaded = false;
96 };
97
98 std::array<IconTypeData, size_t( IconType::Count )> data_;
99 bool zipTried_ = false;
100};
101
102}
#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:386
HashMap< std::string, SizedIcons > map
Definition MRRibbonIcons.h:94
AvailableColor availableColor
Definition MRRibbonIcons.h:93
MeshTexture white
Definition MRRibbonIcons.h:76
MeshTexture colored
Definition MRRibbonIcons.h:76
IconType
Definition MRRibbonIcons.h:25
std::pair< Sizes, Sizes > minMaxSizes
first - min size, second - max size
Definition MRRibbonIcons.h:92
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()
std::unique_ptr< ImGuiImage > white
Definition MRRibbonIcons.h:50
static void free()
this should be called once before program stops (called in RibbonMenu::shutdown)
AvailableColor
Definition MRRibbonIcons.h:84
std::filesystem::path pathDirectory
Definition MRRibbonIcons.h:90
phmap::flat_hash_map< K, V, Hash, Eq, Allocator< std::pair< const K, V > > > HashMap
Definition MRMeshFwd.h:632
ColorType
Definition MRRibbonIcons.h:20
bool loaded
Definition MRRibbonIcons.h:95
std::unique_ptr< ImGuiImage > colored
Definition MRRibbonIcons.h:49
@ Logos
have two sizes
Definition MRRibbonIcons.h:29
@ RibbonItemIcon
Definition MRRibbonIcons.h:26
@ IndependentIcons
have two sizes
Definition MRRibbonIcons.h:28
@ Count
have two sizes, loaded lazily on first request
Definition MRRibbonIcons.h:30
@ ObjectTypeIcon
have four sizes
Definition MRRibbonIcons.h:27
@ Colored
Definition MRRibbonIcons.h:86
@ White
Definition MRRibbonIcons.h:85
@ Colored
Definition MRRibbonIcons.h:21
@ White
Definition MRRibbonIcons.h:22
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRImage.h:19
Definition MRMeshTexture.h:13