Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_draw.c
| Show First 20 Lines • Show All 1,721 Lines • ▼ Show 20 Lines | if (coba->tot != 0) { | ||||
| float pos = x1 + cbd->pos * (sizex - 1) + 1; | float pos = x1 + cbd->pos * (sizex - 1) + 1; | ||||
| ui_draw_colorband_handle(pos_id, rect, pos, &cbd->r, display, true); | ui_draw_colorband_handle(pos_id, rect, pos, &cbd->r, display, true); | ||||
| } | } | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rect) | void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rect) | ||||
| { | { | ||||
| /* sphere color */ | /* sphere color */ | ||||
fclem: Code style: it's better to return early than creating indentation blocks if possible.
It does… | |||||
| float diffuse[3] = {1.0f, 1.0f, 1.0f}; | float diffuse[3] = {1.0f, 1.0f, 1.0f}; | ||||
| float light[3]; | float light[3]; | ||||
| float size; | float size; | ||||
| /* backdrop */ | /* backdrop */ | ||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| UI_draw_roundbox_3ubAlpha( | UI_draw_roundbox_3ubAlpha( | ||||
| true, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f, (uchar *)wcol->inner, 255); | true, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f, (uchar *)wcol->inner, 255); | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | static void ui_draw_but_curve_grid( | ||||
| if (fy > rect->ymin) { | if (fy > rect->ymin) { | ||||
| fy -= dy * (floorf(fy - rect->ymin)); | fy -= dy * (floorf(fy - rect->ymin)); | ||||
| } | } | ||||
| float line_count = (floorf((rect->xmax - fx) / dx) + 1.0f + floorf((rect->ymax - fy) / dy) + | float line_count = (floorf((rect->xmax - fx) / dx) + 1.0f + floorf((rect->ymax - fy) / dy) + | ||||
| 1.0f); | 1.0f); | ||||
| immBegin(GPU_PRIM_LINES, (int)line_count * 2); | immBegin(GPU_PRIM_LINES, (int)line_count * 2); | ||||
| while (fx < rect->xmax) { | while (fx <= rect->xmax) { | ||||
| immVertex2f(pos, fx, rect->ymin); | immVertex2f(pos, fx, rect->ymin); | ||||
| immVertex2f(pos, fx, rect->ymax); | immVertex2f(pos, fx, rect->ymax); | ||||
| fx += dx; | fx += dx; | ||||
| } | } | ||||
| while (fy < rect->ymax) { | while (fy <= rect->ymax) { | ||||
| immVertex2f(pos, rect->xmin, fy); | immVertex2f(pos, rect->xmin, fy); | ||||
| immVertex2f(pos, rect->xmax, fy); | immVertex2f(pos, rect->xmax, fy); | ||||
| fy += dy; | fy += dy; | ||||
| } | } | ||||
| immEnd(); | immEnd(); | ||||
| } | } | ||||
| static void gl_shaded_color_get(const uchar color[3], int shade, uchar r_color[3]) | static void gl_shaded_color_get(const uchar color[3], int shade, uchar r_color[3]) | ||||
| Show All 23 Lines | void ui_draw_but_CURVE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, const rcti *rect) | ||||
| if (but->editcumap) { | if (but->editcumap) { | ||||
| cumap = but->editcumap; | cumap = but->editcumap; | ||||
| } | } | ||||
| else { | else { | ||||
| cumap = (CurveMapping *)but->poin; | cumap = (CurveMapping *)but->poin; | ||||
| } | } | ||||
| /* calculate offset and zoom */ | |||||
| 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); | |||||
| /* exit early if too narrow */ | |||||
| if (zoomx == 0.0f) { | |||||
| return; | |||||
| } | |||||
| CurveMap *cuma = &cumap->cm[cumap->cur]; | CurveMap *cuma = &cumap->cm[cumap->cur]; | ||||
| /* need scissor test, curve can draw outside of boundary */ | /* need scissor test, curve can draw outside of boundary */ | ||||
| int scissor[4]; | int scissor[4]; | ||||
| GPU_scissor_get_i(scissor); | GPU_scissor_get_i(scissor); | ||||
| rcti scissor_new = { | rcti scissor_new = { | ||||
| .xmin = rect->xmin, | .xmin = rect->xmin, | ||||
| .ymin = rect->ymin, | .ymin = rect->ymin, | ||||
| .xmax = rect->xmax, | .xmax = rect->xmax, | ||||
| .ymax = rect->ymax, | .ymax = rect->ymax, | ||||
| }; | }; | ||||
| rcti scissor_region = {0, ar->winx, 0, ar->winy}; | rcti scissor_region = {0, ar->winx, 0, ar->winy}; | ||||
| BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new); | BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new); | ||||
| GPU_scissor(scissor_new.xmin, | GPU_scissor(scissor_new.xmin, | ||||
| scissor_new.ymin, | scissor_new.ymin, | ||||
| BLI_rcti_size_x(&scissor_new), | BLI_rcti_size_x(&scissor_new), | ||||
| BLI_rcti_size_y(&scissor_new)); | BLI_rcti_size_y(&scissor_new)); | ||||
| /* calculate offset and zoom */ | |||||
| 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); | |||||
| /* Do this first to not mess imm context */ | /* Do this first to not mess imm context */ | ||||
| if (but->a1 == UI_GRAD_H) { | if (but->a1 == UI_GRAD_H) { | ||||
| /* magic trigger for curve backgrounds */ | /* magic trigger for curve backgrounds */ | ||||
| float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */ | float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */ | ||||
| rcti grid = { | rcti grid = { | ||||
| .xmin = rect->xmin + zoomx * (-offsx), | .xmin = rect->xmin + zoomx * (-offsx), | ||||
| .xmax = grid.xmin + zoomx, | .xmax = grid.xmin + zoomx, | ||||
| ▲ Show 20 Lines • Show All 652 Lines • Show Last 20 Lines | |||||
Code style: it's better to return early than creating indentation blocks if possible.
It does not make a huge diff here in this case but better get used to it.