MeshLib C++ Docs
Loading...
Searching...
No Matches
MRColorTheme.h
Go to the documentation of this file.
1#pragma once
2#include "exports.h"
3#include "MRMesh/MRColor.h"
4#include "MRMesh/MRSignal.h"
5#include <json/forwards.h>
6#include <filesystem>
7#include <vector>
8#include <array>
9
10namespace MR
11{
14
15
18class ColorTheme
19{
20public:
21 MRVIEWER_API static ColorTheme& instance();
22
23 enum class Preset
24 {
29 };
30 MRVIEWER_API static Preset getPreset();
31 MRVIEWER_API static const char* getPresetName( Preset type );
32
33
34 enum class Type
35 {
38 };
39
40 MRVIEWER_API static Type getThemeType();
41 MRVIEWER_API static const std::string& getThemeName();
42
44 MRVIEWER_API static void setupByTypeName( Type type, const std::string& name );
45 MRVIEWER_API static void setupDefaultDark();
46 MRVIEWER_API static void setupDefaultLight();
47 MRVIEWER_API static void setupUserTheme( const std::string& themeName );
49 MRVIEWER_API static void setupFromFile( const std::filesystem::path& path, Type type = Type::User );
51 MRVIEWER_API static void setupFromJson( const Json::Value& value, Type type = Type::User );
52
56 MRVIEWER_API static void serializeCurrentToFile( const std::filesystem::path& path );
60 MRVIEWER_API static void serializeCurrentToJson( Json::Value& root );
61
63 MRVIEWER_API static bool isInitialized();
64
144
145 MRVIEWER_API static void setRibbonColor( const Color& color, RibbonColorsType type );
146 MRVIEWER_API static const Color& getRibbonColor( RibbonColorsType type );
147 MRVIEWER_API static const char* getRibbonColorTypeName( RibbonColorsType type );
148
158
160 MRVIEWER_API static void setViewportColor( const Color& color, ViewportColorsType type );
161 MRVIEWER_API static const Color& getViewportColor( ViewportColorsType type );
162 MRVIEWER_API static const char* getViewportColorTypeName( ViewportColorsType type );
163
165 MRVIEWER_API static std::filesystem::path getUserThemesDirectory();
166
168 MRVIEWER_API static void updateUserThemesList();
170 MRVIEWER_API static std::vector<std::string> foundUserThemes();
171
173 MRVIEWER_API static void resetImGuiStyle();
174
176 MRVIEWER_API static boost::signals2::connection onChanged( const std::function<void()>& slot, boost::signals2::connect_position position = boost::signals2::at_back );
177
178private:
179 ColorTheme() = default;
180 ~ColorTheme() = default;
181
186 MRVIEWER_API static void apply_( const std::vector<Color>& sceneColors );
187
188 bool isInitialized_ = false;
189 Preset themePreset_ = Preset::Dark;
190 std::array<Color, size_t( RibbonColorsType::Count )> newUIColors_;
191 std::array<Color, size_t( ViewportColorsType::Count )> viewportColors_;
192
193 Type type_{ Type::Default };
194 std::string themeName_;
195
196 std::vector<std::string> foundUserThemes_;
197
198 using ChangedSignal = Signal<void()>;
199 ChangedSignal changedSignal_;
200};
201
202}
ImVec2 position(const ViewportRectangle &rect)
Definition MRViewport.h:27
static void updateUserThemesList()
Find available custom themes.
static boost::signals2::connection onChanged(const std::function< void()> &slot, boost::signals2::connect_position position=boost::signals2::at_back)
Connects given slot to receive signal on every Color Theme change, triggered in apply.
static const char * getRibbonColorTypeName(RibbonColorsType type)
static void setupFromJson(const Json::Value &value, Type type=Type::User)
Setup this struct from Json value.
static std::vector< std::string > foundUserThemes()
Return list of found custom themes.
static void serializeCurrentToFile(const std::filesystem::path &path)
static void setupDefaultLight()
static ColorTheme & instance()
static Type getThemeType()
static Preset getPreset()
static const Color & getRibbonColor(RibbonColorsType type)
static void setViewportColor(const Color &color, ViewportColorsType type)
Getter and setter for viewport colors.
static void setupFromFile(const std::filesystem::path &path, Type type=Type::User)
Setup this struct from serialized color-theme file.
static std::filesystem::path getUserThemesDirectory()
Returns directory where user's custom themes are stored.
static const char * getPresetName(Preset type)
static void resetImGuiStyle()
Reset ImGui style sizes and colors, and apply menu scaling to it.
static bool isInitialized()
True if this structure is filled with colors, false if empty.
ViewportColorsType
Definition MRColorTheme.h:150
static const char * getViewportColorTypeName(ViewportColorsType type)
static void setupDefaultDark()
static void setupByTypeName(Type type, const std::string &name)
Setup this struct.
static const std::string & getThemeName()
Preset
Definition MRColorTheme.h:24
static void setRibbonColor(const Color &color, RibbonColorsType type)
Getter and setter for ribbon colors.
Type
Definition MRColorTheme.h:35
static void serializeCurrentToJson(Json::Value &root)
static const Color & getViewportColor(ViewportColorsType type)
RibbonColorsType
Color types used in ribbon.
Definition MRColorTheme.h:67
static void setupUserTheme(const std::string &themeName)
@ AxisX
Definition MRColorTheme.h:153
@ AxisY
Definition MRColorTheme.h:154
@ AxisZ
Definition MRColorTheme.h:155
@ Count
Definition MRColorTheme.h:156
@ Default
Definition MRColorTheme.h:26
@ Light
Definition MRColorTheme.h:27
@ Dark
Definition MRColorTheme.h:25
@ Count
Definition MRColorTheme.h:28
@ Default
Definition MRColorTheme.h:36
@ User
Definition MRColorTheme.h:37
@ GradBtnSecStyleStart
Definition MRColorTheme.h:133
@ QuickAccessBackground
Definition MRColorTheme.h:75
@ RibbonButtonActiveHovered
Definition MRColorTheme.h:107
@ GradBtnDisableStart
Definition MRColorTheme.h:126
@ RibbonButtonActiveClicked
Definition MRColorTheme.h:108
@ RibbonButtonClicked
Definition MRColorTheme.h:105
@ GradBtnSecStyleEnd
Definition MRColorTheme.h:136
@ GradBtnSecStyleActiveEnd
Definition MRColorTheme.h:138
@ TopPanelBackground
Definition MRColorTheme.h:72
@ GradBtnHoverStart
Definition MRColorTheme.h:124
@ HeaderBackground
Definition MRColorTheme.h:70
@ TabClicked
Definition MRColorTheme.h:80
@ GradBtnDisableEnd
Definition MRColorTheme.h:130
@ RibbonButtonActive
Definition MRColorTheme.h:106
@ DialogTabText
Definition MRColorTheme.h:91
@ TabActive
Definition MRColorTheme.h:81
@ GradBtnStart
Definition MRColorTheme.h:123
@ Grid
Definition MRColorTheme.h:140
@ SelectedObjectFrame
Definition MRColorTheme.h:116
@ RibbonButtonHovered
Definition MRColorTheme.h:104
@ GradBtnEnd
Definition MRColorTheme.h:127
@ TabText
Definition MRColorTheme.h:84
@ DialogTabHovered
Definition MRColorTheme.h:88
@ BackgroundSecStyle
Definition MRColorTheme.h:69
@ GradBtnSecStyleActiveStart
Definition MRColorTheme.h:135
@ GradBtnSecStyleHoverStart
Definition MRColorTheme.h:134
@ TabActiveText
Definition MRColorTheme.h:85
@ ToolbarHovered
Definition MRColorTheme.h:94
@ GradBtnActiveEnd
Definition MRColorTheme.h:129
@ HeaderSeparator
Definition MRColorTheme.h:71
@ GradBtnSecStyleHoverEnd
Definition MRColorTheme.h:137
@ Text
Definition MRColorTheme.h:99
@ TabActiveHovered
Definition MRColorTheme.h:82
@ GradBtnText
Definition MRColorTheme.h:131
@ TextEnabled
Definition MRColorTheme.h:100
@ ThirdpartyBackground
Definition MRColorTheme.h:110
@ Background
Definition MRColorTheme.h:68
@ TextContrastBackground
Definition MRColorTheme.h:121
@ GradientEnd
Definition MRColorTheme.h:119
@ TopPanelSearchBackground
Definition MRColorTheme.h:73
@ FrameBackground
Definition MRColorTheme.h:112
@ TabHovered
Definition MRColorTheme.h:79
@ ModalBackground
Definition MRColorTheme.h:97
@ SelectedObjectText
Definition MRColorTheme.h:115
@ DialogTabActive
Definition MRColorTheme.h:89
@ ToolbarClicked
Definition MRColorTheme.h:95
@ GradBtnActiveStart
Definition MRColorTheme.h:125
@ TabActiveClicked
Definition MRColorTheme.h:83
@ DialogTabActiveHovered
Definition MRColorTheme.h:90
@ DialogTab
Definition MRColorTheme.h:87
@ ProgressBarBackground
Definition MRColorTheme.h:111
@ CollapseHeaderBackground
Definition MRColorTheme.h:113
@ Borders
Definition MRColorTheme.h:77
@ TextDisabled
Definition MRColorTheme.h:101
@ TextSelectedBg
Definition MRColorTheme.h:102
@ DialogTabActiveText
Definition MRColorTheme.h:92
@ Count
Definition MRColorTheme.h:142
@ GradBtnHoverEnd
Definition MRColorTheme.h:128
@ GradientStart
Definition MRColorTheme.h:118
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRColor.h:12
Definition MRSignal.h:27