API Documentation
Loading...
Searching...
No Matches
NDEVRTheme.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: NDEVR
28File: NDEVRLightingTheme
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/INIInterface.h>
35#include <NDEVR/RGBColor.h>
36#include <QPropertyAnimation>
37#include <QProxyStyle>
38#include <QPalette>
39class QFont;
40namespace NDEVR
41{
48 class NDEVRProxyStyle;
49 /**--------------------------------------------------------------------------------------------------
50 \brief An animation that slowly changes the color over the entire UI.
51 *-----------------------------------------------------------------------------------------------**/
52 class ThemeChanger : public QPropertyAnimation
53 {
54 Q_OBJECT
55 Q_PROPERTY(float percent READ percent WRITE setPercent)
56 public:
59 float percent() const;
60 void setPercent(float percent);
64
65 protected:
66 QPropertyAnimation* m_animation;
67 };
68 /**--------------------------------------------------------------------------------------------------
69 \brief Responsible for setting up the core style of the application including size of various widgets
70 and colors.
71 Some themes are inherited from the OS, some from Qt's fusion style, and some are defined and drawn
72 directly.
73 *-----------------------------------------------------------------------------------------------**/
74 class NDEVR_WIDGETS_API NDEVRProxyStyle : public QProxyStyle, public INIInterface
75 {
76 Q_OBJECT
77 public:
79 NDEVRProxyStyle(const File& ini_file);
80 NDEVRProxyStyle(QStyle* style);
82 public:
84 int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override;
85 virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w = nullptr) const override;
86 void drawControl(ControlElement element, const QStyleOption *opt, QPainter *painter, const QWidget *widget) const override;
87 void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const override;
88 void drawArrow(Qt::ArrowType type, QPainter *painter, const QStyleOption *option, const QRect &rect, const QColor &color) const;
89 void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled,
90 const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const override;
91 virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override;
92 QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override;
93 QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override;
94 QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const override;
95 QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const override;
96 QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override;
97 int styleHint(StyleHint stylehint, const QStyleOption *opt = nullptr,
98 const QWidget *widget = nullptr, QStyleHintReturn* returnData = nullptr) const override;
99 virtual QPalette standardPalette() const override;
100 QPalette themePalette(NDEVRLightingTheme theme) const;
102 QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption* option = nullptr, const QWidget* widget = nullptr) const override;
106 void setLightingTheme(NDEVRLightingTheme theme, bool force_update = false, bool save_settings = true);
109 void setUseRoundedButtons(bool use_rounded_buttons);
112 bool isGlobalStyle() const;
113 virtual void getINI(INIFactory& factory) override;
115 NDEVRLightingTheme theme() const { return m_theme; };
120 void polish(QWidget *widget) override;
123 static QFont OriginalFont();
128 protected:
129 void drawRoundedButtonBackground(const QStyleOption* opt, QPainter* p, int radius = Constant<int>::Max) const;
131
133 void init();
136 signals:
138 protected:
139 RGBColor theme_colors[NDEVRLightingTheme::e_num_of_themes][QPalette::NColorRoles];
140 protected:
153 };
155}
156
#define NDEVR_WIDGETS_API
Definition DLLInfo.h:81
Logic for reading or writing to a file as well as navigating filesystems.
Definition File.h:48
Contains methods for easily reading and writing to an INI file including efficient casting,...
Definition INIReader.h:64
Contains methods for easily reading and writing to an INI file including.
Definition INIInterface.h:45
Responsible for setting up the core style of the application including size of various widgets and co...
Definition NDEVRTheme.h:75
TimeSpan resizeAnimationTime() const
virtual void getINI(INIFactory &factory) override
TimeSpan fadeInAnimationTime() const
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override
QStyle * m_native_theme
Definition NDEVRTheme.h:144
void setLightingThemeAnimated(NDEVRLightingTheme theme)
TimeSpan fadeOutAnimationTime() const
QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const override
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget=nullptr) const override
NDEVRProxyStyle(QStyle *style)
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override
fltp08 m_touch_text_scale_vert
Definition NDEVRTheme.h:148
TimeSpan paletteAnimationTime() const
void drawArrow(Qt::ArrowType type, QPainter *painter, const QStyleOption *option, const QRect &rect, const QColor &color) const
NDEVRLightingTheme theme() const
Definition NDEVRTheme.h:115
QPalette interpolatedThemePalette(NDEVRLightingTheme start, NDEVRLightingTheme end, fltp04 percent) const
fltp08 m_touch_ui_scale_horz
Definition NDEVRTheme.h:145
static NDEVRProxyStyle * s_global_style
Definition NDEVRTheme.h:135
NDEVRLightingTheme oldTheme() const
bool m_touch_use_rounded_buttons
Definition NDEVRTheme.h:152
fltp08 baseUIScale() const
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const override
NDEVRLightingTheme m_old_theme
Definition NDEVRTheme.h:142
void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const override
NDEVRProxyStyle(const File &ini_file)
static String ColorThemeIcon(NDEVRLightingTheme theme)
NDEVRLightingTheme m_theme
Definition NDEVRTheme.h:143
fltp08 m_resolution_pixel_metric
Definition NDEVRTheme.h:151
fltp08 m_desktop_text_scale
Definition NDEVRTheme.h:150
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
void updateResolutionPixelMetric()
static QFont OriginalFont()
int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const override
void setLightingThemeAnimated(NDEVRLightingTheme start, NDEVRLightingTheme end, fltp04 percent)
static NDEVRProxyStyle * GlobalStyle()
void drawRoundedButtonBackground(const QStyleOption *opt, QPainter *p, int radius=Constant< int >::Max) const
int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
bool usingRoundedButtons() const
fltp08 m_desktop_ui_scale
Definition NDEVRTheme.h:147
QPalette themePalette(NDEVRLightingTheme theme) const
RGBColor disabledColor(NDEVRLightingTheme theme) const
void setLightingTheme(NDEVRLightingTheme theme, bool force_update=false, bool save_settings=true)
virtual QPalette standardPalette() const override
fltp04 themeTransitionPercent()
bool isGlobalStyle() const
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *painter, const QWidget *widget) const override
void setUseRoundedButtons(bool use_rounded_buttons)
fltp04 m_theme_transition_percent
Definition NDEVRTheme.h:141
fltp08 baseTextScale() const
void polish(QWidget *widget) override
void lightingThemeChangedSignal(NDEVRLightingTheme theme)
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override
fltp08 m_touch_ui_scale_vert
Definition NDEVRTheme.h:146
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
fltp08 m_touch_text_scale_horz
Definition NDEVRTheme.h:149
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
The core String class for the software.
Definition String.h:47
Logic for reading or writing to a string or a user friendly, TranslatedString.
Definition StringStream.h:118
An animation that slowly changes the color over the entire UI.
Definition NDEVRTheme.h:53
ThemeChanger(NDEVRLightingTheme start, NDEVRLightingTheme end, NDEVRProxyStyle *style)
NDEVRProxyStyle * style
Definition NDEVRTheme.h:63
NDEVRLightingTheme end
Definition NDEVRTheme.h:62
void setPercent(float percent)
QPropertyAnimation * m_animation
Definition NDEVRTheme.h:66
NDEVRLightingTheme start
Definition NDEVRTheme.h:61
float percent
Definition NDEVRTheme.h:55
float percent() const
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Definition ACIColor.h:37
float fltp04
Defines an alias representing a 4 byte floating-point number.
Definition BaseValues.hpp:125
NDEVRLightingTheme
Definition NDEVRTheme.h:43
@ e_dark_theme
Definition NDEVRTheme.h:44
@ e_num_of_themes
Definition NDEVRTheme.h:46
@ e_light_theme
Definition NDEVRTheme.h:45
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:146
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved.
Definition BaseValues.hpp:230