ManaPlus
button.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2018 The ManaPlus Developers
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 /* _______ __ __ __ ______ __ __ _______ __ __
24  * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
25  * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
26  * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
27  * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
28  * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
29  * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
30  *
31  * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
32  *
33  *
34  * Per Larsson a.k.a finalman
35  * Olof Naessén a.k.a jansem/yakslem
36  *
37  * Visit: http://guichan.sourceforge.net
38  *
39  * License: (BSD)
40  * Redistribution and use in source and binary forms, with or without
41  * modification, are permitted provided that the following conditions
42  * are met:
43  * 1. Redistributions of source code must retain the above copyright
44  * notice, this list of conditions and the following disclaimer.
45  * 2. Redistributions in binary form must reproduce the above copyright
46  * notice, this list of conditions and the following disclaimer in
47  * the documentation and/or other materials provided with the
48  * distribution.
49  * 3. Neither the name of Guichan nor the names of its contributors may
50  * be used to endorse or promote products derived from this software
51  * without specific prior written permission.
52  *
53  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
54  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
55  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
56  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
57  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
58  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
59  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
60  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
61  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
62  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
63  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
64  */
65 
66 #include "gui/widgets/button.h"
67 
68 #include "settings.h"
69 
70 #include "resources/imageset.h"
71 #include "resources/imagerect.h"
72 
73 #include "resources/image/image.h"
74 
75 #include "gui/gui.h"
76 #include "gui/skin.h"
77 
78 #include "gui/fonts/font.h"
79 
80 #include "render/renderers.h"
81 
83 
84 #include "utils/delete2.h"
85 
86 #include "debug.h"
87 
88 float Button::mAlpha = 1.0;
89 
90 static std::string const data[Button::BUTTON_COUNT] =
91 {
92  ".xml",
93  "_highlighted.xml",
94  "_pressed.xml",
95  "_disabled.xml"
96 };
97 
98 Button::Button(const Widget2 *const widget,
99  const std::string &restrict skinName) :
100  Widget(widget),
101  MouseListener(),
102  KeyListener(),
103  FocusListener(),
104  WidgetListener(),
105  mSkin(),
106  mCaption(),
107  mDescription(),
108  mSkinName(skinName),
109  mTextChunk(),
110  mVertexes2(new ImageCollection),
111  mEnabledColor(getThemeColor(ThemeColorId::BUTTON, 255U)),
112  mEnabledColor2(getThemeColor(ThemeColorId::BUTTON_OUTLINE, 255U)),
113  mDisabledColor(getThemeColor(ThemeColorId::BUTTON_DISABLED, 255U)),
114  mDisabledColor2(getThemeColor(ThemeColorId::BUTTON_DISABLED_OUTLINE,
115  255U)),
116  mHighlightedColor(getThemeColor(ThemeColorId::BUTTON_HIGHLIGHTED, 255U)),
117  mHighlightedColor2(getThemeColor(
119  mPressedColor(getThemeColor(ThemeColorId::BUTTON_PRESSED, 255U)),
120  mPressedColor2(getThemeColor(ThemeColorId::BUTTON_PRESSED_OUTLINE, 255U)),
121  mImages(nullptr),
122  mImageSet(nullptr),
123  mAlignment(Graphics::CENTER),
124  mClickCount(0),
125  mSpacing(),
126  mTag(0),
127  mMode(0),
128  mXOffset(0),
129  mYOffset(0),
130  mImageWidth(0),
131  mImageHeight(0),
132  mHasMouse(false),
133  mKeyPressed(false),
134  mMousePressed(false),
135  mStick(false),
136  mPressed(false),
137  mTextChanged(true)
138 {
139  init();
140  adjustSize();
141 }
142 
143 Button::Button(const Widget2 *const widget,
144  const std::string &restrict caption,
145  const std::string &restrict actionEventId,
146  const std::string &restrict skinName,
147  ActionListener *const listener) :
148  Widget(widget),
149  MouseListener(),
150  KeyListener(),
151  FocusListener(),
152  WidgetListener(),
153  mSkin(),
154  mCaption(caption),
155  mDescription(),
156  mSkinName(skinName),
157  mTextChunk(),
163  255U)),
169  mImages(nullptr),
172  mClickCount(0),
173  mSpacing(),
174  mTag(0),
175  mMode(0),
176  mXOffset(0),
177  mYOffset(0),
178  mImageWidth(0),
179  mImageHeight(0),
180  mHasMouse(false),
181  mKeyPressed(false),
182  mMousePressed(false),
183  mStick(false),
184  mPressed(false),
185  mTextChanged(true)
186 {
187  init();
188  adjustSize();
189  setActionEventId(actionEventId);
190 
191  if (listener != nullptr)
192  addActionListener(listener);
193 }
194 
195 Button::Button(const Widget2 *const widget,
196  const std::string &restrict caption,
197  const std::string &restrict imageName,
198  const int imageWidth,
199  const int imageHeight,
200  const std::string &restrict actionEventId,
201  const std::string &restrict skinName,
202  ActionListener *const listener) :
203  Widget(widget),
204  MouseListener(),
205  KeyListener(),
206  FocusListener(),
207  WidgetListener(),
208  mSkin(),
209  mCaption(caption),
210  mDescription(),
211  mSkinName(skinName),
212  mTextChunk(),
218  255U)),
224  mImages(nullptr),
227  mClickCount(0),
228  mSpacing(),
229  mTag(0),
230  mMode(0),
231  mXOffset(0),
232  mYOffset(0),
233  mImageWidth(imageWidth),
234  mImageHeight(imageHeight),
235  mHasMouse(false),
236  mKeyPressed(false),
237  mMousePressed(false),
238  mStick(false),
239  mPressed(false),
240  mTextChanged(true)
241 {
242  init();
243  loadImageSet(imageName);
244  adjustSize();
245  setActionEventId(actionEventId);
246 
247  if (listener != nullptr)
248  addActionListener(listener);
249 }
250 
251 Button::Button(const Widget2 *const widget,
252  const std::string &restrict imageName,
253  const int imageWidth,
254  const int imageHeight,
255  const std::string &restrict actionEventId,
256  const std::string &restrict skinName,
257  ActionListener *const listener) :
258  Widget(widget),
259  MouseListener(),
260  KeyListener(),
261  FocusListener(),
262  WidgetListener(),
263  mSkin(),
264  mCaption(),
265  mDescription(),
266  mSkinName(skinName),
267  mTextChunk(),
273  255U)),
279  mImages(nullptr),
282  mClickCount(0),
283  mSpacing(),
284  mTag(0),
285  mMode(0),
286  mXOffset(0),
287  mYOffset(0),
288  mImageWidth(imageWidth),
289  mImageHeight(imageHeight),
290  mHasMouse(false),
291  mKeyPressed(false),
292  mMousePressed(false),
293  mStick(false),
294  mPressed(false),
295  mTextChanged(true)
296 {
297  init();
298  loadImageSet(imageName);
299  adjustSize();
300  setActionEventId(actionEventId);
301 
302  if (listener != nullptr)
303  addActionListener(listener);
304 }
305 
307 {
308  mAllowLogic = false;
309  addMouseListener(this);
310  addKeyListener(this);
311  addFocusListener(this);
312  addWidgetListener(this);
313 
314  setFocusable(true);
315  setFrameSize(0);
316 
317  if (theme != nullptr)
318  {
319  for (int mode = 0; mode < BUTTON_COUNT; mode ++)
320  {
321  Skin *const skin = theme->load(mSkinName + data[mode],
322  "button.xml",
323  true,
325  if (skin != nullptr)
326  {
327  mSkin[mode] = skin;
328  mSpacing[mode] = skin->getOption("spacing");
329  }
330  }
331  }
332 
333  updateAlpha();
334 }
335 
337 {
338  if (mWindow != nullptr)
340 
341  if (gui != nullptr)
342  gui->removeDragged(this);
343 
344  if (theme != nullptr)
345  {
346  for (int mode = 0; mode < BUTTON_COUNT; mode ++)
347  theme->unload(mSkin[mode]);
348  }
350  if (mImageSet != nullptr)
351  {
352  mImageSet->decRef();
353  mImageSet = nullptr;
354  }
355  if (mImages != nullptr)
356  {
357  for (int f = 0; f < BUTTON_COUNT; f ++)
358  mImages[f] = nullptr;
359  delete [] mImages;
360  mImages = nullptr;
361  }
363 }
364 
365 void Button::loadImage(const std::string &imageName)
366 {
367  if (mImageSet != nullptr)
368  {
369  mImageSet->decRef();
370  mImageSet = nullptr;
371  }
372  Image *const image = Theme::getImageFromThemeXml(imageName, "");
373  mImages = new Image*[BUTTON_COUNT];
374  for (int f = 0; f < BUTTON_COUNT; f ++)
375  mImages[f] = image;
376 }
377 
378 void Button::loadImageSet(const std::string &imageName)
379 {
380  if (mImageSet != nullptr)
381  {
382  mImageSet->decRef();
383  mImageSet = nullptr;
384  }
387  if (mImageSet == nullptr)
388  return;
389  mImages = new Image*[BUTTON_COUNT];
390  mImages[0] = nullptr;
391  for (size_t f = 0; f < BUTTON_COUNT; f ++)
392  {
393  Image *const img = mImageSet->get(f);
394  if (img != nullptr)
395  mImages[f] = img;
396  else
397  mImages[f] = mImages[0];
398  }
399 }
400 
402 {
403  const float alpha = std::max(settings.guiAlpha,
405 
406  if (mAlpha != alpha)
407  {
408  mAlpha = alpha;
409  for (int mode = 0; mode < BUTTON_COUNT; mode ++)
410  {
411  for (int a = 0; a < 9; a ++)
412  {
413  Skin *const skin = mSkin[mode];
414  if (skin != nullptr)
415  {
416  const ImageRect &rect = skin->getBorder();
417  Image *const image = rect.grid[a];
418  if (image != nullptr)
419  image->setAlpha(mAlpha);
420  }
421  }
422  }
423  }
424 }
425 
426 void Button::draw(Graphics *const graphics)
427 {
428  BLOCK_START("Button::draw")
429  int mode;
430 
431  if (!isEnabled())
432  mode = BUTTON_DISABLED;
433  else if (isPressed2())
434  mode = BUTTON_PRESSED;
435  else if (mHasMouse)
436  mode = BUTTON_HIGHLIGHTED;
437  else
438  mode = BUTTON_STANDARD;
439 
440  const Skin *const skin = mSkin[mode];
441  if (skin == nullptr)
442  {
443  BLOCK_END("Button::draw")
444  return;
445  }
446 
447  updateAlpha();
448 
449  bool recalc = false;
450  if (mRedraw)
451  {
452  recalc = true;
453  }
454  else
455  {
456  // because we don't know where parent windows was moved,
457  // need recalc vertexes
458  ClipRect &rect = graphics->getTopClip();
459  if (rect.xOffset != mXOffset || rect.yOffset != mYOffset)
460  {
461  recalc = true;
462  mXOffset = rect.xOffset;
463  mYOffset = rect.yOffset;
464  }
465  else if (mMode != mode)
466  {
467  recalc = true;
468  mMode = mode;
469  }
470  else if (graphics->getRedraw())
471  {
472  recalc = true;
473  }
474  }
475 
476  const int padding = skin->getPadding();
477  const int spacing = mSpacing[mode];
478 
479  if (recalc)
480  mTextChanged = true;
481 
482  int imageX = 0;
483  int imageY = 0;
484  int textX = 0;
485  const Rect &rect = mDimension;
486  const int width = rect.width;
487  const int height = rect.height;
488  Font *const font = getFont();
489  int textY = height / 2 - font->getHeight() / 2;
490  if (mImages != nullptr)
491  imageY = height / 2 - mImageHeight / 2;
492 
493 // need move calculation from draw!!!
494 
495  switch (mAlignment)
496  {
497  default:
498  case Graphics::LEFT:
499  {
500  if (mImages != nullptr)
501  {
502  imageX = padding;
503  textX = padding + mImageWidth + spacing;
504  }
505  else
506  {
507  textX = padding;
508  }
509  break;
510  }
511  case Graphics::CENTER:
512  {
513  const int width1 = font->getWidth(mCaption);
514  if (mImages != nullptr)
515  {
516  const int w = width1 + mImageWidth + spacing;
517  imageX = (width - w) / 2;
518  textX = imageX + mImageWidth + spacing - width1 / 2;
519  }
520  else
521  {
522  textX = (width - width1) / 2;
523  }
524  break;
525  }
526  case Graphics::RIGHT:
527  {
528  const int width1 = font->getWidth(mCaption);
529  textX = width - width1 - padding;
530  imageX = textX - width1 - spacing;
531  break;
532  }
533  }
534 
535  if (recalc)
536  {
537  mRedraw = false;
538  mMode = mode;
539  mVertexes2->clear();
540  graphics->calcWindow(mVertexes2,
541  0, 0,
542  width, height,
543  skin->getBorder());
544 
545  if (mImages != nullptr)
546  {
547  if (isPressed())
548  {
549  graphics->calcTileCollection(mVertexes2,
550  mImages[mode],
551  imageX + 1, imageY + 1);
552  }
553  else
554  {
555  graphics->calcTileCollection(mVertexes2,
556  mImages[mode],
557  imageX, imageY);
558  }
559  }
560  graphics->finalize(mVertexes2);
561  }
562  graphics->drawTileCollection(mVertexes2);
563 
564  if (isPressed())
565  {
566  textX ++;
567  textY ++;
568  }
569 
570  if (mTextChanged)
571  {
575  switch (mode)
576  {
577  case BUTTON_DISABLED:
580  break;
581  case BUTTON_PRESSED:
584  break;
585  case BUTTON_HIGHLIGHTED:
588  break;
589  default:
592  break;
593  }
594  font->generate(mTextChunk);
595  mTextChanged = false;
596  }
597 
598  const Image *const image = mTextChunk.img;
599  if (image != nullptr)
600  graphics->drawImage(image, textX, textY);
601 
602  BLOCK_END("Button::draw")
603 }
604 
605 void Button::safeDraw(Graphics *const graphics)
606 {
607  BLOCK_START("Button::safeDraw")
608  int mode;
609 
610  if (!isEnabled())
611  mode = BUTTON_DISABLED;
612  else if (isPressed2())
613  mode = BUTTON_PRESSED;
614  else if (mHasMouse || isFocused())
615  mode = BUTTON_HIGHLIGHTED;
616  else
617  mode = BUTTON_STANDARD;
618 
619  const Skin *const skin = mSkin[mode];
620  if (skin == nullptr)
621  {
622  BLOCK_END("Button::safeDraw")
623  return;
624  }
625 
626  updateAlpha();
627 
628  if (mMode != mode)
629  {
630  mTextChanged = true;
631  mMode = mode;
632  }
633 
634  const int padding = skin->getPadding();
635  const int spacing = mSpacing[mode];
636 
637  int imageX = 0;
638  int imageY = 0;
639  int textX = 0;
640  const Rect &rect = mDimension;
641  const int width = rect.width;
642  const int height = rect.height;
643  Font *const font = getFont();
644  int textY = height / 2 - font->getHeight() / 2;
645  if (mImages != nullptr)
646  imageY = height / 2 - mImageHeight / 2;
647 
648 // need move calculation from draw!!!
649 
650  switch (mAlignment)
651  {
652  default:
653  case Graphics::LEFT:
654  {
655  if (mImages != nullptr)
656  {
657  imageX = padding;
658  textX = padding + mImageWidth + spacing;
659  }
660  else
661  {
662  textX = padding;
663  }
664  break;
665  }
666  case Graphics::CENTER:
667  {
668  const int width1 = font->getWidth(mCaption);
669  if (mImages != nullptr)
670  {
671  const int w = width1 + mImageWidth + spacing;
672  imageX = (width - w) / 2;
673  textX = imageX + mImageWidth + spacing - width1 / 2;
674  }
675  else
676  {
677  textX = (width - width1) / 2;
678  }
679  break;
680  }
681  case Graphics::RIGHT:
682  {
683  const int width1 = font->getWidth(mCaption);
684  textX = width - width1 - padding;
685  imageX = textX - width1 - spacing;
686  break;
687  }
688  }
689 
690  graphics->drawImageRect(0, 0, width, height, skin->getBorder());
691 
692  if (mImages != nullptr)
693  {
694  if (isPressed())
695  graphics->drawImage(mImages[mode], imageX + 1, imageY + 1);
696  else
697  graphics->drawImage(mImages[mode], imageX, imageY);
698  }
699 
700  if (isPressed())
701  {
702  textX ++;
703  textY ++;
704  }
705 
706  if (mTextChanged)
707  {
711  switch (mode)
712  {
713  case BUTTON_DISABLED:
716  break;
717  case BUTTON_PRESSED:
720  break;
721  case BUTTON_HIGHLIGHTED:
724  break;
725  default:
728  break;
729  }
730  font->generate(mTextChunk);
731  mTextChanged = false;
732  }
733 
734  const Image *const image = mTextChunk.img;
735  if (image != nullptr)
736  graphics->drawImage(image, textX, textY);
737 
738  BLOCK_END("Button::safeDraw")
739 }
740 
742 {
743  if (event.getButton() == MouseButton::LEFT)
744  {
745  if (mStick)
746  mPressed = !mPressed;
747 
748  if (mMousePressed && mHasMouse)
749  {
750  mMousePressed = false;
751  mClickCount = event.getClickCount();
753  }
754  else
755  {
756  mMousePressed = false;
757  mClickCount = 0;
758  }
759  event.consume();
760  }
761 }
762 
764 {
765  mRedraw = true;
766 }
767 
769 {
770  mRedraw = true;
771 }
772 
774 {
776  mVertexes2->clear();
778  mRedraw = true;
779  mTextChanged = true;
780 }
781 
783 {
784  const Font *const font = getFont();
785  const Skin *const skin = mSkin[BUTTON_STANDARD];
786  if (skin == nullptr)
787  return;
788  const int padding = skin->getPadding();
789 
790  if (mImages != nullptr)
791  {
792  const int spacing = mSpacing[BUTTON_STANDARD];
793  const int width = font->getWidth(mCaption);
794  if (width != 0)
795  setWidth(width + mImageWidth + spacing + 2 * padding);
796  else
797  setWidth(mImageWidth + 2 * padding);
798  int height = font->getHeight();
799  if (height < mImageHeight)
800  height = mImageHeight;
801  setHeight(height + 2 * padding);
802  }
803  else
804  {
805  setWidth(font->getWidth(mCaption) + 2 * padding);
806  setHeight(font->getHeight() + 2 * padding);
807  }
808 }
809 
811 {
812  const InputActionT action = event.getActionId();
813 
814  if (action == InputAction::GUI_SELECT)
815  {
816  mKeyPressed = true;
817  event.consume();
818  }
819 }
820 
822 {
823  const InputActionT action = event.getActionId();
824 
825  if (action == InputAction::GUI_SELECT && mKeyPressed)
826  {
827  mKeyPressed = false;
828  if (mStick)
829  mPressed = !mPressed;
831  event.consume();
832  }
833 }
834 
835 bool Button::isPressed2() const
836 {
837  return mPressed || isPressed();
838 }
839 
840 bool Button::isPressed() const
841 {
842  if (mMousePressed)
843  return mHasMouse;
844  return mKeyPressed;
845 }
846 
847 void Button::focusLost(const Event& event A_UNUSED)
848 {
849  mMousePressed = false;
850  mKeyPressed = false;
851 }
852 
854 {
855  if (event.getButton() == MouseButton::LEFT)
856  {
857  mMousePressed = true;
858  event.consume();
859  }
860 }
861 
863 {
864  mHasMouse = true;
865 }
866 
868 {
869  mHasMouse = false;
870 }
871 
873 {
874  event.consume();
875 }
876 
878 {
879  if (mWindow != nullptr)
880  mWindow->addWidgetListener(this);
881  Widget::setParent(widget);
882 }
883 
884 void Button::setWindow(Widget *const widget)
885 {
886  if ((widget == nullptr) && (mWindow != nullptr))
887  {
889  mWindow = nullptr;
890  }
891  else
892  {
893  Widget2::setWindow(widget);
894  }
895 }
int mYOffset
Definition: button.h:322
int mSpacing[BUTTON_COUNT]
Definition: button.h:317
Font * getFont() const
Definition: widget.cpp:330
int width
Definition: rect.h:218
std::string text
Definition: textchunk.h:64
void loadImageSet(const std::string &imageName)
Definition: button.cpp:378
Definition: skin.h:35
Image * get(const size_type i) const
Definition: imageset.cpp:66
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
void setWidth(const int width)
Definition: widget.cpp:132
void unload(Skin *const skin)
Definition: theme.cpp:249
ClipRect & getTopClip() const
Definition: graphics.h:280
Image ** mImages
Definition: button.h:304
Gui * gui
Definition: gui.cpp:110
Definition: font.h:88
bool mStick
Definition: button.h:340
Color mDisabledColor2
Definition: button.h:299
virtual void drawImageRect(const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
bool mKeyPressed
Definition: button.h:333
virtual void decRef()
Definition: resource.cpp:49
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
void focusLost(const Event &event)
Definition: button.cpp:847
static Image * getImageFromThemeXml(const std::string &name, const std::string &name2)
Definition: theme.cpp:925
TextChunk mTextChunk
Definition: button.h:293
void keyReleased(KeyEvent &event)
Definition: button.cpp:821
MouseButtonT getButton() const
Definition: mouseevent.h:115
float getMinimumOpacity() const
Definition: theme.h:123
Definition: rect.h:72
#define BLOCK_START(name)
Definition: perfomance.h:78
void mouseEntered(MouseEvent &event)
Definition: button.cpp:862
void addFocusListener(FocusListener *const focusListener)
Definition: widget.cpp:281
Color mHighlightedColor
Definition: button.h:300
static std::string getThemePath()
Definition: theme.h:66
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:178
#define BLOCK_END(name)
Definition: perfomance.h:79
RenderType openGLMode
int yOffset
Definition: cliprect.h:126
int mMode
Definition: button.h:320
ImageSet * mImageSet
Definition: button.h:305
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
Color mEnabledColor
Definition: button.h:296
Color mPressedColor
Definition: button.h:302
#define delete2(var)
Definition: delete2.h:24
void mouseDragged(MouseEvent &event)
Definition: button.cpp:872
int mImageHeight
Definition: button.h:324
Graphics::Alignment mAlignment
Definition: button.h:310
Font * textFont
Definition: textchunk.h:63
void mouseReleased(MouseEvent &event)
Definition: button.cpp:741
int getOption(const std::string &name) const
Definition: skin.h:105
virtual bool isFocused() const
Definition: widget.cpp:183
void draw(Graphics *const graphics)
Definition: button.cpp:426
void adjustSize()
Definition: button.cpp:782
void widgetMoved(const Event &event)
Definition: button.cpp:768
void widgetHidden(const Event &event)
Definition: button.cpp:773
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:464
void distributeActionEvent()
Definition: widget.cpp:492
void keyPressed(KeyEvent &event)
Definition: button.cpp:810
#define new
Definition: debug_new.h:147
Settings settings
Definition: settings.cpp:31
virtual void setAlpha(const float alpha)
Definition: image.cpp:286
void widgetResized(const Event &event)
Definition: button.cpp:763
int getPadding() const
Definition: skin.h:99
static ImageSet * getImageSetFromTheme(const std::string &path, const int w, const int h)
Definition: theme.cpp:659
void safeDraw(Graphics *const graphics)
Definition: button.cpp:605
virtual void setWindow(Widget *const window)
Definition: widget2.h:96
const ImageRect & getBorder() const
Definition: skin.h:67
int mClickCount
Definition: button.h:312
Image * grid[9]
Definition: imagerect.h:41
Button(const Widget2 *const widget, const std::string &skinName)
Definition: button.cpp:98
Widget * mWindow
Definition: widget2.h:111
int xOffset
Definition: cliprect.h:121
void loadImage(const std::string &imageName)
Definition: button.cpp:365
void setFrameSize(const unsigned int frameSize)
Definition: widget.h:167
std::string mCaption
Definition: button.h:287
InputAction ::T InputActionT
Definition: inputaction.h:715
#define nullptr
Definition: localconsts.h:44
bool mAllowLogic
Definition: widget.h:1159
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:291
bool isEnabled() const
Definition: widget.cpp:374
bool mMousePressed
Definition: button.h:338
int height
Definition: rect.h:223
void updateAlpha()
Definition: button.cpp:401
void addKeyListener(KeyListener *const keyListener)
Definition: widget.cpp:271
ImageCollection * mVertexes2
Definition: button.h:295
bool getRedraw() const
Definition: graphics.h:286
void setParent(Widget *widget)
Definition: button.cpp:877
bool mPressed
Definition: button.h:341
bool isPressed2() const
Definition: button.cpp:835
virtual void setParent(Widget *parent)
Definition: widget.h:625
~Button()
Definition: button.cpp:336
void setHeight(const int height)
Definition: widget.cpp:139
void addWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:301
Theme * theme
Definition: theme.cpp:61
#define A_UNUSED
Definition: localconsts.h:171
void setFocusable(const bool focusable)
Definition: widget.cpp:191
void mouseExited(MouseEvent &event)
Definition: button.cpp:867
int mTag
Definition: button.h:319
Color mEnabledColor2
Definition: button.h:297
Image * img
Definition: textchunk.h:62
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
void removeDragged(const Widget *const widget)
Definition: gui.cpp:1160
bool isPressed() const
Definition: button.cpp:840
Definition: widget.h:97
void removeWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:306
Color mPressedColor2
Definition: button.h:303
int getWidth(const std::string &text) const
Definition: font.cpp:333
Definition: event.h:77
int mImageWidth
Definition: button.h:323
bool mRedraw
Definition: widget.h:1163
Color mDisabledColor
Definition: button.h:298
Definition: image.h:61
virtual void calcTileCollection(ImageCollection *const vertCol, const Image *const image, int x, int y)=0
void mousePressed(MouseEvent &event)
Definition: button.cpp:853
Color color
Definition: textchunk.h:65
#define restrict
Definition: localconsts.h:176
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:44
static float mAlpha
Definition: button.h:281
int getHeight() const
Definition: font.cpp:360
void deleteImage()
Definition: textchunk.cpp:192
void setWindow(Widget *const widget)
Definition: button.cpp:884
float guiAlpha
Definition: settings.h:128
Color color2
Definition: textchunk.h:66
static std::string const data[Button::BUTTON_COUNT]
Definition: button.cpp:90
int mXOffset
Definition: button.h:321
Rect mDimension
Definition: widget.h:1100
Color mHighlightedColor2
Definition: button.h:301
#define isBatchDrawRenders(val)
Definition: renderers.h:30
std::string mSkinName
Definition: button.h:291
bool mTextChanged
Definition: button.h:342
bool mHasMouse
Definition: button.h:328
Skin * mSkin[BUTTON_COUNT]
Definition: button.h:283
void init()
Definition: button.cpp:306
virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
std::string mDescription
Definition: button.h:289
void generate(TextChunk &chunk)
Definition: font.cpp:428