3ds Max C++ API Reference
QMaxColorSwatch Class Reference

Simple UI component to display and modify a color-value. More...

#include <QMaxColorSwatch.h>

+ Inheritance diagram for QMaxColorSwatch:

Public Slots

void setValue (const AColor &value)
 Sets the color value associated with this color swatch. More...
 
void setUseAlpha (bool useAlpha)
 Sets whether the color swatch should expose the alpha component. More...
 
void setTitle (const QString &title)
 Sets the title used in the color-picker, when opened. More...
 
void setAnimationKeyBrackets (bool show_brackets)
 Sets whether the animation key brackets should be shown. More...
 
void setIgnoreColorCorrection (bool ignore)
 Sets whether the color swatch should ignore the application-wide color correction and display the raw RGB(A) value. More...
 

Signals

void valueChanged (const AColor &value)
 Will be emitted, if the actual color value has changed. More...
 
void interactiveChanged (bool interactive, bool canceled=false)
 Will be emitted, if swatch changed its interactive state. More...
 

Public Member Functions

 QMaxColorSwatch (QWidget *parent=nullptr)
 Default constructor. More...
 
virtual ~QMaxColorSwatch ()
 
AColor value () const
 The color value associated with this color swatch. More...
 
bool useAlpha () const
 Determines whether the color swatch should expose the alpha component. More...
 
QString title () const
 The title used in the color-picker, when opened. More...
 
bool isInteractive () const
 Determines whether the color swatch is in interactive mode. More...
 
bool hasAnimationKeyBrackets () const
 If the animation key brackets should be shown. More...
 
bool useModalPicker () const
 Determines whether the modal version of the color picker dialog should be used. More...
 
void setUseModalPicker (bool use_modal_picker)
 Sets, if a modal color-picker should be used. More...
 
bool ignoreColorCorrection () const
 Determines whether the color swatch should ignore the application-wide color correction and display the raw RGB(A) value. More...
 
virtual QSize minimumSizeHint () const override
 

Protected Member Functions

 QMaxColorSwatch (QMaxColorSwatchPrivate *_d, QWidget *parent=nullptr)
 
virtual void paintEvent (QPaintEvent *event) override
 
virtual void mousePressEvent (QMouseEvent *event) override
 
virtual void mouseMoveEvent (QMouseEvent *event) override
 
virtual void mouseReleaseEvent (QMouseEvent *event) override
 
virtual void dragEnterEvent (QDragEnterEvent *event) override
 
virtual void dragMoveEvent (QDragMoveEvent *event) override
 
virtual void dropEvent (QDropEvent *event) override
 
void startInteractive ()
 
void stopInteractive (bool canceled)
 
 Q_DECLARE_PRIVATE (QMaxColorSwatch)
 

Properties

AColor value
 The color value associated with this color swatch. More...
 
bool useAlpha
 Determines whether the color swatch should expose the alpha component. More...
 
QString title
 The title of the color picker when shown. More...
 
bool useModalPicker
 Determines whether the modal version of the color picker dialog should be used. More...
 
bool ignoreColorCorrection
 Determines whether the color swatch should ignore the application-wide color correction and display the raw RGB(A) value. More...
 
bool animationKeyBrackets
 Show the animation key brackets around the component. More...
 
bool interactive
 Determines whether the color swatch is in interactive mode. More...
 

Friends

class ColorSwatch
 
class CSCallback
 

Detailed Description

Simple UI component to display and modify a color-value.

The color aka 'value' is stored as a AColor, what means that the RGB color and alpha channels are stored in floats in a range between 0.0f and 1.0f.

If the alpha channel should not be used, please set the useAlpha property to false, in that case the ColorPicker shown on left mouse click will display in non-alpha mode.

Constructor & Destructor Documentation

◆ QMaxColorSwatch() [1/2]

QMaxColorSwatch ( QWidget *  parent = nullptr)
explicit

Default constructor.

Constructs a new QMaxColorSwatch with the following settings:

  • no alpha used
  • non-modal color-picker
  • empty title
  • the color value is just black (0,0,0)

◆ ~QMaxColorSwatch()

virtual ~QMaxColorSwatch ( )
virtual

◆ QMaxColorSwatch() [2/2]

QMaxColorSwatch ( QMaxColorSwatchPrivate *  _d,
QWidget *  parent = nullptr 
)
explicitprotected

Member Function Documentation

◆ value()

AColor value ( ) const

The color value associated with this color swatch.

See also
setValue(), valueChanged(), value

◆ useAlpha()

bool useAlpha ( ) const

Determines whether the color swatch should expose the alpha component.

See also
setUseAlpha(), useAlpha

◆ title()

QString title ( ) const

The title used in the color-picker, when opened.

See also
setTitle(), title

◆ isInteractive()

bool isInteractive ( ) const

Determines whether the color swatch is in interactive mode.

A color watch is in interactive mode, while the color picker dialog is opened and associated to this color swatch - so the user may perform several sequential 'interactive' color changes, that are meant to be captured as one common value change in terms of the undo/redo history.

Since the user has the option to cancel the interactive changes - by pressing the "Cancel" button on the color picker dialog, the signal emitted by that change also includes that information.

See also
interactive, interactiveChanged()

◆ hasAnimationKeyBrackets()

bool hasAnimationKeyBrackets ( ) const

If the animation key brackets should be shown.

See also
animationKeyBrackets, setAnimationKeyBrackets()

◆ useModalPicker()

bool useModalPicker ( ) const

Determines whether the modal version of the color picker dialog should be used.

When using the non-modal version of the color picker dialog, what's the default behavior, a color picker dialog can be used to manipulate the color of different swatches by just clicking on them. The active swatch get painted with white outline, so the user can distinguish what color swatch is to be modified. Switching color swatches in that way will emit an interactiveChanged signal to the previous active color swatch, as if the user had clicked on the Ok button to close the dialog.

See also
useModalPicker, setUseModalPicker()

◆ setUseModalPicker()

void setUseModalPicker ( bool  use_modal_picker)

Sets, if a modal color-picker should be used.

See also
useModalPicker, useModalPicker()

◆ ignoreColorCorrection()

bool ignoreColorCorrection ( ) const

Determines whether the color swatch should ignore the application-wide color correction and display the raw RGB(A) value.

See also
setIgnoreColorCorrection(), ignoreColorCorrection

◆ minimumSizeHint()

virtual QSize minimumSizeHint ( ) const
overridevirtual

◆ valueChanged

void valueChanged ( const AColor value)
signal

Will be emitted, if the actual color value has changed.

Parameters
valueThe new color value associated with this color swatch. Please note, that Qt internally takes care if this signal gets handled asynchronously and creates a copy of this parameter, so it's always safe to access its data.
Note
If alpha is not used, setting a color with a different alpha value will NOT emit a valueChanged, of course.
See also
value, value(), setValue().

◆ interactiveChanged

void interactiveChanged ( bool  interactive,
bool  canceled = false 
)
signal

Will be emitted, if swatch changed its interactive state.

Parameters
interactiveThe new interactive state of this color swatch.
canceledIf the interactive param is false, meaning the color picker dialog has been closed, the user has canceled the previous interactive changes. In that case, no redo/undo record should be filed.
See also
interactive, isInteractive().

◆ setValue

void setValue ( const AColor value)
slot

Sets the color value associated with this color swatch.

Parameters
valueThe new color to be associated with this color swatch. If the new color differs from the recent one, a valueChange() is emitted.
Note
If alpha is not used, setting a color with a different alpha value will NOT emit a valueChanged, of course.
See also
value, value(), valueChanged().

◆ setUseAlpha

void setUseAlpha ( bool  useAlpha)
slot

Sets whether the color swatch should expose the alpha component.

See also
useAlpha(), useAlpha

◆ setTitle

void setTitle ( const QString &  title)
slot

Sets the title used in the color-picker, when opened.

See also
title(), title

◆ setAnimationKeyBrackets

void setAnimationKeyBrackets ( bool  show_brackets)
slot

Sets whether the animation key brackets should be shown.

See also
hasAnimationKeyBrackets(), animationBrackets

◆ setIgnoreColorCorrection

void setIgnoreColorCorrection ( bool  ignore)
slot

Sets whether the color swatch should ignore the application-wide color correction and display the raw RGB(A) value.

See also
ignoreColorCorrection(), ignoreColorCorrection

◆ paintEvent()

virtual void paintEvent ( QPaintEvent *  event)
overrideprotectedvirtual

◆ mousePressEvent()

virtual void mousePressEvent ( QMouseEvent *  event)
overrideprotectedvirtual

◆ mouseMoveEvent()

virtual void mouseMoveEvent ( QMouseEvent *  event)
overrideprotectedvirtual

◆ mouseReleaseEvent()

virtual void mouseReleaseEvent ( QMouseEvent *  event)
overrideprotectedvirtual

◆ dragEnterEvent()

virtual void dragEnterEvent ( QDragEnterEvent *  event)
overrideprotectedvirtual

◆ dragMoveEvent()

virtual void dragMoveEvent ( QDragMoveEvent *  event)
overrideprotectedvirtual

◆ dropEvent()

virtual void dropEvent ( QDropEvent *  event)
overrideprotectedvirtual

◆ startInteractive()

void startInteractive ( )
protected

◆ stopInteractive()

void stopInteractive ( bool  canceled)
protected

◆ Q_DECLARE_PRIVATE()

Q_DECLARE_PRIVATE ( QMaxColorSwatch  )
protected

Friends And Related Function Documentation

◆ ColorSwatch

friend class ColorSwatch
friend

◆ CSCallback

friend class CSCallback
friend

Property Documentation

◆ value

AColor value
readwrite

The color value associated with this color swatch.

See also
value(), setValue(), valueChanged()

◆ useAlpha

bool useAlpha
readwrite

Determines whether the color swatch should expose the alpha component.

See also
useAlpha(), setUseAlpha(), value()

◆ title

QString title
readwrite

The title of the color picker when shown.

See also
title(), setTitle()

◆ useModalPicker

bool useModalPicker
readwrite

Determines whether the modal version of the color picker dialog should be used.

See also
useModalPicker(), setUseModalPicker()

◆ ignoreColorCorrection

bool ignoreColorCorrection
readwrite

Determines whether the color swatch should ignore the application-wide color correction and display the raw RGB(A) value.

See also
ignoreColorCorrection(), setIgnoreColorCorrection()

◆ animationKeyBrackets

bool animationKeyBrackets
readwrite

Show the animation key brackets around the component.

See also
hasAnimationKeyBrackets(), setAnimationKeyBrackets()

◆ interactive

bool interactive
read

Determines whether the color swatch is in interactive mode.

See also
isInteractive(), interactiveChanged()