using namespace Tizen::Base::Runtime;
using namespace Tizen::Graphics::_Text;
-static const int MAX_COUNT_PER_LINE = 5;
-static const int MIN_COUNT_PER_LINE = 3;
static const int MAX_LINE_COUNT = 32; // Only for index of array
+static const int MAX_ITEM_COUNT = 35;
namespace Tizen { namespace Ui { namespace Controls
{
return E_SUCCESS;
}
+ // GUI guide word: 5x2
bool bitmapOnly = IsLayoutBitmapOnly();
if (bitmapOnly == true)
int itemCount = __pModel->GetItemCount();
float itemWidth = __itemWidth + __itemGap;
float itemHeight = __itemHeight + __itemGap;
+ FloatDimension layoutSize(0.0f, 0.0f);
- if (itemCount <= MAX_COUNT_PER_LINE)
+ if (itemCount > MAX_ITEM_COUNT)
{
- countPerLine = itemCount;
- }
- else
- {
- countPerLine = GetCountPerLine(itemCount, MIN_COUNT_PER_LINE, MAX_COUNT_PER_LINE);
+ SetLastResult(E_MAX_EXCEEDED);
+ return layoutSize;
}
+ countPerLine = GetCountPerLine(itemCount);
+
int lineCount = itemCount / countPerLine;
if (itemCount % countPerLine != 0)
{
lineCount++;
}
- FloatDimension layoutSize(0.0f, 0.0f);
-
- layoutSize.width = countPerLine * __itemWidth + (countPerLine -1) * __itemGap;
- layoutSize.height = lineCount * __itemHeight + (lineCount - 1) *__itemGap;
+ layoutSize.width = countPerLine * __itemWidth + (countPerLine - 1) * __itemGap;
+ int showLineCount = __pContextMenu->GetShowItemMaxCount();
+ if (lineCount > showLineCount)
+ {
+ SetLastResult(E_MAX_EXCEEDED);
+ }
+ else
+ {
+ showLineCount = lineCount;
+ }
+ layoutSize.height = showLineCount * __itemHeight + (showLineCount - 1) *__itemGap;
_ContextMenuItem* pItem = null;
- for (int line = 0; line < lineCount; line++)
+ for (int line = 0; line < showLineCount; line++)
{
float pressedTopMargin = 0.0f, pressedBottomMargin = 0.0f;
if (line == 0)
pressedTopMargin = __bgPressedMargin;
}
- if (line == lineCount - 1)
+ if (line == showLineCount - 1)
{
pressedBottomMargin = __bgPressedMargin;
}
pressedDrawRect.width -= pressedLeftMargin + pressedRightMargin;
pressedDrawRect.height -= pressedTopMargin + pressedBottomMargin;
pItem->SetPressedDrawRect(pressedDrawRect);
+ __showItemCount = index;
}
}
- if (lineCount > __pContextMenu->GetShowItemMaxCount())
- {
- SetLastResult(E_MAX_EXCEEDED);
- }
+ __showItemCount++;
return layoutSize;
int itemCount = __pModel->GetItemCount();
float maxWidth = __itemWidth;
float itemHeight = __itemHeight + __itemGap;
- int lineCount = 1;
+ int lineCount = 1, showLineCount = 0;
float lineWidth = 0.0f;
int lineItemCount = 0;
float x = 0.0f;
FloatDimension layoutSize(__itemWidth, __itemHeight);
layoutSize.width = maxWidth - __itemGap;
- layoutSize.height = lineCount * __itemHeight + (lineCount - 1) *__itemGap;
+ showLineCount = __pContextMenu->GetShowItemMaxCount();
+ if (lineCount > showLineCount)
+ {
+ SetLastResult(E_MAX_EXCEEDED);
+ }
+ else
+ {
+ showLineCount = lineCount;
+ }
+ layoutSize.height = showLineCount * __itemHeight + (showLineCount - 1) *__itemGap;
// divide margin
int itemIndex = 0;
- for (int line = 0; line < lineCount; line++)
+ for (int line = 0; line < showLineCount; line++)
{
FloatRectangle drawRect;
float width = lineWidthList[line];
int count = lineItemCountList[line];
float blank = maxWidth - width;
float addMargin = blank / count;
- if (_FloatCompareGE(blank, 100.0f) && line == lineCount - 1)
+ if (_FloatCompareGE(blank, 100.0f) && line == showLineCount - 1)
{
addMargin = 0.0f;
}
pressedTopMargin = __bgPressedMargin;
}
- if (line == lineCount - 1)
+ if (line == showLineCount - 1)
{
pressedBottomMargin = __bgPressedMargin;
}
pressedDrawRect.width -= pressedLeftMargin + pressedRightMargin;
pressedDrawRect.height -= pressedTopMargin + pressedBottomMargin;
pItem->SetPressedDrawRect(pressedDrawRect);
+ __showItemCount = index;
}
itemIndex += count;
}
- if (lineCount > __pContextMenu->GetShowItemMaxCount())
- {
- SetLastResult(E_MAX_EXCEEDED);
- }
+ __showItemCount++;
return layoutSize;
}
}
int
-_ContextMenuGridPresenter::GetCountPerLine(int count, int min, int max) const
+_ContextMenuGridPresenter::GetCountPerLine(int count) const
{
- int minBlank = max;
- int countPerLine = max;
-
- for (int i = max; i >= min; i--)
- {
- int remainder = count % i;
-
- if (remainder == 0)
- {
- countPerLine = i;
- break;
- }
-
- int blank = i - remainder;
-
- if (blank < minBlank)
- {
- minBlank = blank;
- countPerLine = i;
- }
- }
-
- return countPerLine;
+ static const int countOfX[MAX_ITEM_COUNT + 1] = {0, // not used
+ 1, 2, 3, 4, 5, 3, 4, 4, 5, 5,
+ 4, 4, 5, 5, 5, 4, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5,
+ };
+
+ return countOfX[count];
}
int
return r;
}
-
result
_ContextMenuGridPresenter::DrawArrow(Canvas* pCanvas)
{
result r = E_SUCCESS;
TextSimple* pSimpleText = null;
- int itemCount = __pModel->GetItemCount();
+ int itemCount = __showItemCount;
if (itemCount <= 0)
{