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 uint32_t TYPE

Constructors, destructors, conversion operators

ColorSwatchUI()
~ColorSwatchUI() virtual

Public functions

auto Load(App::PropertyList* pConfigProp, struct Math::ColorRGB color, struct Math::Rectangle area, UTFWin::IWindow* pContainerWindow, Object* pExpansionObject) -> void
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.
auto SetArea(struct Math::Rectangle area, bool bUpdateSwatch = false) -> void
Sets the area of this swatch, updating the area of all the windows used by it.
auto GenerateExpansionArea(bool bFitWindow = false) -> void
Calculates and sets the area of the expansion window for this swatch, based on the 'colorpickerExpansionSize' property.
auto AddTooltip(uint32_t instanceID) -> void
Adds a tooltip to this swatch, using the localized eastl::string with the given instance ID (the tableID is 'editor').
auto Update(int msTime, bool) -> void
auto Hide() -> void
auto Destroy() -> void
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(UTFWin::IWindow* pWindow, const UTFWin::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.
IWindowPtr mpFrameWindow
The window that displays the frame of the swatch.
IWindowPtr mpFrameGlowWindow
The window that displays the frame glow of the swatch.
IWindowPtr mpFrameShineWindow
The window that displays the frame shine of the swatch.
IWindowPtr mpColorWindow
The window that displays the current selected color.
IWindowPtr mpMainWindow
The main window that contains all the other windows of the swatch.
IWindowPtr mpExpansionWindow
The panel that shows when the swatch is pressed, and that expands the swatch to show multiple colors.
ObjectPtr mpExpansionObject
An object necessary to do the swatch expansion; generally this is the color picker.
eastl::vector<ColorSwatchUIPtr> mExpansionSwatches
All the color swatch UIs that are shown in the expansion panel of this swatch.
PropertyListPtr 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, struct Math::Rectangle area, UTFWin::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(struct 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 eastl::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(UTFWin::IWindow* pWindow, const UTFWin::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.

IWindowPtr Palettes::ColorSwatchUI::mpFrameWindow

The window that displays the frame of the swatch.

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

IWindowPtr Palettes::ColorSwatchUI::mpFrameGlowWindow

The window that displays the frame glow of the swatch.

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

IWindowPtr Palettes::ColorSwatchUI::mpFrameShineWindow

The window that displays the frame shine of the swatch.

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

IWindowPtr Palettes::ColorSwatchUI::mpColorWindow

The window that displays the current selected color.

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

IWindowPtr 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.

IWindowPtr 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.