Image Component Library (ICL)
Classes | Public Member Functions | Private Attributes | List of all members
icl::qt::Dragger Struct Reference

Utility class that implements draggable rects on the ChromaWidget surface. More...

#include <Dragger.h>

Classes

struct  Color
 Utility class which helps to convert rgb to RG-Chroma and back. More...
 

Public Member Functions

 Dragger (const utils::Point32f &p=utils::Point32f::null, float d=0.02, const Color &c=Color(255, 0, 0))
 creates a new Dragger More...
 
bool hit (const utils::Point32f &x) const
 returns whether a given relative position is inside the dragger More...
 
const utils::Rect32frect () const
 returns the draggers relative rect More...
 
float dim () const
 returns the current dim variable More...
 
const utils::Point32fpos () const
 returns the current center position More...
 
const Colorcol () const
 returns the current color More...
 
void setColor (float r, float g, float b)
 sets the current color More...
 
void setDim (float d)
 sets the current dim More...
 
void setPos (const utils::Point32f &x)
 sets the current position (which is clipped to [0,1]) More...
 
void move (const utils::Point32f &dist)
 moves the dragger by a given distance More...
 
void drag (const utils::Point32f &x)
 makes this dragger "dragged" by the mouse More...
 
void dragTo (const utils::Point32f &x)
 once dragged, this function will move the dragger More...
 
void drop ()
 drops this dragger, to it is no longer moved by the mouse More...
 
void draw (ICLDrawWidget *w) const
 draws this dragger into the given ICLDrawWidget More...
 
bool over () const
 returns whether the mouse is currently over this dragger More...
 
void setOver (bool val=true)
 sets the internal "over"-variable to indicate, that the mouse is over the dragger More...
 
bool dragged () const
 returns whether this dragger is currently dragged More...
 

Private Attributes

utils::Point32f p
 
float d
 
utils::Rect32f r
 
bool dr
 
Color c
 
bool ov
 
utils::Point32f dragOffs
 

Detailed Description

Utility class that implements draggable rects on the ChromaWidget surface.

Constructor & Destructor Documentation

◆ Dragger()

icl::qt::Dragger::Dragger ( const utils::Point32f p = utils::Point32f::null,
float  d = 0.02,
const Color c = Color(255,0,0) 
)
inline

creates a new Dragger

Parameters
pinitial position in relative coordinates [0,1]
drelative dimension in each direction (0.1 -> 10% of widget size)
ccolor of the dragger

Member Function Documentation

◆ col()

const Color& icl::qt::Dragger::col ( ) const
inline

returns the current color

◆ dim()

float icl::qt::Dragger::dim ( ) const
inline

returns the current dim variable

◆ drag()

void icl::qt::Dragger::drag ( const utils::Point32f x)
inline

makes this dragger "dragged" by the mouse

Parameters
xmouse grip point which is used to calculate the offset to the draggers center called "dragOffs"

◆ dragged()

bool icl::qt::Dragger::dragged ( ) const
inline

returns whether this dragger is currently dragged

◆ dragTo()

void icl::qt::Dragger::dragTo ( const utils::Point32f x)
inline

once dragged, this function will move the dragger

The new position is clip( x+dragOffs, [0,1])

Parameters
xnew position (result is clipped to [0,1]

◆ draw()

void icl::qt::Dragger::draw ( ICLDrawWidget w) const

draws this dragger into the given ICLDrawWidget

The ICLDrawWidget must be set up before using

w->setImage( chromaSpaceImage );
w->lock();
w->reset();
w->rel(); // !!
MyDragger.draw(w);
w->unlock();
w->update();
Parameters
wdrawing context

◆ drop()

void icl::qt::Dragger::drop ( )
inline

drops this dragger, to it is no longer moved by the mouse

◆ hit()

bool icl::qt::Dragger::hit ( const utils::Point32f x) const
inline

returns whether a given relative position is inside the dragger

◆ move()

void icl::qt::Dragger::move ( const utils::Point32f dist)
inline

moves the dragger by a given distance

The resulting position is clipped to [0,1]

Parameters
distdistance to move

◆ over()

bool icl::qt::Dragger::over ( ) const
inline

returns whether the mouse is currently over this dragger

◆ pos()

const utils::Point32f& icl::qt::Dragger::pos ( ) const
inline

returns the current center position

◆ rect()

const utils::Rect32f& icl::qt::Dragger::rect ( ) const
inline

returns the draggers relative rect

◆ setColor()

void icl::qt::Dragger::setColor ( float  r,
float  g,
float  b 
)
inline

sets the current color

Parameters
rred value
ggreen value
bblue value

◆ setDim()

void icl::qt::Dragger::setDim ( float  d)
inline

sets the current dim

Parameters
dnew dim value (relative)

◆ setOver()

void icl::qt::Dragger::setOver ( bool  val = true)
inline

sets the internal "over"-variable to indicate, that the mouse is over the dragger

The "over"-variable is used in the draw(..)-function for a nice mouse-over effect

◆ setPos()

void icl::qt::Dragger::setPos ( const utils::Point32f x)
inline

sets the current position (which is clipped to [0,1])

Parameters
xnew center position of the dragger

Member Data Documentation

◆ c

Color icl::qt::Dragger::c
private

!< flag to indicate whether this dragger is currently dragged

◆ d

float icl::qt::Dragger::d
private

!< current center position (relative to the parent widgets size)

◆ dr

bool icl::qt::Dragger::dr
private

!< current relative rect of this dragger (p.x-d,p.y-d,2*d,2*d)

◆ dragOffs

utils::Point32f icl::qt::Dragger::dragOffs
private

!< flag to indicate whether this mouse is currently over this dragger

◆ ov

bool icl::qt::Dragger::ov
private

!< current color of this dragger

◆ p

utils::Point32f icl::qt::Dragger::p
private

◆ r

utils::Rect32f icl::qt::Dragger::r
private

!< relative dimension of this dragger in each direction


The documentation for this struct was generated from the following file: