From 377fe644d1233e955dfd05e40fa9d335447de325 Mon Sep 17 00:00:00 2001 From: inmarket Date: Sun, 16 Aug 2015 14:30:25 +1000 Subject: [PATCH] Coding style, comments, duplicate symbols and other minor fixes --- drivers/gdisp/STM32LTDC/gdisp_lld_STM32LTDC.c | 9 ++---- src/gdisp/gdisp.c | 8 +---- src/gdisp/gdisp.h | 2 +- src/gwin/gwin_button.c | 4 +-- src/gwin/gwin_checkbox.c | 4 +-- src/gwin/gwin_class.h | 2 +- src/gwin/gwin_widget.c | 32 +++++++------------ 7 files changed, 20 insertions(+), 41 deletions(-) diff --git a/drivers/gdisp/STM32LTDC/gdisp_lld_STM32LTDC.c b/drivers/gdisp/STM32LTDC/gdisp_lld_STM32LTDC.c index 9c2de092..0fb8ba5a 100644 --- a/drivers/gdisp/STM32LTDC/gdisp_lld_STM32LTDC.c +++ b/drivers/gdisp/STM32LTDC/gdisp_lld_STM32LTDC.c @@ -316,10 +316,8 @@ LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay* g) switch(g->p.x) { case GDISP_CONTROL_POWER: // Don't do anything if it is the same power mode - if (g->g.Powermode == (powermode_t)g->p.ptr) { + if (g->g.Powermode == (powermode_t)g->p.ptr) return; - } - switch((powermode_t)g->p.ptr) { default: return; @@ -329,11 +327,8 @@ LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay* g) return; case GDISP_CONTROL_ORIENTATION: - // Don't do anything if it is the same power mode - if (g->g.Orientation == (orientation_t)g->p.ptr) { + if (g->g.Orientation == (orientation_t)g->p.ptr) return; - } - switch((orientation_t)g->p.ptr) { case GDISP_ROTATE_0: case GDISP_ROTATE_180: diff --git a/src/gdisp/gdisp.c b/src/gdisp/gdisp.c index 6e431441..0ddee1f6 100644 --- a/src/gdisp/gdisp.c +++ b/src/gdisp/gdisp.c @@ -3325,9 +3325,8 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co } coord_t gdispGetStringWidthCount(const char* str, font_t font, uint16_t count) { - if (!str) { + if (!str) return 0; - } // No mutex required as we only read static data #if GDISP_NEED_TEXT_KERNING @@ -3338,11 +3337,6 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co } coord_t gdispGetStringWidth(const char* str, font_t font) { - if (!str) { - return 0; - } - - // No mutex required as we only read static data return gdispGetStringWidthCount(str, font, 0); } #endif diff --git a/src/gdisp/gdisp.h b/src/gdisp/gdisp.h index 1ff15e44..d0c31ebb 100644 --- a/src/gdisp/gdisp.h +++ b/src/gdisp/gdisp.h @@ -978,7 +978,7 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co coord_t gdispGetCharWidth(char c, font_t font); /** - * @brief Get the pixel width of a string of a given length. + * @brief Get the pixel width of a string of a given character length. * @return The width of the string in pixels. * @pre GDISP_NEED_TEXT must be TRUE in your gfxconf.h * diff --git a/src/gwin/gwin_button.c b/src/gwin/gwin_button.c index 854f540b..7705c4ce 100644 --- a/src/gwin/gwin_button.c +++ b/src/gwin/gwin_button.c @@ -51,7 +51,7 @@ #endif #if GINPUT_NEED_KEYBOARD - static void _keyboardEvent(GWidgetObject* gw, GEventKeyboard* pke) + static void ButtonKeyboard(GWidgetObject* gw, GEventKeyboard* pke) { // ENTER and SPACE keys to press the button if (pke->c[0] == GKEY_ENTER || pke->c[0] == GKEY_SPACE) { @@ -115,7 +115,7 @@ static const gwidgetVMT buttonVMT = { #endif #if GINPUT_NEED_KEYBOARD { - _keyboardEvent // Process keyboard events + ButtonKeyboard // Process keyboard events }, #endif #if GINPUT_NEED_TOGGLE diff --git a/src/gwin/gwin_checkbox.c b/src/gwin/gwin_checkbox.c index 6401092d..d6906b71 100644 --- a/src/gwin/gwin_checkbox.c +++ b/src/gwin/gwin_checkbox.c @@ -56,7 +56,7 @@ static void SendCheckboxEvent(GWidgetObject *gw) { #endif #if GINPUT_NEED_KEYBOARD - static void _keyboardEvent(GWidgetObject* gw, GEventKeyboard* pke) + static void CheckboxKeyboard(GWidgetObject* gw, GEventKeyboard* pke) { // Only react on KEYDOWN events. Ignore KEYUP events. if (pke->keystate & GKEYSTATE_KEYUP) { @@ -110,7 +110,7 @@ static const gwidgetVMT checkboxVMT = { #endif #if GINPUT_NEED_KEYBOARD { - _keyboardEvent // Process keyboard events + CheckboxKeyboard // Process keyboard events }, #endif #if GINPUT_NEED_TOGGLE diff --git a/src/gwin/gwin_class.h b/src/gwin/gwin_class.h index 81b5404a..03d2d506 100644 --- a/src/gwin/gwin_class.h +++ b/src/gwin/gwin_class.h @@ -171,7 +171,7 @@ typedef struct gwinVMT { /** * @brief The current window manager */ - extern GWindowManager* _GWINwm; + extern GWindowManager *_GWINwm; extern bool_t _gwinFlashState; #endif diff --git a/src/gwin/gwin_widget.c b/src/gwin/gwin_widget.c index 84168b09..47e60e82 100644 --- a/src/gwin/gwin_widget.c +++ b/src/gwin/gwin_widget.c @@ -152,9 +152,8 @@ static void gwidgetEvent(void *param, GEvent *pe) { if (pke->bytecount == 1 && pke->c[0] == GKEY_TAB) { // Only react on KEYDOWN events. Ignore KEYUP events. - if (pke->keystate & GKEYSTATE_KEYUP) { + if (pke->keystate & GKEYSTATE_KEYUP) break; - } // Get the next widget bool_t foundWidget = FALSE; @@ -169,9 +168,8 @@ static void gwidgetEvent(void *param, GEvent *pe) { if (nextWidget == 0) { foundWidget = FALSE; // We go through the list twice - just to be sure - if (endOfListDetected) { + if (endOfListDetected) break; - } endOfListDetected = TRUE; continue; } @@ -199,12 +197,10 @@ static void gwidgetEvent(void *param, GEvent *pe) { // Redraw the new and the previous focused widget because they usually render differently when // they are not focused anymore (eg. no blinking cursor) - if (prevWidget != 0) { + if (prevWidget != 0) gwinRedraw(prevWidget); - } - if (nextWidget != 0) { + if (nextWidget != 0) gwinRedraw(nextWidget); - } break; } @@ -213,19 +209,16 @@ static void gwidgetEvent(void *param, GEvent *pe) { GHandle widgetInFocus = gwinGetFocus(); if (widgetInFocus != 0) { // Make sure that it is a widget - if (!gwinIsWidget(widgetInFocus)) { + if (!gwinIsWidget(widgetInFocus)) break; - } // Make sure that the widget is enabled and visible - if (!(widgetInFocus->flags & GWIN_FLG_SYSVISIBLE) || !(widgetInFocus->flags & GWIN_FLG_ENABLED)) { + if (!(widgetInFocus->flags & GWIN_FLG_SYSVISIBLE) || !(widgetInFocus->flags & GWIN_FLG_ENABLED)) break; - } // Check whether this widget provides a method for handling keyboard events - if (((gwidgetVMT*)widgetInFocus->vmt)->KeyboardEvent == 0) { + if (((gwidgetVMT*)widgetInFocus->vmt)->KeyboardEvent == 0) break; - } // If we got this far we can finally pass the event ((gwidgetVMT*)widgetInFocus->vmt)->KeyboardEvent((GWidgetObject*)widgetInFocus, pke); @@ -457,9 +450,8 @@ const GWidgetStyle *gwinGetDefaultStyle(void) { } void gwinSetText(GHandle gh, const char *text, bool_t useAlloc) { - if (!(gh->flags & GWIN_FLG_WIDGET)) { + if (!(gh->flags & GWIN_FLG_WIDGET)) return; - } // Dispose of the old string if ((gh->flags & GWIN_FLG_ALLOCTXT)) { @@ -471,9 +463,9 @@ void gwinSetText(GHandle gh, const char *text, bool_t useAlloc) { } // Alloc the new text if required - if (!text || !*text) { + if (!text || !*text) gw->text = ""; - } else if (useAlloc) { + else if (useAlloc) { char *str; if ((str = gfxAlloc(strlen(text)+1))) { @@ -481,10 +473,8 @@ void gwinSetText(GHandle gh, const char *text, bool_t useAlloc) { strcpy(str, text); } gw->text = (const char *)str; - } else { + } else gw->text = text; - } - _gwinUpdate(gh); }