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 int Button::mInstances = 0;
89 float Button::mAlpha = 1.0;
90 
91 static std::string const data[Button::BUTTON_COUNT] =
92 {
93  "button.xml",
94  "button_highlighted.xml",
95  "button_pressed.xml",
96  "button_disabled.xml"
97 };
98 
99 Skin *Button::button[BUTTON_COUNT];
100 
101 Button::Button(const Widget2 *const widget) :
102  Widget(widget),
103  MouseListener(),
104  KeyListener(),
105  FocusListener(),
106  WidgetListener(),
107  mCaption(),
108  mDescription(),
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  ActionListener *const listener) :
147  Widget(widget),
148  MouseListener(),
149  KeyListener(),
150  FocusListener(),
151  WidgetListener(),
152  mCaption(caption),
153  mDescription(),
154  mTextChunk(),
160  255U)),
166  mImages(nullptr),
169  mClickCount(0),
170  mSpacing(),
171  mTag(0),
172  mMode(0),
173  mXOffset(0),
174  mYOffset(0),
175  mImageWidth(0),
176  mImageHeight(0),
177  mHasMouse(false),
178  mKeyPressed(false),
179  mMousePressed(false),
180  mStick(false),
181  mPressed(false),
182  mTextChanged(true)
183 {
184  init();
185  adjustSize();
186  setActionEventId(actionEventId);
187 
188  if (listener != nullptr)
189  addActionListener(listener);
190 }
191 
192 Button::Button(const Widget2 *const widget,
193  const std::string &restrict caption,
194  const std::string &restrict imageName,
195  const int imageWidth, const int imageHeight,
196  const std::string &restrict actionEventId,
197  ActionListener *const listener) :
198  Widget(widget),
199  MouseListener(),
200  KeyListener(),
201  FocusListener(),
202  WidgetListener(),
203  mCaption(caption),
204  mDescription(),
205  mTextChunk(),
211  255U)),
217  mImages(nullptr),
220  mClickCount(0),
221  mSpacing(),
222  mTag(0),
223  mMode(0),
224  mXOffset(0),
225  mYOffset(0),
226  mImageWidth(imageWidth),
227  mImageHeight(imageHeight),
228  mHasMouse(false),
229  mKeyPressed(false),
230  mMousePressed(false),
231  mStick(false),
232  mPressed(false),
233  mTextChanged(true)
234 {
235  init();
236  loadImageSet(imageName);
237  adjustSize();
238  setActionEventId(actionEventId);
239 
240  if (listener != nullptr)
241  addActionListener(listener);
242 }
243 
244 Button::Button(const Widget2 *const widget,
245  const std::string &restrict imageName,
246  const int imageWidth, const int imageHeight,
247  const std::string &restrict actionEventId,
248  ActionListener *const listener) :
249  Widget(widget),
250  MouseListener(),
251  KeyListener(),
252  FocusListener(),
253  WidgetListener(),
254  mCaption(),
255  mDescription(),
256  mTextChunk(),
262  255U)),
268  mImages(nullptr),
271  mClickCount(0),
272  mSpacing(),
273  mTag(0),
274  mMode(0),
275  mXOffset(0),
276  mYOffset(0),
277  mImageWidth(imageWidth),
278  mImageHeight(imageHeight),
279  mHasMouse(false),
280  mKeyPressed(false),
281  mMousePressed(false),
282  mStick(false),
283  mPressed(false),
284  mTextChanged(true)
285 {
286  init();
287  loadImageSet(imageName);
288  adjustSize();
289  setActionEventId(actionEventId);
290 
291  if (listener != nullptr)
292  addActionListener(listener);
293 }
294 
295 Button::Button(const Widget2 *const widget,
296  const std::string &restrict caption,
297  const std::string &restrict imageName,
298  const std::string &restrict actionEventId,
299  ActionListener *const listener) :
300  Widget(widget),
301  MouseListener(),
302  KeyListener(),
303  FocusListener(),
304  WidgetListener(),
305  mCaption(caption),
306  mDescription(),
307  mTextChunk(),
313  255U)),
319  mImages(nullptr),
322  mClickCount(0),
323  mSpacing(),
324  mTag(0),
325  mMode(0),
326  mXOffset(0),
327  mYOffset(0),
328  mImageWidth(0),
329  mImageHeight(0),
330  mHasMouse(false),
331  mKeyPressed(false),
332  mMousePressed(false),
333  mStick(false),
334  mPressed(false),
335  mTextChanged(true)
336 {
337  init();
338  loadImage(imageName);
339  adjustSize();
340  setActionEventId(actionEventId);
341 
342  if (listener != nullptr)
343  addActionListener(listener);
344 }
345 
347 {
348  mAllowLogic = false;
349  addMouseListener(this);
350  addKeyListener(this);
351  addFocusListener(this);
352  addWidgetListener(this);
353 
354  setFocusable(true);
355  setFrameSize(0);
356 
357  if (mInstances == 0)
358  {
359  if (theme != nullptr)
360  {
361  for (int mode = 0; mode < BUTTON_COUNT; mode ++)
362  {
363  Skin *const skin = theme->load(data[mode],
364  "button.xml",
365  true,
367  if (skin != nullptr)
368  {
369  button[mode] = skin;
370  mSpacing[mode] = skin->getOption("spacing");
371  }
372  }
373  }
374 
375  updateAlpha();
376  }
377 
378  mInstances++;
379 }
380 
382 {
383  if (mWindow != nullptr)
385 
386  if (gui != nullptr)
387  gui->removeDragged(this);
388 
389  mInstances--;
390 
391  if (mInstances == 0 && (theme != nullptr))
392  {
393  for (int mode = 0; mode < BUTTON_COUNT; mode ++)
394  theme->unload(button[mode]);
395  }
397  if (mImageSet != nullptr)
398  {
399  mImageSet->decRef();
400  mImageSet = nullptr;
401  }
402  if (mImages != nullptr)
403  {
404  for (int f = 0; f < BUTTON_COUNT; f ++)
405  mImages[f] = nullptr;
406  delete [] mImages;
407  mImages = nullptr;
408  }
410 }
411 
412 void Button::loadImage(const std::string &imageName)
413 {
414  if (mImageSet != nullptr)
415  {
416  mImageSet->decRef();
417  mImageSet = nullptr;
418  }
419  Image *const image = Theme::getImageFromThemeXml(imageName, "");
420  mImages = new Image*[BUTTON_COUNT];
421  for (int f = 0; f < BUTTON_COUNT; f ++)
422  mImages[f] = image;
423 }
424 
425 void Button::loadImageSet(const std::string &imageName)
426 {
427  if (mImageSet != nullptr)
428  {
429  mImageSet->decRef();
430  mImageSet = nullptr;
431  }
434  if (mImageSet == nullptr)
435  return;
436  mImages = new Image*[BUTTON_COUNT];
437  mImages[0] = nullptr;
438  for (size_t f = 0; f < BUTTON_COUNT; f ++)
439  {
440  Image *const img = mImageSet->get(f);
441  if (img != nullptr)
442  mImages[f] = img;
443  else
444  mImages[f] = mImages[0];
445  }
446 }
447 
449 {
450  const float alpha = std::max(settings.guiAlpha,
452 
453  if (mAlpha != alpha)
454  {
455  mAlpha = alpha;
456  for (int mode = 0; mode < BUTTON_COUNT; mode ++)
457  {
458  for (int a = 0; a < 9; a ++)
459  {
460  Skin *const skin = button[mode];
461  if (skin != nullptr)
462  {
463  const ImageRect &rect = skin->getBorder();
464  Image *const image = rect.grid[a];
465  if (image != nullptr)
466  image->setAlpha(mAlpha);
467  }
468  }
469  }
470  }
471 }
472 
473 void Button::draw(Graphics *const graphics)
474 {
475  BLOCK_START("Button::draw")
476  int mode;
477 
478  if (!isEnabled())
479  mode = BUTTON_DISABLED;
480  else if (isPressed2())
481  mode = BUTTON_PRESSED;
482  else if (mHasMouse)
483  mode = BUTTON_HIGHLIGHTED;
484  else
485  mode = BUTTON_STANDARD;
486 
487  const Skin *const skin = button[mode];
488  if (skin == nullptr)
489  {
490  BLOCK_END("Button::draw")
491  return;
492  }
493 
494  updateAlpha();
495 
496  bool recalc = false;
497  if (mRedraw)
498  {
499  recalc = true;
500  }
501  else
502  {
503  // because we don't know where parent windows was moved,
504  // need recalc vertexes
505  ClipRect &rect = graphics->getTopClip();
506  if (rect.xOffset != mXOffset || rect.yOffset != mYOffset)
507  {
508  recalc = true;
509  mXOffset = rect.xOffset;
510  mYOffset = rect.yOffset;
511  }
512  else if (mMode != mode)
513  {
514  recalc = true;
515  mMode = mode;
516  }
517  else if (graphics->getRedraw())
518  {
519  recalc = true;
520  }
521  }
522 
523  const int padding = skin->getPadding();
524  const int spacing = mSpacing[mode];
525 
526  if (recalc)
527  mTextChanged = true;
528 
529  int imageX = 0;
530  int imageY = 0;
531  int textX = 0;
532  const Rect &rect = mDimension;
533  const int width = rect.width;
534  const int height = rect.height;
535  Font *const font = getFont();
536  int textY = height / 2 - font->getHeight() / 2;
537  if (mImages != nullptr)
538  imageY = height / 2 - mImageHeight / 2;
539 
540 // need move calculation from draw!!!
541 
542  switch (mAlignment)
543  {
544  default:
545  case Graphics::LEFT:
546  {
547  if (mImages != nullptr)
548  {
549  imageX = padding;
550  textX = padding + mImageWidth + spacing;
551  }
552  else
553  {
554  textX = padding;
555  }
556  break;
557  }
558  case Graphics::CENTER:
559  {
560  const int width1 = font->getWidth(mCaption);
561  if (mImages != nullptr)
562  {
563  const int w = width1 + mImageWidth + spacing;
564  imageX = (width - w) / 2;
565  textX = imageX + mImageWidth + spacing - width1 / 2;
566  }
567  else
568  {
569  textX = (width - width1) / 2;
570  }
571  break;
572  }
573  case Graphics::RIGHT:
574  {
575  const int width1 = font->getWidth(mCaption);
576  textX = width - width1 - padding;
577  imageX = textX - width1 - spacing;
578  break;
579  }
580  }
581 
582  if (recalc)
583  {
584  mRedraw = false;
585  mMode = mode;
586  mVertexes2->clear();
587  graphics->calcWindow(mVertexes2,
588  0, 0,
589  width, height,
590  skin->getBorder());
591 
592  if (mImages != nullptr)
593  {
594  if (isPressed())
595  {
596  graphics->calcTileCollection(mVertexes2,
597  mImages[mode],
598  imageX + 1, imageY + 1);
599  }
600  else
601  {
602  graphics->calcTileCollection(mVertexes2,
603  mImages[mode],
604  imageX, imageY);
605  }
606  }
607  graphics->finalize(mVertexes2);
608  }
609  graphics->drawTileCollection(mVertexes2);
610 
611  if (isPressed())
612  {
613  textX ++;
614  textY ++;
615  }
616 
617  if (mTextChanged)
618  {
622  switch (mode)
623  {
624  case BUTTON_DISABLED:
627  break;
628  case BUTTON_PRESSED:
631  break;
632  case BUTTON_HIGHLIGHTED:
635  break;
636  default:
639  break;
640  }
641  font->generate(mTextChunk);
642  mTextChanged = false;
643  }
644 
645  const Image *const image = mTextChunk.img;
646  if (image != nullptr)
647  graphics->drawImage(image, textX, textY);
648 
649  BLOCK_END("Button::draw")
650 }
651 
652 void Button::safeDraw(Graphics *const graphics)
653 {
654  BLOCK_START("Button::safeDraw")
655  int mode;
656 
657  if (!isEnabled())
658  mode = BUTTON_DISABLED;
659  else if (isPressed2())
660  mode = BUTTON_PRESSED;
661  else if (mHasMouse || isFocused())
662  mode = BUTTON_HIGHLIGHTED;
663  else
664  mode = BUTTON_STANDARD;
665 
666  const Skin *const skin = button[mode];
667  if (skin == nullptr)
668  {
669  BLOCK_END("Button::safeDraw")
670  return;
671  }
672 
673  updateAlpha();
674 
675  if (mMode != mode)
676  {
677  mTextChanged = true;
678  mMode = mode;
679  }
680 
681  const int padding = skin->getPadding();
682  const int spacing = mSpacing[mode];
683 
684  int imageX = 0;
685  int imageY = 0;
686  int textX = 0;
687  const Rect &rect = mDimension;
688  const int width = rect.width;
689  const int height = rect.height;
690  Font *const font = getFont();
691  int textY = height / 2 - font->getHeight() / 2;
692  if (mImages != nullptr)
693  imageY = height / 2 - mImageHeight / 2;
694 
695 // need move calculation from draw!!!
696 
697  switch (mAlignment)
698  {
699  default:
700  case Graphics::LEFT:
701  {
702  if (mImages != nullptr)
703  {
704  imageX = padding;
705  textX = padding + mImageWidth + spacing;
706  }
707  else
708  {
709  textX = padding;
710  }
711  break;
712  }
713  case Graphics::CENTER:
714  {
715  const int width1 = font->getWidth(mCaption);
716  if (mImages != nullptr)
717  {
718  const int w = width1 + mImageWidth + spacing;
719  imageX = (width - w) / 2;
720  textX = imageX + mImageWidth + spacing - width1 / 2;
721  }
722  else
723  {
724  textX = (width - width1) / 2;
725  }
726  break;
727  }
728  case Graphics::RIGHT:
729  {
730  const int width1 = font->getWidth(mCaption);
731  textX = width - width1 - padding;
732  imageX = textX - width1 - spacing;
733  break;
734  }
735  }
736 
737  graphics->drawImageRect(0, 0, width, height, skin->getBorder());
738 
739  if (mImages != nullptr)
740  {
741  if (isPressed())
742  graphics->drawImage(mImages[mode], imageX + 1, imageY + 1);
743  else
744  graphics->drawImage(mImages[mode], imageX, imageY);
745  }
746 
747  if (isPressed())
748  {
749  textX ++;
750  textY ++;
751  }
752 
753  if (mTextChanged)
754  {
758  switch (mode)
759  {
760  case BUTTON_DISABLED:
763  break;
764  case BUTTON_PRESSED:
767  break;
768  case BUTTON_HIGHLIGHTED:
771  break;
772  default:
775  break;
776  }
777  font->generate(mTextChunk);
778  mTextChanged = false;
779  }
780 
781  const Image *const image = mTextChunk.img;
782  if (image != nullptr)
783  graphics->drawImage(image, textX, textY);
784 
785  BLOCK_END("Button::safeDraw")
786 }
787 
789 {
790  if (event.getButton() == MouseButton::LEFT)
791  {
792  if (mStick)
793  mPressed = !mPressed;
794 
795  if (mMousePressed && mHasMouse)
796  {
797  mMousePressed = false;
798  mClickCount = event.getClickCount();
800  }
801  else
802  {
803  mMousePressed = false;
804  mClickCount = 0;
805  }
806  event.consume();
807  }
808 }
809 
811 {
812  mRedraw = true;
813 }
814 
816 {
817  mRedraw = true;
818 }
819 
821 {
823  mVertexes2->clear();
825  mRedraw = true;
826  mTextChanged = true;
827 }
828 
830 {
831  const Font *const font = getFont();
832  const Skin *const skin = button[BUTTON_STANDARD];
833  if (skin == nullptr)
834  return;
835  const int padding = skin->getPadding();
836 
837  if (mImages != nullptr)
838  {
839  const int spacing = mSpacing[BUTTON_STANDARD];
840  const int width = font->getWidth(mCaption);
841  if (width != 0)
842  setWidth(width + mImageWidth + spacing + 2 * padding);
843  else
844  setWidth(mImageWidth + 2 * padding);
845  int height = font->getHeight();
846  if (height < mImageHeight)
847  height = mImageHeight;
848  setHeight(height + 2 * padding);
849  }
850  else
851  {
852  setWidth(font->getWidth(mCaption) + 2 * padding);
853  setHeight(font->getHeight() + 2 * padding);
854  }
855 }
856 
858 {
859  const InputActionT action = event.getActionId();
860 
861  if (action == InputAction::GUI_SELECT)
862  {
863  mKeyPressed = true;
864  event.consume();
865  }
866 }
867 
869 {
870  const InputActionT action = event.getActionId();
871 
872  if (action == InputAction::GUI_SELECT && mKeyPressed)
873  {
874  mKeyPressed = false;
875  if (mStick)
876  mPressed = !mPressed;
878  event.consume();
879  }
880 }
881 
882 bool Button::isPressed2() const
883 {
884  return mPressed || isPressed();
885 }
886 
887 bool Button::isPressed() const
888 {
889  if (mMousePressed)
890  return mHasMouse;
891  return mKeyPressed;
892 }
893 
894 void Button::focusLost(const Event& event A_UNUSED)
895 {
896  mMousePressed = false;
897  mKeyPressed = false;
898 }
899 
901 {
902  if (event.getButton() == MouseButton::LEFT)
903  {
904  mMousePressed = true;
905  event.consume();
906  }
907 }
908 
910 {
911  mHasMouse = true;
912 }
913 
915 {
916  mHasMouse = false;
917 }
918 
920 {
921  event.consume();
922 }
923 
925 {
926  if (mWindow != nullptr)
927  mWindow->addWidgetListener(this);
928  Widget::setParent(widget);
929 }
930 
931 void Button::setWindow(Widget *const widget)
932 {
933  if ((widget == nullptr) && (mWindow != nullptr))
934  {
936  mWindow = nullptr;
937  }
938  else
939  {
940  Widget2::setWindow(widget);
941  }
942 }
int mYOffset
Definition: button.h:324
int mSpacing[BUTTON_COUNT]
Definition: button.h:319
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:425
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:306
Button(const Widget2 *const widget)
Definition: button.cpp:101
Gui * gui
Definition: gui.cpp:110
Definition: font.h:88
bool mStick
Definition: button.h:342
Color mDisabledColor2
Definition: button.h:301
virtual void drawImageRect(const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
bool mKeyPressed
Definition: button.h:335
static int mInstances
Definition: button.h:285
virtual void decRef()
Definition: resource.cpp:49
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
void focusLost(const Event &event)
Definition: button.cpp:894
static Image * getImageFromThemeXml(const std::string &name, const std::string &name2)
Definition: theme.cpp:1135
TextChunk mTextChunk
Definition: button.h:295
void keyReleased(KeyEvent &event)
Definition: button.cpp:868
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:909
void addFocusListener(FocusListener *const focusListener)
Definition: widget.cpp:281
Color mHighlightedColor
Definition: button.h:302
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:322
ImageSet * mImageSet
Definition: button.h:307
void setActionEventId(const std::string &actionEventId)
Definition: widget.h:595
Color mEnabledColor
Definition: button.h:298
Color mPressedColor
Definition: button.h:304
#define delete2(var)
Definition: delete2.h:24
void mouseDragged(MouseEvent &event)
Definition: button.cpp:919
int mImageHeight
Definition: button.h:326
Graphics::Alignment mAlignment
Definition: button.h:312
Font * textFont
Definition: textchunk.h:63
void mouseReleased(MouseEvent &event)
Definition: button.cpp:788
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:473
void adjustSize()
Definition: button.cpp:829
void widgetMoved(const Event &event)
Definition: button.cpp:815
void widgetHidden(const Event &event)
Definition: button.cpp:820
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:464
void distributeActionEvent()
Definition: widget.cpp:492
void keyPressed(KeyEvent &event)
Definition: button.cpp:857
#define new
Definition: debug_new.h:147
Settings settings
Definition: settings.cpp:31
virtual void setAlpha(const float alpha)
Definition: image.cpp:285
void widgetResized(const Event &event)
Definition: button.cpp:810
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:652
virtual void setWindow(Widget *const window)
Definition: widget2.h:96
const ImageRect & getBorder() const
Definition: skin.h:67
int mClickCount
Definition: button.h:314
Image * grid[9]
Definition: imagerect.h:41
Widget * mWindow
Definition: widget2.h:111
int xOffset
Definition: cliprect.h:121
void loadImage(const std::string &imageName)
Definition: button.cpp:412
void setFrameSize(const unsigned int frameSize)
Definition: widget.h:167
std::string mCaption
Definition: button.h:291
InputAction ::T InputActionT
Definition: inputaction.h:714
#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:340
int height
Definition: rect.h:223
static void updateAlpha()
Definition: button.cpp:448
void addKeyListener(KeyListener *const keyListener)
Definition: widget.cpp:271
ImageCollection * mVertexes2
Definition: button.h:297
bool getRedraw() const
Definition: graphics.h:286
void setParent(Widget *widget)
Definition: button.cpp:924
bool mPressed
Definition: button.h:343
bool isPressed2() const
Definition: button.cpp:882
virtual void setParent(Widget *parent)
Definition: widget.h:625
~Button()
Definition: button.cpp:381
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:914
int mTag
Definition: button.h:321
Color mEnabledColor2
Definition: button.h:299
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:887
Definition: widget.h:97
void removeWidgetListener(WidgetListener *const widgetListener)
Definition: widget.cpp:306
Color mPressedColor2
Definition: button.h:305
int getWidth(const std::string &text) const
Definition: font.cpp:333
Definition: event.h:77
int mImageWidth
Definition: button.h:325
bool mRedraw
Definition: widget.h:1163
Color mDisabledColor
Definition: button.h:300
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:900
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:286
int getHeight() const
Definition: font.cpp:360
static Skin * button[BUTTON_COUNT]
Definition: button.h:284
void deleteImage()
Definition: textchunk.cpp:192
void setWindow(Widget *const widget)
Definition: button.cpp:931
float guiAlpha
Definition: settings.h:129
Color color2
Definition: textchunk.h:66
static std::string const data[Button::BUTTON_COUNT]
Definition: button.cpp:91
int mXOffset
Definition: button.h:323
Rect mDimension
Definition: widget.h:1100
Color mHighlightedColor2
Definition: button.h:303
#define isBatchDrawRenders(val)
Definition: renderers.h:30
bool mTextChanged
Definition: button.h:344
bool mHasMouse
Definition: button.h:330
void init()
Definition: button.cpp:346
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:293
void generate(TextChunk &chunk)
Definition: font.cpp:428