cleanup: C99
- tighter scoping - declare closer to use - struct initializers - bool vs int
This commit is contained in:
parent
a29e2c379e
commit
384a16bfbc
|
@ -145,11 +145,11 @@ void UI_draw_roundbox_gl_mode(int mode, float minx, float miny, float maxx, floa
|
|||
|
||||
static void round_box_shade_col(const float col1[3], float const col2[3], const float fac)
|
||||
{
|
||||
float col[3];
|
||||
|
||||
col[0] = (fac * col1[0] + (1.0f - fac) * col2[0]);
|
||||
col[1] = (fac * col1[1] + (1.0f - fac) * col2[1]);
|
||||
col[2] = (fac * col1[2] + (1.0f - fac) * col2[2]);
|
||||
float col[3] = {
|
||||
fac * col1[0] + (1.0f - fac) * col2[0],
|
||||
fac * col1[1] + (1.0f - fac) * col2[1],
|
||||
fac * col1[2] + (1.0f - fac) * col2[2]
|
||||
};
|
||||
glColor3fv(col);
|
||||
}
|
||||
|
||||
|
@ -413,13 +413,11 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
|
|||
(void)but;
|
||||
#else
|
||||
ImBuf *ibuf = (ImBuf *)but->poin;
|
||||
//GLint scissor[4];
|
||||
int w, h;
|
||||
|
||||
if (!ibuf) return;
|
||||
|
||||
w = BLI_rcti_size_x(rect);
|
||||
h = BLI_rcti_size_y(rect);
|
||||
int w = BLI_rcti_size_x(rect);
|
||||
int h = BLI_rcti_size_y(rect);
|
||||
|
||||
/* scissor doesn't seem to be doing the right thing...? */
|
||||
#if 0
|
||||
|
@ -427,6 +425,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
|
|||
//fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax)
|
||||
|
||||
/* prevent drawing outside widget area */
|
||||
GLint scissor[4];
|
||||
glGetIntegerv(GL_SCISSOR_BOX, scissor);
|
||||
glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h);
|
||||
#endif
|
||||
|
@ -466,10 +465,10 @@ void UI_draw_safe_areas(
|
|||
const float size_y_half = (y2 - y1) * 0.5f;
|
||||
|
||||
const float *safe_areas[] = {title_aspect, action_aspect};
|
||||
int i, safe_len = ARRAY_SIZE(safe_areas);
|
||||
int safe_len = ARRAY_SIZE(safe_areas);
|
||||
bool is_first = true;
|
||||
|
||||
for (i = 0; i < safe_len; i++) {
|
||||
for (int i = 0; i < safe_len; i++) {
|
||||
if (safe_areas[i][0] || safe_areas[i][1]) {
|
||||
float margin_x, margin_y;
|
||||
float minx, miny, maxx, maxy;
|
||||
|
@ -515,10 +514,7 @@ static void histogram_draw_one(
|
|||
float r, float g, float b, float alpha,
|
||||
float x, float y, float w, float h, const float *data, int res, const bool is_line)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (is_line) {
|
||||
|
||||
glLineWidth(1.5);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glColor4f(r, g, b, alpha);
|
||||
|
@ -528,7 +524,7 @@ static void histogram_draw_one(
|
|||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (i = 0; i < res; i++) {
|
||||
for (int i = 0; i < res; i++) {
|
||||
float x2 = x + i * (w / (float)res);
|
||||
glVertex2f(x2, y + (data[i] * h));
|
||||
}
|
||||
|
@ -546,7 +542,7 @@ static void histogram_draw_one(
|
|||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glVertex2f(x, y);
|
||||
glVertex2f(x, y + (data[0] * h));
|
||||
for (i = 1; i < res; i++) {
|
||||
for (int i = 1; i < res; i++) {
|
||||
float x2 = x + i * (w / (float)res);
|
||||
glVertex2f(x2, y + (data[i] * h));
|
||||
glVertex2f(x2, y);
|
||||
|
@ -559,7 +555,7 @@ static void histogram_draw_one(
|
|||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (i = 0; i < res; i++) {
|
||||
for (int i = 0; i < res; i++) {
|
||||
float x2 = x + i * (w / (float)res);
|
||||
glVertex2f(x2, y + (data[i] * h));
|
||||
}
|
||||
|
@ -574,20 +570,17 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
|
|||
{
|
||||
Histogram *hist = (Histogram *)but->poin;
|
||||
int res = hist->x_resolution;
|
||||
rctf rect;
|
||||
int i;
|
||||
float w, h;
|
||||
const bool is_line = (hist->flag & HISTO_FLAG_LINE) != 0;
|
||||
//float alpha;
|
||||
GLint scissor[4];
|
||||
|
||||
rect.xmin = (float)recti->xmin + 1;
|
||||
rect.xmax = (float)recti->xmax - 1;
|
||||
rect.ymin = (float)recti->ymin + 1;
|
||||
rect.ymax = (float)recti->ymax - 1;
|
||||
rctf rect = {
|
||||
.xmin = (float)recti->xmin + 1,
|
||||
.xmax = (float)recti->xmax - 1,
|
||||
.ymin = (float)recti->ymin + 1,
|
||||
.ymax = (float)recti->ymax - 1
|
||||
};
|
||||
|
||||
w = BLI_rctf_size_x(&rect);
|
||||
h = BLI_rctf_size_y(&rect) * hist->ymax;
|
||||
float w = BLI_rctf_size_x(&rect);
|
||||
float h = BLI_rctf_size_y(&rect) * hist->ymax;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
@ -597,6 +590,7 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
|
|||
UI_draw_roundbox_gl_mode(GL_POLYGON, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f);
|
||||
|
||||
/* need scissor test, histogram can draw outside of boundary */
|
||||
GLint scissor[4];
|
||||
glGetIntegerv(GL_VIEWPORT, scissor);
|
||||
glScissor(ar->winrct.xmin + (rect.xmin - 1),
|
||||
ar->winrct.ymin + (rect.ymin - 1),
|
||||
|
@ -605,7 +599,7 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
|
|||
|
||||
glColor4f(1.f, 1.f, 1.f, 0.08f);
|
||||
/* draw grid lines here */
|
||||
for (i = 1; i <= HISTOGRAM_TOT_GRID_LINES; i++) {
|
||||
for (int i = 1; i <= HISTOGRAM_TOT_GRID_LINES; i++) {
|
||||
const float fac = (float)i / (float)HISTOGRAM_TOT_GRID_LINES;
|
||||
|
||||
/* so we can tell the 1.0 color point */
|
||||
|
@ -641,9 +635,6 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
|
|||
void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti)
|
||||
{
|
||||
Scopes *scopes = (Scopes *)but->poin;
|
||||
rctf rect;
|
||||
int i, c;
|
||||
float w, w3, h, alpha, yofs;
|
||||
GLint scissor[4];
|
||||
float colors[3][3];
|
||||
float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}};
|
||||
|
@ -652,25 +643,27 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
|||
|
||||
if (scopes == NULL) return;
|
||||
|
||||
rect.xmin = (float)recti->xmin + 1;
|
||||
rect.xmax = (float)recti->xmax - 1;
|
||||
rect.ymin = (float)recti->ymin + 1;
|
||||
rect.ymax = (float)recti->ymax - 1;
|
||||
rctf rect = {
|
||||
.xmin = (float)recti->xmin + 1,
|
||||
.xmax = (float)recti->xmax - 1,
|
||||
.ymin = (float)recti->ymin + 1,
|
||||
.ymax = (float)recti->ymax - 1
|
||||
};
|
||||
|
||||
if (scopes->wavefrm_yfac < 0.5f)
|
||||
scopes->wavefrm_yfac = 0.98f;
|
||||
w = BLI_rctf_size_x(&rect) - 7;
|
||||
h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac;
|
||||
yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) / 2.0f;
|
||||
w3 = w / 3.0f;
|
||||
float w = BLI_rctf_size_x(&rect) - 7;
|
||||
float h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac;
|
||||
float yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) / 2.0f;
|
||||
float w3 = w / 3.0f;
|
||||
|
||||
/* log scale for alpha */
|
||||
alpha = scopes->wavefrm_alpha * scopes->wavefrm_alpha;
|
||||
float alpha = scopes->wavefrm_alpha * scopes->wavefrm_alpha;
|
||||
|
||||
unit_m3(colors);
|
||||
|
||||
for (c = 0; c < 3; c++) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (int c = 0; c < 3; c++) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
colors_alpha[c][i] = colors[c][i] * alpha;
|
||||
colorsycc_alpha[c][i] = colorsycc[c][i] * alpha;
|
||||
}
|
||||
|
@ -692,7 +685,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
|||
|
||||
glColor4f(1.f, 1.f, 1.f, 0.08f);
|
||||
/* draw grid lines here */
|
||||
for (i = 0; i < 6; i++) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
char str[4];
|
||||
BLI_snprintf(str, sizeof(str), "%-3d", i * 20);
|
||||
str[3] = '\0';
|
||||
|
@ -704,7 +697,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
|||
}
|
||||
/* 3 vertical separation */
|
||||
if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) {
|
||||
for (i = 1; i < 3; i++) {
|
||||
for (int i = 1; i < 3; i++) {
|
||||
fdrawline(rect.xmin + i * w3, rect.ymin, rect.xmin + i * w3, rect.ymax);
|
||||
}
|
||||
}
|
||||
|
@ -790,7 +783,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
|||
|
||||
|
||||
/* min max */
|
||||
for (c = 0; c < 3; c++) {
|
||||
for (int c = 0; c < 3; c++) {
|
||||
if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB)
|
||||
glColor3f(colors[c][0] * 0.75f, colors[c][1] * 0.75f, colors[c][2] * 0.75f);
|
||||
else
|
||||
|
@ -874,27 +867,25 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
|
|||
{
|
||||
const float skin_rad = DEG2RADF(123.0f); /* angle in radians of the skin tone line */
|
||||
Scopes *scopes = (Scopes *)but->poin;
|
||||
rctf rect;
|
||||
int i, j;
|
||||
float w, h, centerx, centery, diam;
|
||||
float alpha;
|
||||
|
||||
const float colors[6][3] = {
|
||||
{0.75, 0.0, 0.0}, {0.75, 0.75, 0.0}, {0.0, 0.75, 0.0},
|
||||
{0.0, 0.75, 0.75}, {0.0, 0.0, 0.75}, {0.75, 0.0, 0.75}};
|
||||
GLint scissor[4];
|
||||
|
||||
rect.xmin = (float)recti->xmin + 1;
|
||||
rect.xmax = (float)recti->xmax - 1;
|
||||
rect.ymin = (float)recti->ymin + 1;
|
||||
rect.ymax = (float)recti->ymax - 1;
|
||||
rctf rect = {
|
||||
.xmin = (float)recti->xmin + 1,
|
||||
.xmax = (float)recti->xmax - 1,
|
||||
.ymin = (float)recti->ymin + 1,
|
||||
.ymax = (float)recti->ymax - 1
|
||||
};
|
||||
|
||||
w = BLI_rctf_size_x(&rect);
|
||||
h = BLI_rctf_size_y(&rect);
|
||||
centerx = rect.xmin + w / 2;
|
||||
centery = rect.ymin + h / 2;
|
||||
diam = (w < h) ? w : h;
|
||||
float w = BLI_rctf_size_x(&rect);
|
||||
float h = BLI_rctf_size_y(&rect);
|
||||
float centerx = rect.xmin + w / 2;
|
||||
float centery = rect.ymin + h / 2;
|
||||
float diam = (w < h) ? w : h;
|
||||
|
||||
alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha;
|
||||
float alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
@ -904,6 +895,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
|
|||
UI_draw_roundbox_gl_mode(GL_POLYGON, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f);
|
||||
|
||||
/* need scissor test, hvectorscope can draw outside of boundary */
|
||||
GLint scissor[4];
|
||||
glGetIntegerv(GL_VIEWPORT, scissor);
|
||||
glScissor(ar->winrct.xmin + (rect.xmin - 1),
|
||||
ar->winrct.ymin + (rect.ymin - 1),
|
||||
|
@ -916,10 +908,10 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
|
|||
fdrawline(centerx - (diam / 2) - 5, centery, centerx + (diam / 2) + 5, centery);
|
||||
fdrawline(centerx, centery - (diam / 2) - 5, centerx, centery + (diam / 2) + 5);
|
||||
/* circles */
|
||||
for (j = 0; j < 5; j++) {
|
||||
for (int j = 0; j < 5; j++) {
|
||||
glBegin(GL_LINE_LOOP);
|
||||
const int increment = 15;
|
||||
for (i = 0; i <= 360 - increment; i += increment) {
|
||||
for (int i = 0; i <= 360 - increment; i += increment) {
|
||||
const float a = DEG2RADF((float)i);
|
||||
const float r = (j + 1) / 10.0f;
|
||||
glVertex2f(polar_to_x(centerx, diam, r, a), polar_to_y(centery, diam, r, a));
|
||||
|
@ -931,7 +923,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
|
|||
fdrawline(polar_to_x(centerx, diam, 0.5f, skin_rad), polar_to_y(centery, diam, 0.5, skin_rad),
|
||||
polar_to_x(centerx, diam, 0.1f, skin_rad), polar_to_y(centery, diam, 0.1, skin_rad));
|
||||
/* saturation points */
|
||||
for (i = 0; i < 6; i++)
|
||||
for (int i = 0; i < 6; i++)
|
||||
vectorscope_draw_target(centerx, centery, diam, colors[i]);
|
||||
|
||||
if (scopes->ok && scopes->vecscope != NULL) {
|
||||
|
@ -1002,14 +994,13 @@ static void ui_draw_colorband_handle(
|
|||
{
|
||||
const float sizey = BLI_rcti_size_y(rect);
|
||||
const float min_width = 3.0f;
|
||||
float half_width, height, y1, y2;
|
||||
float colf[3] = {UNPACK3(rgb)};
|
||||
|
||||
half_width = floorf(sizey / 3.5f);
|
||||
height = half_width * 1.4f;
|
||||
float half_width = floorf(sizey / 3.5f);
|
||||
float height = half_width * 1.4f;
|
||||
|
||||
y1 = rect->ymin + (sizey * 0.16f);
|
||||
y2 = rect->ymax;
|
||||
float y1 = rect->ymin + (sizey * 0.16f);
|
||||
float y2 = rect->ymax;
|
||||
|
||||
/* align to pixels */
|
||||
x = floorf(x + 0.5f);
|
||||
|
@ -1036,7 +1027,7 @@ static void ui_draw_colorband_handle(
|
|||
}
|
||||
|
||||
/* shift handle down */
|
||||
y1 = y1 - half_width;
|
||||
y1 -= half_width;
|
||||
|
||||
glColor3ub(0, 0, 0);
|
||||
ui_draw_colorband_handle_box(x - half_width, y1 - 1, x + half_width, y1 + height, false);
|
||||
|
@ -1076,25 +1067,19 @@ static void ui_draw_colorband_handle(
|
|||
|
||||
void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *rect)
|
||||
{
|
||||
ColorBand *coba;
|
||||
CBData *cbd;
|
||||
float x1, y1, sizex, sizey, sizey_solid;
|
||||
float v1[2], v2[2];
|
||||
int a;
|
||||
float pos, colf[4] = {0, 0, 0, 0}; /* initialize in case the colorband isn't valid */
|
||||
struct ColorManagedDisplay *display = NULL;
|
||||
|
||||
coba = (ColorBand *)(but->editcoba ? but->editcoba : but->poin);
|
||||
ColorBand *coba = (ColorBand *)(but->editcoba ? but->editcoba : but->poin);
|
||||
if (coba == NULL) return;
|
||||
|
||||
if (but->block->color_profile)
|
||||
display = ui_block_cm_display_get(but->block);
|
||||
|
||||
x1 = rect->xmin;
|
||||
sizex = rect->xmax - x1;
|
||||
sizey = BLI_rcti_size_y(rect);
|
||||
sizey_solid = sizey / 4;
|
||||
y1 = rect->ymin;
|
||||
float x1 = rect->xmin;
|
||||
float sizex = rect->xmax - x1;
|
||||
float sizey = BLI_rcti_size_y(rect);
|
||||
float sizey_solid = sizey / 4;
|
||||
float y1 = rect->ymin;
|
||||
|
||||
/* Drawing the checkerboard.
|
||||
* This could be optimized with a single checkerboard shader,
|
||||
|
@ -1112,14 +1097,17 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
|||
glShadeModel(GL_FLAT);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
cbd = coba->data;
|
||||
CBData *cbd = coba->data;
|
||||
|
||||
float v1[2], v2[2];
|
||||
float colf[4] = {0, 0, 0, 0}; /* initialize in case the colorband isn't valid */
|
||||
|
||||
v1[1] = y1 + sizey_solid;
|
||||
v2[1] = rect->ymax;
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
for (a = 0; a <= sizex; a++) {
|
||||
pos = ((float)a) / sizex;
|
||||
for (int a = 0; a <= sizex; a++) {
|
||||
float pos = ((float)a) / sizex;
|
||||
do_colorband(coba, pos, colf);
|
||||
if (display)
|
||||
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
|
||||
|
@ -1137,8 +1125,8 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
|||
v2[1] = y1 + sizey_solid;
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
for (a = 0; a <= sizex; a++) {
|
||||
pos = ((float)a) / sizex;
|
||||
for (int a = 0; a <= sizex; a++) {
|
||||
float pos = ((float)a) / sizex;
|
||||
do_colorband(coba, pos, colf);
|
||||
if (display)
|
||||
IMB_colormanagement_scene_linear_to_display_v3(colf, display);
|
||||
|
@ -1167,9 +1155,9 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
|||
glDisable(GL_BLEND);
|
||||
|
||||
/* layer: draw handles */
|
||||
for (a = 0; a < coba->tot; a++, cbd++) {
|
||||
for (int a = 0; a < coba->tot; a++, cbd++) {
|
||||
if (a != coba->cur) {
|
||||
pos = x1 + cbd->pos * (sizex - 1) + 1;
|
||||
float pos = x1 + cbd->pos * (sizex - 1) + 1;
|
||||
ui_draw_colorband_handle(rect, pos, &cbd->r, display, false);
|
||||
}
|
||||
}
|
||||
|
@ -1177,7 +1165,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti
|
|||
/* layer: active handle */
|
||||
if (coba->tot != 0) {
|
||||
cbd = &coba->data[coba->cur];
|
||||
pos = x1 + cbd->pos * (sizex - 1) + 1;
|
||||
float pos = x1 + cbd->pos * (sizex - 1) + 1;
|
||||
ui_draw_colorband_handle(rect, pos, &cbd->r, display, true);
|
||||
}
|
||||
}
|
||||
|
@ -1260,11 +1248,9 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
|
|||
|
||||
static void ui_draw_but_curve_grid(const rcti *rect, float zoomx, float zoomy, float offsx, float offsy, float step)
|
||||
{
|
||||
float dx, dy, fx, fy;
|
||||
|
||||
glBegin(GL_LINES);
|
||||
dx = step * zoomx;
|
||||
fx = rect->xmin + zoomx * (-offsx);
|
||||
float dx = step * zoomx;
|
||||
float fx = rect->xmin + zoomx * (-offsx);
|
||||
if (fx > rect->xmin) fx -= dx * (floorf(fx - rect->xmin));
|
||||
while (fx < rect->xmax) {
|
||||
glVertex2f(fx, rect->ymin);
|
||||
|
@ -1272,8 +1258,8 @@ static void ui_draw_but_curve_grid(const rcti *rect, float zoomx, float zoomy, f
|
|||
fx += dx;
|
||||
}
|
||||
|
||||
dy = step * zoomy;
|
||||
fy = rect->ymin + zoomy * (-offsy);
|
||||
float dy = step * zoomy;
|
||||
float fy = rect->ymin + zoomy * (-offsy);
|
||||
if (fy > rect->ymin) fy -= dy * (floorf(fy - rect->ymin));
|
||||
while (fy < rect->ymax) {
|
||||
glVertex2f(rect->xmin, fy);
|
||||
|
@ -1294,12 +1280,6 @@ static void gl_shaded_color(unsigned char *col, int shade)
|
|||
void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti *rect)
|
||||
{
|
||||
CurveMapping *cumap;
|
||||
CurveMap *cuma;
|
||||
CurveMapPoint *cmp;
|
||||
float fx, fy, fac[2], zoomx, zoomy, offsx, offsy;
|
||||
GLint scissor[4];
|
||||
rcti scissor_new;
|
||||
int a;
|
||||
|
||||
if (but->editcumap) {
|
||||
cumap = but->editcumap;
|
||||
|
@ -1308,14 +1288,17 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
|||
cumap = (CurveMapping *)but->poin;
|
||||
}
|
||||
|
||||
cuma = &cumap->cm[cumap->cur];
|
||||
CurveMap *cuma = &cumap->cm[cumap->cur];
|
||||
|
||||
/* need scissor test, curve can draw outside of boundary */
|
||||
GLint scissor[4];
|
||||
glGetIntegerv(GL_VIEWPORT, scissor);
|
||||
scissor_new.xmin = ar->winrct.xmin + rect->xmin;
|
||||
scissor_new.ymin = ar->winrct.ymin + rect->ymin;
|
||||
scissor_new.xmax = ar->winrct.xmin + rect->xmax;
|
||||
scissor_new.ymax = ar->winrct.ymin + rect->ymax;
|
||||
rcti scissor_new = {
|
||||
.xmin = ar->winrct.xmin + rect->xmin,
|
||||
.ymin = ar->winrct.ymin + rect->ymin,
|
||||
.xmax = ar->winrct.xmin + rect->xmax,
|
||||
.ymax = ar->winrct.ymin + rect->ymax
|
||||
};
|
||||
BLI_rcti_isect(&scissor_new, &ar->winrct, &scissor_new);
|
||||
glScissor(scissor_new.xmin,
|
||||
scissor_new.ymin,
|
||||
|
@ -1323,21 +1306,22 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
|||
BLI_rcti_size_y(&scissor_new));
|
||||
|
||||
/* calculate offset and zoom */
|
||||
zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&cumap->curr);
|
||||
zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&cumap->curr);
|
||||
offsx = cumap->curr.xmin - (1.0f / zoomx);
|
||||
offsy = cumap->curr.ymin - (1.0f / zoomy);
|
||||
float zoomx = (BLI_rcti_size_x(rect) - 2.0f) / BLI_rctf_size_x(&cumap->curr);
|
||||
float zoomy = (BLI_rcti_size_y(rect) - 2.0f) / BLI_rctf_size_y(&cumap->curr);
|
||||
float offsx = cumap->curr.xmin - (1.0f / zoomx);
|
||||
float offsy = cumap->curr.ymin - (1.0f / zoomy);
|
||||
|
||||
/* backdrop */
|
||||
if (but->a1 == UI_GRAD_H) {
|
||||
/* magic trigger for curve backgrounds */
|
||||
rcti grid;
|
||||
float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */
|
||||
|
||||
grid.xmin = rect->xmin + zoomx * (-offsx);
|
||||
grid.xmax = grid.xmin + zoomx;
|
||||
grid.ymin = rect->ymin + zoomy * (-offsy);
|
||||
grid.ymax = grid.ymin + zoomy;
|
||||
rcti grid = {
|
||||
.xmin = rect->xmin + zoomx * (-offsx),
|
||||
.xmax = grid.xmin + zoomx,
|
||||
.ymin = rect->ymin + zoomy * (-offsy),
|
||||
.ymax = grid.ymin + zoomy
|
||||
};
|
||||
|
||||
ui_draw_gradient(&grid, col, UI_GRAD_H, 1.0f);
|
||||
|
||||
|
@ -1433,20 +1417,21 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
|||
|
||||
if (cuma->table == NULL)
|
||||
curvemapping_changed(cumap, false);
|
||||
cmp = cuma->table;
|
||||
|
||||
|
||||
CurveMapPoint *cmp = cuma->table;
|
||||
|
||||
/* first point */
|
||||
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
|
||||
glVertex2f(rect->xmin, rect->ymin + zoomy * (cmp[0].y - offsy));
|
||||
}
|
||||
else {
|
||||
fx = rect->xmin + zoomx * (cmp[0].x - offsx + cuma->ext_in[0]);
|
||||
fy = rect->ymin + zoomy * (cmp[0].y - offsy + cuma->ext_in[1]);
|
||||
float fx = rect->xmin + zoomx * (cmp[0].x - offsx + cuma->ext_in[0]);
|
||||
float fy = rect->ymin + zoomy * (cmp[0].y - offsy + cuma->ext_in[1]);
|
||||
glVertex2f(fx, fy);
|
||||
}
|
||||
for (a = 0; a <= CM_TABLE; a++) {
|
||||
fx = rect->xmin + zoomx * (cmp[a].x - offsx);
|
||||
fy = rect->ymin + zoomy * (cmp[a].y - offsy);
|
||||
for (int a = 0; a <= CM_TABLE; a++) {
|
||||
float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
|
||||
float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
|
||||
glVertex2f(fx, fy);
|
||||
}
|
||||
/* last point */
|
||||
|
@ -1454,8 +1439,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
|||
glVertex2f(rect->xmax, rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy));
|
||||
}
|
||||
else {
|
||||
fx = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]);
|
||||
fy = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]);
|
||||
float fx = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]);
|
||||
float fy = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]);
|
||||
glVertex2f(fx, fy);
|
||||
}
|
||||
glEnd();
|
||||
|
@ -1466,14 +1451,14 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
|||
cmp = cuma->curve;
|
||||
glPointSize(3.0f);
|
||||
glBegin(GL_POINTS);
|
||||
for (a = 0; a < cuma->totpoint; a++) {
|
||||
for (int a = 0; a < cuma->totpoint; a++) {
|
||||
if (cmp[a].flag & CUMA_SELECT)
|
||||
UI_ThemeColor(TH_TEXT_HI);
|
||||
else
|
||||
UI_ThemeColor(TH_TEXT);
|
||||
fac[0] = rect->xmin + zoomx * (cmp[a].x - offsx);
|
||||
fac[1] = rect->ymin + zoomy * (cmp[a].y - offsy);
|
||||
glVertex2fv(fac);
|
||||
float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
|
||||
float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
|
||||
glVertex2f(fx, fy);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
|
@ -1487,24 +1472,24 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
|
|||
|
||||
void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti)
|
||||
{
|
||||
rctf rect;
|
||||
bool ok = false;
|
||||
int width, height;
|
||||
GLint scissor[4];
|
||||
MovieClipScopes *scopes = (MovieClipScopes *)but->poin;
|
||||
|
||||
rect.xmin = (float)recti->xmin + 1;
|
||||
rect.xmax = (float)recti->xmax - 1;
|
||||
rect.ymin = (float)recti->ymin + 1;
|
||||
rect.ymax = (float)recti->ymax - 1;
|
||||
rctf rect = {
|
||||
.xmin = (float)recti->xmin + 1,
|
||||
.xmax = (float)recti->xmax - 1,
|
||||
.ymin = (float)recti->ymin + 1,
|
||||
.ymax = (float)recti->ymax - 1
|
||||
};
|
||||
|
||||
width = BLI_rctf_size_x(&rect) + 1;
|
||||
height = BLI_rctf_size_y(&rect);
|
||||
int width = BLI_rctf_size_x(&rect) + 1;
|
||||
int height = BLI_rctf_size_y(&rect);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
/* need scissor test, preview image can draw outside of boundary */
|
||||
GLint scissor[4];
|
||||
glGetIntegerv(GL_VIEWPORT, scissor);
|
||||
glScissor(ar->winrct.xmin + (rect.xmin - 1),
|
||||
ar->winrct.ymin + (rect.ymin - 1),
|
||||
|
@ -1516,22 +1501,19 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
|||
UI_draw_roundbox_corner_set(UI_CNR_ALL);
|
||||
UI_draw_roundbox_gl_mode(GL_POLYGON, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f);
|
||||
|
||||
ok = 1;
|
||||
ok = true;
|
||||
}
|
||||
else if ((scopes->track_search) &&
|
||||
((!scopes->track_preview) ||
|
||||
(scopes->track_preview->x != width || scopes->track_preview->y != height)))
|
||||
{
|
||||
ImBuf *tmpibuf;
|
||||
|
||||
if (scopes->track_preview)
|
||||
IMB_freeImBuf(scopes->track_preview);
|
||||
|
||||
tmpibuf = BKE_tracking_sample_pattern(scopes->frame_width, scopes->frame_height,
|
||||
scopes->track_search, scopes->track,
|
||||
&scopes->undist_marker, true, scopes->use_track_mask,
|
||||
width, height, scopes->track_pos);
|
||||
|
||||
ImBuf *tmpibuf = BKE_tracking_sample_pattern(scopes->frame_width, scopes->frame_height,
|
||||
scopes->track_search, scopes->track,
|
||||
&scopes->undist_marker, true, scopes->use_track_mask,
|
||||
width, height, scopes->track_pos);
|
||||
if (tmpibuf) {
|
||||
if (tmpibuf->rect_float)
|
||||
IMB_rect_from_float(tmpibuf);
|
||||
|
@ -1544,20 +1526,13 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
|||
}
|
||||
|
||||
if (!ok && scopes->track_preview) {
|
||||
float track_pos[2];
|
||||
int a;
|
||||
ImBuf *drawibuf;
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
track_pos[0] = scopes->track_pos[0];
|
||||
track_pos[1] = scopes->track_pos[1];
|
||||
|
||||
/* draw content of pattern area */
|
||||
glScissor(ar->winrct.xmin + rect.xmin, ar->winrct.ymin + rect.ymin, scissor[2], scissor[3]);
|
||||
|
||||
if (width > 0 && height > 0) {
|
||||
drawibuf = scopes->track_preview;
|
||||
ImBuf *drawibuf = scopes->track_preview;
|
||||
|
||||
if (scopes->use_track_mask) {
|
||||
glColor4f(0.0f, 0.0f, 0.0f, 0.3f);
|
||||
|
@ -1568,14 +1543,14 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
|||
glaDrawPixelsSafe(rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y,
|
||||
drawibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, drawibuf->rect);
|
||||
|
||||
/* draw cross for pizel position */
|
||||
glTranslatef(rect.xmin + track_pos[0], rect.ymin + track_pos[1], 0.f);
|
||||
/* draw cross for pixel position */
|
||||
glTranslatef(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1], 0.f);
|
||||
glScissor(ar->winrct.xmin + rect.xmin,
|
||||
ar->winrct.ymin + rect.ymin,
|
||||
BLI_rctf_size_x(&rect),
|
||||
BLI_rctf_size_y(&rect));
|
||||
|
||||
for (a = 0; a < 2; a++) {
|
||||
for (int a = 0; a < 2; a++) {
|
||||
if (a == 1) {
|
||||
glLineStipple(3, 0xaaaa);
|
||||
glEnable(GL_LINE_STIPPLE);
|
||||
|
@ -1597,7 +1572,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
|||
glDisable(GL_LINE_STIPPLE);
|
||||
glPopMatrix();
|
||||
|
||||
ok = 1;
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
|
@ -1631,32 +1606,32 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
|
|||
0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f,
|
||||
};
|
||||
|
||||
unsigned char *col = but->col;
|
||||
int a;
|
||||
GLint scissor[4];
|
||||
rcti scissor_new;
|
||||
float x, y;
|
||||
|
||||
x = 0.5f * (recti->xmin + recti->xmax);
|
||||
y = 0.5f * (recti->ymin + recti->ymax);
|
||||
|
||||
/* need scissor test, can draw outside of boundary */
|
||||
glGetIntegerv(GL_VIEWPORT, scissor);
|
||||
scissor_new.xmin = ar->winrct.xmin + recti->xmin;
|
||||
scissor_new.ymin = ar->winrct.ymin + recti->ymin;
|
||||
scissor_new.xmax = ar->winrct.xmin + recti->xmax;
|
||||
scissor_new.ymax = ar->winrct.ymin + recti->ymax;
|
||||
|
||||
rcti scissor_new = {
|
||||
.xmin = ar->winrct.xmin + recti->xmin,
|
||||
.ymin = ar->winrct.ymin + recti->ymin,
|
||||
.xmax = ar->winrct.xmin + recti->xmax,
|
||||
.ymax = ar->winrct.ymin + recti->ymax
|
||||
};
|
||||
|
||||
BLI_rcti_isect(&scissor_new, &ar->winrct, &scissor_new);
|
||||
glScissor(scissor_new.xmin,
|
||||
scissor_new.ymin,
|
||||
BLI_rcti_size_x(&scissor_new),
|
||||
BLI_rcti_size_y(&scissor_new));
|
||||
|
||||
glColor4ubv(col);
|
||||
glColor4ubv(but->col);
|
||||
|
||||
float x = 0.5f * (recti->xmin + recti->xmax);
|
||||
float y = 0.5f * (recti->ymin + recti->ymax);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBegin(GL_POLYGON);
|
||||
for (a = 0; a < 16; a++)
|
||||
for (int a = 0; a < 16; a++)
|
||||
glVertex2f(x + size * si[a], y + size * co[a]);
|
||||
glEnd();
|
||||
glDisable(GL_BLEND);
|
||||
|
@ -1666,7 +1641,7 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
|
|||
glEnable(GL_BLEND);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
for (a = 0; a < 16; a++)
|
||||
for (int a = 0; a < 16; a++)
|
||||
glVertex2f(x + size * si[a], y + size * co[a]);
|
||||
glEnd();
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
|
@ -1728,19 +1703,14 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
|
|||
|
||||
void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha, int UNUSED(select))
|
||||
{
|
||||
int i;
|
||||
float rad;
|
||||
float a;
|
||||
float dalpha = alpha * 2.0f / 255.0f, calpha;
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
if (radius > (BLI_rctf_size_y(rct) - 10.0f) / 2.0f)
|
||||
rad = (BLI_rctf_size_y(rct) - 10.0f) / 2.0f;
|
||||
else
|
||||
rad = radius;
|
||||
|
||||
i = 12;
|
||||
int a, i = 12;
|
||||
#if 0
|
||||
if (select) {
|
||||
a = i * aspect; /* same as below */
|
||||
|
@ -1750,8 +1720,11 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha
|
|||
{
|
||||
a = i * aspect;
|
||||
}
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
calpha = dalpha;
|
||||
const float dalpha = alpha * 2.0f / 255.0f;
|
||||
float calpha = dalpha;
|
||||
for (; i--; a -= aspect) {
|
||||
/* alpha ranges from 2 to 20 or so */
|
||||
glColor4f(0.0f, 0.0f, 0.0f, calpha);
|
||||
|
|
Loading…
Reference in New Issue