forked from bartvdbraak/blender
UI: Display alpha checkers in image info's color swatch.
This commit is contained in:
parent
8a3d3de3ae
commit
8901701808
@ -59,6 +59,7 @@ extern const unsigned char stipple_halftone[128];
|
||||
extern const unsigned char stipple_quarttone[128];
|
||||
extern const unsigned char stipple_diag_stripes_pos[128];
|
||||
extern const unsigned char stipple_diag_stripes_neg[128];
|
||||
extern const unsigned char stipple_checker_8px[128];
|
||||
|
||||
/**
|
||||
* Draw a lined (non-looping) arc with the given
|
||||
|
@ -726,8 +726,8 @@ void UI_exit(void);
|
||||
#define UI_LAYOUT_MENU 2
|
||||
#define UI_LAYOUT_TOOLBAR 3
|
||||
|
||||
#define UI_UNIT_X U.widget_unit
|
||||
#define UI_UNIT_Y U.widget_unit
|
||||
#define UI_UNIT_X ((void)0, U.widget_unit)
|
||||
#define UI_UNIT_Y ((void)0, U.widget_unit)
|
||||
|
||||
#define UI_LAYOUT_ALIGN_EXPAND 0
|
||||
#define UI_LAYOUT_ALIGN_LEFT 1
|
||||
@ -748,6 +748,10 @@ void UI_exit(void);
|
||||
#define UI_LAYOUT_OP_SHOW_TITLE 1
|
||||
#define UI_LAYOUT_OP_SHOW_EMPTY 2
|
||||
|
||||
/* used for transp checkers */
|
||||
#define UI_ALPHA_CHECKER_DARK 100
|
||||
#define UI_ALPHA_CHECKER_LIGHT 160
|
||||
|
||||
/* flags to set which corners will become rounded:
|
||||
*
|
||||
* 1------2
|
||||
|
@ -935,11 +935,11 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
||||
|
||||
/* first background, to show tranparency */
|
||||
|
||||
glColor4ub(UI_TRANSP_DARK, UI_TRANSP_DARK, UI_TRANSP_DARK, 255);
|
||||
glColor4ub(UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, 255);
|
||||
glRectf(x1, y1, x1 + sizex, y1 + sizey);
|
||||
glEnable(GL_POLYGON_STIPPLE);
|
||||
glColor4ub(UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, 255);
|
||||
glPolygonStipple(checker_stipple_sml);
|
||||
glColor4ub(UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, 255);
|
||||
glPolygonStipple(stipple_checker_8px);
|
||||
glRectf(x1, y1, x1 + sizex, y1 + sizey);
|
||||
glDisable(GL_POLYGON_STIPPLE);
|
||||
|
||||
|
@ -544,11 +544,6 @@ void ui_widget_color_init(struct ThemeUI *tui);
|
||||
void ui_draw_menu_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state, bool use_sep);
|
||||
void ui_draw_preview_item(struct uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state);
|
||||
|
||||
extern const unsigned char checker_stipple_sml[32 * 32 / 8];
|
||||
/* used for transp checkers */
|
||||
#define UI_TRANSP_DARK 100
|
||||
#define UI_TRANSP_LIGHT 160
|
||||
|
||||
#define UI_TEXT_MARGIN_X 0.4f
|
||||
|
||||
/* interface_style.c */
|
||||
|
@ -181,18 +181,6 @@ static const unsigned int check_tria_face[4][3] = {
|
||||
{3, 2, 4}, {3, 4, 5}, {1, 0, 3}, {0, 2, 3}
|
||||
};
|
||||
|
||||
GLubyte const checker_stipple_sml[32 * 32 / 8] =
|
||||
{
|
||||
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
|
||||
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
|
||||
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
|
||||
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
|
||||
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
|
||||
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
|
||||
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
|
||||
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
|
||||
};
|
||||
|
||||
/* ************************************************* */
|
||||
|
||||
void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3)
|
||||
@ -681,15 +669,15 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
||||
float x_mid = 0.0f; /* used for dumb clamping of values */
|
||||
|
||||
/* dark checkers */
|
||||
glColor4ub(UI_TRANSP_DARK, UI_TRANSP_DARK, UI_TRANSP_DARK, 255);
|
||||
glColor4ub(UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, 255);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v);
|
||||
glDrawArrays(GL_POLYGON, 0, wtb->totvert);
|
||||
|
||||
/* light checkers */
|
||||
glEnable(GL_POLYGON_STIPPLE);
|
||||
glColor4ub(UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, 255);
|
||||
glPolygonStipple(checker_stipple_sml);
|
||||
glColor4ub(UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, 255);
|
||||
glPolygonStipple(stipple_checker_8px);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v);
|
||||
glDrawArrays(GL_POLYGON, 0, wtb->totvert);
|
||||
|
@ -137,6 +137,16 @@ const GLubyte stipple_diag_stripes_neg[128] = {
|
||||
0x0f, 0xf0, 0x0f, 0xf0, 0x1f, 0xe0, 0x1f, 0xe0,
|
||||
0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80};
|
||||
|
||||
const GLubyte stipple_checker_8px[128] = {
|
||||
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
|
||||
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
|
||||
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
|
||||
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
|
||||
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
|
||||
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
|
||||
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
|
||||
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255};
|
||||
|
||||
|
||||
void fdrawbezier(float vec[4][3])
|
||||
{
|
||||
@ -204,22 +214,12 @@ void fdrawcheckerboard(float x1, float y1, float x2, float y2)
|
||||
{
|
||||
unsigned char col1[4] = {40, 40, 40}, col2[4] = {50, 50, 50};
|
||||
|
||||
GLubyte checker_stipple[32 * 32 / 8] = {
|
||||
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
|
||||
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
|
||||
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
|
||||
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
|
||||
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
|
||||
255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0,
|
||||
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255,
|
||||
0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255};
|
||||
|
||||
glColor3ubv(col1);
|
||||
glRectf(x1, y1, x2, y2);
|
||||
glColor3ubv(col2);
|
||||
|
||||
glEnable(GL_POLYGON_STIPPLE);
|
||||
glPolygonStipple(checker_stipple);
|
||||
glPolygonStipple(stipple_checker_8px);
|
||||
glRectf(x1, y1, x2, y2);
|
||||
glDisable(GL_POLYGON_STIPPLE);
|
||||
}
|
||||
|
@ -165,6 +165,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar, float zoomx,
|
||||
void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_default_view, int channels, int x, int y,
|
||||
const unsigned char cp[4], const float fp[4], const float linearcol[4], int *zp, float *zpf)
|
||||
{
|
||||
rcti color_rect;
|
||||
char str[256];
|
||||
int dx = 6;
|
||||
const int dy = 0.3f * UI_UNIT_Y;
|
||||
@ -317,23 +318,47 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int use_def
|
||||
}
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glColor3fv(finalcol);
|
||||
dx += 0.25f * UI_UNIT_X;
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(dx, 0.15f * UI_UNIT_Y);
|
||||
glVertex2f(dx, 0.85f * UI_UNIT_Y);
|
||||
glVertex2f(dx + 1.5f * UI_UNIT_X, 0.85 * UI_UNIT_Y);
|
||||
glVertex2f(dx + 1.5f * UI_UNIT_X, 0.15f * UI_UNIT_Y);
|
||||
glEnd();
|
||||
|
||||
BLI_rcti_init(&color_rect, dx, dx + (1.5f * UI_UNIT_X), 0.15f * UI_UNIT_Y, 0.85f * UI_UNIT_Y);
|
||||
|
||||
if (channels == 4) {
|
||||
rcti color_rect_half;
|
||||
int color_quater_x, color_quater_y;
|
||||
|
||||
color_rect_half = color_rect;
|
||||
color_rect_half.xmax = BLI_rcti_cent_x(&color_rect);
|
||||
glRecti(color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
|
||||
|
||||
color_rect_half = color_rect;
|
||||
color_rect_half.xmin = BLI_rcti_cent_x(&color_rect);
|
||||
|
||||
color_quater_x = BLI_rcti_cent_x(&color_rect_half);
|
||||
color_quater_y = BLI_rcti_cent_y(&color_rect_half);
|
||||
|
||||
glColor4ub(UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, UI_ALPHA_CHECKER_DARK, 255);
|
||||
glRecti(color_rect_half.xmin, color_rect_half.ymin, color_rect_half.xmax, color_rect_half.ymax);
|
||||
|
||||
glColor4ub(UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, UI_ALPHA_CHECKER_LIGHT, 255);
|
||||
glRecti(color_quater_x, color_quater_y, color_rect_half.xmax, color_rect_half.ymax);
|
||||
glRecti(color_rect_half.xmin, color_rect_half.ymin, color_quater_x, color_quater_y);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glColor4f(UNPACK3(finalcol), fp ? fp[3] : (cp[3] / 255.0f));
|
||||
glRecti(color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
else {
|
||||
glColor3fv(finalcol);
|
||||
glRecti(color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
|
||||
}
|
||||
|
||||
/* draw outline */
|
||||
glColor3ub(128, 128, 128);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2f(dx, 0.15f * UI_UNIT_Y);
|
||||
glVertex2f(dx, 0.85f * UI_UNIT_Y);
|
||||
glVertex2f(dx + 1.5f * UI_UNIT_X, 0.85f * UI_UNIT_Y);
|
||||
glVertex2f(dx + 1.5f * UI_UNIT_X, 0.15f * UI_UNIT_Y);
|
||||
glEnd();
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
glRecti(color_rect.xmin, color_rect.ymin, color_rect.xmax, color_rect.ymax);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
|
||||
dx += 1.75f * UI_UNIT_X;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user