34#include <NDEVR/INIInterface.h>
35#include <NDEVR/RGBColor.h>
36#include <QPropertyAnimation>
51 class NDEVRProxyStyle;
126 int pixelMetric(PixelMetric metric,
const QStyleOption *option =
nullptr,
const QWidget *widget =
nullptr)
const override;
134 virtual void drawPrimitive(PrimitiveElement pe,
const QStyleOption *opt, QPainter *p,
const QWidget *w =
nullptr)
const override;
142 void drawControl(ControlElement element,
const QStyleOption *opt, QPainter *painter,
const QWidget *widget)
const override;
150 void drawComplexControl(ComplexControl control,
const QStyleOptionComplex *option, QPainter *painter,
const QWidget *widget =
nullptr)
const override;
159 void drawArrow(Qt::ArrowType type, QPainter *painter,
const QStyleOption *option,
const QRect &rect,
const QColor &color)
const;
170 void drawItemText(QPainter *painter,
const QRect &rect,
int flags,
const QPalette &pal,
bool enabled,
171 const QString &text, QPalette::ColorRole textRole = QPalette::NoRole)
const override;
179 virtual void drawItemPixmap(QPainter *painter,
const QRect &rect,
int alignment,
const QPixmap &pixmap)
const override;
187 QRect
subElementRect(SubElement element,
const QStyleOption *option,
const QWidget *widget)
const override;
196 QRect
subControlRect(ComplexControl cc,
const QStyleOptionComplex *opt, SubControl sc,
const QWidget *widget)
const override;
206 QRect
itemTextRect(
const QFontMetrics &fm,
const QRect &r,
int flags,
bool enabled,
const QString &text)
const override;
214 QRect
itemPixmapRect(
const QRect &r,
int flags,
const QPixmap &pixmap)
const override;
223 QSize
sizeFromContents(ContentsType type,
const QStyleOption *option,
const QSize &size,
const QWidget *widget)
const override;
232 int styleHint(StyleHint stylehint,
const QStyleOption *opt =
nullptr,
233 const QWidget *widget =
nullptr, QStyleHintReturn* returnData =
nullptr)
const override;
260 QIcon
standardIcon(StandardPixmap
standardIcon,
const QStyleOption* option =
nullptr,
const QWidget* widget =
nullptr)
const override;
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Contains methods for easily reading and writing to an INI file including efficient casting,...
INIInterface()
Constructs an INIInterface with no default INI file.
Responsible for setting up the core style of the application including size of various widgets and co...
void saveSettings()
Persists the current style settings to storage.
fltp08 m_touch_text_scale_vert
Vertical text scale factor for touch mode.
fltp08 m_touch_text_scale_horz
Horizontal text scale factor for touch mode.
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override
Returns the sub-element rectangle for a given element type.
void drawRoundedButtonBackground(const QStyleOption *opt, QPainter *p, int radius=Constant< int >::Max) const
Draws a rounded button background.
NDEVRLightingTheme oldTheme() const
Returns the theme that was active before the most recent theme change.
void updateUIFromStyle()
Refreshes the entire UI to reflect current style settings.
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget=nullptr) const override
Draws a complex control such as a scroll bar or slider.
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *painter, const QWidget *widget) const override
Draws a control element such as a button or label.
NDEVRLightingTheme theme() const
Returns the currently active lighting theme.
static NDEVRProxyStyle * s_global_style
The singleton global style instance.
void setUseRoundedButtons(bool use_rounded_buttons)
Enables or disables rounded button rendering.
void lightingThemeChangedSignal(NDEVRLightingTheme theme)
Emitted when the lighting theme changes.
NDEVRLightingTheme m_old_theme
The previously active theme before the last change.
TimeSpan fadeOutAnimationTime() const
Returns the duration of fade-out animations.
TimeSpan resizeAnimationTime() const
Returns the duration of widget resize animations.
void setToDefaultColors()
Resets all theme colors to their default values.
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const override
Returns the bounding rectangle for an item pixmap.
static NDEVRProxyStyle * GlobalStyle()
Returns the singleton global style instance.
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
Returns the standard icon for a given pixmap type.
fltp08 baseTextScale() const
Returns the base text scaling factor.
void updateResolutionPixelMetric()
Recalculates the resolution-dependent pixel metric based on the current display.
QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const override
Returns the bounding rectangle for item text.
void setToDefaultSizes()
Resets all UI size metrics to their default values.
fltp08 desktopFontScale()
Returns the desktop font scaling factor.
void setLightingThemeAnimated(NDEVRLightingTheme start, NDEVRLightingTheme end, fltp04 percent)
Sets the lighting theme with an animated transition at a specific percentage.
void polish(QWidget *widget) override
Polishes a widget by applying NDEVR-specific style adjustments.
NDEVRProxyStyle(const File &ini_file)
Constructs the proxy style and loads settings from an INI file.
fltp08 m_desktop_text_scale
Text scale factor for desktop mode.
NDEVRProxyStyle(QStyle *style)
Constructs the proxy style wrapping an existing QStyle.
fltp08 m_touch_ui_scale_horz
Horizontal UI scale factor for touch mode.
void drawArrow(Qt::ArrowType type, QPainter *painter, const QStyleOption *option, const QRect &rect, const QColor &color) const
Draws an arrow indicator in the given direction.
void setLightingThemeAnimated(NDEVRLightingTheme theme)
Sets the lighting theme with an animated transition from the current theme.
NDEVRLightingTheme m_theme
The currently active lighting theme.
int styleHint(StyleHint stylehint, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr, QStyleHintReturn *returnData=nullptr) const override
Returns a style hint value for the given hint type.
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
Draws a primitive style element with custom NDEVR rendering.
QPalette themePalette(NDEVRLightingTheme theme) const
Returns the palette for a specific lighting theme.
fltp08 m_desktop_ui_scale
UI scale factor for desktop mode.
bool m_touch_use_rounded_buttons
Whether rounded button rendering is enabled in touch mode.
QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override
Computes the size for a widget given its contents type.
void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const override
Draws text within a styled context.
QPalette interpolatedThemePalette(NDEVRLightingTheme start, NDEVRLightingTheme end, fltp04 percent) const
Returns a palette that interpolates between two themes.
fltp04 m_theme_transition_percent
Current animation progress during theme transitions.
virtual void getINI(INIFactory &factory) override
Serializes or deserializes theme settings through an INI factory.
virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override
Draws a pixmap within a styled context.
TimeSpan fadeInAnimationTime() const
Returns the duration of fade-in animations.
void updateFontScale()
Recalculates the font scale based on current settings.
bool isGlobalStyle() const
Checks whether this instance is the global singleton style.
void updateIconOverrideTheme()
Updates the icon theme override to match the current lighting theme.
RGBColor theme_colors[NDEVRLightingTheme::e_num_of_themes][QPalette::NColorRoles]
Per-theme color table indexed by theme and palette role.
fltp08 m_touch_ui_scale_vert
Vertical UI scale factor for touch mode.
bool usingRoundedButtons() const
Checks whether rounded buttons are currently enabled.
void init()
Initializes the proxy style with default values and system metrics.
fltp08 baseUIScale() const
Returns the base UI scaling factor.
RGBColor disabledColor(NDEVRLightingTheme theme) const
Returns the disabled-state color for a given theme.
NDEVRProxyStyle()
Constructs the proxy style with default settings.
void setLightingTheme(NDEVRLightingTheme theme, bool force_update=false, bool save_settings=true)
Sets the active lighting theme immediately.
QStyle * m_native_theme
The platform native style used as a fallback.
fltp08 m_resolution_pixel_metric
A DPI-aware pixel metric for the current display.
virtual QPalette standardPalette() const override
Returns the standard palette for the current theme.
int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const override
Returns a pixel metric value scaled for the current UI settings.
fltp04 themeTransitionPercent()
Returns the current theme transition animation percentage.
TimeSpan paletteAnimationTime() const
Returns the duration of palette transition animations.
static StringView ColorThemeIcon(NDEVRLightingTheme theme)
Returns the icon name associated with a given lighting theme.
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override
Returns the sub-control rectangle for a complex control.
static QFont OriginalFont()
Returns the original application font before any scaling is applied.
Represents a color in the RGB space with optional alpha transparency.
Logic for reading or writing to a string or a user friendly, TranslatedString.
The core String View class for the NDEVR API.
void setPercent(float percent)
Sets the current interpolation percentage and updates the style.
QPropertyAnimation * m_animation
The underlying Qt property animation driver.
NDEVRLightingTheme end
The theme at the end of the animation.
void startAnimation()
Begins the theme transition animation.
NDEVRProxyStyle * style
The proxy style being animated.
NDEVRLightingTheme start
The theme at the beginning of the animation.
float percent() const
Returns the current interpolation percentage of the animation.
ThemeChanger(NDEVRLightingTheme start, NDEVRLightingTheme end, NDEVRProxyStyle *style)
Constructs a ThemeChanger animation between two themes.
Stores a time span, or difference between two times, with an optional start time.
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
double fltp08
Defines an alias representing an 8 byte floating-point number.
NDEVRLightingTheme
Enumerates the available UI color themes.
@ e_light_theme
A light color theme with dark text on light backgrounds.
@ e_dark_theme
A dark color theme with light text on dark backgrounds.
@ e_num_of_themes
The total number of available themes.