本文整理汇总了C++中widget::Ptr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::get方法的具体用法?C++ Ptr::get怎么用?C++ Ptr::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类widget::Ptr
的用法示例。
在下文中一共展示了Ptr::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleEvent
bool EventManager::handleEvent(sf::Event& event)
{
// Check if a mouse button has moved
if (event.type == sf::Event::MouseMoved)
{
// Loop through all widgets
for (unsigned int i=0; i<m_Widgets.size(); ++i)
{
// Check if the mouse went down on the widget
if (m_Widgets[i]->m_MouseDown)
{
// Some widgets should always receive mouse move events while dragging them, even if the mouse is no longer on top of them.
if ((m_Widgets[i]->m_DraggableWidget) || (m_Widgets[i]->m_ContainerWidget))
{
m_Widgets[i]->mouseMoved(static_cast<float>(event.mouseMove.x), static_cast<float>(event.mouseMove.y));
return true;
}
}
}
// Check if the mouse is on top of an widget
Widget::Ptr widget = mouseOnWidget(static_cast<float>(event.mouseMove.x), static_cast<float>(event.mouseMove.y));
if (widget != nullptr)
{
// Send the event to the widget
widget->mouseMoved(static_cast<float>(event.mouseMove.x), static_cast<float>(event.mouseMove.y));
return true;
}
return false;
}
// Check if a mouse button was pressed
else if (event.type == sf::Event::MouseButtonPressed)
{
// Check if the left mouse was pressed
if (event.mouseButton.button == sf::Mouse::Left)
{
// Check if the mouse is on top of an widget
Widget::Ptr widget = mouseOnWidget(static_cast<float>(event.mouseButton.x), static_cast<float>(event.mouseButton.y));
if (widget != nullptr)
{
// Focus the widget
focusWidget(widget.get());
// Check if the widget is a container
if (widget->m_ContainerWidget)
{
// If another widget was focused then unfocus it now
if ((m_FocusedWidget) && (m_Widgets[m_FocusedWidget-1] != widget))
{
m_Widgets[m_FocusedWidget-1]->m_Focused = false;
m_Widgets[m_FocusedWidget-1]->widgetUnfocused();
m_FocusedWidget = 0;
}
}
widget->leftMousePressed(static_cast<float>(event.mouseButton.x), static_cast<float>(event.mouseButton.y));
return true;
}
else // The mouse didn't went down on an widget, so unfocus the focused widget
unfocusAllWidgets();
}
return false;
}
// Check if a mouse button was released
else if (event.type == sf::Event::MouseButtonReleased)
{
// Check if the left mouse was released
if (event.mouseButton.button == sf::Mouse::Left)
{
// Check if the mouse is on top of an widget
Widget::Ptr widget = mouseOnWidget(static_cast<float>(event.mouseButton.x), static_cast<float>(event.mouseButton.y));
if (widget != nullptr)
widget->leftMouseReleased(static_cast<float>(event.mouseButton.x), static_cast<float>(event.mouseButton.y));
// Tell all the other widgets that the mouse has gone up
for (std::vector<Widget::Ptr>::iterator it = m_Widgets.begin(); it != m_Widgets.end(); ++it)
{
if (*it != widget)
(*it)->mouseNoLongerDown();
}
if (widget != nullptr)
return true;
}
return false;
}
// Check if a key was pressed
else if (event.type == sf::Event::KeyPressed)
{
// Only continue when the character was recognised
if (event.key.code != sf::Keyboard::Unknown)
{
// Check if there is a focused widget
if (m_FocusedWidget)
//.........这里部分代码省略.........
示例2: remove
void Grid::remove(const Widget::Ptr& widget)
{
remove(widget.get());
}