本文整理汇总了C++中GuiControl::localToGlobalCoord方法的典型用法代码示例。如果您正苦于以下问题:C++ GuiControl::localToGlobalCoord方法的具体用法?C++ GuiControl::localToGlobalCoord怎么用?C++ GuiControl::localToGlobalCoord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuiControl
的用法示例。
在下文中一共展示了GuiControl::localToGlobalCoord方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onMouseDragged
void GuiTextEditSliderCtrl::onMouseDragged(const GuiEvent &event)
{
// If we're not active then skip out.
if ( !mActive || !mAwake || !mVisible )
{
Parent::onMouseDragged(event);
return;
}
if(mTextAreaHit == None || mTextAreaHit == Slider)
{
mTextAreaHit = Slider;
GuiControl *parent = getParent();
if(!parent)
return;
Point2I camPos = event.mousePoint;
Point2I point = parent->localToGlobalCoord(getPosition());
F32 maxDis = 100;
F32 val;
if(camPos.y < point.y)
{
if((F32)point.y < maxDis)
maxDis = (F32)point.y;
val = point.y - maxDis;
if(point.y > 0)
mMulInc= 1.0f-(((float)camPos.y - val) / maxDis);
else
mMulInc = 1.0f;
checkIncValue();
return;
}
else if(camPos.y > point.y + getExtent().y)
{
GuiCanvas *root = getRoot();
val = (F32)(root->getHeight() - (point.y + getHeight()));
if(val < maxDis)
maxDis = val;
if( val > 0)
mMulInc= -(F32)(camPos.y - (point.y + getHeight()))/maxDis;
else
mMulInc = -1.0f;
checkIncValue();
return;
}
mTextAreaHit = None;
Parent::onMouseDragged(event);
}
}
示例2: onMouseDown
void GuiTextEditSliderCtrl::onMouseDown(const GuiEvent &event)
{
// If we're not active then skip out.
if ( !mActive || !mAwake || !mVisible )
{
Parent::onMouseDown(event);
return;
}
char txt[20];
Parent::getText(txt);
mValue = dAtof(txt);
mMouseDownTime = Sim::getCurrentTime();
GuiControl *parent = getParent();
if(!parent)
return;
Point2I camPos = event.mousePoint;
Point2I point = parent->localToGlobalCoord(getPosition());
if(camPos.x > point.x + getExtent().x - 14)
{
if(camPos.y > point.y + (getExtent().y/2))
{
mValue -=mIncAmount;
mTextAreaHit = ArrowDown;
mMulInc = -0.15f;
}
else
{
mValue +=mIncAmount;
mTextAreaHit = ArrowUp;
mMulInc = 0.15f;
}
checkRange();
setValue();
mouseLock();
// We should get the focus and set the
// cursor to the start of the text to
// mimic the standard Windows behavior.
setFirstResponder();
mCursorPos = mBlockStart = mBlockEnd = 0;
setUpdate();
return;
}
Parent::onMouseDown(event);
}