Image Component Library (ICL)
|
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 | |
bool | hit (const utils::Point32f &x) const |
returns whether a given relative position is inside the dragger | |
const utils::Rect32f & | rect () const |
returns the draggers relative rect | |
float | dim () const |
returns the current dim variable | |
const utils::Point32f & | pos () const |
returns the current center position | |
const Color & | col () const |
returns the current color | |
void | setColor (float r, float g, float b) |
sets the current color | |
void | setDim (float d) |
sets the current dim | |
void | setPos (const utils::Point32f &x) |
sets the current position (which is clipped to [0,1]) | |
void | move (const utils::Point32f &dist) |
moves the dragger by a given distance | |
void | drag (const utils::Point32f &x) |
makes this dragger "dragged" by the mouse | |
void | dragTo (const utils::Point32f &x) |
once dragged, this function will move the dragger | |
void | drop () |
drops this dragger, to it is no longer moved by the mouse | |
void | draw (ICLDrawWidget *w) const |
draws this dragger into the given ICLDrawWidget | |
bool | over () const |
returns whether the mouse is currently over this dragger | |
void | setOver (bool val=true) |
sets the internal "over"-variable to indicate, that the mouse is over the dragger | |
bool | dragged () const |
returns whether this dragger is currently dragged | |
Private Attributes | |
utils::Point32f | p |
float | d |
utils::Rect32f | r |
bool | dr |
Color | c |
bool | ov |
utils::Point32f | dragOffs |
Utility class that implements draggable rects on the ChromaWidget surface.
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
p | initial position in relative coordinates [0,1] |
d | relative dimension in each direction (0.1 -> 10% of widget size) |
c | color of the dragger |
const Color& icl::qt::Dragger::col | ( | ) | const [inline] |
returns the current color
float icl::qt::Dragger::dim | ( | ) | const [inline] |
returns the current dim variable
void icl::qt::Dragger::drag | ( | const utils::Point32f & | x | ) | [inline] |
makes this dragger "dragged" by the mouse
x | mouse grip point which is used to calculate the offset to the draggers center called "dragOffs" |
bool icl::qt::Dragger::dragged | ( | ) | const [inline] |
returns whether this dragger is currently dragged
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])
x | new position (result is clipped to [0,1] |
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();
w | drawing context |
void icl::qt::Dragger::drop | ( | ) | [inline] |
drops this dragger, to it is no longer moved by the mouse
bool icl::qt::Dragger::hit | ( | const utils::Point32f & | x | ) | const [inline] |
returns whether a given relative position is inside the dragger
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]
dist | distance to move |
bool icl::qt::Dragger::over | ( | ) | const [inline] |
returns whether the mouse is currently over this dragger
const utils::Point32f& icl::qt::Dragger::pos | ( | ) | const [inline] |
returns the current center position
const utils::Rect32f& icl::qt::Dragger::rect | ( | ) | const [inline] |
returns the draggers relative rect
void icl::qt::Dragger::setColor | ( | float | r, |
float | g, | ||
float | b | ||
) | [inline] |
sets the current color
r | red value |
g | green value |
b | blue value |
void icl::qt::Dragger::setDim | ( | float | d | ) | [inline] |
sets the current dim
d | new dim value (relative) |
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
void icl::qt::Dragger::setPos | ( | const utils::Point32f & | x | ) | [inline] |
sets the current position (which is clipped to [0,1])
x | new center position of the dragger |
Color icl::qt::Dragger::c [private] |
!< flag to indicate whether this dragger is currently dragged
float icl::qt::Dragger::d [private] |
!< current center position (relative to the parent widgets size)
bool icl::qt::Dragger::dr [private] |
!< current relative rect of this dragger (p.x-d,p.y-d,2*d,2*d)
utils::Point32f icl::qt::Dragger::dragOffs [private] |
!< flag to indicate whether this mouse is currently over this dragger
bool icl::qt::Dragger::ov [private] |
!< current color of this dragger
utils::Point32f icl::qt::Dragger::p [private] |
utils::Rect32f icl::qt::Dragger::r [private] |
!< relative dimension of this dragger in each direction