diff --git a/Import/GacUI.cpp b/Import/GacUI.cpp index 55b9bcf5..8d35c835 100644 --- a/Import/GacUI.cpp +++ b/Import/GacUI.cpp @@ -6541,9 +6541,9 @@ DataGridContentProvider CloseEditor(false); } - GuiListControl::IItemCoordinateTransformer* DataGridContentProvider::CreatePreferredCoordinateTransformer() + compositions::IGuiAxis* DataGridContentProvider::CreatePreferredAxis() { - return new DefaultItemCoordinateTransformer; + return new GuiDefaultAxis; } GuiListControl::IItemArranger* DataGridContentProvider::CreatePreferredArranger() @@ -8420,7 +8420,7 @@ GuiListControl::ItemCallback void GuiListControl::ItemCallback::SetViewLocation(Point value) { Rect virtualRect(value, listControl->GetViewSize()); - Rect realRect=listControl->itemCoordinateTransformer->VirtualRectToRealRect(listControl->fullSize, virtualRect); + Rect realRect=listControl->axis->VirtualRectToRealRect(listControl->fullSize, virtualRect); listControl->GetHorizontalScroll()->SetPosition(realRect.Left()); listControl->GetVerticalScroll()->SetPosition(realRect.Top()); } @@ -8428,24 +8428,24 @@ GuiListControl::ItemCallback Size GuiListControl::ItemCallback::GetStylePreferredSize(IItemStyleController* style) { Size size=style->GetBoundsComposition()->GetPreferredBounds().GetSize(); - return listControl->itemCoordinateTransformer->RealSizeToVirtualSize(size); + return listControl->axis->RealSizeToVirtualSize(size); } void GuiListControl::ItemCallback::SetStyleAlignmentToParent(IItemStyleController* style, Margin margin) { - Margin newMargin=listControl->itemCoordinateTransformer->VirtualMarginToRealMargin(margin); + Margin newMargin=listControl->axis->VirtualMarginToRealMargin(margin); style->GetBoundsComposition()->SetAlignmentToParent(newMargin); } Rect GuiListControl::ItemCallback::GetStyleBounds(IItemStyleController* style) { Rect bounds=style->GetBoundsComposition()->GetBounds(); - return listControl->itemCoordinateTransformer->RealRectToVirtualRect(listControl->GetViewSize(), bounds); + return listControl->axis->RealRectToVirtualRect(listControl->GetViewSize(), bounds); } void GuiListControl::ItemCallback::SetStyleBounds(IItemStyleController* style, Rect bounds) { - Rect newBounds=listControl->itemCoordinateTransformer->VirtualRectToRealRect(listControl->GetViewSize(), bounds); + Rect newBounds=listControl->axis->VirtualRectToRealRect(listControl->GetViewSize(), bounds); return style->GetBoundsComposition()->SetBounds(newBounds); } @@ -8492,7 +8492,7 @@ GuiListControl Size GuiListControl::QueryFullSize() { Size virtualSize=itemArranger?itemArranger->GetTotalSize():Size(0, 0); - fullSize=itemCoordinateTransformer->VirtualSizeToRealSize(virtualSize); + fullSize=axis->VirtualSizeToRealSize(virtualSize); return fullSize; } @@ -8500,7 +8500,7 @@ GuiListControl { if(itemArranger) { - Rect newBounds=itemCoordinateTransformer->RealRectToVirtualRect(fullSize, viewBounds); + Rect newBounds=axis->RealRectToVirtualRect(fullSize, viewBounds); itemArranger->OnViewChanged(newBounds); } } @@ -8656,7 +8656,7 @@ GuiListControl { StyleProviderChanged.SetAssociatedComposition(boundsComposition); ArrangerChanged.SetAssociatedComposition(boundsComposition); - CoordinateTransformerChanged.SetAssociatedComposition(boundsComposition); + AxisChanged.SetAssociatedComposition(boundsComposition); ItemLeftButtonDown.SetAssociatedComposition(boundsComposition); ItemLeftButtonUp.SetAssociatedComposition(boundsComposition); @@ -8673,7 +8673,7 @@ GuiListControl callback=new ItemCallback(this); itemProvider->AttachCallback(callback.Obj()); - itemCoordinateTransformer=new list::DefaultItemCoordinateTransformer; + axis=new GuiDefaultAxis; if(acceptFocus) { @@ -8726,17 +8726,17 @@ GuiListControl return old; } - GuiListControl::IItemCoordinateTransformer* GuiListControl::GetCoordinateTransformer() + compositions::IGuiAxis* GuiListControl::GetAxis() { - return itemCoordinateTransformer.Obj(); + return axis.Obj(); } - Ptr GuiListControl::SetCoordinateTransformer(Ptr value) + Ptr GuiListControl::SetAxis(Ptr value) { - Ptr old=itemCoordinateTransformer; - itemCoordinateTransformer=value; + Ptr old=axis; + axis=value; SetStyleProviderAndArranger(itemStyleProvider, itemArranger); - CoordinateTransformerChanged.Execute(GetNotifyEventArguments()); + AxisChanged.Execute(GetNotifyEventArguments()); return old; } @@ -9016,40 +9016,40 @@ GuiSelectableListControl if(!GetArranger()) return false; NormalizeSelectedItemIndexStartEnd(); - KeyDirection keyDirection=Up; + KeyDirection keyDirection=KeyDirection::Up; switch(code) { case VKEY_UP: - keyDirection=Up; + keyDirection=KeyDirection::Up; break; case VKEY_DOWN: - keyDirection=Down; + keyDirection=KeyDirection::Down; break; case VKEY_LEFT: - keyDirection=Left; + keyDirection=KeyDirection::Left; break; case VKEY_RIGHT: - keyDirection=Right; + keyDirection=KeyDirection::Right; break; case VKEY_HOME: - keyDirection=Home; + keyDirection=KeyDirection::Home; break; case VKEY_END: - keyDirection=End; + keyDirection=KeyDirection::End; break; case VKEY_PRIOR: - keyDirection=PageUp; + keyDirection=KeyDirection::PageUp; break; case VKEY_NEXT: - keyDirection=PageDown; + keyDirection=KeyDirection::PageDown; break; default: return false; } - if(GetCoordinateTransformer()) + if(GetAxis()) { - keyDirection=GetCoordinateTransformer()->RealKeyDirectionToVirtualKeyDirection(keyDirection); + keyDirection=GetAxis()->RealKeyDirectionToVirtualKeyDirection(keyDirection); } vint itemIndex=GetArranger()->FindItem(selectedItemIndexEnd, keyDirection); if(SelectItemsByClick(itemIndex, ctrl, shift, true)) @@ -9075,363 +9075,6 @@ GuiSelectableListControl namespace list { -/*********************************************************************** -DefaultItemCoordinateTransformer -***********************************************************************/ - - DefaultItemCoordinateTransformer::DefaultItemCoordinateTransformer() - { - } - - DefaultItemCoordinateTransformer::~DefaultItemCoordinateTransformer() - { - } - - Size DefaultItemCoordinateTransformer::RealSizeToVirtualSize(Size size) - { - return size; - } - - Size DefaultItemCoordinateTransformer::VirtualSizeToRealSize(Size size) - { - return size; - } - - Point DefaultItemCoordinateTransformer::RealPointToVirtualPoint(Size realFullSize, Point point) - { - return point; - } - - Point DefaultItemCoordinateTransformer::VirtualPointToRealPoint(Size realFullSize, Point point) - { - return point; - } - - Rect DefaultItemCoordinateTransformer::RealRectToVirtualRect(Size realFullSize, Rect rect) - { - return rect; - } - - Rect DefaultItemCoordinateTransformer::VirtualRectToRealRect(Size realFullSize, Rect rect) - { - return rect; - } - - Margin DefaultItemCoordinateTransformer::RealMarginToVirtualMargin(Margin margin) - { - return margin; - } - - Margin DefaultItemCoordinateTransformer::VirtualMarginToRealMargin(Margin margin) - { - return margin; - } - - GuiListControl::KeyDirection DefaultItemCoordinateTransformer::RealKeyDirectionToVirtualKeyDirection(GuiListControl::KeyDirection key) - { - return key; - } - -/*********************************************************************** -AxisAlignedItemCoordinateTransformer -***********************************************************************/ - - AxisAlignedItemCoordinateTransformer::AxisAlignedItemCoordinateTransformer(Alignment _alignment) - :alignment(_alignment) - { - } - - AxisAlignedItemCoordinateTransformer::~AxisAlignedItemCoordinateTransformer() - { - } - - AxisAlignedItemCoordinateTransformer::Alignment AxisAlignedItemCoordinateTransformer::GetAlignment() - { - return alignment; - } - - Size AxisAlignedItemCoordinateTransformer::RealSizeToVirtualSize(Size size) - { - switch(alignment) - { - case LeftDown: - case RightDown: - case LeftUp: - case RightUp: - return Size(size.x, size.y); - case DownLeft: - case DownRight: - case UpLeft: - case UpRight: - return Size(size.y, size.x); - } - return size; - } - - Size AxisAlignedItemCoordinateTransformer::VirtualSizeToRealSize(Size size) - { - return RealSizeToVirtualSize(size); - } - - Point AxisAlignedItemCoordinateTransformer::RealPointToVirtualPoint(Size realFullSize, Point point) - { - Rect rect(point, Size(0, 0)); - return RealRectToVirtualRect(realFullSize, rect).LeftTop(); - } - - Point AxisAlignedItemCoordinateTransformer::VirtualPointToRealPoint(Size realFullSize, Point point) - { - Rect rect(point, Size(0, 0)); - return VirtualRectToRealRect(realFullSize, rect).LeftTop(); - } - - Rect AxisAlignedItemCoordinateTransformer::RealRectToVirtualRect(Size realFullSize, Rect rect) - { - vint x1=rect.x1; - vint x2=realFullSize.x-rect.x2; - vint y1=rect.y1; - vint y2=realFullSize.y-rect.y2; - vint w=rect.Width(); - vint h=rect.Height(); - switch(alignment) - { - case LeftDown: - return Rect(Point(x2, y1), Size(w, h)); - case RightDown: - return Rect(Point(x1, y1), Size(w, h)); - case LeftUp: - return Rect(Point(x2, y2), Size(w, h)); - case RightUp: - return Rect(Point(x1, y2), Size(w, h)); - case DownLeft: - return Rect(Point(y1, x2), Size(h, w)); - case DownRight: - return Rect(Point(y1, x1), Size(h, w)); - case UpLeft: - return Rect(Point(y2, x2), Size(h, w)); - case UpRight: - return Rect(Point(y2, x1), Size(h, w)); - } - return rect; - } - - Rect AxisAlignedItemCoordinateTransformer::VirtualRectToRealRect(Size realFullSize, Rect rect) - { - realFullSize=RealSizeToVirtualSize(realFullSize); - vint x1=rect.x1; - vint x2=realFullSize.x-rect.x2; - vint y1=rect.y1; - vint y2=realFullSize.y-rect.y2; - vint w=rect.Width(); - vint h=rect.Height(); - switch(alignment) - { - case LeftDown: - return Rect(Point(x2, y1), Size(w, h)); - case RightDown: - return Rect(Point(x1, y1), Size(w, h)); - case LeftUp: - return Rect(Point(x2, y2), Size(w, h)); - case RightUp: - return Rect(Point(x1, y2), Size(w, h)); - case DownLeft: - return Rect(Point(y2, x1), Size(h, w)); - case DownRight: - return Rect(Point(y1, x1), Size(h, w)); - case UpLeft: - return Rect(Point(y2, x2), Size(h, w)); - case UpRight: - return Rect(Point(y1, x2), Size(h, w)); - } - return rect; - } - - Margin AxisAlignedItemCoordinateTransformer::RealMarginToVirtualMargin(Margin margin) - { - vint x1=margin.left; - vint x2=margin.right; - vint y1=margin.top; - vint y2=margin.bottom; - switch(alignment) - { - case LeftDown: - return Margin(x2, y1, x1, y2); - case RightDown: - return Margin(x1, y1, x2, y2); - case LeftUp: - return Margin(x2, y2, x1, y1); - case RightUp: - return Margin(x1, y2, x2, y1); - case DownLeft: - return Margin(y1, x2, y2, x1); - case DownRight: - return Margin(y1, x1, y2, x2); - case UpLeft: - return Margin(y2, x2, y1, x1); - case UpRight: - return Margin(y2, x1, y1, x2); - } - return margin; - } - - Margin AxisAlignedItemCoordinateTransformer::VirtualMarginToRealMargin(Margin margin) - { - vint x1=margin.left; - vint x2=margin.right; - vint y1=margin.top; - vint y2=margin.bottom; - switch(alignment) - { - case LeftDown: - return Margin(x2, y1, x1, y2); - case RightDown: - return Margin(x1, y1, x2, y2); - case LeftUp: - return Margin(x2, y2, x1, y1); - case RightUp: - return Margin(x1, y2, x2, y1); - case DownLeft: - return Margin(y2, x1, y1, x2); - case DownRight: - return Margin(y1, x1, y2, x2); - case UpLeft: - return Margin(y2, x2, y1, x1); - case UpRight: - return Margin(y1, x2, y2, x1); - default:; - } - return margin; - } - - GuiListControl::KeyDirection AxisAlignedItemCoordinateTransformer::RealKeyDirectionToVirtualKeyDirection(GuiListControl::KeyDirection key) - { - bool pageKey=false; - switch(key) - { - case GuiListControl::PageUp: - pageKey=true; - key=GuiListControl::Up; - break; - case GuiListControl::PageDown: - pageKey=true; - key=GuiListControl::Down; - break; - case GuiListControl::PageLeft: - pageKey=true; - key=GuiListControl::Left; - break; - case GuiListControl::PageRight: - pageKey=true; - key=GuiListControl::Right; - break; - default:; - } - - switch(key) - { - case GuiListControl::Up: - switch(alignment) - { - case LeftDown: key=GuiListControl::Up; break; - case RightDown: key=GuiListControl::Up; break; - case LeftUp: key=GuiListControl::Down; break; - case RightUp: key=GuiListControl::Down; break; - case DownLeft: key=GuiListControl::Left; break; - case DownRight: key=GuiListControl::Left; break; - case UpLeft: key=GuiListControl::Right; break; - case UpRight: key=GuiListControl::Right; break; - } - break; - case GuiListControl::Down: - switch(alignment) - { - case LeftDown: key=GuiListControl::Down; break; - case RightDown: key=GuiListControl::Down; break; - case LeftUp: key=GuiListControl::Up; break; - case RightUp: key=GuiListControl::Up; break; - case DownLeft: key=GuiListControl::Right; break; - case DownRight: key=GuiListControl::Right; break; - case UpLeft: key=GuiListControl::Left; break; - case UpRight: key=GuiListControl::Left; break; - } - break; - case GuiListControl::Left: - switch(alignment) - { - case LeftDown: key=GuiListControl::Right; break; - case RightDown: key=GuiListControl::Left; break; - case LeftUp: key=GuiListControl::Right; break; - case RightUp: key=GuiListControl::Left; break; - case DownLeft: key=GuiListControl::Down; break; - case DownRight: key=GuiListControl::Up; break; - case UpLeft: key=GuiListControl::Down; break; - case UpRight: key=GuiListControl::Up; break; - } - break; - case GuiListControl::Right: - switch(alignment) - { - case LeftDown: key=GuiListControl::Left; break; - case RightDown: key=GuiListControl::Right; break; - case LeftUp: key=GuiListControl::Left; break; - case RightUp: key=GuiListControl::Right; break; - case DownLeft: key=GuiListControl::Up; break; - case DownRight: key=GuiListControl::Down; break; - case UpLeft: key=GuiListControl::Up; break; - case UpRight: key=GuiListControl::Down; break; - } - break; - case GuiListControl::Home: - switch(alignment) - { - case LeftDown: key=GuiListControl::Home; break; - case RightDown: key=GuiListControl::Home; break; - case LeftUp: key=GuiListControl::End; break; - case RightUp: key=GuiListControl::End; break; - case DownLeft: key=GuiListControl::Home; break; - case DownRight: key=GuiListControl::Home; break; - case UpLeft: key=GuiListControl::End; break; - case UpRight: key=GuiListControl::End; break; - } - break; - case GuiListControl::End: - switch(alignment) - { - case LeftDown: key=GuiListControl::End; break; - case RightDown: key=GuiListControl::End; break; - case LeftUp: key=GuiListControl::Home; break; - case RightUp: key=GuiListControl::Home; break; - case DownLeft: key=GuiListControl::End; break; - case DownRight: key=GuiListControl::End; break; - case UpLeft: key=GuiListControl::Home; break; - case UpRight: key=GuiListControl::Home; break; - } - break; - default:; - } - - if(pageKey) - { - switch(key) - { - case GuiListControl::Up: - key=GuiListControl::PageUp; - break; - case GuiListControl::Down: - key=GuiListControl::PageDown; - break; - case GuiListControl::Left: - key=GuiListControl::PageLeft; - break; - case GuiListControl::Right: - key=GuiListControl::PageRight; - break; - default:; - } - } - return key; - } - /*********************************************************************** RangedItemArrangerBase ***********************************************************************/ @@ -9723,7 +9366,7 @@ FixedHeightItemArranger { } - vint FixedHeightItemArranger::FindItem(vint itemIndex, GuiListControl::KeyDirection key) + vint FixedHeightItemArranger::FindItem(vint itemIndex, compositions::KeyDirection key) { vint count=itemProvider->Count(); if(count==0) return -1; @@ -9731,22 +9374,22 @@ FixedHeightItemArranger if(groupCount==0) groupCount=1; switch(key) { - case GuiListControl::Up: + case KeyDirection::Up: itemIndex--; break; - case GuiListControl::Down: + case KeyDirection::Down: itemIndex++; break; - case GuiListControl::Home: + case KeyDirection::Home: itemIndex=0; break; - case GuiListControl::End: + case KeyDirection::End: itemIndex=count; break; - case GuiListControl::PageUp: + case KeyDirection::PageUp: itemIndex-=groupCount; break; - case GuiListControl::PageDown: + case KeyDirection::PageDown: itemIndex+=groupCount; break; default: @@ -9949,7 +9592,7 @@ FixedSizeMultiColumnItemArranger { } - vint FixedSizeMultiColumnItemArranger::FindItem(vint itemIndex, GuiListControl::KeyDirection key) + vint FixedSizeMultiColumnItemArranger::FindItem(vint itemIndex, compositions::KeyDirection key) { vint count=itemProvider->Count(); vint columnCount=viewBounds.Width()/itemSize.x; @@ -9959,34 +9602,34 @@ FixedSizeMultiColumnItemArranger switch(key) { - case GuiListControl::Up: + case KeyDirection::Up: itemIndex-=columnCount; break; - case GuiListControl::Down: + case KeyDirection::Down: itemIndex+=columnCount; break; - case GuiListControl::Left: + case KeyDirection::Left: itemIndex--; break; - case GuiListControl::Right: + case KeyDirection::Right: itemIndex++; break; - case GuiListControl::Home: + case KeyDirection::Home: itemIndex=0; break; - case GuiListControl::End: + case KeyDirection::End: itemIndex=count; break; - case GuiListControl::PageUp: + case KeyDirection::PageUp: itemIndex-=columnCount*rowCount; break; - case GuiListControl::PageDown: + case KeyDirection::PageDown: itemIndex+=columnCount*rowCount; break; - case GuiListControl::PageLeft: + case KeyDirection::PageLeft: itemIndex-=itemIndex%columnCount; break; - case GuiListControl::PageRight: + case KeyDirection::PageRight: itemIndex+=columnCount-itemIndex%columnCount-1; break; default: @@ -10207,35 +9850,35 @@ FixedHeightMultiColumnItemArranger { } - vint FixedHeightMultiColumnItemArranger::FindItem(vint itemIndex, GuiListControl::KeyDirection key) + vint FixedHeightMultiColumnItemArranger::FindItem(vint itemIndex, compositions::KeyDirection key) { vint count=itemProvider->Count(); vint groupCount=viewBounds.Height()/itemHeight; if(groupCount==0) groupCount=1; switch(key) { - case GuiListControl::Up: + case KeyDirection::Up: itemIndex--; break; - case GuiListControl::Down: + case KeyDirection::Down: itemIndex++; break; - case GuiListControl::Left: + case KeyDirection::Left: itemIndex-=groupCount; break; - case GuiListControl::Right: + case KeyDirection::Right: itemIndex+=groupCount; break; - case GuiListControl::Home: + case KeyDirection::Home: itemIndex=0; break; - case GuiListControl::End: + case KeyDirection::End: itemIndex=count; break; - case GuiListControl::PageUp: + case KeyDirection::PageUp: itemIndex-=itemIndex%groupCount; break; - case GuiListControl::PageDown: + case KeyDirection::PageDown: itemIndex+=groupCount-itemIndex%groupCount-1; break; default: @@ -10820,9 +10463,9 @@ ListViewBigIconContentProvider { } - GuiListControl::IItemCoordinateTransformer* ListViewBigIconContentProvider::CreatePreferredCoordinateTransformer() + compositions::IGuiAxis* ListViewBigIconContentProvider::CreatePreferredAxis() { - return new DefaultItemCoordinateTransformer; + return new GuiDefaultAxis; } GuiListControl::IItemArranger* ListViewBigIconContentProvider::CreatePreferredArranger() @@ -10934,9 +10577,9 @@ ListViewSmallIconContentProvider { } - GuiListControl::IItemCoordinateTransformer* ListViewSmallIconContentProvider::CreatePreferredCoordinateTransformer() + compositions::IGuiAxis* ListViewSmallIconContentProvider::CreatePreferredAxis() { - return new DefaultItemCoordinateTransformer; + return new GuiDefaultAxis; } GuiListControl::IItemArranger* ListViewSmallIconContentProvider::CreatePreferredArranger() @@ -11047,9 +10690,9 @@ ListViewListContentProvider { } - GuiListControl::IItemCoordinateTransformer* ListViewListContentProvider::CreatePreferredCoordinateTransformer() + compositions::IGuiAxis* ListViewListContentProvider::CreatePreferredAxis() { - return new DefaultItemCoordinateTransformer; + return new GuiDefaultAxis; } GuiListControl::IItemArranger* ListViewListContentProvider::CreatePreferredArranger() @@ -11211,9 +10854,9 @@ ListViewTileContentProvider { } - GuiListControl::IItemCoordinateTransformer* ListViewTileContentProvider::CreatePreferredCoordinateTransformer() + compositions::IGuiAxis* ListViewTileContentProvider::CreatePreferredAxis() { - return new DefaultItemCoordinateTransformer; + return new GuiDefaultAxis; } GuiListControl::IItemArranger* ListViewTileContentProvider::CreatePreferredArranger() @@ -11401,9 +11044,9 @@ ListViewInformationContentProvider { } - GuiListControl::IItemCoordinateTransformer* ListViewInformationContentProvider::CreatePreferredCoordinateTransformer() + compositions::IGuiAxis* ListViewInformationContentProvider::CreatePreferredAxis() { - return new DefaultItemCoordinateTransformer; + return new GuiDefaultAxis; } GuiListControl::IItemArranger* ListViewInformationContentProvider::CreatePreferredArranger() @@ -11839,9 +11482,9 @@ ListViewDetailContentProvider { } - GuiListControl::IItemCoordinateTransformer* ListViewDetailContentProvider::CreatePreferredCoordinateTransformer() + compositions::IGuiAxis* ListViewDetailContentProvider::CreatePreferredAxis() { - return new DefaultItemCoordinateTransformer; + return new GuiDefaultAxis; } GuiListControl::IItemArranger* ListViewDetailContentProvider::CreatePreferredArranger() @@ -12309,7 +11952,7 @@ GuiListView { SetStyleProvider(0); SetArranger(0); - SetCoordinateTransformer(contentProvider->CreatePreferredCoordinateTransformer()); + SetAxis(contentProvider->CreatePreferredAxis()); SetStyleProvider(new list::ListViewItemStyleProvider(contentProvider)); SetArranger(contentProvider->CreatePreferredArranger()); return true; @@ -32252,6 +31895,377 @@ GuiToolstripButton } } +/*********************************************************************** +GRAPHICSCOMPOSITION\GUIGRAPHICSAXIS.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace compositions + { + +/*********************************************************************** +GuiDefaultAxis +***********************************************************************/ + + GuiDefaultAxis::GuiDefaultAxis() + { + } + + GuiDefaultAxis::~GuiDefaultAxis() + { + } + + Size GuiDefaultAxis::RealSizeToVirtualSize(Size size) + { + return size; + } + + Size GuiDefaultAxis::VirtualSizeToRealSize(Size size) + { + return size; + } + + Point GuiDefaultAxis::RealPointToVirtualPoint(Size realFullSize, Point point) + { + return point; + } + + Point GuiDefaultAxis::VirtualPointToRealPoint(Size realFullSize, Point point) + { + return point; + } + + Rect GuiDefaultAxis::RealRectToVirtualRect(Size realFullSize, Rect rect) + { + return rect; + } + + Rect GuiDefaultAxis::VirtualRectToRealRect(Size realFullSize, Rect rect) + { + return rect; + } + + Margin GuiDefaultAxis::RealMarginToVirtualMargin(Margin margin) + { + return margin; + } + + Margin GuiDefaultAxis::VirtualMarginToRealMargin(Margin margin) + { + return margin; + } + + KeyDirection GuiDefaultAxis::RealKeyDirectionToVirtualKeyDirection(KeyDirection key) + { + return key; + } + +/*********************************************************************** +GuiAxis +***********************************************************************/ + + GuiAxis::GuiAxis(AxisDirection _axisDirection) + :axisDirection(_axisDirection) + { + } + + GuiAxis::~GuiAxis() + { + } + + AxisDirection GuiAxis::GetAlignment() + { + return axisDirection; + } + + Size GuiAxis::RealSizeToVirtualSize(Size size) + { + switch(axisDirection) + { + case AxisDirection::LeftDown: + case AxisDirection::RightDown: + case AxisDirection::LeftUp: + case AxisDirection::RightUp: + return Size(size.x, size.y); + case AxisDirection::DownLeft: + case AxisDirection::DownRight: + case AxisDirection::UpLeft: + case AxisDirection::UpRight: + return Size(size.y, size.x); + } + return size; + } + + Size GuiAxis::VirtualSizeToRealSize(Size size) + { + return RealSizeToVirtualSize(size); + } + + Point GuiAxis::RealPointToVirtualPoint(Size realFullSize, Point point) + { + Rect rect(point, Size(0, 0)); + return RealRectToVirtualRect(realFullSize, rect).LeftTop(); + } + + Point GuiAxis::VirtualPointToRealPoint(Size realFullSize, Point point) + { + Rect rect(point, Size(0, 0)); + return VirtualRectToRealRect(realFullSize, rect).LeftTop(); + } + + Rect GuiAxis::RealRectToVirtualRect(Size realFullSize, Rect rect) + { + vint x1=rect.x1; + vint x2=realFullSize.x-rect.x2; + vint y1=rect.y1; + vint y2=realFullSize.y-rect.y2; + vint w=rect.Width(); + vint h=rect.Height(); + switch(axisDirection) + { + case AxisDirection::LeftDown: + return Rect(Point(x2, y1), Size(w, h)); + case AxisDirection::RightDown: + return Rect(Point(x1, y1), Size(w, h)); + case AxisDirection::LeftUp: + return Rect(Point(x2, y2), Size(w, h)); + case AxisDirection::RightUp: + return Rect(Point(x1, y2), Size(w, h)); + case AxisDirection::DownLeft: + return Rect(Point(y1, x2), Size(h, w)); + case AxisDirection::DownRight: + return Rect(Point(y1, x1), Size(h, w)); + case AxisDirection::UpLeft: + return Rect(Point(y2, x2), Size(h, w)); + case AxisDirection::UpRight: + return Rect(Point(y2, x1), Size(h, w)); + } + return rect; + } + + Rect GuiAxis::VirtualRectToRealRect(Size realFullSize, Rect rect) + { + realFullSize=RealSizeToVirtualSize(realFullSize); + vint x1=rect.x1; + vint x2=realFullSize.x-rect.x2; + vint y1=rect.y1; + vint y2=realFullSize.y-rect.y2; + vint w=rect.Width(); + vint h=rect.Height(); + switch(axisDirection) + { + case AxisDirection::LeftDown: + return Rect(Point(x2, y1), Size(w, h)); + case AxisDirection::RightDown: + return Rect(Point(x1, y1), Size(w, h)); + case AxisDirection::LeftUp: + return Rect(Point(x2, y2), Size(w, h)); + case AxisDirection::RightUp: + return Rect(Point(x1, y2), Size(w, h)); + case AxisDirection::DownLeft: + return Rect(Point(y2, x1), Size(h, w)); + case AxisDirection::DownRight: + return Rect(Point(y1, x1), Size(h, w)); + case AxisDirection::UpLeft: + return Rect(Point(y2, x2), Size(h, w)); + case AxisDirection::UpRight: + return Rect(Point(y1, x2), Size(h, w)); + } + return rect; + } + + Margin GuiAxis::RealMarginToVirtualMargin(Margin margin) + { + vint x1=margin.left; + vint x2=margin.right; + vint y1=margin.top; + vint y2=margin.bottom; + switch(axisDirection) + { + case AxisDirection::LeftDown: + return Margin(x2, y1, x1, y2); + case AxisDirection::RightDown: + return Margin(x1, y1, x2, y2); + case AxisDirection::LeftUp: + return Margin(x2, y2, x1, y1); + case AxisDirection::RightUp: + return Margin(x1, y2, x2, y1); + case AxisDirection::DownLeft: + return Margin(y1, x2, y2, x1); + case AxisDirection::DownRight: + return Margin(y1, x1, y2, x2); + case AxisDirection::UpLeft: + return Margin(y2, x2, y1, x1); + case AxisDirection::UpRight: + return Margin(y2, x1, y1, x2); + } + return margin; + } + + Margin GuiAxis::VirtualMarginToRealMargin(Margin margin) + { + vint x1=margin.left; + vint x2=margin.right; + vint y1=margin.top; + vint y2=margin.bottom; + switch(axisDirection) + { + case AxisDirection::LeftDown: + return Margin(x2, y1, x1, y2); + case AxisDirection::RightDown: + return Margin(x1, y1, x2, y2); + case AxisDirection::LeftUp: + return Margin(x2, y2, x1, y1); + case AxisDirection::RightUp: + return Margin(x1, y2, x2, y1); + case AxisDirection::DownLeft: + return Margin(y2, x1, y1, x2); + case AxisDirection::DownRight: + return Margin(y1, x1, y2, x2); + case AxisDirection::UpLeft: + return Margin(y2, x2, y1, x1); + case AxisDirection::UpRight: + return Margin(y1, x2, y2, x1); + default:; + } + return margin; + } + + KeyDirection GuiAxis::RealKeyDirectionToVirtualKeyDirection(KeyDirection key) + { + bool pageKey=false; + switch(key) + { + case KeyDirection::PageUp: + pageKey=true; + key=KeyDirection::Up; + break; + case KeyDirection::PageDown: + pageKey=true; + key=KeyDirection::Down; + break; + case KeyDirection::PageLeft: + pageKey=true; + key=KeyDirection::Left; + break; + case KeyDirection::PageRight: + pageKey=true; + key=KeyDirection::Right; + break; + default:; + } + + switch(key) + { + case KeyDirection::Up: + switch(axisDirection) + { + case AxisDirection::LeftDown: key=KeyDirection::Up; break; + case AxisDirection::RightDown: key=KeyDirection::Up; break; + case AxisDirection::LeftUp: key=KeyDirection::Down; break; + case AxisDirection::RightUp: key=KeyDirection::Down; break; + case AxisDirection::DownLeft: key=KeyDirection::Left; break; + case AxisDirection::DownRight: key=KeyDirection::Left; break; + case AxisDirection::UpLeft: key=KeyDirection::Right; break; + case AxisDirection::UpRight: key=KeyDirection::Right; break; + } + break; + case KeyDirection::Down: + switch(axisDirection) + { + case AxisDirection::LeftDown: key=KeyDirection::Down; break; + case AxisDirection::RightDown: key=KeyDirection::Down; break; + case AxisDirection::LeftUp: key=KeyDirection::Up; break; + case AxisDirection::RightUp: key=KeyDirection::Up; break; + case AxisDirection::DownLeft: key=KeyDirection::Right; break; + case AxisDirection::DownRight: key=KeyDirection::Right; break; + case AxisDirection::UpLeft: key=KeyDirection::Left; break; + case AxisDirection::UpRight: key=KeyDirection::Left; break; + } + break; + case KeyDirection::Left: + switch(axisDirection) + { + case AxisDirection::LeftDown: key=KeyDirection::Right; break; + case AxisDirection::RightDown: key=KeyDirection::Left; break; + case AxisDirection::LeftUp: key=KeyDirection::Right; break; + case AxisDirection::RightUp: key=KeyDirection::Left; break; + case AxisDirection::DownLeft: key=KeyDirection::Down; break; + case AxisDirection::DownRight: key=KeyDirection::Up; break; + case AxisDirection::UpLeft: key=KeyDirection::Down; break; + case AxisDirection::UpRight: key=KeyDirection::Up; break; + } + break; + case KeyDirection::Right: + switch(axisDirection) + { + case AxisDirection::LeftDown: key=KeyDirection::Left; break; + case AxisDirection::RightDown: key=KeyDirection::Right; break; + case AxisDirection::LeftUp: key=KeyDirection::Left; break; + case AxisDirection::RightUp: key=KeyDirection::Right; break; + case AxisDirection::DownLeft: key=KeyDirection::Up; break; + case AxisDirection::DownRight: key=KeyDirection::Down; break; + case AxisDirection::UpLeft: key=KeyDirection::Up; break; + case AxisDirection::UpRight: key=KeyDirection::Down; break; + } + break; + case KeyDirection::Home: + switch(axisDirection) + { + case AxisDirection::LeftDown: key=KeyDirection::Home; break; + case AxisDirection::RightDown: key=KeyDirection::Home; break; + case AxisDirection::LeftUp: key=KeyDirection::End; break; + case AxisDirection::RightUp: key=KeyDirection::End; break; + case AxisDirection::DownLeft: key=KeyDirection::Home; break; + case AxisDirection::DownRight: key=KeyDirection::Home; break; + case AxisDirection::UpLeft: key=KeyDirection::End; break; + case AxisDirection::UpRight: key=KeyDirection::End; break; + } + break; + case KeyDirection::End: + switch(axisDirection) + { + case AxisDirection::LeftDown: key=KeyDirection::End; break; + case AxisDirection::RightDown: key=KeyDirection::End; break; + case AxisDirection::LeftUp: key=KeyDirection::Home; break; + case AxisDirection::RightUp: key=KeyDirection::Home; break; + case AxisDirection::DownLeft: key=KeyDirection::End; break; + case AxisDirection::DownRight: key=KeyDirection::End; break; + case AxisDirection::UpLeft: key=KeyDirection::Home; break; + case AxisDirection::UpRight: key=KeyDirection::Home; break; + } + break; + default:; + } + + if(pageKey) + { + switch(key) + { + case KeyDirection::Up: + key=KeyDirection::PageUp; + break; + case KeyDirection::Down: + key=KeyDirection::PageDown; + break; + case KeyDirection::Left: + key=KeyDirection::PageLeft; + break; + case KeyDirection::Right: + key=KeyDirection::PageRight; + break; + default:; + } + } + return key; + } + } + } +} + /*********************************************************************** GRAPHICSCOMPOSITION\GUIGRAPHICSBASICCOMPOSITION.CPP ***********************************************************************/ @@ -33282,6 +33296,384 @@ Event Receiver } } +/*********************************************************************** +GRAPHICSCOMPOSITION\GUIGRAPHICSFLOWCOMPOSITION.CPP +***********************************************************************/ + +namespace vl +{ + namespace presentation + { + namespace compositions + { + using namespace collections; + +/*********************************************************************** +GuiFlowComposition +***********************************************************************/ + + void GuiFlowComposition::UpdateFlowItemBounds(bool forceUpdate) + { + if (forceUpdate || needUpdate) + { + needUpdate = false; + auto clientMargin = axis->RealMarginToVirtualMargin(extraMargin); + if (clientMargin.left < 0) clientMargin.left = 0; + if (clientMargin.top < 0) clientMargin.top = 0; + if (clientMargin.right < 0) clientMargin.right = 0; + if (clientMargin.bottom < 0) clientMargin.bottom = 0; + + auto realFullSize = previousBounds.GetSize(); + auto clientSize = axis->RealSizeToVirtualSize(realFullSize); + clientSize.x -= (clientMargin.left + clientMargin.right); + clientSize.y -= (clientMargin.top + clientMargin.bottom); + + flowItemBounds.Resize(flowItems.Count()); + for (vint i = 0; i < flowItems.Count(); i++) + { + flowItemBounds[i] = Rect(Point(0, 0), flowItems[i]->GetMinSize()); + } + + vint currentIndex = 0; + vint rowTop = 0; + + while (currentIndex < flowItems.Count()) + { + auto itemSize = axis->RealSizeToVirtualSize(flowItemBounds[currentIndex].GetSize()); + vint rowWidth = itemSize.x; + vint rowHeight = itemSize.y; + vint rowItemCount = 1; + + for (vint i = currentIndex + 1; i < flowItems.Count(); i++) + { + itemSize = axis->RealSizeToVirtualSize(flowItemBounds[i].GetSize()); + vint itemWidth = itemSize.x + columnPadding; + if (rowWidth + itemWidth > clientSize.x) + { + break; + } + rowWidth += itemWidth; + if (rowHeight < itemSize.y) + { + rowHeight = itemSize.y; + } + rowItemCount++; + } + + vint baseLine = 0; + Array itemBaseLines(rowItemCount); + for (vint i = 0; i < rowItemCount; i++) + { + vint index = currentIndex + i; + vint itemBaseLine = 0; + itemSize = axis->RealSizeToVirtualSize(flowItemBounds[index].GetSize()); + + auto option = flowItems[index]->GetFlowOption(); + switch (option.baseline) + { + case GuiFlowOption::FromTop: + itemBaseLine = option.distance; + break; + case GuiFlowOption::FromBottom: + itemBaseLine = itemSize.y - option.distance; + break; + case GuiFlowOption::Percentage: + itemBaseLine = (vint)(itemSize.y*option.percentage); + break; + } + + itemBaseLines[i] = itemBaseLine; + if (baseLine < itemBaseLine) + { + baseLine = itemBaseLine; + } + } + + vint rowUsedWidth = 0; + for (vint i = 0; i < rowItemCount; i++) + { + vint index = currentIndex + i; + itemSize = axis->RealSizeToVirtualSize(flowItemBounds[index].GetSize()); + + vint itemLeft = 0; + vint itemTop = rowTop + baseLine - itemBaseLines[i]; + + switch (alignment) + { + case FlowAlignment::Left: + itemLeft = rowUsedWidth + i * columnPadding; + break; + case FlowAlignment::Center: + itemLeft = rowUsedWidth + i * columnPadding + (clientSize.x - rowWidth) / 2; + break; + case FlowAlignment::Extend: + if (i == 0) + { + itemLeft = rowUsedWidth; + } + else + { + itemLeft = rowUsedWidth + (vint)((double)(clientSize.x - rowWidth) * i / (rowItemCount - 1)) + i * columnPadding; + } + break; + } + + flowItemBounds[index] = axis->VirtualRectToRealRect( + realFullSize, + Rect( + Point( + itemLeft + clientMargin.left, + itemTop + clientMargin.top + ), + itemSize + ) + ); + rowUsedWidth += itemSize.x; + } + + rowTop += rowHeight + rowPadding; + currentIndex += rowItemCount; + } + + minHeight = rowTop == 0 ? 0 : rowTop - rowPadding; + } + } + + void GuiFlowComposition::OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments) + { + UpdateFlowItemBounds(true); + } + + void GuiFlowComposition::OnChildInserted(GuiGraphicsComposition* child) + { + GuiBoundsComposition::OnChildInserted(child); + auto item = dynamic_cast(child); + if (item && !flowItems.Contains(item)) + { + flowItems.Add(item); + needUpdate = true; + } + } + + void GuiFlowComposition::OnChildRemoved(GuiGraphicsComposition* child) + { + GuiBoundsComposition::OnChildRemoved(child); + auto item=dynamic_cast(child); + if(item) + { + flowItems.Remove(item); + needUpdate = true; + } + } + + GuiFlowComposition::GuiFlowComposition() + :axis(new GuiDefaultAxis) + { + BoundsChanged.AttachMethod(this, &GuiFlowComposition::OnBoundsChanged); + } + + GuiFlowComposition::~GuiFlowComposition() + { + } + + const GuiFlowComposition::ItemCompositionList& GuiFlowComposition::GetFlowItems() + { + return flowItems; + } + + Margin GuiFlowComposition::GetExtraMargin() + { + return extraMargin; + } + + void GuiFlowComposition::SetExtraMargin(Margin value) + { + extraMargin = value; + needUpdate = true; + } + + vint GuiFlowComposition::GetRowPadding() + { + return rowPadding; + } + + void GuiFlowComposition::SetRowPadding(vint value) + { + rowPadding = value; + needUpdate = true; + } + + vint GuiFlowComposition::GetColumnPadding() + { + return columnPadding; + } + + void GuiFlowComposition::SetColumnPadding(vint value) + { + columnPadding = value; + needUpdate = true; + } + + Ptr GuiFlowComposition::GetAxis() + { + return axis; + } + + void GuiFlowComposition::SetAxis(Ptr value) + { + if (value) + { + axis = value; + needUpdate = true; + } + } + + FlowAlignment GuiFlowComposition::GetAlignment() + { + return alignment; + } + + void GuiFlowComposition::SetAlignment(FlowAlignment value) + { + alignment = value; + needUpdate = true; + } + + Size GuiFlowComposition::GetMinPreferredClientSize() + { + Size minSize = GuiBoundsComposition::GetMinPreferredClientSize(); + if (GetMinSizeLimitation() == GuiGraphicsComposition::LimitToElementAndChildren) + { + auto clientMargin = extraMargin; + if (clientMargin.left < 0) clientMargin.left = 0; + if (clientMargin.top < 0) clientMargin.top = 0; + if (clientMargin.right < 0) clientMargin.right = 0; + if (clientMargin.bottom < 0) clientMargin.bottom = 0; + + auto clientSize = axis->VirtualSizeToRealSize(Size(0, minHeight)); + clientSize.x += clientMargin.left + clientMargin.right; + clientSize.y += clientMargin.top + clientMargin.bottom; + + if (minSize.x < clientSize.x) minSize.x = clientSize.x; + if (minSize.y < clientSize.y) minSize.y = clientSize.y; + } + + vint x = 0; + vint y = 0; + if (extraMargin.left > 0) x += extraMargin.left; + if (extraMargin.right > 0) x += extraMargin.right; + if (extraMargin.top > 0) y += extraMargin.top; + if (extraMargin.bottom > 0) y += extraMargin.bottom; + return minSize + Size(x, y); + } + + Rect GuiFlowComposition::GetBounds() + { + if (!needUpdate) + { + for (vint i = 0; i < flowItems.Count(); i++) + { + if (flowItemBounds[i].GetSize() != flowItems[i]->GetMinSize()) + { + needUpdate = true; + break; + } + } + } + + if (needUpdate) + { + UpdateFlowItemBounds(true); + } + + bounds = GuiBoundsComposition::GetBounds(); + return bounds; + } + +/*********************************************************************** +GuiFlowItemComposition +***********************************************************************/ + + void GuiFlowItemComposition::OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent) + { + GuiGraphicsSite::OnParentChanged(oldParent, newParent); + flowParent = newParent == 0 ? 0 : dynamic_cast(newParent); + } + + Size GuiFlowItemComposition::GetMinSize() + { + return GetBoundsInternal(bounds).GetSize(); + } + + GuiFlowItemComposition::GuiFlowItemComposition() + { + SetMinSizeLimitation(GuiGraphicsComposition::LimitToElementAndChildren); + } + + GuiFlowItemComposition::~GuiFlowItemComposition() + { + } + + bool GuiFlowItemComposition::IsSizeAffectParent() + { + return false; + } + + Rect GuiFlowItemComposition::GetBounds() + { + Rect result = bounds; + if(flowParent) + { + flowParent->UpdateFlowItemBounds(false); + vint index = flowParent->flowItems.IndexOf(this); + if (index != -1) + { + result = flowParent->flowItemBounds[index]; + } + + result = Rect( + result.Left() - extraMargin.left, + result.Top() - extraMargin.top, + result.Right() + extraMargin.right, + result.Bottom() + extraMargin.bottom + ); + } + UpdatePreviousBounds(result); + return result; + } + + void GuiFlowItemComposition::SetBounds(Rect value) + { + bounds = value; + } + + Margin GuiFlowItemComposition::GetExtraMargin() + { + return extraMargin; + } + + void GuiFlowItemComposition::SetExtraMargin(Margin value) + { + extraMargin = value; + } + + GuiFlowOption GuiFlowItemComposition::GetFlowOption() + { + return option; + } + + void GuiFlowItemComposition::SetFlowOption(GuiFlowOption value) + { + option = value; + if (flowParent) + { + flowParent->needUpdate = true; + } + } + } + } +} + /*********************************************************************** GRAPHICSCOMPOSITION\GUIGRAPHICSSPECIALIZEDCOMPOSITION.CPP ***********************************************************************/ @@ -33579,7 +33971,7 @@ GuiStackComposition void GuiStackComposition::OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments) { - UpdateStackItemBounds(); + EnsureStackItemVisible(); } void GuiStackComposition::OnChildInserted(GuiGraphicsComposition* child) @@ -33655,12 +34047,12 @@ GuiStackComposition void GuiStackComposition::SetPadding(vint value) { padding = value; + EnsureStackItemVisible(); } Size GuiStackComposition::GetMinPreferredClientSize() { Size minSize = GuiBoundsComposition::GetMinPreferredClientSize(); - UpdateStackItemBounds(); if (GetMinSizeLimitation() == GuiGraphicsComposition::LimitToElementAndChildren) { if (!ensuringVisibleStackItem || direction == Vertical || direction == ReversedVertical) @@ -33690,9 +34082,18 @@ GuiStackComposition Rect GuiStackComposition::GetBounds() { + for (vint i = 0; i < stackItems.Count(); i++) + { + if (stackItemBounds[i].GetSize() != stackItems[i]->GetMinSize()) + { + UpdateStackItemBounds(); + break; + } + } + Rect bounds = GuiBoundsComposition::GetBounds(); previousBounds = bounds; - EnsureStackItemVisible(); + UpdatePreviousBounds(previousBounds); return bounds; } @@ -33704,6 +34105,7 @@ GuiStackComposition void GuiStackComposition::SetExtraMargin(Margin value) { extraMargin=value; + EnsureStackItemVisible(); } bool GuiStackComposition::IsStackItemClipped() diff --git a/Import/GacUI.h b/Import/GacUI.h index 007be29f..0dad1677 100644 --- a/Import/GacUI.h +++ b/Import/GacUI.h @@ -62,6 +62,27 @@ Enumerations Bottom=2, }; + /// Axis direction. + enum class AxisDirection + { + /// X:left, Y:down. + LeftDown, + /// X:right, Y:down. + RightDown, + /// X:left, Y:up. + LeftUp, + /// X:right, Y:up. + RightUp, + /// X:down, Y:left. + DownLeft, + /// X:down, Y:right. + DownRight, + /// X:up, Y:left. + UpLeft, + /// X:up, Y:right. + UpRight, + }; + /*********************************************************************** TextPos ***********************************************************************/ @@ -6800,6 +6821,278 @@ Stack Compositions #endif +/*********************************************************************** +GRAPHICSCOMPOSITION\GUIGRAPHICSAXIS.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Composition System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSAXIS +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSAXIS + + +namespace vl +{ + namespace presentation + { + namespace compositions + { + +/*********************************************************************** +Axis Interface +***********************************************************************/ + + /// Represents the four directions that is accessable by keyboard. + enum class KeyDirection + { + /// The up direction. + Up, + /// The down direction. + Down, + /// The left direction. + Left, + /// The right direction. + Right, + /// The home direction. + Home, + /// The end direction. + End, + /// The page up direction. + PageUp, + /// The page down direction. + PageDown, + /// The page left direction. + PageLeft, + /// The page right direction. + PageRight, + }; + + /// Item coordinate transformer for a . In all functions in this interface, real coordinate is in the list control's container space, virtual coordinate is in a space that the transformer created. + class IGuiAxis : public virtual IDescriptable, public Description + { + public: + /// Translate real size to virtual size. + /// The virtual size. + /// The real size. + virtual Size RealSizeToVirtualSize(Size size)=0; + /// Translate virtual size to real size. + /// The real size. + /// The virtual size. + virtual Size VirtualSizeToRealSize(Size size)=0; + /// Translate real point to virtual point. + /// The virtual point. + /// The real full size. + /// The real point. + virtual Point RealPointToVirtualPoint(Size realFullSize, Point point)=0; + /// Translate virtual point to real point. + /// The real point. + /// The real full size. + /// The virtual point. + virtual Point VirtualPointToRealPoint(Size realFullSize, Point point)=0; + /// Translate real bounds to virtual bounds. + /// The virtual bounds. + /// The real full size. + /// The real bounds. + virtual Rect RealRectToVirtualRect(Size realFullSize, Rect rect)=0; + /// Translate virtual bounds to real bounds. + /// The real bounds. + /// The real full size. + /// The virtual bounds. + virtual Rect VirtualRectToRealRect(Size realFullSize, Rect rect)=0; + /// Translate real margin to margin size. + /// The virtual margin. + /// The real margin. + virtual Margin RealMarginToVirtualMargin(Margin margin)=0; + /// Translate virtual margin to margin size. + /// The real margin. + /// The virtual margin. + virtual Margin VirtualMarginToRealMargin(Margin margin)=0; + /// Translate real key direction to virtual key direction. + /// The virtual key direction. + /// The real key direction. + virtual KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)=0; + }; + +/*********************************************************************** +Axis Implementation +***********************************************************************/ + + /// Default item coordinate transformer. This transformer doesn't transform any coordinate. + class GuiDefaultAxis : public Object, virtual public IGuiAxis, public Description + { + public: + /// Create the transformer. + GuiDefaultAxis(); + ~GuiDefaultAxis(); + + Size RealSizeToVirtualSize(Size size)override; + Size VirtualSizeToRealSize(Size size)override; + Point RealPointToVirtualPoint(Size realFullSize, Point point)override; + Point VirtualPointToRealPoint(Size realFullSize, Point point)override; + Rect RealRectToVirtualRect(Size realFullSize, Rect rect)override; + Rect VirtualRectToRealRect(Size realFullSize, Rect rect)override; + Margin RealMarginToVirtualMargin(Margin margin)override; + Margin VirtualMarginToRealMargin(Margin margin)override; + KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)override; + }; + + /// Axis aligned item coordinate transformer. This transformer transforms coordinates by changing the axis direction. + class GuiAxis : public Object, virtual public IGuiAxis, public Description + { + protected: + AxisDirection axisDirection; + + public: + /// Create the transformer with a specified axis direction. + /// The specified axis direction. + GuiAxis(AxisDirection _axisDirection); + ~GuiAxis(); + + /// Get the specified axis direction. + /// The specified axis direction. + AxisDirection GetAlignment(); + Size RealSizeToVirtualSize(Size size)override; + Size VirtualSizeToRealSize(Size size)override; + Point RealPointToVirtualPoint(Size realFullSize, Point point)override; + Point VirtualPointToRealPoint(Size realFullSize, Point point)override; + Rect RealRectToVirtualRect(Size realFullSize, Rect rect)override; + Rect VirtualRectToRealRect(Size realFullSize, Rect rect)override; + Margin RealMarginToVirtualMargin(Margin margin)override; + Margin VirtualMarginToRealMargin(Margin margin)override; + KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)override; + }; + } + } +} + +#endif + +/*********************************************************************** +GRAPHICSCOMPOSITION\GUIGRAPHICSFLOWCOMPOSITION.H +***********************************************************************/ +/*********************************************************************** +Vczh Library++ 3.0 +Developer: Zihan Chen(vczh) +GacUI::Composition System + +Interfaces: +***********************************************************************/ + +#ifndef VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSFLOWCOMPOSITION +#define VCZH_PRESENTATION_ELEMENTS_GUIGRAPHICSFLOWCOMPOSITION + + +namespace vl +{ + namespace presentation + { + namespace compositions + { + +/*********************************************************************** +Flow Compositions +***********************************************************************/ + + enum class FlowAlignment + { + Left, + Center, + Extend, + }; + + class GuiFlowComposition : public GuiBoundsComposition, public Description + { + friend class GuiFlowItemComposition; + + typedef collections::List ItemCompositionList; + protected: + Margin extraMargin; + vint rowPadding = 0; + vint columnPadding = 0; + FlowAlignment alignment = FlowAlignment::Left; + Ptr axis; + + ItemCompositionList flowItems; + collections::Array flowItemBounds; + Rect bounds; + vint minHeight = 0; + bool needUpdate = false; + + void UpdateFlowItemBounds(bool forceUpdate); + void OnBoundsChanged(GuiGraphicsComposition* sender, GuiEventArgs& arguments); + void OnChildInserted(GuiGraphicsComposition* child)override; + void OnChildRemoved(GuiGraphicsComposition* child)override; + public: + GuiFlowComposition(); + ~GuiFlowComposition(); + + const ItemCompositionList& GetFlowItems(); + + Margin GetExtraMargin(); + void SetExtraMargin(Margin value); + vint GetRowPadding(); + void SetRowPadding(vint value); + vint GetColumnPadding(); + void SetColumnPadding(vint value); + Ptr GetAxis(); + void SetAxis(Ptr value); + FlowAlignment GetAlignment(); + void SetAlignment(FlowAlignment value); + + Size GetMinPreferredClientSize()override; + Rect GetBounds()override; + }; + + struct GuiFlowOption + { + enum BaselineType + { + Percentage, + FromTop, + FromBottom, + }; + + BaselineType baseline = FromBottom; + double percentage = 0.0; + vint distance = 0; + }; + + class GuiFlowItemComposition : public GuiGraphicsSite, public Description + { + friend class GuiFlowComposition; + protected: + GuiFlowComposition* flowParent; + Rect bounds; + Margin extraMargin; + GuiFlowOption option; + + void OnParentChanged(GuiGraphicsComposition* oldParent, GuiGraphicsComposition* newParent)override; + Size GetMinSize(); + public: + GuiFlowItemComposition(); + ~GuiFlowItemComposition(); + + bool IsSizeAffectParent()override; + Rect GetBounds()override; + void SetBounds(Rect value); + + Margin GetExtraMargin(); + void SetExtraMargin(Margin value); + + GuiFlowOption GetFlowOption(); + void SetFlowOption(GuiFlowOption value); + }; + } + } +} + +#endif + /*********************************************************************** GRAPHICSCOMPOSITION\GUIGRAPHICSSPECIALIZEDCOMPOSITION.H ***********************************************************************/ @@ -9845,31 +10138,6 @@ List Control // Provider Interfaces //----------------------------------------------------------- - /// Represents the four directions that is accessable by keyboard. - enum KeyDirection - { - /// The up direction. - Up, - /// The down direction. - Down, - /// The left direction. - Left, - /// The right direction. - Right, - /// The home direction. - Home, - /// The end direction. - End, - /// The page up direction. - PageUp, - /// The page down direction. - PageDown, - /// The page left direction. - PageLeft, - /// The page right direction. - PageRight, - }; - /// Item provider for a . class IItemProvider : public virtual IDescriptable, public Description { @@ -9982,58 +10250,12 @@ List Control /// The item index that is found. Returns -1 if this operation failed. /// The base item index. /// The key direction. - virtual vint FindItem(vint itemIndex, KeyDirection key)=0; + virtual vint FindItem(vint itemIndex, compositions::KeyDirection key)=0; /// Adjust the view location to make an item visible. /// Returns true if this operation succeeded. /// The item index of the item to be made visible. virtual bool EnsureItemVisible(vint itemIndex)=0; }; - - /// Item coordinate transformer for a . In all functions in this interface, real coordinate is in the list control's container space, virtual coordinate is in a space that the transformer created. - class IItemCoordinateTransformer : public virtual IDescriptable, public Description - { - public: - /// Translate real size to virtual size. - /// The virtual size. - /// The real size. - virtual Size RealSizeToVirtualSize(Size size)=0; - /// Translate virtual size to real size. - /// The real size. - /// The virtual size. - virtual Size VirtualSizeToRealSize(Size size)=0; - /// Translate real point to virtual point. - /// The virtual point. - /// The real full size. - /// The real point. - virtual Point RealPointToVirtualPoint(Size realFullSize, Point point)=0; - /// Translate virtual point to real point. - /// The real point. - /// The real full size. - /// The virtual point. - virtual Point VirtualPointToRealPoint(Size realFullSize, Point point)=0; - /// Translate real bounds to virtual bounds. - /// The virtual bounds. - /// The real full size. - /// The real bounds. - virtual Rect RealRectToVirtualRect(Size realFullSize, Rect rect)=0; - /// Translate virtual bounds to real bounds. - /// The real bounds. - /// The real full size. - /// The virtual bounds. - virtual Rect VirtualRectToRealRect(Size realFullSize, Rect rect)=0; - /// Translate real margin to margin size. - /// The virtual margin. - /// The real margin. - virtual Margin RealMarginToVirtualMargin(Margin margin)=0; - /// Translate virtual margin to margin size. - /// The real margin. - /// The virtual margin. - virtual Margin VirtualMarginToRealMargin(Margin margin)=0; - /// Translate real key direction to virtual key direction. - /// The virtual key direction. - /// The real key direction. - virtual KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)=0; - }; protected: @@ -10077,7 +10299,7 @@ List Control Ptr itemProvider; Ptr itemStyleProvider; Ptr itemArranger; - Ptr itemCoordinateTransformer; + Ptr axis; Size fullSize; virtual void OnItemModified(vint start, vint count, vint newCount); @@ -10133,7 +10355,7 @@ List Control /// Arranger changed event. compositions::GuiNotifyEvent ArrangerChanged; /// Coordinate transformer changed event. - compositions::GuiNotifyEvent CoordinateTransformerChanged; + compositions::GuiNotifyEvent AxisChanged; /// Item left mouse button down event. compositions::GuiItemMouseEvent ItemLeftButtonDown; @@ -10179,11 +10401,11 @@ List Control virtual Ptr SetArranger(Ptr value); /// Get the item coordinate transformer. /// The item coordinate transformer. - virtual IItemCoordinateTransformer* GetCoordinateTransformer(); + virtual compositions::IGuiAxis* GetAxis(); /// Set the item coordinate transformer /// The old item coordinate transformer /// The new item coordinate transformer - virtual Ptr SetCoordinateTransformer(Ptr value); + virtual Ptr SetAxis(Ptr value); /// Adjust the view location to make an item visible. /// Returns true if this operation succeeded. /// The item index of the item to be made visible. @@ -10280,79 +10502,6 @@ Selectable List Control void ClearSelection(); }; -/*********************************************************************** -Predefined ItemCoordinateTransformer -***********************************************************************/ - - namespace list - { - /// Default item coordinate transformer. This transformer doesn't transform any coordinate. - class DefaultItemCoordinateTransformer : public Object, virtual public GuiListControl::IItemCoordinateTransformer, public Description - { - public: - /// Create the transformer. - DefaultItemCoordinateTransformer(); - ~DefaultItemCoordinateTransformer(); - - Size RealSizeToVirtualSize(Size size)override; - Size VirtualSizeToRealSize(Size size)override; - Point RealPointToVirtualPoint(Size realFullSize, Point point)override; - Point VirtualPointToRealPoint(Size realFullSize, Point point)override; - Rect RealRectToVirtualRect(Size realFullSize, Rect rect)override; - Rect VirtualRectToRealRect(Size realFullSize, Rect rect)override; - Margin RealMarginToVirtualMargin(Margin margin)override; - Margin VirtualMarginToRealMargin(Margin margin)override; - GuiListControl::KeyDirection RealKeyDirectionToVirtualKeyDirection(GuiListControl::KeyDirection key)override; - }; - - /// Axis aligned item coordinate transformer. This transformer transforms coordinates by changing the axis direction. - class AxisAlignedItemCoordinateTransformer : public Object, virtual public GuiListControl::IItemCoordinateTransformer, public Description - { - public: - /// Axis direction. - enum Alignment - { - /// X:left, Y:down. - LeftDown, - /// X:right, Y:down. - RightDown, - /// X:left, Y:up. - LeftUp, - /// X:right, Y:up. - RightUp, - /// X:down, Y:left. - DownLeft, - /// X:down, Y:right. - DownRight, - /// X:up, Y:left. - UpLeft, - /// X:up, Y:right. - UpRight, - }; - protected: - Alignment alignment; - - public: - /// Create the transformer with a specified axis direction. - /// The specified axis direction. - AxisAlignedItemCoordinateTransformer(Alignment _alignment); - ~AxisAlignedItemCoordinateTransformer(); - - /// Get the specified axis direction. - /// The specified axis direction. - Alignment GetAlignment(); - Size RealSizeToVirtualSize(Size size)override; - Size VirtualSizeToRealSize(Size size)override; - Point RealPointToVirtualPoint(Size realFullSize, Point point)override; - Point VirtualPointToRealPoint(Size realFullSize, Point point)override; - Rect RealRectToVirtualRect(Size realFullSize, Rect rect)override; - Rect VirtualRectToRealRect(Size realFullSize, Rect rect)override; - Margin RealMarginToVirtualMargin(Margin margin)override; - Margin VirtualMarginToRealMargin(Margin margin)override; - GuiListControl::KeyDirection RealKeyDirectionToVirtualKeyDirection(GuiListControl::KeyDirection key)override; - }; - }; - /*********************************************************************** Predefined ItemArranger ***********************************************************************/ @@ -10410,7 +10559,7 @@ Predefined ItemArranger FixedHeightItemArranger(); ~FixedHeightItemArranger(); - vint FindItem(vint itemIndex, GuiListControl::KeyDirection key)override; + vint FindItem(vint itemIndex, compositions::KeyDirection key)override; bool EnsureItemVisible(vint itemIndex)override; }; @@ -10431,7 +10580,7 @@ Predefined ItemArranger FixedSizeMultiColumnItemArranger(); ~FixedSizeMultiColumnItemArranger(); - vint FindItem(vint itemIndex, GuiListControl::KeyDirection key)override; + vint FindItem(vint itemIndex, compositions::KeyDirection key)override; bool EnsureItemVisible(vint itemIndex)override; }; @@ -10452,7 +10601,7 @@ Predefined ItemArranger FixedHeightMultiColumnItemArranger(); ~FixedHeightMultiColumnItemArranger(); - vint FindItem(vint itemIndex, GuiListControl::KeyDirection key)override; + vint FindItem(vint itemIndex, compositions::KeyDirection key)override; bool EnsureItemVisible(vint itemIndex)override; }; } @@ -11270,7 +11419,7 @@ ListView ItemStyleProvider public: /// Create a default and preferred for the related item style provider. /// The created item coordinate transformer. - virtual GuiListControl::IItemCoordinateTransformer* CreatePreferredCoordinateTransformer()=0; + virtual compositions::IGuiAxis* CreatePreferredAxis()=0; /// Create a default and preferred for the related item style provider. /// The created item coordinate arranger. virtual GuiListControl::IItemArranger* CreatePreferredArranger()=0; @@ -11393,7 +11542,7 @@ ListView ItemContentProvider ListViewBigIconContentProvider(Size _minIconSize=Size(32, 32), bool _fitImage=true); ~ListViewBigIconContentProvider(); - GuiListControl::IItemCoordinateTransformer* CreatePreferredCoordinateTransformer()override; + compositions::IGuiAxis* CreatePreferredAxis()override; GuiListControl::IItemArranger* CreatePreferredArranger()override; ListViewItemStyleProvider::IListViewItemContent* CreateItemContent(const FontProperties& font)override; void AttachListControl(GuiListControl* value)override; @@ -11430,7 +11579,7 @@ ListView ItemContentProvider ListViewSmallIconContentProvider(Size _minIconSize=Size(16, 16), bool _fitImage=true); ~ListViewSmallIconContentProvider(); - GuiListControl::IItemCoordinateTransformer* CreatePreferredCoordinateTransformer()override; + compositions::IGuiAxis* CreatePreferredAxis()override; GuiListControl::IItemArranger* CreatePreferredArranger()override; ListViewItemStyleProvider::IListViewItemContent* CreateItemContent(const FontProperties& font)override; void AttachListControl(GuiListControl* value)override; @@ -11467,7 +11616,7 @@ ListView ItemContentProvider ListViewListContentProvider(Size _minIconSize=Size(16, 16), bool _fitImage=true); ~ListViewListContentProvider(); - GuiListControl::IItemCoordinateTransformer* CreatePreferredCoordinateTransformer()override; + compositions::IGuiAxis* CreatePreferredAxis()override; GuiListControl::IItemArranger* CreatePreferredArranger()override; ListViewItemStyleProvider::IListViewItemContent* CreateItemContent(const FontProperties& font)override; void AttachListControl(GuiListControl* value)override; @@ -11510,7 +11659,7 @@ ListView ItemContentProvider ListViewTileContentProvider(Size _minIconSize=Size(32, 32), bool _fitImage=true); ~ListViewTileContentProvider(); - GuiListControl::IItemCoordinateTransformer* CreatePreferredCoordinateTransformer()override; + compositions::IGuiAxis* CreatePreferredAxis()override; GuiListControl::IItemArranger* CreatePreferredArranger()override; ListViewItemStyleProvider::IListViewItemContent* CreateItemContent(const FontProperties& font)override; void AttachListControl(GuiListControl* value)override; @@ -11554,7 +11703,7 @@ ListView ItemContentProvider ListViewInformationContentProvider(Size _minIconSize=Size(32, 32), bool _fitImage=true); ~ListViewInformationContentProvider(); - GuiListControl::IItemCoordinateTransformer* CreatePreferredCoordinateTransformer()override; + compositions::IGuiAxis* CreatePreferredAxis()override; GuiListControl::IItemArranger* CreatePreferredArranger()override; ListViewItemStyleProvider::IListViewItemContent* CreateItemContent(const FontProperties& font)override; void AttachListControl(GuiListControl* value)override; @@ -11708,7 +11857,7 @@ ListView ItemContentProvider(Detailed) ListViewDetailContentProvider(Size _minIconSize=Size(16, 16), bool _fitImage=true); ~ListViewDetailContentProvider(); - GuiListControl::IItemCoordinateTransformer* CreatePreferredCoordinateTransformer()override; + compositions::IGuiAxis* CreatePreferredAxis()override; GuiListControl::IItemArranger* CreatePreferredArranger()override; ListViewItemStyleProvider::IListViewItemContent* CreateItemContent(const FontProperties& font)override; void AttachListControl(GuiListControl* value)override; @@ -15733,7 +15882,7 @@ Datagrid ContentProvider DataGridContentProvider(); ~DataGridContentProvider(); - GuiListControl::IItemCoordinateTransformer* CreatePreferredCoordinateTransformer()override; + compositions::IGuiAxis* CreatePreferredAxis()override; GuiListControl::IItemArranger* CreatePreferredArranger()override; ListViewItemStyleProvider::IListViewItemContent* CreateItemContent(const FontProperties& font)override; void AttachListControl(GuiListControl* value)override; diff --git a/Import/GacUIReflection.cpp b/Import/GacUIReflection.cpp index 89ec0c6f..65de39cb 100644 --- a/Import/GacUIReflection.cpp +++ b/Import/GacUIReflection.cpp @@ -4552,10 +4552,6 @@ GuiListViewInstanceLoader return Value(); } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override - { - } - void GetConstructorParameters(const TypeInfo& typeInfo, collections::List& propertyNames)override { if (typeInfo.typeName == GetTypeName()) @@ -4602,11 +4598,6 @@ GuiListViewInstanceLoader } return IGuiInstanceLoader::GetPropertyType(propertyInfo); } - - bool SetPropertyValue(PropertyValue& propertyValue)override - { - return false; - } }; /*********************************************************************** @@ -5156,6 +5147,70 @@ GuiBindableDataGridInstanceLoader } }; +/*********************************************************************** +GuiAxisInstanceLoader +***********************************************************************/ + + class GuiAxisInstanceLoader : public Object, public IGuiInstanceLoader + { + protected: + GlobalStringKey typeName; + GlobalStringKey _AxisDirection; + + public: + GuiAxisInstanceLoader() + { + typeName = GlobalStringKey::Get(description::GetTypeDescriptor()->GetTypeName()); + _AxisDirection = GlobalStringKey::Get(L"AxisDirection"); + } + + GlobalStringKey GetTypeName()override + { + return typeName; + } + + bool IsCreatable(const TypeInfo& typeInfo)override + { + return typeName == typeInfo.typeName; + } + + description::Value CreateInstance(Ptr env, const TypeInfo& typeInfo, collections::Group& constructorArguments)override + { + if (typeInfo.typeName == GetTypeName()) + { + vint indexAxisDirection = constructorArguments.Keys().IndexOf(_AxisDirection); + if (indexAxisDirection == -1) + { + return Value(); + } + + auto axisDirection = UnboxValue(constructorArguments.GetByIndex(indexAxisDirection)[0]); + auto axis = new GuiAxis(axisDirection); + return Value::From(axis); + } + return Value(); + } + + void GetConstructorParameters(const TypeInfo& typeInfo, collections::List& propertyNames)override + { + if (typeInfo.typeName == GetTypeName()) + { + propertyNames.Add(_AxisDirection); + } + } + + Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + { + if (propertyInfo.propertyName == _AxisDirection) + { + auto info = GuiInstancePropertyInfo::Assign(description::GetTypeDescriptor()); + info->scope = GuiInstancePropertyInfo::Constructor; + return info; + } + return IGuiInstanceLoader::GetPropertyType(propertyInfo); + } + }; + /*********************************************************************** GuiCompositionInstanceLoader ***********************************************************************/ @@ -5560,6 +5615,7 @@ GuiPredefinedInstanceLoadersPlugin manager->SetLoader(new GuiBindableDataColumnInstanceLoader); // VisualizerTemplates, EditorTemplate manager->SetLoader(new GuiBindableDataGridInstanceLoader); // ControlTemplate, ItemSource + manager->SetLoader(new GuiAxisInstanceLoader); manager->SetLoader(new GuiCompositionInstanceLoader); manager->SetLoader(new GuiTableCompositionInstanceLoader); manager->SetLoader(new GuiCellCompositionInstanceLoader); @@ -9344,6 +9400,17 @@ Type Declaration ENUM_CLASS_ITEM(Bottom) END_ENUM_ITEM(Alignment) + BEGIN_ENUM_ITEM(AxisDirection) + ENUM_CLASS_ITEM(LeftDown) + ENUM_CLASS_ITEM(RightDown) + ENUM_CLASS_ITEM(LeftUp) + ENUM_CLASS_ITEM(RightUp) + ENUM_CLASS_ITEM(DownLeft) + ENUM_CLASS_ITEM(DownRight) + ENUM_CLASS_ITEM(UpLeft) + ENUM_CLASS_ITEM(UpRight) + END_ENUM_ITEM(AxisDirection) + BEGIN_STRUCT_MEMBER(TextPos) STRUCT_MEMBER(row) STRUCT_MEMBER(column) @@ -10261,6 +10328,46 @@ Type Declaration #define INTERFACE_IDENTIFIER(INTERFACE)\ CLASS_MEMBER_STATIC_EXTERNALMETHOD(GetIdentifier, NO_PARAMETER, WString(*)(), []()->WString{return INTERFACE::Identifier;}) + BEGIN_ENUM_ITEM(KeyDirection) + ENUM_CLASS_ITEM(Up) + ENUM_CLASS_ITEM(Down) + ENUM_CLASS_ITEM(Left) + ENUM_CLASS_ITEM(Right) + ENUM_CLASS_ITEM(Home) + ENUM_CLASS_ITEM(End) + ENUM_CLASS_ITEM(PageUp) + ENUM_CLASS_ITEM(PageDown) + ENUM_CLASS_ITEM(PageLeft) + ENUM_CLASS_ITEM(PageRight) + END_ENUM_ITEM(KeyDirection) + + BEGIN_CLASS_MEMBER(IGuiAxis) + CLASS_MEMBER_BASE(IDescriptable) + INTERFACE_EXTERNALCTOR(compositions, IGuiAxis) + + CLASS_MEMBER_METHOD(RealSizeToVirtualSize, {L"size"}) + CLASS_MEMBER_METHOD(VirtualSizeToRealSize, {L"size"}) + CLASS_MEMBER_METHOD(RealPointToVirtualPoint, {L"realFullSize" _ L"point"}) + CLASS_MEMBER_METHOD(VirtualPointToRealPoint, {L"realFullSize" _ L"point"}) + CLASS_MEMBER_METHOD(RealRectToVirtualRect, {L"realFullSize" _ L"rect"}) + CLASS_MEMBER_METHOD(VirtualRectToRealRect, {L"realFullSize" _ L"rect"}) + CLASS_MEMBER_METHOD(RealMarginToVirtualMargin, {L"margin"}) + CLASS_MEMBER_METHOD(VirtualMarginToRealMargin, {L"margin"}) + CLASS_MEMBER_METHOD(RealKeyDirectionToVirtualKeyDirection, {L"key"}) + END_CLASS_MEMBER(IGuiAxis) + + BEGIN_CLASS_MEMBER(GuiDefaultAxis) + CLASS_MEMBER_BASE(IGuiAxis) + CLASS_MEMBER_CONSTRUCTOR(Ptr(), NO_PARAMETER) + END_CLASS_MEMBER(GuiDefaultAxis) + + BEGIN_CLASS_MEMBER(GuiAxis) + CLASS_MEMBER_BASE(IGuiAxis) + CLASS_MEMBER_CONSTRUCTOR(Ptr(AxisDirection), {L"axisDirection"}) + + CLASS_MEMBER_PROPERTY_READONLY_FAST(Alignment) + END_CLASS_MEMBER(GuiAxis) + BEGIN_CLASS_MEMBER(GuiStackComposition) CLASS_MEMBER_BASE(GuiBoundsComposition) CLASS_MEMBER_CONSTRUCTOR(GuiStackComposition*(), NO_PARAMETER) @@ -10341,6 +10448,46 @@ Type Declaration CLASS_MEMBER_METHOD(SetSite, {L"row" _ L"column" _ L"rowSpan" _ L"columnSpan"}) END_CLASS_MEMBER(GuiCellComposition) + BEGIN_ENUM_ITEM(FlowAlignment) + ENUM_CLASS_ITEM(Left) + ENUM_CLASS_ITEM(Center) + ENUM_CLASS_ITEM(Extend) + END_ENUM_ITEM(FlowAlignment) + + BEGIN_CLASS_MEMBER(GuiFlowComposition) + CLASS_MEMBER_BASE(GuiBoundsComposition) + CLASS_MEMBER_CONSTRUCTOR(GuiFlowComposition*(), NO_PARAMETER) + + CLASS_MEMBER_PROPERTY_READONLY_FAST(FlowItems) + CLASS_MEMBER_PROPERTY_FAST(ExtraMargin) + CLASS_MEMBER_PROPERTY_FAST(RowPadding) + CLASS_MEMBER_PROPERTY_FAST(ColumnPadding) + CLASS_MEMBER_PROPERTY_FAST(Axis) + CLASS_MEMBER_PROPERTY_FAST(Alignment) + END_CLASS_MEMBER(GuiFlowComposition) + + BEGIN_STRUCT_MEMBER(GuiFlowOption) + STRUCT_MEMBER(baseline) + STRUCT_MEMBER(percentage) + STRUCT_MEMBER(distance) + END_STRUCT_MEMBER(GuiFlowOption) + + BEGIN_ENUM_ITEM(GuiFlowOption::BaselineType) + ENUM_ITEM_NAMESPACE(GuiFlowOption) + ENUM_NAMESPACE_ITEM(Percentage) + ENUM_NAMESPACE_ITEM(FromTop) + ENUM_NAMESPACE_ITEM(FromBottom) + END_ENUM_ITEM(GuiFlowOption::BaselineType) + + BEGIN_CLASS_MEMBER(GuiFlowItemComposition) + CLASS_MEMBER_BASE(GuiGraphicsSite) + CLASS_MEMBER_CONSTRUCTOR(GuiFlowItemComposition*(), NO_PARAMETER) + + CLASS_MEMBER_PROPERTY_EVENT_FAST(Bounds, BoundsChanged) + CLASS_MEMBER_PROPERTY_FAST(ExtraMargin) + CLASS_MEMBER_PROPERTY_FAST(FlowOption) + END_CLASS_MEMBER(GuiFlowItemComposition) + BEGIN_CLASS_MEMBER(GuiSideAlignedComposition) CLASS_MEMBER_BASE(GuiGraphicsSite) CLASS_MEMBER_CONSTRUCTOR(GuiSideAlignedComposition*(), NO_PARAMETER) @@ -10964,7 +11111,7 @@ Type Declaration CLASS_MEMBER_PROPERTY_READONLY_FAST(ItemProvider) CLASS_MEMBER_PROPERTY_GUIEVENT_FAST(StyleProvider) CLASS_MEMBER_PROPERTY_GUIEVENT_FAST(Arranger) - CLASS_MEMBER_PROPERTY_GUIEVENT_FAST(CoordinateTransformer) + CLASS_MEMBER_PROPERTY_GUIEVENT_FAST(Axis) CLASS_MEMBER_METHOD(EnsureItemVisible, {L"itemIndex"}) END_CLASS_MEMBER(GuiListControl) @@ -11007,20 +11154,6 @@ Type Declaration CLASS_MEMBER_METHOD(GetBindingValue, {L"itemIndex"}) END_CLASS_MEMBER(GuiListControl::IItemBindingView) - BEGIN_ENUM_ITEM(GuiListControl::KeyDirection) - ENUM_ITEM_NAMESPACE(GuiListControl) - ENUM_NAMESPACE_ITEM(Up) - ENUM_NAMESPACE_ITEM(Down) - ENUM_NAMESPACE_ITEM(Left) - ENUM_NAMESPACE_ITEM(Right) - ENUM_NAMESPACE_ITEM(Home) - ENUM_NAMESPACE_ITEM(End) - ENUM_NAMESPACE_ITEM(PageUp) - ENUM_NAMESPACE_ITEM(PageDown) - ENUM_NAMESPACE_ITEM(PageLeft) - ENUM_NAMESPACE_ITEM(PageRight) - END_ENUM_ITEM(GuiListControl::KeyDirection) - BEGIN_CLASS_MEMBER(GuiListControl::IItemProvider) CLASS_MEMBER_BASE(IDescriptable) INTERFACE_EXTERNALCTOR(GuiListControl, IItemProvider) @@ -11074,21 +11207,6 @@ Type Declaration CLASS_MEMBER_METHOD(EnsureItemVisible, {L"itemIndex"}) END_CLASS_MEMBER(GuiListControl::IItemArranger) - BEGIN_CLASS_MEMBER(GuiListControl::IItemCoordinateTransformer) - CLASS_MEMBER_BASE(IDescriptable) - INTERFACE_EXTERNALCTOR(GuiListControl, IItemCoordinateTransformer) - - CLASS_MEMBER_METHOD(RealSizeToVirtualSize, {L"size"}) - CLASS_MEMBER_METHOD(VirtualSizeToRealSize, {L"size"}) - CLASS_MEMBER_METHOD(RealPointToVirtualPoint, {L"realFullSize" _ L"point"}) - CLASS_MEMBER_METHOD(VirtualPointToRealPoint, {L"realFullSize" _ L"point"}) - CLASS_MEMBER_METHOD(RealRectToVirtualRect, {L"realFullSize" _ L"rect"}) - CLASS_MEMBER_METHOD(VirtualRectToRealRect, {L"realFullSize" _ L"rect"}) - CLASS_MEMBER_METHOD(RealMarginToVirtualMargin, {L"margin"}) - CLASS_MEMBER_METHOD(VirtualMarginToRealMargin, {L"margin"}) - CLASS_MEMBER_METHOD(RealKeyDirectionToVirtualKeyDirection, {L"key"}) - END_CLASS_MEMBER(GuiListControl::IItemCoordinateTransformer) - BEGIN_CLASS_MEMBER(GuiSelectableListControl) CLASS_MEMBER_BASE(GuiListControl) CLASS_MEMBER_CONSTRUCTOR(GuiSelectableListControl*(GuiSelectableListControl::IStyleProvider* _ GuiSelectableListControl::IItemProvider*), {L"styleProvider" _ L"itemProvider"}) @@ -11114,30 +11232,6 @@ Type Declaration CLASS_MEMBER_METHOD(SetStyleSelected, {L"style" _ L"value"}) END_CLASS_MEMBER(GuiSelectableListControl::IItemStyleProvider) - BEGIN_CLASS_MEMBER(DefaultItemCoordinateTransformer) - CLASS_MEMBER_BASE(GuiListControl::IItemCoordinateTransformer) - CLASS_MEMBER_CONSTRUCTOR(Ptr(), NO_PARAMETER) - END_CLASS_MEMBER(DefaultItemCoordinateTransformer) - - BEGIN_CLASS_MEMBER(AxisAlignedItemCoordinateTransformer) - CLASS_MEMBER_BASE(GuiListControl::IItemCoordinateTransformer) - CLASS_MEMBER_CONSTRUCTOR(Ptr(AxisAlignedItemCoordinateTransformer::Alignment), {L"alignment"}) - - CLASS_MEMBER_PROPERTY_READONLY_FAST(Alignment) - END_CLASS_MEMBER(AxisAlignedItemCoordinateTransformer) - - BEGIN_ENUM_ITEM(AxisAlignedItemCoordinateTransformer::Alignment) - ENUM_ITEM_NAMESPACE(AxisAlignedItemCoordinateTransformer) - ENUM_NAMESPACE_ITEM(LeftDown) - ENUM_NAMESPACE_ITEM(RightDown) - ENUM_NAMESPACE_ITEM(LeftUp) - ENUM_NAMESPACE_ITEM(RightUp) - ENUM_NAMESPACE_ITEM(DownLeft) - ENUM_NAMESPACE_ITEM(DownRight) - ENUM_NAMESPACE_ITEM(UpLeft) - ENUM_NAMESPACE_ITEM(UpRight) - END_ENUM_ITEM(AxisAlignedItemCoordinateTransformer::Alignment) - BEGIN_CLASS_MEMBER(RangedItemArrangerBase) CLASS_MEMBER_BASE(GuiListControl::IItemArranger) END_CLASS_MEMBER(RangedItemArrangerBase) @@ -11314,7 +11408,7 @@ Type Declaration CLASS_MEMBER_BASE(IDescriptable) INTERFACE_EXTERNALCTOR(ListViewItemStyleProvider, IListViewItemContentProvider) - CLASS_MEMBER_METHOD(CreatePreferredCoordinateTransformer, NO_PARAMETER) + CLASS_MEMBER_METHOD(CreatePreferredAxis, NO_PARAMETER) CLASS_MEMBER_METHOD(CreatePreferredArranger, NO_PARAMETER) CLASS_MEMBER_METHOD(CreateItemContent, {L"font"}) CLASS_MEMBER_METHOD(AttachListControl, {L"value"}) diff --git a/Import/GacUIReflection.h b/Import/GacUIReflection.h index 7ac5a8f2..d5952df4 100644 --- a/Import/GacUIReflection.h +++ b/Import/GacUIReflection.h @@ -898,6 +898,7 @@ Type List #define GUIREFLECTIONBASIC_TYPELIST(F)\ F(presentation::Color)\ F(presentation::Alignment)\ + F(presentation::AxisDirection)\ F(presentation::TextPos)\ F(presentation::GridPos)\ F(presentation::Point)\ @@ -1210,6 +1211,10 @@ Type List ***********************************************************************/ #define GUIREFLECTIONCOMPOSITION_TYPELIST(F)\ + F(presentation::compositions::KeyDirection)\ + F(presentation::compositions::IGuiAxis)\ + F(presentation::compositions::GuiDefaultAxis)\ + F(presentation::compositions::GuiAxis)\ F(presentation::compositions::GuiStackComposition)\ F(presentation::compositions::GuiStackComposition::Direction)\ F(presentation::compositions::GuiStackItemComposition)\ @@ -1217,6 +1222,11 @@ Type List F(presentation::compositions::GuiCellOption::ComposeType)\ F(presentation::compositions::GuiTableComposition)\ F(presentation::compositions::GuiCellComposition)\ + F(presentation::compositions::FlowAlignment)\ + F(presentation::compositions::GuiFlowComposition)\ + F(presentation::compositions::GuiFlowOption)\ + F(presentation::compositions::GuiFlowOption::BaselineType)\ + F(presentation::compositions::GuiFlowItemComposition)\ F(presentation::compositions::GuiSideAlignedComposition)\ F(presentation::compositions::GuiSideAlignedComposition::Direction)\ F(presentation::compositions::GuiPartialViewComposition)\ @@ -1274,6 +1284,65 @@ Interface Proxy INVOKE_INTERFACE_PROXY_NOPARAMS(Stop); } }; + + class compositions_IGuiAxis : public ValueInterfaceRoot, public virtual IGuiAxis + { + public: + compositions_IGuiAxis(Ptr _proxy) + :ValueInterfaceRoot(_proxy) + { + } + + static Ptr Create(Ptr proxy) + { + return new compositions_IGuiAxis(proxy); + } + + Size RealSizeToVirtualSize(Size size)override + { + return INVOKEGET_INTERFACE_PROXY(RealSizeToVirtualSize, size); + } + + Size VirtualSizeToRealSize(Size size)override + { + return INVOKEGET_INTERFACE_PROXY(VirtualSizeToRealSize, size); + } + + Point RealPointToVirtualPoint(Size realFullSize, Point point)override + { + return INVOKEGET_INTERFACE_PROXY(RealPointToVirtualPoint, realFullSize, point); + } + + Point VirtualPointToRealPoint(Size realFullSize, Point point)override + { + return INVOKEGET_INTERFACE_PROXY(VirtualPointToRealPoint, realFullSize, point); + } + + Rect RealRectToVirtualRect(Size realFullSize, Rect rect)override + { + return INVOKEGET_INTERFACE_PROXY(RealRectToVirtualRect, realFullSize, rect); + } + + Rect VirtualRectToRealRect(Size realFullSize, Rect rect)override + { + return INVOKEGET_INTERFACE_PROXY(VirtualRectToRealRect, realFullSize, rect); + } + + Margin RealMarginToVirtualMargin(Margin margin)override + { + return INVOKEGET_INTERFACE_PROXY(RealMarginToVirtualMargin, margin); + } + + Margin VirtualMarginToRealMargin(Margin margin)override + { + return INVOKEGET_INTERFACE_PROXY(VirtualMarginToRealMargin, margin); + } + + KeyDirection RealKeyDirectionToVirtualKeyDirection(KeyDirection key)override + { + return INVOKEGET_INTERFACE_PROXY(RealKeyDirectionToVirtualKeyDirection, key); + } + }; } #pragma warning(pop) @@ -1358,17 +1427,12 @@ Type List F(presentation::controls::GuiListControl::IItemArrangerCallback)\ F(presentation::controls::GuiListControl::IItemPrimaryTextView)\ F(presentation::controls::GuiListControl::IItemBindingView)\ - F(presentation::controls::GuiListControl::KeyDirection)\ F(presentation::controls::GuiListControl::IItemProvider)\ F(presentation::controls::GuiListControl::IItemStyleController)\ F(presentation::controls::GuiListControl::IItemStyleProvider)\ F(presentation::controls::GuiListControl::IItemArranger)\ - F(presentation::controls::GuiListControl::IItemCoordinateTransformer)\ F(presentation::controls::GuiSelectableListControl)\ F(presentation::controls::GuiSelectableListControl::IItemStyleProvider)\ - F(presentation::controls::list::DefaultItemCoordinateTransformer)\ - F(presentation::controls::list::AxisAlignedItemCoordinateTransformer)\ - F(presentation::controls::list::AxisAlignedItemCoordinateTransformer::Alignment)\ F(presentation::controls::list::RangedItemArrangerBase)\ F(presentation::controls::list::FixedHeightItemArranger)\ F(presentation::controls::list::FixedSizeMultiColumnItemArranger)\ @@ -2070,7 +2134,7 @@ Interface Proxy INVOKE_INTERFACE_PROXY(OnViewChanged, bounds); } - vint FindItem(vint itemIndex, GuiListControl::KeyDirection key)override + vint FindItem(vint itemIndex, compositions::KeyDirection key)override { return INVOKEGET_INTERFACE_PROXY(FindItem, itemIndex, key); } @@ -2081,65 +2145,6 @@ Interface Proxy } }; - class GuiListControl_IItemCoordinateTransformer : public ValueInterfaceRoot, public virtual GuiListControl::IItemCoordinateTransformer - { - public: - GuiListControl_IItemCoordinateTransformer(Ptr _proxy) - :ValueInterfaceRoot(_proxy) - { - } - - static Ptr Create(Ptr proxy) - { - return new GuiListControl_IItemCoordinateTransformer(proxy); - } - - Size RealSizeToVirtualSize(Size size)override - { - return INVOKEGET_INTERFACE_PROXY(RealSizeToVirtualSize, size); - } - - Size VirtualSizeToRealSize(Size size)override - { - return INVOKEGET_INTERFACE_PROXY(VirtualSizeToRealSize, size); - } - - Point RealPointToVirtualPoint(Size realFullSize, Point point)override - { - return INVOKEGET_INTERFACE_PROXY(RealPointToVirtualPoint, realFullSize, point); - } - - Point VirtualPointToRealPoint(Size realFullSize, Point point)override - { - return INVOKEGET_INTERFACE_PROXY(VirtualPointToRealPoint, realFullSize, point); - } - - Rect RealRectToVirtualRect(Size realFullSize, Rect rect)override - { - return INVOKEGET_INTERFACE_PROXY(RealRectToVirtualRect, realFullSize, rect); - } - - Rect VirtualRectToRealRect(Size realFullSize, Rect rect)override - { - return INVOKEGET_INTERFACE_PROXY(VirtualRectToRealRect, realFullSize, rect); - } - - Margin RealMarginToVirtualMargin(Margin margin)override - { - return INVOKEGET_INTERFACE_PROXY(RealMarginToVirtualMargin, margin); - } - - Margin VirtualMarginToRealMargin(Margin margin)override - { - return INVOKEGET_INTERFACE_PROXY(VirtualMarginToRealMargin, margin); - } - - GuiListControl::KeyDirection RealKeyDirectionToVirtualKeyDirection(GuiListControl::KeyDirection key)override - { - return INVOKEGET_INTERFACE_PROXY(RealKeyDirectionToVirtualKeyDirection, key); - } - }; - class GuiSelectableListControl_IItemStyleProvider : public virtual GuiListControl_IItemStyleProvider, public virtual GuiSelectableListControl::IItemStyleProvider { public: @@ -2358,9 +2363,9 @@ Interface Proxy return new ListViewItemStyleProvider_IListViewItemContentProvider(proxy); } - GuiListControl::IItemCoordinateTransformer* CreatePreferredCoordinateTransformer()override + compositions::IGuiAxis* CreatePreferredAxis()override { - return INVOKEGET_INTERFACE_PROXY_NOPARAMS(CreatePreferredCoordinateTransformer); + return INVOKEGET_INTERFACE_PROXY_NOPARAMS(CreatePreferredAxis); } GuiListControl::IItemArranger* CreatePreferredArranger()override diff --git a/Tools/GacGen.exe b/Tools/GacGen.exe index 3588e51d..53bc5082 100644 Binary files a/Tools/GacGen.exe and b/Tools/GacGen.exe differ diff --git a/Tools/ParserGen.exe b/Tools/ParserGen.exe index f2282d54..7e7b5b47 100644 Binary files a/Tools/ParserGen.exe and b/Tools/ParserGen.exe differ diff --git a/Tutorial/GacUI_HelloWorlds/UIRes/MVVM.bin b/Tutorial/GacUI_HelloWorlds/UIRes/MVVM.bin index 05b5ca35..9b923e01 100644 Binary files a/Tutorial/GacUI_HelloWorlds/UIRes/MVVM.bin and b/Tutorial/GacUI_HelloWorlds/UIRes/MVVM.bin differ diff --git a/Tutorial/GacUI_Layout/Flow/UI/Resource.xml b/Tutorial/GacUI_Layout/Flow/UI/Resource.xml index b3dd67cf..075fbe1f 100644 --- a/Tutorial/GacUI_Layout/Flow/UI/Resource.xml +++ b/Tutorial/GacUI_Layout/Flow/UI/Resource.xml @@ -13,10 +13,218 @@ + + + + + + + - + + + + + + + + composeType:MinSize + composeType:MinSize + composeType:Percentage percentage:1.0 + + + composeType:MinSize + composeType:MinSize + composeType:Percentage percentage:1.0 + + + + + + + +
+ + composeType:MinSize + composeType:MinSize + composeType:MinSize + composeType:MinSize + + + composeType:MinSize + composeType:MinSize + composeType:MinSize + composeType:MinSize + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + composeType:MinSize + composeType:MinSize + composeType:MinSize + + + composeType:MinSize + + + + + + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Tutorial/GacUI_Layout/Flow/UI/Source/DemoPartialClasses.h b/Tutorial/GacUI_Layout/Flow/UI/Source/DemoPartialClasses.h index 8088a85f..70f473f2 100644 --- a/Tutorial/GacUI_Layout/Flow/UI/Source/DemoPartialClasses.h +++ b/Tutorial/GacUI_Layout/Flow/UI/Source/DemoPartialClasses.h @@ -23,11 +23,21 @@ namespace demo friend struct vl::reflection::description::CustomTypeDescriptorSelector; private: protected: + vl::presentation::compositions::GuiFlowComposition* flowLayout; + vl::presentation::controls::GuiSelectableButton::MutexGroupController* groupAlignment; + vl::presentation::controls::GuiSelectableButton::MutexGroupController* groupAxis; + vl::presentation::controls::GuiControl* groupBoxAlignment; + vl::presentation::controls::GuiControl* groupBoxAxis; void InitializeComponents() { if (InitializeFromResource()) { + GUI_INSTANCE_REFERENCE(flowLayout); + GUI_INSTANCE_REFERENCE(groupAlignment); + GUI_INSTANCE_REFERENCE(groupAxis); + GUI_INSTANCE_REFERENCE(groupBoxAlignment); + GUI_INSTANCE_REFERENCE(groupBoxAxis); } else { @@ -37,6 +47,11 @@ namespace demo MainWindow_() :vl::presentation::GuiInstancePartialClass(L"demo::MainWindow") ,vl::presentation::controls::GuiWindow(vl::presentation::theme::GetCurrentTheme()->CreateWindowStyle()) + ,flowLayout(0) + ,groupAlignment(0) + ,groupAxis(0) + ,groupBoxAlignment(0) + ,groupBoxAxis(0) { } }; diff --git a/Tutorial/GacUI_Layout/UIRes/Flow.bin b/Tutorial/GacUI_Layout/UIRes/Flow.bin index d5b5f212..30ec7b95 100644 Binary files a/Tutorial/GacUI_Layout/UIRes/Flow.bin and b/Tutorial/GacUI_Layout/UIRes/Flow.bin differ