GuiColorPickerCtrl Class Reference

#include <guiColorPicker.h>

Inheritance diagram for GuiColorPickerCtrl:

Inheritance graph
[legend]
List of all members.

Detailed Description

GuiColorPickerCtrl.

This control draws a box containing a color specified by mPickColor, in a way according to one of the PickMode enum's, stored as mDisplayMode.

The color the box represents is stored as mBaseColour (for pPallete, pBlendColorRange), whilst the color chosen by the box is stored as mPickColor.

Whenever the control is clicked, it will do one of many things :

  1. If its in pPallete mode, execute the regular "command"
  2. If its in pBlendColorRange mode, update the selector position. The position will be re-read upon the next render. In addition, a cross will be drawn where the color has been selected from. As with 1, "command" will be executed.
  3. If its in pHorizColorRange or pVertColorRange mode, it will function in a similar manner to 2, but the selector will resemble a horizontal or vertical bar.
  4. If its in pHorizAlphaRange or pVertAlphaRange mode, it will also function the same way as 3
  5. If its in pDropperBackground mode, nothing will happen

Colours are drawn in different ways according to mDisplayMode:

  1. With pPallete, a box with a blank color, mBaseColor is drawn.
  2. With pHorizColorRange, a horizontal box with colors blending in the range, mColorRange.
  3. With pVertColorRange, a vertical box with colors blending in the range, mColorRange.
  4. With pBlendColorRange, a box, the bottom colors being black, but the top left being white, and the top right being mBaseColor.
  5. With pHorizAlphaRange, a horizontal box with black blending with an alpha from 0 to 255
  6. With pVertAlphaRange, a vertical box with black blending with an apha from 0 to 255
  7. With pDropperBackground, nothing is drawn


Core Variables

ColorF mPickColor
 Color that has been picked from control.
ColorF mBaseColor
 Colour we display (in case of pallet and blend mode).
PickMode mDisplayMode
 Current color display mode of the selector.
Point2I mSelectorPos
 Current position of the selector.
bool mPositionChanged
 Current position has changed since last render?
bool mMouseOver
 Mouse is over?
bool mMouseDown
 Mouse button down?
bool mActionOnMove
 Perform onAction() when position has changed?
S32 mSelectorGap
 The half-way "gap" between the selector pos and where the selector is allowed to draw.
GFXStateBlockRef mStateBlock
static ColorI mColorRange [9]
 Color range for pHorizColorRange and pVertColorRange.

Public Types

 pPallet = 0
 We just have a solid color; We just act like a pallet.
 pHorizColorRange
 We have a range of base colors going horizontally.
 pVertColorRange
 We have a range of base colors going vertically.
 pHorizColorBrightnessRange
 HorizColorRange with brightness.
 pVertColorBrightnessRange
 VertColorRange with brightness.
 pBlendColorRange
 We have a box which shows a range in brightness of the color.
 pHorizAlphaRange
 We have a box which shows a range in alpha going horizontally.
 pVertAlphaRange
 We have a box which shows a range in alpha going vertically.
 pDropperBackground
 The control does not draw anything; Only does something when you click, or move the mouse (when active).
 sHorizontal = 0
 Horizontal selector with small gap.
 sVertical
 Vertical selector with small gap.
enum  PickMode {
  pPallet = 0,
  pHorizColorRange,
  pVertColorRange,
  pHorizColorBrightnessRange,
  pVertColorBrightnessRange,
  pBlendColorRange,
  pHorizAlphaRange,
  pVertAlphaRange,
  pDropperBackground
}
enum  SelectorMode {
  sHorizontal = 0,
  sVertical
}

Public Member Functions

 DECLARE_CONOBJECT (GuiColorPickerCtrl)
 GuiColorPickerCtrl ()
void onRender (Point2I offset, const RectI &updateRect)
 Called when this control is to render itself.
Color Value Functions
NOTE: setValue only sets baseColor, since setting pickColor wouldn't be useful

void setValue (ColorF &value)
ColorF getValue ()
 NOTE: getValue() returns baseColor if pallet (since pallet controls can't "pick" colours themselves).
const char * getScriptValue ()
 Returns the value of the variable bound to this object.
void setScriptValue (const char *value)
 Sets the value of the variable bound to this object.
void updateColor ()
Selector Functions
void setSelectorPos (const Point2I &pos)
 Set new pos (in local coords).
Point2I getSelectorPos ()
Input Events
void onMouseDown (const GuiEvent &)
void onMouseUp (const GuiEvent &)
void onMouseMove (const GuiEvent &event)
void onMouseDragged (const GuiEvent &event)
void onMouseEnter (const GuiEvent &)
void onMouseLeave (const GuiEvent &)

Static Public Member Functions

static void initPersistFields ()
 Register dynamic fields in a subclass of ConsoleObject.

Protected Member Functions

Core Rendering functions
void renderColorBox (RectI &bounds)
 Function that draws the actual color box.
void drawSelector (RectI &bounds, Point2I &selectorPos, SelectorMode mode)
 Function that draws the selection indicator.
void drawBlendBox (RectI &bounds, ColorF &c1, ColorF &c2, ColorF &c3, ColorF &c4)
void drawBlendRangeBox (RectI &bounds, bool vertical, U8 numColors, ColorI *colors)

Private Types

typedef GuiControl Parent


Member Typedef Documentation

Reimplemented from GuiControl.


Member Enumeration Documentation

Enumerator:
pPallet  We just have a solid color; We just act like a pallet.
pHorizColorRange  We have a range of base colors going horizontally.
pVertColorRange  We have a range of base colors going vertically.
pHorizColorBrightnessRange  HorizColorRange with brightness.
pVertColorBrightnessRange  VertColorRange with brightness.
pBlendColorRange  We have a box which shows a range in brightness of the color.
pHorizAlphaRange  We have a box which shows a range in alpha going horizontally.
pVertAlphaRange  We have a box which shows a range in alpha going vertically.
pDropperBackground  The control does not draw anything; Only does something when you click, or move the mouse (when active).

Enumerator:
sHorizontal  Horizontal selector with small gap.
sVertical  Vertical selector with small gap.


Constructor & Destructor Documentation

GuiColorPickerCtrl::GuiColorPickerCtrl (  ) 


Member Function Documentation

void GuiColorPickerCtrl::renderColorBox ( RectI bounds  )  [protected]

Function that draws the actual color box.

void GuiColorPickerCtrl::drawSelector ( RectI bounds,
Point2I selectorPos,
SelectorMode  mode 
) [protected]

Function that draws the selection indicator.

void GuiColorPickerCtrl::drawBlendBox ( RectI bounds,
ColorF c1,
ColorF c2,
ColorF c3,
ColorF c4 
) [protected]

void GuiColorPickerCtrl::drawBlendRangeBox ( RectI bounds,
bool  vertical,
U8  numColors,
ColorI colors 
) [protected]

GuiColorPickerCtrl::DECLARE_CONOBJECT ( GuiColorPickerCtrl   ) 

static void GuiColorPickerCtrl::initPersistFields (  )  [static]

Register dynamic fields in a subclass of ConsoleObject.

See also:
addField(), addFieldV(), addDeprecatedField(), addGroup(), endGroup()

Reimplemented from GuiControl.

void GuiColorPickerCtrl::onRender ( Point2I  offset,
const RectI updateRect 
) [virtual]

Called when this control is to render itself.

Parameters:
offset The location this control is to begin rendering
updateRect The screen area this control has drawing access to

Reimplemented from GuiControl.

void GuiColorPickerCtrl::setValue ( ColorF value  )  [inline]

ColorF GuiColorPickerCtrl::getValue (  )  [inline]

NOTE: getValue() returns baseColor if pallet (since pallet controls can't "pick" colours themselves).

const char* GuiColorPickerCtrl::getScriptValue (  )  [virtual]

Returns the value of the variable bound to this object.

Reimplemented from GuiControl.

void GuiColorPickerCtrl::setScriptValue ( const char *  value  )  [virtual]

Sets the value of the variable bound to this object.

Reimplemented from GuiControl.

void GuiColorPickerCtrl::updateColor (  )  [inline]

void GuiColorPickerCtrl::setSelectorPos ( const Point2I pos  ) 

Set new pos (in local coords).

Point2I GuiColorPickerCtrl::getSelectorPos (  )  [inline]

void GuiColorPickerCtrl::onMouseDown ( const GuiEvent  )  [virtual]

Reimplemented from GuiControl.

void GuiColorPickerCtrl::onMouseUp ( const GuiEvent  )  [virtual]

Reimplemented from GuiControl.

void GuiColorPickerCtrl::onMouseMove ( const GuiEvent event  )  [virtual]

Reimplemented from GuiControl.

void GuiColorPickerCtrl::onMouseDragged ( const GuiEvent event  )  [virtual]

Reimplemented from GuiControl.

void GuiColorPickerCtrl::onMouseEnter ( const GuiEvent  )  [virtual]

Reimplemented from GuiControl.

void GuiColorPickerCtrl::onMouseLeave ( const GuiEvent  )  [virtual]

Reimplemented from GuiControl.


Member Data Documentation

Color that has been picked from control.

Colour we display (in case of pallet and blend mode).

Current color display mode of the selector.

Current position of the selector.

Current position has changed since last render?

Mouse is over?

Mouse button down?

Perform onAction() when position has changed?

The half-way "gap" between the selector pos and where the selector is allowed to draw.

ColorI GuiColorPickerCtrl::mColorRange[9] [static, protected]

Color range for pHorizColorRange and pVertColorRange.