Draw background on pulldown widgets if the header is transparent.
Since the viewport header now supports transparency, text on pulldowns can be hard to read if their color matches the viewport content. Background is drawn using the 'inner' theme color, that was unused until now.
This commit is contained in:
@@ -94,6 +94,7 @@ void ED_region_image_metadata_draw(int x, int y, struct ImBuf *ibuf, const rc
|
|||||||
void ED_region_grid_draw(struct ARegion *ar, float zoomx, float zoomy);
|
void ED_region_grid_draw(struct ARegion *ar, float zoomx, float zoomy);
|
||||||
float ED_region_blend_alpha(struct ARegion *ar);
|
float ED_region_blend_alpha(struct ARegion *ar);
|
||||||
void ED_region_visible_rect(struct ARegion *ar, struct rcti *rect);
|
void ED_region_visible_rect(struct ARegion *ar, struct rcti *rect);
|
||||||
|
bool ED_region_is_overlap(int spacetype, int regiontype);
|
||||||
|
|
||||||
int ED_region_snap_size_test(const struct ARegion *ar);
|
int ED_region_snap_size_test(const struct ARegion *ar);
|
||||||
bool ED_region_snap_size_apply(struct ARegion *ar, int snap_flag);
|
bool ED_region_snap_size_apply(struct ARegion *ar, int snap_flag);
|
||||||
|
|||||||
@@ -2626,15 +2626,9 @@ static void widget_state_nothing(uiWidgetType *wt, int UNUSED(state))
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* special case, button that calls pulldown */
|
/* special case, button that calls pulldown */
|
||||||
static void widget_state_pulldown(uiWidgetType *wt, int state)
|
static void widget_state_pulldown(uiWidgetType *wt, int UNUSED(state))
|
||||||
{
|
{
|
||||||
wt->wcol = *(wt->wcol_theme);
|
wt->wcol = *(wt->wcol_theme);
|
||||||
|
|
||||||
copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
|
|
||||||
copy_v3_v3_char(wt->wcol.outline, wt->wcol.inner);
|
|
||||||
|
|
||||||
if (state & UI_ACTIVE)
|
|
||||||
copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* special case, pie menu items */
|
/* special case, pie menu items */
|
||||||
@@ -3812,10 +3806,23 @@ static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat
|
|||||||
|
|
||||||
static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
|
||||||
{
|
{
|
||||||
if (state & UI_ACTIVE) {
|
float back[4];
|
||||||
|
UI_GetThemeColor4fv(TH_BACK, back);
|
||||||
|
|
||||||
|
if ((state & UI_ACTIVE) || (back[3] < 1.0f)) {
|
||||||
uiWidgetBase wtb;
|
uiWidgetBase wtb;
|
||||||
const float rad = wcol->roundness * U.widget_unit;
|
const float rad = wcol->roundness * U.widget_unit;
|
||||||
|
|
||||||
|
if (state & UI_ACTIVE) {
|
||||||
|
copy_v4_v4_char(wcol->inner, wcol->inner_sel);
|
||||||
|
copy_v3_v3_char(wcol->text, wcol->text_sel);
|
||||||
|
copy_v3_v3_char(wcol->outline, wcol->inner);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wcol->inner[3] *= 1.0f - back[3];
|
||||||
|
wcol->outline[3] = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
widget_init(&wtb);
|
widget_init(&wtb);
|
||||||
|
|
||||||
/* half rounded */
|
/* half rounded */
|
||||||
|
|||||||
@@ -56,6 +56,8 @@
|
|||||||
|
|
||||||
#include "BLF_api.h"
|
#include "BLF_api.h"
|
||||||
|
|
||||||
|
#include "ED_screen.h"
|
||||||
|
|
||||||
#include "UI_interface.h"
|
#include "UI_interface.h"
|
||||||
#include "UI_interface_icons.h"
|
#include "UI_interface_icons.h"
|
||||||
|
|
||||||
@@ -96,6 +98,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
|||||||
static char error[4] = {240, 0, 240, 255};
|
static char error[4] = {240, 0, 240, 255};
|
||||||
static char alert[4] = {240, 60, 60, 255};
|
static char alert[4] = {240, 60, 60, 255};
|
||||||
static char headerdesel[4] = {0, 0, 0, 255};
|
static char headerdesel[4] = {0, 0, 0, 255};
|
||||||
|
static char back[4] = {0, 0, 0, 255};
|
||||||
static char setting = 0;
|
static char setting = 0;
|
||||||
const char *cp = error;
|
const char *cp = error;
|
||||||
|
|
||||||
@@ -183,6 +186,12 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo
|
|||||||
cp = ts->header;
|
cp = ts->header;
|
||||||
else
|
else
|
||||||
cp = ts->button;
|
cp = ts->button;
|
||||||
|
|
||||||
|
copy_v4_v4_char(back, cp);
|
||||||
|
if (!ED_region_is_overlap(spacetype, theme_regionid)) {
|
||||||
|
back[3] = 255;
|
||||||
|
}
|
||||||
|
cp = back;
|
||||||
break;
|
break;
|
||||||
case TH_LOW_GRAD:
|
case TH_LOW_GRAD:
|
||||||
cp = ts->gradients.gradient;
|
cp = ts->gradients.gradient;
|
||||||
|
|||||||
@@ -1005,19 +1005,19 @@ static void region_overlap_fix(ScrArea *sa, ARegion *ar)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* overlapping regions only in the following restricted cases */
|
/* overlapping regions only in the following restricted cases */
|
||||||
static bool region_is_overlap(ScrArea *sa, ARegion *ar)
|
bool ED_region_is_overlap(int spacetype, int regiontype)
|
||||||
{
|
{
|
||||||
if (U.uiflag2 & USER_REGION_OVERLAP) {
|
if (U.uiflag2 & USER_REGION_OVERLAP) {
|
||||||
if (ELEM(sa->spacetype, SPACE_VIEW3D, SPACE_SEQ, SPACE_IMAGE)) {
|
if (ELEM(spacetype, SPACE_VIEW3D, SPACE_SEQ, SPACE_IMAGE)) {
|
||||||
if (ELEM(ar->regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS))
|
if (ELEM(regiontype, RGN_TYPE_TOOLS, RGN_TYPE_UI, RGN_TYPE_TOOL_PROPS))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (ELEM(sa->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) {
|
if (ELEM(spacetype, SPACE_VIEW3D, SPACE_IMAGE)) {
|
||||||
if (ar->regiontype == RGN_TYPE_HEADER)
|
if (regiontype == RGN_TYPE_HEADER)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (sa->spacetype == SPACE_SEQ) {
|
else if (spacetype == SPACE_SEQ) {
|
||||||
if (ar->regiontype == RGN_TYPE_PREVIEW)
|
if (regiontype == RGN_TYPE_PREVIEW)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1046,7 +1046,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti
|
|||||||
alignment = ar->alignment & ~RGN_SPLIT_PREV;
|
alignment = ar->alignment & ~RGN_SPLIT_PREV;
|
||||||
|
|
||||||
/* set here, assuming userpref switching forces to call this again */
|
/* set here, assuming userpref switching forces to call this again */
|
||||||
ar->overlap = region_is_overlap(sa, ar);
|
ar->overlap = ED_region_is_overlap(sa->spacetype, ar->regiontype);
|
||||||
|
|
||||||
/* clear state flags first */
|
/* clear state flags first */
|
||||||
ar->flag &= ~RGN_FLAG_TOO_SMALL;
|
ar->flag &= ~RGN_FLAG_TOO_SMALL;
|
||||||
|
|||||||
Reference in New Issue
Block a user