Palettes::ColorSwatchUI class

This class holds all information related with a single color button in editor categories and its user interface.

A color swatch is a button used to select a color, and it can optionally be expanded to show more color buttons. The multiple color swatches in the category are grouped in the Palettes::ColorPickerUI class.

Base classes

class UTFWin::IWinProc
This class is a window procedure, also known as an event/message listener.
class DefaultRefCounted
The default implementation of a reference counted class.

Public static variables

static const static uint32_t TYPE

Constructors, destructors, conversion operators

ColorSwatchUI()
~ColorSwatchUI() virtual

Public functions

void Load(App::PropertyList* pConfigProp, struct Math::ColorRGB color, union Math::Rectangle area, IWindow* pContainerWindow, Object* pExpansionObject)
Loads and generates the user interface for this color swatch, using the given color and area, as well as some properties of the configuration PROP file given.
void SetArea(union Math::Rectangle area, bool bUpdateSwatch = false)
Sets the area of this swatch, updating the area of all the windows used by it.
void GenerateExpansionArea(bool bFitWindow = false)
Calculates and sets the area of the expansion window for this swatch, based on the 'colorpickerExpansionSize' property.
void AddTooltip(uint32_t instanceID)
Adds a tooltip to this swatch, using the localized string with the given instance ID (the tableID is 'editor').
void Update(int msTime, bool)
void Destroy()
auto AddRef() -> int override
auto Release() -> int override
auto Cast(uint32_t type) const -> void* override
auto GetEventFlags() const -> int override
Gets the flags that represent which type of messages this IWinProc can handle.
auto HandleUIMessage(IWindow* pWindow, const Message& message) -> bool override
Method called every time a message is received on a window that has this IWinProc added.

Public variables

bool mIsLoaded
Whether the user interface for this color swatch has already been loaded.
bool mIsRollover
Whether the button is on rollover state (that is, the mouse is over the button).
bool mIsMouseDown
Whether the swatch button is being pressed with the left mouse click.
bool mIsShowingPanel
Whether the expansion panel is being shown.-.
bool field_10
bool mIsCustomColor
Whether this swatch is the button used to set a custom color in the color picker.
bool mIsDefaultColor
Whether this swatch is the button used to set the default color in the color picker.
float mMouseRolloverTime
float field_18
float mMouseDownTime
float mMouseSelectTime
Math::ColorRGB mOriginalColor
The original color with which this swatch was loaded. This never changes.
Math::ColorRGB mColor
The current selected color of the swatch.
Math::Rectangle mArea
The area (relative to the container window) that this swatch button fits.
intrusive_ptr<IWindow> mpFrameWindow
The window that displays the frame of the swatch.
intrusive_ptr<IWindow> mpFrameGlowWindow
The window that displays the frame glow of the swatch.
intrusive_ptr<IWindow> mpFrameShineWindow
The window that displays the frame shine of the swatch.
intrusive_ptr<IWindow> mpColorWindow
The window that displays the current selected color.
intrusive_ptr<IWindow> mpMainWindow
The main window that contains all the other windows of the swatch.
intrusive_ptr<IWindow> mpExpansionWindow
The panel that shows when the swatch is pressed, and that expands the swatch to show multiple colors.
intrusive_ptr<Object> mpExpansionObject
An object necessary to do the swatch expansion; generally this is the color picker.
vector<intrusive_ptr<ColorSwatchUI>> mExpansionSwatches
All the color swatch UIs that are shown in the expansion panel of this swatch.
intrusive_ptr<App::PropertyList> mpConfigProp
The PROP file used to configurate the color picker.
Clock mClock
A milliseconds clock used to measure click time.
int mClickTime
In milliseconds, the last time when the mouse was being pressed over the button.
int mPreviousClickTime
In milliseconds, the previous time when the mouse was being pressed over the button.
int mColorIndex
The index of this color inside the color picker.
int field_A4

Function documentation

void Palettes::ColorSwatchUI::Load(App::PropertyList* pConfigProp, struct Math::ColorRGB color, union Math::Rectangle area, IWindow* pContainerWindow, Object* pExpansionObject)

Loads and generates the user interface for this color swatch, using the given color and area, as well as some properties of the configuration PROP file given.

Parameters
pConfigProp The PROP file that contains the configuration of the color picker.
color The main color of this swatch button.
area The area, relative to the parent window, that this button must have.
pContainerWindow The window that will contain the button.
pExpansionObject An object necessary to do the swatch expansion; generally this is the color picker.

The user interface will be inserted into the container window that is provided.

void Palettes::ColorSwatchUI::SetArea(union Math::Rectangle area, bool bUpdateSwatch = false)

Sets the area of this swatch, updating the area of all the windows used by it.

Parameters
area The new area for the swatch windows.
bUpdateSwatch [Optional] If true, it changes the Palettes::ColorSwatchUI::mArea field.

void Palettes::ColorSwatchUI::GenerateExpansionArea(bool bFitWindow = false)

Calculates and sets the area of the expansion window for this swatch, based on the 'colorpickerExpansionSize' property.

Parameters
bFitWindow [Optional] If true, the area width is limited so it fits into the game window.

The value of that property is for a game with a width of 800 px, but in this method it is scaled accordingly to the current game dimensions.

void Palettes::ColorSwatchUI::AddTooltip(uint32_t instanceID)

Adds a tooltip to this swatch, using the localized string with the given instance ID (the tableID is 'editor').

Parameters
instanceID The instance ID of the tooltip text, inside the 'editor' locale table.

int Palettes::ColorSwatchUI::GetEventFlags() const override

Gets the flags that represent which type of messages this IWinProc can handle.

This allows for better performance, since generally a procedure only needs to listen specific events. The flags are in the kEventFlag... values.

bool Palettes::ColorSwatchUI::HandleUIMessage(IWindow* pWindow, const Message& message) override

Method called every time a message is received on a window that has this IWinProc added.

Parameters
pWindow The window that received this message.
message The message received.
Returns Whether the message was handled or not.

This method is responsible of handling (or not) the message. This method receives the IWindow that is currently receiving the message; this way, the same IWinProc can be listening for more than one window. This method returns whether the message was handled or not; if it was handled, no other IWinProcs will be called on that window.

Variable documentation

bool Palettes::ColorSwatchUI::mIsLoaded

Whether the user interface for this color swatch has already been loaded.

This is set to true in the Load method.

intrusive_ptr<IWindow> Palettes::ColorSwatchUI::mpFrameWindow

The window that displays the frame of the swatch.

It displays the image determined by the property 'colorpickerImageDefaultFrame'.

intrusive_ptr<IWindow> Palettes::ColorSwatchUI::mpFrameGlowWindow

The window that displays the frame glow of the swatch.

It displays the image determined by the property 'colorpickerImageDefaultFrameGlow'.

intrusive_ptr<IWindow> Palettes::ColorSwatchUI::mpFrameShineWindow

The window that displays the frame shine of the swatch.

It displays the image determined by the property 'colorpickerImageDefaultFrameShine'.

intrusive_ptr<IWindow> Palettes::ColorSwatchUI::mpColorWindow

The window that displays the current selected color.

It uses the image determined by the property 'colorPickerImageDefaultColor' as background.

intrusive_ptr<IWindow> Palettes::ColorSwatchUI::mpMainWindow

The main window that contains all the other windows of the swatch.

This one is added into the container window provided in the method Load, and has this class added as a window procedure.

intrusive_ptr<IWindow> Palettes::ColorSwatchUI::mpExpansionWindow

The panel that shows when the swatch is pressed, and that expands the swatch to show multiple colors.

This shows the image determined by the property 'colorpickerImageExpansionBackground', and it is not added into mpMainWindow, but into the main game window instead.