QPainterPath UBGraphicsCompass::pencilShape() const { int penWidthIndex = UBSettings::settings()->penWidthIndex(); int logicalCompassPencilWidth = penWidthIndex > 1 ? 8 : (penWidthIndex > 0 ? 4 : 2); QPainterPath path; path.moveTo(rect().right() - sPencilLength, rect().center().y() - logicalCompassPencilWidth / 2); path.lineTo(rect().right() - logicalCompassPencilWidth / 2, rect().center().y() - logicalCompassPencilWidth / 2); QRectF tipRect(rect().right() - logicalCompassPencilWidth, rect().center().y() - logicalCompassPencilWidth / 2, logicalCompassPencilWidth, logicalCompassPencilWidth); path.arcTo(tipRect, 90, -180); path.lineTo(rect().right() - sPencilLength, rect().center().y() + logicalCompassPencilWidth / 2); path.closeSubpath(); return path; }
void CUIWindowItem::PositionSelf() { if( m_pWindow ) { CEGUI::MouseCursor& cursor = CEGUI::MouseCursor::getSingleton(); CEGUI::Rect screen( CEGUI::System::getSingleton().getRenderer()->getRect()); CEGUI::Rect tipRect( m_pWindow->getUnclippedPixelRect()); const CEGUI::Image* mouseImage = cursor.getImage(); CEGUI::Point mousePos(cursor.getPosition()); CEGUI::Size mouseSz(0,0); if (mouseImage) { mouseSz = mouseImage->getSize(); } CEGUI::Point tmpPos(mousePos.d_x - tipRect.getWidth() - 5, mousePos.d_y - tipRect.getHeight() - 5); tipRect.setPosition(tmpPos); // if tooltip would be off the right of the screen, // reposition to the other side of the mouse cursor. if ( tipRect.d_right < 0 ) { tmpPos.d_x = mousePos.d_x + mouseSz.d_width + 5; } // if tooltip would be off the bottom of the screen, // reposition to the other side of the mouse cursor. if ( tipRect.d_bottom < 0 ) { tmpPos.d_y = mousePos.d_y + mouseSz.d_height + 5; } // set final position of tooltip window. m_pWindow->setPosition( CEGUI::Absolute, tmpPos); } }
void Tooltip::positionSelf(void) { MouseCursor& cursor = MouseCursor::getSingleton(); Rect screen(Vector2(0, 0), System::getSingleton().getRenderer()->getDisplaySize()); Rect tipRect(getUnclippedOuterRect()); const Image* mouseImage = cursor.getImage(); Point mousePos(cursor.getPosition()); Size mouseSz(0,0); if (mouseImage) { mouseSz = mouseImage->getSize(); } Point tmpPos(mousePos.d_x + mouseSz.d_width, mousePos.d_y + mouseSz.d_height); tipRect.setPosition(tmpPos); // if tooltip would be off the right of the screen, // reposition to the other side of the mouse cursor. if (screen.d_right < tipRect.d_right) { tmpPos.d_x = mousePos.d_x - tipRect.getWidth() - 5; } // if tooltip would be off the bottom of the screen, // reposition to the other side of the mouse cursor. if (screen.d_bottom < tipRect.d_bottom) { tmpPos.d_y = mousePos.d_y - tipRect.getHeight() - 5; } // set final position of tooltip window. setPosition( UVector2(cegui_absdim(tmpPos.d_x), cegui_absdim(tmpPos.d_y))); }