bool CUIScrollBox::OnMouse(float x, float y, EUIMessages mouse_action) { bool cursor_over; if(x>=-10.0f && x<GetWidth()+10.0f && y>=-10.0f && y<GetHeight()+10.0f) cursor_over = true; else cursor_over = false; bool im_capturer = (GetParent()->GetMouseCapturer()==this); if(mouse_action == WINDOW_LBUTTON_DOWN) { GetParent()->SetCapture(this, true); } else if(mouse_action == WINDOW_LBUTTON_UP) { GetParent()->SetCapture(this, false); } else if(im_capturer && mouse_action == WINDOW_MOUSE_MOVE && cursor_over) { Fvector2 pos = GetWndPos(); Fvector2 delta = GetUICursor()->GetPosDelta(); if(m_bIsHorizontal) pos.x += delta.x; else pos.y += delta.y; SetWndPos (pos); GetMessageTarget()->SendMessage(this, SCROLLBOX_MOVE); } return true; }
void CUIDragItem::Draw() { Fvector2 tmp; tmp.sub (GetWndPos(), GetUICursor().GetCursorPosition()); tmp.sub (m_pos_offset); tmp.mul (-1.0f); MoveWndDelta (tmp); inherited::Draw (); if(m_custom_draw) m_custom_draw->OnDraw(this); }
void CUIDragItem::Draw() { Fvector2 tmp; tmp.sub (GetWndPos(), GetUICursor()->GetCursorPosition()); tmp.sub (m_pos_offset); tmp.mul (-1.0f); MoveWndDelta (tmp); UI()->PushScissor (UI()->ScreenRect(),true); inherited::Draw(); UI()->PopScissor(); }
bool CUIScrollBox::OnMouseAction(float x, float y, EUIMessages mouse_action) { Fvector2 border; border.x = 512.0f; // :) border.y = 512.0f; bool over_x = ( x >= -border.x && x < (GetWidth() + border.x) ); bool over_y = ( y >= -border.y && y < (GetHeight() + border.y) ); bool cursor_over = false; if(over_x && over_y) { cursor_over = true; } bool im_capturer = (GetParent()->GetMouseCapturer() == this); if(mouse_action == WINDOW_LBUTTON_DOWN || mouse_action == WINDOW_LBUTTON_DB_CLICK) { GetParent()->SetCapture(this, true); return true; } if(mouse_action == WINDOW_LBUTTON_UP) { GetParent()->SetCapture(this, false); return true; } if(im_capturer && mouse_action == WINDOW_MOUSE_MOVE && cursor_over) { Fvector2 pos = GetWndPos(); Fvector2 delta = GetUICursor().GetCursorPositionDelta(); if(IsHorizontal()) pos.x += delta.x; else pos.y += delta.y; SetWndPos (pos); GetMessageTarget()->SendMessage(this, SCROLLBOX_MOVE); } if( !cursor_over ) { GetParent()->SetCapture(this, false); } return true; }
void CUIDetectorWave::Update() { Fvector2 P = GetWndPos(); float dp = m_curr_v*Device.fTimeDelta; P.x += dp; if(P.x > 0) P.x -= m_step; else if(P.x < -(2*m_step) ) P.x += m_step; SetWndPos (P); inherited::Update(); }
void CUILines::Draw() { Fvector2 p = GetWndPos(); Draw(p.x, p.y); }