本文整理汇总了C++中Rect::IsPointIn方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::IsPointIn方法的具体用法?C++ Rect::IsPointIn怎么用?C++ Rect::IsPointIn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect::IsPointIn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnMouseButtonEvent
bool GuiList::OnMouseButtonEvent(const MouseButtonEvent& mbe)
{
if (!IsVisible())
{
return false;
}
Vec2f cursorPos(mbe.x, mbe.y);
if (mbe.button == AMJU_BUTTON_MOUSE_LEFT &&
mbe.isDown)
{
// Stop scrolling, no?
GuiScroll* scroll = dynamic_cast<GuiScroll*>(GetParent());
Assert(scroll);
scroll->StopScrolling();
// Check each item
int selected = -1;
for (unsigned int i = 0; i < m_children.size(); i++)
{
GuiElement* item = m_children[i];
Rect r = GetRect(item);
if (r.IsPointIn(cursorPos))
{
selected = i;
break;
}
}
if (selected != -1)
{
// TODO Should react on mouse up when up item == down item ??
if (IsMultiSel())
{
// Toggle selected flag for this child
SetSelected(selected, !IsSelected(selected));
}
else
{
SetSelected(selected, true);
if (m_singleClickFunc)
{
m_singleClickFunc(this, selected);
}
}
// TODO Why is this a bad idea ?
//m_items[m_selected]->ExecuteCommand();
// Problem with nested item, but should open up on mouse over anyway...
// SetVisible(false); // TODO flag for this behaviour
return true; // handled
}
}
return false; // not handled
}
示例2: OnCursorEvent
bool GuiTextEdit::OnCursorEvent(const CursorEvent& ce)
{
// TODO In drag mode, select part of the text
Rect r = GetRect(this);
if (!r.IsPointIn(Vec2f(ce.x, ce.y)))
{
//return false; // not handled - cursor not in edit box
// We do want to hande this, e.g. if we drag mouse past the right hand end, we want to select all text.
}
if (s_drag && HasFocus())
{
m_selectedText = CalcCursorPos(ce.x);
m_triListSelection = 0;
#ifdef TEXT_EDIT_DEBUG
std::cout << "Selected: m_caret: " << m_caret << " m_selectedText: " << m_selectedText << ": \"";
if (m_caret > m_selectedText)
{
std::cout << m_text.substr(m_selectedText, m_caret - m_selectedText);
}
else
{
std::cout << m_text.substr(m_caret, m_selectedText - m_caret);
}
std::cout << "\"\n";
#endif
}
return false;
}
示例3: OnDoubleClickEvent
bool GuiList::OnDoubleClickEvent(const DoubleClickEvent& dce)
{
if (dce.button != AMJU_BUTTON_MOUSE_LEFT)
{
return false;
}
if (!IsVisible())
{
return false;
}
if (m_doubleClickFunc)
{
Vec2f cursorPos(dce.x, dce.y);
for (unsigned int i = 0; i < m_children.size(); i++)
{
GuiElement* item = m_children[i];
Rect r = GetRect(item);
if (r.IsPointIn(cursorPos))
{
m_doubleClickFunc(this, i);
return true;
}
}
}
return false;
}
示例4: OnMouseButtonEvent
bool GuiTextEdit::OnMouseButtonEvent(const MouseButtonEvent& mbe)
{
if (!IsVisible())
{
return false;
}
Rect r = GetRect(this);
if (!r.IsPointIn(Vec2f(mbe.x, mbe.y)))
{
return false; // not handled - cursor not in edit box
}
// We want to drag to select text even if this is not the focus ?
//if (HasFocus())
{
s_drag = mbe.isDown;
#ifdef TEXT_EDIT_DEBUG
std::cout << "GuiTextEdit Drag is now " << (s_drag ? "ON" : "OFF") << "\n";
#endif
}
// If clicked in bounding rect, this element gets focus
SetHasFocus(true);
if (!mbe.isDown)
{
return true;
}
m_caret = CalcCursorPos(mbe.x);
m_selectedText = m_caret;
m_triListSelection = 0;
#ifdef TEXT_EDIT_DEBUG
std::cout << "MB down, resetting selection trilist.\n";
#endif
return true; // ?
}