Go to the documentation of this file.
39 m_rootWidget->
setId(
"root");
40 m_mouseReceiver = m_rootWidget;
41 m_keyboardReceiver = m_rootWidget;
48 m_mouseReceiver =
nullptr;
49 m_keyboardReceiver =
nullptr;
50 m_rootWidget =
nullptr;
51 m_draggingWidget =
nullptr;
52 m_hoveredWidget =
nullptr;
53 m_pressedWidget =
nullptr;
55 m_destroyedWidgets.clear();
56 m_checkEvent =
nullptr;
61 m_rootWidget->
draw(m_rootWidget->
getRect(), drawPane);
88 if(pressedWidget && !pressedWidget->
isEnabled())
89 pressedWidget =
nullptr;
103 bool accepted =
false;
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);
130 if(m_pressedWidget && m_pressedWidget->
isDraggable() && m_draggingWidget != m_pressedWidget) {
140 if(m_draggingWidget) {
145 if(m_pressedWidget) {
173 m_pressedWidget = newPressedWidget;
176 if(fireClicks && oldPressedWidget && oldPressedWidget->
isEnabled() && oldPressedWidget->
containsPoint(clickedPos))
177 oldPressedWidget->
onClick(clickedPos);
188 bool accepted =
false;
191 m_draggingWidget =
nullptr;
192 if(oldDraggingWidget) {
194 if(!clickedPos.
isNull()) {
197 if(child->onDrop(oldDraggingWidget, clickedPos)) {
198 droppedWidget = child;
204 accepted = oldDraggingWidget->
onDragLeave(droppedWidget, clickedPos);
210 m_draggingWidget = draggingWidget;
221 if(m_hoverUpdateScheduled && !now)
228 m_hoverUpdateScheduled =
false;
232 if(hoveredWidget && !hoveredWidget->
isEnabled())
233 hoveredWidget =
nullptr;
236 if(hoveredWidget != m_hoveredWidget) {
238 m_hoveredWidget = hoveredWidget;
253 m_hoverUpdateScheduled =
true;
273 if(m_keyboardReceiver == widget)
276 if(m_mouseReceiver == widget)
279 if(m_hoveredWidget == widget)
282 if(m_pressedWidget == widget)
285 if(m_draggingWidget == widget)
289 if(widget == m_rootWidget || !m_rootWidget)
292 m_destroyedWidgets.push_back(widget);
294 if(m_checkEvent && !m_checkEvent->
isExecuted())
300 m_destroyedWidgets.clear();
335 std::string tag = styleNode->
tag();
337 if(
split.size() != 2)
338 throw OTMLException(styleNode,
"not a valid style declaration");
340 std::string name =
split[0];
341 std::string base =
split[1];
348 name = name.substr(1);
352 styleNode->
writeAt(
"__unique",
true);
366 if(!oldStyle || !oldStyle->
valueAt(
"__unique",
false) || unique) {
371 style->
merge(styleNode);
373 m_styles[name] = style;
379 auto it = m_styles.find(styleName);
380 if(it != m_styles.end())
381 return m_styles[styleName];
386 node->
writeAt(
"__class", styleName);
387 m_styles[styleName] = node;
397 if(style && style->
get(
"__class"))
398 return style->
valueAt(
"__class");
410 std::string tag = node->tag();
413 if(tag.find(
"<") != std::string::npos)
443 if(!originalStyleNode)
447 styleNode->
merge(widgetNode);
449 std::string widgetType = styleNode->
valueAt(
"__class");
462 if(!childNode->isUnique()) {
void setTag(const std::string &tag)
void onWidgetAppear(const UIWidgetPtr &widget)
void onWidgetDisappear(const UIWidgetPtr &widget)
OTMLNodePtr getStyle(const std::string &styleName)
void writeAt(const std::string &childTag, const T &v)
void resize(const Size &size)
All OTML errors throw this exception.
EventDispatcher g_dispatcher
static OTMLDocumentPtr parse(const std::string &fileName)
Parse OTML from a file.
void callGlobalField(const std::string &global, const std::string &field, const T &... args)
bool removeChild(const OTMLNodePtr &oldChild)
void updateHoveredWidget(bool now=false)
stdext::shared_object_ptr< UIWidget > UIWidgetPtr
void error(const std::string &what)
std::string getStyleClass(const std::string &styleName)
bool starts_with(const std::string &str, const std::string &test)
ResourceManager g_resources
T valueAt(const std::string &childTag)
R callLuaField(const std::string &field, const T &... args)
EventPtr addEvent(const std::function< void()> &callback, bool pushFront=false)
UIWidgetPtr createWidgetFromOTML(const OTMLNodePtr &widgetNode, const UIWidgetPtr &parent)
void importStyleFromOTML(const OTMLNodePtr &styleNode)
void resetMouseReceiver()
OTMLNodePtr get(const std::string &childTag)
void resetKeyboardReceiver()
void trim(std::string &str)
void render(Fw::DrawPane drawPane)
void throw_exception(const std::string &what)
Throws a generic exception.
UIWidgetPtr loadUI(std::string file, const UIWidgetPtr &parent)
std::vector< std::string > split(const std::string &str, const std::string &separators)
virtual const char * what() const
void updatePressedWidget(const UIWidgetPtr &newPressedWidget, const Point &clickedPos=Point(), bool fireClicks=true)
void merge(const OTMLNodePtr &node)
void onWidgetDestroy(const UIWidgetPtr &widget)
void inputEvent(const InputEvent &event)
bool updateDraggingWidget(const UIWidgetPtr &draggingWidget, const Point &clickedPos=Point())
bool importStyle(std::string file)
ScheduledEventPtr scheduleEvent(const std::function< void()> &callback, int delay)
std::deque< UIWidgetPtr > UIWidgetList
UIWidgetPtr createWidget(const std::string &styleName, const UIWidgetPtr &parent)
std::string guessFilePath(const std::string &filename, const std::string &type)
void warning(const std::string &what)
static OTMLNodePtr create(std::string tag="", bool unique=false)