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::setImage(Image *const image)
379 {
380  if (image == nullptr)
381  return;
382  if (mImageSet != nullptr)
383  {
384  mImageSet->decRef();
385  mImageSet = nullptr;
386  }
387  mImageWidth = image->getWidth();
388  mImageHeight = image->getHeight();
389  mImages = new Image*[BUTTON_COUNT];
390  for (int f = 0; f < BUTTON_COUNT; f ++)
391  mImages[f] = image;
392 }
393 
394 void Button::loadImageSet(const std::string &imageName)
395 {
396  if (mImageSet != nullptr)
397  {
398  mImageSet->decRef();
399  mImageSet = nullptr;
400  }
403  if (mImageSet == nullptr)
404  return;
405  mImages = new Image*[BUTTON_COUNT];
406  mImages[0] = nullptr;
407  for (size_t f = 0; f < BUTTON_COUNT; f ++)
408  {
409  Image *const img = mImageSet->get(f);
410  if (img != nullptr)
411  mImages[f] = img;
412  else
413  mImages[f] = mImages[0];
414  }
415 }
416 
418 {
419  const float alpha = std::max(settings.guiAlpha,
421 
422  if (mAlpha != alpha)
423  {
424  mAlpha = alpha;
425  for (int mode = 0; mode < BUTTON_COUNT; mode ++)
426  {
427  for (int a = 0; a < 9; a ++)
428  {
429  Skin *const skin = mSkin[mode];
430  if (skin != nullptr)
431  {
432  const ImageRect &rect = skin->getBorder();
433  Image *const image = rect.grid[a];
434  if (image != nullptr)
435  image->setAlpha(mAlpha);
436  }
437  }
438  }
439  }
440 }
441 
442 void Button::draw(Graphics *const graphics)
443 {
444  BLOCK_START("Button::draw")
445  int mode;
446 
447  if (!isEnabled())
448  mode = BUTTON_DISABLED;
449  else if (isPressed2())
450  mode = BUTTON_PRESSED;
451  else if (mHasMouse)
452  mode = BUTTON_HIGHLIGHTED;
453  else
454  mode = BUTTON_STANDARD;
455 
456  const Skin *const skin = mSkin[mode];
457  if (skin == nullptr)
458  {
459  BLOCK_END("Button::draw")
460  return;
461  }
462 
463  updateAlpha();
464 
465  bool recalc = false;
466  if (mRedraw)
467  {
468  recalc = true;
469  }
470  else
471  {
472  // because we don't know where parent windows was moved,
473  // need recalc vertexes
474  ClipRect &rect = graphics->getTopClip();
475  if (rect.xOffset != mXOffset || rect.yOffset != mYOffset)
476  {
477  recalc = true;
478  mXOffset = rect.xOffset;
479  mYOffset = rect.yOffset;
480  }
481  else if (mMode != mode)
482  {
483  recalc = true;
484  mMode = mode;
485  }
486  else if (graphics->getRedraw())
487  {
488  recalc = true;
489  }
490  }
491 
492  const int padding = skin->getPadding();
493  const int spacing = mSpacing[mode];
494 
495  if (recalc)
496  mTextChanged = true;
497 
498  int imageX = 0;
499  int imageY = 0;
500  int textX = 0;
501  const Rect &rect = mDimension;
502  const int width = rect.width;
503  const int height = rect.height;
504  Font *const font = getFont();
505  int textY = height / 2 - font->getHeight() / 2;
506  if (mImages != nullptr)
507  imageY = height / 2 - mImageHeight / 2;
508 
509 // need move calculation from draw!!!
510 
511  switch (mAlignment)
512  {
513  default:
514  case Graphics::LEFT:
515  {
516  if (mImages != nullptr)
517  {
518  imageX = padding;
519  textX = padding + mImageWidth + spacing;
520  }
521  else
522  {
523  textX = padding;
524  }
525  break;
526  }
527  case Graphics::CENTER:
528  {
529  const int width1 = font->getWidth(mCaption);
530  if (mImages != nullptr)
531  {
532  const int w = width1 + mImageWidth + spacing;
533  imageX = (width - w) / 2;
534  textX = imageX + mImageWidth + spacing - width1 / 2;
535  }
536  else
537  {
538  textX = (width - width1) / 2;
539  }
540  break;
541  }
542  case Graphics::RIGHT:
543  {
544  const int width1 = font->getWidth(mCaption);
545  textX = width - width1 - padding;
546  imageX = textX - width1 - spacing;
547  break;
548  }
549  }
550 
551  if (recalc)
552  {
553  mRedraw = false;
554  mMode = mode;
555  mVertexes2->clear();
556  graphics->calcWindow(mVertexes2,
557  0, 0,
558  width, height,
559  skin->getBorder());
560 
561  if (mImages != nullptr)
562  {
563  if (isPressed())
564  {
565  graphics->calcTileCollection(mVertexes2,
566  mImages[mode],
567  imageX + 1, imageY + 1);
568  }
569  else
570  {
571  graphics->calcTileCollection(mVertexes2,
572  mImages[mode],
573  imageX, imageY);
574  }
575  }
576  graphics->finalize(mVertexes2);
577  }
578  graphics->drawTileCollection(mVertexes2);
579 
580  if (isPressed())
581  {
582  textX ++;
583  textY ++;
584  }
585 
586  if (mTextChanged)
587  {
591  switch (mode)
592  {
593  case BUTTON_DISABLED:
596  break;
597  case BUTTON_PRESSED:
600  break;
601  case BUTTON_HIGHLIGHTED:
604  break;
605  default:
608  break;
609  }
610  font->generate(mTextChunk);
611  mTextChanged = false;
612  }
613 
614  const Image *const image = mTextChunk.img;
615  if (image != nullptr)
616  graphics->drawImage(image, textX, textY);
617 
618  BLOCK_END("Button::draw")
619 }
620 
621 void Button::safeDraw(Graphics *const graphics)
622 {
623  BLOCK_START("Button::safeDraw")
624  int mode;
625 
626  if (!isEnabled())
627  mode = BUTTON_DISABLED;
628  else if (isPressed2())
629  mode = BUTTON_PRESSED;
630  else if (mHasMouse || isFocused())
631  mode = BUTTON_HIGHLIGHTED;
632  else
633  mode = BUTTON_STANDARD;
634 
635  const Skin *const skin = mSkin[mode];
636  if (skin == nullptr)
637  {
638  BLOCK_END("Button::safeDraw")
639  return;
640  }
641 
642  updateAlpha();
643 
644  if (mMode != mode)
645  {
646  mTextChanged = true;
647  mMode = mode;
648  }
649 
650  const int padding = skin->getPadding();
651  const int spacing = mSpacing[mode];
652 
653  int imageX = 0;
654  int imageY = 0;
655  int textX = 0;
656  const Rect &rect = mDimension;
657  const int width = rect.width;
658  const int height = rect.height;
659  Font *const font = getFont();
660  int textY = height / 2 - font->getHeight() / 2;
661  if (mImages != nullptr)
662  imageY = height / 2 - mImageHeight / 2;
663 
664 // need move calculation from draw!!!
665 
666  switch (mAlignment)
667  {
668  default:
669  case Graphics::LEFT:
670  {
671  if (mImages != nullptr)
672  {
673  imageX = padding;
674  textX = padding + mImageWidth + spacing;
675  }
676  else
677  {
678  textX = padding;
679  }
680  break;
681  }
682  case Graphics::CENTER:
683  {
684  const int width1 = font->getWidth(mCaption);
685  if (mImages != nullptr)
686  {
687  const int w = width1 + mImageWidth + spacing;
688  imageX = (width - w) / 2;
689  textX = imageX + mImageWidth + spacing - width1 / 2;
690  }
691  else
692  {
693  textX = (width - width1) / 2;
694  }
695  break;
696  }
697  case Graphics::RIGHT:
698  {
699  const int width1 = font->getWidth(mCaption);
700  textX = width - width1 - padding;
701  imageX = textX - width1 - spacing;
702  break;
703  }
704  }
705 
706  graphics->drawImageRect(0, 0, width, height, skin->getBorder());
707 
708  if (mImages != nullptr)
709  {
710  if (isPressed())
711  graphics->drawImage(mImages[mode], imageX + 1, imageY + 1);
712  else
713  graphics->drawImage(mImages[mode], imageX, imageY);
714  }
715 
716  if (isPressed())
717  {
718  textX ++;
719  textY ++;
720  }
721 
722  if (mTextChanged)
723  {
727  switch (mode)
728  {
729  case BUTTON_DISABLED:
732  break;
733  case BUTTON_PRESSED:
736  break;
737  case BUTTON_HIGHLIGHTED:
740  break;
741  default:
744  break;
745  }
746  font->generate(mTextChunk);
747  mTextChanged = false;
748  }
749 
750  const Image *const image = mTextChunk.img;
751  if (image != nullptr)
752  graphics->drawImage(image, textX, textY);
753 
754  BLOCK_END("Button::safeDraw")
755 }
756 
758 {
759  if (event.getButton() == MouseButton::LEFT)
760  {
761  if (mStick)
762  mPressed = !mPressed;
763 
764  if (mMousePressed && mHasMouse)
765  {
766  mMousePressed = false;
767  mClickCount = event.getClickCount();
769  }
770  else
771  {
772  mMousePressed = false;
773  mClickCount = 0;
774  }
775  event.consume();
776  }
777 }
778 
780 {
781  mRedraw = true;
782 }
783 
785 {
786  mRedraw = true;
787 }
788 
790 {
792  mVertexes2->clear();
794  mRedraw = true;
795  mTextChanged = true;
796 }
797 
799 {
800  const Font *const font = getFont();
801  const Skin *const skin = mSkin[BUTTON_STANDARD];
802  if (skin == nullptr)
803  return;
804  const int padding = skin->getPadding();
805 
806  if (mImages != nullptr)
807  {
808  const int spacing = mSpacing[BUTTON_STANDARD];
809  const int width = font->getWidth(mCaption);
810  if (width != 0)
811  setWidth(width + mImageWidth + spacing + 2 * padding);
812  else
813  setWidth(mImageWidth + 2 * padding);
814  int height = font->getHeight();
815  if (height < mImageHeight)
816  height = mImageHeight;
817  setHeight(height + 2 * padding);
818  }
819  else
820  {
821  setWidth(font->getWidth(mCaption) + 2 * padding);
822  setHeight(font->getHeight() + 2 * padding);
823  }
824 }
825 
827 {
828  const InputActionT action = event.getActionId();
829 
830  if (action == InputAction::GUI_SELECT)
831  {
832  mKeyPressed = true;
833  event.consume();
834  }
835 }
836 
838 {
839  const InputActionT action = event.getActionId();
840 
841  if (action == InputAction::GUI_SELECT && mKeyPressed)
842  {
843  mKeyPressed = false;
844  if (mStick)
845  mPressed = !mPressed;
847  event.consume();
848  }
849 }
850 
851 bool Button::isPressed2() const
852 {
853  return mPressed || isPressed();
854 }
855 
856 bool Button::isPressed() const
857 {
858  if (mMousePressed)
859  return mHasMouse;
860  return mKeyPressed;
861 }
862 
863 void Button::focusLost(const Event& event A_UNUSED)
864 {
865  mMousePressed = false;
866  mKeyPressed = false;
867 }
868 
870 {
871  if (event.getButton() == MouseButton::LEFT)
872  {
873  mMousePressed = true;
874  event.consume();
875  }
876 }
877 
879 {
880  mHasMouse = true;
881 }
882 
884 {
885  mHasMouse = false;
886 }
887 
889 {
890  event.consume();
891 }
892 
894 {
895  if (mWindow != nullptr)
896  mWindow->addWidgetListener(this);
897  Widget::setParent(widget);
898 }
899 
900 void Button::setWindow(Widget *const widget)
901 {
902  if ((widget == nullptr) && (mWindow != nullptr))
903  {
905  mWindow = nullptr;
906  }
907  else
908  {
909  Widget2::setWindow(widget);
910  }
911 }
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:394
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
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
virtual void decRef()
Definition: resource.cpp:49
void addActionListener(ActionListener *const actionListener)
Definition: widget.cpp:251
void focusLost(const Event &event)
Definition: button.cpp:863
void setImage(Image *const image)
Definition: button.cpp:378
static Image * getImageFromThemeXml(const std::string &name, const std::string &name2)
Definition: theme.cpp:925
TextChunk mTextChunk
Definition: button.h:295
void keyReleased(KeyEvent &event)
Definition: button.cpp:837
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:878
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:888
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:757
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:442
void adjustSize()
Definition: button.cpp:798
void widgetMoved(const Event &event)
Definition: button.cpp:784
void widgetHidden(const Event &event)
Definition: button.cpp:789
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:464
void distributeActionEvent()
Definition: widget.cpp:492
void keyPressed(KeyEvent &event)
Definition: button.cpp:826
#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:779
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:621
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
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:289
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:340
int height
Definition: rect.h:223
void updateAlpha()
Definition: button.cpp:417
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:893
bool mPressed
Definition: button.h:343
bool isPressed2() const
Definition: button.cpp:851
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:159
void setFocusable(const bool focusable)
Definition: widget.cpp:191
void mouseExited(MouseEvent &event)
Definition: button.cpp:883
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:1161
bool isPressed() const
Definition: button.cpp:856
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:869
Color color
Definition: textchunk.h:65
int getWidth() const A_INLINE
Definition: image.h:116
#define restrict
Definition: localconsts.h:164
const Color & getThemeColor(const ThemeColorIdT type, const unsigned int alpha) const A_INLINE
Definition: widget2.h:44
static float mAlpha
Definition: button.h:283
int getHeight() const
Definition: font.cpp:361
void deleteImage()
Definition: textchunk.cpp:192
void setWindow(Widget *const widget)
Definition: button.cpp:900
float guiAlpha
Definition: settings.h:129
Color color2
Definition: textchunk.h:66
static std::string const data[Button::BUTTON_COUNT]
Definition: button.cpp:90
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
std::string mSkinName
Definition: button.h:293
bool mTextChanged
Definition: button.h:344
bool mHasMouse
Definition: button.h:330
Skin * mSkin[BUTTON_COUNT]
Definition: button.h:285
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:291
int getHeight() const A_INLINE
Definition: image.h:122
void generate(TextChunk &chunk)
Definition: font.cpp:429