Add support of Image widget

Issue #249 new
Patryk Kubiak created an issue

Implementation reason

Loading and Login screens in cgraphic program requires to show ChocoOS logo. If the task #248 is finished, it is possible to draw images in the color map by using oC_ColorMap_DrawImage, but WidgetScreen module has to provide a possibility to draw an image also to allow for integration with other widgets - otherwise for example opacity will be not possible

Generic Description

The WidgetScreen module should allow for adding Image widgets. New widget type should be added, and function for drawing Image widget should be implemented. The widget should support drawing strings from widget definition field String.

Required Interface

#!c

typedef enum
{
    oC_WidgetScreen_WidgetType_None        = 0 ,
    < ... > 
    oC_WidgetScreen_WidgetType_Image ,

    oC_WidgetScreen_WidgetType_NumberOfTypes 
} oC_WidgetScreen_WidgetType_t;

typedef enum
{
    WidgetType_TextBox          = oC_WidgetScreen_WidgetType_TextBox,
    WidgetType_PushButton       = oC_WidgetScreen_WidgetType_PushButton,
    WidgetType_CheckBox         = oC_WidgetScreen_WidgetType_CheckBox,
    WidgetType_RadioButton      = oC_WidgetScreen_WidgetType_RadioButton,
    WidgetType_ProgressBar      = oC_WidgetScreen_WidgetType_ProgressBar,
    WidgetType_Image            = oC_WidgetScreen_WidgetType_Image,

    WidgetType_NumberOfTypes    = oC_WidgetScreen_WidgetType_NumberOfTypes,
} WidgetType_t;

// Draws image widget
// It should use function `oC_ColorMap_DrawImage` to draw image and `DrawString` to 
// draw a string inside the image 
static void DrawImage( Widget_t * Widget , oC_ColorMap_t * ColorMap, oC_Pixel_Position_t ScreenPosition );

static const WidgetHandlersDefinition_t WidgetHandlersDefinition[oC_WidgetScreen_WidgetType_NumberOfTypes] =
{
    [ WidgetType_TextBox     ] = { .DrawWidget = DrawTextBox      , .UpdateState = NULL                     , .RegisterActivity = NULL                          , .CheckDefinition = NULL                           } ,
    [ WidgetType_Image       ] = { .DrawWidget = DrawImage        , .UpdateState = NULL                     , .RegisterActivity = NULL                          , .CheckDefinition = NULL                           } ,
};

Bitbucket

https://bitbucket.org/chocos/chocos/issues/249/add-support-of-image-widget

Trello

Link to trello board: https://trello.com/c/nAmr8xSt

Story

  • [ #240 ] - Preparation of the sample graphic program

List of requirements

  • [ #249 ] - The WidgetScreen supports Image widget
  • [ #249 ] - The Image widget supports strings
  • [ #249 ] - The Image widget supports *.png images
  • [ #249 ] - The Image widget uses uPNG to draw an image

Comments (4)

  1. Log in to comment