cgv
Loading...
Searching...
No Matches
cgv::render::gl::gl_cursor Class Reference

windows only implementation of functionality to create and draw an RGBA texture representing standard mouse cursor icons. More...

#include <gl_cursor.h>

Public Member Functions

void update_duration ()
 
void clear ()
 
void add_frame (unsigned tex_id)
 
 gl_cursor ()
 construct empty gl_cursor instance
 
bool is_created () const
 check whether cursor has been created
 
bool create (const std::string &id="arrow")
 Create cursor from textual name of default cursor.
 
bool create_from_file (const std::string &file_name)
 Create cursor from a file of type .cur or .ani.
 
unsigned get_width () const
 return the width of the cursor
 
unsigned get_height () const
 return the height of the cursor
 
int get_hot_x () const
 return the x-coordinate of the hot spot of the cursor in local pixel coordinates
 
int get_hot_y () const
 return the y-coordinate of the hot spot of the cursor in local pixel coordinates
 
void set_hot_spot (int _x, int _y)
 set a new hot spot of the cursor in local pixel coordinates
 
unsigned get_nr_steps () const
 return the number of animation steps
 
unsigned get_nr_frames () const
 return the number of animation frames
 
unsigned get_texture_id (unsigned frame_idx=0) const
 return the gl texture id of the given frame
 
unsigned get_step_frame (unsigned step_idx) const
 return the frame index of given step
 
void set_step_frame (unsigned step_idx, unsigned frame_idx)
 set the frame index of given step
 
unsigned get_step_period (unsigned step_idx) const
 return the period of given step in 1/60th of a second
 
void set_step_period (unsigned step_idx, unsigned period)
 return the period of given step in 1/60th of a second
 
void append_step (unsigned frame_idx, unsigned period)
 append an animation step given by frame index and step period
 
unsigned find_step_index (double elapsed_seconds) const
 find the step index of a given elapsed time in seconds
 
unsigned get_frame_texture_id (int frame_idx) const
 return the gl texture id of the given frame
 
void draw (int x, int y, bool use_color=false, unsigned frame_idx=0)
 draw the cursor at the given location
 

Public Attributes

int hot_x
 
int hot_y
 
unsigned w
 
unsigned h
 
std::vector< unsigned > tex_ids
 
std::vector< unsigned > frames
 
std::vector< unsigned > periods
 
unsigned duration
 

Detailed Description

windows only implementation of functionality to create and draw an RGBA texture representing standard mouse cursor icons.

This class is completely standalone and does not depend on any other file in the cgv framework.

Definition at line 15 of file gl_cursor.h.

Constructor & Destructor Documentation

◆ gl_cursor()

cgv::render::gl::gl_cursor::gl_cursor ( )

construct empty gl_cursor instance

Definition at line 205 of file gl_cursor.cxx.

Member Function Documentation

◆ add_frame()

void cgv::render::gl::gl_cursor::add_frame ( unsigned  tex_id)

Definition at line 226 of file gl_cursor.cxx.

◆ append_step()

void cgv::render::gl::gl_cursor::append_step ( unsigned  frame_idx,
unsigned  period 
)

append an animation step given by frame index and step period

Definition at line 496 of file gl_cursor.cxx.

◆ clear()

void cgv::render::gl::gl_cursor::clear ( )

Definition at line 216 of file gl_cursor.cxx.

◆ create()

bool cgv::render::gl::gl_cursor::create ( const std::string &  id = "arrow")

Create cursor from textual name of default cursor.

This can only be called when the opengl context is active in which this cursor is used. The return value tells whether the creation was successful. Possible values for the cursor id are:

  • "startup" ... arrow with wait icon
  • "arrow" ... default arrow
  • "cross" ... simple cross
  • "wait" ... icon used when applications are stalled
  • "hand" ... hand with pointing finger
  • "help" ... help icon
  • "no" ... circle with diagonal dash
  • "ns" ... double arrow from north to south
  • "we" ... double arrow from west to east
  • "move" ... quadrupel arrow pointing north, east, south, west
  • "nesw" ... double arrow pointing from north-east to south-west
  • "nwse" ... double arrow pointing from north-west to south-east.

Definition at line 432 of file gl_cursor.cxx.

◆ create_from_file()

bool cgv::render::gl::gl_cursor::create_from_file ( const std::string &  file_name)

Create cursor from a file of type .cur or .ani.

Definition at line 437 of file gl_cursor.cxx.

◆ draw()

void cgv::render::gl::gl_cursor::draw ( int  x,
int  y,
bool  use_color = false,
unsigned  frame_idx = 0 
)

draw the cursor at the given location

The current opengl transformation must result in a scaling proportional to pixel coordinates. By default the texture color and alpha values are directly drawn to screen. If use_color is set to true, color and alpha are multiplied with the currently set color.

Definition at line 515 of file gl_cursor.cxx.

◆ find_step_index()

unsigned cgv::render::gl::gl_cursor::find_step_index ( double  elapsed_seconds) const

find the step index of a given elapsed time in seconds

Definition at line 504 of file gl_cursor.cxx.

◆ get_height()

unsigned cgv::render::gl::gl_cursor::get_height ( ) const
inline

return the height of the cursor

Definition at line 55 of file gl_cursor.h.

◆ get_hot_x()

int cgv::render::gl::gl_cursor::get_hot_x ( ) const
inline

return the x-coordinate of the hot spot of the cursor in local pixel coordinates

Definition at line 57 of file gl_cursor.h.

◆ get_hot_y()

int cgv::render::gl::gl_cursor::get_hot_y ( ) const
inline

return the y-coordinate of the hot spot of the cursor in local pixel coordinates

Definition at line 59 of file gl_cursor.h.

◆ get_nr_frames()

unsigned cgv::render::gl::gl_cursor::get_nr_frames ( ) const

return the number of animation frames

Definition at line 459 of file gl_cursor.cxx.

◆ get_nr_steps()

unsigned cgv::render::gl::gl_cursor::get_nr_steps ( ) const

return the number of animation steps

Definition at line 453 of file gl_cursor.cxx.

◆ get_step_frame()

unsigned cgv::render::gl::gl_cursor::get_step_frame ( unsigned  step_idx) const

return the frame index of given step

Definition at line 471 of file gl_cursor.cxx.

◆ get_step_period()

unsigned cgv::render::gl::gl_cursor::get_step_period ( unsigned  step_idx) const

return the period of given step in 1/60th of a second

Definition at line 483 of file gl_cursor.cxx.

◆ get_texture_id()

unsigned cgv::render::gl::gl_cursor::get_texture_id ( unsigned  frame_idx = 0) const

return the gl texture id of the given frame

Definition at line 465 of file gl_cursor.cxx.

◆ get_width()

unsigned cgv::render::gl::gl_cursor::get_width ( ) const
inline

return the width of the cursor

Definition at line 53 of file gl_cursor.h.

◆ is_created()

bool cgv::render::gl::gl_cursor::is_created ( ) const

check whether cursor has been created

Definition at line 211 of file gl_cursor.cxx.

◆ set_hot_spot()

void cgv::render::gl::gl_cursor::set_hot_spot ( int  _x,
int  _y 
)
inline

set a new hot spot of the cursor in local pixel coordinates

Definition at line 61 of file gl_cursor.h.

◆ set_step_frame()

void cgv::render::gl::gl_cursor::set_step_frame ( unsigned  step_idx,
unsigned  frame_idx 
)

set the frame index of given step

Definition at line 477 of file gl_cursor.cxx.

◆ set_step_period()

void cgv::render::gl::gl_cursor::set_step_period ( unsigned  step_idx,
unsigned  period 
)

return the period of given step in 1/60th of a second

Definition at line 489 of file gl_cursor.cxx.

◆ update_duration()

void cgv::render::gl::gl_cursor::update_duration ( )

Definition at line 445 of file gl_cursor.cxx.

Member Data Documentation

◆ duration

unsigned cgv::render::gl::gl_cursor::duration

Definition at line 23 of file gl_cursor.h.

◆ frames

std::vector<unsigned> cgv::render::gl::gl_cursor::frames

Definition at line 21 of file gl_cursor.h.

◆ h

unsigned cgv::render::gl::gl_cursor::h

Definition at line 19 of file gl_cursor.h.

◆ hot_x

int cgv::render::gl::gl_cursor::hot_x

Definition at line 18 of file gl_cursor.h.

◆ hot_y

int cgv::render::gl::gl_cursor::hot_y

Definition at line 18 of file gl_cursor.h.

◆ periods

std::vector<unsigned> cgv::render::gl::gl_cursor::periods

Definition at line 22 of file gl_cursor.h.

◆ tex_ids

std::vector<unsigned> cgv::render::gl::gl_cursor::tex_ids

Definition at line 20 of file gl_cursor.h.

◆ w

unsigned cgv::render::gl::gl_cursor::w

Definition at line 19 of file gl_cursor.h.


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