Otclient 1.0  14/8/2020
uimanager.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #include "uimanager.h"
24 #include "ui.h"
25 
26 #include <framework/otml/otml.h>
32 
34 
36 {
37  // creates root widget
38  m_rootWidget = UIWidgetPtr(new UIWidget);
39  m_rootWidget->setId("root");
40  m_mouseReceiver = m_rootWidget;
41  m_keyboardReceiver = m_rootWidget;
42 }
43 
45 {
46  // destroy root widget and its children
47  m_rootWidget->destroy();
48  m_mouseReceiver = nullptr;
49  m_keyboardReceiver = nullptr;
50  m_rootWidget = nullptr;
51  m_draggingWidget = nullptr;
52  m_hoveredWidget = nullptr;
53  m_pressedWidget = nullptr;
54  m_styles.clear();
55  m_destroyedWidgets.clear();
56  m_checkEvent = nullptr;
57 }
58 
60 {
61  m_rootWidget->draw(m_rootWidget->getRect(), drawPane);
62 }
63 
64 void UIManager::resize(const Size&)
65 {
66  m_rootWidget->setSize(g_window.getSize());
67 }
68 
70 {
71  UIWidgetList widgetList;
72  switch (event.type) {
74  m_keyboardReceiver->propagateOnKeyText(event.keyText);
75  break;
77  m_keyboardReceiver->propagateOnKeyDown(event.keyCode, event.keyboardModifiers);
78  break;
80  m_keyboardReceiver->propagateOnKeyPress(event.keyCode, event.keyboardModifiers, event.autoRepeatTicks);
81  break;
83  m_keyboardReceiver->propagateOnKeyUp(event.keyCode, event.keyboardModifiers);
84  break;
86  if (event.mouseButton == Fw::MouseLeftButton && m_mouseReceiver->isVisible()) {
87  UIWidgetPtr pressedWidget = m_mouseReceiver->recursiveGetChildByPos(event.mousePos, false);
88  if (pressedWidget && !pressedWidget->isEnabled())
89  pressedWidget = nullptr;
90  updatePressedWidget(pressedWidget, event.mousePos);
91  }
92 
93  m_mouseReceiver->propagateOnMouseEvent(event.mousePos, widgetList);
94  for (const UIWidgetPtr& widget : widgetList) {
95  widget->recursiveFocus(Fw::MouseFocusReason);
96  if (widget->onMousePress(event.mousePos, event.mouseButton))
97  break;
98  }
99 
100  break;
102  {
103  // release dragging widget
104  bool accepted = false;
105  if (m_draggingWidget && event.mouseButton == Fw::MouseLeftButton)
106  accepted = updateDraggingWidget(nullptr, event.mousePos);
107 
108  if (!accepted) {
109  m_mouseReceiver->propagateOnMouseEvent(event.mousePos, widgetList);
110 
111  // mouse release is always fired first on the pressed widget
112  if (m_pressedWidget) {
113  auto it = std::find(widgetList.begin(), widgetList.end(), m_pressedWidget);
114  if (it != widgetList.end())
115  widgetList.erase(it);
116  widgetList.push_front(m_pressedWidget);
117  }
118 
119  for (const UIWidgetPtr& widget : widgetList) {
120  if (widget->onMouseRelease(event.mousePos, event.mouseButton))
121  break;
122  }
123  }
124 
125  if (m_pressedWidget && event.mouseButton == Fw::MouseLeftButton)
126  updatePressedWidget(nullptr, event.mousePos, !accepted);
127  break;
128  }
130  {
131  // start dragging when moving a pressed widget
132  if (m_pressedWidget && m_pressedWidget->isDraggable() && m_draggingWidget != m_pressedWidget) {
133  // only drags when moving more than 4 pixels
134  if ((event.mousePos - m_pressedWidget->getLastClickPosition()).length() >= 4)
135  updateDraggingWidget(m_pressedWidget, event.mousePos - event.mouseMoved);
136  }
137 
138  // mouse move can change hovered widgets
139  updateHoveredWidget(true);
140 
141  // first fire dragging move
142  if (m_draggingWidget) {
143  if (m_draggingWidget->onDragMove(event.mousePos, event.mouseMoved))
144  break;
145  }
146 
147  if (m_pressedWidget) {
148  if (m_pressedWidget->onMouseMove(event.mousePos, event.mouseMoved)) {
149  break;
150  }
151  }
152 
153  m_mouseReceiver->propagateOnMouseMove(event.mousePos, event.mouseMoved, widgetList);
154  for (const UIWidgetPtr& widget : widgetList) {
155  if (widget->onMouseMove(event.mousePos, event.mouseMoved))
156  break;
157  }
158  break;
159  }
161  m_rootWidget->propagateOnMouseEvent(event.mousePos, widgetList);
162  for (const UIWidgetPtr& widget : widgetList) {
163  if (widget->onMouseWheel(event.mousePos, event.wheelDirection))
164  break;
165  }
166  break;
167  default:
168  break;
169  };
170 }
171 
172 void UIManager::updatePressedWidget(const UIWidgetPtr& newPressedWidget, const Point& clickedPos, bool fireClicks)
173 {
174  UIWidgetPtr oldPressedWidget = m_pressedWidget;
175  m_pressedWidget = newPressedWidget;
176 
177  // when releasing mouse inside pressed widget area send onClick event
178  if (fireClicks && oldPressedWidget && oldPressedWidget->isEnabled() && oldPressedWidget->containsPoint(clickedPos))
179  oldPressedWidget->onClick(clickedPos);
180 
181  if (newPressedWidget)
182  newPressedWidget->updateState(Fw::PressedState);
183 
184  if (oldPressedWidget)
185  oldPressedWidget->updateState(Fw::PressedState);
186 }
187 
188 bool UIManager::updateDraggingWidget(const UIWidgetPtr& draggingWidget, const Point& clickedPos)
189 {
190  bool accepted = false;
191 
192  UIWidgetPtr oldDraggingWidget = m_draggingWidget;
193  m_draggingWidget = nullptr;
194  if (oldDraggingWidget) {
195  UIWidgetPtr droppedWidget;
196  if (!clickedPos.isNull()) {
197  auto clickedChildren = m_rootWidget->recursiveGetChildrenByPos(clickedPos);
198  for (const UIWidgetPtr& child : clickedChildren) {
199  if (child->onDrop(oldDraggingWidget, clickedPos)) {
200  droppedWidget = child;
201  break;
202  }
203  }
204  }
205 
206  accepted = oldDraggingWidget->onDragLeave(droppedWidget, clickedPos);
207  oldDraggingWidget->updateState(Fw::DraggingState);
208  }
209 
210  if (draggingWidget) {
211  if (draggingWidget->onDragEnter(clickedPos)) {
212  m_draggingWidget = draggingWidget;
213  draggingWidget->updateState(Fw::DraggingState);
214  accepted = true;
215  }
216  }
217 
218  return accepted;
219 }
220 
222 {
223  if (m_hoverUpdateScheduled && !now)
224  return;
225 
226  auto func = [this] {
227  if (!m_rootWidget)
228  return;
229 
230  m_hoverUpdateScheduled = false;
231  UIWidgetPtr hoveredWidget;
232  //if(!g_window.isMouseButtonPressed(Fw::MouseLeftButton) && !g_window.isMouseButtonPressed(Fw::MouseRightButton)) {
233  hoveredWidget = m_rootWidget->recursiveGetChildByPos(g_window.getMousePosition(), false);
234  if (hoveredWidget && !hoveredWidget->isEnabled())
235  hoveredWidget = nullptr;
236  //}
237 
238  if (hoveredWidget != m_hoveredWidget) {
239  UIWidgetPtr oldHovered = m_hoveredWidget;
240  m_hoveredWidget = hoveredWidget;
241  if (oldHovered) {
242  oldHovered->updateState(Fw::HoverState);
243  oldHovered->onHoverChange(false);
244  }
245  if (hoveredWidget) {
246  hoveredWidget->updateState(Fw::HoverState);
247  hoveredWidget->onHoverChange(true);
248  }
249  }
250  };
251 
252  if (now)
253  func();
254  else {
255  m_hoverUpdateScheduled = true;
256  g_dispatcher.addEvent(func);
257  }
258 }
259 
261 {
262  if (widget->containsPoint(g_window.getMousePosition()))
264 }
265 
267 {
268  if (widget->containsPoint(g_window.getMousePosition()))
270 }
271 
273 {
274  // release input grabs
275  if (m_keyboardReceiver == widget)
277 
278  if (m_mouseReceiver == widget)
280 
281  if (m_hoveredWidget == widget)
283 
284  if (m_pressedWidget == widget)
285  updatePressedWidget(nullptr);
286 
287  if (m_draggingWidget == widget)
288  updateDraggingWidget(nullptr);
289 
290 #ifndef NDEBUG
291  if (widget == m_rootWidget || !m_rootWidget)
292  return;
293 
294  m_destroyedWidgets.push_back(widget);
295 
296  if (m_checkEvent && !m_checkEvent->isExecuted())
297  return;
298 
299  m_checkEvent = g_dispatcher.scheduleEvent([this] {
301  UIWidgetList backupList = m_destroyedWidgets;
302  m_destroyedWidgets.clear();
303  g_dispatcher.scheduleEvent([backupList] {
305  for (const UIWidgetPtr& widget : backupList) {
306  if (widget->ref_count() != 1)
307  g_logger.warning(stdext::format("widget '%s' destroyed but still have %d reference(s) left", widget->getId(), widget->getUseCount() - 1));
308  }
309  }, 1);
310  }, 1000);
311 #endif
312 }
313 
315 {
316  m_styles.clear();
317 }
318 
319 bool UIManager::importStyle(std::string file)
320 {
321  try {
322  file = g_resources.guessFilePath(file, "otui");
323 
325 
326  for (const OTMLNodePtr& styleNode : doc->children())
327  importStyleFromOTML(styleNode);
328  return true;
329  }
330  catch (stdext::exception& e) {
331  g_logger.error(stdext::format("Failed to import UI styles from '%s': %s", file, e.what()));
332  return false;
333  }
334 }
335 
337 {
338  std::string tag = styleNode->tag();
339  std::vector<std::string> split = stdext::split(tag, "<");
340  if (split.size() != 2)
341  throw OTMLException(styleNode, "not a valid style declaration");
342 
343  std::string name = split[0];
344  std::string base = split[1];
345  bool unique = false;
346 
347  stdext::trim(name);
348  stdext::trim(base);
349 
350  if (name[0] == '#') {
351  name = name.substr(1);
352  unique = true;
353 
354  styleNode->setTag(name);
355  styleNode->writeAt("__unique", true);
356  }
357 
358  OTMLNodePtr oldStyle = m_styles[name];
359 
360  // Warn about redefined styles
361  /*
362  if(!g_app.isRunning() && (oldStyle && !oldStyle->valueAt("__unique", false))) {
363  auto it = m_styles.find(name);
364  if(it != m_styles.end())
365  g_logger.warning(stdext::format("style '%s' is being redefined", name));
366  }
367  */
368 
369  if (!oldStyle || !oldStyle->valueAt("__unique", false) || unique) {
370  OTMLNodePtr originalStyle = getStyle(base);
371  if (!originalStyle)
372  stdext::throw_exception(stdext::format("base style '%s', is not defined", base));
373  OTMLNodePtr style = originalStyle->clone();
374  style->merge(styleNode);
375  style->setTag(name);
376  m_styles[name] = style;
377  }
378 }
379 
380 OTMLNodePtr UIManager::getStyle(const std::string& styleName)
381 {
382  auto it = m_styles.find(styleName);
383  if (it != m_styles.end())
384  return m_styles[styleName];
385 
386  // styles starting with UI are automatically defined
387  if (stdext::starts_with(styleName, "UI")) {
388  OTMLNodePtr node = OTMLNode::create(styleName);
389  node->writeAt("__class", styleName);
390  m_styles[styleName] = node;
391  return node;
392  }
393 
394  return nullptr;
395 }
396 
397 std::string UIManager::getStyleClass(const std::string& styleName)
398 {
399  OTMLNodePtr style = getStyle(styleName);
400  if (style && style->get("__class"))
401  return style->valueAt("__class");
402  return "";
403 }
404 
405 UIWidgetPtr UIManager::loadUI(std::string file, const UIWidgetPtr& parent)
406 {
407  try {
408  file = g_resources.guessFilePath(file, "otui");
409 
411  UIWidgetPtr widget;
412  for (const OTMLNodePtr& node : doc->children()) {
413  std::string tag = node->tag();
414 
415  // import styles in these files too
416  if (tag.find("<") != std::string::npos)
417  importStyleFromOTML(node);
418  else {
419  if (widget)
420  stdext::throw_exception("cannot have multiple main widgets in otui files");
421  widget = createWidgetFromOTML(node, parent);
422  }
423  }
424 
425  return widget;
426  }
427  catch (stdext::exception& e) {
428  g_logger.error(stdext::format("failed to load UI from '%s': %s", file, e.what()));
429  return nullptr;
430  }
431 }
432 
433 UIWidgetPtr UIManager::createWidget(const std::string& styleName, const UIWidgetPtr& parent)
434 {
435  OTMLNodePtr node = OTMLNode::create(styleName);
436  try {
437  return createWidgetFromOTML(node, parent);
438  }
439  catch (stdext::exception& e) {
440  g_logger.error(stdext::format("failed to create widget from style '%s': %s", styleName, e.what()));
441  return nullptr;
442  }
443 }
444 
446 {
447  OTMLNodePtr originalStyleNode = getStyle(widgetNode->tag());
448  if (!originalStyleNode)
449  stdext::throw_exception(stdext::format("'%s' is not a defined style", widgetNode->tag()));
450 
451  OTMLNodePtr styleNode = originalStyleNode->clone();
452  styleNode->merge(widgetNode);
453 
454  std::string widgetType = styleNode->valueAt("__class");
455 
456  // call widget creation from lua
457  UIWidgetPtr widget = g_lua.callGlobalField<UIWidgetPtr>(widgetType, "create");
458  if (parent)
459  parent->addChild(widget);
460 
461  if (widget) {
462  widget->callLuaField("onCreate");
463 
464  widget->setStyleFromNode(styleNode);
465 
466  for (const OTMLNodePtr& childNode : styleNode->children()) {
467  if (!childNode->isUnique()) {
468  createWidgetFromOTML(childNode, widget);
469  styleNode->removeChild(childNode);
470  }
471  }
472  }
473  else
474  stdext::throw_exception(stdext::format("unable to create widget of type '%s'", widgetType));
475 
476  widget->callLuaField("onSetup");
477  return widget;
478 }
ui.h
OTMLNode::setTag
void setTag(const std::string &tag)
Definition: otmlnode.h:50
UIManager::onWidgetAppear
void onWidgetAppear(const UIWidgetPtr &widget)
Definition: uimanager.cpp:260
eventdispatcher.h
graphics.h
UIWidget
Definition: uiwidget.h:47
Event::isExecuted
bool isExecuted()
Definition: event.h:39
UIWidget::onDragEnter
virtual bool onDragEnter(const Point &mousePos)
Definition: uiwidget.cpp:1539
UIManager::onWidgetDisappear
void onWidgetDisappear(const UIWidgetPtr &widget)
Definition: uimanager.cpp:266
UIManager::getStyle
OTMLNodePtr getStyle(const std::string &styleName)
Definition: uimanager.cpp:380
UIWidget::isEnabled
bool isEnabled()
Definition: uiwidget.h:226
OTMLNode::writeAt
void writeAt(const std::string &childTag, const T &v)
Definition: otmlnode.h:162
UIManager::resize
void resize(const Size &size)
Definition: uimanager.cpp:64
OTMLException
All OTML errors throw this exception.
Definition: otmlexception.h:29
Fw::MouseWheelInputEvent
@ MouseWheelInputEvent
Definition: const.h:243
platformwindow.h
otml.h
stdext::shared_object::ref_count
refcount_t ref_count()
Definition: shared_object.h:48
Fw::DraggingState
@ DraggingState
Definition: const.h:280
g_dispatcher
EventDispatcher g_dispatcher
Definition: eventdispatcher.cpp:28
PlatformWindow::getSize
Size getSize()
Definition: platformwindow.h:75
OTMLDocument::parse
static OTMLDocumentPtr parse(const std::string &fileName)
Parse OTML from a file.
Definition: otmldocument.cpp:36
UIWidget::propagateOnMouseMove
bool propagateOnMouseMove(const Point &mousePos, const Point &mouseMoved, UIWidgetList &widgetList)
Definition: uiwidget.cpp:1733
UIWidget::propagateOnKeyDown
bool propagateOnKeyDown(uchar keyCode, int keyboardModifiers)
Definition: uiwidget.cpp:1642
LuaInterface::callGlobalField
void callGlobalField(const std::string &global, const std::string &field, const T &... args)
Definition: luainterface.h:445
UIWidget::recursiveGetChildByPos
UIWidgetPtr recursiveGetChildByPos(const Point &childPos, bool wantsPhantom)
Definition: uiwidget.cpp:1180
OTMLNode::removeChild
bool removeChild(const OTMLNodePtr &oldChild)
Definition: otmlnode.cpp:125
UIWidget::getId
std::string getId()
Definition: uiwidget.h:254
UIWidget::onHoverChange
virtual void onHoverChange(bool hovered)
Definition: uiwidget.cpp:1527
UIManager::updateHoveredWidget
void updateHoveredWidget(bool now=false)
Definition: uimanager.cpp:221
resourcemanager.h
UIWidgetPtr
stdext::shared_object_ptr< UIWidget > UIWidgetPtr
Definition: declarations.h:39
Logger::error
void error(const std::string &what)
Definition: logger.h:54
UIWidget::destroy
void destroy()
Definition: uiwidget.cpp:780
Fw::KeyUpInputEvent
@ KeyUpInputEvent
Definition: const.h:239
UIWidget::propagateOnKeyPress
bool propagateOnKeyPress(uchar keyCode, int keyboardModifiers, int autoRepeatTicks)
Definition: uiwidget.cpp:1664
UIWidget::addChild
void addChild(const UIWidgetPtr &child)
Definition: uiwidget.cpp:138
Fw::KeyTextInputEvent
@ KeyTextInputEvent
Definition: const.h:236
Fw::MouseFocusReason
@ MouseFocusReason
Definition: const.h:222
UIWidget::containsPoint
bool containsPoint(const Point &point)
Definition: uiwidget.h:252
OTMLNode::children
OTMLNodeList children()
Definition: otmlnode.cpp:171
UIManager::getStyleClass
std::string getStyleClass(const std::string &styleName)
Definition: uimanager.cpp:397
Fw::HoverState
@ HoverState
Definition: const.h:271
stdext::format
std::string format()
Definition: format.h:84
stdext::starts_with
bool starts_with(const std::string &str, const std::string &test)
Definition: string.cpp:263
Fw::MousePressInputEvent
@ MousePressInputEvent
Definition: const.h:240
Fw::KeyPressInputEvent
@ KeyPressInputEvent
Definition: const.h:238
Fw::MouseLeftButton
@ MouseLeftButton
Definition: const.h:248
Fw::MouseMoveInputEvent
@ MouseMoveInputEvent
Definition: const.h:242
InputEvent::type
Fw::InputEventType type
Definition: inputevent.h:42
g_resources
ResourceManager g_resources
Definition: resourcemanager.cpp:32
UIManager::clearStyles
void clearStyles()
Definition: uimanager.cpp:314
UIWidget::onDragMove
virtual bool onDragMove(const Point &mousePos, const Point &mouseMoved)
Definition: uiwidget.cpp:1549
InputEvent
Definition: inputevent.h:28
InputEvent::keyboardModifiers
int keyboardModifiers
Definition: inputevent.h:49
g_window
PlatformWindow & g_window
Definition: platformwindow.cpp:37
OTMLNode::valueAt
T valueAt(const std::string &childTag)
Definition: otmlnode.h:130
OTMLNode::tag
std::string tag()
Definition: otmlnode.h:36
LuaObject::callLuaField
R callLuaField(const std::string &field, const T &... args)
Definition: luaobject.h:172
UIManager
Definition: uimanager.h:32
g_logger
Logger g_logger
Definition: logger.cpp:35
g_lua
LuaInterface g_lua
Definition: luainterface.cpp:31
UIWidget::getLastClickPosition
Point getLastClickPosition()
Definition: uiwidget.h:268
LuaObject::getUseCount
int getUseCount()
Definition: luaobject.cpp:112
EventDispatcher::addEvent
EventPtr addEvent(const std::function< void()> &callback, bool pushFront=false)
Definition: eventdispatcher.cpp:104
UIManager::createWidgetFromOTML
UIWidgetPtr createWidgetFromOTML(const OTMLNodePtr &widgetNode, const UIWidgetPtr &parent)
Definition: uimanager.cpp:445
UIManager::importStyleFromOTML
void importStyleFromOTML(const OTMLNodePtr &styleNode)
Definition: uimanager.cpp:336
UIManager::resetMouseReceiver
void resetMouseReceiver()
Definition: uimanager.h:60
OTMLNode::clone
OTMLNodePtr clone()
Definition: otmlnode.cpp:180
UIWidget::propagateOnKeyUp
bool propagateOnKeyUp(uchar keyCode, int keyboardModifiers)
Definition: uiwidget.cpp:1689
OTMLNode::get
OTMLNodePtr get(const std::string &childTag)
Definition: otmlnode.cpp:54
UIWidget::onClick
virtual bool onClick(const Point &mousePos)
Definition: uiwidget.cpp:1610
UIManager::resetKeyboardReceiver
void resetKeyboardReceiver()
Definition: uimanager.h:61
stdext::trim
void trim(std::string &str)
Definition: string.cpp:226
UIManager::render
void render(Fw::DrawPane drawPane)
Definition: uimanager.cpp:59
UIWidget::propagateOnKeyText
bool propagateOnKeyText(const std::string &keyText)
Definition: uiwidget.cpp:1620
Fw::PressedState
@ PressedState
Definition: const.h:272
UIWidget::isDraggable
bool isDraggable()
Definition: uiwidget.h:244
TPoint::isNull
bool isNull() const
Definition: point.h:41
stdext::throw_exception
void throw_exception(const std::string &what)
Throws a generic exception.
Definition: exception.h:43
UIManager::loadUI
UIWidgetPtr loadUI(std::string file, const UIWidgetPtr &parent)
Definition: uimanager.cpp:405
UIWidget::setStyleFromNode
void setStyleFromNode(const OTMLNodePtr &styleNode)
Definition: uiwidget.cpp:925
stdext::split
std::vector< std::string > split(const std::string &str, const std::string &separators)
Definition: string.cpp:273
InputEvent::keyText
std::string keyText
Definition: inputevent.h:48
InputEvent::keyCode
Fw::Key keyCode
Definition: inputevent.h:47
stdext::exception::what
virtual const char * what() const
Definition: exception.h:37
g_ui
UIManager g_ui
Definition: uimanager.cpp:33
Fw::DrawPane
DrawPane
Definition: const.h:285
stdext::shared_object_ptr< UIWidget >
UIManager::updatePressedWidget
void updatePressedWidget(const UIWidgetPtr &newPressedWidget, const Point &clickedPos=Point(), bool fireClicks=true)
Definition: uimanager.cpp:172
UIWidget::draw
virtual void draw(const Rect &visibleRect, Fw::DrawPane drawPane)
Definition: uiwidget.cpp:58
UIManager::init
void init()
Definition: uimanager.cpp:35
OTMLNode::merge
void merge(const OTMLNodePtr &node)
Definition: otmlnode.cpp:158
UIManager::onWidgetDestroy
void onWidgetDestroy(const UIWidgetPtr &widget)
Definition: uimanager.cpp:272
uimanager.h
UIManager::inputEvent
void inputEvent(const InputEvent &event)
Definition: uimanager.cpp:69
UIManager::terminate
void terminate()
Definition: uimanager.cpp:44
UIWidget::setSize
void setSize(const Size &size)
Definition: uiwidget.h:303
PlatformWindow::getMousePosition
Point getMousePosition()
Definition: platformwindow.h:83
Fw::MouseReleaseInputEvent
@ MouseReleaseInputEvent
Definition: const.h:241
InputEvent::mousePos
Point mousePos
Definition: inputevent.h:50
UIWidget::onMouseMove
virtual bool onMouseMove(const Point &mousePos, const Point &mouseMoved)
Definition: uiwidget.cpp:1600
UIWidget::recursiveGetChildrenByPos
UIWidgetList recursiveGetChildrenByPos(const Point &childPos)
Definition: uiwidget.cpp:1210
UIManager::updateDraggingWidget
bool updateDraggingWidget(const UIWidgetPtr &draggingWidget, const Point &clickedPos=Point())
Definition: uimanager.cpp:188
UIWidget::getRect
Rect getRect()
Definition: uiwidget.h:358
TPoint< int >
UIManager::importStyle
bool importStyle(std::string file)
Definition: uimanager.cpp:319
UIWidget::onDragLeave
virtual bool onDragLeave(UIWidgetPtr droppedWidget, const Point &mousePos)
Definition: uiwidget.cpp:1544
Fw::KeyDownInputEvent
@ KeyDownInputEvent
Definition: const.h:237
LuaInterface::collectGarbage
void collectGarbage()
Definition: luainterface.cpp:729
EventDispatcher::scheduleEvent
ScheduledEventPtr scheduleEvent(const std::function< void()> &callback, int delay)
Definition: eventdispatcher.cpp:82
UIWidget::setId
void setId(const std::string &id)
Definition: uiwidget.cpp:815
InputEvent::mouseButton
Fw::MouseButton mouseButton
Definition: inputevent.h:46
InputEvent::mouseMoved
Point mouseMoved
Definition: inputevent.h:51
TSize< int >
UIWidgetList
std::deque< UIWidgetPtr > UIWidgetList
Definition: declarations.h:53
UIManager::createWidget
UIWidgetPtr createWidget(const std::string &styleName, const UIWidgetPtr &parent)
Definition: uimanager.cpp:433
InputEvent::wheelDirection
Fw::MouseWheelDirection wheelDirection
Definition: inputevent.h:45
InputEvent::autoRepeatTicks
int autoRepeatTicks
Definition: inputevent.h:52
ResourceManager::guessFilePath
std::string guessFilePath(const std::string &filename, const std::string &type)
Definition: resourcemanager.cpp:353
UIWidget::propagateOnMouseEvent
bool propagateOnMouseEvent(const Point &mousePos, UIWidgetList &widgetList)
Definition: uiwidget.cpp:1711
application.h
Logger::warning
void warning(const std::string &what)
Definition: logger.h:53
stdext::exception
Definition: exception.h:31
UIWidget::isVisible
bool isVisible()
Definition: uiwidget.h:238
OTMLNode::create
static OTMLNodePtr create(std::string tag="", bool unique=false)
Definition: otmlnode.cpp:27