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

#include <skillrectanglelistbox.h>

Inheritance diagram for SkillRectangleListBox:
Widget MouseListener Widget2

Public Member Functions

 SkillRectangleListBox (const Widget2 *const widget, SkillModel *const model)
 
 ~SkillRectangleListBox ()
 
SkillInfogetSelectedInfo () const
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
const SkillInfogetSkillByEvent (const MouseEvent &event) const
 
int getSelectionByEvent (const MouseEvent &event) const
 
void mouseMoved (MouseEvent &event)
 
void mouseDragged (MouseEvent &event)
 
void mousePressed (MouseEvent &event)
 
void mouseReleased (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
void updateAlpha ()
 
void setSelected (const int selected)
 
- 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
 
virtual void logic ()
 
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 ()
 
virtual void setFocusHandler (FocusHandler *const focusHandler)
 
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
 
virtual WidgetgetWidgetAt (int x, int y)
 
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 Rect getChildrenArea ()
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
virtual void moveToTop (Widget *widget)
 
virtual void moveToBottom (Widget *widget)
 
virtual void focusNext ()
 
virtual void focusPrevious ()
 
virtual void showWidgetPart (Widget *const widget, const Rect &area)
 
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 MouseListener
virtual ~MouseListener ()
 
virtual void mouseEntered (MouseEvent &event)
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 

Private Attributes

Color mHighlightColor
 
Color mTextColor
 
Color mTextColor2
 
Color mCooldownColor
 
Color mForegroundSelectedColor
 
Color mForegroundSelectedColor2
 
SkillModelmModel
 
SkinmSkin
 
int mSelected
 
int mPadding
 
int mBoxWidth
 
int mBoxHeight
 
int mIconXOffset
 
int mIconYOffset
 
int mTextXOffset
 
int mTextYOffset
 
bool mSkillClicked
 

Static Private Attributes

static float mAlpha = 1.0
 

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 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 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 MouseListener
 MouseListener ()
 
- 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 48 of file skillrectanglelistbox.h.

Constructor & Destructor Documentation

◆ SkillRectangleListBox()

SkillRectangleListBox::SkillRectangleListBox ( const Widget2 *const  widget,
SkillModel *const  model 
)
inline

Definition at line 52 of file skillrectanglelistbox.h.

53  :
54  Widget(widget),
55  MouseListener(),
56  mHighlightColor(getThemeColor(ThemeColorId::HIGHLIGHT, 255U)),
58  mTextColor2(getThemeColor(ThemeColorId::TEXT_OUTLINE, 255U)),
61  ThemeColorId::LISTBOX_SELECTED, 255U)),
63  ThemeColorId::LISTBOX_SELECTED_OUTLINE, 255U)),
64  mModel(model),
65  mSkin(nullptr),
66  mSelected(-1),
67  mPadding(2),
68  mBoxWidth(80),
69  mBoxHeight(70),
70  mIconXOffset(24),
71  mIconYOffset(10),
72  mTextXOffset(0),
73  mTextYOffset(44),
74  mSkillClicked(false)
75  {
76  if (theme != nullptr)
77  {
78  mSkin = theme->load("skillrectanglelistbox.xml",
79  "listbox.xml",
80  true,
82  }
83 
84  if (mSkin != nullptr)
85  {
87  mBoxWidth = mSkin->getOption("boxWidth", 80);
88  mBoxHeight = mSkin->getOption("boxHeight", 70);
89  mIconXOffset = mSkin->getOption("iconXOffset", 24);
90  mIconYOffset = mSkin->getOption("iconYOffset", 10);
91  mTextXOffset = mSkin->getOption("textXOffset", 0);
92  mTextYOffset = mSkin->getOption("textYOffset", 44);
93  }
94  Font *const font = getFont();
95  int minWidth = font->getWidth("Lvl: 10/10") + mTextXOffset + 2;
96  int minHeight = font->getHeight() + mTextYOffset + 2;
97  if (mBoxWidth < minWidth)
98  mBoxWidth = minWidth;
99  if (mBoxHeight < minHeight)
100  mBoxHeight = minHeight;
101  int maxX = 0;
102  int maxY = 0;
103  for (int i = 0;
104  i < model->getNumberOfElements();
105  ++i)
106  {
107  SkillInfo *const e = model->getSkillAt(i);
108  if (e != nullptr)
109  {
110  if (e->x > maxX)
111  maxX = e->x;
112  if (e->y > maxY)
113  maxY = e->y;
114  }
115  }
116  maxX ++;
117  maxY ++;
118  setWidth(maxX * mBoxWidth);
119  setHeight(maxY * mBoxHeight);
120  addMouseListener(this);
121  }
Definition: font.h:90
int getHeight() const
Definition: font.cpp:362
int getWidth(const std::string &text) const
Definition: font.cpp:334
SkillInfo * getSkillAt(const int i) const
Definition: skillmodel.cpp:39
int getNumberOfElements()
Definition: skillmodel.h:46
int getOption(const std::string &name) const
Definition: skin.h:106
int getPadding() const
Definition: skin.h:100
static std::string getThemePath()
Definition: theme.h:67
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:179
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:45
void setWidth(const int width)
Definition: widget.cpp:133
Widget(const Widget2 *const widget)
Definition: widget.cpp:85
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:292
void setHeight(const int height)
Definition: widget.cpp:140
Font * getFont() const
Definition: widget.cpp:331
@ SKILL_COOLDOWN
Definition: sp.h:256
Theme * theme
Definition: theme.cpp:62

References Widget::addMouseListener(), Widget::getFont(), Font::getHeight(), SkillModel::getNumberOfElements(), Skin::getOption(), Skin::getPadding(), SkillModel::getSkillAt(), Theme::getThemePath(), Font::getWidth(), Theme::load(), mBoxHeight, mBoxWidth, mIconXOffset, mIconYOffset, mPadding, mSkin, mTextXOffset, mTextYOffset, Widget::setHeight(), Widget::setWidth(), theme, SkillInfo::x, and SkillInfo::y.

◆ ~SkillRectangleListBox()

SkillRectangleListBox::~SkillRectangleListBox ( )
inline

Definition at line 125 of file skillrectanglelistbox.h.

126  {
127  delete2(mModel)
128  }
#define delete2(var)
Definition: delete2.h:25

References delete2, and mModel.

Member Function Documentation

◆ draw()

void SkillRectangleListBox::draw ( Graphics *const  graphics)
inlinevirtual

Draws the widget. It is called by the parent widget when it is time for the widget to draw itself. The graphics object is set up so that all drawing is relative to the widget, i.e coordinate (0,0) is the top left corner of the widget. It is not possible to draw outside of a widget's dimension.

Parameters
graphicsaA graphics object to draw with.

Implements Widget.

Definition at line 144 of file skillrectanglelistbox.h.

145  {
146  if (mModel == nullptr)
147  return;
148 
149  SkillModel *const model = mModel;
150  updateAlpha();
151 
152  int maxX = 0;
153  int maxY = 0;
154  mHighlightColor.a = CAST_S32(mAlpha * 255.0F);
155  graphics->setColor(mHighlightColor);
156  Font *const font = getFont();
157  if (mSelected >= 0)
158  {
159  SkillInfo *const e = model->getSkillAt(mSelected);
160  if (e != nullptr)
161  {
162  const int x = e->x * mBoxWidth + mPadding;
163  const int y = e->y * mBoxHeight + mPadding;
164 
165  graphics->fillRectangle(Rect(x, y,
167 
168  const int xOffset = (mBoxWidth -
169  font->getWidth(e->skillLevel)) / 2;
170  font->drawString(graphics,
173  e->skillLevel,
174  x + mTextXOffset + xOffset,
175  y + mTextYOffset);
176  }
177  }
178 
179  // +++ need split drawing icons and text
180  for (int i = 0;
181  i < model->getNumberOfElements();
182  ++i)
183  {
184  SkillInfo *const e = model->getSkillAt(i);
185  if (e != nullptr)
186  {
187  if (e->x > maxX)
188  maxX = e->x;
189  if (e->y > maxY)
190  maxY = e->y;
191  const SkillData *const data = e->data;
192  const int x = e->x * mBoxWidth + mPadding;
193  const int y = e->y * mBoxHeight + mPadding;
194 
195  graphics->drawImage(data->icon,
196  x + mIconXOffset,
197  y + mIconYOffset);
198 
199  if (i != mSelected)
200  {
201  const int width1 = font->getWidth(e->skillLevel);
202  const int xOffset = (mBoxWidth -
203  width1) / 2;
204  font->drawString(graphics,
205  mTextColor,
206  mTextColor2,
207  e->skillLevel,
208  x + mTextXOffset + xOffset,
209  y + mTextYOffset);
210  if (e->skillLevelWidth < 0)
211  {
212  // Add one for padding
213  e->skillLevelWidth = width1 + 1;
214  }
215  }
216  else
217  {
218  if (e->skillLevelWidth < 0)
219  {
220  // Add one for padding
221  e->skillLevelWidth = font->getWidth(
222  e->skillLevel) + 1;
223  }
224  }
225  }
226  }
227  maxX ++;
228  maxY ++;
229  setWidth(maxX * mBoxWidth);
230  setHeight(maxY * mBoxHeight);
231  }
#define CAST_S32
Definition: cast.h:30
unsigned int a
Definition: color.h:251
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
Definition: font.cpp:254
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
virtual void fillRectangle(const Rect &rectangle)=0
virtual void setColor(const Color &color)
Definition: graphics.h:320
Definition: rect.h:74
uint32_t data
int skillLevelWidth
Definition: skillinfo.h:68
std::string skillLevel
Definition: skillinfo.h:52
SkillData * data
Definition: skillinfo.h:63

References Color::a, CAST_S32, data, SkillInfo::data, Font::drawString(), Widget::getFont(), SkillModel::getNumberOfElements(), SkillModel::getSkillAt(), Font::getWidth(), mAlpha, mBoxHeight, mBoxWidth, mForegroundSelectedColor, mHighlightColor, mIconXOffset, mIconYOffset, mModel, mPadding, mSelected, mTextColor, mTextColor2, mTextXOffset, mTextYOffset, Widget::setHeight(), Widget::setWidth(), SkillInfo::skillLevel, SkillInfo::skillLevelWidth, updateAlpha(), x, SkillInfo::x, y, and SkillInfo::y.

Referenced by safeDraw().

◆ getSelectedInfo()

SkillInfo* SkillRectangleListBox::getSelectedInfo ( ) const
inline

Definition at line 130 of file skillrectanglelistbox.h.

131  {
132  if (mModel == nullptr)
133  return nullptr;
134  const int selected = mSelected;
135  if (selected < 0 ||
136  selected > mModel->getNumberOfElements())
137  {
138  return nullptr;
139  }
140 
141  return mModel->getSkillAt(selected);
142  }

References SkillModel::getNumberOfElements(), SkillModel::getSkillAt(), mModel, and mSelected.

Referenced by SkillTab::getSelectedInfo().

◆ getSelectionByEvent()

int SkillRectangleListBox::getSelectionByEvent ( const MouseEvent event) const
inline

Definition at line 258 of file skillrectanglelistbox.h.

259  {
260  if (mModel == nullptr)
261  return -1;
262  const int posX = (event.getX() - mPadding) / mBoxWidth;
263  const int posY = (event.getY() - mPadding) / mBoxHeight;
264  for (int i = 0;
266  ++i)
267  {
268  SkillInfo *const e = mModel->getSkillAt(i);
269  if (e != nullptr)
270  {
271  if (posX == e->x && posY == e->y)
272  return i;
273  }
274  }
275  return -1;
276  }

References SkillModel::getNumberOfElements(), SkillModel::getSkillAt(), mBoxHeight, mBoxWidth, mModel, mPadding, SkillInfo::x, and SkillInfo::y.

Referenced by mouseDragged(), and mouseReleased().

◆ getSkillByEvent()

const SkillInfo* SkillRectangleListBox::getSkillByEvent ( const MouseEvent event) const
inline

Definition at line 238 of file skillrectanglelistbox.h.

239  {
240  if (mModel == nullptr)
241  return nullptr;
242  const int posX = (event.getX() - mPadding) / mBoxWidth;
243  const int posY = (event.getY() - mPadding) / mBoxHeight;
244  for (int i = 0;
246  ++i)
247  {
248  SkillInfo *const e = mModel->getSkillAt(i);
249  if (e != nullptr)
250  {
251  if (posX == e->x && posY == e->y)
252  return e;
253  }
254  }
255  return nullptr;
256  }

References SkillModel::getNumberOfElements(), SkillModel::getSkillAt(), mBoxHeight, mBoxWidth, mModel, mPadding, SkillInfo::x, and SkillInfo::y.

Referenced by mouseDragged(), mouseMoved(), and mousePressed().

◆ mouseDragged()

void SkillRectangleListBox::mouseDragged ( MouseEvent event)
inlinevirtual

Called when the mouse has moved and the mouse has previously been pressed on the widget.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 295 of file skillrectanglelistbox.h.

296  {
297  if (event.getButton() != MouseButton::LEFT)
298  return;
299  setSelected(std::max(0, getSelectionByEvent(event)));
300 
301  if (dragDrop.isEmpty())
302  {
303  if (mSkillClicked)
304  {
305  mSkillClicked = false;
306  const SkillInfo *const skill = getSkillByEvent(event);
307  if (skill == nullptr)
308  return;
311  dragDrop.setItemData(skill->toDataStr());
312  }
313  }
314  }
void setItem(const int item)
Definition: dragdrop.h:238
void dragSkill(const SkillInfo *const info, const DragDropSourceT source, const int tag)
Definition: dragdrop.h:152
bool isEmpty() const
Definition: dragdrop.h:196
void setItemData(const std::string &data)
Definition: dragdrop.h:78
MouseButtonT getButton() const
Definition: mouseevent.h:116
const SkillInfo * getSkillByEvent(const MouseEvent &event) const
int getSelectionByEvent(const MouseEvent &event) const
void setSelected(const int selected)
DragDrop dragDrop
bool skill(InputEvent &event)
Definition: commands.cpp:97
const int SKILL_MIN_ID
Definition: skill.h:25

References dragDrop, DragDrop::dragSkill(), getSelectionByEvent(), getSkillByEvent(), DragDrop::isEmpty(), MouseButton::LEFT, mSkillClicked, DragDrop::setItem(), DragDrop::setItemData(), setSelected(), Actions::skill(), SKILL_MIN_ID, and DragDropSource::Skills.

◆ mouseExited()

void SkillRectangleListBox::mouseExited ( MouseEvent event)
inlinevirtual

Called when the mouse has exited the widget area.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 367 of file skillrectanglelistbox.h.

368  {
369  skillPopup->hide();
370  }
void hide()
Definition: popup.cpp:265
SkillPopup * skillPopup
Definition: skillpopup.cpp:42

References Popup::hide(), and skillPopup.

◆ mouseMoved()

void SkillRectangleListBox::mouseMoved ( MouseEvent event)
inlinevirtual

Called when the mouse has moved in the widget area and no mouse button has been pressed (i.e no widget is being dragged).

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 278 of file skillrectanglelistbox.h.

279  {
280  if ((viewport == nullptr) || !dragDrop.isEmpty())
281  return;
282 
283  const SkillInfo *const skill = getSkillByEvent(event);
284  if (skill == nullptr)
285  return;
287  skill->customSelectedLevel,
288  skill->customCastType,
289  skill->customOffsetX,
290  skill->customOffsetY);
292  viewport->mMouseY);
293  }
void position(const int x, const int y)
Definition: popup.cpp:235
void show(const SkillInfo *const skill, const int level, const CastTypeT type, const int offsetX, const int offsetY)
Definition: skillpopup.cpp:106
int mMouseX
Definition: viewport.h:154
int mMouseY
Definition: viewport.h:155
Viewport * viewport
Definition: viewport.cpp:36

References dragDrop, getSkillByEvent(), DragDrop::isEmpty(), Viewport::mMouseX, Viewport::mMouseY, Popup::position(), SkillPopup::show(), Actions::skill(), skillPopup, and viewport.

◆ mousePressed()

void SkillRectangleListBox::mousePressed ( MouseEvent event)
inlinevirtual

Called when a mouse button has been pressed on the widget area.

NOTE: A mouse press is NOT equal to a mouse click. Use mouseClickMessage to check for mouse clicks.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 316 of file skillrectanglelistbox.h.

317  {
318  const MouseButtonT button = event.getButton();
319  if (button == MouseButton::LEFT ||
320  button == MouseButton::RIGHT)
321  {
322  const SkillInfo *const skill = getSkillByEvent(event);
323  if (skill == nullptr)
324  return;
325  event.consume();
326  mSkillClicked = true;
327  SkillModel *const model = mModel;
328  if ((model != nullptr) &&
329  mSelected >= 0 &&
330  model->getSkillAt(mSelected) == skill)
331  {
332  skillPopup->hide();
333 
334  const int x = skill->x * mBoxWidth + mPadding;
335  const int y = skill->y * mBoxHeight + mPadding;
336  Font *const font = getFont();
337  const int height = font->getHeight();
338  const int eventX = event.getX();
339  const int eventY = event.getY() - mTextYOffset;
340  if (button == MouseButton::LEFT)
341  {
342  if (eventX >= x + mTextXOffset &&
343  eventX <= x + mBoxWidth - mTextXOffset &&
344  eventY >= y &&
345  eventY <= y + height)
346  {
348  }
349  }
350  else if (button == MouseButton::RIGHT)
351  {
353  }
354  }
355  }
356  }
void showSkillLevelPopup(const SkillInfo *const info)
Definition: popupmenu.cpp:2356
void showSkillPopup(const SkillInfo *const info)
Definition: popupmenu.cpp:2263
MouseButton ::T MouseButtonT
Definition: mousebutton.h:78
PopupMenu * popupMenu
Definition: popupmenu.cpp:103

References Widget::getFont(), Font::getHeight(), SkillModel::getSkillAt(), getSkillByEvent(), Popup::hide(), MouseButton::LEFT, mBoxHeight, mBoxWidth, mModel, mPadding, mSelected, mSkillClicked, mTextXOffset, mTextYOffset, popupMenu, MouseButton::RIGHT, PopupMenu::showSkillLevelPopup(), PopupMenu::showSkillPopup(), Actions::skill(), skillPopup, x, and y.

◆ mouseReleased()

void SkillRectangleListBox::mouseReleased ( MouseEvent event)
inlinevirtual

Called when a mouse button has been released on the widget area.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 358 of file skillrectanglelistbox.h.

359  {
360  if (event.getButton() == MouseButton::LEFT)
361  {
362  setSelected(std::max(0, getSelectionByEvent(event)));
364  }
365  }
void distributeActionEvent()
Definition: widget.cpp:493

References Widget::distributeActionEvent(), getSelectionByEvent(), MouseButton::LEFT, and setSelected().

◆ safeDraw()

void SkillRectangleListBox::safeDraw ( Graphics *const  graphics)
inlinevirtual

Implements Widget.

Definition at line 233 of file skillrectanglelistbox.h.

234  {
235  SkillRectangleListBox::draw(graphics);
236  }
void draw(Graphics *const graphics)

References draw().

◆ setSelected()

void SkillRectangleListBox::setSelected ( const int  selected)
inline

Definition at line 381 of file skillrectanglelistbox.h.

382  {
383  if (mModel == nullptr)
384  {
385  mSelected = -1;
386  }
387  else
388  {
389  if (selected < 0)
390  mSelected = -1;
391  else if (selected >= mModel->getNumberOfElements())
393  else
394  mSelected = selected;
395  }
396  }

References SkillModel::getNumberOfElements(), mModel, and mSelected.

Referenced by mouseDragged(), and mouseReleased().

◆ updateAlpha()

void SkillRectangleListBox::updateAlpha ( )
inline

Definition at line 372 of file skillrectanglelistbox.h.

373  {
374  const float alpha = std::max(settings.guiAlpha,
376 
377  if (mAlpha != alpha)
378  mAlpha = alpha;
379  }
float guiAlpha
Definition: settings.h:131
float getMinimumOpacity() const
Definition: theme.h:124
Settings settings
Definition: settings.cpp:32

References Theme::getMinimumOpacity(), Settings::guiAlpha, mAlpha, settings, and theme.

Referenced by draw().

Field Documentation

◆ mAlpha

float SkillRectangleListBox::mAlpha = 1.0
staticprivate

Definition at line 416 of file skillrectanglelistbox.h.

Referenced by draw(), and updateAlpha().

◆ mBoxHeight

int SkillRectangleListBox::mBoxHeight
private

◆ mBoxWidth

int SkillRectangleListBox::mBoxWidth
private

◆ mCooldownColor

Color SkillRectangleListBox::mCooldownColor
private

Definition at line 402 of file skillrectanglelistbox.h.

◆ mForegroundSelectedColor

Color SkillRectangleListBox::mForegroundSelectedColor
private

Definition at line 403 of file skillrectanglelistbox.h.

Referenced by draw().

◆ mForegroundSelectedColor2

Color SkillRectangleListBox::mForegroundSelectedColor2
private

Definition at line 404 of file skillrectanglelistbox.h.

◆ mHighlightColor

Color SkillRectangleListBox::mHighlightColor
private

Definition at line 399 of file skillrectanglelistbox.h.

Referenced by draw().

◆ mIconXOffset

int SkillRectangleListBox::mIconXOffset
private

Definition at line 411 of file skillrectanglelistbox.h.

Referenced by draw(), and SkillRectangleListBox().

◆ mIconYOffset

int SkillRectangleListBox::mIconYOffset
private

Definition at line 412 of file skillrectanglelistbox.h.

Referenced by draw(), and SkillRectangleListBox().

◆ mModel

SkillModel* SkillRectangleListBox::mModel
private

◆ mPadding

int SkillRectangleListBox::mPadding
private

◆ mSelected

int SkillRectangleListBox::mSelected
private

Definition at line 407 of file skillrectanglelistbox.h.

Referenced by draw(), getSelectedInfo(), mousePressed(), and setSelected().

◆ mSkillClicked

bool SkillRectangleListBox::mSkillClicked
private

Definition at line 415 of file skillrectanglelistbox.h.

Referenced by mouseDragged(), and mousePressed().

◆ mSkin

Skin* SkillRectangleListBox::mSkin
private

Definition at line 406 of file skillrectanglelistbox.h.

Referenced by SkillRectangleListBox().

◆ mTextColor

Color SkillRectangleListBox::mTextColor
private

Definition at line 400 of file skillrectanglelistbox.h.

Referenced by draw().

◆ mTextColor2

Color SkillRectangleListBox::mTextColor2
private

Definition at line 401 of file skillrectanglelistbox.h.

Referenced by draw().

◆ mTextXOffset

int SkillRectangleListBox::mTextXOffset
private

Definition at line 413 of file skillrectanglelistbox.h.

Referenced by draw(), mousePressed(), and SkillRectangleListBox().

◆ mTextYOffset

int SkillRectangleListBox::mTextYOffset
private

Definition at line 414 of file skillrectanglelistbox.h.

Referenced by draw(), mousePressed(), and SkillRectangleListBox().


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