void InvalidateVisibleParent(IWidget& wgt) { if(IsVisible(wgt)) if(const auto p_con = FetchContainerPtr(wgt)) InvalidateVisible(*p_con, GetBoundsOf(wgt)); }
void Widget::SetView(unique_ptr<AView> p) { if(!p) p.reset(new View(GetBoundsOf(*this))); p->swap(*view_ptr); view_ptr = std::move(p); }
void BorderResizer::Wrap() { auto& controller(widget.get().GetController()); yunseq( FetchEvent<TouchDown>(controller).Add([this](CursorEventArgs&& e){ yunseq(orig_loc = FetchGUIState().CursorLocation, locked_bounds = GetBoundsOf(widget), focused = CheckArea(e)); }, 0xE0), FetchEvent<TouchHeld>(controller).Add([this](CursorEventArgs&& e){ if(e.Strategy == RoutedEventArgs::Direct && focused != Area(BorderArea::Center, BorderArea::Center)) { auto& st(FetchGUIState()); if(st.CheckDraggingOffset()) { const auto offset(st.CursorLocation - orig_loc); auto bounds(locked_bounds); switch(focused.first) { case BorderArea::Left: bounds.Width = max<SPos>(MinSize.Width, locked_bounds.Width - offset.X); bounds.X += locked_bounds.Width - bounds.Width; break; case BorderArea::Right: bounds.Width = max<SPos>(MinSize.Width, locked_bounds.Width + offset.X); break; default: ; } switch(focused.second) { case BorderArea::Up: bounds.Height = max<SPos>(MinSize.Height, locked_bounds.Height - offset.Y); bounds.Y += locked_bounds.Height - bounds.Height; break; case BorderArea::Down: bounds.Height = max<SPos>(MinSize.Height, locked_bounds.Height + offset.Y); break; default: ; } YTraceDe(Notice, "BorderResizer: new bounds = %s.\n", to_string(bounds).c_str()); InvalidateParent(widget); if(HostMode) { const auto& off( bounds.GetPoint() - locked_bounds.GetPoint()); SetBoundsOf(widget, bounds); const auto& nloc(FetchGUIState().CursorLocation - off); if(bounds.Width != MinSize.Width) orig_loc.X = nloc.X; if(bounds.Height != MinSize.Height) orig_loc.Y = nloc.Y; locked_bounds = GetBoundsOf(widget); locked_bounds.GetPointRef() -= off; } else SetBoundsOf(widget, bounds); } e.Handled = true; // XXX: Paint context target invalidated. } }, 0xE0), FetchEvent<Click>(controller).Add([this](CursorEventArgs&& e){ CallEvent<ClickAcross>(widget, e); }, 0xE0), FetchEvent<ClickAcross>(controller).Add([this](CursorEventArgs&&){ yunseq(orig_loc = Point::Invalid, locked_bounds = Rect(), focused = {BorderArea::Center, BorderArea::Center}); }, 0xE0) ); }
void SetInvalidationToParent(IWidget& wgt) { if(const auto p_con = FetchContainerPtr(wgt)) p_con->GetRenderer().CommitInvalidation(GetBoundsOf(wgt)); }