forked from bartvdbraak/blender
UI: tweaks to ID and non ID preview templates
- label is shown on a UI_UNIT_Y heigh instead of 0.2 * total button size - vertically centering non-ID previews labels - making some constants dependent on ui units
This commit is contained in:
parent
9e850addae
commit
b53836d2c9
@ -187,7 +187,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
|
|||||||
/* preview thumbnails */
|
/* preview thumbnails */
|
||||||
if (template.prv_rows > 0 && template.prv_cols > 0) {
|
if (template.prv_rows > 0 && template.prv_cols > 0) {
|
||||||
int w = 4 * U.widget_unit * template.prv_cols;
|
int w = 4 * U.widget_unit * template.prv_cols;
|
||||||
int h = ((int)(5.25f * U.widget_unit)) * template.prv_rows;
|
int h = 5 * U.widget_unit * template.prv_rows;
|
||||||
|
|
||||||
/* fake button, it holds space for search items */
|
/* fake button, it holds space for search items */
|
||||||
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 26, w, h, NULL, 0, 0, 0, 0, NULL);
|
uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 26, w, h, NULL, 0, 0, 0, 0, NULL);
|
||||||
@ -1668,7 +1668,7 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem)
|
|||||||
int x, y;
|
int x, y;
|
||||||
/* XXX hardcoded size to 5 units */
|
/* XXX hardcoded size to 5 units */
|
||||||
const int w = UI_UNIT_X * 5;
|
const int w = UI_UNIT_X * 5;
|
||||||
const int h = args.show_labels ? (int)(6.25f * UI_UNIT_Y) : UI_UNIT_Y * 5;
|
const int h = args.show_labels ? 6 * UI_UNIT_Y : UI_UNIT_Y * 5;
|
||||||
|
|
||||||
x = (a % 8) * w;
|
x = (a % 8) * w;
|
||||||
y = (a / 8) * h;
|
y = (a / 8) * h;
|
||||||
|
@ -1526,17 +1526,14 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
|
|||||||
/* Big previews with optional text label below */
|
/* Big previews with optional text label below */
|
||||||
if (but->flag & UI_BUT_ICON_PREVIEW && ui_block_is_menu(but->block)) {
|
if (but->flag & UI_BUT_ICON_PREVIEW && ui_block_is_menu(but->block)) {
|
||||||
const BIFIconID icon = (but->flag & UI_HAS_ICON) ? but->icon + but->iconadd : ICON_NONE;
|
const BIFIconID icon = (but->flag & UI_HAS_ICON) ? but->icon + but->iconadd : ICON_NONE;
|
||||||
const int icon_size_i = BLI_rcti_size_y(rect);
|
int icon_size = BLI_rcti_size_y(rect);
|
||||||
float icon_size, text_size;
|
int text_size = 0;
|
||||||
|
|
||||||
/* This is a bit britle, but avoids adding an 'UI_BUT_HAS_LABEL' flag to but... */
|
/* This is a bit britle, but avoids adding an 'UI_BUT_HAS_LABEL' flag to but... */
|
||||||
if (icon_size_i > BLI_rcti_size_x(rect)) {
|
if (icon_size > BLI_rcti_size_x(rect)) {
|
||||||
icon_size = 0.8f * (float)icon_size_i;
|
/* button is not square, it has extra height for label */
|
||||||
text_size = 0.2f * (float)icon_size_i;
|
text_size = UI_UNIT_Y;
|
||||||
}
|
icon_size -= text_size;
|
||||||
else {
|
|
||||||
icon_size = (float)icon_size_i;
|
|
||||||
text_size = 0.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw icon in rect above the space reserved for the label */
|
/* draw icon in rect above the space reserved for the label */
|
||||||
@ -1545,9 +1542,12 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
|
|||||||
widget_draw_preview(icon, alpha, rect);
|
widget_draw_preview(icon, alpha, rect);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
/* offset rect to draw label in*/
|
/* offset rect to draw label in */
|
||||||
rect->ymin -= text_size;
|
rect->ymin -= text_size;
|
||||||
rect->ymax -= icon_size;
|
rect->ymax -= icon_size;
|
||||||
|
|
||||||
|
/* vertically centering text */
|
||||||
|
rect->ymin += UI_UNIT_Y / 2;
|
||||||
}
|
}
|
||||||
/* Icons on the left with optional text label on the right */
|
/* Icons on the left with optional text label on the right */
|
||||||
else if (but->flag & UI_HAS_ICON || show_menu_icon) {
|
else if (but->flag & UI_HAS_ICON || show_menu_icon) {
|
||||||
@ -4113,7 +4113,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic
|
|||||||
void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state)
|
void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state)
|
||||||
{
|
{
|
||||||
rcti trect = *rect;
|
rcti trect = *rect;
|
||||||
const float text_size = 0.2f * BLI_rcti_size_y(rect);
|
const float text_size = UI_UNIT_Y;
|
||||||
float font_dims[2] = {0.0f, 0.0f};
|
float font_dims[2] = {0.0f, 0.0f};
|
||||||
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
|
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
|
||||||
|
|
||||||
@ -4131,8 +4131,8 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int
|
|||||||
|
|
||||||
/* text rect */
|
/* text rect */
|
||||||
trect.xmin += 0;
|
trect.xmin += 0;
|
||||||
trect.xmax = trect.xmin + font_dims[0] + 10;
|
trect.xmax = trect.xmin + font_dims[0] + U.widget_unit / 2;
|
||||||
trect.ymin += 10;
|
trect.ymin += U.widget_unit / 2;
|
||||||
trect.ymax = trect.ymin + font_dims[1];
|
trect.ymax = trect.ymin + font_dims[1];
|
||||||
if (trect.xmax > rect->xmax - PREVIEW_PAD)
|
if (trect.xmax > rect->xmax - PREVIEW_PAD)
|
||||||
trect.xmax = rect->xmax - PREVIEW_PAD;
|
trect.xmax = rect->xmax - PREVIEW_PAD;
|
||||||
|
Loading…
Reference in New Issue
Block a user