Otclient  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& 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  // release dragging widget
103  bool accepted = false;
104  if(m_draggingWidget && event.mouseButton == Fw::MouseLeftButton)
105  accepted = updateDraggingWidget(nullptr, event.mousePos);
106 
107  if(!accepted) {
108  m_mouseReceiver->propagateOnMouseEvent(event.mousePos, widgetList);
109 
110  // mouse release is always fired first on the pressed widget
111  if(m_pressedWidget) {
112  auto it = std::find(widgetList.begin(), widgetList.end(), m_pressedWidget);
113  if(it != widgetList.end())
114  widgetList.erase(it);
115  widgetList.push_front(m_pressedWidget);
116  }
117 
118  for(const UIWidgetPtr& widget : widgetList) {
119  if(widget->onMouseRelease(event.mousePos, event.mouseButton))
120  break;
121  }
122  }
123 
124  if(m_pressedWidget && event.mouseButton == Fw::MouseLeftButton)
125  updatePressedWidget(nullptr, event.mousePos, !accepted);
126  break;
127  }
129  // start dragging when moving a pressed widget
130  if(m_pressedWidget && m_pressedWidget->isDraggable() && m_draggingWidget != m_pressedWidget) {
131  // only drags when moving more than 4 pixels
132  if((event.mousePos - m_pressedWidget->getLastClickPosition()).length() >= 4)
133  updateDraggingWidget(m_pressedWidget, event.mousePos - event.mouseMoved);
134  }
135 
136  // mouse move can change hovered widgets
137  updateHoveredWidget(true);
138 
139  // first fire dragging move
140  if(m_draggingWidget) {
141  if(m_draggingWidget->onDragMove(event.mousePos, event.mouseMoved))
142  break;
143  }
144 
145  if(m_pressedWidget) {
146  if(m_pressedWidget->onMouseMove(event.mousePos, event.mouseMoved)) {
147  break;
148  }
149  }
150 
151  m_mouseReceiver->propagateOnMouseMove(event.mousePos, event.mouseMoved, widgetList);
152  for(const UIWidgetPtr& widget : widgetList) {
153  if(widget->onMouseMove(event.mousePos, event.mouseMoved))
154  break;
155  }
156  break;
157  }
159  m_rootWidget->propagateOnMouseEvent(event.mousePos, widgetList);
160  for(const UIWidgetPtr& widget : widgetList) {
161  if(widget->onMouseWheel(event.mousePos, event.wheelDirection))
162  break;
163  }
164  break;
165  default:
166  break;
167  };
168 }
169 
170 void UIManager::updatePressedWidget(const UIWidgetPtr& newPressedWidget, const Point& clickedPos, bool fireClicks)
171 {
172  UIWidgetPtr oldPressedWidget = m_pressedWidget;
173  m_pressedWidget = newPressedWidget;
174 
175  // when releasing mouse inside pressed widget area send onClick event
176  if(fireClicks && oldPressedWidget && oldPressedWidget->isEnabled() && oldPressedWidget->containsPoint(clickedPos))
177  oldPressedWidget->onClick(clickedPos);
178 
179  if(newPressedWidget)
180  newPressedWidget->updateState(Fw::PressedState);
181 
182  if(oldPressedWidget)
183  oldPressedWidget->updateState(Fw::PressedState);
184 }
185 
186 bool UIManager::updateDraggingWidget(const UIWidgetPtr& draggingWidget, const Point& clickedPos)
187 {
188  bool accepted = false;
189 
190  UIWidgetPtr oldDraggingWidget = m_draggingWidget;
191  m_draggingWidget = nullptr;
192  if(oldDraggingWidget) {
193  UIWidgetPtr droppedWidget;
194  if(!clickedPos.isNull()) {
195  auto clickedChildren = m_rootWidget->recursiveGetChildrenByPos(clickedPos);
196  for(const UIWidgetPtr& child : clickedChildren) {
197  if(child->onDrop(oldDraggingWidget, clickedPos)) {
198  droppedWidget = child;
199  break;
200  }
201  }
202  }
203 
204  accepted = oldDraggingWidget->onDragLeave(droppedWidget, clickedPos);
205  oldDraggingWidget->updateState(Fw::DraggingState);
206  }
207 
208  if(draggingWidget) {
209  if(draggingWidget->onDragEnter(clickedPos)) {
210  m_draggingWidget = draggingWidget;
211  draggingWidget->updateState(Fw::DraggingState);
212  accepted = true;
213  }
214  }
215 
216  return accepted;
217 }
218 
220 {
221  if(m_hoverUpdateScheduled && !now)
222  return;
223 
224  auto func = [this] {
225  if(!m_rootWidget)
226  return;
227 
228  m_hoverUpdateScheduled = false;
229  UIWidgetPtr hoveredWidget;
230  //if(!g_window.isMouseButtonPressed(Fw::MouseLeftButton) && !g_window.isMouseButtonPressed(Fw::MouseRightButton)) {
231  hoveredWidget = m_rootWidget->recursiveGetChildByPos(g_window.getMousePosition(), false);
232  if(hoveredWidget && !hoveredWidget->isEnabled())
233  hoveredWidget = nullptr;
234  //}
235 
236  if(hoveredWidget != m_hoveredWidget) {
237  UIWidgetPtr oldHovered = m_hoveredWidget;
238  m_hoveredWidget = hoveredWidget;
239  if(oldHovered) {
240  oldHovered->updateState(Fw::HoverState);
241  oldHovered->onHoverChange(false);
242  }
243  if(hoveredWidget) {
244  hoveredWidget->updateState(Fw::HoverState);
245  hoveredWidget->onHoverChange(true);
246  }
247  }
248  };
249 
250  if(now)
251  func();
252  else {
253  m_hoverUpdateScheduled = true;
254  g_dispatcher.addEvent(func);
255  }
256 }
257 
259 {
262 }
263 
265 {
268 }
269 
271 {
272  // release input grabs
273  if(m_keyboardReceiver == widget)
275 
276  if(m_mouseReceiver == widget)
278 
279  if(m_hoveredWidget == widget)
281 
282  if(m_pressedWidget == widget)
283  updatePressedWidget(nullptr);
284 
285  if(m_draggingWidget == widget)
286  updateDraggingWidget(nullptr);
287 
288 #ifndef NDEBUG
289  if(widget == m_rootWidget || !m_rootWidget)
290  return;
291 
292  m_destroyedWidgets.push_back(widget);
293 
294  if(m_checkEvent && !m_checkEvent->isExecuted())
295  return;
296 
297  m_checkEvent = g_dispatcher.scheduleEvent([this] {
299  UIWidgetList backupList = m_destroyedWidgets;
300  m_destroyedWidgets.clear();
301  g_dispatcher.scheduleEvent([backupList] {
303  for(const UIWidgetPtr& widget : backupList) {
304  if(widget->ref_count() != 1)
305  g_logger.warning(stdext::format("widget '%s' destroyed but still have %d reference(s) left", widget->getId(), widget->getUseCount()-1));
306  }
307  }, 1);
308  }, 1000);
309 #endif
310 }
311 
313 {
314  m_styles.clear();
315 }
316 
317 bool UIManager::importStyle(std::string file)
318 {
319  try {
320  file = g_resources.guessFilePath(file, "otui");
321 
323 
324  for(const OTMLNodePtr& styleNode : doc->children())
325  importStyleFromOTML(styleNode);
326  return true;
327  } catch(stdext::exception& e) {
328  g_logger.error(stdext::format("Failed to import UI styles from '%s': %s", file, e.what()));
329  return false;
330  }
331 }
332 
334 {
335  std::string tag = styleNode->tag();
336  std::vector<std::string> split = stdext::split(tag, "<");
337  if(split.size() != 2)
338  throw OTMLException(styleNode, "not a valid style declaration");
339 
340  std::string name = split[0];
341  std::string base = split[1];
342  bool unique = false;
343 
344  stdext::trim(name);
345  stdext::trim(base);
346 
347  if(name[0] == '#') {
348  name = name.substr(1);
349  unique = true;
350 
351  styleNode->setTag(name);
352  styleNode->writeAt("__unique", true);
353  }
354 
355  OTMLNodePtr oldStyle = m_styles[name];
356 
357  // Warn about redefined styles
358  /*
359  if(!g_app.isRunning() && (oldStyle && !oldStyle->valueAt("__unique", false))) {
360  auto it = m_styles.find(name);
361  if(it != m_styles.end())
362  g_logger.warning(stdext::format("style '%s' is being redefined", name));
363  }
364  */
365 
366  if(!oldStyle || !oldStyle->valueAt("__unique", false) || unique) {
367  OTMLNodePtr originalStyle = getStyle(base);
368  if(!originalStyle)
369  stdext::throw_exception(stdext::format("base style '%s', is not defined", base));
370  OTMLNodePtr style = originalStyle->clone();
371  style->merge(styleNode);
372  style->setTag(name);
373  m_styles[name] = style;
374  }
375 }
376 
377 OTMLNodePtr UIManager::getStyle(const std::string& styleName)
378 {
379  auto it = m_styles.find(styleName);
380  if(it != m_styles.end())
381  return m_styles[styleName];
382 
383  // styles starting with UI are automatically defined
384  if(stdext::starts_with(styleName, "UI")) {
385  OTMLNodePtr node = OTMLNode::create(styleName);
386  node->writeAt("__class", styleName);
387  m_styles[styleName] = node;
388  return node;
389  }
390 
391  return nullptr;
392 }
393 
394 std::string UIManager::getStyleClass(const std::string& styleName)
395 {
396  OTMLNodePtr style = getStyle(styleName);
397  if(style && style->get("__class"))
398  return style->valueAt("__class");
399  return "";
400 }
401 
402 UIWidgetPtr UIManager::loadUI(std::string file, const UIWidgetPtr& parent)
403 {
404  try {
405  file = g_resources.guessFilePath(file, "otui");
406 
408  UIWidgetPtr widget;
409  for(const OTMLNodePtr& node : doc->children()) {
410  std::string tag = node->tag();
411 
412  // import styles in these files too
413  if(tag.find("<") != std::string::npos)
414  importStyleFromOTML(node);
415  else {
416  if(widget)
417  stdext::throw_exception("cannot have multiple main widgets in otui files");
418  widget = createWidgetFromOTML(node, parent);
419  }
420  }
421 
422  return widget;
423  } catch(stdext::exception& e) {
424  g_logger.error(stdext::format("failed to load UI from '%s': %s", file, e.what()));
425  return nullptr;
426  }
427 }
428 
429 UIWidgetPtr UIManager::createWidget(const std::string& styleName, const UIWidgetPtr& parent)
430 {
431  OTMLNodePtr node = OTMLNode::create(styleName);
432  try {
433  return createWidgetFromOTML(node, parent);
434  } catch(stdext::exception& e) {
435  g_logger.error(stdext::format("failed to create widget from style '%s': %s", styleName, e.what()));
436  return nullptr;
437  }
438 }
439 
441 {
442  OTMLNodePtr originalStyleNode = getStyle(widgetNode->tag());
443  if(!originalStyleNode)
444  stdext::throw_exception(stdext::format("'%s' is not a defined style", widgetNode->tag()));
445 
446  OTMLNodePtr styleNode = originalStyleNode->clone();
447  styleNode->merge(widgetNode);
448 
449  std::string widgetType = styleNode->valueAt("__class");
450 
451  // call widget creation from lua
452  UIWidgetPtr widget = g_lua.callGlobalField<UIWidgetPtr>(widgetType, "create");
453  if(parent)
454  parent->addChild(widget);
455 
456  if(widget) {
457  widget->callLuaField("onCreate");
458 
459  widget->setStyleFromNode(styleNode);
460 
461  for(const OTMLNodePtr& childNode : styleNode->children()) {
462  if(!childNode->isUnique()) {
463  createWidgetFromOTML(childNode, widget);
464  styleNode->removeChild(childNode);
465  }
466  }
467  } else
468  stdext::throw_exception(stdext::format("unable to create widget of type '%s'", widgetType));
469 
470  widget->callLuaField("onSetup");
471  return widget;
472 }
ui.h
OTMLNode::setTag
void setTag(const std::string &tag)
Definition: otmlnode.h:50
UIManager::onWidgetAppear
void onWidgetAppear(const UIWidgetPtr &widget)
Definition: uimanager.cpp:258
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:1520
UIManager::onWidgetDisappear
void onWidgetDisappear(const UIWidgetPtr &widget)
Definition: uimanager.cpp:264
UIManager::getStyle
OTMLNodePtr getStyle(const std::string &styleName)
Definition: uimanager.cpp:377
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:1713
UIWidget::propagateOnKeyDown
bool propagateOnKeyDown(uchar keyCode, int keyboardModifiers)
Definition: uiwidget.cpp:1622
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:1173
OTMLNode::removeChild
bool removeChild(const OTMLNodePtr &oldChild)
Definition: otmlnode.cpp:124
UIWidget::getId
std::string getId()
Definition: uiwidget.h:254
UIWidget::onHoverChange
virtual void onHoverChange(bool hovered)
Definition: uiwidget.cpp:1508
UIManager::updateHoveredWidget
void updateHoveredWidget(bool now=false)
Definition: uimanager.cpp:219
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:774
Fw::KeyUpInputEvent
@ KeyUpInputEvent
Definition: const.h:239
UIWidget::propagateOnKeyPress
bool propagateOnKeyPress(uchar keyCode, int keyboardModifiers, int autoRepeatTicks)
Definition: uiwidget.cpp:1644
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:170
UIManager::getStyleClass
std::string getStyleClass(const std::string &styleName)
Definition: uimanager.cpp:394
Fw::HoverState
@ HoverState
Definition: const.h:271
stdext::format
std::string format()
Definition: format.h:82
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:312
UIWidget::onDragMove
virtual bool onDragMove(const Point &mousePos, const Point &mouseMoved)
Definition: uiwidget.cpp:1530
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:440
UIManager::importStyleFromOTML
void importStyleFromOTML(const OTMLNodePtr &styleNode)
Definition: uimanager.cpp:333
UIManager::resetMouseReceiver
void resetMouseReceiver()
Definition: uimanager.h:60
OTMLNode::clone
OTMLNodePtr clone()
Definition: otmlnode.cpp:179
UIWidget::propagateOnKeyUp
bool propagateOnKeyUp(uchar keyCode, int keyboardModifiers)
Definition: uiwidget.cpp:1669
OTMLNode::get
OTMLNodePtr get(const std::string &childTag)
Definition: otmlnode.cpp:54
UIWidget::onClick
virtual bool onClick(const Point &mousePos)
Definition: uiwidget.cpp:1590
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:1600
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:402
UIWidget::setStyleFromNode
void setStyleFromNode(const OTMLNodePtr &styleNode)
Definition: uiwidget.cpp:919
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:170
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:157
UIManager::onWidgetDestroy
void onWidgetDestroy(const UIWidgetPtr &widget)
Definition: uimanager.cpp:270
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:1580
UIWidget::recursiveGetChildrenByPos
UIWidgetList recursiveGetChildrenByPos(const Point &childPos)
Definition: uiwidget.cpp:1203
UIManager::updateDraggingWidget
bool updateDraggingWidget(const UIWidgetPtr &draggingWidget, const Point &clickedPos=Point())
Definition: uimanager.cpp:186
UIWidget::getRect
Rect getRect()
Definition: uiwidget.h:358
TPoint< int >
UIManager::importStyle
bool importStyle(std::string file)
Definition: uimanager.cpp:317
UIWidget::onDragLeave
virtual bool onDragLeave(UIWidgetPtr droppedWidget, const Point &mousePos)
Definition: uiwidget.cpp:1525
Fw::KeyDownInputEvent
@ KeyDownInputEvent
Definition: const.h:237
LuaInterface::collectGarbage
void collectGarbage()
Definition: luainterface.cpp:714
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:809
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:429
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:352
UIWidget::propagateOnMouseEvent
bool propagateOnMouseEvent(const Point &mousePos, UIWidgetList &widgetList)
Definition: uiwidget.cpp:1691
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