}
// calculate body rect
- // calculate real drawing margin for contextmenu
- float leftMargin = screenLeftMargin;
- float rightMargin = screen.width - screenRightMargin;
- float topMargin = screenTopMargin;
- float bottomMargin = screen.height - screenBottomMargin;
+ // calculate drawable boundaries for contextmenu
+ float leftBoundary = screenLeftMargin;
+ float rightBoundary = screen.width - screenRightMargin;
+ float topBoundary = screenTopMargin;
+ float bottomBoundary = screen.height - screenBottomMargin;
if (__pModel->GetItemCount() <= 0)
{
{
// Check touch position
// - Check left margin
- if (anchorPosition.x <= leftMargin + arrowRect.width)
+ if (anchorPosition.x <= leftBoundary + arrowRect.width)
{
- anchorPosition.x = leftMargin + arrowRect.width;
+ anchorPosition.x = leftBoundary + arrowRect.width;
}
// - check right margin
- if (anchorPosition.x >= (rightMargin - arrowRect.width))
+ if (anchorPosition.x >= (rightBoundary - arrowRect.width))
{
- anchorPosition.x = rightMargin - arrowRect.width;
+ anchorPosition.x = rightBoundary - arrowRect.width;
}
// - check top margin
- if (anchorPosition.y <= topMargin)
+ if (anchorPosition.y <= topBoundary)
{
- anchorPosition.y = topMargin + bodyRect.height;
+ anchorPosition.y = topBoundary + bodyRect.height;
}
// - check bottom margin
- if (anchorPosition.y >= bottomMargin)
+ if (anchorPosition.y >= bottomBoundary)
{
- anchorPosition.y = bottomMargin;
+ anchorPosition.y = bottomBoundary;
}
// Set body position x
bodyRect.x = anchorPosition.x - (bodyRect.width / 2.0f);
// - Check left margin
- if (bodyRect.x <= leftMargin)
+ if (bodyRect.x <= leftBoundary)
{
- bodyRect.x = leftMargin;
+ bodyRect.x = leftBoundary;
}
// - check right margin
- if ((bodyRect.x + bodyRect.width) >= rightMargin)
+ if ((bodyRect.x + bodyRect.width) >= rightBoundary)
{
- bodyRect.x = rightMargin - bodyRect.width;
+ bodyRect.x = rightBoundary - bodyRect.width;
}
// Set body position y
bodyRect.y = anchorPosition.y - arrowRect.height - bodyRect.height;
// - check top margin
- if (bodyRect.y <= topMargin)
+ if (bodyRect.y <= topBoundary)
{
- bodyRect.y = topMargin;
+ bodyRect.y = topBoundary;
}
windowRect.x = bodyRect.x;
{
// Check touch position
// - Check left margin
- if (anchorPosition.x <= leftMargin + arrowRect.width)
+ if (anchorPosition.x <= leftBoundary + arrowRect.width)
{
- anchorPosition.x = leftMargin + arrowRect.width;
+ anchorPosition.x = leftBoundary + arrowRect.width;
}
// - check right margin
- if (anchorPosition.x >= (rightMargin - arrowRect.width))
+ if (anchorPosition.x >= (rightBoundary - arrowRect.width))
{
- anchorPosition.x = rightMargin - arrowRect.width;
+ anchorPosition.x = rightBoundary - arrowRect.width;
}
// - check top margin
- if (anchorPosition.y <= topMargin)
+ if (anchorPosition.y <= topBoundary)
{
- anchorPosition.y = topMargin;
+ anchorPosition.y = topBoundary;
}
// - check bottom margin
- if (anchorPosition.y >= bottomMargin)
+ if (anchorPosition.y >= bottomBoundary)
{
- anchorPosition.y = bottomMargin;
+ anchorPosition.y = bottomBoundary;
}
// Set body position x
bodyRect.x = anchorPosition.x - (bodyRect.width / 2.0f);
// - Check left margin
- if (bodyRect.x <= leftMargin)
+ if (bodyRect.x <= leftBoundary)
{
- bodyRect.x = leftMargin;
+ bodyRect.x = leftBoundary;
}
// - check right margin
- if ((bodyRect.x + bodyRect.width) >= rightMargin)
+ if ((bodyRect.x + bodyRect.width) >= rightBoundary)
{
- bodyRect.x = rightMargin - bodyRect.width;
+ bodyRect.x = rightBoundary - bodyRect.width;
}
// Set body position y
bodyRect.y = anchorPosition.y + arrowRect.height;
// - Check bottom margin
- if ((bodyRect.y + bodyRect.height) >= bottomMargin)
+ if ((bodyRect.y + bodyRect.height) >= bottomBoundary)
{
- bodyRect.y = bottomMargin - bodyRect.height;
+ bodyRect.y = bottomBoundary - bodyRect.height;
}
windowRect.x = bodyRect.x;
{
// Check touch position
// - Check left margin
- if (anchorPosition.x <= leftMargin)
+ if (anchorPosition.x <= leftBoundary)
{
- anchorPosition.x = leftMargin + bodyRect.width;
+ anchorPosition.x = leftBoundary + bodyRect.width;
}
// - check right margin
- if (anchorPosition.x >= rightMargin)
+ if (anchorPosition.x >= rightBoundary)
{
- anchorPosition.x = rightMargin;
+ anchorPosition.x = rightBoundary;
}
// - Check top margin
- if (anchorPosition.y <= topMargin + arrowRect.height)
+ if (anchorPosition.y <= topBoundary + arrowRect.height)
{
- anchorPosition.y = topMargin + arrowRect.height;
+ anchorPosition.y = topBoundary + arrowRect.height;
}
// - check bottom margin
- if (anchorPosition.y >= (bottomMargin - arrowRect.height))
+ if (anchorPosition.y >= (bottomBoundary - arrowRect.height))
{
- anchorPosition.y = bottomMargin - arrowRect.height;
+ anchorPosition.y = bottomBoundary - arrowRect.height;
}
// Set body position x
bodyRect.x = anchorPosition.x - arrowRect.width - bodyRect.width;
// - Check left margin
- if (bodyRect.x <= leftMargin)
+ if (bodyRect.x <= leftBoundary)
{
- bodyRect.x = leftMargin;
+ bodyRect.x = leftBoundary;
}
// - check right margin
- if ((bodyRect.x + bodyRect.width + arrowRect.width) >= rightMargin)
+ if ((bodyRect.x + bodyRect.width + arrowRect.width) >= rightBoundary)
{
- bodyRect.x = rightMargin - bodyRect.width - arrowRect.width;
+ bodyRect.x = rightBoundary - bodyRect.width - arrowRect.width;
}
// Set body position y
bodyRect.y = anchorPosition.y - (bodyRect.height / 2.0f);
// - check top margin
- if (bodyRect.y <= topMargin)
+ if (bodyRect.y <= topBoundary)
{
- bodyRect.y = topMargin;
+ bodyRect.y = topBoundary;
}
// - check bottom margin
- if ((bodyRect.y + bodyRect.height) >= bottomMargin)
+ if ((bodyRect.y + bodyRect.height) >= bottomBoundary)
{
- bodyRect.y = bottomMargin - bodyRect.height;
+ bodyRect.y = bottomBoundary - bodyRect.height;
}
windowRect.x = bodyRect.x;
{
// Check touch position
// - Check top margin
- if (anchorPosition.x <= leftMargin)
+ if (anchorPosition.x <= leftBoundary)
{
- anchorPosition.x = leftMargin;
+ anchorPosition.x = leftBoundary;
}
// - check right margin
- if (anchorPosition.x >= rightMargin)
+ if (anchorPosition.x >= rightBoundary)
{
- anchorPosition.x = rightMargin - bodyRect.width;
+ anchorPosition.x = rightBoundary - bodyRect.width;
}
// - Check top margin
- if (anchorPosition.y <= topMargin + arrowRect.height)
+ if (anchorPosition.y <= topBoundary + arrowRect.height)
{
- anchorPosition.y = topMargin + arrowRect.height;
+ anchorPosition.y = topBoundary + arrowRect.height;
}
// - check bottom margin
- if (anchorPosition.y >= (bottomMargin - arrowRect.height))
+ if (anchorPosition.y >= (bottomBoundary - arrowRect.height))
{
- anchorPosition.y = bottomMargin - arrowRect.height;
+ anchorPosition.y = bottomBoundary - arrowRect.height;
}
// Set body position x
bodyRect.x = anchorPosition.x + arrowRect.width;
// - Check left margin
- if (bodyRect.x <= leftMargin)
+ if (bodyRect.x <= leftBoundary)
{
- bodyRect.x = leftMargin;
+ bodyRect.x = leftBoundary;
}
// - check right margin
- if ((bodyRect.x + bodyRect.width) >= rightMargin)
+ if ((bodyRect.x + bodyRect.width + arrowRect.width) >= rightBoundary)
{
- bodyRect.x = rightMargin - bodyRect.width;
+ bodyRect.x = rightBoundary - bodyRect.width - arrowRect.width;
}
// Set body position y
bodyRect.y = anchorPosition.y - (bodyRect.height / 2);
// - check top margin
- if (bodyRect.y <= topMargin)
+ if (bodyRect.y <= topBoundary)
{
- bodyRect.y = topMargin;
+ bodyRect.y = topBoundary;
}
// - check bottom margin
- if ((bodyRect.y + bodyRect.height) >= bottomMargin)
+ if ((bodyRect.y + bodyRect.height) >= bottomBoundary)
{
- bodyRect.y = bottomMargin - bodyRect.height;
+ bodyRect.y = bottomBoundary - bodyRect.height;
}
- windowRect.x = bodyRect.x + arrowRect.width;
+ windowRect.x = bodyRect.x - arrowRect.width;
windowRect.y = bodyRect.y;
windowRect.width = bodyRect.width + arrowRect.width;
windowRect.height = bodyRect.height;
}
// calculate body rect
- // calculate real drawing margin for contextmenu
- float leftMargin = screenLeftMargin;
- float rightMargin = screen.width - screenRightMargin;
- float topMargin = screenTopMargin;
- float bottomMargin = screen.height - screenBottomMargin;
+ // calculate drawable boundaries for contextmenu
+ float leftBoundary = screenLeftMargin;
+ float rightBoundary = screen.width - screenRightMargin;
+ float topBoundary = screenTopMargin;
+ float bottomBoundary = screen.height - screenBottomMargin;
// calculate layout size (__layoutSize)
AdjustItemLayout();
{
// Check touch position
// - Check left margin
- if (anchorPosition.x <= leftMargin + arrowRect.width)
+ if (anchorPosition.x <= leftBoundary + arrowRect.width)
{
- anchorPosition.x = leftMargin + arrowRect.width;
+ anchorPosition.x = leftBoundary + arrowRect.width;
}
// - check right margin
- if (anchorPosition.x >= (rightMargin - arrowRect.width))
+ if (anchorPosition.x >= (rightBoundary - arrowRect.width))
{
- anchorPosition.x = rightMargin - arrowRect.width;
+ anchorPosition.x = rightBoundary - arrowRect.width;
}
// - check top margin
- if (anchorPosition.y <= topMargin)
+ if (anchorPosition.y <= topBoundary)
{
- anchorPosition.y = topMargin + bodyRect.height;
+ anchorPosition.y = topBoundary + bodyRect.height;
}
// - check bottom margin
- if (anchorPosition.y >= bottomMargin)
+ if (anchorPosition.y >= bottomBoundary)
{
- anchorPosition.y = bottomMargin;
+ anchorPosition.y = bottomBoundary;
}
// Set body position x
bodyRect.x = anchorPosition.x - (bodyRect.width / 2.0f);
// - Check left margin
- if (bodyRect.x <= leftMargin)
+ if (bodyRect.x <= leftBoundary)
{
- bodyRect.x = leftMargin;
+ bodyRect.x = leftBoundary;
}
// - check right margin
- if ((bodyRect.x + bodyRect.width) >= rightMargin)
+ if ((bodyRect.x + bodyRect.width) >= rightBoundary)
{
- bodyRect.x = rightMargin - bodyRect.width;
+ bodyRect.x = rightBoundary - bodyRect.width;
}
// Set body position y
bodyRect.y = anchorPosition.y - arrowRect.height - bodyRect.height;
// - check top margin
- if (bodyRect.y <= topMargin)
+ if (bodyRect.y <= topBoundary)
{
- bodyRect.y = topMargin;
+ bodyRect.y = topBoundary;
}
windowRect.x = bodyRect.x;
{
// Check touch position
// - Check left margin
- if (anchorPosition.x <= leftMargin + arrowRect.width)
+ if (anchorPosition.x <= leftBoundary + arrowRect.width)
{
- anchorPosition.x = leftMargin + arrowRect.width;
+ anchorPosition.x = leftBoundary + arrowRect.width;
}
// - check right margin
- if (anchorPosition.x >= (rightMargin - arrowRect.width))
+ if (anchorPosition.x >= (rightBoundary - arrowRect.width))
{
- anchorPosition.x = rightMargin - arrowRect.width;
+ anchorPosition.x = rightBoundary - arrowRect.width;
}
// - check top margin
- if (anchorPosition.y <= topMargin)
+ if (anchorPosition.y <= topBoundary)
{
- anchorPosition.y = topMargin;
+ anchorPosition.y = topBoundary;
}
// - check bottom margin
- if (anchorPosition.y >= bottomMargin)
+ if (anchorPosition.y >= bottomBoundary)
{
- anchorPosition.y = bottomMargin;
+ anchorPosition.y = bottomBoundary;
}
// Set body position x
bodyRect.x = anchorPosition.x - (bodyRect.width / 2.0f);
// - Check left margin
- if (bodyRect.x <= leftMargin)
+ if (bodyRect.x <= leftBoundary)
{
- bodyRect.x = leftMargin;
+ bodyRect.x = leftBoundary;
}
// - check right margin
- if ((bodyRect.x + bodyRect.width) >= rightMargin)
+ if ((bodyRect.x + bodyRect.width) >= rightBoundary)
{
- bodyRect.x = rightMargin - bodyRect.width;
+ bodyRect.x = rightBoundary - bodyRect.width;
}
// Set body position y
bodyRect.y = anchorPosition.y + arrowRect.height;
// - Check bottom margin
- if ((bodyRect.y + bodyRect.height) >= bottomMargin)
+ if ((bodyRect.y + bodyRect.height) >= bottomBoundary)
{
- bodyRect.y = bottomMargin - bodyRect.height;
+ bodyRect.y = bottomBoundary - bodyRect.height;
}
windowRect.x = bodyRect.x;
{
// Check touch position
// - Check left margin
- if (anchorPosition.x <= leftMargin)
+ if (anchorPosition.x <= leftBoundary)
{
- anchorPosition.x = leftMargin + bodyRect.width;
+ anchorPosition.x = leftBoundary + bodyRect.width;
}
// - check right margin
- if (anchorPosition.x >= rightMargin)
+ if (anchorPosition.x >= rightBoundary)
{
- anchorPosition.x = rightMargin;
+ anchorPosition.x = rightBoundary;
}
// - Check top margin
- if (anchorPosition.y <= topMargin + arrowRect.height)
+ if (anchorPosition.y <= topBoundary + arrowRect.height)
{
- anchorPosition.y = topMargin + arrowRect.height;
+ anchorPosition.y = topBoundary + arrowRect.height;
}
// - check bottom margin
- if (anchorPosition.y >= (bottomMargin - arrowRect.height))
+ if (anchorPosition.y >= (bottomBoundary - arrowRect.height))
{
- anchorPosition.y = bottomMargin - arrowRect.height;
+ anchorPosition.y = bottomBoundary - arrowRect.height;
}
// Set body position x
bodyRect.x = anchorPosition.x - arrowRect.width - bodyRect.width;
// - Check left margin
- if (bodyRect.x <= leftMargin)
+ if (bodyRect.x <= leftBoundary)
{
- bodyRect.x = leftMargin;
+ bodyRect.x = leftBoundary;
}
// - check right margin
- if ((bodyRect.x + bodyRect.width + arrowRect.width) >= rightMargin)
+ if ((bodyRect.x + bodyRect.width + arrowRect.width) >= rightBoundary)
{
- bodyRect.x = rightMargin - bodyRect.width - arrowRect.width;
+ bodyRect.x = rightBoundary - bodyRect.width - arrowRect.width;
}
// Set body position y
bodyRect.y = anchorPosition.y - (bodyRect.height / 2.0f);
// - check top margin
- if (bodyRect.y <= topMargin)
+ if (bodyRect.y <= topBoundary)
{
- bodyRect.y = topMargin;
+ bodyRect.y = topBoundary;
}
// - check bottom margin
- if ((bodyRect.y + bodyRect.height) >= bottomMargin)
+ if ((bodyRect.y + bodyRect.height) >= bottomBoundary)
{
- bodyRect.y = bottomMargin - bodyRect.height;
+ bodyRect.y = bottomBoundary - bodyRect.height;
}
windowRect.x = bodyRect.x;
{
// Check touch position
// - Check top margin
- if (anchorPosition.x <= leftMargin)
+ if (anchorPosition.x <= leftBoundary)
{
- anchorPosition.x = leftMargin;
+ anchorPosition.x = leftBoundary;
}
// - check right margin
- if (anchorPosition.x >= rightMargin)
+ if (anchorPosition.x >= rightBoundary)
{
- anchorPosition.x = rightMargin - bodyRect.width;
+ anchorPosition.x = rightBoundary - bodyRect.width;
}
// - Check top margin
- if (anchorPosition.y <= topMargin + arrowRect.height)
+ if (anchorPosition.y <= topBoundary + arrowRect.height)
{
- anchorPosition.y = topMargin + arrowRect.height;
+ anchorPosition.y = topBoundary + arrowRect.height;
}
// - check bottom margin
- if (anchorPosition.y >= (bottomMargin - arrowRect.height))
+ if (anchorPosition.y >= (bottomBoundary - arrowRect.height))
{
- anchorPosition.y = bottomMargin - arrowRect.height;
+ anchorPosition.y = bottomBoundary - arrowRect.height;
}
// Set body position x
bodyRect.x = anchorPosition.x + arrowRect.width;
// - Check left margin
- if (bodyRect.x <= leftMargin)
+ if (bodyRect.x <= leftBoundary)
{
- bodyRect.x = leftMargin;
+ bodyRect.x = leftBoundary;
}
// - check right margin
- if ((bodyRect.x + bodyRect.width) >= rightMargin)
+ if ((bodyRect.x + bodyRect.width + arrowRect.width) >= rightBoundary)
{
- bodyRect.x = rightMargin - bodyRect.width;
+ bodyRect.x = rightBoundary - bodyRect.width - arrowRect.width;
}
// Set body position y
bodyRect.y = anchorPosition.y - (bodyRect.height / 2.0f);
// - check top margin
- if (bodyRect.y <= topMargin)
+ if (bodyRect.y <= topBoundary)
{
- bodyRect.y = topMargin;
+ bodyRect.y = topBoundary;
}
// - check bottom margin
- if ((bodyRect.y + bodyRect.height) >= bottomMargin)
+ if ((bodyRect.y + bodyRect.height) >= bottomBoundary)
{
- bodyRect.y = bottomMargin - bodyRect.height;
+ bodyRect.y = bottomBoundary - bodyRect.height;
}
- windowRect.x = bodyRect.x + arrowRect.width;
+ windowRect.x = bodyRect.x - arrowRect.width;
windowRect.y = bodyRect.y;
windowRect.width = bodyRect.width + arrowRect.width;
windowRect.height = bodyRect.height;