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
19{
20public:
21 MRVIEWER_API static ColorTheme& instance();
22
23 enum class Preset
24 {
25 Dark,
26 Default = Dark,
27 Light,
28 Count
29 };
30 MRVIEWER_API static Preset getPreset();
31 MRVIEWER_API static const char* getPresetName( Preset type );
32
33
34 enum class Type
35 {
36 Default,
37 User
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
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
150 {
152 Borders,
153 AxisX,
154 AxisY,
155 AxisZ,
156 Count
157 };
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}
Definition MRColorTheme.h:19
static MRVIEWER_API void updateUserThemesList()
Find available custom themes.
static MRVIEWER_API void setupUserTheme(const std::string &themeName)
static MRVIEWER_API bool isInitialized()
True if this structure is filled with colors, false if empty.
static MRVIEWER_API ColorTheme & instance()
static MRVIEWER_API void setupFromJson(const Json::Value &value, Type type=Type::User)
Setup this struct from Json value.
static MRVIEWER_API 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 MRVIEWER_API const char * getPresetName(Preset type)
static MRVIEWER_API const char * getRibbonColorTypeName(RibbonColorsType type)
static MRVIEWER_API void setupFromFile(const std::filesystem::path &path, Type type=Type::User)
Setup this struct from serialized color-theme file.
static MRVIEWER_API void setRibbonColor(const Color &color, RibbonColorsType type)
Getter and setter for ribbon colors.
static MRVIEWER_API std::filesystem::path getUserThemesDirectory()
Returns directory where user's custom themes are stored.
static MRVIEWER_API std::vector< std::string > foundUserThemes()
Return list of found custom themes.
static MRVIEWER_API void setupByTypeName(Type type, const std::string &name)
Setup this struct.
static MRVIEWER_API Preset getPreset()
static MRVIEWER_API void setupDefaultLight()
static MRVIEWER_API void setupDefaultDark()
ViewportColorsType
Definition MRColorTheme.h:150
static MRVIEWER_API const char * getViewportColorTypeName(ViewportColorsType type)
static MRVIEWER_API void serializeCurrentToFile(const std::filesystem::path &path)
static MRVIEWER_API const Color & getRibbonColor(RibbonColorsType type)
static MRVIEWER_API void setViewportColor(const Color &color, ViewportColorsType type)
Getter and setter for viewport colors.
Preset
Definition MRColorTheme.h:24
static MRVIEWER_API const Color & getViewportColor(ViewportColorsType type)
Type
Definition MRColorTheme.h:35
static MRVIEWER_API Type getThemeType()
RibbonColorsType
Color types used in ribbon.
Definition MRColorTheme.h:67
static MRVIEWER_API void serializeCurrentToJson(Json::Value &root)
static MRVIEWER_API void resetImGuiStyle()
Reset ImGui style sizes and colors, and apply menu scaling to it.
static MRVIEWER_API const std::string & getThemeName()
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRColor.h:12
Definition MRSignal.h:27