Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-01-04 01:58:03 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-01-04 03:00:48 +0300
commit54a4c1cf359c369c8fc16ecf0ecaa92e6f650e2f (patch)
tree763437a793072d559095c6bb8d9cf23ca1c111f1 /source/blender/editors/interface/interface_style.c
parent4431c5825bf26d314abe1f79646883fd746e495b (diff)
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.
Diffstat (limited to 'source/blender/editors/interface/interface_style.c')
-rw-r--r--source/blender/editors/interface/interface_style.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index d4f6933693e..d36786fed72 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -153,7 +153,8 @@ static uiFont *uifont_to_blfont(int id)
void UI_fontstyle_draw_ex(
- const uiFontStyle *fs, const rcti *rect, const char *str, const unsigned char col[4],
+ const uiFontStyle *fs, const rcti *rect, const char *str, const uchar col[4],
+ const struct uiFontStyleDraw_Params *fs_params,
size_t len, float *r_xofs, float *r_yofs)
{
int xofs = 0, yofs;
@@ -171,13 +172,13 @@ void UI_fontstyle_draw_ex(
if (fs->kerning == 1) {
font_flag |= BLF_KERNING_DEFAULT;
}
- if (fs->word_wrap == 1) {
+ if (fs_params->word_wrap == 1) {
font_flag |= BLF_WORD_WRAP;
}
BLF_enable(fs->uifont_id, font_flag);
- if (fs->word_wrap == 1) {
+ if (fs_params->word_wrap == 1) {
/* draw from boundbox top */
yofs = BLI_rcti_size_y(rect) - BLF_height_max(fs->uifont_id);
}
@@ -187,14 +188,14 @@ void UI_fontstyle_draw_ex(
yofs = ceil(0.5f * (BLI_rcti_size_y(rect) - height));
}
- if (fs->align == UI_STYLE_TEXT_CENTER) {
+ if (fs_params->align == UI_STYLE_TEXT_CENTER) {
xofs = floor(0.5f * (BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len)));
/* don't center text if it chops off the start of the text, 2 gives some margin */
if (xofs < 2) {
xofs = 2;
}
}
- else if (fs->align == UI_STYLE_TEXT_RIGHT) {
+ else if (fs_params->align == UI_STYLE_TEXT_RIGHT) {
xofs = BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len) - 0.1f * U.widget_unit;
}
@@ -211,12 +212,14 @@ void UI_fontstyle_draw_ex(
*r_yofs = yofs;
}
-void UI_fontstyle_draw(const uiFontStyle *fs, const rcti *rect, const char *str, const unsigned char col[4])
+void UI_fontstyle_draw(
+ const uiFontStyle *fs, const rcti *rect, const char *str, const uchar col[4],
+ const struct uiFontStyleDraw_Params *fs_params)
{
float xofs, yofs;
UI_fontstyle_draw_ex(
- fs, rect, str, col,
+ fs, rect, str, col, fs_params,
BLF_DRAW_STR_DUMMY_MAX, &xofs, &yofs);
}