- edited description
Add support of FileBox widget
Issue #252
new
Implementation reason
cgraphic
program and all other potential graphic provider needs to give a possibility to show files. The WidgetScreen
module has to allow for that in easy way by providing support of FileBox
widget.
Generic Description
The system has to support FileBox
widget to provide an easy way to show files in the selected directory.
Example of directories in file box view:
Required Interface
typedef enum
{
oC_WidgetScreen_WidgetType_None = 0 ,
oC_WidgetScreen_WidgetType_EditBox ,
oC_WidgetScreen_WidgetType_TextBox ,
oC_WidgetScreen_WidgetType_PushButton ,
oC_WidgetScreen_WidgetType_CheckBox ,
oC_WidgetScreen_WidgetType_RadioButton ,
oC_WidgetScreen_WidgetType_ProgressBar ,
oC_WidgetScreen_WidgetType_Image ,
oC_WidgetScreen_WidgetType_Keyboard ,
oC_WidgetScreen_WidgetType_FileBox ,
oC_WidgetScreen_WidgetType_NumberOfTypes ,
} oC_WidgetScreen_WidgetType_t;
typedef enum
{
WidgetType_TextBox = oC_WidgetScreen_WidgetType_TextBox,
WidgetType_EditBox = oC_WidgetScreen_WidgetType_EditBox,
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_Keyboard = oC_WidgetScreen_WidgetType_Keyboard,
WidgetType_FileBox = oC_WidgetScreen_WidgetType_FileBox,
WidgetType_NumberOfTypes = oC_WidgetScreen_WidgetType_NumberOfTypes,
} WidgetType_t;
typedef enum
{
oC_WidgetScreen_FileType_Directory,
oC_WidgetScreen_FileType_ConsoleProgram,
oC_WidgetScreen_FileType_GraphicProgram,
oC_WidgetScreen_FileType_OtherFiles,
oC_WidgetScreen_FileType_NumberOfTypes
} oC_WidgetScreen_FileType_t;
typedef void (*oC_WidgetScreen_PathChangedHandler_t)( oC_WidgetScreen_t Screen, oC_WidgetScreen_UserContext_t Context, oC_WidgetScreen_WidgetIndex_t Index, const char * NewPath );
extern void oC_WidgetScreen_SetPath( oC_WidgetScreen_t Screen, oC_WidgetScreen_WidgetIndex_t WidgetIndex, const char * Path );
typedef void (*oC_WidgetScreen_FileHandler_t)( oC_WidgetScreen_t Screen, oC_WidgetScreen_UserContext_t Context, oC_WidgetScreen_WidgetIndex_t Index, const char * FilePath );
typedef struct
{
oC_WidgetScreen_WidgetType_t Type;
oC_Pixel_Position_t Position;
oC_Pixel_ResolutionUInt_t Height;
oC_Pixel_ResolutionUInt_t Width;
oC_WidgetScreen_ZPosition_t ZPosition;
const oC_WidgetScreen_Palette_t * Palette;
const oC_WidgetScreen_DrawStyle_t * DrawStyle;
oC_DefaultPathString_t ImagePath;
oC_WidgetScreen_WidgetHandlers_t Handlers;
struct
{
oC_DefaultString_t DefaultString;
oC_Font_t Font;
oC_WidgetScreen_TextAlign_t TextAlign;
oC_WidgetScreen_VerticalTextAlign_t VerticalTextAlign;
oC_WidgetScreen_UpdateWidgetStringHandler_t UpdateStringHandler;
bool Password; // Set it to true, if the input type should be of password type
} String;
union
{
struct
{
oC_WidgetScreen_PushButtonType_t Type;
} PushButton;
struct
{
oC_Pixel_ResolutionUInt_t OptionWidth;
oC_Pixel_ResolutionUInt_t OptionHeight;
oC_Pixel_ResolutionUInt_t HorizontalCellSpacing;
oC_Pixel_ResolutionUInt_t VerticalCellSpacing;
} CheckBox, RadioButton;
struct
{
const oC_WidgetScreen_KeyboardPageDefinition_t * Pages[oC_WidgetScreen_KeyboardPage_Max];
oC_Color_t BackgroundColor;
oC_ColorFormat_t ColorFormat;
} Keyboard;
struct
{
oC_WidgetScreen_InputType_t InputType; // Type of allowed input
oC_WidgetScreen_WidgetIndex_t KeyboardIndex; // Index of keyboard widget
} EditBox;
struct
{
oC_Pixel_ResolutionUInt_t FileWidth;
oC_Pixel_ResolutionUInt_t FileHeight;
oC_Pixel_ResolutionUInt_t HorizontalCellSpacing;
oC_Pixel_ResolutionUInt_t VerticalCellSpacing;
oC_DefaultPathString_t DefaultPath;
oC_WidgetScreen_PathChangedHandler_t PathChangedHandler; // Function called when directory has been changed
oC_WidgetScreen_FileHandler_t FileOpenHandler; // Function called when file has been opened
oC_WidgetScreen_FileHandler_t FileSelectedHandler; // Function called when file has been selected
oC_WidgetScreen_FileHandler_t FileRightClickHandler; // Function called when file has been clicked with right mouse button
const oC_WidgetScreen_Palette_t * DirectoriesPalette;
const oC_WidgetScreen_Palette_t * ConsoleFilesPalette;
const oC_WidgetScreen_Palette_t * GraphicFilesPalette;
const oC_WidgetScreen_Palette_t * OtherFilesPalette;
} FileBox;
} TypeSpecific;
} oC_WidgetScreen_WidgetDefinition_t;
static void DrawFileBox ( Widget_t * Widget , oC_ColorMap_t * ColorMap, oC_Pixel_Position_t ScreenPosition );
static bool RegisterFileBoxActivity ( Widget_t * Widget , oC_Pixel_Position_t ScreenPosition );
static bool UpdateFileBoxState ( Widget_t * Widget , oC_Pixel_Position_t ScreenPosition );
static bool CheckFileBoxDefinition ( const WidgetDefinition_t * Definition );
static const WidgetHandlersDefinition_t WidgetHandlersDefinition[oC_WidgetScreen_WidgetType_NumberOfTypes] =
{
[ WidgetType_EditBox ] = { .DrawWidget = DrawEditBox , .UpdateState = UpdateEditBoxState , .RegisterActivity = RegisterEditBoxActivity , .CheckDefinition = CheckEditBoxDefinition } ,
[ WidgetType_TextBox ] = { .DrawWidget = DrawTextBox , .UpdateState = NULL , .RegisterActivity = NULL , .CheckDefinition = NULL } ,
[ WidgetType_Image ] = { .DrawWidget = DrawImage , .UpdateState = NULL , .RegisterActivity = NULL , .CheckDefinition = NULL } ,
[ WidgetType_PushButton ] = { .DrawWidget = DrawPushButton , .UpdateState = UpdatePushButtonState , .RegisterActivity = RegisterPushButtonActivity , .CheckDefinition = CheckPushButtonDefinition } ,
[ WidgetType_CheckBox ] = { .DrawWidget = DrawCheckBox , .UpdateState = UpdateCheckBoxState , .RegisterActivity = RegisterCheckBoxActivity , .CheckDefinition = CheckCheckBoxDefinition } ,
[ WidgetType_RadioButton ] = { .DrawWidget = DrawRadioButton , .UpdateState = UpdateRadioButtonState , .RegisterActivity = RegisterRadioButtonActivity , .CheckDefinition = CheckCheckBoxDefinition } ,
[ WidgetType_Keyboard ] = { .DrawWidget = DrawKeyboard , .UpdateState = UpdateKeyboardState , .RegisterActivity = RegisterKeyboardActivity , .CheckDefinition = CheckKeyboardDefinition } ,
[ WidgetType_FileBox ] = { .DrawWidget = DrawFileBox , .UpdateState = UpdateFileBoxState , .RegisterActivity = RegisterFileBoxActivity , .CheckDefinition = CheckFileBoxDefinition } ,
[ WidgetType_ProgressBar ] = { .DrawWidget = DrawProgressBar , .UpdateState = NULL , .RegisterActivity = NULL , .CheckDefinition = NULL } ,
};
Bitbucket
https://bitbucket.org/chocos/chocos/issues/252/add-support-of-filebox-widget
Trello
Story
- [ #240 ] - Preparation of the sample graphic program
List of requirements
- [ #252 ] -
WidgetScreen
supportsFileBox
widget - [ #252 ] -
FileBox
widget uses options as files - [ #252 ] -
FileBox
widget shows list of files - [ #252 ] -
FileBox
page can be changed byoC_WidgetScreen_ScrollUp
andoC_WidgetScreen_ScrollDown
- [ #252 ] -
FileBox
shows directories, console programs, graphic programs and other files in different way.
Comments (6)
-
reporter -
reporter - changed title to Add support of FileBox widget
- edited description
-
reporter - edited description
-
reporter - edited description
-
reporter - edited description
-
reporter - edited description
- Log in to comment