ManaPlus
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
Setup_Colors Class Reference

#include <setup_colors.h>

Inheritance diagram for Setup_Colors:
SetupTab SelectionListener Container ActionListener WidgetListener BasicContainer2 BasicContainer Widget WidgetDeathListener Widget2

Public Member Functions

 Setup_Colors (const Widget2 *const widget)
 
 ~Setup_Colors ()
 
void apply ()
 
void cancel ()
 
void action (const ActionEvent &event)
 
void valueChanged (const SelectionEvent &event)
 
- Public Member Functions inherited from SetupTab
const std::string & getName () const
 
virtual void externalUpdated ()
 
virtual void externalUnloaded ()
 
- Public Member Functions inherited from Container
 Container (const Widget2 *const widget)
 
 ~Container ()
 
bool safeRemove (Widget *const widget)
 
void removeControls ()
 
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 
 ~BasicContainer2 ()
 
void setOpaque (Opaque opaque)
 
bool isOpaque () const
 
virtual void add (Widget *const widget)
 
void addXY (Widget *const widget, const int x, const int y)
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
 ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
Rect getChildrenArea ()
 
void focusNext ()
 
void focusPrevious ()
 
void logic ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget * > &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
virtual void clear ()
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
 ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
virtual void setParent (Widget *parent)
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
virtual void postInit ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
 
- Public Member Functions inherited from ActionListener
virtual ~ActionListener ()
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetResized (const Event &event)
 
virtual void widgetMoved (const Event &event)
 
virtual void widgetHidden (const Event &event)
 
virtual void widgetShown (const Event &event)
 
- Public Member Functions inherited from SelectionListener
virtual ~SelectionListener ()
 

Private Member Functions

void updateColor () const
 
void updateGradType ()
 

Static Private Member Functions

static void setEntry (Slider *const s, TextField *const t, const int value)
 

Private Attributes

ListBoxmColorBox
 
ScrollAreamScroll
 
BrowserBoxmPreview
 
TextPreviewmTextPreview
 
ScrollAreamPreviewBox
 
int mSelected
 
LabelmGradTypeLabel
 
SlidermGradTypeSlider
 
LabelmGradTypeText
 
LabelmGradDelayLabel
 
SlidermGradDelaySlider
 
TextFieldmGradDelayText
 
LabelmRedLabel
 
SlidermRedSlider
 
TextFieldmRedText
 
LabelmGreenLabel
 
SlidermGreenSlider
 
TextFieldmGreenText
 
LabelmBlueLabel
 
SlidermBlueSlider
 
TextFieldmBlueText
 

Static Private Attributes

static const char *const rawmsg
 

Additional Inherited Members

- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 
- Data Fields inherited from Widget
Visible mVisible
 
- Protected Types inherited from BasicContainer
typedef std::vector< Widget * > WidgetList
 
typedef WidgetList::iterator WidgetListIterator
 
typedef WidgetList::const_iterator WidgetListConstIterator
 
typedef WidgetList::reverse_iterator WidgetListReverseIterator
 
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Member Functions inherited from SetupTab
 SetupTab (const Widget2 *const widget)
 
void setName (const std::string &name)
 
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetDeathListener
 WidgetDeathListener ()
 
- Protected Member Functions inherited from ActionListener
 ActionListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 
- Protected Member Functions inherited from SelectionListener
 SelectionListener ()
 
- Protected Attributes inherited from BasicContainer2
Opaque mOpaque
 
- Protected Attributes inherited from BasicContainer
WidgetList mWidgets
 
WidgetList mLogicWidgets
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

Definition at line 38 of file setup_colors.h.

Constructor & Destructor Documentation

◆ Setup_Colors()

Setup_Colors::Setup_Colors ( const Widget2 *const  widget)
explicit

Definition at line 53 of file setup_colors.cpp.

53  :
54  SetupTab(widget),
57  mScroll(new ScrollArea(this, mColorBox,
58  Opaque_true, "setup_colors_background.xml")),
60  "browserbox.xml")),
61  mTextPreview(new TextPreview(this, gettext(rawmsg))),
63  "setup_colors_preview_background.xml")),
64  mSelected(-1),
65  // TRANSLATORS: colors tab. label.
66  mGradTypeLabel(new Label(this, _("Type:"))),
67  mGradTypeSlider(new Slider(this, 0.0, 3.0, 1.0)),
68  mGradTypeText(new Label(this)),
69  // TRANSLATORS: colors tab. label.
70  mGradDelayLabel(new Label(this, _("Delay:"))),
71  mGradDelaySlider(new Slider(this, 20.0, 100.0, 1.0)),
72  mGradDelayText(new TextField(this, std::string(), LoseFocusOnTab_true,
73  nullptr, std::string(), false)),
74  // TRANSLATORS: colors tab. label.
75  mRedLabel(new Label(this, _("Red:"))),
76  mRedSlider(new Slider(this, 0.0, 255.0, 1.0)),
77  mRedText(new TextField(this, std::string(), LoseFocusOnTab_true,
78  nullptr, std::string(), false)),
79  // TRANSLATORS: colors tab. label.
80  mGreenLabel(new Label(this, _("Green:"))),
81  mGreenSlider(new Slider(this, 0.0, 255.0, 1.0)),
82  mGreenText(new TextField(this, std::string(), LoseFocusOnTab_true,
83  nullptr, std::string(), false)),
84  // TRANSLATORS: colors tab. label.
85  mBlueLabel(new Label(this, _("Blue:"))),
86  mBlueSlider(new Slider(this, 0.0, 255.0, 1.0)),
87  mBlueText(new TextField(this, std::string(), LoseFocusOnTab_true,
88  nullptr, std::string(), false))
89 {
90  // TRANSLATORS: settings colors tab name
91  setName(_("Colors"));
95 
96  // don't do anything with links
97  mPreview->setLinkHandler(nullptr);
98 
102 
104  mGradTypeSlider->setActionEventId("slider_grad");
107  mGradTypeSlider->setEnabled(false);
108 
109  // TRANSLATORS: color type
110  std::string longText = _("Static");
111 
112  const Font *const font = getFont();
113  // TRANSLATORS: color type
114  if (getFont()->getWidth(_("Pulse")) > font->getWidth(longText))
115  {
116  // TRANSLATORS: color type
117  longText = _("Pulse");
118  }
119  // TRANSLATORS: color type
120  if (getFont()->getWidth(_("Rainbow")) > font->getWidth(longText))
121  {
122  // TRANSLATORS: color type
123  longText = _("Rainbow");
124  }
125  // TRANSLATORS: color type
126  if (getFont()->getWidth(_("Spectrum")) > font->getWidth(longText))
127  {
128  // TRANSLATORS: color type
129  longText = _("Spectrum");
130  }
131 
132  mGradTypeText->setCaption(longText);
133 
135  mGradDelayText->setRange(20, 100);
136  mGradDelayText->setNumeric(true);
137  mGradDelayText->setEnabled(false);
138 
141  mGradDelaySlider->setActionEventId("slider_graddelay");
144 
145  mRedText->setWidth(40);
146  mRedText->setRange(0, 255);
147  mRedText->setNumeric(true);
148  mRedText->setEnabled(false);
149 
150  mRedSlider->setWidth(180);
152  mRedSlider->setActionEventId("slider_red");
154  mRedSlider->setEnabled(false);
155 
156  mGreenText->setWidth(40);
157  mGreenText->setRange(0, 255);
158  mGreenText->setNumeric(true);
159  mGreenText->setEnabled(false);
160 
161  mGreenSlider->setWidth(180);
163  mGreenSlider->setActionEventId("slider_green");
165  mGreenSlider->setEnabled(false);
166 
167  mBlueText->setWidth(40);
168  mBlueText->setRange(0, 255);
169  mBlueText->setNumeric(true);
170  mBlueText->setEnabled(false);
171 
172  mBlueSlider->setWidth(180);
174  mBlueSlider->setActionEventId("slider_blue");
176  mBlueSlider->setEnabled(false);
177 
179 
180  // Do the layout
181  LayoutHelper h(this);
182  ContainerPlacer place = h.getPlacer(0, 0);
183 
184  place(0, 0, mScroll, 6, 6).setPadding(2);
185  place(0, 6, mPreviewBox, 6, 1).setPadding(2);
186  place(0, 7, mGradTypeLabel, 3, 1);
187  place(3, 7, mGradTypeSlider, 1, 1);
188  place(4, 7, mGradTypeText, 2, 1).setPadding(1);
189  place(0, 8, mRedLabel, 3, 1);
190  place(3, 8, mRedSlider, 1, 1);
191  place(5, 8, mRedText, 1, 1).setPadding(1);
192  place(0, 9, mGreenLabel, 3, 1);
193  place(3, 9, mGreenSlider, 1, 1);
194  place(5, 9, mGreenText, 1, 1).setPadding(1);
195  place(0, 10, mBlueLabel, 3, 1);
196  place(3, 10, mBlueSlider, 1, 1);
197  place(5, 10, mBlueText, 1, 1).setPadding(1);
198  place(0, 11, mGradDelayLabel, 3, 1);
199  place(3, 11, mGradDelaySlider, 1, 1);
200  place(5, 11, mGradDelayText, 1, 1).setPadding(1);
201 
203 
204  setDimension(Rect(0, 0, 365, 350));
205 }
void setOpaque(Opaque opaque)
void setLinkHandler(LinkHandler *linkHandler)
Definition: browserbox.cpp:166
void setOpaque(Opaque opaque)
Definition: browserbox.h:75
Definition: font.h:90
int getWidth(const std::string &text) const
Definition: font.cpp:334
Definition: label.h:91
void setCaption(const std::string &caption)
Definition: label.cpp:264
void addSelectionListener(SelectionListener *const selectionListener)
Definition: listbox.cpp:435
Definition: rect.h:74
void setScrollPolicy(const ScrollPolicy hPolicy, const ScrollPolicy vPolicy)
void setHorizontalScrollPolicy(const ScrollPolicy hPolicy)
void setHeight(int height)
void setName(const std::string &name)
Definition: setuptab.h:68
SetupTab(const Widget2 *const widget)
Definition: setuptab.cpp:28
ListBox * mColorBox
Definition: setup_colors.h:59
Slider * mRedSlider
Definition: setup_colors.h:75
BrowserBox * mPreview
Definition: setup_colors.h:61
TextField * mGradDelayText
Definition: setup_colors.h:72
ScrollArea * mPreviewBox
Definition: setup_colors.h:63
Label * mGradDelayLabel
Definition: setup_colors.h:70
TextField * mBlueText
Definition: setup_colors.h:84
Label * mBlueLabel
Definition: setup_colors.h:82
Slider * mGradTypeSlider
Definition: setup_colors.h:67
TextPreview * mTextPreview
Definition: setup_colors.h:62
Label * mGradTypeText
Definition: setup_colors.h:68
Label * mGradTypeLabel
Definition: setup_colors.h:66
TextField * mRedText
Definition: setup_colors.h:76
Label * mRedLabel
Definition: setup_colors.h:74
Slider * mGradDelaySlider
Definition: setup_colors.h:71
Slider * mBlueSlider
Definition: setup_colors.h:83
TextField * mGreenText
Definition: setup_colors.h:80
ScrollArea * mScroll
Definition: setup_colors.h:60
Slider * mGreenSlider
Definition: setup_colors.h:79
Label * mGreenLabel
Definition: setup_colors.h:78
static const char *const rawmsg
Definition: setup_colors.h:57
Definition: slider.h:89
void setValue(const double value)
Definition: slider.cpp:474
void setNumeric(const bool numeric)
Definition: textfield.cpp:269
void setRange(const int min, const int max)
Definition: textfield.h:137
int getValue() const
Definition: textfield.cpp:286
void setWidth(const int width)
Definition: widget.cpp:133
void setEnabled(const bool enabled)
Definition: widget.h:352
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:596
void setDimension(const Rect &dimension)
Definition: widget.cpp:169
Font * getFont() const
Definition: widget.cpp:331
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:252
int getWidth() const
Definition: widget.h:221
#define CREATEWIDGETR(type,...)
Definition: createwidget.h:36
#define _(s)
Definition: gettext.h:35
const bool LoseFocusOnTab_true
const bool Opaque_false
Definition: opaque.h:30
const bool Opaque_true
Definition: opaque.h:30
UserPalette * userPalette
Definition: userpalette.cpp:34

References _, Widget::addActionListener(), ListBox::addSelectionListener(), Widget::getFont(), LayoutHelper::getPlacer(), TextField::getValue(), Widget::getWidth(), Font::getWidth(), mBlueLabel, mBlueSlider, mBlueText, mColorBox, mGradDelayLabel, mGradDelaySlider, mGradDelayText, mGradTypeLabel, mGradTypeSlider, mGradTypeText, mGreenLabel, mGreenSlider, mGreenText, mPreview, mPreviewBox, mRedLabel, mRedSlider, mRedText, mScroll, Opaque_false, Widget::setActionEventId(), Label::setCaption(), Widget::setDimension(), Widget::setEnabled(), ScrollArea::setHeight(), ScrollArea::setHorizontalScrollPolicy(), BrowserBox::setLinkHandler(), SetupTab::setName(), TextField::setNumeric(), BasicContainer2::setOpaque(), BrowserBox::setOpaque(), TextField::setRange(), ScrollArea::setScrollPolicy(), Slider::setValue(), Widget::setWidth(), and ScrollArea::SHOW_NEVER.

◆ ~Setup_Colors()

Setup_Colors::~Setup_Colors ( )

Definition at line 207 of file setup_colors.cpp.

208 {
209  if ((mPreviewBox != nullptr) && mPreviewBox->getContent() == mPreview)
211  else
213 }
Widget * getContent()
#define delete2(var)
Definition: delete2.h:25

References delete2, ScrollArea::getContent(), mPreview, mPreviewBox, and mTextPreview.

Member Function Documentation

◆ action()

void Setup_Colors::action ( const ActionEvent actionEvent)
virtual

Called when an action is recieved from a widget. It is used to be able to recieve a notification that an action has occured.

Parameters
actionEventThe event of the action.

Implements ActionListener.

Definition at line 215 of file setup_colors.cpp.

216 {
217  const std::string &eventId = event.getId();
218  if (eventId == "slider_grad")
219  {
220  updateGradType();
221  updateColor();
222  return;
223  }
224 
225  if (eventId == "slider_graddelay")
226  {
228  std::floor(mGradDelaySlider->getValue())));
229  updateColor();
230  return;
231  }
232  if (eventId == "slider_red")
233  {
234  mRedText->setText(toString(std::floor(mRedSlider->getValue())));
235  updateColor();
236  return;
237  }
238  if (eventId == "slider_green")
239  {
240  mGreenText->setText(toString(std::floor(mGreenSlider->getValue())));
241  updateColor();
242  return;
243  }
244  if (eventId == "slider_blue")
245  {
246  mBlueText->setText(toString(std::floor(mBlueSlider->getValue())));
247  updateColor();
248  return;
249  }
250 }
void updateColor() const
void updateGradType()
double getValue() const
Definition: slider.h:204
void setText(const std::string &text)
Definition: textfield.cpp:803
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774

References Slider::getValue(), mBlueSlider, mBlueText, mGradDelaySlider, mGradDelayText, mGreenSlider, mGreenText, mRedSlider, mRedText, TextField::setText(), Catch::toString(), updateColor(), and updateGradType().

◆ apply()

void Setup_Colors::apply ( )
virtual

Called when the Apply button is pressed in the setup window.

Implements SetupTab.

Definition at line 412 of file setup_colors.cpp.

413 {
414  if (userPalette != nullptr)
415  userPalette->commit();
416 }
void commit()
Definition: userpalette.h:133

References UserPalette::commit(), and userPalette.

◆ cancel()

void Setup_Colors::cancel ( )
virtual

Called when the Cancel button is pressed in the setup window.

Implements SetupTab.

Definition at line 418 of file setup_colors.cpp.

419 {
420  if (userPalette == nullptr)
421  return;
422 
424  const UserColorIdT type = static_cast<UserColorIdT>(
426  const Color *const col = &userPalette->getColor(type, 255U);
428  userPalette->getGradientType(type)));
429  const int delay = userPalette->getGradientDelay(type);
431  setEntry(mRedSlider, mRedText, col->r);
434 }
#define CAST_S32
Definition: cast.h:30
Definition: color.h:76
unsigned int b
Definition: color.h:245
unsigned int r
Definition: color.h:235
unsigned int g
Definition: color.h:240
static void setEntry(Slider *const s, TextField *const t, const int value)
void rollback()
GradientTypeT getGradientType(const UserColorIdT type) const
Definition: userpalette.h:185
int getGradientDelay(const UserColorIdT type) const
Definition: userpalette.h:196
const Color & getColor(UserColorIdT type, const unsigned int alpha)
Definition: userpalette.h:160
int getColorTypeAt(const int i)
UserColorId ::T UserColorIdT
Definition: usercolorid.h:99

References Color::b, CAST_S32, Color::g, UserPalette::getColor(), UserPalette::getColorTypeAt(), UserPalette::getGradientDelay(), UserPalette::getGradientType(), mBlueSlider, mBlueText, mGradDelaySlider, mGradDelayText, mGradTypeSlider, mGreenSlider, mGreenText, mRedSlider, mRedText, mSelected, Color::r, UserPalette::rollback(), setEntry(), Slider::setValue(), and userPalette.

◆ setEntry()

void Setup_Colors::setEntry ( Slider *const  s,
TextField *const  t,
const int  value 
)
staticprivate

Definition at line 403 of file setup_colors.cpp.

405 {
406  if (s != nullptr)
407  s->setValue(value);
408  if (t != nullptr)
409  t->setText(toString(value));
410 }

References TextField::setText(), Slider::setValue(), and Catch::toString().

Referenced by cancel(), and valueChanged().

◆ updateColor()

void Setup_Colors::updateColor ( ) const
private

Definition at line 469 of file setup_colors.cpp.

470 {
471  if (mSelected == -1 || (userPalette == nullptr))
472  return;
473 
474  const UserColorIdT type = static_cast<UserColorIdT>(
476  const GradientTypeT grad = static_cast<GradientTypeT>(
478  const int delay = CAST_S32(mGradDelaySlider->getValue());
479  userPalette->setGradient(type, grad);
480  userPalette->setGradientDelay(type, delay);
481 
482  if (grad == GradientType::STATIC)
483  {
484  userPalette->setColor(type,
488  }
489  else if (grad == GradientType::PULSE)
490  {
495  255U));
496  }
497 }
void setColor(const UserColorIdT type, const int r, const int g, const int b)
void setGradientDelay(const UserColorIdT type, const int delay)
Definition: userpalette.h:109
void setGradient(const UserColorIdT type, const GradientTypeT grad)
void setTestColor(const UserColorIdT type, const Color &color)
Definition: userpalette.h:84
GradientType ::T GradientTypeT
Definition: gradienttype.h:38

References CAST_S32, UserPalette::getColorTypeAt(), Slider::getValue(), mBlueSlider, mGradDelaySlider, mGradTypeSlider, mGreenSlider, mRedSlider, mSelected, GradientType::PULSE, UserPalette::setColor(), UserPalette::setGradient(), UserPalette::setGradientDelay(), UserPalette::setTestColor(), GradientType::STATIC, and userPalette.

Referenced by action().

◆ updateGradType()

void Setup_Colors::updateGradType ( )
private

Definition at line 436 of file setup_colors.cpp.

437 {
438  if (mSelected == -1 || (userPalette == nullptr))
439  return;
440 
442  const UserColorIdT type = static_cast<UserColorIdT>(
444  const GradientTypeT grad = userPalette->getGradientType(type);
445 
447  // TRANSLATORS: color type
448  (grad == GradientType::STATIC) ? _("Static") :
449  // TRANSLATORS: color type
450  (grad == GradientType::PULSE) ? _("Pulse") :
451  // TRANSLATORS: color type
452  (grad == GradientType::RAINBOW) ? _("Rainbow") : _("Spectrum"));
453 
454  const bool enable = (grad == GradientType::STATIC ||
455  grad == GradientType::PULSE);
456  const bool delayEnable = true;
457 
458  mGradDelayText->setEnabled(delayEnable);
459  mGradDelaySlider->setEnabled(delayEnable);
460 
461  mRedText->setEnabled(enable);
462  mRedSlider->setEnabled(enable);
463  mGreenText->setEnabled(enable);
464  mGreenSlider->setEnabled(enable);
465  mBlueText->setEnabled(enable);
466  mBlueSlider->setEnabled(enable);
467 }
int getSelected() const
Definition: listbox.h:168

References _, UserPalette::getColorTypeAt(), UserPalette::getGradientType(), ListBox::getSelected(), mBlueSlider, mBlueText, mColorBox, mGradDelaySlider, mGradDelayText, mGradTypeText, mGreenSlider, mGreenText, mRedSlider, mRedText, mSelected, GradientType::PULSE, GradientType::RAINBOW, Label::setCaption(), Widget::setEnabled(), GradientType::STATIC, and userPalette.

Referenced by action(), and valueChanged().

◆ valueChanged()

void Setup_Colors::valueChanged ( const SelectionEvent event)
virtual

Called when the value of a selection has been changed in a Widget. It is used to be able to recieve a notification that a value has been changed.

Parameters
eventThe event of the value change.

Reimplemented from SelectionListener.

Definition at line 252 of file setup_colors.cpp.

253 {
254  if (userPalette == nullptr)
255  return;
256 
258  const UserColorIdT type = static_cast<UserColorIdT>(
260  const Color *col = &userPalette->getColor(type, 255U);
261  const GradientTypeT grad = userPalette->getGradientType(type);
262  const int delay = userPalette->getGradientDelay(type);
263  const Visible showControls = fromBool(grad != GradientType::LABEL,
264  Visible);
265  mPreview->setVisible(showControls);
266  mPreviewBox->setVisible(showControls);
267  mTextPreview->setVisible(showControls);
268  mGradTypeLabel->setVisible(showControls);
269  mGradTypeSlider->setVisible(showControls);
270  mGradTypeText->setVisible(showControls);
271  mGradDelayLabel->setVisible(showControls);
272  mGradDelaySlider->setVisible(showControls);
273  mGradDelayText->setVisible(showControls);
274  mRedLabel->setVisible(showControls);
275  mRedSlider->setVisible(showControls);
276  mRedText->setVisible(showControls);
277  mGreenLabel->setVisible(showControls);
278  mGreenSlider->setVisible(showControls);
279  mGreenText->setVisible(showControls);
280  mBlueLabel->setVisible(showControls);
281  mBlueSlider->setVisible(showControls);
282  mBlueText->setVisible(showControls);
283 
284  mPreview->clearRows();
288  mTextPreview->setTextBGColor(nullptr);
290  mTextPreview->setShadow(true);
291  mTextPreview->setOutline(true);
292  mTextPreview->useTextAlpha(false);
293 
294 // probably need combite both switches and add all mssing color ids.
295 
296  PRAGMA45(GCC diagnostic push)
297  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
298  switch (type)
299  {
308  case UserColorId::NET:
309  mTextPreview->setBGColor(col);
311  mTextPreview->setOutline(false);
312  mTextPreview->setShadow(false);
313  break;
316  if (gui != nullptr)
319  mTextPreview->setOutline(false);
320  mTextPreview->setShadow(false);
321  break;
328  case UserColorId::MISS:
336  mTextPreview->setShadow(false);
337  break;
338  default:
339  break;
340  }
341 
342  switch (type)
343  {
369  case UserColorId::NET:
370  // TRANSLATORS: colors tab. label.
371  mGradDelayLabel->setCaption(_("Alpha:"));
372  mGradDelayText->setRange(0, 255);
373  mGradDelaySlider->setScale(0, 255);
374  break;
375  default:
376  // TRANSLATORS: colors tab. label.
377  mGradDelayLabel->setCaption(_("Delay:"));
378  mGradDelayText->setRange(20, 100);
379  mGradDelaySlider->setScale(20, 100);
380  break;
381  }
382  PRAGMA45(GCC diagnostic pop)
383  if (grad != GradientType::STATIC && grad != GradientType::PULSE)
384  { // If nonstatic color, don't display the current, but the committed
385  // color at the sliders
386  col = &userPalette->getCommittedColor(type);
387  }
388  else if (grad == GradientType::PULSE)
389  {
390  col = &userPalette->getTestColor(type);
391  }
392 
394  setEntry(mRedSlider, mRedText, col->r);
397 
399  updateGradType();
401 }
#define fromBool(val, name)
Definition: booldefines.h:49
void clearRows()
Definition: browserbox.cpp:359
Font * getFont() const
Definition: gui.h:160
void setContent(Widget *widget)
void setScale(const double scaleStart, const double scaleEnd)
Definition: slider.cpp:468
void setTextColor(const Color *color)
Definition: textpreview.h:46
void setShadow(const bool shadow)
Definition: textpreview.h:90
void setTextBGColor(const Color *color)
Definition: textpreview.h:66
void useTextAlpha(const bool alpha)
Definition: textpreview.h:57
void setOpaque(const Opaque opaque)
Definition: textpreview.h:116
void setBGColor(const Color *color)
Definition: textpreview.h:74
void setFont(Font *const font)
Definition: textpreview.h:82
void setOutline(const bool outline)
Definition: textpreview.h:98
const Color & getTestColor(const UserColorIdT type) const
Definition: userpalette.h:74
const Color & getCommittedColor(const UserColorIdT type) const
Definition: userpalette.h:61
void setVisible(Visible visible)
Definition: widget.cpp:225
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wredundant-decls") PRAGMA45(GCC diagnostic pop) class TestMain
Gui * gui
Definition: gui.cpp:111
Font * boldFont
Definition: gui.cpp:112
@ AIR_COLLISION_HIGHLIGHT
Definition: usercolorid.h:81
@ HIT_PLAYER_MONSTER
Definition: usercolorid.h:70
@ MONSTER_COLLISION_HIGHLIGHT
Definition: usercolorid.h:83
@ HOME_PLACE_BORDER
Definition: usercolorid.h:95
@ GROUNDTOP_COLLISION_HIGHLIGHT
Definition: usercolorid.h:84
@ HIT_LOCAL_PLAYER_MONSTER
Definition: usercolorid.h:74
@ HIT_LOCAL_PLAYER_MISS
Definition: usercolorid.h:76
@ HIT_MONSTER_PLAYER
Definition: usercolorid.h:71
@ MONSTER_ATTACK_RANGE
Definition: usercolorid.h:90
@ HIT_LOCAL_PLAYER_CRITICAL
Definition: usercolorid.h:75
@ ATTACK_RANGE_BORDER
Definition: usercolorid.h:89
@ SKILL_ATTACK_RANGE
Definition: usercolorid.h:91
@ COLLISION_HIGHLIGHT
Definition: usercolorid.h:80
@ WATER_COLLISION_HIGHLIGHT
Definition: usercolorid.h:82
@ PORTAL_HIGHLIGHT
Definition: usercolorid.h:79
@ WALKABLE_HIGHLIGHT
Definition: usercolorid.h:85
bool Visible
Definition: visible.h:30

References _, UserColorId::AIR_COLLISION_HIGHLIGHT, UserColorId::ATTACK_RANGE, UserColorId::ATTACK_RANGE_BORDER, Color::b, boldFont, CAST_S32, BrowserBox::clearRows(), UserColorId::COLLISION_HIGHLIGHT, UserColorId::ELEMENTAL_HP, UserColorId::ELEMENTAL_HP2, UserColorId::EXP_INFO, UserColorId::FLOOR_ITEM_TEXT, fromBool, Color::g, UserPalette::getColor(), UserPalette::getColorTypeAt(), UserPalette::getCommittedColor(), Gui::getFont(), UserPalette::getGradientDelay(), UserPalette::getGradientType(), ListBox::getSelected(), UserPalette::getTestColor(), UserColorId::GROUNDTOP_COLLISION_HIGHLIGHT, gui, UserColorId::HIT_CRITICAL, UserColorId::HIT_LOCAL_PLAYER_CRITICAL, UserColorId::HIT_LOCAL_PLAYER_MISS, UserColorId::HIT_LOCAL_PLAYER_MONSTER, UserColorId::HIT_MONSTER_PLAYER, UserColorId::HIT_PLAYER_MONSTER, UserColorId::HOME_PLACE, UserColorId::HOME_PLACE_BORDER, UserColorId::HOMUN_HP, UserColorId::HOMUN_HP2, GradientType::LABEL, mBlueLabel, mBlueSlider, mBlueText, mColorBox, UserColorId::MERC_HP, UserColorId::MERC_HP2, mGradDelayLabel, mGradDelaySlider, mGradDelayText, mGradTypeLabel, mGradTypeSlider, mGradTypeText, mGreenLabel, mGreenSlider, mGreenText, UserColorId::MISS, UserColorId::MONSTER_ATTACK_RANGE, UserColorId::MONSTER_COLLISION_HIGHLIGHT, UserColorId::MONSTER_HP, UserColorId::MONSTER_HP2, mPreview, mPreviewBox, mRedLabel, mRedSlider, mRedText, mSelected, mTextPreview, UserColorId::NET, Opaque_false, Opaque_true, UserColorId::PARTICLE, UserColorId::PICKUP_INFO, UserColorId::PLAYER_HP, UserColorId::PLAYER_HP2, UserColorId::PORTAL_HIGHLIGHT, PRAGMA45(), GradientType::PULSE, Color::r, UserColorId::ROAD_POINT, TextPreview::setBGColor(), Label::setCaption(), ScrollArea::setContent(), Widget::setEnabled(), setEntry(), TextPreview::setFont(), TextPreview::setOpaque(), TextPreview::setOutline(), TextField::setRange(), Slider::setScale(), TextPreview::setShadow(), TextPreview::setTextBGColor(), TextPreview::setTextColor(), Slider::setValue(), Widget::setVisible(), UserColorId::SKILL_ATTACK_RANGE, GradientType::STATIC, updateGradType(), userPalette, TextPreview::useTextAlpha(), UserColorId::WALKABLE_HIGHLIGHT, and UserColorId::WATER_COLLISION_HIGHLIGHT.

Field Documentation

◆ mBlueLabel

Label* Setup_Colors::mBlueLabel
private

Definition at line 82 of file setup_colors.h.

Referenced by Setup_Colors(), and valueChanged().

◆ mBlueSlider

Slider* Setup_Colors::mBlueSlider
private

Definition at line 83 of file setup_colors.h.

Referenced by action(), cancel(), Setup_Colors(), updateColor(), updateGradType(), and valueChanged().

◆ mBlueText

TextField* Setup_Colors::mBlueText
private

Definition at line 84 of file setup_colors.h.

Referenced by action(), cancel(), Setup_Colors(), updateGradType(), and valueChanged().

◆ mColorBox

ListBox* Setup_Colors::mColorBox
private

Definition at line 59 of file setup_colors.h.

Referenced by Setup_Colors(), updateGradType(), and valueChanged().

◆ mGradDelayLabel

Label* Setup_Colors::mGradDelayLabel
private

Definition at line 70 of file setup_colors.h.

Referenced by Setup_Colors(), and valueChanged().

◆ mGradDelaySlider

Slider* Setup_Colors::mGradDelaySlider
private

Definition at line 71 of file setup_colors.h.

Referenced by action(), cancel(), Setup_Colors(), updateColor(), updateGradType(), and valueChanged().

◆ mGradDelayText

TextField* Setup_Colors::mGradDelayText
private

Definition at line 72 of file setup_colors.h.

Referenced by action(), cancel(), Setup_Colors(), updateGradType(), and valueChanged().

◆ mGradTypeLabel

Label* Setup_Colors::mGradTypeLabel
private

Definition at line 66 of file setup_colors.h.

Referenced by Setup_Colors(), and valueChanged().

◆ mGradTypeSlider

Slider* Setup_Colors::mGradTypeSlider
private

Definition at line 67 of file setup_colors.h.

Referenced by cancel(), Setup_Colors(), updateColor(), and valueChanged().

◆ mGradTypeText

Label* Setup_Colors::mGradTypeText
private

Definition at line 68 of file setup_colors.h.

Referenced by Setup_Colors(), updateGradType(), and valueChanged().

◆ mGreenLabel

Label* Setup_Colors::mGreenLabel
private

Definition at line 78 of file setup_colors.h.

Referenced by Setup_Colors(), and valueChanged().

◆ mGreenSlider

Slider* Setup_Colors::mGreenSlider
private

Definition at line 79 of file setup_colors.h.

Referenced by action(), cancel(), Setup_Colors(), updateColor(), updateGradType(), and valueChanged().

◆ mGreenText

TextField* Setup_Colors::mGreenText
private

Definition at line 80 of file setup_colors.h.

Referenced by action(), cancel(), Setup_Colors(), updateGradType(), and valueChanged().

◆ mPreview

BrowserBox* Setup_Colors::mPreview
private

Definition at line 61 of file setup_colors.h.

Referenced by Setup_Colors(), valueChanged(), and ~Setup_Colors().

◆ mPreviewBox

ScrollArea* Setup_Colors::mPreviewBox
private

Definition at line 63 of file setup_colors.h.

Referenced by Setup_Colors(), valueChanged(), and ~Setup_Colors().

◆ mRedLabel

Label* Setup_Colors::mRedLabel
private

Definition at line 74 of file setup_colors.h.

Referenced by Setup_Colors(), and valueChanged().

◆ mRedSlider

Slider* Setup_Colors::mRedSlider
private

Definition at line 75 of file setup_colors.h.

Referenced by action(), cancel(), Setup_Colors(), updateColor(), updateGradType(), and valueChanged().

◆ mRedText

TextField* Setup_Colors::mRedText
private

Definition at line 76 of file setup_colors.h.

Referenced by action(), cancel(), Setup_Colors(), updateGradType(), and valueChanged().

◆ mScroll

ScrollArea* Setup_Colors::mScroll
private

Definition at line 60 of file setup_colors.h.

Referenced by Setup_Colors().

◆ mSelected

int Setup_Colors::mSelected
private

Definition at line 64 of file setup_colors.h.

Referenced by cancel(), updateColor(), updateGradType(), and valueChanged().

◆ mTextPreview

TextPreview* Setup_Colors::mTextPreview
private

Definition at line 62 of file setup_colors.h.

Referenced by valueChanged(), and ~Setup_Colors().

◆ rawmsg

const char *const Setup_Colors::rawmsg
staticprivate
Initial value:
=
(const_cast <char*>( "This is what the color looks like" ))

Definition at line 57 of file setup_colors.h.


The documentation for this class was generated from the following files: