void TWindow::SimulateMouseMoved() { TPoint mouse; const TPoint& scroll = GetScroll(); mouse.Set(fLastMouseMovedLocation.h + scroll.h, fLastMouseMovedLocation.v + scroll.v); HandleMouseMoved(mouse, fLastMouseMovedModifiers); }
void TWindow::RedrawRect(const TRect& r) { TPoint scroll = GetScroll(); TRect clipRect(r); clipRect.Offset(-scroll.h, -scroll.v); TRegion clipRegion(clipRect); Draw(&clipRegion); }
void TWindow::Redraw() { if (IsCreated()) { TRect r(0, 0, GetWidth(), GetHeight()); const TPoint& scroll = GetScroll(); r.Offset(scroll.h, scroll.v); RedrawRect(r); } }
void TWindow::LocalToRoot(TRect& rect) const { int x, y; Window childWindow; XTranslateCoordinates(sDisplay, fWindow, gApplication->GetRootWindow(), 0, 0, &x, &y, &childWindow); const TPoint& scroll = GetScroll(); rect.Offset(x - scroll.h, y - scroll.v); }
BOOL CScrView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) { CPointAp pp = GetScroll(); if (abs(zDelta) > line_.cy) pp.y -= (zDelta/line_.cy) * line_.cy; // Restrict movement to multiple of text height else pp.y -= zDelta; if (pp.y < 0) pp.y = 0; // Scroll to start (else SetScroll ignores -ve position) SetScroll(pp); return TRUE; // return CView::OnMouseWheel(nFlags, zDelta, pt); }
void TWindow::LocalToTopLevel(TRect& rect) const { const TWindow* window = this; const TPoint& scroll = GetScroll(); rect.Offset(-scroll.h, -scroll.v); while (window->fParent) { rect.Offset(window->fBounds.left, window->fBounds.top); window = window->fParent; } }
void CDebugCamera::Update( const FLOAT fFrameTime, BOOL bIsCurrent ) { CMouse* pMouse = GetGameEngine()->GetInput()->GetMouse(); VECTOR vScroll = GetScroll(); if ( pMouse->IsMouseDown( EMouseButton_Middle ) ) { VECTOR vMove = pMouse->GetMousePosition() - m_vLastMousePos; vMove = vMove * GetGameEngine()->GetView()->GetZoom(); vScroll = vScroll - vMove; SetScroll( vScroll ); } m_vLastMousePos = pMouse->GetMousePosition(); }
bool GuiListBox::Load(File* f) { if (!GuiElement::Load(f)) { return false; } // GetScroll()->SetLocalPos(GetCombinedPos()); GetScroll()->SetSize(GetSize()); // TODO do we need this ? // GetList()->SetLocalPos(GetCombinedPos()); // Don't: // GetList()->SetSize(GetSize()); return true; }
//---------------------------------------------------------------------------------------------- //vrati polohu okna v souradnicich obrazovky int CGEnMain::GetWindowPos(float &x1, float &y1, float &x2, float &y2) { if(!GameWindow) return 0; const CMatrix2D *m; GameWindow->GetGlobalTransPtr(&m); CVec2 scp; float scx,scy; GetScroll(scx,scy); float sx,sy; GameWindow->GetWindowSize(sx,sy); scp = m->TransPoint(scx,scy); x1=scp.x;y1=scp.y; scp = m->TransPoint(scx+sx,scy+sy); x2=scp.x;y2=scp.y; return 1; }
void TWindow::HandleEvent(XEvent& event) { TPoint mouse; const TPoint& scroll = GetScroll(); switch (event.type) { case Expose: { TRect r(event.xexpose.x, event.xexpose.y, event.xexpose.x + event.xexpose.width, event.xexpose.y + event.xexpose.height); if (fUpdateRegion) fUpdateRegion->Union(r); else { fUpdateRegion = new TRegion(r); fNextUpdate = sFirstUpdate; sFirstUpdate = this; } // if (event.xexpose.count == 0) // Update(); break; } case KeyPress: case KeyRelease: { TTopLevelWindow* topLevel = GetTopLevelWindow(); if (topLevel) topLevel->DispatchKeyEvent(event); break; } case ButtonPress: if (event.xbutton.button >= 1 && event.xbutton.button <= 3) { fCurrentEventTime = event.xbutton.time; mouse.Set(event.xbutton.x + scroll.h, event.xbutton.y + scroll.v); // check for multiple clicks TTime now = gApplication->GetCurrentTime(); if (now - fLastClickTime < kDoubleClickTime && abs(fLastClick.h - mouse.h) <= kDoubleClickDelta && abs(fLastClick.v - mouse.v) <= kDoubleClickDelta) ++fClickCount; else fClickCount = 1; fLastClick = mouse; fLastClickTime = now; if (IsTargetable() && event.xbutton.button != 2) RequestTarget(); HandleMouseDown(mouse, (TMouseButton)event.xbutton.button, event.xbutton.state); } else if (event.xbutton.button == 4 || event.xbutton.button == 5) { HandleScrollWheel(event.xbutton.button == 5); } break; case ButtonRelease: if (event.xbutton.button >= 1 && event.xbutton.button <= 3) { fCurrentEventTime = event.xbutton.time; mouse.Set(event.xbutton.x + scroll.h, event.xbutton.y + scroll.v); HandleMouseUp(mouse, (TMouseButton)event.xbutton.button, event.xbutton.state); } break; case EnterNotify: fCurrentEventTime = event.xcrossing.time; mouse.Set(event.xcrossing.x + scroll.h, event.xcrossing.y + scroll.v); HandleMouseEnter(mouse, event.xcrossing.state); break; case LeaveNotify: fCurrentEventTime = event.xcrossing.time; mouse.Set(event.xcrossing.x + scroll.h, event.xcrossing.y + scroll.v); HandleMouseLeave(mouse, event.xcrossing.state); break; case MotionNotify: { // avoid getting too many MotionNotify events by ignoring them if we have more in the queue XEvent testEvent; if (XPending(sDisplay) > 0 && XCheckTypedWindowEvent(sDisplay, event.xany.window, MotionNotify, &testEvent)) break; fLastMouseMovedLocation.Set(event.xmotion.x, event.xmotion.y); fLastMouseMovedModifiers = event.xmotion.state; fCurrentEventTime = event.xmotion.time; mouse.Set(event.xmotion.x + scroll.h, event.xmotion.y + scroll.v); HandleMouseMoved(mouse, event.xmotion.state); break; } case FocusIn: { if (event.xfocus.detail == NotifyAncestor || event.xfocus.detail == NotifyInferior || event.xfocus.detail == NotifyNonlinear || event.xfocus.detail == NotifyNonlinearVirtual) { if (event.xfocus.mode != NotifyGrab && event.xfocus.mode != NotifyUngrab) // these events confuse XIM, according to gdk comment { TTopLevelWindow* topLevel = GetTopLevelWindow(); if (topLevel) topLevel->GotFocus(this); break; } } } case FocusOut: { if (event.xfocus.detail == NotifyAncestor || event.xfocus.detail == NotifyInferior || event.xfocus.detail == NotifyNonlinear || event.xfocus.detail == NotifyNonlinearVirtual) { if (event.xfocus.mode != NotifyGrab && event.xfocus.mode != NotifyUngrab) // these events confuse XIM, according to gdk comment { TTopLevelWindow* topLevel = GetTopLevelWindow(); if (topLevel) topLevel->LostFocus(this); break; } } } case KeymapNotify: // printf("KeymapNotify\n"); break; case GraphicsExpose: // printf("GraphicsExpose\n"); break; case NoExpose: //mgl why are we getting these when drawing scrollbars? // printf("NoExpose\n"); break; case VisibilityNotify: fObscured = (event.xvisibility.state != VisibilityUnobscured); break; case CreateNotify: printf("CreateNotify\n"); break; case DestroyNotify: printf("DestroyNotify\n"); break; case MapNotify: DoMapped(true); break; case UnmapNotify: DoMapped(false); break; case MapRequest: printf("MapRequest\n"); break; case ReparentNotify: // printf("ReparentNotify\n"); break; case ConfigureNotify: { // we manage child window notification ourselves if (fParent == NULL) { TRect oldBounds(fBounds); fBounds.Set(event.xconfigure.x, event.xconfigure.y, event.xconfigure.x + event.xconfigure.width, event.xconfigure.y + event.xconfigure.height); NotifyBoundsChanged(oldBounds); } break; } case ConfigureRequest: printf("ConfigureRequest\n"); break; case GravityNotify: printf("GravityNotify\n"); break; case ResizeRequest: printf("ResizeRequest\n"); break; case CirculateNotify: printf("CirculateNotify\n"); break; case CirculateRequest: printf("CirculateRequest\n"); break; case PropertyNotify: printf("PropertyNotify\n"); break; case SelectionClear: { if (fIsSelectionOwner) { LostSelectionOwnership(); fIsSelectionOwner = false; } break; } case SelectionRequest: { XSelectionEvent response; response.type = SelectionNotify; response.display = event.xselectionrequest.display; response.requestor = event.xselectionrequest.requestor; response.selection = event.xselectionrequest.selection; response.target = event.xselectionrequest.target; response.property = event.xselectionrequest.property; response.time = event.xselectionrequest.time; Atom targetAtom = XInternAtom(event.xselectionrequest.display, "TARGETS", false); if (event.xselectionrequest.target == targetAtom) { Atom targets[] = { XA_STRING }; int result; result = XChangeProperty(event.xselectionrequest.display, event.xselectionrequest.requestor, event.xselectionrequest.property, event.xselectionrequest.target, 8, PropModeReplace, (const unsigned char*)targets, sizeof(targets)); if (result == BadAlloc || result == BadAtom || result == BadMatch || result == BadValue || result == BadWindow) printf ("SelectionRequest - XChangeProperty failed: %d\n", result); response.send_event = true; } else { unsigned char* data; uint32 length; Atom type = event.xselectionrequest.target; if (response.selection == XA_PRIMARY && RequestSelectionData(type, data, length)) { response.target = type; XChangeProperty(response.display, response.requestor, event.xselectionrequest.property, type, 8, PropModeReplace, data, length); free(data); } else response.property = None; } XSendEvent(sDisplay, response.requestor, false, NoEventMask, (XEvent *)&response); break; } case SelectionNotify: { if (event.xselection.property != None) { Atom type; unsigned long items, length, remaining; int actualFormat; unsigned char* data; // first compute the length XGetWindowProperty(sDisplay, fWindow, event.xselection.property, 0, 0, false, AnyPropertyType, &type, &actualFormat, &items, &length, &data); if (data) XFree(data); // now get the data XGetWindowProperty(sDisplay, fWindow, event.xselection.property, 0, length, true, AnyPropertyType, &type, &actualFormat, &items, &remaining, &data); ASSERT(remaining == 0); ReceiveSelectionData(type, data, length); XFree(data); } break; } case ColormapNotify: printf("ColormapNotify\n"); break; case ClientMessage: if ((Atom)event.xclient.data.l[0] == sDeleteWindowAtom) { Close(); } else if ((Atom)event.xclient.data.l[0] == sTakeFocusAtom) { /* TTopLevelWindow* topLevel = GetTopLevelWindow(); ASSERT(topLevel == this); topLevel->TakeFocus(); */ } else printf("unknown ClientMessage\n"); break; case MappingNotify: printf("MappingNotify\n"); break; default: break; } }
//------------------------------------------------------------------------------ const Ogre::Vector2 Background2D::GetScreenScroll() const { return GetScroll() * m_screen_scale; }
bool GLSprite::DrawShaped( const math::Vector2 &v2Pos, const math::Vector2 &v2Size, const Color& color0, const Color& color1, const Color& color2, const Color& color3, const float angle) { if (v2Size == math::Vector2(0,0)) { return true; } // compute flip parameters that will be sent to the VS math::Vector2 flipMul, flipAdd; GetFlipShaderParameters(flipAdd, flipMul); // centralizes the sprite according to the origin math::Vector2 v2Center = m_normalizedOrigin * v2Size; GLVideo* video = m_video.lock().get(); ShaderPtr pCurrentVS = video->GetVertexShader(); math::Matrix4x4 mRot; if (angle != 0.0f) mRot = math::RotateZ(math::DegreeToRadian(angle)); pCurrentVS->SetMatrixConstant("rotationMatrix", mRot); // rounds up the final position to avoid alpha distortion math::Vector2 v2FinalPos; if (video->IsRoundingUpPosition()) { v2FinalPos.x = floor(v2Pos.x); v2FinalPos.y = floor(v2Pos.y); } else { v2FinalPos = v2Pos; } pCurrentVS->SetConstant("size", v2Size); pCurrentVS->SetConstant("entityPos", v2FinalPos); pCurrentVS->SetConstant("center", v2Center); pCurrentVS->SetConstant("flipMul", flipMul); pCurrentVS->SetConstant("flipAdd", flipAdd); pCurrentVS->SetConstant("bitmapSize", GetBitmapSizeF()); pCurrentVS->SetConstant("scroll", GetScroll()); pCurrentVS->SetConstant("multiply", GetMultiply()); const bool setCameraPos = pCurrentVS->ConstantExist("cameraPos"); if (setCameraPos) pCurrentVS->SetConstant("cameraPos", video->GetCameraPos()); if (m_rect.size.x == 0 || m_rect.size.y == 0) { pCurrentVS->SetConstant("rectSize", GetBitmapSizeF()); pCurrentVS->SetConstant("rectPos", 0, 0); } else { pCurrentVS->SetConstant("rectSize", m_rect.size); pCurrentVS->SetConstant("rectPos", m_rect.pos); } pCurrentVS->SetConstant("color0", color0); pCurrentVS->SetConstant("color1", color1); pCurrentVS->SetConstant("color2", color2); pCurrentVS->SetConstant("color3", color3); if (pCurrentVS->ConstantExist("depth")) pCurrentVS->SetConstant("depth", video->GetSpriteDepth()); // apply textures according to the rendering mode (pixel shaded or not) ShaderPtr pCurrentPS = video->GetPixelShader(); SetDiffuseTexture(pCurrentPS); pCurrentVS->SetShader(); // draw the one-pixel-quad applying the vertex shader video->GetRectRenderer().Draw(m_rectMode); return true; }