From 2a7f0dfd32b7f012529564a068e49362404eb7ed Mon Sep 17 00:00:00 2001 From: "vignesh.v" Date: Thu, 26 Sep 2013 18:35:23 +0530 Subject: [PATCH] Fix for display issue in Header and Footer Signed-off-by: vignesh.v Change-Id: I53efef027c1e12b96892aa8ab60fbcbb2f93567b --- src/ui/controls/FUiCtrl_Toolbar.cpp | 144 ++++++++++++++++++++++++++++++------ 1 file changed, 121 insertions(+), 23 deletions(-) diff --git a/src/ui/controls/FUiCtrl_Toolbar.cpp b/src/ui/controls/FUiCtrl_Toolbar.cpp index a4de714..e3bc1f0 100644 --- a/src/ui/controls/FUiCtrl_Toolbar.cpp +++ b/src/ui/controls/FUiCtrl_Toolbar.cpp @@ -39,6 +39,7 @@ using namespace Tizen::Base; using namespace Tizen::Base::Collection; using namespace Tizen::Graphics; using namespace Tizen::Ui; +using namespace Tizen::Base::Utility; namespace { @@ -8174,21 +8175,25 @@ _Toolbar::RearrangeHeaderSegmentedItems(void) if (!(__pButtonItems[LEFT_BUTTON] || __pButtonItems[RIGHT_BUTTON])) // no button { blockWidth[0] = blockWidth[1] = blockWidth[2] = GetSizeF().width / 3; - blockWidth[1] += 1; __pItems.at(0)->SetBounds(FloatRectangle(0, vmargin, blockWidth[0], segmentedItemHeight)); __pItems.at(1)->SetBounds(FloatRectangle(blockWidth[0], vmargin, blockWidth[1], segmentedItemHeight)); - __pItems.at(2)->SetBounds(FloatRectangle(GetSizeF().width - blockWidth[2], vmargin, blockWidth[2] + 1, segmentedItemHeight)); + __pItems.at(2)->SetBounds(FloatRectangle(GetSizeF().width - blockWidth[2], vmargin, blockWidth[2], segmentedItemHeight)); } else { blockWidth[0] = blockWidth[1] = blockWidth[2] = (__itemArea.width + leftMargin) / 3; - blockWidth[1] += 1; __pItems.at(0)->SetBounds(FloatRectangle(0, vmargin, blockWidth[0], segmentedItemHeight)); __pItems.at(1)->SetBounds(FloatRectangle(blockWidth[0], vmargin, blockWidth[1], segmentedItemHeight)); - __pItems.at(2)->SetBounds(FloatRectangle(blockWidth[0] + blockWidth[1] - 1, - vmargin, blockWidth[2] + 1, segmentedItemHeight)); + __pItems.at(2)->SetBounds(FloatRectangle(blockWidth[0] + blockWidth[1], + vmargin, blockWidth[2], segmentedItemHeight)); + } + + for (int i = 0; i < 3; i++) + { + __pItems.at(i)->SetBounds(CoordinateSystem::AlignToDevice(__pItems.at(i)->GetBoundsF())); + } for (int i = 0; i < __itemCount; i++) @@ -8473,14 +8478,38 @@ _Toolbar::RearrangeFooterSegmentedItems(void) __itemArea.width -= (itemButtonRightGap + iconSize + rightMargin); } - iconSize = 0; leftMargin = 0; itemButtonLeftGap = 0; } - blockWidth[0] = blockWidth[1] = blockWidth[2] = __itemArea.width / 3; - blockWidth[1] += 1; + int width = 0; + if (fmod(__itemArea.width, __itemCount) == 0) + { + + blockWidth[0] = blockWidth[1] = blockWidth[2] = __itemArea.width / __itemCount; + } + else + { + width = __itemArea.width / __itemCount; + blockWidth[0] = blockWidth[1] = blockWidth[2] = width; + int balanceWidth = Math::Round((fmod(__itemArea.width, 3) + 0.00001f) * 10.0f); + while (balanceWidth > 0) + { + for (int i = 0; i < __itemCount; i++) + { + if (balanceWidth > 0) + { + blockWidth[i] += 0.1f; + balanceWidth = balanceWidth - 1; + } + else + { + break; + } + } + } + } if (__pButtonItems[LEFT_BUTTON]) { @@ -8488,15 +8517,15 @@ _Toolbar::RearrangeFooterSegmentedItems(void) { __pItems.at(0)->SetBounds(FloatRectangle(leftMargin + iconSize + itemButtonLeftGap + dividerWidth, (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[0] - dividerWidth, segmentedItemHeight)); __pItems.at(1)->SetBounds(FloatRectangle(leftMargin + iconSize + itemButtonLeftGap + blockWidth[0], (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[1], segmentedItemHeight)); - __pItems.at(2)->SetBounds(FloatRectangle(leftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + blockWidth[1] - 1, - (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[2] - dividerWidth + 1, segmentedItemHeight)); + __pItems.at(2)->SetBounds(FloatRectangle(leftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + blockWidth[1], + (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[2] - dividerWidth, segmentedItemHeight)); } else { __pItems.at(0)->SetBounds(FloatRectangle(leftMargin + iconSize + itemButtonLeftGap + dividerWidth, (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[0] - dividerWidth, segmentedItemHeight)); __pItems.at(1)->SetBounds(FloatRectangle(leftMargin + iconSize + itemButtonLeftGap + blockWidth[0], (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[1], segmentedItemHeight)); __pItems.at(2)->SetBounds(FloatRectangle(GetSizeF().width - blockWidth[2], - (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[2] + 2, segmentedItemHeight)); + (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[2], segmentedItemHeight)); } } else @@ -8506,17 +8535,23 @@ _Toolbar::RearrangeFooterSegmentedItems(void) __pItems.at(0)->SetBounds(FloatRectangle(leftMargin + iconSize + itemButtonLeftGap, (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[0], segmentedItemHeight)); __pItems.at(1)->SetBounds(FloatRectangle(leftMargin + iconSize + itemButtonLeftGap + blockWidth[0], (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[1], segmentedItemHeight)); __pItems.at(2)->SetBounds(FloatRectangle(__itemArea.width - blockWidth[2], - (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[2] - dividerWidth + 1, segmentedItemHeight)); + (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[2] - dividerWidth, segmentedItemHeight)); } else { __pItems.at(0)->SetBounds(FloatRectangle(leftMargin + iconSize + itemButtonLeftGap, (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[0], segmentedItemHeight)); __pItems.at(1)->SetBounds(FloatRectangle(leftMargin + iconSize + itemButtonLeftGap + blockWidth[0], (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[1], segmentedItemHeight)); __pItems.at(2)->SetBounds(FloatRectangle(GetSizeF().width - blockWidth[2], - (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[2] + 1, segmentedItemHeight)); + (GetSizeF().height - segmentedItemHeight) / 2, blockWidth[2], segmentedItemHeight)); } } + for (int i = 0; i < 3; i++) + { + __pItems.at(i)->SetBounds(CoordinateSystem::AlignToDevice(__pItems.at(i)->GetBoundsF())); + + } + for (int i = 0; i < __itemCount ; i++) { if (__pItems.at(i)->GetChildCount() != 0) @@ -8632,12 +8667,44 @@ _Toolbar::RearrangeTabItmes(void) } else if (__itemCount == 3) { - itemWidth[0] = itemWidth[1] = itemWidth[2] = __itemArea.width / 3; - itemWidth[1] += 1; + + int width = 0; + if (fmod(__itemArea.width, __itemCount) == 0) + { + + itemWidth[0] = itemWidth[1] = itemWidth[2] = __itemArea.width / 3; + } + else + { + width = __itemArea.width / __itemCount; + itemWidth[0] = itemWidth[1] = itemWidth[2] = width; + int balanceWidth = Math::Round((fmod(__itemArea.width, 3) + 0.00001f) * 10.0f); + while (balanceWidth > 0) + { + for (int i = 0; i < __itemCount; i++) + { + if (balanceWidth > 0) + { + itemWidth[i] += 0.1f; + balanceWidth = balanceWidth - 1; + } + else + { + break; + } + } + } + } __pItems.at(0)->SetBounds(FloatRectangle(0.0f, vmargin, itemWidth[0], segmentedItemHeight)); __pItems.at(1)->SetBounds(FloatRectangle(itemWidth[0], vmargin, itemWidth[1], segmentedItemHeight)); - __pItems.at(2)->SetBounds(FloatRectangle(__itemArea.width - itemWidth[2], vmargin, itemWidth[2] + 1, segmentedItemHeight)); + __pItems.at(2)->SetBounds(FloatRectangle(__itemArea.width - itemWidth[2], vmargin, itemWidth[2], segmentedItemHeight)); + + for (int i = 0; i < 3; i++) + { + __pItems.at(i)->SetBounds(CoordinateSystem::AlignToDevice(__pItems.at(i)->GetBoundsF())); + + } GET_SHAPE_CONFIG(HEADER::TAB_ITEM_FONT_SIZE_3_ITEM, GetOrientation(), fontSize); // 26 @@ -8902,8 +8969,33 @@ _Toolbar::RearrangeButtonItems(void) } } - blockWidth[0] = blockWidth[1] = blockWidth[2] = __itemArea.width / 3; - blockWidth[1] += 1; + int width = 0; + if (fmod(__itemArea.width, __itemCount) == 0) + { + + blockWidth[0] = blockWidth[1] = blockWidth[2] = __itemArea.width / __itemCount; + } + else + { + width = __itemArea.width / __itemCount; + blockWidth[0] = blockWidth[1] = blockWidth[2] = width; + int balanceWidth = Math::Round((fmod(__itemArea.width, 3) + 0.00001f) * 10.0f); + while (balanceWidth > 0) + { + for (int i = 0; i < __itemCount; i++) + { + if (balanceWidth > 0) + { + blockWidth[i] += 0.1f; + balanceWidth = balanceWidth - 1; + } + else + { + break; + } + } + } + } if (__pButtonItems[LEFT_BUTTON]) { @@ -8911,15 +9003,15 @@ _Toolbar::RearrangeButtonItems(void) { __pItems.at(0)->SetBounds(FloatRectangle(footerLeftMargin + iconSize + itemButtonLeftGap + dividerWidth, (GetSizeF().height - itemHeight) / 2, blockWidth[0] - dividerWidth, itemHeight)); __pItems.at(1)->SetBounds(FloatRectangle(footerLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0], (GetSizeF().height - itemHeight) / 2, blockWidth[1], itemHeight)); - __pItems.at(2)->SetBounds(FloatRectangle(footerLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + blockWidth[1] - 1, - (GetSizeF().height - itemHeight) / 2, blockWidth[2] - dividerWidth + 1, itemHeight)); + __pItems.at(2)->SetBounds(FloatRectangle(footerLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0] + blockWidth[1], + (GetSizeF().height - itemHeight) / 2, blockWidth[2] - dividerWidth, itemHeight)); } else { __pItems.at(0)->SetBounds(FloatRectangle(footerLeftMargin + iconSize + itemButtonLeftGap + dividerWidth, (GetSizeF().height - itemHeight) / 2, blockWidth[0] - dividerWidth, itemHeight)); __pItems.at(1)->SetBounds(FloatRectangle(footerLeftMargin + iconSize + itemButtonLeftGap + blockWidth[0], (GetSizeF().height - itemHeight) / 2, blockWidth[1], itemHeight)); __pItems.at(2)->SetBounds(FloatRectangle(GetSizeF().width - blockWidth[2], - (GetSizeF().height - itemHeight) / 2, blockWidth[2] + 2, itemHeight)); + (GetSizeF().height - itemHeight) / 2, blockWidth[2], itemHeight)); } } else @@ -8929,17 +9021,23 @@ _Toolbar::RearrangeButtonItems(void) __pItems.at(0)->SetBounds(FloatRectangle(0.0f, (GetSizeF().height - itemHeight) / 2, blockWidth[0], itemHeight)); __pItems.at(1)->SetBounds(FloatRectangle(blockWidth[0], (GetSizeF().height - itemHeight) / 2, blockWidth[1], itemHeight)); __pItems.at(2)->SetBounds(FloatRectangle(__itemArea.width - blockWidth[2], - (GetSizeF().height - itemHeight) / 2, blockWidth[2] - dividerWidth + 1, itemHeight)); + (GetSizeF().height - itemHeight) / 2, blockWidth[2] - dividerWidth, itemHeight)); } else { __pItems.at(0)->SetBounds(FloatRectangle(0.0f, (GetSizeF().height - itemHeight) / 2, blockWidth[0], itemHeight)); __pItems.at(1)->SetBounds(FloatRectangle(blockWidth[0], (GetSizeF().height - itemHeight) / 2, blockWidth[1], itemHeight)); __pItems.at(2)->SetBounds(FloatRectangle(GetSizeF().width - blockWidth[2], - (GetSizeF().height - itemHeight) / 2, blockWidth[2] + 1, itemHeight)); + (GetSizeF().height - itemHeight) / 2, blockWidth[2], itemHeight)); } } + for (int i = 0; i < 3; i++) + { + __pItems.at(i)->SetBounds(CoordinateSystem::AlignToDevice(__pItems.at(i)->GetBoundsF())); + + } + for (int i = 0; i < __itemCount; i++) { if (__pItems.at(i)->GetChildCount() != 0) -- 2.7.4