, __itemBitmapHeight(0.0f)
, __itemFontSize(0.0f)
, __dividerHeight(0.0f)
+ , __bgPressedMargin(0.0f)
{
}
GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ICON_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapWidth);
GET_SHAPE_CONFIG(CONTEXTMENU::GRID_ICON_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapHeight);
GET_SHAPE_CONFIG(CONTEXTMENU::GRID_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __dividerHeight);
+ GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_BG_PRESSED_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __bgPressedMargin);
}
_ContextMenuItem*
for (int line = 0; line < lineCount; line++)
{
+ float pressedTopMargin = 0.0f, pressedBottomMargin = 0.0f;
+ if (line == 0)
+ {
+ pressedTopMargin = __bgPressedMargin;
+ }
+
+ if (line == lineCount - 1)
+ {
+ pressedBottomMargin = __bgPressedMargin;
+ }
+
for (int i = 0; i < countPerLine; i++)
{
int index = (line * countPerLine) + i;
drawRect.y = (line * itemHeight);
bool drawDivider = true;
- if (i == countPerLine -1)
+ if (i == countPerLine - 1)
{
drawDivider = false;
}
pItem->SetDrawRect(drawRect);
pItem->SetLowerDivider(drawDivider);
+
+ float pressedLeftMargin = 0.0f, pressedRightMargin = 0.0f;
+ if (i == 0)
+ {
+ pressedLeftMargin = __bgPressedMargin;
+ }
+
+ if (i == countPerLine - 1)
+ {
+ pressedRightMargin = __bgPressedMargin;
+ }
+
+ FloatRectangle pressedDrawRect = drawRect;
+ pressedDrawRect.x += pressedLeftMargin;
+ pressedDrawRect.y += pressedTopMargin;
+ pressedDrawRect.width -= pressedLeftMargin + pressedRightMargin;
+ pressedDrawRect.height -= pressedTopMargin + pressedBottomMargin;
+ pItem->SetPressedDrawRect(pressedDrawRect);
}
}
int itemIndex = 0;
for (int line = 0; line < lineCount; line++)
{
- int width = lineWidthList[line];
+ FloatRectangle drawRect;
+ float width = lineWidthList[line];
int count = lineItemCountList[line];
+ float margin = (maxWidth - width) / count;
- if (maxWidth == width)
+ float pressedTopMargin = 0.0f, pressedBottomMargin = 0.0f;
+ if (line == 0)
{
- itemIndex += count;
- continue;
+ pressedTopMargin = __bgPressedMargin;
}
- int margin = (maxWidth - width) / count;
+ if (line == lineCount - 1)
+ {
+ pressedBottomMargin = __bgPressedMargin;
+ }
for (int i = 0; i < count; i++)
{
break;
}
- FloatRectangle drawRect = pItem->GetDrawRect();
+ drawRect = pItem->GetDrawRect();
drawRect.width = drawRect.width + margin;
drawRect.x = drawRect.x + (i * margin);
pItem->SetDrawRect(drawRect);
+
+ float pressedLeftMargin = 0.0f, pressedRightMargin = 0.0f;
+ if (i == 0)
+ {
+ pressedLeftMargin = __bgPressedMargin;
+ }
+
+ if (i == count - 1)
+ {
+ pressedRightMargin = __bgPressedMargin;
+ }
+
+ FloatRectangle pressedDrawRect = drawRect;
+ pressedDrawRect.x += pressedLeftMargin;
+ pressedDrawRect.y += pressedTopMargin;
+ pressedDrawRect.width -= pressedLeftMargin + pressedRightMargin;
+ pressedDrawRect.height -= pressedTopMargin + pressedBottomMargin;
+ pItem->SetPressedDrawRect(pressedDrawRect);
}
itemIndex += count;
}
FloatRectangle drawRect = pItem->GetDrawRect();
-
drawRect.x += x;
drawRect.y += y;
-
pItem->SetDrawRect(drawRect);
+
+ FloatRectangle pressedDrawRect = pItem->GetPressedDrawRect();
+ pressedDrawRect.x += x;
+ pressedDrawRect.y += y;
+ pItem->SetPressedDrawRect(pressedDrawRect);
}
}
if (__selectedIndex == i)
{
+ FloatRectangle pressedDrawRect = pItem->GetPressedDrawRect();
itemStatus = CONTEXT_MENU_CORE_ITEM_STATUS_PRESSED;
+ Bitmap* bgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(pItem->GetMagentaBgBitmap()), Color::GetColor(COLOR_ID_MAGENTA), pressedColor);
+ SysTryReturn(NID_UI_CTRL, bgBitmap, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
- pCanvas->FillRoundRectangle(pressedColor, rect, FloatDimension(3.0f, 3.0f));
+ DrawBitmap(*pCanvas, pressedDrawRect, *bgBitmap);
+ delete bgBitmap;
+ bgBitmap = null;
}
String text = pItem->GetText();
if (__selectedIndex == i)
{
+ FloatRectangle pressedDrawRect = pItem->GetPressedDrawRect();
itemStatus = CONTEXT_MENU_ITEM_DRAWING_STATUS_PRESSED;
+ Bitmap* bgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*(pItem->GetMagentaBgBitmap()), Color::GetColor(COLOR_ID_MAGENTA), pressedColor);
+ SysTryReturn(NID_UI_CTRL, bgBitmap, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
- pCanvas->FillRoundRectangle(pressedColor, rect, FloatDimension(3.0f, 3.0f));
+ DrawBitmap(*pCanvas, pressedDrawRect, *bgBitmap);
+ delete bgBitmap;
+ bgBitmap = null;
}
const Bitmap* pBitmap = pItem->GetBitmap(itemStatus);