本文整理汇总了C++中mygui::Widget::getAbsolutePosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Widget::getAbsolutePosition方法的具体用法?C++ Widget::getAbsolutePosition怎么用?C++ Widget::getAbsolutePosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mygui::Widget
的用法示例。
在下文中一共展示了Widget::getAbsolutePosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getCoordNewWidget
MyGUI::IntCoord WidgetCreatorManager::getCoordNewWidget(const MyGUI::IntPoint& _point)
{
MyGUI::IntPoint point = _point;
if (!MyGUI::InputManager::getInstance().isShiftPressed())
{
point.left += mGridStep / 2;
point.top += mGridStep / 2;
}
MyGUI::Widget* parent = mNewWidget->getParent();
if (parent != nullptr && !mNewWidget->isRootWidget())
point -= parent->getAbsolutePosition();
if (!MyGUI::InputManager::getInstance().isShiftPressed())
{
point.left = toGrid(point.left);
point.top = toGrid(point.top);
}
MyGUI::IntCoord coord = MyGUI::IntCoord(
std::min(mStartPoint.left, point.left),
std::min(mStartPoint.top, point.top),
abs(point.left - mStartPoint.left),
abs(point.top - mStartPoint.top));
return coord;
}
示例2: moveNewWidget
void WidgetCreatorManager::moveNewWidget(const MyGUI::IntPoint& _point)
{
if (mNewWidget == nullptr)
{
// тип виджета может отсутсвовать
if (!MyGUI::WidgetManager::getInstance().isFactoryExist(mWidgetType))
return;
// выделяем верний виджет
if (!mPopupMode)
WidgetSelectorManager::getInstance().selectWidget(mStartPoint);
MyGUI::Widget* parent = WidgetSelectorManager::getInstance().getSelectedWidget();
// пока не найдем ближайшего над нами способного быть родителем
while (parent != nullptr && !WidgetTypes::getInstance().findWidgetStyle(parent->getTypeName())->parent)
parent = parent->getParent();
if (!WidgetTypes::getInstance().findWidgetStyle(mWidgetType)->child)
parent = nullptr;
if (parent != nullptr)
mNewWidget = parent->createWidgetT(
mPopupMode ? MyGUI::WidgetStyle::Popup : MyGUI::WidgetStyle::Child,
mWidgetType,
EditorWidgets::getInstance().getSkinReplace(mWidgetSkin),
MyGUI::IntCoord(),
MyGUI::Align::Default,
DEFAULT_EDITOR_LAYER);
else
mNewWidget = MyGUI::Gui::getInstance().createWidgetT(
mWidgetType,
EditorWidgets::getInstance().getSkinReplace(mWidgetSkin),
MyGUI::IntCoord(),
MyGUI::Align::Default,
DEFAULT_EDITOR_LAYER);
// переводим старт поинт в координаты отца
if (parent != nullptr && !mNewWidget->isRootWidget())
{
if (parent->getClientWidget())
mStartPoint -= parent->getClientWidget()->getAbsolutePosition();
else
mStartPoint -= parent->getAbsolutePosition();
}
if (!MyGUI::InputManager::getInstance().isShiftPressed())
{
mStartPoint.left = Grid::getInstance().toGrid(mStartPoint.left);
mStartPoint.top = Grid::getInstance().toGrid(mStartPoint.top);
}
}
MyGUI::IntCoord coord = getCoordNewWidget(_point);
mNewWidget->setCoord(coord);
eventChangeSelector(true, mNewWidget->getAbsoluteCoord());
}
示例3: updateSelectionFromValue
void WorkspaceControl::updateSelectionFromValue()
{
// саму рамку отображаем в глобальных
if (mCurrentWidget != nullptr)
{
MyGUI::Widget* parent = mCurrentWidget->getParent();
if (parent != nullptr && !mCurrentWidget->isRootWidget())
mAreaSelectorControl->setCoord(mCoordValue + parent->getAbsolutePosition());
else
mAreaSelectorControl->setCoord(mCoordValue);
}
}
示例4: notifyPropertyChangeCoord
void WorkspaceControl::notifyPropertyChangeCoord(MyGUI::Widget* _widget, const MyGUI::IntCoord& _coordValue, const std::string& _owner)
{
if (_owner == "WorkspaceControl" || _widget != mCurrentWidget)
return;
// тут приходит в абсолютных, конвертим в локальные
mCoordValue = _coordValue;
if (mCurrentWidget != nullptr)
{
MyGUI::Widget* parent = mCurrentWidget->getParent();
if (parent != nullptr && !mCurrentWidget->isRootWidget())
mCoordValue = mCoordValue - parent->getAbsolutePosition();
}
updateSelectionFromValue();
}
示例5: notifyChangePosition
void WorkspaceControl::notifyChangePosition()
{
if (!mMoveableWidget)
return;
mCoordValue = mAreaSelectorControl->getCoord();
// конвертируем в локальные координаты
if (mCurrentWidget != nullptr)
{
MyGUI::Widget* parent = mCurrentWidget->getParent();
if (parent != nullptr && !mCurrentWidget->isRootWidget())
mCoordValue = mCoordValue - parent->getAbsolutePosition();
}
// снапим к гриду
if (!MyGUI::InputManager::getInstance().isShiftPressed())
{
MyGUI::IntCoord coord = mCoordValue;
MyGUI::IntCoord actionScale = mAreaSelectorControl->getActionScale();
if (actionScale.left != 0 && actionScale.width != 0)
{
int right = coord.right();
coord.width = toGrid(coord.width + (mGridStep / 2));
coord.left = right - coord.width;
}
else if (actionScale.width != 0)
{
int right = toGrid(coord.right() + (mGridStep / 2));
coord.width = right - coord.left;
}
else if (actionScale.left != 0)
{
coord.left = toGrid(coord.left + (mGridStep / 2));
}
if (actionScale.top != 0 && actionScale.height != 0)
{
int bottom = coord.bottom();
coord.height = toGrid(coord.height + (mGridStep / 2));
coord.top = bottom - coord.height;
}
else if (actionScale.height != 0)
{
int bottom = toGrid(coord.bottom() + (mGridStep / 2));
coord.height = bottom - coord.top;
}
else if (actionScale.top != 0)
{
coord.top = toGrid(coord.top + (mGridStep / 2));
}
if (coord != mCoordValue)
{
mCoordValue = coord;
updateSelectionFromValue();
}
}
if (mCurrentWidget != nullptr)
setWidgetCoord(mCurrentWidget, mCoordValue);
UndoManager::getInstance().addValue(PR_POSITION);
}