OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4GUI::CMouse Class Reference

#include <C4Gui.h>

Collaboration diagram for C4GUI::CMouse:
[legend]

Public Types

enum  TooltipShowState { TTST_None = 0, TTST_Immediate = 1, TTST_All = 2 }
 

Public Member Functions

 CMouse (int32_t iX, int32_t iY)
 
 ~CMouse ()
 
void Draw (C4TargetFacet &cgo, TooltipShowState draw_tool_tips)
 
void Input (int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
 
bool IsLDown ()
 
void GetLastXY (int32_t &rX, int32_t &rY, DWORD &rdwKeys)
 
void ResetElements ()
 
void ReleaseElements ()
 
void OnElementGetsInvisible (Element *pChild)
 
void RemoveElement (Element *pChild)
 
void SetOwnedMouse (bool fToVal)
 
void ResetToolTipTime ()
 
bool IsMouseStill ()
 
void ResetActiveInput ()
 
bool IsActiveInput ()
 
void ReleaseButtons ()
 

Public Attributes

int32_t x
 
int32_t y
 
bool LDown
 
bool MDown
 
bool RDown
 
int32_t LDownX
 
int32_t LDownY
 
DWORD dwKeys
 
bool fActive
 
C4TimeMilliseconds tLastMovementTime
 
bool fActiveInput
 
ElementpMouseOverElement
 
ElementpPrevMouseOverElement
 
ElementpDragElement
 

Detailed Description

Definition at line 2529 of file C4Gui.h.

Member Enumeration Documentation

Enumerator
TTST_None 
TTST_Immediate 
TTST_All 

Definition at line 2544 of file C4Gui.h.

2545  {
2546  TTST_None = 0, // show no tooltips
2547  TTST_Immediate = 1, // show only tooltips of elements that require immediate show (i.e. otherwise unlabeled buttons)
2548  TTST_All = 2, // show all tooltips (mouse hovered on same element for some time)
2549  };

Constructor & Destructor Documentation

C4GUI::CMouse::CMouse ( int32_t  iX,
int32_t  iY 
)

Definition at line 449 of file C4Gui.cpp.

References dwKeys, LDown, MDown, pDragElement, pMouseOverElement, pPrevMouseOverElement, RDown, ResetToolTipTime(), x, and y.

449  : fActive(true), fActiveInput(false)
450  {
451  // set pos
452  x=iX; y=iY;
453  // reset fields
454  LDown=MDown=RDown=false;
455  dwKeys=0;
457  pDragElement = nullptr;
459  // LDownX/Y initialized upon need
460  }
Element * pDragElement
Definition: C4Gui.h:2553
int32_t y
Definition: C4Gui.h:2532
bool RDown
Definition: C4Gui.h:2533
bool LDown
Definition: C4Gui.h:2533
Element * pPrevMouseOverElement
Definition: C4Gui.h:2552
bool fActive
Definition: C4Gui.h:2536
DWORD dwKeys
Definition: C4Gui.h:2535
int32_t x
Definition: C4Gui.h:2532
void ResetToolTipTime()
Definition: C4Gui.h:2575
bool fActiveInput
Definition: C4Gui.h:2542
Element * pMouseOverElement
Definition: C4Gui.h:2552
bool MDown
Definition: C4Gui.h:2533

Here is the call graph for this function:

C4GUI::CMouse::~CMouse ( )

Definition at line 462 of file C4Gui.cpp.

463  {
464  }

Member Function Documentation

void C4GUI::CMouse::Draw ( C4TargetFacet cgo,
TooltipShowState  draw_tool_tips 
)

Definition at line 488 of file C4Gui.cpp.

References C4GUI::Screen::DrawToolTip(), fActive, C4GUI::Element::GetToolTip(), C4Draw::GetZoom(), GfxR, C4Facet::Hgt, C4GUI::Element::IsImmediateToolTip(), pDraw, pMouseOverElement, C4TargetFacet::Set(), C4Draw::SetZoom(), C4Facet::Surface, TTST_All, TTST_None, C4Facet::Wdt, C4Facet::X, x, C4Facet::Y, y, and ZoomData::Zoom.

Referenced by C4GUI::Screen::RenderMouse().

489  {
490  // only if owned
491  if (!fActive) return;
492 
493  // Make sure to draw the cursor without zoom.
494  ZoomData GuiZoom;
495  pDraw->GetZoom(&GuiZoom);
496  const float oldZoom = GuiZoom.Zoom;
497  GuiZoom.Zoom = 1.0;
498  pDraw->SetZoom(GuiZoom);
499 
500  int32_t iOffsetX = -GfxR->fctMouseCursor.Wdt/2;
501  int32_t iOffsetY = -GfxR->fctMouseCursor.Hgt/2;
502  GfxR->fctMouseCursor.Draw(cgo.Surface,x+iOffsetX,y+iOffsetY,0);
503  // ToolTip
504  if (pMouseOverElement && draw_tool_tips != TTST_None)
505  {
506  if (draw_tool_tips == TTST_All || pMouseOverElement->IsImmediateToolTip())
507  {
508  const char *szTip = pMouseOverElement->GetToolTip();
509  if (szTip && *szTip)
510  {
511  C4TargetFacet cgoTip; cgoTip.Set(cgo.Surface, cgo.X, cgo.Y, cgo.Wdt, cgo.Hgt);
512  Screen::DrawToolTip(szTip, cgoTip, x, y);
513  }
514  }
515  }
516 
517  // And restore old zoom settings.
518  GuiZoom.Zoom = oldZoom;
519  pDraw->SetZoom(GuiZoom);
520  }
float Y
Definition: C4Facet.h:120
#define GfxR
int32_t y
Definition: C4Gui.h:2532
bool IsImmediateToolTip() const
Definition: C4Gui.h:441
static void DrawToolTip(const char *szTip, C4TargetFacet &cgo, float guix, float guiy)
Definition: C4Gui.cpp:1012
const char * GetToolTip()
Definition: C4Gui.cpp:424
bool fActive
Definition: C4Gui.h:2536
void Set(const C4Facet &cpy)
Definition: C4Facet.h:184
C4Draw * pDraw
Definition: C4Draw.cpp:45
void GetZoom(ZoomData *r)
Definition: C4Draw.h:197
float Hgt
Definition: C4Facet.h:120
int32_t x
Definition: C4Gui.h:2532
C4Surface * Surface
Definition: C4Facet.h:119
float Wdt
Definition: C4Facet.h:120
void SetZoom(float X, float Y, float Zoom)
Definition: C4Draw.cpp:782
Element * pMouseOverElement
Definition: C4Gui.h:2552
float X
Definition: C4Facet.h:120
float Zoom
Definition: C4Draw.h:70

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::CMouse::GetLastXY ( int32_t &  rX,
int32_t &  rY,
DWORD rdwKeys 
)
inline

Definition at line 2564 of file C4Gui.h.

References dwKeys, x, and y.

Referenced by ReleaseElements().

2564 { rX=x; rY=y; rdwKeys=dwKeys; }
int32_t y
Definition: C4Gui.h:2532
DWORD dwKeys
Definition: C4Gui.h:2535
int32_t x
Definition: C4Gui.h:2532

Here is the caller graph for this function:

void C4GUI::CMouse::Input ( int32_t  iButton,
int32_t  iX,
int32_t  iY,
DWORD  dwKeyParam 
)

Definition at line 466 of file C4Gui.cpp.

References C4MC_Button_LeftDown, C4MC_Button_LeftUp, C4MC_Button_RightDown, C4MC_Button_RightUp, dwKeys, fActiveInput, LDown, LDownX, LDownY, RDown, ResetToolTipTime(), x, and y.

Referenced by C4GUI::Screen::MouseInput().

467  {
468  // pos changed or click issued?
469  if (iButton || iX!=x || iY!=y)
470  {
471  // then hide tooltips for a while
473  // and mark as active input device
474  fActiveInput = true;
475  }
476  // copy fields
477  x=iX; y=iY; dwKeys=dwKeyParam;
478  // update buttons
479  switch (iButton)
480  {
481  case C4MC_Button_LeftDown: LDown=true; LDownX=x; LDownY=y; break;
482  case C4MC_Button_LeftUp: LDown=false; break;
483  case C4MC_Button_RightDown: RDown=true; break;
484  case C4MC_Button_RightUp: RDown=false; break;
485  }
486  }
const int32_t C4MC_Button_LeftDown
int32_t y
Definition: C4Gui.h:2532
bool RDown
Definition: C4Gui.h:2533
const int32_t C4MC_Button_RightUp
bool LDown
Definition: C4Gui.h:2533
const int32_t C4MC_Button_LeftUp
int32_t LDownX
Definition: C4Gui.h:2534
DWORD dwKeys
Definition: C4Gui.h:2535
int32_t LDownY
Definition: C4Gui.h:2534
const int32_t C4MC_Button_RightDown
int32_t x
Definition: C4Gui.h:2532
void ResetToolTipTime()
Definition: C4Gui.h:2575
bool fActiveInput
Definition: C4Gui.h:2542

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GUI::CMouse::IsActiveInput ( )
inline

Definition at line 2578 of file C4Gui.h.

References fActiveInput.

Referenced by C4Menu::Draw(), and C4GUI::Screen::RenderMouse().

2578 { return fActiveInput; }
bool fActiveInput
Definition: C4Gui.h:2542

Here is the caller graph for this function:

bool C4GUI::CMouse::IsLDown ( )
inline

Definition at line 2562 of file C4Gui.h.

References LDown.

Referenced by C4GUI::ScrollBar::MouseInput(), and C4GUI::Screen::MouseInput().

2562 { return LDown; }
bool LDown
Definition: C4Gui.h:2533

Here is the caller graph for this function:

bool C4GUI::CMouse::IsMouseStill ( )
inline

Definition at line 2576 of file C4Gui.h.

References C4GUI_ToolTipShowTime, and C4TimeMilliseconds::Now().

Referenced by C4GUI::Screen::RenderMouse().

#define C4GUI_ToolTipShowTime
Definition: C4Gui.h:143
C4TimeMilliseconds tLastMovementTime
Definition: C4Gui.h:2537
static C4TimeMilliseconds Now()

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::CMouse::OnElementGetsInvisible ( Element pChild)

Definition at line 549 of file C4Gui.cpp.

References RemoveElement().

Referenced by C4GUI::Element::SetVisibility().

550  {
551  // clear ptr
552  RemoveElement(pChild);
553  }
void RemoveElement(Element *pChild)
Definition: C4Gui.cpp:537

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::CMouse::ReleaseButtons ( )
inline

Definition at line 2580 of file C4Gui.h.

2580 { LDown = RDown = MDown = false; }
bool RDown
Definition: C4Gui.h:2533
bool LDown
Definition: C4Gui.h:2533
bool MDown
Definition: C4Gui.h:2533
void C4GUI::CMouse::ReleaseElements ( )

Definition at line 522 of file C4Gui.cpp.

References dwKeys, GetLastXY(), C4GUI::Element::MouseLeave(), pDragElement, pMouseOverElement, pPrevMouseOverElement, C4GUI::Element::ScreenPos2ClientPos(), and C4GUI::Element::StopDragging().

Referenced by C4GUI::Screen::ActivateDialog(), C4GUI::Screen::CloseDialog(), and C4GUI::Screen::RecheckActiveDialog().

523  {
524  // release MouseOver
526  // release drag
527  if (pDragElement)
528  {
529  int32_t iX, iY; DWORD dwKeys;
530  GetLastXY(iX, iY, dwKeys);
532  pDragElement->StopDragging(*this, iX, iY, dwKeys);
533  }
535  }
Element * pDragElement
Definition: C4Gui.h:2553
virtual void StopDragging(CMouse &rMouse, int32_t iX, int32_t iY, DWORD dwKeyParam)
Definition: C4Gui.cpp:283
void GetLastXY(int32_t &rX, int32_t &rY, DWORD &rdwKeys)
Definition: C4Gui.h:2564
Element * pPrevMouseOverElement
Definition: C4Gui.h:2552
DWORD dwKeys
Definition: C4Gui.h:2535
void ScreenPos2ClientPos(int32_t &riX, int32_t &riY)
Definition: C4Gui.cpp:219
uint32_t DWORD
Element * pMouseOverElement
Definition: C4Gui.h:2552
virtual void MouseLeave(CMouse &rMouse)
Definition: C4Gui.h:414

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::CMouse::RemoveElement ( Element pChild)

Definition at line 537 of file C4Gui.cpp.

References C4GUI::Element::MouseLeave(), pDragElement, pMouseOverElement, and pPrevMouseOverElement.

Referenced by OnElementGetsInvisible(), C4GUI::ContextMenu::RemoveElement(), and C4GUI::Screen::RemoveElement().

538  {
539  // clear ptr
540  if (pMouseOverElement == pChild)
541  {
542  pMouseOverElement->MouseLeave(*this); // do leave callback so any tooltip is cleared!
543  pMouseOverElement = nullptr;
544  }
545  if (pPrevMouseOverElement == pChild) pPrevMouseOverElement = nullptr;
546  if (pDragElement == pChild) pDragElement = nullptr;
547  }
Element * pDragElement
Definition: C4Gui.h:2553
Element * pPrevMouseOverElement
Definition: C4Gui.h:2552
Element * pMouseOverElement
Definition: C4Gui.h:2552
virtual void MouseLeave(CMouse &rMouse)
Definition: C4Gui.h:414

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::CMouse::ResetActiveInput ( )
inline

Definition at line 2577 of file C4Gui.h.

Referenced by C4GUI::Screen::CharIn(), and C4GUI::Screen::KeyAny().

2577 { fActiveInput = false; }
bool fActiveInput
Definition: C4Gui.h:2542

Here is the caller graph for this function:

void C4GUI::CMouse::ResetElements ( )
inline

Definition at line 2566 of file C4Gui.h.

Referenced by C4GUI::Screen::RemoveElement().

Element * pDragElement
Definition: C4Gui.h:2553
Element * pPrevMouseOverElement
Definition: C4Gui.h:2552
Element * pMouseOverElement
Definition: C4Gui.h:2552

Here is the caller graph for this function:

void C4GUI::CMouse::ResetToolTipTime ( )
inline

Definition at line 2575 of file C4Gui.h.

References C4TimeMilliseconds::Now().

Referenced by CMouse(), and Input().

C4TimeMilliseconds tLastMovementTime
Definition: C4Gui.h:2537
static C4TimeMilliseconds Now()

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::CMouse::SetOwnedMouse ( bool  fToVal)
inline

Definition at line 2573 of file C4Gui.h.

Referenced by C4GUI::Screen::SetExclusive(), and C4GUI::Screen::SetMouseInGUI().

2573 { fActive=fToVal; }
bool fActive
Definition: C4Gui.h:2536

Here is the caller graph for this function:

Member Data Documentation

DWORD C4GUI::CMouse::dwKeys
bool C4GUI::CMouse::fActive

Definition at line 2536 of file C4Gui.h.

Referenced by Draw().

bool C4GUI::CMouse::fActiveInput

Definition at line 2542 of file C4Gui.h.

Referenced by Input(), and IsActiveInput().

bool C4GUI::CMouse::LDown

Definition at line 2533 of file C4Gui.h.

Referenced by CMouse(), Input(), IsLDown(), and C4ScriptGuiWindow::ProcessMouseInput().

int32_t C4GUI::CMouse::LDownX

Definition at line 2534 of file C4Gui.h.

Referenced by Input().

int32_t C4GUI::CMouse::LDownY

Definition at line 2534 of file C4Gui.h.

Referenced by Input().

bool C4GUI::CMouse::MDown

Definition at line 2533 of file C4Gui.h.

Referenced by CMouse().

Element* C4GUI::CMouse::pMouseOverElement
Element * C4GUI::CMouse::pPrevMouseOverElement

Definition at line 2552 of file C4Gui.h.

Referenced by CMouse(), C4GUI::Screen::MouseInput(), ReleaseElements(), and RemoveElement().

bool C4GUI::CMouse::RDown

Definition at line 2533 of file C4Gui.h.

Referenced by CMouse(), and Input().

C4TimeMilliseconds C4GUI::CMouse::tLastMovementTime

Definition at line 2537 of file C4Gui.h.

int32_t C4GUI::CMouse::y

The documentation for this class was generated from the following files: