// MouseMoved void MultipleManipulatorState::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) { if (fCurrentManipulator) { // the mouse is currently pressed fCurrentManipulator->MouseMoved(where); } else { // the mouse is currently NOT pressed // call MouseOver on all manipulators // until one feels responsible int32 count = fManipulators.CountItems(); bool updateCursor = true; for (int32 i = 0; i < count; i++) { Manipulator* manipulator = (Manipulator*)fManipulators.ItemAtFast(i); if (manipulator->TrackingBounds(fView).Contains(where) && manipulator->MouseOver(where)) { updateCursor = false; break; } } if (updateCursor) _UpdateCursor(); } }
void RoomContainer::MouseOver(uint16 x, uint16 y) { const uint16 kScrollingStep = 64; uint16 horizBorderSize = 35; uint32 vertBorderSize = 40; // TODO: Less hardcoding of the window number Window* window = GUI::Get()->GetWindow(1); if (window != NULL) { horizBorderSize += window->Width(); } sint16 scrollByX = 0; sint16 scrollByY = 0; if (x <= horizBorderSize) scrollByX = -kScrollingStep; else if (x >= fViewPort.w - horizBorderSize) scrollByX = kScrollingStep; if (y <= vertBorderSize) scrollByY = -kScrollingStep; else if (y >= fViewPort.h - vertBorderSize) scrollByY = kScrollingStep; IE::point point = { int16(x), int16(y) }; ConvertToArea(point); _UpdateCursor(x, y, scrollByX, scrollByY); // TODO: This screams for improvements if (fWed != NULL) { int32 cursor = -1; fMouseOverObject = _ObjectAtPoint(point, cursor); if (cursor != -1) GUI::Get()->SetCursor(cursor); } else if (fWorldMap != NULL) { for (uint32 i = 0; i < fWorldMap->CountAreaEntries(); i++) { AreaEntry& area = fWorldMap->AreaEntryAt(i); GFX::rect areaRect = area.Rect(); if (rect_contains(areaRect, point)) { ConvertFromArea(areaRect); ConvertToScreen(areaRect); //char* toolTip = area.TooltipName(); //RenderString(toolTip, GraphicsEngine::Get()->ScreenSurface()); //free(toolTip); GraphicsEngine::Get()->ScreenBitmap()->StrokeRect(areaRect, 600); break; } } } IE::point newAreaOffset = fAreaOffset; newAreaOffset.x += scrollByX; newAreaOffset.y += scrollByY; SetAreaOffset(newAreaOffset); }
//------------------------------------------------------------------------ // mousePos : Screen 상의 마우스 위치 // [2011/2/14 jjuiddong] //------------------------------------------------------------------------ void CTerrainCursor::UpdateCursor(POINT mousePos) { if (!m_pTerrain) return; m_ScreenPos = mousePos; Vector3 pos; if (m_pTerrain->Pick(&Vector2((float)mousePos.x, (float)mousePos.y), &pos)) { m_CursorPos = pos; _UpdateCursor(m_CursorPos); } }
// DeleteManipulators void MultipleManipulatorState::DeleteManipulators() { BRect dirty(LONG_MAX, LONG_MAX, LONG_MIN, LONG_MIN); int32 count = fManipulators.CountItems(); for (int32 i = 0; i < count; i++) { Manipulator* m = (Manipulator*)fManipulators.ItemAtFast(i); dirty = dirty | m->Bounds(); m->DetachedFromView(fView); delete m; } fManipulators.MakeEmpty(); fCurrentManipulator = NULL; fPreviousManipulator = NULL; fView->Invalidate(dirty); _UpdateCursor(); }
//------------------------------------------------------------------------ // 저장된 커서의 위치를 기준으로 커서 모양을 업데이트 한다. // [2011/2/14 jjuiddong] //------------------------------------------------------------------------ void CTerrainCursor::UpdateCursor() { if (!m_pTerrain) return; _UpdateCursor(m_CursorPos); }