class::ui::Element

class ui::Element
  : public draw::Drawing
  : public ev::EventHandler

An Element is a basic building block of the UI. An Element inherits both a draw::Drawing and an sm::EventHandler. It is designed to be used within a ui::EventLoop rather than an sm::EventLoop.

Summary

Element()

draw::AnimationAttr & animation_attr()

u16 animation_frame_delay() const

u8 animation_path() const

u8 animation_type() const

virtual Element * handle_event(

const Event & event,
const draw::DrawingAttr & attr
)

bool is_bounce_left_enabled() const

bool is_bounce_right_enabled() const

bool is_cancelled() const

bool is_confirmed() const

bool is_enabled() const

bool is_exclusive_checklist() const

bool is_redraw_pending() const

bool is_scroll_visible() const

void set_animation(

u8 type,
u8 path,
u16 delay
)

void set_animation_frame_delay(

u16 delay
)

void set_animation_path(

u8 v
)

void set_animation_type(

u8 v
)

void set_bounce_left_enabled(

bool v
)

void set_bounce_right_enabled(

bool v
)

void set_cancel(

bool v
)

void set_confirm(

bool v
)

void set_enable(

bool v
)

void set_enabled(

bool v
)

void set_exclusive_checklist(

bool v
)

void set_redraw_pending(

bool v
)

void set_scroll_visible(

bool v
)

protected draw::AnimationAttr m_animation_attr

protected void adjust_x_center(

sg_size_t w,
sg_int_t & x
)

protected virtual void draw_scroll(

const draw::DrawingScaledAttr & attr,
int selected,
int total,
int visible
)

Members

Element()

Construct an element


draw::AnimationAttr & animation_attr()

u16 animation_frame_delay() const

u8 animation_path() const

u8 animation_type() const

virtual Element * handle_event(

const Event & event,
const draw::DrawingAttr & attr
)

Handles an event sent by the event loop.

Parameters

  • event The event that should be handled

  • attr The draw::DrawingAttr to use to update the display based on the event.


bool is_bounce_left_enabled() const

Access whether bouncing left is enabled


bool is_bounce_right_enabled() const

Access whether bouncing right is enabled


bool is_cancelled() const

Returns true if element is visible


bool is_confirmed() const

bool is_enabled() const

Returns true if element is enabled


bool is_exclusive_checklist() const

bool is_redraw_pending() const

This methods returns true if the handle_event() called the drawidth() method and the underlying device needs to be redrawn

Returns

True if it is time to redraw the element on the LCD or bitmap


bool is_scroll_visible() const

Returns true if element’s scroll is visible


void set_animation(

u8 type,
u8 path,
u16 delay
)


void set_animation_frame_delay(

u16 delay
)


void set_animation_path(

u8 v
)


void set_animation_type(

u8 v
)


void set_bounce_left_enabled(

bool v
)

Set whether the tab should bounce on trying to go left on the left-most tab


void set_bounce_right_enabled(

bool v
)

Set whether the tab should bounce on trying to go right on the right-most tab


void set_cancel(

bool v
)


void set_confirm(

bool v
)


void set_enable(

bool v
)

Enable the element


void set_enabled(

bool v
)


void set_exclusive_checklist(

bool v
)


void set_redraw_pending(

bool v
)

This methods sets whether a redraw is pending. A control loop that handles the element might look like this:

LCD lcd; //lcd that inherits Bitmap
DrawingAttr drawing_attr; //holds the info about the bitmap and
drawing_attr.set(lcd, drawing_point(0,0), drawing_dim(1000, 1000)); //full screen element
My element; //my special element that inherits Element and re-implements the handle_event() and drawidth() methods
  while(1){
     element.handle_event(Element::UPDATE, drawing_attr);
     if( element.is_redraw_pending() ){
        lcd.refresh(); //copy the bitmap to the hardware device -- redraw
        element.set_redraw_pending(false); //clear the redraw flag
     }
  Timer::wait_milliseconds(100);  //update loop once every ten seconds
  }

Parameters

  • v The value of the redraw pending flags

void set_scroll_visible(

bool v
)


protected draw::AnimationAttr m_animation_attr

protected void adjust_x_center(

sg_size_t w,
sg_int_t & x
)


protected virtual void draw_scroll(

const draw::DrawingScaledAttr & attr,
int selected,
int total,
int visible
)


X

Thanks for Coming!

Subscribe to news and updates