Colours

These interfaces are used to implement clients for centralised colour configuration.

namespace colours

Enums

enum colour_identifier_t

Values:

enumerator colour_text
enumerator colour_selection_text
enumerator colour_inactive_selection_text
enumerator colour_background
enumerator colour_selection_background
enumerator colour_inactive_selection_background
enumerator colour_active_item_frame
enumerator colour_group_foreground

Reserved

enumerator colour_group_background

Reserved

enum colour_flag_t

Values:

enumerator colour_flag_text
enumerator colour_flag_selection_text
enumerator colour_flag_inactive_selection_text
enumerator colour_flag_background
enumerator colour_flag_selection_background
enumerator colour_flag_inactive_selection_background
enumerator colour_flag_active_item_frame
enumerator colour_flag_group_foreground
enumerator colour_flag_group_background
enumerator colour_flag_all
enum bool_identifier_t

Values:

enumerator bool_use_custom_active_item_frame
enumerator bool_dark_mode_enabled

Implemented in Columns UI 2.0. Always false on older versions.

See also

helper for more details

enum bool_flag_t

Values:

enumerator bool_flag_use_custom_active_item_frame
enumerator bool_flag_dark_mode_enabled

Functions

static COLORREF g_get_system_color(const colour_identifier_t p_identifier)
bool is_dark_mode_active()

Get whether the UI-wide dark mode is currently active.

Convenience method to avoid having to instantiate a helper instance.

See also

helper::is_dark_mode_active() for more details.

class manager_instance : public service_base

One implementation in Columns UI - do not reimplement!

Public Functions

virtual COLORREF get_colour(const colour_identifier_t &p_identifier) const = 0

Get the specified colour.

virtual bool get_bool(const bool_identifier_t &p_identifier) const = 0

Get the specified colour.

virtual bool get_themed() const = 0

Only returns true if your client::get_themes_supported() method does. Indicates selected items should be drawn using Theme API.

FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(manager_instance)
class common_callback

Use this class if you wish to use the global colours only rather than implementing the client class

Subclassed by cui::colours::dark_mode_notifier

Public Functions

virtual void on_colour_changed(uint32_t changed_items_mask) const = 0
virtual void on_bool_changed(uint32_t changed_items_mask) const = 0
class manager : public service_base

One implementation in Columns UI - do not reimplement!

It is not recommended to use this class directly - use the helper class instead.

Public Functions

virtual void create_instance(const GUID &p_client_guid, cui::colours::manager_instance::ptr &p_out) = 0

Creates a manager_instance for the given client (null GUID implies global settings).

inline virtual void register_common_callback(common_callback *p_callback)
inline virtual void deregister_common_callback(common_callback *p_callback)
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(manager)
class helper

Helper to simplify retrieving colours.

Public Functions

inline COLORREF get_colour(const colour_identifier_t &p_identifier) const
inline bool get_bool(const bool_identifier_t &p_identifier) const
inline bool get_themed() const
inline bool is_dark_mode_active() const

Get whether the UI-wide dark mode is currently active.

Implemented in Columns UI 2.0. Always false on older versions.

There is only one global value of this flag; it does not vary between colour clients.

If your window contains a scroll bar, you should call SetWindowTheme based on the value of this flag as follows:

const auto dark_mode_active = cui::colours::is_dark_mode_active().
SetWindowTheme(wnd, dark_mode_active ? L"DarkMode_Explorer" : nullptr, nullptr);

You should also do this when the client::on_bool_changed() method of your client is called with the bool_flag_dark_mode_enabled bit set.

inline helper(GUID guid = GUID{})

You can omit guid for the global colours

class client : public service_base

Public Functions

virtual const GUID &get_client_guid() const = 0
virtual void get_name(pfc::string_base &p_out) const = 0
inline virtual uint32_t get_supported_colours() const
virtual uint32_t get_supported_bools() const = 0

Return a combination of bool_flag_t to indicate which boolean flags are supported.

If dark mode is supported by your panel, you should set the bool_flag_dark_mode_enabled bit.

virtual bool get_themes_supported() const = 0

Indicates whether you are Theme API aware and can draw selected items using Theme API

virtual void on_colour_changed(uint32_t changed_items_mask) const = 0
virtual void on_bool_changed(uint32_t changed_items_mask) const = 0

Called whenever a supported boolean flag changes. Support for a flag is determined using the get_supported_bools() method.

Example implementation:

void on_bool_changed(uint32_t changed_items_mask) const override
{
    if (changed_items_mask & colours::bool_flag_dark_mode_enabled) {
        const auto is_dark = cui::colours::is_dark_mode_active();
        // Handle dark mode change
    }
}

Note

Only bool_flag_dark_mode_enabled is currently supported. Ensure you inspect changed_items_mask to check which flags have changed.

Parameters:

changed_items_mask[in] a combination of bool_flag_t indicating the flags that have changed. (Only indicates which flags have changed, not the new values.)

FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(client)
template<class tClass>
class factory : public service_factory_t<tClass>
class dark_mode_notifier : private cui::colours::common_callback

Helper for receiving notifications when the global dark mode status changes.

This is mainly used by non-panel parts of the UI. Panels would normally receive this notification through the on_bool_changed method of their client instance.

Public Functions

inline dark_mode_notifier(std::function<void()> callback)
inline ~dark_mode_notifier()
inline virtual void on_colour_changed(uint32_t changed_items_mask) const override
inline virtual void on_bool_changed(uint32_t changed_items_mask) const override