//---------------------------------------------------------- //Pinch controll //---------------------------------------------------------- void TapCamera::BeginPinch( const Vec2& v1, const Vec2& v2 ) { if( dragging_ ) EndDrag(); if( pinching_ ) EndPinch(); BeginDrag( Vec2() ); vec_pinch_start_center_ = (v1 + v2) / 2.f; Vec2 vec = v1 - v2; float x_diff; float y_diff; vec.Value( x_diff, y_diff ); pinch_start_distance_SQ_ = x_diff * x_diff + y_diff * y_diff; camera_rotation_start_ = atan2f( y_diff, x_diff ); camera_rotation_now_ = 0; pinching_ = true; momentum_ = false; //Init momentum factors vec_offset_delta_ = Vec3(); }
/** * Mouse event handler */ void MouseCallback(int button, int state, int x, int y) { // If in trampoline mode, begin or end drag as appropriate if(trampoline) { if(button == GLUT_LEFT_BUTTON) { if(state == GLUT_DOWN) BeginDrag(x,y); else if(dragging && state == GLUT_UP) EndDrag(); return; } } if (button == GLUT_LEFT_BUTTON || button == GLUT_RIGHT_BUTTON) { gMouseButton = button; } else { gMouseButton = -1; } if (state == GLUT_UP) { gPreviousMouseX = -1; gPreviousMouseY = -1; } }
// /// Handle the DRAGLISTMSGSTRING notification by calling virtual functions /// based on the notification message. // /// Responds to the DL_BEGINDRAG, DL_DRAGGING, DL_DROPPED, and DL_CANCELDRAG /// messages by calling the BeginDrag, Dragging, Dropped, and CancelDrag functions /// respectively. // TResult TDragList::DragNotify(TParam1, TParam2 lp) { DRAGLISTINFO * info = (DRAGLISTINFO *)lp; if (info) { TPoint p = info->ptCursor; int item = ItemFromPoint(p); switch (info->uNotification) { case DL_BEGINDRAG: return BeginDrag(item, p); case DL_DRAGGING: return Dragging(item, p); case DL_DROPPED: Dropped(item, p); break; case DL_CANCELDRAG: CancelDrag(item, p); break; default: // Should not ever happen. ///TH perhaps throw an exception? break; } } return 0; }
void wxBasePlayerGameListCtrl::LeftDown(wxMouseEvent &event) { wxInt32 index = HitTest(event.GetPosition()); if(-1 != index) { // See if there's a player there. ColorType color = static_cast<ColorType>(index); ColorMap::const_iterator it = sPlayers.find(color); if(sPlayers.end() != it) { const Player &player = it->second; // Ensure that this player is allowed to be moved. DataObject input(player), output; RULE.Decide(shLogicUIAllowColorChange, input, output); if(true == output.read<bool>()) { // Set the index being dragged. mDragIndex = index; // Drag and drop. BeginDrag(player); } } } }
void iArmyListEx::OnMouseTrack(const iPoint& pos) { if (m_pDragItem) { Drag(pos); } else if (m_pArmy && pos.GetSqDelta(m_dragAnchor) > DRAG_DELTA && m_dCell != -1 && m_pArmy->At(m_dCell).IsValid()) { BeginDrag(m_dCell, m_pArmy->At(m_dCell), pos); m_dCell = -1; } }
FReply STrackNode::OnDragDetected( const FGeometry& MyGeometry, const FPointerEvent& MouseEvent ) { if (AllowDrag && MouseEvent.IsMouseButtonDown( EKeys::LeftMouseButton ) ) { bBeingDragged = true; return BeginDrag( MyGeometry, MouseEvent ); } return FReply::Unhandled(); }
bool myDragImage::StartDrag() { BeginDrag( wxPoint(0, 0),editor, false ); wxPoint pt = editor->ScreenToClient(wxGetMousePosition()); // Store the initial x position, as we know it must be in the bp margin m_startx = pt.x; Move(pt); Show(); return false; }
void TrackballManipulator::OnMouseButtonPressed(const Mouse::Button& pButton) { if(pButton != Mouse::Button_Left || !HasFocus()) return; Int32 x, y; InputSubsystem::GetMouse().GetPos(x, y); QPoint widgetPos = mEditor->GetMainView()->mapFromGlobal(QPoint(x, y)); BeginDrag(); // #TODO: Fix for no command /* mOldObjectOrientation = mEntityProperties->GetOrientation(); */ }
// Begin drag. hotspot is the location of the drag position relative to the upper-left // corner of the image. This is full screen only. fullScreenRect gives the // position of the window on the screen, to restrict the drag to. bool wxDragImage::BeginDrag(const wxPoint& hotspot, wxWindow* window, wxWindow* fullScreenRect) { wxRect rect; int x = fullScreenRect->GetPosition().x; int y = fullScreenRect->GetPosition().y; wxSize sz = fullScreenRect->GetSize(); if (fullScreenRect->GetParent() && !fullScreenRect->IsKindOf(CLASSINFO(wxFrame))) fullScreenRect->GetParent()->ClientToScreen(& x, & y); rect.x = x; rect.y = y; rect.width = sz.x; rect.height = sz.y; return BeginDrag(hotspot, window, true, & rect); }
//----------------------------------------------------------------------------- // Purpose: // Input : nFlags - // point - //----------------------------------------------------------------------------- void CGroupList::OnMouseMove(UINT nFlags, CPoint point) { CTreeCtrl::OnMouseMove(nFlags, point); if (m_bRButtonDown && !m_hDragItem && (point.x != m_ptRButtonDown.x) && (point.y != m_ptRButtonDown.y)) { // First mouse move since a right button down. Start dragging. HTREEITEM hItem = HitTest(m_ptRButtonDown); BeginDrag(point, hItem); } if (!m_hDragItem) { return; } if (m_pDragImageList) { m_pDragImageList->DragMove(point); } // // Highlight the item we hit. // HTREEITEM hItem = HitTest(point); if (hItem == GetDropHilightItem()) { return; } // hide image first if (m_pDragImageList) { m_pDragImageList->DragLeave(this); m_pDragImageList->DragShowNolock(FALSE); } SelectDropTarget(hItem); if (m_pDragImageList) { m_pDragImageList->DragEnter(this, point); } }
//---------------------------------------------------------------------------// // OnMouseDown // //---------------------------------------------------------------------------// void CMGTreeView::OnMouseDown(int iX, int iY, int iButton) { CMGControl::OnMouseDown(iX,iY,iButton); if (iButton == 1) { int Offset = m_ScrollBar->IsVisible() ? (int)(m_ScrollBar->GetPos() * (m_Root->GetTotalHeight() - Height())) : 0; CMGTreeItem *pItemAt = GetItemAt(iX, iY+Offset); if (pItemAt) { if (pItemAt->IsFolder()) { if (iX < (pItemAt->Left()+12)) { if (pItemAt->IsExpanded()) pItemAt->Collapse(); else pItemAt->Expand(); } else { SelectItem(pItemAt); } } else { if (iX >= (pItemAt->Left()+12)) { SelectItem(pItemAt); BeginDrag (); } } } } else if (m_ScrollBar->IsVisible()) { if (iButton == 4) m_ScrollBar->SetPos(m_ScrollBar->GetPos()-0.1f); else if (iButton == 5) m_ScrollBar->SetPos(m_ScrollBar->GetPos()+0.1f); } Update(); }
void TapCamera::Update() { if( momentum_ ) { float momenttum_steps = momemtum_steps_; //Momentum rotation Vec2 v = vec_drag_delta_; BeginDrag( Vec2() ); //NOTE:This call reset _VDragDelta Drag( v * vec_flip_ ); //Momentum shift vec_offset_ += vec_offset_delta_; BallUpdate(); EndDrag(); //Decrease deltas vec_drag_delta_ = v * MOMENTUM_FACTOR_DECREASE; vec_offset_delta_ = vec_offset_delta_ * MOMENTUM_FACTOR_DECREASE_SHIFT; //Count steps momemtum_steps_ = momenttum_steps * MOMENTUM_FACTOR_DECREASE; if( momemtum_steps_ < MOMENTUM_FACTOR_THRESHOLD ) { momentum_ = false; } } else { vec_drag_delta_ *= MOMENTUM_FACTOR; vec_offset_delta_ = vec_offset_delta_ * MOMENTUM_FACTOR; BallUpdate(); } Vec3 vec = vec_offset_ + vec_offset_now_; Vec3 vec_tmp( TRANSFORM_FACTOR, -TRANSFORM_FACTOR, TRANSFORM_FACTORZ ); vec *= vec_tmp * vec_pinch_transform_factor_; mat_transform_ = Mat4::Translation( vec ); }
BOOL CPaletteBar::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult) { if (message == WM_NOTIFY) { NMHDR *pNMHDR = (NMHDR *) lParam; switch (pNMHDR->code) { case TBN_BEGINADJUST : return BeginAdjust(wParam, lParam, pLResult); case TBN_BEGINDRAG: return BeginDrag(wParam, lParam, pLResult); case TBN_CUSTHELP: return CustomizeHelp(wParam, lParam, pLResult); case TBN_ENDADJUST: return EndAdjust(wParam, lParam, pLResult); case TBN_ENDDRAG: return EndDrag(wParam, lParam, pLResult); case TBN_GETBUTTONINFO: return GetButtonInfo(wParam, lParam, pLResult); case TBN_QUERYDELETE: return QueryDelete(wParam, lParam, pLResult); case TBN_QUERYINSERT: return QueryInsert(wParam, lParam, pLResult); case TBN_RESET: return Reset(wParam, lParam, pLResult); case TBN_TOOLBARCHANGE: return ToolBarChange(wParam, lParam, pLResult); } } return CToolBarCtrl::OnChildNotify(message, wParam, lParam, pLResult); }
void CCustomTabCtrl::OnMouseMove(UINT nFlags, CPoint point) { if (nFlags&MK_LBUTTON && md == 1) { if (abs(point.x - oldp.x) > 4) { if (::GetCapture() != m_hWnd) ::SetCapture(m_hWnd); // SetCursor(CTermView::hand_cursor); md = 2; BeginDrag(point); } } if (dragimg) { ClientToScreen(&point); dragimg->DragShowNolock(TRUE); dragimg->DragMove(point); } CTabCtrl::OnMouseMove(nFlags, point); }
void EditView::MouseMove( const Point& cNewPos, int nCode, uint32 nButtons, Message* pcData ) { if ( (nButtons & 0x01) == 0 ) { return; } if ( pcData != NULL ) { return; } Message* pcMsg = NULL; Point cOffset; Rect cFrame; if ( m_cLargeRect.DoIntersect( cNewPos ) ) { pcMsg = new Message( ID_DRAG_LARGE ); cFrame = Rect( 0, 0, 31, 31 ); cOffset = cNewPos - m_cLargeRect.LeftTop(); } else if ( m_cSmallRect.DoIntersect( cNewPos ) ) { pcMsg = new Message( ID_DRAG_SMALL ); cFrame = Rect( 0, 0, 15, 15 ); cOffset = cNewPos - m_cSmallRect.LeftTop(); } if ( pcMsg != NULL ) { BeginDrag( pcMsg, cOffset, cFrame ); } }
//-------------------------------------------------------------------// // OnBegindrag() // //-------------------------------------------------------------------// // Catches LVN_BEGINDRAG messages, so we can let MS tell us when // to begin dragging. //-------------------------------------------------------------------// void OleListCtrl::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult) { m_bDeselectOnNoDrag &= !BeginDrag( m_nLastUnderCursor, 0 ); *pResult = 0; }
/** \brief DragSelection callback. * Handles the results of a drag selection. */ void RemoteIconView::DragSelection( Point cStartPoint ) { /* Most of this is adapted from IconDirectoryView::DragSelection */ if( m_pcServer == NULL ) { DEBUG( "DragSelection with m_pcServer== NULL\n" ); return; } String zBase = m_pcServer->GetServerAddress(); Message cMsg( 1234 ); /* Message code isn't important */ /* Add all selected icons to the message, and find the icon under the mouse. */ int nCount = 0; int nLastSelected = -1; Point cIconPos = Point( 0,0 ); for( uint i = 0; i < GetIconCount(); i++ ) { if( GetIconSelected( i ) ) { RemoteIconData* pcData = (RemoteIconData*)GetIconData( i ); // DEBUG( " %s\n", pcData->m_cNode.m_zPath.c_str() ); cMsg.AddString( "remote-file/path", pcData->m_cNode.m_zPath ); cMsg.AddString( "server", zBase ); cMsg.AddBool( "is_dir", pcData->m_cNode.m_bIsDir ); if( Rect( GetIconPosition( i ), GetIconPosition( i ) + GetIconSize() ).DoIntersect( cStartPoint ) ) { cIconPos = GetIconPosition( i ); } nLastSelected = i; nCount++; } } if( nCount == 0 ) return; /* Create a drag&drop icon */ Bitmap cBitmap( (int)GetIconSize().x + 1, (int)GetIconSize().y + 1, CS_RGB32, Bitmap::ACCEPT_VIEWS | Bitmap::SHARE_FRAMEBUFFER ); View* pcView = new View( Rect( Point(0,0), GetIconSize() ), "temp" ); cBitmap.AddChild( pcView ); Image* pcIcon = NULL; String zLabel; if( nCount == 1 ) { /* Only one file selected; use its icon */ zLabel = GetIconString( nLastSelected, 0 ); pcIcon = GetIconImage( nLastSelected ); } else { /* Multiple files selected; use dir icon */ zLabel.Format( "%i items", nCount ); /* TODO: localise the string */ /* TODO: Fall back to resource if file isn't present */ File* pcFile = new File( "/system/icons/folder.png" ); BitmapImage* pcBitmapImage = new BitmapImage( pcFile ); Point cSize = (GetView() == VIEW_LIST || GetView() == VIEW_DETAILS ? Point( 24,24 ) : Point( 48,48 )); if( pcBitmapImage->GetSize() != cSize ) pcBitmapImage->SetSize( cSize ); pcIcon = pcBitmapImage; } if( pcIcon ) { RenderIcon( zLabel, pcIcon, pcView, Point(0,0) ); } cBitmap.Sync(); if( nCount != 1 ) delete( pcIcon ); BeginDrag( &cMsg, cStartPoint - cIconPos, &cBitmap ); }
INT_PTR MappingDlg::_proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_SHOWWINDOW: { if (wParam == TRUE) { load(); } else { save(); } break; } case WM_SIZE: { ::MoveWindow(m_hList, 0, 0, LOWORD(lParam), HIWORD(lParam), FALSE); break; } case WM_NOTIFY: { switch (((LPNMHDR)lParam)->idFrom) { case IDC_MAPPING_LIST: switch (((LPNMLISTVIEW)lParam)->hdr.code) { case LVN_BEGINDRAG: BeginDrag(((LPNMLISTVIEW)lParam)->iItem); SetFocus(m_hList); break; case NM_RCLICK: { POINT pt; GetCursorPos(&pt); TrackPopupMenu((HMENU)GetSubMenu(m_hMenu, 0), TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, m_hDlg, NULL); break; } case NM_DBLCLK: editMappingDataDlg(); break; case LVN_ITEMCHANGED: if (m_active) { DWORD newstate = (((LPNMLISTVIEW)lParam)->uNewState & LVIS_STATEIMAGEMASK); if (newstate != (((LPNMLISTVIEW)lParam)->uOldState & LVIS_STATEIMAGEMASK)) { Mapping * btn = (Mapping *) ((LPNMLISTVIEW)lParam)->lParam; if (btn != 0) { btn->Enable = newstate == INDEXTOSTATEIMAGEMASK(2); m_change =true; } } break; } } break; default: return FALSE; } break; } case WM_MOUSEMOVE: if ( m_dragflag && GetCapture() == hWnd) { DragMove(LOWORD(lParam), HIWORD(lParam)); } break; case WM_LBUTTONUP: if ( m_dragflag && GetCapture() == hWnd){ EndDrag(LOWORD(lParam), HIWORD(lParam)); InvalidateRect(hWnd, NULL, FALSE); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_MENU_MAPPING_ADD: addMappingDataDlg(); break; case ID_MENU_MAPPING_DEL: deleteMappingData(); break; case ID_MENU_MAPPING_EDIT: editMappingDataDlg(); break; } break; default: return FALSE; } return TRUE; }
//----------------------------------------------------------------------------- // Purpose: Begins dragging an item in the visgroup list. The drag image is // created and anchored relative to the mouse cursor. // Input : pNMHDR - // pResult - //----------------------------------------------------------------------------- void CGroupList::OnBegindrag(NMHDR *pNMHDR, LRESULT *pResult) { NMTREEVIEW *ptv = (NMTREEVIEW *)pNMHDR; BeginDrag(ptv->ptDrag, ptv->itemNew.hItem); *pResult = 0; }