ManaPlus
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Attributes

#include <gui.h>

Public Member Functions

 Gui ()
 
 ~Gui ()
 
void postInit (Graphics *const graphics)
 
void logic ()
 
void slowLogic ()
 
void clearFonts ()
 
void draw ()
 
void videoResized () const
 
FocusHandlergetFocusHandler () const
 
FontgetFont () const
 
FontgetHelpFont () const
 
FontgetSecureFont () const
 
FontgetNpcFont () const
 
FontgetInfoParticleFont () const
 
void setUseCustomCursor (const bool customCursor)
 
void setCursorType (const CursorT index)
 
void setDoubleClick (const bool b)
 
void updateFonts ()
 
bool handleInput ()
 
bool handleKeyInput ()
 
void resetClickCount ()
 
MouseEventcreateMouseEvent (Window *const widget)
 
void addGlobalFocusListener (FocusListener *focusListener)
 
void removeGlobalFocusListener (FocusListener *focusListener)
 
void distributeGlobalFocusGainedEvent (const Event &focusEvent)
 
void removeDragged (const Widget *const widget)
 
int getLastMouseX () const
 
int getLastMouseY () const
 
void setTop (Widget *const top)
 
WidgetgetTop () const
 
void setGraphics (Graphics *const graphics)
 
GraphicsgetGraphics () const
 
void setInput (SDLInput *const input)
 
SDLInputgetInput () const
 
void addGlobalKeyListener (KeyListener *const keyListener)
 
void removeGlobalKeyListener (KeyListener *const keyListener)
 
bool isLongPress () const
 
int getMousePressLength () const
 

Static Public Member Functions

static void getAbsolutePosition (Widget *widget, int &x, int &y)
 
static uint8_t getMouseState (int &x, int &y)
 

Protected Member Functions

void handleMouseMoved (const MouseInput &mouseInput)
 
void handleMouseReleased (const MouseInput &mouseInput)
 
void handleMousePressed (const MouseInput &mouseInput)
 
void handleMouseInput ()
 
void distributeMouseEvent (Widget *const source, const MouseEventTypeT type, const MouseButtonT button, const int x, const int y, const bool force, const bool toSourceOnly)
 
void handleMouseWheelMovedDown (const MouseInput &mouseInput)
 
void handleMouseWheelMovedUp (const MouseInput &mouseInput)
 
WidgetgetWidgetAt (const int x, const int y) const
 
WidgetgetMouseEventSource (const int x, const int y) const
 
WidgetgetKeyEventSource () const
 
void distributeKeyEvent (KeyEvent &event) const
 
void distributeKeyEventToGlobalKeyListeners (KeyEvent &event)
 
void handleModalMouseInputFocus ()
 
void handleModalFocus ()
 
void handleModalFocusGained ()
 
void handleModalFocusReleased ()
 

Private Types

typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerListIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 

Private Attributes

WidgetmTop
 
GraphicsmGraphics
 
SDLInputmInput
 
FocusHandlermFocusHandler
 
KeyListenerList mKeyListeners
 
MouseButtonT mLastMousePressButton
 
unsigned int mLastMousePressTimeStamp
 
int mLastMouseX
 
int mLastMouseY
 
int mClickCount
 
MouseButtonT mLastMouseDragButton
 
std::deque< Widget * > mWidgetWithMouseQueue
 
GuiConfigListenermConfigListener
 
FontmGuiFont
 
FontmInfoParticleFont
 
FontmHelpFont
 
FontmSecureFont
 
FontmNpcFont
 
ImageSetmMouseCursors
 
float mMouseCursorAlpha
 
int mMouseInactivityTimer
 
CursorT mCursorType
 
FocusListenerList mFocusListeners
 
Color mForegroundColor
 
Color mForegroundColor2
 
time_t mTime
 
time_t mTime10
 
bool mCustomCursor
 
bool mDoubleClick
 

Detailed Description

Main GUI class.

Definition at line 115 of file gui.h.

Member Typedef Documentation

◆ FocusListenerIterator

typedef FocusListenerList::iterator Gui::FocusListenerIterator
private

Definition at line 510 of file gui.h.

◆ FocusListenerList

typedef std::list<FocusListener*> Gui::FocusListenerList
private

Definition at line 509 of file gui.h.

◆ KeyListenerList

typedef std::list<KeyListener*> Gui::KeyListenerList
private

Typedef.

Definition at line 437 of file gui.h.

◆ KeyListenerListIterator

typedef KeyListenerList::iterator Gui::KeyListenerListIterator
private

Typedef.

Definition at line 442 of file gui.h.

Constructor & Destructor Documentation

◆ Gui()

Gui::Gui ( )

Constructor.

Definition at line 113 of file gui.cpp.

113  :
114  mTop(nullptr),
115  mGraphics(nullptr),
116  mInput(nullptr),
118  mKeyListeners(),
121  mLastMouseX(0),
122  mLastMouseY(0),
123  mClickCount(1),
127  mGuiFont(nullptr),
128  mInfoParticleFont(nullptr),
129  mHelpFont(nullptr),
130  mSecureFont(nullptr),
131  mNpcFont(nullptr),
132  mMouseCursors(nullptr),
133  mMouseCursorAlpha(1.0F),
136 #ifdef ANDROID
137  mLastMouseRealX(0),
138  mLastMouseRealY(0),
139 #endif // ANDROID
140  mFocusListeners(),
142  mForegroundColor2(theme->getColor(ThemeColorId::TEXT_OUTLINE, 255)),
143  mTime(0),
144  mTime10(0),
145  mCustomCursor(false),
146  mDoubleClick(true)
147 {
148 }

◆ ~Gui()

Gui::~Gui ( )

Member Function Documentation

◆ addGlobalFocusListener()

void Gui::addGlobalFocusListener ( FocusListener focusListener)

Definition at line 1141 of file gui.cpp.

1142 {
1143  mFocusListeners.push_back(focusListener);
1144 }

References mFocusListeners.

Referenced by PopupList::postInit().

◆ addGlobalKeyListener()

void Gui::addGlobalKeyListener ( KeyListener *const  keyListener)

Adds a global key listener to the Gui. A global key listener will receive all key events generated from the GUI and global key listeners will receive the events before key listeners of widgets.

Parameters
keyListenerThe key listener to add.
See also
removeGlobalKeyListener

Definition at line 1209 of file gui.cpp.

1210 {
1211  mKeyListeners.push_back(keyListener);
1212 }

References mKeyListeners.

◆ clearFonts()

void Gui::clearFonts ( )

Definition at line 371 of file gui.cpp.

372 {
373  if (mGuiFont != nullptr)
374  mGuiFont->clear();
375  if (mInfoParticleFont != nullptr)
377  if (mHelpFont != nullptr)
378  mHelpFont->clear();
379  if (mSecureFont != nullptr)
380  mSecureFont->clear();
381  if (boldFont != nullptr)
382  boldFont->clear();
383  if (mNpcFont != nullptr)
384  mNpcFont->clear();
385 }

References boldFont, Font::clear(), mGuiFont, mHelpFont, mInfoParticleFont, mNpcFont, and mSecureFont.

◆ createMouseEvent()

MouseEvent * Gui::createMouseEvent ( Window *const  widget)

Definition at line 985 of file gui.cpp.

986 {
987  if ((viewport == nullptr) || (widget == nullptr))
988  return nullptr;
989 
990  int x = 0;
991  int y = 0;
992  int mouseX = 0;
993  int mouseY = 0;
994 
995  getAbsolutePosition(widget, x, y);
996  getMouseState(mouseX, mouseY);
997 
998  return new MouseEvent(widget,
1001  mouseX - x,
1002  mouseY - y,
1003  mClickCount);
1004 }

References MouseButton::EMPTY, getAbsolutePosition(), getMouseState(), mClickCount, MouseEventType::MOVED, viewport, x, and y.

Referenced by Window::setVisible().

◆ distributeGlobalFocusGainedEvent()

void Gui::distributeGlobalFocusGainedEvent ( const Event focusEvent)

Definition at line 1151 of file gui.cpp.

1152 {
1153  for (FocusListenerIterator iter = mFocusListeners.begin();
1154  iter != mFocusListeners.end();
1155  ++ iter)
1156  {
1157  (*iter)->focusGained(focusEvent);
1158  }
1159 }

References mFocusListeners.

Referenced by FocusHandler::distributeFocusGainedEvent().

◆ distributeKeyEvent()

void Gui::distributeKeyEvent ( KeyEvent event) const
protected

Distributes a key event.

Parameters
eventThe key event to distribute.

Definition at line 1319 of file gui.cpp.

1320 {
1321  Widget* parent = event.getSource();
1322  Widget* widget = parent;
1323 
1324  if (parent == nullptr)
1325  return;
1326  if (mFocusHandler->getModalFocused() != nullptr &&
1327  !widget->isModalFocused())
1328  {
1329  return;
1330  }
1331  if (mFocusHandler->getModalMouseInputFocused() != nullptr &&
1332  !widget->isModalMouseInputFocused())
1333  {
1334  return;
1335  }
1336 
1337  while (parent != nullptr)
1338  {
1339  // If the widget has been removed due to input
1340  // cancel the distribution.
1341  if (!Widget::widgetExists(widget))
1342  break;
1343 
1344  parent = widget->getParent();
1345 
1346  if (widget->isEnabled())
1347  {
1348  std::list<KeyListener*> keyListeners
1349  = widget->getKeyListeners();
1350 
1351  const KeyEventTypeT eventType = event.getType();
1352  // Send the event to all key listeners of the source widget.
1353  FOR_EACH (std::list<KeyListener*>::const_iterator,
1354  it, keyListeners)
1355  {
1356  switch (eventType)
1357  {
1358  case KeyEventType::PRESSED:
1359  (*it)->keyPressed(event);
1360  break;
1362  (*it)->keyReleased(event);
1363  break;
1364  default:
1365  break;
1366  }
1367  }
1368  }
1369 
1370  const Widget *const swap = widget;
1371  widget = parent;
1372  parent = swap->getParent();
1373 
1374  // If a non modal focused widget has been reach
1375  // and we have modal focus cancel the distribution.
1376  if ((widget != nullptr) &&
1377  (mFocusHandler->getModalFocused() != nullptr) &&
1378  !widget->isModalFocused())
1379  {
1380  break;
1381  }
1382  }
1383 }

References FOR_EACH, Widget::getKeyListeners(), FocusHandler::getModalFocused(), FocusHandler::getModalMouseInputFocused(), Widget::getParent(), Widget::isEnabled(), Widget::isModalFocused(), Widget::isModalMouseInputFocused(), mFocusHandler, KeyEventType::PRESSED, KeyEventType::RELEASED, and Widget::widgetExists().

Referenced by handleKeyInput().

◆ distributeKeyEventToGlobalKeyListeners()

void Gui::distributeKeyEventToGlobalKeyListeners ( KeyEvent event)
protected

Distributes a key event to the global key listeners.

Parameters
eventThe key event to distribute.

Definition at line 1385 of file gui.cpp.

1386 {
1387  BLOCK_START("Gui::distributeKeyEventToGlobalKeyListeners")
1388  const KeyEventTypeT eventType = event.getType();
1390  {
1391  switch (eventType)
1392  {
1393  case KeyEventType::PRESSED:
1394  (*it)->keyPressed(event);
1395  break;
1397  (*it)->keyReleased(event);
1398  break;
1399  default:
1400  break;
1401  }
1402 
1403  if (event.isConsumed())
1404  break;
1405  }
1406  BLOCK_END("Gui::distributeKeyEventToGlobalKeyListeners")
1407 }

References BLOCK_END, BLOCK_START, FOR_EACH, InputGuiEvent::isConsumed(), mKeyListeners, KeyEventType::PRESSED, and KeyEventType::RELEASED.

Referenced by handleKeyInput().

◆ distributeMouseEvent()

void Gui::distributeMouseEvent ( Widget *const  source,
const MouseEventTypeT  type,
const MouseButtonT  button,
const int  x,
const int  y,
const bool  force,
const bool  toSourceOnly 
)
protected

Definition at line 853 of file gui.cpp.

859 {
860  if ((source == nullptr) || (mFocusHandler == nullptr))
861  return;
862 
863  Widget *widget = source;
864 
865  if (!force)
866  {
867  if (mFocusHandler->getModalFocused() != nullptr
868  && !widget->isModalFocused())
869  {
870  return;
871  }
872  if (mFocusHandler->getModalMouseInputFocused() != nullptr
873  && !widget->isModalMouseInputFocused())
874  {
875  return;
876  }
877  }
878 
879  MouseEvent event(source,
880  type, button,
881  x, y, mClickCount);
882 
883  Widget* parent = source;
884  while (parent != nullptr)
885  {
886  // If the widget has been removed due to input
887  // cancel the distribution.
888  if (!Widget::widgetExists(widget))
889  break;
890 
891  parent = widget->getParent();
892 
893  if (widget->isEnabled() || force)
894  {
895  int widgetX;
896  int widgetY;
897  widget->getAbsolutePosition(widgetX, widgetY);
898 
899  event.setX(x - widgetX);
900  event.setY(y - widgetY);
901 
902  std::list<MouseListener*> mouseListeners
903  = widget->getMouseListeners();
904 
905  const MouseEventTypeT mouseType = event.getType();
906  // Send the event to all mouse listeners of the widget.
907  FOR_EACH (std::list<MouseListener*>::const_iterator,
908  it, mouseListeners)
909  {
910  switch (mouseType)
911  {
913  (*it)->mouseEntered(event);
914  break;
916  (*it)->mouseExited(event);
917  break;
919  (*it)->mouseMoved(event);
920  break;
922  (*it)->mousePressed(event);
923  break;
926  (*it)->mouseReleased(event);
927  break;
929  (*it)->mouseWheelMovedUp(event);
930  break;
932  (*it)->mouseWheelMovedDown(event);
933  break;
935  (*it)->mouseDragged(event);
936  break;
938  (*it)->mouseClicked(event);
939  break;
940  default:
941  break;
942  }
943  }
944 
945  if (toSourceOnly)
946  break;
947  }
948 
949  const Widget *const swap = widget;
950  widget = parent;
951  parent = swap->getParent();
952 
953 #ifndef DYECMD
954  if (type == MouseEventType::RELEASED)
955  dragDrop.clear();
956 #endif // DYECMD
957 
958  if ((widget == nullptr) || event.isConsumed())
959  break;
960 
961  // If a non modal focused widget has been reach
962  // and we have modal focus cancel the distribution.
963  if ((mFocusHandler->getModalFocused() != nullptr)
964  && !widget->isModalFocused())
965  {
966  break;
967  }
968 
969  // If a non modal mouse input focused widget has been reach
970  // and we have modal mouse input focus cancel the distribution.
971  if ((mFocusHandler->getModalMouseInputFocused() != nullptr)
972  && !widget->isModalMouseInputFocused())
973  {
974  break;
975  }
976  }
977 }

References DragDrop::clear(), MouseEventType::CLICKED, dragDrop, MouseEventType::DRAGGED, MouseEventType::ENTERED, MouseEventType::EXITED, FOR_EACH, Widget::getAbsolutePosition(), FocusHandler::getModalFocused(), FocusHandler::getModalMouseInputFocused(), Widget::getMouseListeners(), Widget::getParent(), InputGuiEvent::isConsumed(), Widget::isEnabled(), Widget::isModalFocused(), Widget::isModalMouseInputFocused(), mClickCount, mFocusHandler, MouseEventType::MOVED, MouseEventType::PRESSED, MouseEventType::RELEASED, MouseEventType::RELEASED2, MouseEventType::WHEEL_MOVED_DOWN, MouseEventType::WHEEL_MOVED_UP, Widget::widgetExists(), x, and y.

Referenced by handleModalFocusGained(), handleModalFocusReleased(), handleMouseMoved(), handleMousePressed(), handleMouseReleased(), handleMouseWheelMovedDown(), and handleMouseWheelMovedUp().

◆ draw()

void Gui::draw ( )

Draws the whole Gui by calling draw functions down in the Gui hierarchy. It also draws the mouse pointer.

Definition at line 469 of file gui.cpp.

470 {
471  BLOCK_START("Gui::draw 1")
472  Widget *const top = getTop();
473  if (top == nullptr)
474  return;
475  mGraphics->pushClipArea(top->getDimension());
476 
478  {
479  top->draw(mGraphics);
480  touchManager.draw();
481  }
482  else
483  {
484  top->safeDraw(mGraphics);
486  }
487 
488  int mouseX;
489  int mouseY;
490  const MouseStateType button = getMouseState(mouseX, mouseY);
491 
492  if ((settings.mouseFocused ||
493  ((button & SDL_BUTTON(1)) != 0)) &&
494  mMouseCursors != nullptr &&
495  mCustomCursor &&
496  mMouseCursorAlpha > 0.0F)
497  {
498 #ifndef DYECMD
499  const Image *const image = dragDrop.getItemImage();
500  if (mGuiFont != nullptr)
501  {
502  const std::string &str = dragDrop.getText();
503  if (!str.empty())
504  {
505  const int posX = mouseX - mGuiFont->getWidth(str) / 2;
506  const int posY = mouseY +
507  (image != nullptr ? image->mBounds.h / 2 : 0);
510  str,
511  posX, posY);
512  }
513  }
514  if (image != nullptr)
515  {
516  const int posX = mouseX - (image->mBounds.w / 2);
517  const int posY = mouseY - (image->mBounds.h / 2);
518  mGraphics->drawImage(image, posX, posY);
519  }
520 #endif // DYECMD
521 
522  Image *const mouseCursor = mMouseCursors->get(
524  if (mouseCursor != nullptr)
525  {
526  mouseCursor->setAlpha(mMouseCursorAlpha);
527  mGraphics->drawImage(mouseCursor, mouseX - 15, mouseY - 17);
528  }
529  }
530 
532  BLOCK_END("Gui::draw 1")
533 }

References BLOCK_END, BLOCK_START, CAST_SIZE, dragDrop, TouchManager::draw(), Graphics::drawImage(), Font::drawString(), ImageSet::get(), DragDrop::getItemImage(), getMouseState(), DragDrop::getText(), getTop(), Font::getWidth(), isBatchDrawRenders, Image::mBounds, mCursorType, mCustomCursor, mForegroundColor, mForegroundColor2, mGraphics, mGuiFont, mMouseCursorAlpha, mMouseCursors, Settings::mouseFocused, MouseStateType, openGLMode, Graphics::popClipArea(), Graphics::pushClipArea(), TouchManager::safeDraw(), Image::setAlpha(), settings, top, and touchManager.

Referenced by Game::createScreenshot(), Client::gameExec(), and WindowManager::resizeVideo().

◆ getAbsolutePosition()

void Gui::getAbsolutePosition ( Widget widget,
int &  x,
int &  y 
)
static

Definition at line 1006 of file gui.cpp.

1009 {
1010  if (widget == nullptr)
1011  return;
1012  x = 0;
1013  y = 0;
1014  while (widget->getParent() != nullptr)
1015  {
1016  x += widget->getX();
1017  y += widget->getY();
1018  widget = widget->getParent();
1019  }
1020 }

References x, and y.

Referenced by createMouseEvent().

◆ getFocusHandler()

FocusHandler* Gui::getFocusHandler ( ) const
inline

Definition at line 153 of file gui.h.

154  { return mFocusHandler; }

References mFocusHandler.

Referenced by InputManager::updateConditionMask().

◆ getFont()

Font* Gui::getFont ( ) const
inline

◆ getGraphics()

Graphics * Gui::getGraphics ( ) const

Gets the graphics object used for drawing.

Returns
The graphics object used for drawing. NULL if no graphics object has been set.
See also
setGraphics, AllegroGraphics, HGEGraphics, OpenLayerGraphics, OpenGLGraphics, SDLGraphics

Definition at line 1194 of file gui.cpp.

1195 {
1196  return mGraphics;
1197 }

References mGraphics.

◆ getHelpFont()

Font* Gui::getHelpFont ( ) const
inline

Return help font.

Definition at line 165 of file gui.h.

166  { return mHelpFont; }

References mHelpFont.

Referenced by DidYouKnowWindow::DidYouKnowWindow(), HelpWindow::HelpWindow(), ServerInfoWindow::ServerInfoWindow(), and Setup_Input::Setup_Input().

◆ getInfoParticleFont()

Font* Gui::getInfoParticleFont ( ) const
inline

Return the Font used for "Info Particles", i.e. ones showing, what you picked up, etc.

Definition at line 184 of file gui.h.

185  { return mInfoParticleFont; }

References mInfoParticleFont.

Referenced by LocalPlayer::logic(), and Being::takeDamage().

◆ getInput()

SDLInput * Gui::getInput ( ) const

Gets the input object being used for input handling.

Returns
The input object used for handling input. NULL if no input object has been set.
See also
setInput, AllegroInput, HGEInput, OpenLayerInput, SDLInput

Definition at line 1204 of file gui.cpp.

1205 {
1206  return mInput;
1207 }

References mInput.

◆ getKeyEventSource()

Widget * Gui::getKeyEventSource ( ) const
protected

Gets the source of the key event.

Returns
The source widget of the key event.

Definition at line 1305 of file gui.cpp.

1306 {
1307  Widget* widget = mFocusHandler->getFocused();
1308 
1309  while (widget != nullptr &&
1310  widget->getInternalFocusHandler() != nullptr &&
1311  widget->getInternalFocusHandler()->getFocused() != nullptr)
1312  {
1313  widget = widget->getInternalFocusHandler()->getFocused();
1314  }
1315 
1316  return widget;
1317 }

References FocusHandler::getFocused(), Widget::getInternalFocusHandler(), and mFocusHandler.

Referenced by handleKeyInput().

◆ getLastMouseX()

int Gui::getLastMouseX ( ) const
inline

Definition at line 223 of file gui.h.

224  { return mLastMouseX; }

References mLastMouseX.

Referenced by SDLInput::pushInput().

◆ getLastMouseY()

int Gui::getLastMouseY ( ) const
inline

Definition at line 226 of file gui.h.

227  { return mLastMouseY; }

References mLastMouseY.

Referenced by SDLInput::pushInput().

◆ getMouseEventSource()

Widget * Gui::getMouseEventSource ( const int  x,
const int  y 
) const
protected

Gets the source of the mouse event.

Returns
The source widget of the mouse event.

Definition at line 1289 of file gui.cpp.

1290 {
1291  Widget *const widget = getWidgetAt(x, y);
1292  if (widget == nullptr)
1293  return nullptr;
1294 
1295  if (mFocusHandler != nullptr &&
1296  mFocusHandler->getModalMouseInputFocused() != nullptr &&
1297  !widget->isModalMouseInputFocused())
1298  {
1300  }
1301 
1302  return widget;
1303 }

References FocusHandler::getModalMouseInputFocused(), getWidgetAt(), Widget::isModalMouseInputFocused(), mFocusHandler, x, and y.

Referenced by handleModalFocusReleased(), handleMouseMoved(), handleMousePressed(), handleMouseReleased(), handleMouseWheelMovedDown(), and handleMouseWheelMovedUp().

◆ getMousePressLength()

int Gui::getMousePressLength ( ) const

Definition at line 1529 of file gui.cpp.

1530 {
1531  if (mLastMousePressTimeStamp == 0U)
1532  return 0;
1533  unsigned int ticks = SDL_GetTicks();
1534  if (ticks > mLastMousePressTimeStamp)
1535  return ticks - mLastMousePressTimeStamp;
1536  return mLastMousePressTimeStamp - ticks;
1537 }

References mLastMousePressTimeStamp.

Referenced by isLongPress().

◆ getMouseState()

uint8_t Gui::getMouseState ( int &  x,
int &  y 
)
static

Definition at line 1170 of file gui.cpp.

1171 {
1172  const MouseStateType res = SDL_GetMouseState(&x, &y);
1173  const int scale = mainGraphics->getScale();
1174  x /= scale;
1175  y /= scale;
1176  return res;
1177 }

References Graphics::getScale(), mainGraphics, MouseStateType, x, and y.

Referenced by createMouseEvent(), draw(), Viewport::logic(), ToolTipListener::mouseMoved(), CharacterDisplay::mouseMoved(), PopupMenu::setMousePos(), PopupMenu::setMousePos2(), SDLInput::simulateMouseMove(), and ChatWindow::updateVisibility().

◆ getNpcFont()

Font* Gui::getNpcFont ( ) const
inline

Return npc font.

Definition at line 177 of file gui.h.

178  { return mNpcFont; }

References mNpcFont.

Referenced by NpcDialog::createSkinControls(), NpcDialog::NpcDialog(), and QuestsWindow::QuestsWindow().

◆ getSecureFont()

Font* Gui::getSecureFont ( ) const
inline

Return secure font.

Definition at line 171 of file gui.h.

172  { return mSecureFont; }

References mSecureFont.

Referenced by ChatWindow::addWhisperTab(), TradeWindow::initTrade(), BeingPopup::show(), and Being::showName().

◆ getTop()

Widget* Gui::getTop ( ) const
inline

Gets the top widget. The top widget is the root widget of the GUI.

Returns
The top widget. NULL if no top widget has been set.

Definition at line 247 of file gui.h.

248  { return mTop; }

References mTop.

Referenced by draw(), Game::Game(), Client::stateGame(), Client::stateGame1(), and videoResized().

◆ getWidgetAt()

Widget * Gui::getWidgetAt ( const int  x,
const int  y 
) const
protected

Gets the widget at a certain position.

Returns
The widget at a certain position.

Definition at line 1267 of file gui.cpp.

1268 {
1269  // If the widget's parent has no child then we have found the widget..
1270  Widget* parent = mTop;
1271  Widget* child = mTop;
1272  Widget* selectable = mTop;
1273 
1274  while (child != nullptr)
1275  {
1276  Widget *const swap = child;
1277  int parentX;
1278  int parentY;
1279  parent->getAbsolutePosition(parentX, parentY);
1280  child = parent->getWidgetAt(x - parentX, y - parentY);
1281  parent = swap;
1282  if (parent->isSelectable())
1283  selectable = parent;
1284  }
1285 
1286  return selectable;
1287 }

References Widget::getAbsolutePosition(), Widget::getWidgetAt(), Widget::isSelectable(), mTop, x, and y.

Referenced by getMouseEventSource().

◆ handleInput()

bool Gui::handleInput ( )

Definition at line 387 of file gui.cpp.

388 {
389  if (mInput != nullptr)
390  return handleKeyInput();
391  return false;
392 }

References handleKeyInput(), and mInput.

Referenced by Client::gameExec(), and InputManager::handleEvent().

◆ handleKeyInput()

bool Gui::handleKeyInput ( )

Definition at line 394 of file gui.cpp.

395 {
396  if (guiInput == nullptr)
397  return false;
398 
399  BLOCK_START("Gui::handleKeyInput")
400  bool consumed(false);
401 
402  while (!mInput->isKeyQueueEmpty())
403  {
404  const KeyInput keyInput = guiInput->dequeueKeyInput();
405 
406  KeyEvent eventToGlobalKeyListeners(nullptr,
407  keyInput.getType(),
408  keyInput.getActionId(), keyInput.getKey());
409 
410 #ifdef USE_SDL2
411  if (!keyInput.getText().empty())
412  eventToGlobalKeyListeners.setText(keyInput.getText());
413 #endif // USE_SDL2
414 
416  eventToGlobalKeyListeners);
417 
418  // If a global key listener consumes the event it will not be
419  // sent further to the source of the event.
420  if (eventToGlobalKeyListeners.isConsumed())
421  {
422  consumed = true;
423  continue;
424  }
425 
426  if (mFocusHandler != nullptr)
427  {
428  bool eventConsumed = false;
429 
430  // Send key inputs to the focused widgets
431  if (mFocusHandler->getFocused() != nullptr)
432  {
433  KeyEvent event(getKeyEventSource(),
434  keyInput.getType(),
435  keyInput.getActionId(), keyInput.getKey());
436 #ifdef USE_SDL2
437  if (!keyInput.getText().empty())
438  event.setText(keyInput.getText());
439 #endif // USE_SDL2
440 
443  else
444  distributeKeyEvent(event);
445 
446  eventConsumed = event.isConsumed();
447  if (eventConsumed)
448  consumed = true;
449  }
450 
451  // If the key event hasn't been consumed and
452  // tabbing is enable check for tab press and
453  // change focus.
454  if (!eventConsumed && keyInput.getActionId()
456  keyInput.getType() == KeyEventType::PRESSED)
457  {
460  else
462  }
463  }
464  } // end while
465  BLOCK_END("Gui::handleKeyInput")
466  return consumed;
467 }

References BLOCK_END, BLOCK_START, SDLInput::dequeueKeyInput(), distributeKeyEvent(), distributeKeyEventToGlobalKeyListeners(), FocusHandler::focusNone(), KeyInput::getActionId(), FocusHandler::getFocused(), KeyInput::getKey(), getKeyEventSource(), KeyInput::getType(), InputAction::GUI_MOD, InputAction::GUI_TAB, guiInput, inputManager, InputManager::isActionActive(), InputGuiEvent::isConsumed(), Widget::isFocusable(), SDLInput::isKeyQueueEmpty(), mFocusHandler, mInput, KeyEventType::PRESSED, FocusHandler::tabNext(), and FocusHandler::tabPrevious().

Referenced by handleInput().

◆ handleModalFocus()

void Gui::handleModalFocus ( )
protected

Handles modal focus. Modal focus needs to be checked at each logic iteration as it might be necessary to distribute mouse entered or mouse exited events.

Definition at line 1433 of file gui.cpp.

1434 {
1435  BLOCK_START("Gui::handleModalFocus")
1436  Widget *const lastModalWidget
1437  = mFocusHandler->getLastWidgetWithModalFocus();
1438  Widget *const modalWidget = mFocusHandler->getModalFocused();
1439 
1440  if (lastModalWidget != modalWidget)
1441  {
1442  // Check if modal focus has been gained by a widget.
1443  if (lastModalWidget == nullptr)
1444  {
1447  }
1448  // Check if modal focus has been released.
1449  else
1450  {
1453  }
1454  }
1455  BLOCK_END("Gui::handleModalFocus")
1456 }

References BLOCK_END, BLOCK_START, FocusHandler::getLastWidgetWithModalFocus(), FocusHandler::getModalFocused(), handleModalFocusGained(), handleModalFocusReleased(), mFocusHandler, and FocusHandler::setLastWidgetWithModalFocus().

Referenced by logic().

◆ handleModalFocusGained()

void Gui::handleModalFocusGained ( )
protected

Handles modal focus gained. If modal focus has been gained it might be necessary to distribute mouse entered or mouse exited events.

Definition at line 1458 of file gui.cpp.

1459 {
1460  // Distribute an event to all widgets in the "widget with mouse" queue.
1461  while (!mWidgetWithMouseQueue.empty())
1462  {
1463  Widget *const widget = mWidgetWithMouseQueue.front();
1464 
1465  if (Widget::widgetExists(widget))
1466  {
1467  distributeMouseEvent(widget,
1470  mLastMouseX,
1471  mLastMouseY,
1472  true,
1473  true);
1474  }
1475 
1476  mWidgetWithMouseQueue.pop_front();
1477  }
1478 
1481 }

References distributeMouseEvent(), MouseEventType::EXITED, FocusHandler::getModalMouseInputFocused(), mFocusHandler, mLastMousePressButton, mLastMouseX, mLastMouseY, mWidgetWithMouseQueue, FocusHandler::setLastWidgetWithModalMouseInputFocus(), and Widget::widgetExists().

Referenced by handleModalFocus(), and handleModalMouseInputFocus().

◆ handleModalFocusReleased()

void Gui::handleModalFocusReleased ( )
protected

Handles modal mouse input focus gained. If modal focus has been gained it might be necessary to distribute mouse entered or mouse exited events.

Definition at line 1483 of file gui.cpp.

1484 {
1485  // Check all widgets below the mouse to see if they are
1486  // present in the "widget with mouse" queue. If a widget
1487  // is not then it should be added and an entered event should
1488  // be sent to it.
1490  Widget* parent = widget;
1491 
1492  while (parent != nullptr &&
1493  widget != nullptr)
1494  {
1495  parent = widget->getParent();
1496 
1497  // Check if the widget is present in the "widget with mouse" queue.
1498  bool widgetIsPresentInQueue = false;
1499  FOR_EACH (std::deque<Widget*>::const_iterator,
1500  iter, mWidgetWithMouseQueue)
1501  {
1502  if (*iter == widget)
1503  {
1504  widgetIsPresentInQueue = true;
1505  break;
1506  }
1507  }
1508 
1509  // Widget is not present, send an entered event and add
1510  // it to the "widget with mouse" queue.
1511  if (!widgetIsPresentInQueue && Widget::widgetExists(widget))
1512  {
1513  distributeMouseEvent(widget,
1516  mLastMouseX,
1517  mLastMouseY,
1518  false,
1519  true);
1520  mWidgetWithMouseQueue.push_front(widget);
1521  }
1522 
1523  const Widget *const swap = widget;
1524  widget = parent;
1525  parent = swap->getParent();
1526  }
1527 }

References distributeMouseEvent(), MouseEventType::ENTERED, FOR_EACH, getMouseEventSource(), Widget::getParent(), mLastMousePressButton, mLastMouseX, mLastMouseY, mWidgetWithMouseQueue, and Widget::widgetExists().

Referenced by handleModalFocus(), and handleModalMouseInputFocus().

◆ handleModalMouseInputFocus()

void Gui::handleModalMouseInputFocus ( )
protected

Handles modal mouse input focus. Modal mouse input focus needs to be checked at each logic iteration as it might be necessary to distribute mouse entered or mouse exited events.

Definition at line 1409 of file gui.cpp.

1410 {
1411  BLOCK_START("Gui::handleModalMouseInputFocus")
1412  Widget *const lastModalWidget
1413  = mFocusHandler->getLastWidgetWithModalMouseInputFocus();
1414  Widget *const modalWidget = mFocusHandler->getModalMouseInputFocused();
1415  if (lastModalWidget != modalWidget)
1416  {
1417  // Check if modal mouse input focus has been gained by a widget.
1418  if (lastModalWidget == nullptr)
1419  {
1422  }
1423  // Check if modal mouse input focus has been released.
1424  else
1425  {
1428  }
1429  }
1430  BLOCK_END("Gui::handleModalMouseInputFocus")
1431 }

References BLOCK_END, BLOCK_START, FocusHandler::getLastWidgetWithModalMouseInputFocus(), FocusHandler::getModalMouseInputFocused(), handleModalFocusGained(), handleModalFocusReleased(), mFocusHandler, and FocusHandler::setLastWidgetWithModalMouseInputFocus().

Referenced by logic().

◆ handleMouseInput()

void Gui::handleMouseInput ( )
protected

Definition at line 1022 of file gui.cpp.

1023 {
1024  BLOCK_START("Gui::handleMouseInput")
1025  while (!mInput->isMouseQueueEmpty())
1026  {
1027  const MouseInput mouseInput = guiInput->dequeueMouseInput();
1028 
1029  if (touchManager.processEvent(mouseInput))
1030  {
1031 #ifdef ANDROID
1032 #ifndef USE_SDL2
1033  SDL_WarpMouse(mLastMouseX, mLastMouseY,
1034  mLastMouseRealX, mLastMouseRealY);
1035 #endif // USE_SDL2
1036 #endif // ANDROID
1037 
1039  continue;
1040  }
1041 
1042  // Save the current mouse state. It will be needed if modal focus
1043  // changes or modal mouse input focus changes.
1044  mLastMouseX = mouseInput.getX();
1045  mLastMouseY = mouseInput.getY();
1046 #ifdef ANDROID
1047  mLastMouseRealX = mouseInput.getRealX();
1048  mLastMouseRealY = mouseInput.getRealY();
1049 #endif // ANDROID
1050 
1051  switch (mouseInput.getType())
1052  {
1054  handleMousePressed(mouseInput);
1055  break;
1057  handleMouseReleased(mouseInput);
1058  break;
1059  case MouseEventType::MOVED:
1060  handleMouseMoved(mouseInput);
1061  break;
1063  handleMouseWheelMovedDown(mouseInput);
1064  break;
1066  handleMouseWheelMovedUp(mouseInput);
1067  break;
1073  default:
1074  break;
1075  }
1076  }
1077  BLOCK_END("Gui::handleMouseInput")
1078 }

References BLOCK_END, BLOCK_START, MouseEventType::CLICKED, SDLInput::dequeueMouseInput(), MouseEventType::DRAGGED, MouseEventType::ENTERED, MouseEventType::EXITED, MouseInput::getRealX(), MouseInput::getRealY(), MouseInput::getType(), MouseInput::getX(), MouseInput::getY(), guiInput, handleMouseMoved(), handleMousePressed(), handleMouseReleased(), handleMouseWheelMovedDown(), handleMouseWheelMovedUp(), SDLInput::isMouseQueueEmpty(), mInput, mLastMouseX, mLastMouseY, mMouseInactivityTimer, MouseEventType::MOVED, MouseEventType::PRESSED, TouchManager::processEvent(), MouseEventType::RELEASED, MouseEventType::RELEASED2, touchManager, MouseEventType::WHEEL_MOVED_DOWN, and MouseEventType::WHEEL_MOVED_UP.

Referenced by logic().

◆ handleMouseMoved()

void Gui::handleMouseMoved ( const MouseInput mouseInput)
protected

Definition at line 592 of file gui.cpp.

593 {
594  // Check if the mouse leaves the application window.
595  if (mTop != nullptr &&
596  !mWidgetWithMouseQueue.empty() &&
597  (mouseInput.getX() < 0 ||
598  mouseInput.getY() < 0 ||
599  !mTop->getDimension().isPointInRect(mouseInput.getX(),
600  mouseInput.getY())))
601  {
602  // Distribute an event to all widgets in the
603  // "widget with mouse" queue.
604  while (!mWidgetWithMouseQueue.empty())
605  {
606  Widget *const widget = mWidgetWithMouseQueue.front();
607 
608  if (Widget::widgetExists(widget))
609  {
610  distributeMouseEvent(widget,
612  mouseInput.getButton(),
613  mouseInput.getX(),
614  mouseInput.getY(),
615  true,
616  true);
617  }
618 
619  mWidgetWithMouseQueue.pop_front();
620  }
621 
623  return;
624  }
625 
626  const int mouseX = mouseInput.getX();
627  const int mouseY = mouseInput.getY();
628  const MouseButtonT button = mouseInput.getButton();
629 
630  // Check if there is a need to send mouse exited events by
631  // traversing the "widget with mouse" queue.
632  bool widgetWithMouseQueueCheckDone = mWidgetWithMouseQueue.empty();
633  while (!widgetWithMouseQueueCheckDone)
634  {
635  unsigned int iterations = 0;
636  for (std::deque<Widget*>::iterator
637  iter = mWidgetWithMouseQueue.begin();
638  iter != mWidgetWithMouseQueue.end();
639  ++ iter)
640  {
641  Widget *const widget = *iter;
642 
643  // If a widget in the "widget with mouse queue" doesn't
644  // exists anymore it should be removed from the queue.
645  if (!Widget::widgetExists(widget))
646  {
647  mWidgetWithMouseQueue.erase(iter);
648  break;
649  }
650  else
651  {
652  int x;
653  int y;
654  widget->getAbsolutePosition(x, y);
655 
656  if (x > mouseX
657  || y > mouseY
658  || x + widget->getWidth() <= mouseX
659  || y + widget->getHeight() <= mouseY
660  || !widget->isVisible())
661  {
662  distributeMouseEvent(widget,
664  button,
665  mouseX,
666  mouseY,
667  true,
668  true);
669  mClickCount = 1;
671  mWidgetWithMouseQueue.erase(iter);
672  break;
673  }
674  }
675 
676  iterations++;
677  }
678 
679  widgetWithMouseQueueCheckDone =
680  (CAST_SIZE(iterations) == mWidgetWithMouseQueue.size());
681  }
682 
683  // Check all widgets below the mouse to see if they are
684  // present in the "widget with mouse" queue. If a widget
685  // is not then it should be added and an entered event should
686  // be sent to it.
687  Widget* parent = getMouseEventSource(mouseX, mouseY);
688  Widget* widget = parent;
689 
690  // If a widget has modal mouse input focus then it will
691  // always be returned from getMouseEventSource, but we only wan't to
692  // send mouse entered events if the mouse has actually entered the
693  // widget with modal mouse input focus, hence we need to check if
694  // that's the case. If it's not we should simply ignore to send any
695  // mouse entered events.
696  if ((mFocusHandler->getModalMouseInputFocused() != nullptr)
698  && Widget::widgetExists(widget) &&
699  (widget != nullptr))
700  {
701  int x;
702  int y;
703  widget->getAbsolutePosition(x, y);
704 
705  if (x > mouseX || y > mouseY
706  || x + widget->getWidth() <= mouseX
707  || y + widget->getHeight() <= mouseY)
708  {
709  parent = nullptr;
710  }
711  }
712 
713  while (parent != nullptr)
714  {
715  parent = widget->getParent();
716 
717  // Check if the widget is present in the "widget with mouse" queue.
718  bool widgetIsPresentInQueue = false;
719  FOR_EACH (std::deque<Widget*>::const_iterator,
720  iter, mWidgetWithMouseQueue)
721  {
722  if (*iter == widget)
723  {
724  widgetIsPresentInQueue = true;
725  break;
726  }
727  }
728 
729  // Widget is not present, send an entered event and add
730  // it to the "widget with mouse" queue.
731  if (!widgetIsPresentInQueue
732  && Widget::widgetExists(widget))
733  {
734  distributeMouseEvent(widget,
736  button,
737  mouseX,
738  mouseY,
739  true,
740  true);
741  mWidgetWithMouseQueue.push_front(widget);
742  }
743 
744  const Widget *const swap = widget;
745  widget = parent;
746  parent = swap->getParent();
747  }
748 
749  if (mFocusHandler->getDraggedWidget() != nullptr)
750  {
754  mouseX,
755  mouseY,
756  false,
757  false);
758  }
759  else
760  {
761  Widget *const sourceWidget = getMouseEventSource(mouseX, mouseY);
762  distributeMouseEvent(sourceWidget,
764  button,
765  mouseX,
766  mouseY,
767  false,
768  false);
769  }
771 }

References CAST_SIZE, distributeMouseEvent(), MouseEventType::DRAGGED, MouseEventType::ENTERED, MouseEventType::EXITED, FOR_EACH, Widget::getAbsolutePosition(), MouseInput::getButton(), Widget::getDimension(), FocusHandler::getDraggedWidget(), Widget::getHeight(), FocusHandler::getModalMouseInputFocused(), getMouseEventSource(), Widget::getParent(), Widget::getWidth(), MouseInput::getX(), MouseInput::getY(), Rect::isPointInRect(), Widget::isVisible(), mClickCount, mFocusHandler, mLastMouseDragButton, mLastMousePressTimeStamp, mMouseInactivityTimer, MouseEventType::MOVED, mTop, mWidgetWithMouseQueue, Widget::widgetExists(), x, and y.

Referenced by handleMouseInput().

◆ handleMousePressed()

void Gui::handleMousePressed ( const MouseInput mouseInput)
protected

Definition at line 773 of file gui.cpp.

774 {
775  const int x = mouseInput.getX();
776  const int y = mouseInput.getY();
777  const MouseButtonT button = mouseInput.getButton();
778  const unsigned int timeStamp = mouseInput.getTimeStamp();
779 
780  Widget *sourceWidget = getMouseEventSource(x, y);
781 
782  if (mFocusHandler->getDraggedWidget() != nullptr)
783  sourceWidget = mFocusHandler->getDraggedWidget();
784 
785  if (sourceWidget == nullptr)
786  return;
787  int sourceWidgetX;
788  int sourceWidgetY;
789  sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
790 
791  if (((mFocusHandler->getModalFocused() != nullptr)
792  && sourceWidget->isModalFocused())
793  || (mFocusHandler->getModalFocused() == nullptr))
794  {
795  sourceWidget->requestFocus();
796  }
797 
798  if (mDoubleClick &&
799  timeStamp - mLastMousePressTimeStamp < 250U &&
800  mLastMousePressButton == button)
801  {
802  mClickCount ++;
803  }
804  else
805  {
806  mClickCount = 1;
807  }
808 
809  distributeMouseEvent(sourceWidget,
811  button,
812  x,
813  y,
814  false,
815  false);
816  mFocusHandler->setLastWidgetPressed(sourceWidget);
817  mFocusHandler->setDraggedWidget(sourceWidget);
818  mLastMouseDragButton = button;
819  mLastMousePressButton = button;
820  mLastMousePressTimeStamp = timeStamp;
821 }

References distributeMouseEvent(), Widget::getAbsolutePosition(), MouseInput::getButton(), FocusHandler::getDraggedWidget(), FocusHandler::getModalFocused(), getMouseEventSource(), MouseInput::getTimeStamp(), MouseInput::getX(), MouseInput::getY(), Widget::isModalFocused(), mClickCount, mDoubleClick, mFocusHandler, mLastMouseDragButton, mLastMousePressButton, mLastMousePressTimeStamp, MouseEventType::PRESSED, Widget::requestFocus(), FocusHandler::setDraggedWidget(), FocusHandler::setLastWidgetPressed(), x, and y.

Referenced by handleMouseInput().

◆ handleMouseReleased()

void Gui::handleMouseReleased ( const MouseInput mouseInput)
protected

Definition at line 1080 of file gui.cpp.

1081 {
1082  Widget *sourceWidget = getMouseEventSource(
1083  mouseInput.getX(), mouseInput.getY());
1084 
1085  int sourceWidgetX;
1086  int sourceWidgetY;
1087  if (mFocusHandler->getDraggedWidget() != nullptr)
1088  {
1089  if (sourceWidget != mFocusHandler->getLastWidgetPressed())
1091 
1092  Widget *const oldWidget = sourceWidget;
1093  sourceWidget = mFocusHandler->getDraggedWidget();
1094  if ((oldWidget != nullptr) && oldWidget != sourceWidget)
1095  {
1096  oldWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
1097  distributeMouseEvent(oldWidget,
1099  mouseInput.getButton(),
1100  mouseInput.getX(),
1101  mouseInput.getY(),
1102  false,
1103  false);
1104  }
1105  }
1106 
1107  if (sourceWidget == nullptr)
1108  return;
1109  sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
1110  distributeMouseEvent(sourceWidget,
1112  mouseInput.getButton(),
1113  mouseInput.getX(),
1114  mouseInput.getY(),
1115  false,
1116  false);
1117 
1118  if (mouseInput.getButton() == mLastMousePressButton
1119  && mFocusHandler->getLastWidgetPressed() == sourceWidget)
1120  {
1121  distributeMouseEvent(sourceWidget,
1123  mouseInput.getButton(),
1124  mouseInput.getX(),
1125  mouseInput.getY(),
1126  false,
1127  false);
1128 
1130  }
1131  else
1132  {
1134  mClickCount = 0;
1135  }
1136 
1137  if (mFocusHandler->getDraggedWidget() != nullptr)
1138  mFocusHandler->setDraggedWidget(nullptr);
1139 }

References MouseEventType::CLICKED, distributeMouseEvent(), MouseButton::EMPTY, Widget::getAbsolutePosition(), MouseInput::getButton(), FocusHandler::getDraggedWidget(), FocusHandler::getLastWidgetPressed(), getMouseEventSource(), MouseInput::getX(), MouseInput::getY(), mClickCount, mFocusHandler, mLastMousePressButton, MouseEventType::RELEASED, MouseEventType::RELEASED2, FocusHandler::setDraggedWidget(), and FocusHandler::setLastWidgetPressed().

Referenced by handleMouseInput().

◆ handleMouseWheelMovedDown()

void Gui::handleMouseWheelMovedDown ( const MouseInput mouseInput)
protected

Handles mouse wheel moved down input.

Parameters
mouseInputThe mouse input to handle.

Definition at line 1219 of file gui.cpp.

1220 {
1221  Widget* sourceWidget = getMouseEventSource(
1222  mouseInput.getX(), mouseInput.getY());
1223 
1224  if (mFocusHandler->getDraggedWidget() != nullptr)
1225  sourceWidget = mFocusHandler->getDraggedWidget();
1226 
1227  if (sourceWidget != nullptr)
1228  {
1229  int sourceWidgetX = 0;
1230  int sourceWidgetY = 0;
1231 
1232  sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
1233  distributeMouseEvent(sourceWidget,
1235  mouseInput.getButton(),
1236  mouseInput.getX(),
1237  mouseInput.getY(),
1238  false,
1239  false);
1240  }
1241 }

References distributeMouseEvent(), Widget::getAbsolutePosition(), MouseInput::getButton(), FocusHandler::getDraggedWidget(), getMouseEventSource(), MouseInput::getX(), MouseInput::getY(), mFocusHandler, and MouseEventType::WHEEL_MOVED_DOWN.

Referenced by handleMouseInput().

◆ handleMouseWheelMovedUp()

void Gui::handleMouseWheelMovedUp ( const MouseInput mouseInput)
protected

Handles mouse wheel moved up input.

Parameters
mouseInputThe mouse input to handle.

Definition at line 1243 of file gui.cpp.

1244 {
1245  Widget* sourceWidget = getMouseEventSource(
1246  mouseInput.getX(), mouseInput.getY());
1247 
1248  if (mFocusHandler->getDraggedWidget() != nullptr)
1249  sourceWidget = mFocusHandler->getDraggedWidget();
1250 
1251  if (sourceWidget != nullptr)
1252  {
1253  int sourceWidgetX;
1254  int sourceWidgetY;
1255 
1256  sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
1257  distributeMouseEvent(sourceWidget,
1259  mouseInput.getButton(),
1260  mouseInput.getX(),
1261  mouseInput.getY(),
1262  false,
1263  false);
1264  }
1265 }

References distributeMouseEvent(), Widget::getAbsolutePosition(), MouseInput::getButton(), FocusHandler::getDraggedWidget(), getMouseEventSource(), MouseInput::getX(), MouseInput::getY(), mFocusHandler, and MouseEventType::WHEEL_MOVED_UP.

Referenced by handleMouseInput().

◆ isLongPress()

bool Gui::isLongPress ( ) const
inline

Definition at line 308 of file gui.h.

309  { return getMousePressLength() > 250; }

References getMousePressLength().

Referenced by Viewport::mouseReleased().

◆ logic()

void Gui::logic ( )

Performs logic of the GUI. Overridden to track mouse pointer activity.

Definition at line 301 of file gui.cpp.

302 {
303  BLOCK_START("Gui::logic")
305 
306  if (mTop == nullptr)
307  {
308  BLOCK_END("Gui::logic")
309  return;
310  }
311 
314 
315  if (guiInput != nullptr)
317 
318  mTop->logic();
319  BLOCK_END("Gui::logic")
320 }

References BLOCK_END, BLOCK_START, ResourceManager::clearScheduled(), guiInput, handleModalFocus(), handleModalMouseInputFocus(), handleMouseInput(), Widget::logic(), and mTop.

Referenced by Client::gameExec().

◆ postInit()

void Gui::postInit ( Graphics *const  graphics)

Definition at line 150 of file gui.cpp.

151 {
152  logger->log1("Initializing GUI...");
153  // Set graphics
154  setGraphics(graphics);
155 
156  // Set input
157  guiInput = new SDLInput;
159 
160  // Set focus handler
161  delete mFocusHandler;
163 
164  // Initialize top GUI widget
165  WindowContainer *const guiTop = new WindowContainer(nullptr);
166  guiTop->setFocusable(true);
167  guiTop->setSize(graphics->mWidth, graphics->mHeight);
168  guiTop->setOpaque(Opaque_false);
170  setTop(guiTop);
171 
172  const StringVect langs = getLang();
173  const bool isJapan = (!langs.empty() && langs[0].size() > 3
174  && langs[0].substr(0, 3) == "ja_");
175  const bool isChinese = (!langs.empty() && langs[0].size() > 3
176  && langs[0].substr(0, 3) == "zh_");
177 
178  // Set global font
179  const int fontSize = config.getIntValue("fontSize");
180  std::string fontFile = config.getValue("font", "");
181  if (isJapan)
182  {
183  fontFile = config.getValue("japanFont", "");
184  if (fontFile.empty())
185  fontFile = branding.getStringValue("japanFont");
186  }
187  else if (isChinese)
188  {
189  fontFile = config.getValue("chinaFont", "");
190  if (fontFile.empty())
191  fontFile = branding.getStringValue("chinaFont");
192  }
193  if (fontFile.empty())
194  fontFile = branding.getStringValue("font");
195 
196  mGuiFont = new Font(fontFile, fontSize, TTF_STYLE_NORMAL);
197 
198  // Set particle font
199  fontFile = config.getValue("particleFont", "");
200  if (isJapan)
201  {
202  fontFile = config.getValue("japanFont", "");
203  if (fontFile.empty())
204  fontFile = branding.getStringValue("japanFont");
205  }
206  else if (isChinese)
207  {
208  fontFile = config.getValue("chinaFont", "");
209  if (fontFile.empty())
210  fontFile = branding.getStringValue("chinaFont");
211  }
212  if (fontFile.empty())
213  fontFile = branding.getStringValue("particleFont");
214 
215  mInfoParticleFont = new Font(fontFile, fontSize, TTF_STYLE_BOLD);
216 
217  // Set bold font
218  fontFile = config.getValue("boldFont", "");
219  if (fontFile.empty())
220  fontFile = branding.getStringValue("boldFont");
221 
222  boldFont = new Font(fontFile, fontSize, TTF_STYLE_NORMAL);
223 
224  // Set help font
225  fontFile = config.getValue("helpFont", "");
226  if (fontFile.empty())
227  fontFile = branding.getStringValue("helpFont");
228 
229  mHelpFont = new Font(fontFile, fontSize, TTF_STYLE_NORMAL);
230 
231  // Set secure font
232  fontFile = config.getValue("secureFont", "");
233  if (fontFile.empty())
234  fontFile = branding.getStringValue("secureFont");
235 
236  mSecureFont = new Font(fontFile, fontSize, TTF_STYLE_NORMAL);
237 
238  // Set npc font
239  const int npcFontSize = config.getIntValue("npcfontSize");
240  fontFile = config.getValue("npcFont", "");
241  if (isJapan)
242  {
243  fontFile = config.getValue("japanFont", "");
244  if (fontFile.empty())
245  fontFile = branding.getStringValue("japanFont");
246  }
247  else if (isChinese)
248  {
249  fontFile = config.getValue("chinaFont", "");
250  if (fontFile.empty())
251  fontFile = branding.getStringValue("chinaFont");
252  }
253  if (fontFile.empty())
254  fontFile = branding.getStringValue("npcFont");
255 
256  mNpcFont = new Font(fontFile, npcFontSize, TTF_STYLE_NORMAL);
257 
259 
260  // Initialize mouse cursor and listen for changes to the option
261  setUseCustomCursor(config.getBoolValue("customcursor"));
262  setDoubleClick(config.getBoolValue("doubleClick"));
263  config.addListener("customcursor", mConfigListener);
264  config.addListener("doubleClick", mConfigListener);
265 }

References Configuration::addListener(), boldFont, branding, config, Configuration::getBoolValue(), Configuration::getIntValue(), getLang(), Configuration::getStringValue(), ConfigurationObject::getValue(), guiInput, Logger::log1(), logger, mConfigListener, mFocusHandler, mGuiFont, Graphics::mHeight, mHelpFont, mInfoParticleFont, mNpcFont, mSecureFont, Graphics::mWidth, Opaque_false, setDoubleClick(), Widget::setFocusable(), Widget::setGlobalFont(), setGraphics(), setInput(), BasicContainer2::setOpaque(), Widget::setSize(), setTop(), setUseCustomCursor(), and Window::setWindowContainer().

Referenced by Client::gameInit().

◆ removeDragged()

void Gui::removeDragged ( const Widget *const  widget)

◆ removeGlobalFocusListener()

void Gui::removeGlobalFocusListener ( FocusListener focusListener)

Definition at line 1146 of file gui.cpp.

1147 {
1148  mFocusListeners.remove(focusListener);
1149 }

References mFocusListeners.

Referenced by PopupList::~PopupList().

◆ removeGlobalKeyListener()

void Gui::removeGlobalKeyListener ( KeyListener *const  keyListener)

Removes global key listener from the Gui.

Parameters
keyListenerThe key listener to remove.
Exceptions
Exceptionif the key listener hasn't been added.
See also
addGlobalKeyListener

Definition at line 1214 of file gui.cpp.

1215 {
1216  mKeyListeners.remove(keyListener);
1217 }

References mKeyListeners.

◆ resetClickCount()

void Gui::resetClickCount ( )

◆ setCursorType()

void Gui::setCursorType ( const CursorT  index)
inline

Sets which cursor should be used.

Definition at line 195 of file gui.h.

196  { mCursorType = index; }

References mCursorType.

Referenced by Window::mouseExited(), Window::mouseReleased(), Window::setModal(), Window::updateResizeHandler(), Window::widgetHidden(), and Window::Window().

◆ setDoubleClick()

void Gui::setDoubleClick ( const bool  b)
inline

Definition at line 198 of file gui.h.

199  { mDoubleClick = b; }

References mDoubleClick.

Referenced by GuiConfigListener::optionChanged(), and postInit().

◆ setGraphics()

void Gui::setGraphics ( Graphics *const  graphics)

Sets the graphics object to use for drawing.

Parameters
graphicsThe graphics object to use for drawing.
See also
getGraphics, AllegroGraphics, HGEGraphics, OpenLayerGraphics, OpenGLGraphics, SDLGraphics

Definition at line 1189 of file gui.cpp.

1190 {
1191  mGraphics = graphics;
1192 }

References mGraphics.

Referenced by postInit().

◆ setInput()

void Gui::setInput ( SDLInput *const  input)

Sets the input object to use for input handling.

Parameters
inputThe input object to use for input handling.
See also
getInput, AllegroInput, HGEInput, OpenLayerInput, SDLInput

Definition at line 1199 of file gui.cpp.

1200 {
1201  mInput = input;
1202 }

References mInput.

Referenced by postInit().

◆ setTop()

void Gui::setTop ( Widget *const  top)

Sets the top widget. The top widget is the root widget of the GUI. If you want a GUI to be able to contain more than one widget the top widget should be a container.

Parameters
topThe top widget.
See also
Container

Definition at line 1179 of file gui.cpp.

1180 {
1181  if (mTop != nullptr)
1182  mTop->setFocusHandler(nullptr);
1183  if (top != nullptr)
1184  top->setFocusHandler(mFocusHandler);
1185 
1186  mTop = top;
1187 }

References mFocusHandler, mTop, Widget::setFocusHandler(), and top.

Referenced by postInit(), and ~Gui().

◆ setUseCustomCursor()

void Gui::setUseCustomCursor ( const bool  customCursor)

Sets whether a custom cursor should be rendered.

Definition at line 553 of file gui.cpp.

554 {
556  {
557  SDL::showCursor(false);
558  return;
559  }
560  if (customCursor != mCustomCursor)
561  {
562  mCustomCursor = customCursor;
563 
564  if (mCustomCursor)
565  {
566  // Hide the SDL mouse cursor
567  SDL::showCursor(false);
568 
569  // Load the mouse cursor
570  if (mMouseCursors != nullptr)
572  mMouseCursors = Theme::getImageSetFromTheme("mouse.png", 40, 40);
573 
574  if (mMouseCursors == nullptr)
575  logger->log("Error: Unable to load mouse cursors.");
576  }
577  else
578  {
579  // Show the SDL mouse cursor
580  SDL::showCursor(true);
581 
582  // Unload the mouse cursor
583  if (mMouseCursors != nullptr)
584  {
586  mMouseCursors = nullptr;
587  }
588  }
589  }
590 }

References Resource::decRef(), Theme::getImageSetFromTheme(), Options::hideCursor, Logger::log(), logger, mCustomCursor, mMouseCursors, Settings::options, settings, and SDL::showCursor().

Referenced by GuiConfigListener::optionChanged(), and postInit().

◆ slowLogic()

void Gui::slowLogic ( )

Definition at line 322 of file gui.cpp.

323 {
324  BLOCK_START("Gui::slowLogic")
325  Palette::advanceGradients();
326 
327  // Fade out mouse cursor after extended inactivity
328  if (mMouseInactivityTimer < 100 * 15)
329  {
331  mMouseCursorAlpha = std::min(1.0F, mMouseCursorAlpha + 0.05F);
332  }
333  else
334  {
335  mMouseCursorAlpha = std::max(0.0F, mMouseCursorAlpha - 0.005F);
336  }
337  if (mGuiFont != nullptr)
338  mGuiFont->slowLogic(0);
339  if (mInfoParticleFont != nullptr)
341  if (mHelpFont != nullptr)
342  mHelpFont->slowLogic(2);
343  if (mSecureFont != nullptr)
345  if (boldFont != nullptr)
346  boldFont->slowLogic(4);
347  if (mNpcFont != nullptr)
348  mNpcFont->slowLogic(5);
349  if (windowContainer != nullptr)
351 
352  const time_t time = cur_time;
353  if (mTime != time)
354  {
355  logger->flush();
356  if (ipc != nullptr)
357  ipc->flush();
358  mTime = time;
359 
360  if (time > mTime10 || mTime10 - time > 10)
361  {
362  mTime10 = time + 10;
365  }
366  }
367 
368  BLOCK_END("Gui::slowLogic")
369 }

References Palette::advanceGradients(), BLOCK_END, BLOCK_START, boldFont, ResourceManager::cleanOrphans(), cur_time, IPC::flush(), Logger::flush(), guiInput, ipc, logger, mGuiFont, mHelpFont, mInfoParticleFont, mMouseCursorAlpha, mMouseInactivityTimer, mNpcFont, mSecureFont, mTime, mTime10, SDLInput::simulateMouseMove(), WindowContainer::slowLogic(), Font::slowLogic(), and windowContainer.

Referenced by Client::gameExec().

◆ updateFonts()

void Gui::updateFonts ( )

Definition at line 823 of file gui.cpp.

824 {
825  const int fontSize = config.getIntValue("fontSize");
826  std::string fontFile = config.getValue("font", "");
827  if (fontFile.empty())
828  fontFile = branding.getStringValue("font");
829 
830  mGuiFont->loadFont(fontFile, fontSize, TTF_STYLE_NORMAL);
831 
832  fontFile = config.getValue("particleFont", "");
833  if (fontFile.empty())
834  fontFile = branding.getStringValue("particleFont");
835 
836  mInfoParticleFont->loadFont(fontFile, fontSize, TTF_STYLE_BOLD);
837 
838  fontFile = config.getValue("boldFont", "");
839  if (fontFile.empty())
840  fontFile = branding.getStringValue("boldFont");
841 
842  boldFont->loadFont(fontFile, fontSize, TTF_STYLE_NORMAL);
843 
844  const int npcFontSize = config.getIntValue("npcfontSize");
845 
846  fontFile = config.getValue("npcFont", "");
847  if (fontFile.empty())
848  fontFile = branding.getStringValue("npcFont");
849 
850  mNpcFont->loadFont(fontFile, npcFontSize, TTF_STYLE_NORMAL);
851 }

References boldFont, branding, config, Configuration::getIntValue(), Configuration::getStringValue(), ConfigurationObject::getValue(), Font::loadFont(), mGuiFont, mInfoParticleFont, and mNpcFont.

Referenced by Setup_Theme::apply().

◆ videoResized()

void Gui::videoResized ( ) const

Called when the application window has been resized.

Definition at line 535 of file gui.cpp.

536 {
537  WindowContainer *const top = static_cast<WindowContainer *>(getTop());
538 
539  if (top != nullptr)
540  {
541  const int oldWidth = top->getWidth();
542  const int oldHeight = top->getHeight();
543 
545  top->adjustAfterResize(oldWidth, oldHeight);
546  }
547 
548  if (viewport != nullptr)
551 }

References Widget::distributeWindowResizeEvent(), Image::getHeight(), getTop(), Image::getWidth(), mainGraphics, Graphics::mHeight, Graphics::mWidth, top, Viewport::videoResized(), and viewport.

Referenced by WindowManager::resizeVideo().

Field Documentation

◆ mClickCount

int Gui::mClickCount
private

Holds the current click count. Used to keep track of clicks for a the last pressed button.

Definition at line 473 of file gui.h.

Referenced by createMouseEvent(), distributeMouseEvent(), handleMouseMoved(), handleMousePressed(), handleMouseReleased(), and resetClickCount().

◆ mConfigListener

GuiConfigListener* Gui::mConfigListener
private

Definition at line 488 of file gui.h.

Referenced by postInit(), and ~Gui().

◆ mCursorType

CursorT Gui::mCursorType
private

Definition at line 503 of file gui.h.

Referenced by draw(), and setCursorType().

◆ mCustomCursor

bool Gui::mCustomCursor
private

Show custom cursor

Definition at line 516 of file gui.h.

Referenced by draw(), and setUseCustomCursor().

◆ mDoubleClick

bool Gui::mDoubleClick
private

Definition at line 517 of file gui.h.

Referenced by handleMousePressed(), and setDoubleClick().

◆ mFocusHandler

FocusHandler* Gui::mFocusHandler
private

◆ mFocusListeners

FocusListenerList Gui::mFocusListeners
private

◆ mForegroundColor

Color Gui::mForegroundColor
private

Definition at line 512 of file gui.h.

Referenced by draw().

◆ mForegroundColor2

Color Gui::mForegroundColor2
private

Definition at line 513 of file gui.h.

Referenced by draw().

◆ mGraphics

Graphics* Gui::mGraphics
private

Holds the graphics implementation used.

Definition at line 422 of file gui.h.

Referenced by draw(), getGraphics(), and setGraphics().

◆ mGuiFont

Font* Gui::mGuiFont
private

The global GUI font

Definition at line 490 of file gui.h.

Referenced by clearFonts(), draw(), getFont(), postInit(), slowLogic(), updateFonts(), and ~Gui().

◆ mHelpFont

Font* Gui::mHelpFont
private

Font for Help Window

Definition at line 494 of file gui.h.

Referenced by clearFonts(), getHelpFont(), postInit(), slowLogic(), and ~Gui().

◆ mInfoParticleFont

Font* Gui::mInfoParticleFont
private

Font for Info Particles

Definition at line 492 of file gui.h.

Referenced by clearFonts(), getInfoParticleFont(), postInit(), slowLogic(), updateFonts(), and ~Gui().

◆ mInput

SDLInput* Gui::mInput
private

Holds the input implementation used.

Definition at line 427 of file gui.h.

Referenced by getInput(), handleInput(), handleKeyInput(), handleMouseInput(), and setInput().

◆ mKeyListeners

KeyListenerList Gui::mKeyListeners
private

Holds the global key listeners of the Gui.

Definition at line 447 of file gui.h.

Referenced by addGlobalKeyListener(), distributeKeyEventToGlobalKeyListeners(), and removeGlobalKeyListener().

◆ mLastMouseDragButton

MouseButtonT Gui::mLastMouseDragButton
private

Holds the last button used when a drag of a widget was initiated. Used to be able to release a drag when the same button is released.

Definition at line 480 of file gui.h.

Referenced by handleMouseMoved(), and handleMousePressed().

◆ mLastMousePressButton

MouseButtonT Gui::mLastMousePressButton
private

Holds the last mouse button pressed.

Definition at line 452 of file gui.h.

Referenced by handleModalFocusGained(), handleModalFocusReleased(), handleMousePressed(), and handleMouseReleased().

◆ mLastMousePressTimeStamp

unsigned int Gui::mLastMousePressTimeStamp
private

Holds the last mouse press time stamp.

Definition at line 457 of file gui.h.

Referenced by getMousePressLength(), handleMouseMoved(), handleMousePressed(), and resetClickCount().

◆ mLastMouseX

int Gui::mLastMouseX
private

Holds the last mouse x coordinate.

Definition at line 462 of file gui.h.

Referenced by getLastMouseX(), handleModalFocusGained(), handleModalFocusReleased(), and handleMouseInput().

◆ mLastMouseY

int Gui::mLastMouseY
private

Holds the last mouse y coordinate.

Definition at line 467 of file gui.h.

Referenced by getLastMouseY(), handleModalFocusGained(), handleModalFocusReleased(), and handleMouseInput().

◆ mMouseCursorAlpha

float Gui::mMouseCursorAlpha
private

Definition at line 501 of file gui.h.

Referenced by draw(), and slowLogic().

◆ mMouseCursors

ImageSet* Gui::mMouseCursors
private

Mouse cursor images

Definition at line 500 of file gui.h.

Referenced by draw(), setUseCustomCursor(), and ~Gui().

◆ mMouseInactivityTimer

int Gui::mMouseInactivityTimer
private

Definition at line 502 of file gui.h.

Referenced by handleMouseInput(), handleMouseMoved(), and slowLogic().

◆ mNpcFont

Font* Gui::mNpcFont
private

Font for npc text

Definition at line 498 of file gui.h.

Referenced by clearFonts(), getNpcFont(), postInit(), slowLogic(), updateFonts(), and ~Gui().

◆ mSecureFont

Font* Gui::mSecureFont
private

Font for secure labels

Definition at line 496 of file gui.h.

Referenced by clearFonts(), getSecureFont(), postInit(), slowLogic(), and ~Gui().

◆ mTime

time_t Gui::mTime
private

Definition at line 514 of file gui.h.

Referenced by slowLogic().

◆ mTime10

time_t Gui::mTime10
private

Definition at line 515 of file gui.h.

Referenced by slowLogic().

◆ mTop

Widget* Gui::mTop
private

Holds the top widget.

Definition at line 417 of file gui.h.

Referenced by getTop(), getWidgetAt(), handleMouseMoved(), logic(), setTop(), and ~Gui().

◆ mWidgetWithMouseQueue

std::deque<Widget*> Gui::mWidgetWithMouseQueue
private

Holds a stack with all the widgets with the mouse. Used to properly distribute mouse events.

Definition at line 486 of file gui.h.

Referenced by handleModalFocusGained(), handleModalFocusReleased(), and handleMouseMoved().


The documentation for this class was generated from the following files:
FocusHandler::getDraggedWidget
Widget * getDraggedWidget() const
Definition: focushandler.cpp:573
MouseInput::getRealY
int getRealY() const
Definition: mouseinput.h:169
Gui::mConfigListener
GuiConfigListener * mConfigListener
Definition: gui.h:488
DragDrop::getText
const std::string & getText() const
Definition: dragdrop.h:231
MouseInput::getX
int getX() const
Definition: mouseinput.h:148
MouseEventType::ENTERED
@ ENTERED
Definition: mouseeventtype.h:77
ConfigurationObject::getValue
std::string getValue(const std::string &key, const std::string &deflt) const
Definition: configuration.cpp:268
Gui::handleModalMouseInputFocus
void handleModalMouseInputFocus()
Definition: gui.cpp:1409
isBatchDrawRenders
#define isBatchDrawRenders(val)
Definition: renderers.h:30
Gui::setInput
void setInput(SDLInput *const input)
Definition: gui.cpp:1199
Gui::mMouseInactivityTimer
int mMouseInactivityTimer
Definition: gui.h:502
Gui::mTime10
time_t mTime10
Definition: gui.h:515
Gui::handleKeyInput
bool handleKeyInput()
Definition: gui.cpp:394
SDLInput::simulateMouseMove
void simulateMouseMove()
Definition: sdlinput.cpp:379
MouseInput::getRealX
int getRealX() const
Definition: mouseinput.h:166
touchManager
TouchManager touchManager
Definition: touchmanager.cpp:49
Widget::distributeWindowResizeEvent
static void distributeWindowResizeEvent()
Definition: widget.cpp:354
CAST_SIZE
#define CAST_SIZE
Definition: cast.h:33
SDLInput
Definition: sdlinput.h:103
Widget::isEnabled
bool isEnabled() const
Definition: widget.cpp:374
Font::clear
void clear()
Definition: font.cpp:247
MouseButton::EMPTY
@ EMPTY
Definition: mousebutton.h:72
Cursor::CURSOR_POINTER
@ CURSOR_POINTER
Definition: cursor.h:28
pushClipArea
void pushClipArea(const Rect &restrict area) restrict2 override final
Gui::getKeyEventSource
Widget * getKeyEventSource() const
Definition: gui.cpp:1305
KeyInput::getKey
const Key & getKey() const
Definition: keyinput.h:132
FocusHandler::setLastWidgetWithModalMouseInputFocus
void setLastWidgetWithModalMouseInputFocus(Widget *const widget)
Definition: focushandler.cpp:608
Gui::setTop
void setTop(Widget *const top)
Definition: gui.cpp:1179
Gui::handleMouseWheelMovedUp
void handleMouseWheelMovedUp(const MouseInput &mouseInput)
Definition: gui.cpp:1243
Image::getHeight
int getHeight() const A_INLINE
Definition: image.h:128
Gui::mNpcFont
Font * mNpcFont
Definition: gui.h:498
Gui::getTop
Widget * getTop() const
Definition: gui.h:247
MouseInput
Definition: mouseinput.h:72
Label::finalCleanup
static void finalCleanup()
Definition: label.cpp:296
SDL::showCursor
void showCursor(const bool show)
Definition: sdlsharedhelper.cpp:37
Gui::mGuiFont
Font * mGuiFont
Definition: gui.h:490
Palette
Definition: palette.h:43
Widget::getParent
Widget * getParent() const
Definition: widget.h:201
Options::hideCursor
bool hideCursor
Definition: options.h:100
openGLMode
RenderType openGLMode
Definition: graphicsmanager.cpp:116
Gui::mLastMousePressButton
MouseButtonT mLastMousePressButton
Definition: gui.h:452
Widget::getX
int getX() const
Definition: widget.h:268
settings
Settings settings
Definition: settings.cpp:31
Gui::handleMouseInput
void handleMouseInput()
Definition: gui.cpp:1022
ResourceManager::cleanOrphans
bool cleanOrphans(const bool always)
Definition: resourcemanager.cpp:226
Image::setAlpha
virtual void setAlpha(const float alpha)
Definition: image.cpp:286
Gui::mHelpFont
Font * mHelpFont
Definition: gui.h:494
Gui
Definition: gui.h:115
Gui::setDoubleClick
void setDoubleClick(const bool b)
Definition: gui.h:198
Gui::FocusListenerIterator
FocusListenerList::iterator FocusListenerIterator
Definition: gui.h:510
StringVect
std::vector< std::string > StringVect
Definition: stringvector.h:28
Gui::mLastMousePressTimeStamp
unsigned int mLastMousePressTimeStamp
Definition: gui.h:457
KeyInput::getType
KeyEventTypeT getType() const
Definition: keyinput.h:122
Widget::isVisible
bool isVisible() const
Definition: widget.h:377
MouseEventType::CLICKED
@ CLICKED
Definition: mouseeventtype.h:76
DragDrop::getItemImage
Image * getItemImage()
Definition: dragdrop.h:74
Gui::mFocusHandler
FocusHandler * mFocusHandler
Definition: gui.h:432
Image
Definition: image.h:67
Gui::getWidgetAt
Widget * getWidgetAt(const int x, const int y) const
Definition: gui.cpp:1267
FocusHandler::getLastWidgetPressed
Widget * getLastWidgetPressed() const
Definition: focushandler.cpp:613
TouchManager::draw
void draw()
Definition: touchmanager.cpp:207
Gui::getMouseEventSource
Widget * getMouseEventSource(const int x, const int y) const
Definition: gui.cpp:1289
Widget::isSelectable
virtual bool isSelectable() const
Definition: widget.h:944
cur_time
volatile time_t cur_time
Definition: timer.cpp:57
Gui::mDoubleClick
bool mDoubleClick
Definition: gui.h:517
Gui::KeyListenerListIterator
KeyListenerList::iterator KeyListenerListIterator
Definition: gui.h:442
Logger::flush
void flush()
Definition: logger.cpp:417
delete2
#define delete2(var)
Definition: delete2.h:24
Gui::mGraphics
Graphics * mGraphics
Definition: gui.h:422
Theme::getImageSetFromTheme
static ImageSet * getImageSetFromTheme(const std::string &path, const int w, const int h)
Definition: theme.cpp:659
Graphics::getScale
int getScale() const
Definition: graphics.h:365
bool
Font::slowLogic
void slowLogic(const int rnd)
Definition: font.cpp:318
Widget::getKeyListeners
const std::list< KeyListener * > & getKeyListeners() const A_CONST
Definition: widget.cpp:440
Widget::requestFocus
virtual void requestFocus()
Definition: widget.cpp:203
SDLInput::dequeueKeyInput
KeyInput dequeueKeyInput()
Definition: sdlinput.cpp:111
Configuration::addListener
void addListener(const std::string &key, ConfigListener *const listener)
Definition: configuration.cpp:905
FocusHandler::focusNone
void focusNone()
Definition: focushandler.cpp:542
logger
Logger * logger
Definition: logger.cpp:88
Theme::getColor
const Color & getColor(const ThemeColorIdT type, const unsigned int alpha)
Definition: theme.h:135
MouseEventType::PRESSED
@ PRESSED
Definition: mouseeventtype.h:72
FocusHandler::setLastWidgetWithModalFocus
void setLastWidgetWithModalFocus(Widget *const widget)
Definition: focushandler.cpp:598
Gui::handleMouseWheelMovedDown
void handleMouseWheelMovedDown(const MouseInput &mouseInput)
Definition: gui.cpp:1219
KeyInput::getActionId
InputActionT getActionId() const
Definition: keyinput.h:142
if
if(!vert) return
Gui::mForegroundColor
Color mForegroundColor
Definition: gui.h:512
Gui::getMousePressLength
int getMousePressLength() const
Definition: gui.cpp:1529
getLang
LangVect getLang()
Definition: langs.cpp:41
Gui::mKeyListeners
KeyListenerList mKeyListeners
Definition: gui.h:447
Gui::mLastMouseX
int mLastMouseX
Definition: gui.h:462
Font::drawString
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
Definition: font.cpp:253
MouseEventType::EXITED
@ EXITED
Definition: mouseeventtype.h:78
FocusHandler
Definition: focushandler.h:83
branding
Configuration branding
Definition: configuration.cpp:54
MouseInput::getY
int getY() const
Definition: mouseinput.h:158
inputManager
InputManager inputManager
Definition: inputmanager.cpp:68
Gui::mLastMouseY
int mLastMouseY
Definition: gui.h:467
guiInput
SDLInput * guiInput
Definition: sdlinput.cpp:100
Widget::getWidgetAt
virtual Widget * getWidgetAt(int x, int y)
Definition: widget.h:791
Widget::getAbsolutePosition
virtual void getAbsolutePosition(int &x, int &y) const
Definition: widget.cpp:311
InputGuiEvent::isConsumed
bool isConsumed() const
Definition: inputguievent.h:109
Settings::options
Options options
Definition: settings.h:129
ImageSet::get
Image * get(const size_type i) const
Definition: imageset.cpp:66
Gui::mMouseCursorAlpha
float mMouseCursorAlpha
Definition: gui.h:501
MouseEventType::RELEASED2
@ RELEASED2
Definition: mouseeventtype.h:80
FocusHandler::setLastWidgetPressed
void setLastWidgetPressed(Widget *const lastWidgetPressed)
Definition: focushandler.cpp:618
Gui::mTime
time_t mTime
Definition: gui.h:514
Gui::handleModalFocus
void handleModalFocus()
Definition: gui.cpp:1433
MouseEventType::WHEEL_MOVED_DOWN
@ WHEEL_MOVED_DOWN
Definition: mouseeventtype.h:74
KeyEvent
Definition: keyevent.h:84
FocusHandler::tabNext
void tabNext()
Definition: focushandler.cpp:174
FocusHandler::tabPrevious
void tabPrevious()
Definition: focushandler.cpp:245
Gui::mSecureFont
Font * mSecureFont
Definition: gui.h:496
KeyInput
Definition: keyinput.h:79
Widget::getMouseListeners
const std::list< MouseListener * > & getMouseListeners() const A_CONST
Definition: widget.cpp:435
InputManager::isActionActive
bool isActionActive(const InputActionT index) const
Definition: inputmanager.cpp:364
Gui::mFocusListeners
FocusListenerList mFocusListeners
Definition: gui.h:511
theme
Theme * theme
Definition: theme.cpp:61
Gui::handleModalFocusGained
void handleModalFocusGained()
Definition: gui.cpp:1458
Widget::getY
int getY() const
Definition: widget.h:287
Widget::getWidth
int getWidth() const
Definition: widget.h:220
Rect::isPointInRect
bool isPointInRect(const int x_, const int y_) const
Definition: rect.h:196
ResourceManager
Definition: resourcefunctiontypes.h:34
mainGraphics
Graphics * mainGraphics
Definition: graphics.cpp:108
x
x
Definition: graphics_calcImageRect.hpp:72
Font
Definition: font.h:88
WindowContainer
Definition: windowcontainer.h:34
FocusHandler::setDraggedWidget
void setDraggedWidget(Widget *const draggedWidget)
Definition: focushandler.cpp:578
TouchManager::processEvent
bool processEvent(const MouseInput &mouseInput)
Definition: touchmanager.cpp:285
Configuration::getStringValue
std::string getStringValue(const std::string &key) const
Definition: configuration.cpp:487
Gui::mForegroundColor2
Color mForegroundColor2
Definition: gui.h:513
MouseInput::getButton
MouseButtonT getButton() const
Definition: mouseinput.h:128
MouseEventTypeT
MouseEventType ::T MouseEventTypeT
Definition: mouseeventtype.h:82
Font::getWidth
int getWidth(const std::string &text) const
Definition: font.cpp:333
Gui::handleMouseMoved
void handleMouseMoved(const MouseInput &mouseInput)
Definition: gui.cpp:592
Window::setWindowContainer
static void setWindowContainer(WindowContainer *const windowContainer)
Definition: window.cpp:305
Widget::setGlobalFont
static void setGlobalFont(Font *const font)
Definition: widget.cpp:337
Gui::getMouseState
static uint8_t getMouseState(int &x, int &y)
Definition: gui.cpp:1170
Opaque_false
const bool Opaque_false
Definition: opaque.h:29
Gui::mLastMouseDragButton
MouseButtonT mLastMouseDragButton
Definition: gui.h:480
Font::loadFont
void loadFont(std::string filename, const int size, const int style)
Definition: font.cpp:218
WindowContainer::slowLogic
void slowLogic()
Definition: windowcontainer.cpp:42
Logger::log1
void log1(const char *const log_text)
Definition: logger.cpp:237
Configuration::getIntValue
int getIntValue(const std::string &key) const
Definition: configuration.cpp:403
Widget::getHeight
int getHeight() const
Definition: widget.h:239
viewport
Viewport * viewport
Definition: viewport.cpp:35
Image::mBounds
SDL_Rect mBounds
Definition: image.h:216
Widget::widgetExists
static bool widgetExists(const Widget *const widget)
Definition: widget.cpp:360
Gui::distributeMouseEvent
void distributeMouseEvent(Widget *const source, const MouseEventTypeT type, const MouseButtonT button, const int x, const int y, const bool force, const bool toSourceOnly)
Definition: gui.cpp:853
config
Configuration config
Definition: configuration.cpp:51
Graphics::mHeight
int mHeight
Definition: graphics.h:484
Gui::mClickCount
int mClickCount
Definition: gui.h:473
InputAction::GUI_TAB
@ GUI_TAB
Definition: inputaction.h:308
Tab::finalCleanup
static void finalCleanup()
Definition: tab.cpp:487
FocusHandler::getModalMouseInputFocused
Widget * getModalMouseInputFocused() const
Definition: focushandler.cpp:422
Gui::distributeKeyEventToGlobalKeyListeners
void distributeKeyEventToGlobalKeyListeners(KeyEvent &event)
Definition: gui.cpp:1385
Configuration::removeListeners
void removeListeners(ConfigListener *const listener)
Definition: configuration.cpp:938
ipc
IPC * ipc
Definition: ipc.cpp:36
MouseInput::getTimeStamp
int getTimeStamp() const
Definition: mouseinput.h:133
Widget::getDimension
const Rect & getDimension() const
Definition: widget.h:316
Widget::isModalMouseInputFocused
virtual bool isModalMouseInputFocused() const
Definition: widget.cpp:421
InputAction::GUI_MOD
@ GUI_MOD
Definition: inputaction.h:312
Gui::mCursorType
CursorT mCursorType
Definition: gui.h:503
MouseButtonT
MouseButton ::T MouseButtonT
Definition: mousebutton.h:77
MouseEventType::RELEASED
@ RELEASED
Definition: mouseeventtype.h:73
MouseEventType::MOVED
@ MOVED
Definition: mouseeventtype.h:71
Gui::setUseCustomCursor
void setUseCustomCursor(const bool customCursor)
Definition: gui.cpp:553
GuiConfigListener
Definition: guiconfiglistener.h:34
Resource::decRef
virtual void decRef()
Definition: resource.cpp:49
Gui::mTop
Widget * mTop
Definition: gui.h:417
Widget::getInternalFocusHandler
virtual FocusHandler * getInternalFocusHandler()
Definition: widget.cpp:455
SDLInput::dequeueMouseInput
MouseInput dequeueMouseInput()
Definition: sdlinput.cpp:122
Gui::logic
void logic()
Definition: gui.cpp:301
Widget::setFocusHandler
virtual void setFocusHandler(FocusHandler *const focusHandler)
Definition: widget.cpp:237
Viewport::videoResized
void videoResized()
Definition: viewport.cpp:270
Gui::mMouseCursors
ImageSet * mMouseCursors
Definition: gui.h:500
Gui::handleMouseReleased
void handleMouseReleased(const MouseInput &mouseInput)
Definition: gui.cpp:1080
Settings::mouseFocused
bool mouseFocused
Definition: settings.h:155
Gui::getAbsolutePosition
static void getAbsolutePosition(Widget *widget, int &x, int &y)
Definition: gui.cpp:1006
BLOCK_START
#define BLOCK_START(name)
Definition: perfomance.h:78
Widget::setFocusable
void setFocusable(const bool focusable)
Definition: widget.cpp:191
KeyEventType::PRESSED
@ PRESSED
Definition: keyeventtype.h:71
BLOCK_END
#define BLOCK_END(name)
Definition: perfomance.h:79
QuestType::TEXT
@ TEXT
Definition: questtype.h:28
Gui::handleModalFocusReleased
void handleModalFocusReleased()
Definition: gui.cpp:1483
Graphics::drawImage
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
Gui::distributeKeyEvent
void distributeKeyEvent(KeyEvent &event) const
Definition: gui.cpp:1319
MouseEventType::DRAGGED
@ DRAGGED
Definition: mouseeventtype.h:79
Gui::mInfoParticleFont
Font * mInfoParticleFont
Definition: gui.h:492
Gui::setGraphics
void setGraphics(Graphics *const graphics)
Definition: gui.cpp:1189
ResourceManager::clearScheduled
void clearScheduled()
Definition: resourcemanager.cpp:634
IPC::flush
void flush()
Definition: ipc.cpp:189
Gui::handleMousePressed
void handleMousePressed(const MouseInput &mouseInput)
Definition: gui.cpp:773
boldFont
Font * boldFont
Definition: gui.cpp:111
Widget::isModalFocused
virtual bool isModalFocused() const
Definition: widget.cpp:407
dragDrop
DragDrop dragDrop
DragDrop::clear
void clear()
Definition: dragdrop.h:182
KeyEventTypeT
KeyEventType ::T KeyEventTypeT
Definition: keyeventtype.h:74
BasicContainer2::setOpaque
void setOpaque(Opaque opaque)
Definition: basiccontainer2.h:109
Widget::isFocusable
bool isFocusable() const
Definition: widget.cpp:198
FocusHandler::getFocused
Widget * getFocused() const
Definition: focushandler.cpp:412
MouseEvent
Definition: mouseevent.h:79
MouseInput::getType
MouseEventTypeT getType() const
Definition: mouseinput.h:118
Widget::setSize
void setSize(const int width, const int height)
Definition: widget.cpp:366
y
y
Definition: graphics_calcImageRect.hpp:72
Gui::mCustomCursor
bool mCustomCursor
Definition: gui.h:516
MouseStateType
#define MouseStateType
Definition: gui.h:99
MouseEventType::WHEEL_MOVED_UP
@ WHEEL_MOVED_UP
Definition: mouseeventtype.h:75
FocusHandler::getModalFocused
Widget * getModalFocused() const
Definition: focushandler.cpp:417
Image::getWidth
int getWidth() const A_INLINE
Definition: image.h:122
Gui::mWidgetWithMouseQueue
std::deque< Widget * > mWidgetWithMouseQueue
Definition: gui.h:486
Graphics::popClipArea
virtual void popClipArea()
Definition: graphics.cpp:738
Logger::log
void log(const char *const log_text,...)
Definition: logger.cpp:268
FOR_EACH
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
KeyEventType::RELEASED
@ RELEASED
Definition: keyeventtype.h:72
Gui::mInput
SDLInput * mInput
Definition: gui.h:427
Widget
Definition: widget.h:97
TouchManager::safeDraw
void safeDraw()
Definition: touchmanager.cpp:236
top
const Image *const restrict top
Definition: graphics_calcImageRect.hpp:39
windowContainer
WindowContainer * windowContainer
Definition: windowcontainer.cpp:33
Widget::cleanGlobalFont
static void cleanGlobalFont()
Definition: widget.h:649
Configuration::getBoolValue
bool getBoolValue(const std::string &key) const
Definition: configuration.cpp:596
Graphics::mWidth
int mWidth
Definition: graphics.h:483