diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/editors/space_info/info_draw.c | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/editors/space_info/info_draw.c')
-rw-r--r-- | source/blender/editors/space_info/info_draw.c | 314 |
1 files changed, 162 insertions, 152 deletions
diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index 39d255427cc..a7d6694b362 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -46,236 +46,246 @@ /* complicates things a bit, so leaving in old simple code */ #define USE_INFO_NEWLINE -static void info_report_color(unsigned char *fg, unsigned char *bg, Report *report, const short do_tint) +static void info_report_color(unsigned char *fg, + unsigned char *bg, + Report *report, + const short do_tint) { - int bg_id = TH_BACK, fg_id = TH_TEXT; - int shade = do_tint ? 0 : -6; - - if (report->flag & SELECT) { - bg_id = TH_INFO_SELECTED; - fg_id = TH_INFO_SELECTED_TEXT; - } - else if (report->type & RPT_ERROR_ALL) { - bg_id = TH_INFO_ERROR; - fg_id = TH_INFO_ERROR_TEXT; - } - else if (report->type & RPT_WARNING_ALL) { - bg_id = TH_INFO_WARNING; - fg_id = TH_INFO_WARNING_TEXT; - } - else if (report->type & RPT_INFO_ALL) { - bg_id = TH_INFO_INFO; - fg_id = TH_INFO_INFO_TEXT; - } - else if (report->type & RPT_DEBUG_ALL) { - bg_id = TH_INFO_DEBUG; - fg_id = TH_INFO_DEBUG_TEXT; - } - else { - bg_id = TH_BACK; - fg_id = TH_TEXT; - } - - UI_GetThemeColorShade3ubv(bg_id, shade, bg); - UI_GetThemeColor3ubv(fg_id, fg); + int bg_id = TH_BACK, fg_id = TH_TEXT; + int shade = do_tint ? 0 : -6; + + if (report->flag & SELECT) { + bg_id = TH_INFO_SELECTED; + fg_id = TH_INFO_SELECTED_TEXT; + } + else if (report->type & RPT_ERROR_ALL) { + bg_id = TH_INFO_ERROR; + fg_id = TH_INFO_ERROR_TEXT; + } + else if (report->type & RPT_WARNING_ALL) { + bg_id = TH_INFO_WARNING; + fg_id = TH_INFO_WARNING_TEXT; + } + else if (report->type & RPT_INFO_ALL) { + bg_id = TH_INFO_INFO; + fg_id = TH_INFO_INFO_TEXT; + } + else if (report->type & RPT_DEBUG_ALL) { + bg_id = TH_INFO_DEBUG; + fg_id = TH_INFO_DEBUG_TEXT; + } + else { + bg_id = TH_BACK; + fg_id = TH_TEXT; + } + + UI_GetThemeColorShade3ubv(bg_id, shade, bg); + UI_GetThemeColor3ubv(fg_id, fg); } /* reports! */ #ifdef USE_INFO_NEWLINE static void report_textview_init__internal(TextViewContext *tvc) { - Report *report = (Report *)tvc->iter; - const char *str = report->message; - const char *next_str = strchr(str + tvc->iter_char, '\n'); - - if (next_str) { - tvc->iter_char_next = (int)(next_str - str); - } - else { - tvc->iter_char_next = report->len; - } + Report *report = (Report *)tvc->iter; + const char *str = report->message; + const char *next_str = strchr(str + tvc->iter_char, '\n'); + + if (next_str) { + tvc->iter_char_next = (int)(next_str - str); + } + else { + tvc->iter_char_next = report->len; + } } static int report_textview_skip__internal(TextViewContext *tvc) { - SpaceInfo *sinfo = (SpaceInfo *)tvc->arg1; - const int report_mask = info_report_mask(sinfo); - while (tvc->iter && (((Report *)tvc->iter)->type & report_mask) == 0) { - tvc->iter = (void *)((Link *)tvc->iter)->prev; - } - return (tvc->iter != NULL); + SpaceInfo *sinfo = (SpaceInfo *)tvc->arg1; + const int report_mask = info_report_mask(sinfo); + while (tvc->iter && (((Report *)tvc->iter)->type & report_mask) == 0) { + tvc->iter = (void *)((Link *)tvc->iter)->prev; + } + return (tvc->iter != NULL); } -#endif // USE_INFO_NEWLINE +#endif // USE_INFO_NEWLINE static int report_textview_begin(TextViewContext *tvc) { - // SpaceConsole *sc = (SpaceConsole *)tvc->arg1; - ReportList *reports = (ReportList *)tvc->arg2; + // SpaceConsole *sc = (SpaceConsole *)tvc->arg1; + ReportList *reports = (ReportList *)tvc->arg2; - tvc->lheight = 14 * UI_DPI_FAC; //sc->lheight; - tvc->sel_start = 0; - tvc->sel_end = 0; + tvc->lheight = 14 * UI_DPI_FAC; //sc->lheight; + tvc->sel_start = 0; + tvc->sel_end = 0; - /* iterator */ - tvc->iter = reports->list.last; + /* iterator */ + tvc->iter = reports->list.last; - UI_ThemeClearColor(TH_BACK); - GPU_clear(GPU_COLOR_BIT); + UI_ThemeClearColor(TH_BACK); + GPU_clear(GPU_COLOR_BIT); #ifdef USE_INFO_NEWLINE - tvc->iter_tmp = 0; - if (tvc->iter && report_textview_skip__internal(tvc)) { - /* init the newline iterator */ - tvc->iter_char = 0; - report_textview_init__internal(tvc); - - return true; - } - else { - return false; - } + tvc->iter_tmp = 0; + if (tvc->iter && report_textview_skip__internal(tvc)) { + /* init the newline iterator */ + tvc->iter_char = 0; + report_textview_init__internal(tvc); + + return true; + } + else { + return false; + } #else - return (tvc->iter != NULL); + return (tvc->iter != NULL); #endif } static void report_textview_end(TextViewContext *UNUSED(tvc)) { - /* pass */ + /* pass */ } #ifdef USE_INFO_NEWLINE static int report_textview_step(TextViewContext *tvc) { - /* simple case, but no newline support */ - Report *report = (Report *)tvc->iter; - - if (report->len <= tvc->iter_char_next) { - tvc->iter = (void *)((Link *)tvc->iter)->prev; - if (tvc->iter && report_textview_skip__internal(tvc)) { - tvc->iter_tmp++; - - tvc->iter_char = 0; /* reset start */ - report_textview_init__internal(tvc); - - return true; - } - else { - return false; - } - } - else { - /* step to the next newline */ - tvc->iter_char = tvc->iter_char_next + 1; - report_textview_init__internal(tvc); - - return true; - } + /* simple case, but no newline support */ + Report *report = (Report *)tvc->iter; + + if (report->len <= tvc->iter_char_next) { + tvc->iter = (void *)((Link *)tvc->iter)->prev; + if (tvc->iter && report_textview_skip__internal(tvc)) { + tvc->iter_tmp++; + + tvc->iter_char = 0; /* reset start */ + report_textview_init__internal(tvc); + + return true; + } + else { + return false; + } + } + else { + /* step to the next newline */ + tvc->iter_char = tvc->iter_char_next + 1; + report_textview_init__internal(tvc); + + return true; + } } static int report_textview_line_get(struct TextViewContext *tvc, const char **line, int *len) { - Report *report = (Report *)tvc->iter; - *line = report->message + tvc->iter_char; - *len = tvc->iter_char_next - tvc->iter_char; - return 1; + Report *report = (Report *)tvc->iter; + *line = report->message + tvc->iter_char; + *len = tvc->iter_char_next - tvc->iter_char; + return 1; } -static int report_textview_line_color(struct TextViewContext *tvc, unsigned char fg[3], unsigned char bg[3]) +static int report_textview_line_color(struct TextViewContext *tvc, + unsigned char fg[3], + unsigned char bg[3]) { - Report *report = (Report *)tvc->iter; - info_report_color(fg, bg, report, tvc->iter_tmp % 2); - return TVC_LINE_FG | TVC_LINE_BG; + Report *report = (Report *)tvc->iter; + info_report_color(fg, bg, report, tvc->iter_tmp % 2); + return TVC_LINE_FG | TVC_LINE_BG; } - -#else // USE_INFO_NEWLINE +#else // USE_INFO_NEWLINE static int report_textview_step(TextViewContext *tvc) { - SpaceInfo *sinfo = (SpaceInfo *)tvc->arg1; - const int report_mask = info_report_mask(sinfo); - do { - tvc->iter = (void *)((Link *)tvc->iter)->prev; - } while (tvc->iter && (((Report *)tvc->iter)->type & report_mask) == 0); + SpaceInfo *sinfo = (SpaceInfo *)tvc->arg1; + const int report_mask = info_report_mask(sinfo); + do { + tvc->iter = (void *)((Link *)tvc->iter)->prev; + } while (tvc->iter && (((Report *)tvc->iter)->type & report_mask) == 0); - return (tvc->iter != NULL); + return (tvc->iter != NULL); } static int report_textview_line_get(struct TextViewContext *tvc, const char **line, int *len) { - Report *report = (Report *)tvc->iter; - *line = report->message; - *len = report->len; + Report *report = (Report *)tvc->iter; + *line = report->message; + *len = report->len; - return 1; + return 1; } -static int report_textview_line_color(struct TextViewContext *tvc, unsigned char fg[3], unsigned char bg[3]) +static int report_textview_line_color(struct TextViewContext *tvc, + unsigned char fg[3], + unsigned char bg[3]) { - Report *report = (Report *)tvc->iter; - info_report_color(fg, bg, report, tvc->iter_tmp % 2); - return TVC_LINE_FG | TVC_LINE_BG; + Report *report = (Report *)tvc->iter; + info_report_color(fg, bg, report, tvc->iter_tmp % 2); + return TVC_LINE_FG | TVC_LINE_BG; } -#endif // USE_INFO_NEWLINE +#endif // USE_INFO_NEWLINE #undef USE_INFO_NEWLINE -static int info_textview_main__internal(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports, - int draw, int mval[2], void **mouse_pick, int *pos_pick) +static int info_textview_main__internal(struct SpaceInfo *sinfo, + ARegion *ar, + ReportList *reports, + int draw, + int mval[2], + void **mouse_pick, + int *pos_pick) { - int ret = 0; + int ret = 0; - View2D *v2d = &ar->v2d; + View2D *v2d = &ar->v2d; - TextViewContext tvc = {0}; - tvc.begin = report_textview_begin; - tvc.end = report_textview_end; + TextViewContext tvc = {0}; + tvc.begin = report_textview_begin; + tvc.end = report_textview_end; - tvc.step = report_textview_step; - tvc.line_get = report_textview_line_get; - tvc.line_color = report_textview_line_color; - tvc.const_colors = NULL; + tvc.step = report_textview_step; + tvc.line_get = report_textview_line_get; + tvc.line_color = report_textview_line_color; + tvc.const_colors = NULL; - tvc.arg1 = sinfo; - tvc.arg2 = reports; + tvc.arg1 = sinfo; + tvc.arg2 = reports; - /* view */ - tvc.sel_start = 0; - tvc.sel_end = 0; - tvc.lheight = 14 * UI_DPI_FAC; //sc->lheight; - tvc.ymin = v2d->cur.ymin; - tvc.ymax = v2d->cur.ymax; - tvc.winx = ar->winx - V2D_SCROLL_WIDTH; + /* view */ + tvc.sel_start = 0; + tvc.sel_end = 0; + tvc.lheight = 14 * UI_DPI_FAC; //sc->lheight; + tvc.ymin = v2d->cur.ymin; + tvc.ymax = v2d->cur.ymax; + tvc.winx = ar->winx - V2D_SCROLL_WIDTH; - ret = textview_draw(&tvc, draw, mval, mouse_pick, pos_pick); + ret = textview_draw(&tvc, draw, mval, mouse_pick, pos_pick); - return ret; + return ret; } void *info_text_pick(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports, int mouse_y) { - void *mouse_pick = NULL; - int mval[2]; + void *mouse_pick = NULL; + int mval[2]; - mval[0] = 0; - mval[1] = mouse_y; + mval[0] = 0; + mval[1] = mouse_y; - info_textview_main__internal(sinfo, ar, reports, 0, mval, &mouse_pick, NULL); - return (void *)mouse_pick; + info_textview_main__internal(sinfo, ar, reports, 0, mval, &mouse_pick, NULL); + return (void *)mouse_pick; } - int info_textview_height(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports) { - int mval[2] = {INT_MAX, INT_MAX}; - return info_textview_main__internal(sinfo, ar, reports, 0, mval, NULL, NULL); + int mval[2] = {INT_MAX, INT_MAX}; + return info_textview_main__internal(sinfo, ar, reports, 0, mval, NULL, NULL); } void info_textview_main(struct SpaceInfo *sinfo, ARegion *ar, ReportList *reports) { - int mval[2] = {INT_MAX, INT_MAX}; - info_textview_main__internal(sinfo, ar, reports, 1, mval, NULL, NULL); + int mval[2] = {INT_MAX, INT_MAX}; + info_textview_main__internal(sinfo, ar, reports, 1, mval, NULL, NULL); } |