ManaPlus
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | Friends
Tab Class Reference

#include <tab.h>

Inheritance diagram for Tab:
BasicContainer MouseListener WidgetListener Widget WidgetDeathListener Widget2 ChatTab ShortcutTab SkillTab SocialTab BattleTab ChannelTab ClanTab EmulateGuildTab GmTab GuildTab LangTab PartyTab TradeTab WhisperTab SocialAttackTab SocialFriendsTab SocialGuildTab SocialGuildTab2 SocialNavigationTab SocialPartyTab SocialPickupTab SocialPlayersTab

Public Types

enum  {
  TAB_STANDARD = 0, TAB_HIGHLIGHTED = 1, TAB_SELECTED = 2, TAB_UNUSED = 3,
  TAB_COUNT = 4
}
 

Public Member Functions

 Tab (const Widget2 *const widget)
 
 ~Tab ()
 
void updateAlpha ()
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void setTabColor (const Color *const color1, const Color *const color2)
 
void setHighlightedTabColor (const Color *const color1, const Color *const color2)
 
void setSelectedTabColor (const Color *const color1, const Color *const color2)
 
void setFlashTabColor (const Color *const color1, const Color *const color2)
 
void setPlayerFlashTabColor (const Color *const color1, const Color *const color2)
 
void setFlash (const int flash)
 
int getFlash () const
 
void widgetResized (const Event &event)
 
void widgetMoved (const Event &event)
 
void setLabelFont (Font *const font)
 
LabelgetLabel () const
 
void adjustSize ()
 
void setTabbedArea (TabbedArea *tabbedArea)
 
TabbedAreagetTabbedArea () const
 
void setCaption (const std::string &caption)
 
const std::string & getCaption () const
 
void mouseEntered (MouseEvent &event)
 
void mouseExited (MouseEvent &event)
 
void setImage (Image *const image)
 
- 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 MouseListener
virtual ~MouseListener ()
 
virtual void mousePressed (MouseEvent &event)
 
virtual void mouseReleased (MouseEvent &event)
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
virtual void mouseMoved (MouseEvent &event)
 
virtual void mouseDragged (MouseEvent &event)
 
- Public Member Functions inherited from WidgetListener
virtual ~WidgetListener ()
 
virtual void widgetHidden (const Event &event)
 
virtual void widgetShown (const Event &event)
 

Static Public Member Functions

static void finalCleanup ()
 
- 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)
 

Protected Member Functions

virtual void setCurrent ()
 
- 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 MouseListener
 MouseListener ()
 
- Protected Member Functions inherited from WidgetListener
 WidgetListener ()
 

Protected Attributes

LabelmLabel
 
TabbedAreamTabbedArea
 
bool mHasMouse
 
- 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
 

Private Member Functions

void init ()
 

Private Attributes

const ColormTabColor
 
const ColormTabOutlineColor
 
const ColormTabHighlightedColor
 
const ColormTabHighlightedOutlineColor
 
const ColormTabSelectedColor
 
const ColormTabSelectedOutlineColor
 
const ColormFlashColor
 
const ColormFlashOutlineColor
 
const ColormPlayerFlashColor
 
const ColormPlayerFlashOutlineColor
 
int mFlash
 
ImageCollectionmVertexes
 
ImagemImage
 
int mMode
 
int mLabelMode
 

Static Private Attributes

static SkintabImg [TAB_COUNT]
 
static int mInstances = 0
 
static float mAlpha = 1.0
 

Friends

class TabbedArea
 

Additional Inherited Members

- 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
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

A tab, the same as the Guichan tab in 0.8, but extended

Definition at line 84 of file tab.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
TAB_STANDARD 
TAB_HIGHLIGHTED 
TAB_SELECTED 
TAB_UNUSED 
TAB_COUNT 

Definition at line 95 of file tab.h.

96  {
97  TAB_STANDARD = 0,
98  TAB_HIGHLIGHTED = 1,
99  TAB_SELECTED = 2,
100  TAB_UNUSED = 3,
101  TAB_COUNT = 4 // Must be last
102  };

Constructor & Destructor Documentation

◆ Tab()

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

Definition at line 102 of file tab.cpp.

References init().

102  :
103  BasicContainer(widget),
104  MouseListener(),
105  WidgetListener(),
106  mLabel(new Label(this)),
107  mTabbedArea(nullptr),
121  mFlash(0),
123  mImage(nullptr),
124  mMode(0),
125  mLabelMode(-1),
126  mHasMouse(false)
127 {
128  init();
129 }
const Color * mTabHighlightedColor
Definition: tab.h:227
int mMode
Definition: tab.h:238
TabbedArea * mTabbedArea
Definition: tab.h:215
Label * mLabel
Definition: tab.h:213
ImageCollection * mVertexes
Definition: tab.h:236
const Color * mTabHighlightedOutlineColor
Definition: tab.h:228
const Color * mTabSelectedOutlineColor
Definition: tab.h:230
const Color * mFlashColor
Definition: tab.h:231
int mLabelMode
Definition: tab.h:239
int mFlash
Definition: tab.h:235
const Color * mTabColor
Definition: tab.h:225
Definition: label.h:87
Image * mImage
Definition: tab.h:237
const Color * mFlashOutlineColor
Definition: tab.h:232
bool mHasMouse
Definition: tab.h:242
const Color * mTabSelectedColor
Definition: tab.h:229
const Color * mPlayerFlashColor
Definition: tab.h:233
void init()
Definition: tab.cpp:153
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:44
const Color * mTabOutlineColor
Definition: tab.h:226
BasicContainer(const Widget2 *const widget)
const Color * mPlayerFlashOutlineColor
Definition: tab.h:234

◆ ~Tab()

Tab::~Tab ( )

Definition at line 131 of file tab.cpp.

References Image::decRef(), delete2, gui, mImage, mInstances, mLabel, mVertexes, Gui::removeDragged(), TAB_COUNT, tabImg, theme, and Theme::unload().

132 {
133  if (gui != nullptr)
134  gui->removeDragged(this);
135 
136  mInstances--;
137  if (mInstances == 0 && (theme != nullptr))
138  {
139  for (int mode = 0; mode < TAB_COUNT; mode ++)
140  theme->unload(tabImg[mode]);
141  }
142 
143  delete2(mLabel);
144 
145  if (mImage != nullptr)
146  {
147  mImage->decRef();
148  mImage = nullptr;
149  }
151 }
void unload(Skin *const skin)
Definition: theme.cpp:249
Gui * gui
Definition: gui.cpp:110
Label * mLabel
Definition: tab.h:213
#define delete2(var)
Definition: delete2.h:24
ImageCollection * mVertexes
Definition: tab.h:236
Image * mImage
Definition: tab.h:237
static int mInstances
Definition: tab.h:222
Theme * theme
Definition: theme.cpp:61
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1161
static Skin * tabImg[TAB_COUNT]
Definition: tab.h:221
void decRef()
Definition: image.cpp:522

Member Function Documentation

◆ adjustSize()

void Tab::adjustSize ( )

Definition at line 425 of file tab.cpp.

References TabbedArea::adjustTabPositions(), Widget::getHeight(), Skin::getPadding(), Widget::getWidth(), Image::mBounds, mImage, mLabel, mTabbedArea, Widget::setSize(), TAB_STANDARD, and tabImg.

Referenced by getLabel(), setCaption(), setImage(), and setLabelFont().

426 {
427  const Skin *const skin = tabImg[TAB_STANDARD];
428  if (skin == nullptr)
429  return;
430  const int pad2 = skin->getPadding() * 2;
431 
432  if (mImage != nullptr)
433  {
434  const SDL_Rect &rect = mImage->mBounds;
435  setSize(rect.w + pad2, rect.h + pad2);
436  }
437  else
438  {
439  setSize(mLabel->getWidth() + pad2,
440  mLabel->getHeight() + pad2);
441  }
442 
443  if (mTabbedArea != nullptr)
445 }
void setSize(const int width, const int height)
Definition: widget.cpp:366
void adjustTabPositions()
Definition: tabbedarea.cpp:605
int getWidth() const
Definition: widget.h:220
Definition: skin.h:35
TabbedArea * mTabbedArea
Definition: tab.h:215
Label * mLabel
Definition: tab.h:213
int getPadding() const
Definition: skin.h:99
Image * mImage
Definition: tab.h:237
int getHeight() const
Definition: widget.h:239
SDL_Rect mBounds
Definition: image.h:210
static Skin * tabImg[TAB_COUNT]
Definition: tab.h:221

◆ draw()

void Tab::draw ( Graphics *const  graphics)
virtual

Draw the tabbed area.

Implements Widget.

Definition at line 214 of file tab.cpp.

References BLOCK_END, BLOCK_START, Graphics::calcTileCollection(), Graphics::calcWindow(), ImageCollection::clear(), BasicContainer::drawChildren(), Graphics::drawTileCollection(), Graphics::finalize(), Skin::getBorder(), Skin::getPadding(), Graphics::getRedraw(), Rect::height, TabbedArea::isTabSelected(), Widget::mDimension, mFlash, mFlashColor, mFlashOutlineColor, mHasMouse, mImage, mLabel, mLabelMode, mMode, mPlayerFlashColor, mPlayerFlashOutlineColor, Widget::mRedraw, mTabbedArea, mTabColor, mTabHighlightedColor, mTabHighlightedOutlineColor, mTabOutlineColor, mTabSelectedColor, mTabSelectedOutlineColor, mVertexes, Label::setForegroundColorAll(), TAB_HIGHLIGHTED, TAB_SELECTED, TAB_STANDARD, tabImg, updateAlpha(), and Rect::width.

215 {
216  BLOCK_START("Tab::draw")
217  int mode = TAB_STANDARD;
218 
219  // check which type of tab to draw
220  if (mTabbedArea != nullptr)
221  {
222  int labelMode = mFlash;
223 
224  if (mTabbedArea->isTabSelected(this))
225  {
226  labelMode = 3;
227  mode = TAB_SELECTED;
228  // if tab is selected, it doesnt need to highlight activity
229  mFlash = 0;
230  }
231  else if (labelMode == 0)
232  {
233  if (mHasMouse)
234  {
235  labelMode = 4;
236  mode = TAB_HIGHLIGHTED;
237  }
238  }
239  else if (mHasMouse)
240  {
241  mode = TAB_HIGHLIGHTED;
242  }
243 
244  // mRedraw need here because no other way to say label to change color
245  // +++ text from label must be moved to tab itself
246  if (labelMode != mLabelMode || mRedraw)
247  {
248  mLabelMode = labelMode;
249  switch (labelMode)
250  {
251  case 0: // default state
252  default:
255  break;
256  case 1: // mFlash == 1
259  break;
260  case 2: // mFlash == 2
263  break;
264  case 3: // mTabbedArea->isTabSelected(this)
267  break;
268  case 4: // mHasMouse
271  break;
272  }
273  }
274  }
275 
276  const Skin *const skin = tabImg[mode];
277  if (skin == nullptr)
278  {
279  BLOCK_END("Tab::draw")
280  return;
281  }
282 
283  updateAlpha();
284 
285  const ImageRect &rect = skin->getBorder();
286  if (mRedraw || mode != mMode || graphics->getRedraw())
287  {
288  mMode = mode;
289  mRedraw = false;
290  mVertexes->clear();
291  graphics->calcWindow(mVertexes,
292  0, 0,
294  rect);
295 
296  if (mImage != nullptr)
297  {
298  const Skin *const skin1 = tabImg[TAB_STANDARD];
299  if (skin1 != nullptr)
300  {
301  const int padding = skin1->getPadding();
302  graphics->calcTileCollection(mVertexes,
303  mImage,
304  padding,
305  padding);
306  }
307  }
308  graphics->finalize(mVertexes);
309  }
310 
311  graphics->drawTileCollection(mVertexes);
312 
313  drawChildren(graphics);
314  BLOCK_END("Tab::draw")
315 }
const Color * mTabHighlightedColor
Definition: tab.h:227
int width
Definition: rect.h:218
Definition: skin.h:35
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
int mMode
Definition: tab.h:238
void updateAlpha()
Definition: tab.cpp:189
TabbedArea * mTabbedArea
Definition: tab.h:215
#define BLOCK_START(name)
Definition: perfomance.h:78
Label * mLabel
Definition: tab.h:213
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:79
ImageCollection * mVertexes
Definition: tab.h:236
const Color * mTabHighlightedOutlineColor
Definition: tab.h:228
const Color * mTabSelectedOutlineColor
Definition: tab.h:230
const Color * mFlashColor
Definition: tab.h:231
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:464
int mLabelMode
Definition: tab.h:239
int getPadding() const
Definition: skin.h:99
int mFlash
Definition: tab.h:235
const Color * mTabColor
Definition: tab.h:225
Image * mImage
Definition: tab.h:237
const Color * mFlashOutlineColor
Definition: tab.h:232
int height
Definition: rect.h:223
bool mHasMouse
Definition: tab.h:242
const Color * mTabSelectedColor
Definition: tab.h:229
const Color * mPlayerFlashColor
Definition: tab.h:233
bool isTabSelected(const size_t index) const
Definition: tabbedarea.cpp:291
virtual void drawChildren(Graphics *const graphics)
bool mRedraw
Definition: widget.h:1163
virtual void calcTileCollection(ImageCollection *const vertCol, const Image *const image, int x, int y)=0
void setForegroundColorAll(const Color &color1, const Color &color2)
Definition: label.cpp:214
static Skin * tabImg[TAB_COUNT]
Definition: tab.h:221
const Color * mTabOutlineColor
Definition: tab.h:226
Rect mDimension
Definition: widget.h:1100
const Color * mPlayerFlashOutlineColor
Definition: tab.h:234
virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0

◆ finalCleanup()

void Tab::finalCleanup ( )
static

Definition at line 487 of file tab.cpp.

References TAB_COUNT, and tabImg.

Referenced by getLabel(), and Gui::~Gui().

488 {
489  for (int f = 0; f < TAB_COUNT; f ++)
490  {
491  tabImg[f] = nullptr;
492  }
493 }
static Skin * tabImg[TAB_COUNT]
Definition: tab.h:221

◆ getCaption()

const std::string & Tab::getCaption ( ) const

Definition at line 472 of file tab.cpp.

References Label::getCaption(), and mLabel.

Referenced by TabbedArea::getCurrentWidget(), and getLabel().

473 {
474  return mLabel->getCaption();
475 }
Label * mLabel
Definition: tab.h:213
const std::string & getCaption() const
Definition: label.h:132

◆ getFlash()

int Tab::getFlash ( ) const
inline

Definition at line 177 of file tab.h.

References ServerCommandType::font, mFlash, setLabelFont(), widgetMoved(), and widgetResized().

Referenced by ChatTab::chatLog().

178  { return mFlash; }
int mFlash
Definition: tab.h:235

◆ getLabel()

Label* Tab::getLabel ( ) const
inline

◆ getTabbedArea()

TabbedArea * Tab::getTabbedArea ( ) const

Definition at line 452 of file tab.cpp.

References mTabbedArea.

Referenced by ChatTab::chatLog(), and getLabel().

453 {
454  return mTabbedArea;
455 }
TabbedArea * mTabbedArea
Definition: tab.h:215

◆ init()

void Tab::init ( )
private

Load images if no other instances exist yet

Definition at line 153 of file tab.cpp.

References BasicContainer::add(), Widget::addMouseListener(), Widget::addWidgetListener(), data, Skin::getPadding(), Theme::getThemePath(), Theme::load(), mFlash, mInstances, mLabel, Widget::setFocusable(), Widget::setFrameSize(), Widget::setPosition(), TAB_COUNT, TAB_STANDARD, tabImg, theme, and updateAlpha().

Referenced by Tab().

154 {
155  addMouseListener(this);
156  setFocusable(false);
157  setFrameSize(0);
158  mFlash = 0;
159 
160  addWidgetListener(this);
161 
162  if (mInstances == 0)
163  {
164  // Load the skin
165  if (theme != nullptr)
166  {
167  for (int mode = 0; mode < TAB_COUNT; mode ++)
168  {
169  tabImg[mode] = theme->load(data[mode],
170  "tab.xml",
171  true,
173  }
174  }
175  updateAlpha();
176  }
177  mInstances++;
178 
179  add(mLabel);
180 
181  const Skin *const skin = tabImg[TAB_STANDARD];
182  if (skin == nullptr)
183  return;
184  const int padding = skin->getPadding();
185 
186  mLabel->setPosition(padding, padding);
187 }
Definition: skin.h:35
void updateAlpha()
Definition: tab.cpp:189
static std::string getThemePath()
Definition: theme.h:66
Label * mLabel
Definition: tab.h:213
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:178
int getPadding() const
Definition: skin.h:99
int mFlash
Definition: tab.h:235
uint32_t data
void setFrameSize(const unsigned int frameSize)
Definition: widget.h:167
void add(Widget *const widget)
static int mInstances
Definition: tab.h:222
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:291
void setPosition(const int x, const int y)
Definition: widget.cpp:160
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:301
Theme * theme
Definition: theme.cpp:61
void setFocusable(const bool focusable)
Definition: widget.cpp:191
static Skin * tabImg[TAB_COUNT]
Definition: tab.h:221

◆ mouseEntered()

void Tab::mouseEntered ( MouseEvent event)
virtual

Called when the mouse has entered into the widget area.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 477 of file tab.cpp.

References mHasMouse.

Referenced by getLabel().

478 {
479  mHasMouse = true;
480 }
bool mHasMouse
Definition: tab.h:242

◆ mouseExited()

void Tab::mouseExited ( MouseEvent event)
virtual

Called when the mouse has exited the widget area.

Parameters
eventDescribes the event.

Reimplemented from MouseListener.

Definition at line 482 of file tab.cpp.

References mHasMouse.

Referenced by getLabel().

483 {
484  mHasMouse = false;
485 }
bool mHasMouse
Definition: tab.h:242

◆ safeDraw()

void Tab::safeDraw ( Graphics *const  graphics)
virtual

Implements Widget.

Definition at line 317 of file tab.cpp.

References BLOCK_END, BLOCK_START, Graphics::drawImage(), Graphics::drawImageRect(), Skin::getBorder(), Skin::getPadding(), Rect::height, TabbedArea::isTabSelected(), Widget::mDimension, mFlash, mFlashColor, mFlashOutlineColor, mHasMouse, mImage, mLabel, mLabelMode, mPlayerFlashColor, mPlayerFlashOutlineColor, mTabbedArea, mTabColor, mTabHighlightedColor, mTabHighlightedOutlineColor, mTabOutlineColor, mTabSelectedColor, mTabSelectedOutlineColor, BasicContainer::safeDrawChildren(), Label::setForegroundColorAll(), TAB_HIGHLIGHTED, TAB_SELECTED, TAB_STANDARD, tabImg, updateAlpha(), and Rect::width.

318 {
319  BLOCK_START("Tab::draw")
320  int mode = TAB_STANDARD;
321 
322  // check which type of tab to draw
323  if (mTabbedArea != nullptr)
324  {
325  int labelMode = mFlash;
326 
327  if (mTabbedArea->isTabSelected(this))
328  {
329  labelMode = 3;
330  mode = TAB_SELECTED;
331  // if tab is selected, it doesnt need to highlight activity
332  mFlash = 0;
333  }
334  else if (labelMode == 0)
335  {
336  if (mHasMouse)
337  {
338  labelMode = 4;
339  mode = TAB_HIGHLIGHTED;
340  }
341  }
342  else if (mHasMouse)
343  {
344  mode = TAB_HIGHLIGHTED;
345  }
346 
347  if (labelMode != mLabelMode)
348  {
349  mLabelMode = labelMode;
350  switch (labelMode)
351  {
352  case 0: // default state
353  default:
356  break;
357  case 1: // mFlash == 1
360  break;
361  case 2: // mFlash == 2
364  break;
365  case 3: // mTabbedArea->isTabSelected(this)
368  break;
369  case 4: // mHasMouse
372  break;
373  }
374  }
375  }
376 
377  const Skin *const skin = tabImg[mode];
378  if (skin == nullptr)
379  {
380  BLOCK_END("Tab::draw")
381  return;
382  }
383 
384  updateAlpha();
385 
386  graphics->drawImageRect(0, 0,
387  mDimension.width, mDimension.height,
388  skin->getBorder());
389  if (mImage != nullptr)
390  {
391  const Skin *const skin1 = tabImg[TAB_STANDARD];
392  if (skin1 != nullptr)
393  {
394  const int padding = skin1->getPadding();
395  graphics->drawImage(mImage, padding, padding);
396  }
397  }
398 
399  safeDrawChildren(graphics);
400  BLOCK_END("Tab::draw")
401 }
const Color * mTabHighlightedColor
Definition: tab.h:227
Definition: skin.h:35
void updateAlpha()
Definition: tab.cpp:189
TabbedArea * mTabbedArea
Definition: tab.h:215
#define BLOCK_START(name)
Definition: perfomance.h:78
Label * mLabel
Definition: tab.h:213
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:79
const Color * mTabHighlightedOutlineColor
Definition: tab.h:228
const Color * mTabSelectedOutlineColor
Definition: tab.h:230
const Color * mFlashColor
Definition: tab.h:231
int mLabelMode
Definition: tab.h:239
int getPadding() const
Definition: skin.h:99
int mFlash
Definition: tab.h:235
const Color * mTabColor
Definition: tab.h:225
Image * mImage
Definition: tab.h:237
const Color * mFlashOutlineColor
Definition: tab.h:232
bool mHasMouse
Definition: tab.h:242
void drawImageRect(int x, int y, int w, int h, const ImageRect &restrict imgRect) restrict2 override final
const Color * mTabSelectedColor
Definition: tab.h:229
const Color * mPlayerFlashColor
Definition: tab.h:233
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
bool isTabSelected(const size_t index) const
Definition: tabbedarea.cpp:291
void setForegroundColorAll(const Color &color1, const Color &color2)
Definition: label.cpp:214
static Skin * tabImg[TAB_COUNT]
Definition: tab.h:221
const Color * mTabOutlineColor
Definition: tab.h:226
Rect mDimension
Definition: widget.h:1100
virtual void safeDrawChildren(Graphics *const graphics)
const Color * mPlayerFlashOutlineColor
Definition: tab.h:234

◆ setCaption()

void Tab::setCaption ( const std::string &  caption)

◆ setCurrent()

virtual void Tab::setCurrent ( )
inlineprotectedvirtual

Reimplemented in ChatTab, SocialTab, and SkillTab.

Definition at line 210 of file tab.h.

Referenced by TabbedArea::setSelectedTab().

211  { }

◆ setFlash()

void Tab::setFlash ( const int  flash)
inline

Set tab flashing state

Definition at line 174 of file tab.h.

References mFlash, and Widget::mRedraw.

Referenced by ChatTab::chatLog(), and ChatTab::setCurrent().

175  { mFlash = flash; mRedraw = true; }
int mFlash
Definition: tab.h:235
bool mRedraw
Definition: widget.h:1163

◆ setFlashTabColor()

void Tab::setFlashTabColor ( const Color *const  color1,
const Color *const  color2 
)
inline

Set the flash color for the tab's text.

Definition at line 152 of file tab.h.

References mFlashColor, mFlashOutlineColor, and Widget::mRedraw.

154  {
155  mFlashColor = color1;
156  mFlashOutlineColor = color2;
157  mRedraw = true;
158  }
const Color * mFlashColor
Definition: tab.h:231
const Color * mFlashOutlineColor
Definition: tab.h:232
bool mRedraw
Definition: widget.h:1163

◆ setHighlightedTabColor()

void Tab::setHighlightedTabColor ( const Color *const  color1,
const Color *const  color2 
)
inline

Set the highlighted color for the tab's text.

Definition at line 130 of file tab.h.

References Widget::mRedraw, mTabHighlightedColor, and mTabHighlightedOutlineColor.

Referenced by SocialGuildTab::SocialGuildTab(), SocialGuildTab2::SocialGuildTab2(), and SocialPartyTab::SocialPartyTab().

132  {
133  mTabHighlightedColor = color1;
135  mRedraw = true;
136  }
const Color * mTabHighlightedColor
Definition: tab.h:227
const Color * mTabHighlightedOutlineColor
Definition: tab.h:228
bool mRedraw
Definition: widget.h:1163

◆ setImage()

void Tab::setImage ( Image *const  image)

Definition at line 464 of file tab.cpp.

References adjustSize(), Image::decRef(), and mImage.

Referenced by TabbedArea::addTab(), and getLabel().

465 {
466  if (mImage != nullptr)
467  mImage->decRef();
468  mImage = image;
469  adjustSize();
470 }
Image * mImage
Definition: tab.h:237
void decRef()
Definition: image.cpp:522
void adjustSize()
Definition: tab.cpp:425

◆ setLabelFont()

void Tab::setLabelFont ( Font *const  font)

Definition at line 413 of file tab.cpp.

References Label::adjustSize(), adjustSize(), mLabel, Widget::mRedraw, and Widget::setFont().

Referenced by ChatWindow::addWhisperTab(), and getFlash().

414 {
415  if (mLabel == nullptr)
416  return;
417 
418  mLabel->setFont(font);
419  mLabel->adjustSize();
420  adjustSize();
421  mRedraw = true;
422 }
Label * mLabel
Definition: tab.h:213
void setFont(Font *const font)
Definition: widget.cpp:348
bool mRedraw
Definition: widget.h:1163
void adjustSize()
Definition: label.cpp:197
void adjustSize()
Definition: tab.cpp:425

◆ setPlayerFlashTabColor()

void Tab::setPlayerFlashTabColor ( const Color *const  color1,
const Color *const  color2 
)
inline

Set the player flash color for the tab's text.

Definition at line 163 of file tab.h.

References mPlayerFlashColor, mPlayerFlashOutlineColor, and Widget::mRedraw.

165  {
166  mPlayerFlashColor = color1;
167  mPlayerFlashOutlineColor = color2;
168  mRedraw = true;
169  }
const Color * mPlayerFlashColor
Definition: tab.h:233
bool mRedraw
Definition: widget.h:1163
const Color * mPlayerFlashOutlineColor
Definition: tab.h:234

◆ setSelectedTabColor()

void Tab::setSelectedTabColor ( const Color *const  color1,
const Color *const  color2 
)
inline

Set the selected color for the tab's text.

Definition at line 141 of file tab.h.

References Widget::mRedraw, mTabSelectedColor, and mTabSelectedOutlineColor.

Referenced by SocialGuildTab::SocialGuildTab(), SocialGuildTab2::SocialGuildTab2(), and SocialPartyTab::SocialPartyTab().

143  {
144  mTabSelectedColor = color1;
145  mTabSelectedOutlineColor = color2;
146  mRedraw = true;
147  }
const Color * mTabSelectedOutlineColor
Definition: tab.h:230
const Color * mTabSelectedColor
Definition: tab.h:229
bool mRedraw
Definition: widget.h:1163

◆ setTabbedArea()

void Tab::setTabbedArea ( TabbedArea tabbedArea)

Definition at line 447 of file tab.cpp.

References mTabbedArea.

Referenced by TabbedArea::addTab(), and getLabel().

448 {
449  mTabbedArea = tabbedArea;
450 }
TabbedArea * mTabbedArea
Definition: tab.h:215

◆ setTabColor()

void Tab::setTabColor ( const Color *const  color1,
const Color *const  color2 
)
inline

Set the normal color for the tab's text.

Definition at line 119 of file tab.h.

References Widget::mRedraw, mTabColor, and mTabOutlineColor.

Referenced by SocialGuildTab::SocialGuildTab(), SocialGuildTab2::SocialGuildTab2(), and SocialPartyTab::SocialPartyTab().

121  {
122  mTabColor = color1;
123  mTabOutlineColor = color2;
124  mRedraw = true;
125  }
const Color * mTabColor
Definition: tab.h:225
bool mRedraw
Definition: widget.h:1163
const Color * mTabOutlineColor
Definition: tab.h:226

◆ updateAlpha()

void Tab::updateAlpha ( )

Update the alpha value to the graphic components.

Definition at line 189 of file tab.cpp.

References Skin::getBorder(), Theme::getMinimumOpacity(), ImageRect::grid, Settings::guiAlpha, mAlpha, Image::setAlpha(), settings, TAB_COUNT, tabImg, and theme.

Referenced by draw(), init(), and safeDraw().

190 {
191  const float alpha = std::max(settings.guiAlpha,
193 
194  if (alpha != mAlpha)
195  {
196  mAlpha = alpha;
197  for (int a = 0; a < 9; a++)
198  {
199  for (int t = 0; t < TAB_COUNT; t++)
200  {
201  Skin *const skin = tabImg[t];
202  if (skin != nullptr)
203  {
204  const ImageRect &rect = skin->getBorder();
205  Image *const image = rect.grid[a];
206  if (image != nullptr)
207  image->setAlpha(mAlpha);
208  }
209  }
210  }
211  }
212 }
Definition: skin.h:35
static float mAlpha
Definition: tab.h:223
float getMinimumOpacity() const
Definition: theme.h:123
Settings settings
Definition: settings.cpp:31
virtual void setAlpha(const float alpha)
Definition: image.cpp:286
const ImageRect & getBorder() const
Definition: skin.h:67
Image * grid[9]
Definition: imagerect.h:41
Theme * theme
Definition: theme.cpp:61
Definition: image.h:61
static Skin * tabImg[TAB_COUNT]
Definition: tab.h:221
float guiAlpha
Definition: settings.h:129

◆ widgetMoved()

void Tab::widgetMoved ( const Event event)
virtual

Invoked when a widget is moved.

Parameters
eventDescribes the event.

Reimplemented from WidgetListener.

Definition at line 408 of file tab.cpp.

References Widget::mRedraw.

Referenced by getFlash().

409 {
410  mRedraw = true;
411 }
bool mRedraw
Definition: widget.h:1163

◆ widgetResized()

void Tab::widgetResized ( const Event event)
virtual

Invoked when a widget changes its size.

Parameters
eventDescribes the event.

Reimplemented from WidgetListener.

Definition at line 403 of file tab.cpp.

References Widget::mRedraw.

Referenced by getFlash().

404 {
405  mRedraw = true;
406 }
bool mRedraw
Definition: widget.h:1163

Friends And Related Function Documentation

◆ TabbedArea

friend class TabbedArea
friend

Definition at line 208 of file tab.h.

Field Documentation

◆ mAlpha

float Tab::mAlpha = 1.0
staticprivate

Definition at line 223 of file tab.h.

Referenced by updateAlpha().

◆ mFlash

int Tab::mFlash
private

Definition at line 235 of file tab.h.

Referenced by draw(), getFlash(), init(), safeDraw(), and setFlash().

◆ mFlashColor

const Color* Tab::mFlashColor
private

Definition at line 231 of file tab.h.

Referenced by draw(), safeDraw(), and setFlashTabColor().

◆ mFlashOutlineColor

const Color* Tab::mFlashOutlineColor
private

Definition at line 232 of file tab.h.

Referenced by draw(), safeDraw(), and setFlashTabColor().

◆ mHasMouse

bool Tab::mHasMouse
protected

Definition at line 242 of file tab.h.

Referenced by draw(), mouseEntered(), mouseExited(), and safeDraw().

◆ mImage

Image* Tab::mImage
private

Definition at line 237 of file tab.h.

Referenced by adjustSize(), draw(), safeDraw(), setImage(), and ~Tab().

◆ mInstances

int Tab::mInstances = 0
staticprivate

Number of tab instances

Definition at line 222 of file tab.h.

Referenced by init(), and ~Tab().

◆ mLabel

Label* Tab::mLabel
protected

Definition at line 213 of file tab.h.

Referenced by adjustSize(), draw(), getCaption(), getLabel(), init(), safeDraw(), setCaption(), setLabelFont(), and ~Tab().

◆ mLabelMode

int Tab::mLabelMode
private

Definition at line 239 of file tab.h.

Referenced by draw(), and safeDraw().

◆ mMode

int Tab::mMode
private

Definition at line 238 of file tab.h.

Referenced by draw().

◆ mPlayerFlashColor

const Color* Tab::mPlayerFlashColor
private

Definition at line 233 of file tab.h.

Referenced by draw(), safeDraw(), and setPlayerFlashTabColor().

◆ mPlayerFlashOutlineColor

const Color* Tab::mPlayerFlashOutlineColor
private

Definition at line 234 of file tab.h.

Referenced by draw(), safeDraw(), and setPlayerFlashTabColor().

◆ mTabbedArea

TabbedArea* Tab::mTabbedArea
protected

Definition at line 215 of file tab.h.

Referenced by adjustSize(), draw(), getTabbedArea(), safeDraw(), and setTabbedArea().

◆ mTabColor

const Color* Tab::mTabColor
private

Definition at line 225 of file tab.h.

Referenced by draw(), safeDraw(), and setTabColor().

◆ mTabHighlightedColor

const Color* Tab::mTabHighlightedColor
private

Definition at line 227 of file tab.h.

Referenced by draw(), safeDraw(), and setHighlightedTabColor().

◆ mTabHighlightedOutlineColor

const Color* Tab::mTabHighlightedOutlineColor
private

Definition at line 228 of file tab.h.

Referenced by draw(), safeDraw(), and setHighlightedTabColor().

◆ mTabOutlineColor

const Color* Tab::mTabOutlineColor
private

Definition at line 226 of file tab.h.

Referenced by draw(), safeDraw(), and setTabColor().

◆ mTabSelectedColor

const Color* Tab::mTabSelectedColor
private

Definition at line 229 of file tab.h.

Referenced by draw(), safeDraw(), and setSelectedTabColor().

◆ mTabSelectedOutlineColor

const Color* Tab::mTabSelectedOutlineColor
private

Definition at line 230 of file tab.h.

Referenced by draw(), safeDraw(), and setSelectedTabColor().

◆ mVertexes

ImageCollection* Tab::mVertexes
private

Definition at line 236 of file tab.h.

Referenced by draw(), and ~Tab().

◆ tabImg

Skin * Tab::tabImg
staticprivate

Tab state graphics

Definition at line 221 of file tab.h.

Referenced by adjustSize(), draw(), finalCleanup(), init(), safeDraw(), updateAlpha(), and ~Tab().


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