From d396bc272377b897b28abc8b41a3b9b461e711c6 Mon Sep 17 00:00:00 2001 From: Jeahoon Kim Date: Tue, 30 Apr 2013 16:34:24 +0900 Subject: [PATCH] Fixed a defect(N_SE-36363). And fixed a margin bug of GridLayout when using stretchable/shrinkable. Change-Id: Ic5074e28ef2778d71f27b18d3cee7a4fb22003ed Signed-off-by: Jeahoon Kim --- src/ui/inc/FUi_LayoutLayout.h | 4 ++++ src/ui/layout/FUi_LayoutLayout.cpp | 38 ++++++++++++++++++++++++++++++ src/ui/layout/FUi_LayoutRelativeLayout.cpp | 4 ++++ src/ui/layout/FUi_LayoutTableLayout.cpp | 26 +++++++------------- 4 files changed, 55 insertions(+), 17 deletions(-) diff --git a/src/ui/inc/FUi_LayoutLayout.h b/src/ui/inc/FUi_LayoutLayout.h index 8f6c7be..1b52f4a 100644 --- a/src/ui/inc/FUi_LayoutLayout.h +++ b/src/ui/inc/FUi_LayoutLayout.h @@ -312,6 +312,10 @@ protected: void SetItemList(ProxyList* pItemList); ProxyList* GetProxyList(void) const; + void AlignToDevice(const LayoutPoint layoutPoint, LayoutPoint& alignedPoint); + void AlignToDevice(const LayoutSize layoutSize, LayoutSize& alignedSize); + void AlignToDevice(const LayoutRect layoutRect, LayoutRect& alignedRect); + private: /** * This is the copy constructor for this class. diff --git a/src/ui/layout/FUi_LayoutLayout.cpp b/src/ui/layout/FUi_LayoutLayout.cpp index 2d18b16..92d6b39 100644 --- a/src/ui/layout/FUi_LayoutLayout.cpp +++ b/src/ui/layout/FUi_LayoutLayout.cpp @@ -22,12 +22,18 @@ */ #include +#include +#include +#include +#include #include "FUi_LayoutLayout.h" #include "FUi_LayoutLayoutItemProxy.h" #include "FUi_LayoutProxyList.h" #include "FUi_LayoutLayoutItemInfo.h" #include "FUi_LayoutLayoutList.h" +using namespace Tizen::Graphics; + namespace Tizen { namespace Ui { namespace _Layout { @@ -901,4 +907,36 @@ Layout::GetProxyList(void) const return __pProxyList; } +void +Layout::AlignToDevice(const LayoutPoint layoutPoint, LayoutPoint& alignedPoint) +{ + FloatPoint point(layoutPoint.x, layoutPoint.y); + point = CoordinateSystem::AlignToDevice(point); + + alignedPoint.x = point.x; + alignedPoint.y = point.y; +} + +void +Layout::AlignToDevice(const LayoutSize layoutSize, LayoutSize& alignedSize) +{ + FloatDimension size(layoutSize.w, layoutSize.h); + size = CoordinateSystem::AlignToDevice(size); + + alignedSize.w = size.width; + alignedSize.h = size.height; +} + +void +Layout::AlignToDevice(const LayoutRect layoutRect, LayoutRect& alignedRect) +{ + FloatRectangle rect(layoutRect.x, layoutRect.y, layoutRect.w, layoutRect.h); + rect = CoordinateSystem::AlignToDevice(rect); + + alignedRect.x = rect.x; + alignedRect.y = rect.y; + alignedRect.w = rect.width; + alignedRect.h = rect.height; +} + }}} // Tizen::Ui::_Layout diff --git a/src/ui/layout/FUi_LayoutRelativeLayout.cpp b/src/ui/layout/FUi_LayoutRelativeLayout.cpp index 104dae0..5262342 100644 --- a/src/ui/layout/FUi_LayoutRelativeLayout.cpp +++ b/src/ui/layout/FUi_LayoutRelativeLayout.cpp @@ -556,6 +556,7 @@ RelativeLayout::CalculatePosition(ProxyListNode& curNode) { return r; } + AlignToDevice(curItemRect, curItemRect); curItemRect.x = targetPosition.x + curItemMargin.left; } @@ -566,6 +567,7 @@ RelativeLayout::CalculatePosition(ProxyListNode& curNode) { return r; } + AlignToDevice(curItemRect, curItemRect); curItemRect.y = targetPosition.y + curItemMargin.top; } @@ -577,6 +579,7 @@ RelativeLayout::CalculatePosition(ProxyListNode& curNode) return r; } + AlignToDevice(curItemRect, curItemRect); if (pCurItemInfo->__pTarget[EDGE_LEFT] != null) { curItemRect.w = targetPosition.x - curItemRect.x - curItemMargin.right; @@ -592,6 +595,7 @@ RelativeLayout::CalculatePosition(ProxyListNode& curNode) return r; } + AlignToDevice(curItemRect, curItemRect); if (pCurItemInfo->__pTarget[EDGE_TOP] != null) { curItemRect.h = targetPosition.y - curItemRect.y - curItemMargin.bottom; diff --git a/src/ui/layout/FUi_LayoutTableLayout.cpp b/src/ui/layout/FUi_LayoutTableLayout.cpp index cf49a92..84e3bca 100644 --- a/src/ui/layout/FUi_LayoutTableLayout.cpp +++ b/src/ui/layout/FUi_LayoutTableLayout.cpp @@ -182,22 +182,14 @@ TableLayout::CalculateSize() pItemProxy->GetMeasuredSize(rect.w, rect.h); ItemMargin margin = pItemProxy->GetItemMargin(); - ItemAlign itemAlign = pItemProxy->GetItemAlignment(); - if (itemAlign.HAlign == ITEM_HORIZONTAL_ALIGN_LEFT || itemAlign.HAlign == ITEM_HORIZONTAL_ALIGN_LEFT_RIGHT) + if (!__pColInfo[j].widthStretchable && !__pColInfo[j].widthShrinkable) { - rect.w += margin.left; + rect.w += margin.left + margin.right; } - if (itemAlign.HAlign == ITEM_HORIZONTAL_ALIGN_RIGHT || itemAlign.HAlign == ITEM_HORIZONTAL_ALIGN_LEFT_RIGHT) - { - rect.w += margin.right; - } - if (itemAlign.VAlign == ITEM_VERTICAL_ALIGN_TOP || itemAlign.VAlign == ITEM_VERTICAL_ALIGN_TOP_BOTTOM) - { - rect.h += margin.top; - } - if (itemAlign.VAlign == ITEM_VERTICAL_ALIGN_BOTTOM || itemAlign.VAlign == ITEM_VERTICAL_ALIGN_TOP_BOTTOM) + + if (!__pRowInfo[i].heightStretchable && !__pRowInfo[i].heightShrinkable) { - rect.h += margin.bottom; + rect.h += margin.top + margin.bottom; } if (!pItemInfo->__merged) @@ -389,7 +381,7 @@ TableLayout::CalculateShrinkCell(const LayoutRect windowRect) ProxyListNode* pCurNode = null; TableItemInfo* pItemInfo = null; - if (shrinkTotalWidth > 0 && __shrinkColumnCount > 0) + if (shrinkTotalWidth >= 0.0f && __shrinkColumnCount > 0) { if (pContainerProxy->GetItemWidthMatchMode() == WRAP_CONTENT) { @@ -553,7 +545,7 @@ TableLayout::CalculateShrinkCell(const LayoutRect windowRect) delete[] pShrinkedColumns; } - if (shrinkTotalHeight > 0.0f && __shrinkRowCount > 0) + if (shrinkTotalHeight >= 0.0f && __shrinkRowCount > 0) { if (pContainerProxy->GetItemHeightMatchMode() == WRAP_CONTENT) { @@ -749,7 +741,7 @@ TableLayout::CalculateStretchCell(const LayoutRect windowRect) ProxyListNode* pCurNode = null; TableItemInfo* pItemInfo = null; - if (stretchTotalWidth > 0 && __stretchColumnCount > 0) + if (stretchTotalWidth >= 0.0f && __stretchColumnCount > 0) { if (pContainerProxy->GetItemWidthMatchMode() == WRAP_CONTENT) { @@ -894,7 +886,7 @@ TableLayout::CalculateStretchCell(const LayoutRect windowRect) delete[] pStretchedColumns; } - if (stretchTotalHeight > 0 && __stretchRowCount > 0) + if (stretchTotalHeight >= 0.0f && __stretchRowCount > 0) { if (pContainerProxy->GetItemHeightMatchMode() == WRAP_CONTENT) { -- 2.7.4