Path MakeNormalizedAbsolute(const Path& pth, size_t len) { Path res(pth); if(IsRelative(res)) res = Path(FetchCurrentWorkingDirectory(len)) / res; res.Normalize(); YTraceDe(Debug, "Converted path is '%s'.", string(res).c_str()); YAssert(IsAbsolute(res), "Invalid path converted."); return res; }
void EnsureDirectory(const Path& pth) { string upath; for(const auto& name : pth) { upath += MakeMBCS(name.c_str()) + YCL_PATH_DELIMITER; if(!VerifyDirectory(upath) && !umkdir(upath.c_str()) && errno != EEXIST) { YTraceDe(Err, "Failed making directory path '%s'", upath.c_str()); ystdex::throw_error(errno); } } }
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) ); }