Blender V5.0
GHOST_Rect Class Reference

#include <GHOST_Rect.hh>

Public Member Functions

 GHOST_Rect (int32_t l=0, int32_t t=0, int32_t r=0, int32_t b=0)
virtual ~GHOST_Rect ()=default
virtual int32_t getWidth () const
virtual int32_t getHeight () const
virtual void set (int32_t l, int32_t t, int32_t r, int32_t b)
virtual bool isEmpty () const
virtual bool isValid () const
virtual void inset (int32_t i)
virtual void unionRect (const GHOST_Rect &r)
virtual void unionPoint (int32_t x, int32_t y)
virtual void wrapPoint (int32_t &x, int32_t &y, int32_t ofs, GHOST_TAxisFlag axis)
virtual void clampPoint (int32_t &x, int32_t &y)
virtual bool isInside (int32_t x, int32_t y) const
virtual GHOST_TVisibility getVisibility (GHOST_Rect &r) const
virtual void setCenter (int32_t cx, int32_t cy)
virtual void setCenter (int32_t cx, int32_t cy, int32_t w, int32_t h)
virtual bool clip (GHOST_Rect &r) const

Public Attributes

int32_t l_
int32_t t_
int32_t r_
int32_t b_

Detailed Description

Implements rectangle functionality. The four extreme coordinates are stored as left, top, right and bottom. To be valid, a rectangle should have a left coordinate smaller than or equal to right. To be valid, a rectangle should have a top coordinate smaller than or equal to bottom.

Definition at line 20 of file GHOST_Rect.hh.

Constructor & Destructor Documentation

◆ GHOST_Rect()

GHOST_Rect::GHOST_Rect ( int32_t l = 0,
int32_t t = 0,
int32_t r = 0,
int32_t b = 0 )
inline

Constructs a rectangle with the given values.

Parameters
lrequested left coordinate of the rectangle.
trequested top coordinate of the rectangle.
rrequested right coordinate of the rectangle.
brequested bottom coordinate of the rectangle.

Definition at line 29 of file GHOST_Rect.hh.

References b, b_, l, l_, r_, and t_.

Referenced by clip(), getVisibility(), unionRect(), and ~GHOST_Rect().

◆ ~GHOST_Rect()

virtual GHOST_Rect::~GHOST_Rect ( )
virtualdefault

Destructor.

References b, GHOST_Rect(), i, l, w(), x, and y.

Member Function Documentation

◆ clampPoint()

void GHOST_Rect::clampPoint ( int32_t & x,
int32_t & y )
inlinevirtual

Confine x & y within the rectangle (inclusive).

Parameters
xThe x-coordinate of the point.
yThe y-coordinate of the point.

Definition at line 253 of file GHOST_Rect.hh.

References b_, l_, r_, t_, x, and y.

◆ clip()

bool GHOST_Rect::clip ( GHOST_Rect & r) const
virtual

Clips a rectangle. Updates the rectangle given such that it will fit within this one. This can result in an empty rectangle.

Parameters
rthe rectangle to clip.
Returns
whether clipping has occurred

Definition at line 92 of file GHOST_Rect.cc.

References b_, GHOST_Rect(), l_, r_, and t_.

Referenced by GHOST_SystemCocoa::handleMouseEvent().

◆ getHeight()

◆ getVisibility()

GHOST_TVisibility GHOST_Rect::getVisibility ( GHOST_Rect & r) const
virtual

Returns whether the rectangle is inside this rectangle.

Parameters
rrectangle to test.
Returns
visibility (not, partially or fully visible).

Definition at line 42 of file GHOST_Rect.cc.

References b_, GHOST_kFullyVisible, GHOST_kNotVisible, GHOST_kPartiallyVisible, GHOST_Rect(), isInside(), l_, r_, t_, and v.

◆ getWidth()

◆ inset()

void GHOST_Rect::inset ( int32_t i)
virtual

Grows (or shrinks the rectangle). The method avoids negative insets making the rectangle invalid

Parameters
iThe amount of offset given to each extreme (negative values shrink the rectangle).

Definition at line 11 of file GHOST_Rect.cc.

References b_, getHeight(), getWidth(), i, l_, r_, and t_.

◆ isEmpty()

bool GHOST_Rect::isEmpty ( ) const
inlinevirtual

Returns whether this rectangle is empty. Empty rectangles are rectangles that have width==0 and/or height==0.

Returns
boolean value (true==empty rectangle)

Definition at line 183 of file GHOST_Rect.hh.

References getHeight(), and getWidth().

◆ isInside()

bool GHOST_Rect::isInside ( int32_t x,
int32_t y ) const
inlinevirtual

Returns whether the point is inside this rectangle. Point on the boundary is considered inside.

Parameters
xx-coordinate of point to test.
yy-coordinate of point to test.
Returns
boolean value (true if point is inside).

Definition at line 270 of file GHOST_Rect.hh.

References b_, l_, r_, t_, x, and y.

Referenced by getVisibility(), and GHOST_WindowWin32::loadWintab().

◆ isValid()

bool GHOST_Rect::isValid ( ) const
inlinevirtual

Returns whether this rectangle is valid. Valid rectangles are rectangles that have l_ <= r_ and t_ <= b_. Thus, empty rectangles are valid.

Returns
boolean value (true==valid rectangle)

Definition at line 188 of file GHOST_Rect.hh.

References b_, l_, r_, and t_.

◆ set()

void GHOST_Rect::set ( int32_t l,
int32_t t,
int32_t r,
int32_t b )
inlinevirtual

Sets all members of the rectangle.

Parameters
lrequested left coordinate of the rectangle.
trequested top coordinate of the rectangle.
rrequested right coordinate of the rectangle.
brequested bottom coordinate of the rectangle.

Definition at line 175 of file GHOST_Rect.hh.

References b, b_, l, l_, r_, and t_.

◆ setCenter() [1/2]

void GHOST_Rect::setCenter ( int32_t cx,
int32_t cy )
virtual

Sets rectangle members. Sets rectangle members such that it is centered at the given location.

Parameters
cxrequested center x-coordinate of the rectangle.
cyrequested center y-coordinate of the rectangle.

Definition at line 70 of file GHOST_Rect.cc.

References b_, l_, r_, and t_.

◆ setCenter() [2/2]

void GHOST_Rect::setCenter ( int32_t cx,
int32_t cy,
int32_t w,
int32_t h )
virtual

Sets rectangle members. Sets rectangle members such that it is centered at the given location, with the width requested.

Parameters
cxrequested center x-coordinate of the rectangle.
cyrequested center y-coordinate of the rectangle.
wrequested width of the rectangle.
hrequested height of the rectangle.

Definition at line 80 of file GHOST_Rect.cc.

References b_, l_, r_, t_, and w().

◆ unionPoint()

void GHOST_Rect::unionPoint ( int32_t x,
int32_t y )
inlinevirtual

Grows the rectangle to included a point.

Parameters
xThe x-coordinate of the point.
yThe y-coordinate of the point.

Definition at line 209 of file GHOST_Rect.hh.

References b_, l_, r_, t_, x, and y.

◆ unionRect()

void GHOST_Rect::unionRect ( const GHOST_Rect & r)
inlinevirtual

Does a union of the rectangle given and this rectangle. The result is stored in this rectangle.

Parameters
rThe rectangle that is input for the union operation.

Definition at line 193 of file GHOST_Rect.hh.

References b_, GHOST_Rect(), l_, r_, and t_.

◆ wrapPoint()

void GHOST_Rect::wrapPoint ( int32_t & x,
int32_t & y,
int32_t ofs,
GHOST_TAxisFlag axis )
inlinevirtual

Grows the rectangle to included a point.

Parameters
xThe x-coordinate of the point.
yThe y-coordinate of the point.

Definition at line 225 of file GHOST_Rect.hh.

References b_, getHeight(), getWidth(), GHOST_kAxisX, GHOST_kAxisY, l_, r_, t_, w(), x, and y.

Referenced by getCursorPositionClientRelative_impl(), GHOST_SystemCocoa::handleMouseEvent(), and GHOST_SystemWayland::window_cursor_grab_set().

Member Data Documentation

◆ b_

◆ l_

◆ r_

◆ t_


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