void ScrollBar::LeftDown(Point p, dword) { push = GetMousePart(); LLOG("ScrollBar::LeftDown(" << p << ")"); LLOG("MousePos = " << GetMousePos() << ", ScreenView = " << GetScreenView() << ", rel. pos = " << (GetMousePos() - GetScreenView().TopLeft())); LLOG("GetWorkArea = " << GetWorkArea()); LLOG("VisibleScreenView = " << GetVisibleScreenView()); LLOG("PartRect(0) = " << GetPartRect(0)); LLOG("PartRect(1) = " << GetPartRect(1)); LLOG("PartRect(2) = " << GetPartRect(2)); LLOG("ScrollBar::LeftDown: mousepart = " << (int)push << ", rect = " << GetPartRect(push) << ", overthumb = " << style->overthumb << ", slider = " << Slider()); LLOG("thumbpos = " << thumbpos << ", thumbsize = " << thumbsize); if(push == 2) delta = GetHV(p.x, p.y) - thumbpos; else { if(jump) { delta = thumbsize / 2; Drag(p); } else if(push == 0) PrevPage(); else NextPage(); } SetCapture(); Refresh(); WhenLeftClick(); }
void ShowToolTip() { LLOG("ShowToolTip"); CloseToolTip(); if(tipctrl) { String text = tipctrl->GetTip(); LLOG("-> showing tip: " << text << " tipctrl: " << UPP::Name(tipctrl)); Ctrl *top = tipctrl->GetTopCtrl(); if(!text.IsEmpty() && top && (top->IsForeground() || top->IsPopUp())) { LLOG("-> foreground"); ToolTip& q = AppToolTip(); q.Set(text); Size sz = q.GetMinSize(); Rect r = top->GetWorkArea(); Point p = GetMousePos() + Size(0, 22); if(p.y + sz.cy > r.bottom) p = GetMousePos() - Size(0, 22); q.PopUp(top, p, !showmode); showmode = true; KillTimeCallback((void *)EndShowMode); return; } LLOG("-> background / empty text, top = " << UPP::Name(top)); } SetTimeCallback(200, callback(EndShowMode), (void *)EndShowMode); }
//----------------------------------------------------------------------------- // Purpose: AccumulateMouse //----------------------------------------------------------------------------- void CInput::AccumulateMouse( void ) { if( !cl_mouseenable.GetBool() ) { return; } if( !cl_mouselook.GetBool() ) { return; } if ( m_rawinput.GetBool() ) { return; } int w, h; engine->GetScreenSize( w, h ); // x,y = screen center int x = w >> 1; x; int y = h >> 1; y; //only accumulate mouse if we are not moving the camera with the mouse if ( !m_fCameraInterceptingMouse && vgui::surface()->IsCursorLocked() ) { //Assert( !vgui::surface()->IsCursorVisible() ); // By design, we follow the old mouse path even when using SDL for Windows, to retain old mouse behavior. #if defined( PLATFORM_WINDOWS ) int current_posx, current_posy; GetMousePos(current_posx, current_posy); m_flAccumulatedMouseXMovement += current_posx - x; m_flAccumulatedMouseYMovement += current_posy - y; #elif defined( USE_SDL ) int dx, dy; engine->GetMouseDelta( dx, dy ); m_flAccumulatedMouseXMovement += dx; m_flAccumulatedMouseYMovement += dy; #else #error #endif // force the mouse to the center, so there's room to move ResetMouse(); } else if ( m_fMouseActive ) { // Clamp int ox, oy; GetMousePos( ox, oy ); ox = clamp( ox, 0, w - 1 ); oy = clamp( oy, 0, h - 1 ); SetMousePos( ox, oy ); } }
Image RichEdit::CursorImage(Point p, dword flags) { if(tablesel) return Image::Arrow(); switch(GetHotSpot(p)) { case 0: return Image::SizeBottomRight(); case 1: return Image::SizeVert(); case 2: return Image::SizeHorz(); default: if(text.GetRichPos(GetMousePos(p)).object) { return Image::Arrow(); } else if(HasCapture() && tabmove.table && tabmove.column >= -2) return Image::SizeHorz(); else { RichHotPos hp = GetHotPos(p); if(hp.table > 0) return Image::SizeHorz(); else { int c = GetMousePos(p); return InSelection(c) && !HasCapture() ? Image::Arrow() : Image::IBeam(); } } } return Image::Arrow(); }
//----------------------------------------------------------------------------- // Purpose: AccumulateMouse //----------------------------------------------------------------------------- void CInput::AccumulateMouse( int nSlot ) { if( !cl_mouseenable.GetBool() ) { return; } if( !UsingMouselook( nSlot ) ) { return; } int w, h; engine->GetScreenSize( w, h ); // x,y = screen center int x = w >> 1; int y = h >> 1; // Clamp if ( m_fMouseActive ) { int ox, oy; GetMousePos( ox, oy ); ox = clamp( ox, 0, w - 1 ); oy = clamp( oy, 0, h - 1 ); SetMousePos( ox, oy ); } //only accumulate mouse if we are not moving the camera with the mouse PerUserInput_t &user = GetPerUser( nSlot ); if ( !user.m_fCameraInterceptingMouse && vgui::surface()->IsCursorLocked() ) { //Assert( !vgui::surface()->IsCursorVisible() ); #ifdef WIN32 int current_posx, current_posy; GetMousePos(current_posx, current_posy); user.m_flAccumulatedMouseXMovement += current_posx - x; user.m_flAccumulatedMouseYMovement += current_posy - y; // force the mouse to the center, so there's room to move ResetMouse(); #elif defined(OSX) CGMouseDelta deltaX, deltaY; CGGetLastMouseDelta( &deltaX, &deltaY ); user.m_flAccumulatedMouseXMovement += deltaX; user.m_flAccumulatedMouseYMovement += deltaY; #else #error #endif } }
void CView::ClickingLeftButtonEvent() { if (m_pMenu && !m_pMenu->GetMenuWorkSpaceRect().contains(GetMousePos(*m_pWindow))) { m_pMenu.release(); m_pMenu = nullptr; } else if (m_pFrame->GetStartMousePos().x == OUTSTIDE_WORKSPACE_POS) { m_pFrame->SetStartMousePos(GetMousePos(*m_pWindow)); } m_mouseClicked = true; }
void clGUIWindow::PreRender() { clGUIDialogWindow::PreRender(); static const float ResizeCornerW = Env->GUI->GetDefaultResizeCornerWidth(); static const float ResizeCornerH = Env->GUI->GetDefaultResizeCornerHeight(); UpdateUniformsV( FResizeCornerShader, LVector4( GetX2(), GetY2(), GetX2() - ResizeCornerW, GetY2() + ResizeCornerH ) ); UpdateUniformsV( FResizeCornerHighlightShader, LVector4( GetX2(), GetY2(), GetX2() - ResizeCornerW, GetY2() + ResizeCornerH ) ); FResizeCornerHighlighted ? Env->Renderer->AddBuffer( FResizeCornerGeometry, FResizeCornerHighlightShader, 1, false ) : Env->Renderer->AddBuffer( FResizeCornerGeometry, FResizeCornerShader, 1, false ); static const float CloseButtonW = Env->GUI->GetDefaultCloseButtonWidth(); static const float CloseButtonH_D1 = Env->GUI->GetDefaultCloseButtonHeight_Delta1(); static const float CloseButtonH_D2 = Env->GUI->GetDefaultCloseButtonHeight_Delta2(); if ( FCloseButtonHighlighted ) { UpdateUniformsV( FCloseButtonHighlightShader, LVector4( GetX2() - CloseButtonW, GetY1() + CloseButtonH_D1, GetX2(), GetY1() + CloseButtonH_D2 ) ); Env->Renderer->AddBuffer( FCloseButtonGeometry, FCloseButtonHighlightShader, 1, false ); } else { UpdateUniformsV( FCloseButtonShader, LVector4( GetX2() - CloseButtonW, GetY1() + CloseButtonH_D1, GetX2(), GetY1() + CloseButtonH_D2 ) ); UpdateUniformsV( FCloseButtonCaptionHighlightedShader, LVector4( GetX2() - CloseButtonW, GetY1() + CloseButtonH_D1, GetX2(), GetY1() + CloseButtonH_D2 ) ); ContainsCaption( Local2Screen( GetMousePos() ) ) ? Env->Renderer->AddBuffer( FCloseButtonGeometry, FCloseButtonCaptionHighlightedShader, 1, false ) : Env->Renderer->AddBuffer( FCloseButtonGeometry, FCloseButtonShader, 1, false ); } }
void DockWindow::ContainerDragStart(DockCont &dc) { if (!dc.IsFloating()) { // Reposition if not under the mouse Rect r = dc.GetScreenRect(); Point pt = GetMousePos(); Point tl = r.TopLeft(); bool move = false; if (r.left > pt.x || r.right < pt.x) { tl.x += pt.x - r.left - r.Width()/2; move = true; } if (r.top < pt.y) { tl.y += pt.y - r.top + DOCKCONT_WND_OFFSET; move = true; } // Note: Due to different bugfix, at this point a dragged tab will have docked state but // no parent and should not be animatehld dc.SyncUserSize(true, true); if (IsAnimatedHighlight() && dc.IsDocked() && dc.GetParent()) { Undock0(dc, true); dc.StateNotDocked(); } FloatContainer(dc, move ? tl : Null); dc.StartMouseDrag(pt); } }
ALERROR AGScreen::AddArea (AGArea *pArea, const RECT &rcRect, DWORD dwTag) // AddArea // // Add an area to the screen { ALERROR error; // Initialize the area if (error = pArea->Init(this, this, rcRect, dwTag)) return error; // Add the area if (error = m_Areas.AppendObject(pArea, NULL)) return error; // Get the mouse position and fire mouse move, if appropriate POINT pt; GetMousePos(&pt); if (HitTest(pt) == pArea) SetMouseOver(pArea); return NOERROR; }
bool IGUIObject::MouseOver() { if (!GetGUI()) throw PSERROR_GUI_OperationNeedsGUIObject(); return m_CachedActualSize.PointInside(GetMousePos()); }
void DisplayPopup::Sync() { if(display && ctrl && !ctrl->IsDragAndDropTarget() && !IsDragAndDropTarget()) { Ctrl *top = ctrl->GetTopCtrl(); if(top && top->HasFocusDeep()) { Size sz = display->GetStdSize(value); if(sz.cx + 2 * margin > item.GetWidth() || sz.cy > item.GetHeight()) { slim = item + ctrl->GetScreenView().TopLeft(); if(slim.Contains(GetMousePos())) { // Rect wa = GetWorkArea(); Rect r = item; r.right = max(r.right, r.left + sz.cx + 2 * margin); r.bottom = max(r.bottom, r.top + sz.cy); r.Inflate(1, 1); r.Offset(ctrl->GetScreenView().TopLeft()); SetRect(r); if(!IsOpen()) Ctrl::PopUp(ctrl, true, false, false); Refresh(); return; } } } } if(IsOpen()) Close(); }
// Do you have any idea how much I wanted to call // this ElvisHasLeftTheBuilding()? void Window::MouseHasLeftWindow(void) { IncUsageRef(); string StatusControlName = string("WindowStatus"); m_pTheme->HandleControlMessage(StatusControlName, CM_WindowLeave); if (m_pMouseInControl) { m_pMouseInControl->AcceptTransition(CT_MouseLeave); m_pMouseInControl = NULL; } else if (!m_pMouseInControl) { Pos oPos; GetMousePos(oPos); m_pMouseInControl = ControlFromPos(oPos); if (m_pMouseInControl) { m_pMouseInControl->AcceptTransition(CT_MouseEnter); m_pTheme->HandleControlMessage(StatusControlName, CM_WindowEnter); } } DecUsageRef(); }
void QTFPopUp::PopUp(Ctrl *parent) { Close(); Rect r = Rect(0, 0, width, maxheight); GetFrame().FrameLayout(r); int cy = min(maxheight, GetHeight(r.Width()) + maxheight - r.Height()); Rect area = GetWorkArea(); Point p = GetMousePos(); r.top = max(area.top, p.y + 16); r.bottom = r.top + cy; if(r.bottom > area.bottom) { r.bottom = area.bottom; r.top = r.bottom - cy; } r.left = max(area.left, p.x - width / 2); r.right = r.left + width; if(r.right > area.right) { r.right = area.right; r.left = r.right - width; } open = false; SetRect(r); Ctrl::PopUp(parent); SetFocus(); open = true; }
bool CDropDown::MouseOver() { if(!GetGUI()) throw PSERROR_GUI_OperationNeedsGUIObject(); if (m_Open) { CRect rect(m_CachedActualSize.left, m_CachedActualSize.top, m_CachedActualSize.right, GetListRect().bottom); return rect.PointInside(GetMousePos()); } else return m_CachedActualSize.PointInside(GetMousePos()); }
void LineEdit::LeftRepeat(Point p, dword flags) { if(HasCapture()) { int c = GetMousePos(p); if(mpos != c) PlaceCaret(c, true); } }
//----------------------------------------------------------------------------- // Purpose: AccumulateMouse //----------------------------------------------------------------------------- void CInput::AccumulateMouse( void ) { if( !cl_mouseenable.GetBool() ) { return; } if( !cl_mouselook.GetBool() ) { return; } int x, y; GetWindowCenter( x, y ); //only accumulate mouse if we are not moving the camera with the mouse if ( !m_fCameraInterceptingMouse && vgui::surface()->IsCursorLocked() ) { //Assert( !vgui::surface()->IsCursorVisible() ); int current_posx, current_posy; GetMousePos(current_posx, current_posy); m_flAccumulatedMouseXMovement += current_posx - x; m_flAccumulatedMouseYMovement += current_posy - y; // force the mouse to the center, so there's room to move ResetMouse(); } }
void SplitterFrame::LeftDown(Point p, dword) { SetCapture(); Refresh(); ref = GetMousePos(); size0 = BoundSize(); }
void GuiPlatformGripResize(TopWindow *q) { if(q->top) { Point p = GetMousePos(); gtk_window_begin_resize_drag(q->gtk(), GDK_WINDOW_EDGE_SOUTH_EAST, 1, p.x, p.y, Ctrl::CurrentTime); } }
int GLWindow::GetMouseX() { if (MousePos.x==0) GetMousePos(); int back=MousePos.x; MousePos.x=0; return back; }
int GLWindow::GetMouseY() { if (MousePos.y==0) GetMousePos(); int back=MousePos.y; MousePos.y=0; return back; }
void LineEdit::MouseMove(Point p, dword flags) { if((flags & K_MOUSELEFT) && HasFocus() && HasCapture()) { int c = GetMousePos(p); dorectsel = flags & K_ALT; PlaceCaret(c, mpos != c || HasCapture()); dorectsel = false; } }
// Get current mouse position. If the mouse is above/below the current // window then scroll the window down/up proportionally to the time the LMB // is held down. This function is called from autoscroll_thread() when the // mouse is captured and a wipe selection is active. static void AutoScroll(WINDOW *wp) { #define DVSR 10 #define INCR 6 #define TRIGGER (DVSR + INCR) POINT current; int Scroll = 0; static int ScrollCount = 0, Throttle = INCR; GetMousePos(¤t); if (wp == 0) return; // Determine if we are above or below the window, // and if so, how far... if (current.y < wp->w_toprow) { // Above the window // Scroll = wp->w_toprow - current.y; Scroll = 1; } if (current.y > mode_row(wp)) { // Below // Scroll = current.y - mode_row(wp); // Scroll *= -1; Scroll = -1; } if (Scroll) { int row; if (Scroll > 0) { row = wp->w_toprow; } else { row = mode_row(wp) - 1; } // Scroll the pre-determined amount, ensuring at least one line of // window movement per timer tick. Note also that ScrollScale is // signed, so it will be negative if we want to scroll down. mvupwind(TRUE, Scroll * max(ScrollCount, TRIGGER) / (Throttle + DVSR)); // Set the cursor. Column doesn't really matter, it will // get updated as soon as we get back into the window... setcursor(row, 0) && sel_extend(TRUE, TRUE); (void) update(TRUE); ScrollCount++; if (ScrollCount > TRIGGER && Throttle > 0 && ScrollCount % INCR == 0) Throttle--; } else { // Reset counters Throttle = INCR; ScrollCount = 0; } #undef DVSR #undef INCR #undef TRIGGER }
//----------------------------------------------------------------------------- // Purpose: AccumulateMouse //----------------------------------------------------------------------------- void CInput::AccumulateMouse( void ) { if( !cl_mouseenable.GetBool() ) { return; } if( !cl_mouselook.GetBool() ) { return; } int w, h; engine->GetScreenSize( w, h ); // x,y = screen center int x = w >> 1; int y = h >> 1; // Clamp if ( m_fMouseActive ) { int ox, oy; GetMousePos( ox, oy ); ox = clamp( ox, 0, w - 1 ); oy = clamp( oy, 0, h - 1 ); SetMousePos( ox, oy ); } //only accumulate mouse if we are not moving the camera with the mouse if ( !m_fCameraInterceptingMouse && vgui::surface()->IsCursorLocked() ) { //Assert( !vgui::surface()->IsCursorVisible() ); int current_posx, current_posy; GetMousePos(current_posx, current_posy); m_flAccumulatedMouseXMovement += current_posx - x; m_flAccumulatedMouseYMovement += current_posy - y; // force the mouse to the center, so there's room to move ResetMouse(); } }
void DocEdit::RightDown(Point p, dword w) { SetFocus(); int c = GetMousePos(p); int l, h; if(!GetSelection(l, h) || c < l || c >= h) PlaceCaret(c, false); MenuBar::Execute(WhenBar); }
void RichEdit::LeftTriple(Point p, dword flags) { NextUndo(); int c = GetMousePos(p); if(c >= 0 && c != objectpos) { RichPos rp = text.GetRichPos(c); Select(c - rp.posinpara, rp.paralen + 1); } }
void My_TestGLDrawing::MouseMove(int x, int y, int modKeys) { Hdx_UnitTestGLDrawing::MouseMove(x, y, modKeys); if (!(modKeys & GarchGLDebugWindow::Alt)) { _endPos = GetMousePos(); } }
//----------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------- bool CCanvas::IsMouseOver( int x1, int y1, int x2, int y2 ) { if( GetForegroundWindow() != g_RenderInterf->GetWnd() ) //If our window does not have focus return false; int x, y; GetMousePos( &x, &y ); return( (x >= x1) && (y >= y1) && (x < x2) && (y < y2) ); }
void LineEdit::LeftUp(Point p, dword flags) { if(!HasCapture() && selclick) { mpos = GetMousePos(p); PlaceCaret(mpos, flags & K_SHIFT); SetWantFocus(); } selclick = false; }
void LineEdit::RightDown(Point p, dword flags) { mpos = GetMousePos(p); SetWantFocus(); int l, h; if(!GetSelection(l, h) || mpos < l || mpos >= h) PlaceCaret(mpos, false); MenuBar::Execute(WhenBar); }
void DocEdit::LeftUp(Point p, dword flags) { if(!HasCapture() && selclick) { int c = GetMousePos(p); PlaceCaret(c, flags & K_SHIFT); SetFocus(); } selclick = false; ReleaseCapture(); }