From 54a4c1cf359c369c8fc16ecf0ecaa92e6f650e2f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 Jan 2019 09:58:03 +1100 Subject: UI: refactor layout vars out of uiFontStyle Word wrap and alignment layout args only used by UI_fontstyle_draw were vars in uiFontStyle. These were written to before drawing, so better pass as an argument. Pass uiFontStyle & uiWidgetColors as const args. --- source/blender/editors/include/UI_interface.h | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/include') diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index b1dc5821d7a..c525d9cffe6 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -367,7 +367,7 @@ void UI_draw_widget_scroll(struct uiWidgetColors *wcol, const struct rcti *rect, /* Shortening string helper. */ float UI_text_clip_middle_ex( - struct uiFontStyle *fstyle, char *str, float okwidth, const float minwidth, + const struct uiFontStyle *fstyle, char *str, float okwidth, const float minwidth, const size_t max_len, const char rpart_sep); /* Callbacks @@ -1254,20 +1254,33 @@ struct ID *UI_context_active_but_get_tab_ID(struct bContext *C); uiBut *UI_region_active_but_get(struct ARegion *ar); +/* uiFontStyle.align */ +typedef enum eFontStyle_Align { + UI_STYLE_TEXT_LEFT = 0, + UI_STYLE_TEXT_CENTER = 1, + UI_STYLE_TEXT_RIGHT = 2 +} eFontStyle_Align; + +struct uiFontStyleDraw_Params { + eFontStyle_Align align; + uint word_wrap : 1; +}; + /* Styled text draw */ void UI_fontstyle_set(const struct uiFontStyle *fs); void UI_fontstyle_draw_ex( const struct uiFontStyle *fs, const struct rcti *rect, const char *str, - const unsigned char col[4], size_t len, float *r_xofs, float *r_yofs); + const uchar col[4], const struct uiFontStyleDraw_Params *fs_params, + size_t len, float *r_xofs, float *r_yofs); void UI_fontstyle_draw( const struct uiFontStyle *fs, const struct rcti *rect, const char *str, - const unsigned char col[4]); + const uchar col[4], const struct uiFontStyleDraw_Params *fs_params); void UI_fontstyle_draw_rotated( const struct uiFontStyle *fs, const struct rcti *rect, const char *str, - const unsigned char col[4]); + const uchar col[4]); void UI_fontstyle_draw_simple( const struct uiFontStyle *fs, float x, float y, const char *str, - const unsigned char col[4]); + const uchar col[4]); void UI_fontstyle_draw_simple_backdrop( const struct uiFontStyle *fs, float x, float y, const char *str, const float col_fg[4], const float col_bg[4]); -- cgit v1.2.3