111 if(!child->isExplicitlyVisible() || !child->getRect().isValid() || child->getOpacity() < Fw::MIN_ALPHA)
115 if(!childVisibleRect.
isValid())
122 if(child->getOpacity() < oldOpacity)
125 child->draw(childVisibleRect, drawPane);
141 g_logger.traceWarning(
"attempt to add a null child into a UIWidget");
146 g_logger.traceWarning(
"attemp to add a destroyed child into a UIWidget");
151 g_logger.traceWarning(
"attempt to add a child again into a UIWidget");
158 child->
setParent(static_self_cast<UIWidget>());
168 child->updateStates();
182 g_logger.traceWarning(
"attempt to insert a null child into a UIWidget");
187 g_logger.traceWarning(
"attempt to insert a child again into a UIWidget");
191 index = index <= 0 ? (
m_children.size() + index) : index-1;
195 index = stdext::clamp<int>(index, 0, (
int)
m_children.size());
201 child->
setParent(static_self_cast<UIWidget>());
211 child->updateStates();
212 updateChildrenIndexStates();
222 bool focusAnother =
false;
235 assert(child->
getParent() == static_self_cast<UIWidget>());
241 child->updateStates();
242 updateChildrenIndexStates();
249 g_logger.traceError(
"attempt to remove an unknown child from a UIWidget");
262 g_logger.
error(
"attempt to focus an unknown child in a UIWidget");
299 auto focusedIt = std::find(rotatedChildren.begin(), rotatedChildren.end(),
m_focusedChild);
300 if(focusedIt != rotatedChildren.end()) {
301 std::rotate(rotatedChildren.begin(), focusedIt, rotatedChildren.end());
302 rotatedChildren.pop_front();
308 if(child->isFocusable() && child->isExplicitlyEnabled() && child->isVisible()) {
339 std::reverse(rotatedChildren.begin(), rotatedChildren.end());
342 auto focusedIt = std::find(rotatedChildren.begin(), rotatedChildren.end(),
m_focusedChild);
343 if(focusedIt != rotatedChildren.end()) {
344 std::rotate(rotatedChildren.begin(), focusedIt, rotatedChildren.end());
345 rotatedChildren.pop_front();
351 if(child->isFocusable() && child->isExplicitlyEnabled() && child->isVisible()) {
385 g_logger.traceError(
"cannot find child");
391 updateChildrenIndexStates();
405 g_logger.traceError(
"cannot find child");
410 updateChildrenIndexStates();
429 g_logger.traceError(
"cannot find child");
434 updateChildrenIndexStates();
447 g_logger.traceError(
"cannot find child");
457 if(otherChild == child)
460 otherChild->setEnabled(
false);
479 g_logger.traceError(
"cannot find child");
499 if(otherChild == lockedChild)
502 otherChild->setEnabled(
false);
506 otherChild->setEnabled(
true);
531 if(styleNode->
size() == 0)
534 m_loadingStyle =
true;
538 if(node->tag()[0] ==
'!') {
539 std::string tag = node->tag().substr(1);
541 std::string origin =
"@" + node->source() +
": [" + node->tag() +
"]";
546 node->setValue(value);
562 m_firstOnStyle =
false;
566 m_loadingStyle =
false;
575 anchorLayout->addAnchor(static_self_cast<UIWidget>(), anchoredEdge, hookedWidgetId, hookedEdge);
617 anchorLayout->removeAnchors(static_self_cast<UIWidget>());
626 parent->updateLayout();
642 parentLayout->updateLater();
651 parent->lockChild(static_self_cast<UIWidget>());
660 parent->unlockChild(static_self_cast<UIWidget>());
682 parent->focusChild(static_self_cast<UIWidget>(), reason);
683 parent->recursiveFocus(reason);
694 parent->
lowerChild(static_self_cast<UIWidget>());
704 parent->
raiseChild(static_self_cast<UIWidget>());
744 boundRect.
bind(parentRect);
750 void UIWidget::internalDestroy()
764 child->internalDestroy();
785 parent->removeChild(
self);
823 if(oldParent == parent)
827 if(oldParent && oldParent->
hasChild(
self))
851 layout->
setParent(static_self_cast<UIWidget>());
889 if(!m_updateEventScheduled) {
892 self->m_updateEventScheduled =
false;
893 if(oldRect != self->getRect())
894 self->onGeometryChange(oldRect, self->getRect());
896 m_updateEventScheduled =
true;
913 styleNode = styleNode->
clone();
981 }
else if(focusable && !parent->getFocusedChild() && parent->getAutoFocusPolicy() !=
Fw::AutoFocusNone) {
1025 return anchorLayout->hasAnchors(static_self_cast<UIWidget>());
1072 if(!child->isExplicitlyVisible() || !child->getRect().isValid())
1074 Rect marginRect = child->getMarginRect();
1076 childrenRect = marginRect;
1078 childrenRect = childrenRect.
united(marginRect);
1083 childrenRect = myClippingRect;
1085 if(childrenRect.
width() < myClippingRect.
width())
1090 return childrenRect;
1110 return static_self_cast<UIWidget>();
1132 if(child->getId() == childId)
1154 index = index <= 0 ? (
m_children.size() + index) : index-1;
1184 else if(wantsPhantom || !child->
isPhantom())
1195 UIWidgetList subChildren = child->recursiveGetChildren();
1196 if(!subChildren.empty())
1197 children.insert(children.end(), subChildren.begin(), subChildren.end());
1198 children.push_back(child);
1213 if(!subChildren.empty())
1214 children.insert(children.end(), subChildren.begin(), subChildren.end());
1215 children.push_back(child);
1231 if(!subChildren.empty())
1232 children.insert(children.end(), subChildren.begin(), subChildren.end());
1233 children.push_back(child);
1254 int oldStates = m_states;
1260 if(oldStates != m_states) {
1271 return (m_states & state);
1279 bool newStatus =
true;
1281 bool updateChildren =
false;
1285 UIWidgetPtr widget = static_self_cast<UIWidget>();
1288 parent = widget->getParent();
1289 if(!widget->isExplicitlyEnabled() ||
1290 ((parent && parent->getFocusedChild() != widget))) {
1294 }
while((widget = parent));
1296 updateChildren = newStatus != oldStatus;
1316 bool enabled =
true;
1317 UIWidgetPtr widget = static_self_cast<UIWidget>();
1319 if(!widget->isExplicitlyEnabled()) {
1323 }
while((widget = widget->getParent()));
1324 newStatus = !enabled;
1325 updateChildren = newStatus != oldStatus;
1345 bool visible =
true;
1346 UIWidgetPtr widget = static_self_cast<UIWidget>();
1348 if(!widget->isExplicitlyVisible()) {
1352 }
while((widget = widget->getParent()));
1353 newStatus = !visible;
1354 updateChildren = newStatus != oldStatus;
1361 if(updateChildren) {
1365 child->updateState(state);
1378 void UIWidget::updateStates()
1387 void UIWidget::updateChildrenIndexStates()
1400 void UIWidget::updateStyle()
1405 if(m_loadingStyle && !m_updateStyleScheduled) {
1408 self->m_updateStyleScheduled =
false;
1409 self->updateStyle();
1411 m_updateStyleScheduled =
true;
1424 newStateStyle->
addChild(otherNode->clone());
1431 std::string statesStr = style->tag().substr(1);
1432 std::vector<std::string> statesSplit =
stdext::split(statesStr,
" ");
1435 for(std::string stateStr : statesSplit) {
1436 if(stateStr.length() == 0)
1439 bool notstate = (stateStr[0] ==
'!');
1441 stateStr = stateStr.substr(1);
1444 if((!notstate && !stateOn) || (notstate && stateOn))
1450 newStateStyle->
merge(style);
1458 m_stateStyle = newStateStyle;
1468 setId(node->value());
1470 parseBaseStyle(styleNode);
1471 parseImageStyle(styleNode);
1472 parseTextStyle(styleNode);
1484 if(!child->isAnchored() && child->isVisible())
1485 child->bindRectToParent();
1505 callLuaField(
"onChildFocusChange", focusedChild, unfocusedChild, reason);
1522 return callLuaField<bool>(
"onDragEnter", mousePos);
1527 return callLuaField<bool>(
"onDragLeave", droppedWidget, mousePos);
1532 return callLuaField<bool>(
"onDragMove", mousePos, mouseMoved);
1537 return callLuaField<bool>(
"onDrop", draggedWidget, mousePos);
1542 return callLuaField<bool>(
"onKeyText", keyText);
1547 return callLuaField<bool>(
"onKeyDown", keyCode, keyboardModifiers);
1552 return callLuaField<bool>(
"onKeyPress", keyCode, keyboardModifiers, autoRepeatTicks);
1557 return callLuaField<bool>(
"onKeyUp", keyCode, keyboardModifiers);
1572 return callLuaField<bool>(
"onMousePress", mousePos, button);
1577 return callLuaField<bool>(
"onMouseRelease", mousePos, button);
1582 return callLuaField<bool>(
"onMouseMove", mousePos, mouseMoved);
1587 return callLuaField<bool>(
"onMouseWheel", mousePos, direction);
1592 return callLuaField<bool>(
"onClick", mousePos);
1597 return callLuaField<bool>(
"onDoubleClick", mousePos);
1606 if(!child->isExplicitlyEnabled() || !child->isExplicitlyVisible())
1610 if(child->isFocused())
1611 children.push_back(child);
1615 if(child->propagateOnKeyText(keyText))
1628 if(!child->isExplicitlyEnabled() || !child->isExplicitlyVisible())
1632 if(child->isFocused())
1633 children.push_back(child);
1637 if(child->propagateOnKeyDown(keyCode, keyboardModifiers))
1641 return onKeyDown(keyCode, keyboardModifiers);
1650 if(!child->isExplicitlyEnabled() || !child->isExplicitlyVisible())
1654 if(child->isFocused())
1655 children.push_back(child);
1659 if(child->propagateOnKeyPress(keyCode, keyboardModifiers, autoRepeatTicks))
1664 return onKeyPress(keyCode, keyboardModifiers, autoRepeatTicks);
1675 if(!child->isExplicitlyEnabled() || !child->isExplicitlyVisible())
1679 if(child->isFocused())
1680 children.push_back(child);
1684 if(child->propagateOnKeyUp(keyCode, keyboardModifiers))
1688 return onKeyUp(keyCode, keyboardModifiers);
1706 widgetList.push_back(static_self_cast<UIWidget>());
1717 if(child->isExplicitlyVisible() && child->isExplicitlyEnabled() && child->containsPoint(mousePos))
1718 child->propagateOnMouseMove(mousePos, mouseMoved, widgetList);
1720 widgetList.push_back(static_self_cast<UIWidget>());