Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-30 05:51:25 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-30 05:51:25 +0400
commita6ebffe182e3867b8a365499c7eb990fb277cbe7 (patch)
tree4bd67917e822a49eb7d939cafd1d6e57a3b6b4f5 /source/blender/editors/interface
parent7b60ebf398757e40006b239d52562874b6b07784 (diff)
style cleanup: interface
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface.c1894
-rw-r--r--source/blender/editors/interface/interface_anim.c30
-rw-r--r--source/blender/editors/interface/interface_draw.c872
-rw-r--r--source/blender/editors/interface/interface_handlers.c3144
-rw-r--r--source/blender/editors/interface/interface_icons.c358
-rw-r--r--source/blender/editors/interface/interface_layout.c1236
-rw-r--r--source/blender/editors/interface/interface_ops.c126
-rw-r--r--source/blender/editors/interface/interface_panel.c644
-rw-r--r--source/blender/editors/interface/interface_regions.c1307
-rw-r--r--source/blender/editors/interface/interface_style.c188
-rw-r--r--source/blender/editors/interface/interface_templates.c1044
-rw-r--r--source/blender/editors/interface/interface_utils.c56
-rw-r--r--source/blender/editors/interface/interface_widgets.c1534
-rw-r--r--source/blender/editors/interface/resources.c1420
-rw-r--r--source/blender/editors/interface/view2d.c896
-rw-r--r--source/blender/editors/interface/view2d_ops.c515
16 files changed, 7640 insertions, 7624 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index b6821abf243..1cb51e8f6fa 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -72,16 +72,16 @@
#include "interface_intern.h"
-#define MENU_WIDTH 120
-#define MENU_ITEM_HEIGHT 20
-#define MENU_SEP_HEIGHT 6
+#define MENU_WIDTH 120
+#define MENU_ITEM_HEIGHT 20
+#define MENU_SEP_HEIGHT 6
#define PRECISION_FLOAT_MAX 6
#define PRECISION_FLOAT_MAX_POW 1000000 /* pow(10, PRECISION_FLOAT_MAX) */
/* avoid unneeded calls to ui_get_but_val */
#define UI_BUT_VALUE_UNSET DBL_MAX
-#define UI_GET_BUT_VALUE_INIT(_but, _value) if (_value == DBL_MAX) { (_value)= ui_get_but_val(_but); }
+#define UI_GET_BUT_VALUE_INIT(_but, _value) if (_value == DBL_MAX) { (_value) = ui_get_but_val(_but); }
/*
* a full doc with API notes can be found in bf-blender/trunk/blender/doc/guides/interface_API.txt
@@ -99,41 +99,41 @@ void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y
float gx, gy;
int sx, sy, getsizex, getsizey;
- getsizex= ar->winrct.xmax-ar->winrct.xmin+1;
- getsizey= ar->winrct.ymax-ar->winrct.ymin+1;
- sx= ar->winrct.xmin;
- sy= ar->winrct.ymin;
+ getsizex = ar->winrct.xmax - ar->winrct.xmin + 1;
+ getsizey = ar->winrct.ymax - ar->winrct.ymin + 1;
+ sx = ar->winrct.xmin;
+ sy = ar->winrct.ymin;
- gx= *x;
- gy= *y;
+ gx = *x;
+ gy = *y;
if (block->panel) {
gx += block->panel->ofsx;
gy += block->panel->ofsy;
}
- *x= ((float)sx) + ((float)getsizex)*(0.5f+ 0.5f*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0]));
- *y= ((float)sy) + ((float)getsizey)*(0.5f+ 0.5f*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1]));
+ *x = ((float)sx) + ((float)getsizex) * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] + block->winmat[3][0]));
+ *y = ((float)sy) + ((float)getsizey) * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] + block->winmat[3][1]));
}
void ui_block_to_window(const ARegion *ar, uiBlock *block, int *x, int *y)
{
float fx, fy;
- fx= *x;
- fy= *y;
+ fx = *x;
+ fy = *y;
ui_block_to_window_fl(ar, block, &fx, &fy);
- *x= (int)(fx+0.5f);
- *y= (int)(fy+0.5f);
+ *x = (int)(fx + 0.5f);
+ *y = (int)(fy + 0.5f);
}
void ui_block_to_window_rct(const ARegion *ar, uiBlock *block, rctf *graph, rcti *winr)
{
rctf tmpr;
- tmpr= *graph;
+ tmpr = *graph;
ui_block_to_window_fl(ar, block, &tmpr.xmin, &tmpr.ymin);
ui_block_to_window_fl(ar, block, &tmpr.xmax, &tmpr.ymax);
@@ -143,29 +143,29 @@ void ui_block_to_window_rct(const ARegion *ar, uiBlock *block, rctf *graph, rcti
winr->ymax = tmpr.ymax;
}
-void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y) /* for mouse cursor */
+void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y) /* for mouse cursor */
{
float a, b, c, d, e, f, px, py;
int sx, sy, getsizex, getsizey;
- getsizex= ar->winrct.xmax-ar->winrct.xmin+1;
- getsizey= ar->winrct.ymax-ar->winrct.ymin+1;
- sx= ar->winrct.xmin;
- sy= ar->winrct.ymin;
+ getsizex = ar->winrct.xmax - ar->winrct.xmin + 1;
+ getsizey = ar->winrct.ymax - ar->winrct.ymin + 1;
+ sx = ar->winrct.xmin;
+ sy = ar->winrct.ymin;
- a= 0.5f*((float)getsizex)*block->winmat[0][0];
- b= 0.5f*((float)getsizex)*block->winmat[1][0];
- c= 0.5f*((float)getsizex)*(1.0f+block->winmat[3][0]);
+ a = 0.5f * ((float)getsizex) * block->winmat[0][0];
+ b = 0.5f * ((float)getsizex) * block->winmat[1][0];
+ c = 0.5f * ((float)getsizex) * (1.0f + block->winmat[3][0]);
- d= 0.5f*((float)getsizey)*block->winmat[0][1];
- e= 0.5f*((float)getsizey)*block->winmat[1][1];
- f= 0.5f*((float)getsizey)*(1.0f+block->winmat[3][1]);
+ d = 0.5f * ((float)getsizey) * block->winmat[0][1];
+ e = 0.5f * ((float)getsizey) * block->winmat[1][1];
+ f = 0.5f * ((float)getsizey) * (1.0f + block->winmat[3][1]);
- px= *x - sx;
- py= *y - sy;
+ px = *x - sx;
+ py = *y - sy;
- *y= (a*(py-f) + d*(c-px))/(a*e-d*b);
- *x= (px- b*(*y)- c)/a;
+ *y = (a * (py - f) + d * (c - px)) / (a * e - d * b);
+ *x = (px - b * (*y) - c) / a;
if (block->panel) {
*x -= block->panel->ofsx;
@@ -177,19 +177,19 @@ void ui_window_to_block(const ARegion *ar, uiBlock *block, int *x, int *y)
{
float fx, fy;
- fx= *x;
- fy= *y;
+ fx = *x;
+ fy = *y;
ui_window_to_block_fl(ar, block, &fx, &fy);
- *x= (int)(fx+0.5f);
- *y= (int)(fy+0.5f);
+ *x = (int)(fx + 0.5f);
+ *y = (int)(fy + 0.5f);
}
void ui_window_to_region(const ARegion *ar, int *x, int *y)
{
- *x-= ar->winrct.xmin;
- *y-= ar->winrct.ymin;
+ *x -= ar->winrct.xmin;
+ *y -= ar->winrct.ymin;
}
/* ******************* block calc ************************* */
@@ -198,7 +198,7 @@ void ui_block_translate(uiBlock *block, int x, int y)
{
uiBut *bt;
- for (bt= block->buttons.first; bt; bt=bt->next) {
+ for (bt = block->buttons.first; bt; bt = bt->next) {
bt->x1 += x;
bt->y1 += y;
bt->x2 += x;
@@ -213,16 +213,16 @@ void ui_block_translate(uiBlock *block, int x, int y)
static void ui_text_bounds_block(uiBlock *block, float offset)
{
- uiStyle *style=UI_GetStyle();
+ uiStyle *style = UI_GetStyle();
uiBut *bt;
- int i = 0, j, x1addval= offset, nextcol;
- int lastcol= 0, col= 0;
+ int i = 0, j, x1addval = offset, nextcol;
+ int lastcol = 0, col = 0;
uiStyleFontSet(&style->widget);
- for (bt= block->buttons.first; bt; bt= bt->next) {
- if (bt->type!=SEPR) {
- j= BLF_width(style->widget.uifont_id, bt->drawstr);
+ for (bt = block->buttons.first; bt; bt = bt->next) {
+ if (bt->type != SEPR) {
+ j = BLF_width(style->widget.uifont_id, bt->drawstr);
if (j > i) i = j;
}
@@ -232,26 +232,26 @@ static void ui_text_bounds_block(uiBlock *block, float offset)
}
/* cope with multi collumns */
- bt= block->buttons.first;
+ bt = block->buttons.first;
while (bt) {
if (bt->next && bt->x1 < bt->next->x1) {
- nextcol= 1;
+ nextcol = 1;
col++;
}
- else nextcol= 0;
+ else nextcol = 0;
bt->x1 = x1addval;
bt->x2 = bt->x1 + i + block->bounds;
if (col == lastcol)
- bt->x2= MAX2(bt->x2, offset + block->minbounds);
+ bt->x2 = MAX2(bt->x2, offset + block->minbounds);
- ui_check_but(bt); // clips text again
+ ui_check_but(bt); // clips text again
if (nextcol)
- x1addval+= i + block->bounds;
+ x1addval += i + block->bounds;
- bt= bt->next;
+ bt = bt->next;
}
}
@@ -260,26 +260,26 @@ void ui_bounds_block(uiBlock *block)
uiBut *bt;
int xof;
- if (block->buttons.first==NULL) {
+ if (block->buttons.first == NULL) {
if (block->panel) {
- block->minx= 0.0; block->maxx= block->panel->sizex;
- block->miny= 0.0; block->maxy= block->panel->sizey;
+ block->minx = 0.0; block->maxx = block->panel->sizex;
+ block->miny = 0.0; block->maxy = block->panel->sizey;
}
}
else {
- block->minx= block->miny= 10000;
- block->maxx= block->maxy= -10000;
+ block->minx = block->miny = 10000;
+ block->maxx = block->maxy = -10000;
- bt= block->buttons.first;
+ bt = block->buttons.first;
while (bt) {
- if (bt->x1 < block->minx) block->minx= bt->x1;
- if (bt->y1 < block->miny) block->miny= bt->y1;
+ if (bt->x1 < block->minx) block->minx = bt->x1;
+ if (bt->y1 < block->miny) block->miny = bt->y1;
- if (bt->x2 > block->maxx) block->maxx= bt->x2;
- if (bt->y2 > block->maxy) block->maxy= bt->y2;
+ if (bt->x2 > block->maxx) block->maxx = bt->x2;
+ if (bt->y2 > block->maxy) block->maxy = bt->y2;
- bt= bt->next;
+ bt = bt->next;
}
block->minx -= block->bounds;
@@ -288,22 +288,22 @@ void ui_bounds_block(uiBlock *block)
block->maxy += block->bounds;
}
- block->maxx= block->minx + MAX2(block->maxx - block->minx, block->minbounds);
+ block->maxx = block->minx + MAX2(block->maxx - block->minx, block->minbounds);
/* hardcoded exception... but that one is annoying with larger safety */
- bt= block->buttons.first;
- if (bt && strncmp(bt->str, "ERROR", 5)==0) xof= 10;
- else xof= 40;
-
- block->safety.xmin = block->minx-xof;
- block->safety.ymin = block->miny-xof;
- block->safety.xmax = block->maxx+xof;
- block->safety.ymax = block->maxy+xof;
+ bt = block->buttons.first;
+ if (bt && strncmp(bt->str, "ERROR", 5) == 0) xof = 10;
+ else xof = 40;
+
+ block->safety.xmin = block->minx - xof;
+ block->safety.ymin = block->miny - xof;
+ block->safety.xmax = block->maxx + xof;
+ block->safety.ymax = block->maxy + xof;
}
static void ui_centered_bounds_block(const bContext *C, uiBlock *block)
{
- wmWindow *window= CTX_wm_window(C);
+ wmWindow *window = CTX_wm_window(C);
int xmax, ymax;
int startx, starty;
int width, height;
@@ -316,8 +316,8 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block)
ui_bounds_block(block);
- width= block->maxx - block->minx;
- height= block->maxy - block->miny;
+ width = block->maxx - block->minx;
+ height = block->maxy - block->miny;
startx = (xmax * 0.5f) - (width * 0.5f);
starty = (ymax * 0.5f) - (height * 0.5f);
@@ -330,60 +330,60 @@ static void ui_centered_bounds_block(const bContext *C, uiBlock *block)
}
static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_calc)
{
- wmWindow *window= CTX_wm_window(C);
+ wmWindow *window = CTX_wm_window(C);
int startx, starty, endx, endy, width, height, oldwidth, oldheight;
int oldbounds, xmax, ymax;
- oldbounds= block->bounds;
+ oldbounds = block->bounds;
/* compute mouse position with user defined offset */
ui_bounds_block(block);
wm_window_get_size(window, &xmax, &ymax);
- oldwidth= block->maxx - block->minx;
- oldheight= block->maxy - block->miny;
+ oldwidth = block->maxx - block->minx;
+ oldheight = block->maxy - block->miny;
/* first we ensure wide enough text bounds */
- if (bounds_calc==UI_BLOCK_BOUNDS_POPUP_MENU) {
+ if (bounds_calc == UI_BLOCK_BOUNDS_POPUP_MENU) {
if (block->flag & UI_BLOCK_LOOP) {
- block->bounds= 50;
+ block->bounds = 50;
ui_text_bounds_block(block, block->minx);
}
}
/* next we recompute bounds */
- block->bounds= oldbounds;
+ block->bounds = oldbounds;
ui_bounds_block(block);
/* and we adjust the position to fit within window */
- width= block->maxx - block->minx;
- height= block->maxy - block->miny;
+ width = block->maxx - block->minx;
+ height = block->maxy - block->miny;
/* avoid divide by zero below, caused by calling with no UI, but better not crash */
- oldwidth= oldwidth > 0 ? oldwidth : MAX2(1, width);
- oldheight= oldheight > 0 ? oldheight : MAX2(1, height);
+ oldwidth = oldwidth > 0 ? oldwidth : MAX2(1, width);
+ oldheight = oldheight > 0 ? oldheight : MAX2(1, height);
/* offset block based on mouse position, user offset is scaled
* along in case we resized the block in ui_text_bounds_block */
- startx= window->eventstate->x + block->minx + (block->mx*width)/oldwidth;
- starty= window->eventstate->y + block->miny + (block->my*height)/oldheight;
+ startx = window->eventstate->x + block->minx + (block->mx * width) / oldwidth;
+ starty = window->eventstate->y + block->miny + (block->my * height) / oldheight;
- if (startx<10)
- startx= 10;
- if (starty<10)
- starty= 10;
-
- endx= startx+width;
- endy= starty+height;
-
- if (endx>xmax) {
- endx= xmax-10;
- startx= endx-width;
+ if (startx < 10)
+ startx = 10;
+ if (starty < 10)
+ starty = 10;
+
+ endx = startx + width;
+ endy = starty + height;
+
+ if (endx > xmax) {
+ endx = xmax - 10;
+ startx = endx - width;
}
- if (endy>ymax-20) {
- endy= ymax-20;
- starty= endy-height;
+ if (endy > ymax - 20) {
+ endy = ymax - 20;
+ starty = endy - height;
}
ui_block_translate(block, startx - block->minx, starty - block->miny);
@@ -395,43 +395,43 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_
/* used for various cases */
void uiBoundsBlock(uiBlock *block, int addval)
{
- if (block==NULL)
+ if (block == NULL)
return;
- block->bounds= addval;
- block->dobounds= UI_BLOCK_BOUNDS;
+ block->bounds = addval;
+ block->dobounds = UI_BLOCK_BOUNDS;
}
/* used for pulldowns */
void uiTextBoundsBlock(uiBlock *block, int addval)
{
- block->bounds= addval;
- block->dobounds= UI_BLOCK_BOUNDS_TEXT;
+ block->bounds = addval;
+ block->dobounds = UI_BLOCK_BOUNDS_TEXT;
}
/* used for block popups */
void uiPopupBoundsBlock(uiBlock *block, int addval, int mx, int my)
{
- block->bounds= addval;
- block->dobounds= UI_BLOCK_BOUNDS_POPUP_MOUSE;
- block->mx= mx;
- block->my= my;
+ block->bounds = addval;
+ block->dobounds = UI_BLOCK_BOUNDS_POPUP_MOUSE;
+ block->mx = mx;
+ block->my = my;
}
/* used for menu popups */
void uiMenuPopupBoundsBlock(uiBlock *block, int addval, int mx, int my)
{
- block->bounds= addval;
- block->dobounds= UI_BLOCK_BOUNDS_POPUP_MENU;
- block->mx= mx;
- block->my= my;
+ block->bounds = addval;
+ block->dobounds = UI_BLOCK_BOUNDS_POPUP_MENU;
+ block->mx = mx;
+ block->my = my;
}
/* used for centered popups, i.e. splash */
void uiCenteredBoundsBlock(uiBlock *block, int addval)
{
- block->bounds= addval;
- block->dobounds= UI_BLOCK_BOUNDS_POPUP_CENTER;
+ block->bounds = addval;
+ block->dobounds = UI_BLOCK_BOUNDS_POPUP_CENTER;
}
void uiExplicitBoundsBlock(uiBlock *block, int minx, int miny, int maxx, int maxy)
@@ -452,26 +452,26 @@ static int ui_but_float_precision(uiBut *but, double value)
int prec;
/* first check if prec is 0 and fallback to a simple default */
- if ((prec= (int)but->a2) == 0) {
- prec= (but->hardmax < 10.001f) ? 3 : 2;
+ if ((prec = (int)but->a2) == 0) {
+ prec = (but->hardmax < 10.001f) ? 3 : 2;
}
/* check on the number of decimal places need to display
* the number, this is so 0.00001 is not displayed as 0.00,
* _but_, this is only for small values si 10.0001 will not get
* the same treatment */
- if (value != 0.0 && (value= ABS(value)) < 0.1) {
- int value_i= (int)((value * PRECISION_FLOAT_MAX_POW) + 0.5);
+ if (value != 0.0 && (value = ABS(value)) < 0.1) {
+ int value_i = (int)((value * PRECISION_FLOAT_MAX_POW) + 0.5);
if (value_i != 0) {
- const int prec_span= 3; /* show: 0.01001, 5 would allow 0.0100001 for eg. */
+ const int prec_span = 3; /* show: 0.01001, 5 would allow 0.0100001 for eg. */
int test_prec;
- int prec_min= -1;
- int dec_flag= 0;
- int i= PRECISION_FLOAT_MAX;
+ int prec_min = -1;
+ int dec_flag = 0;
+ int i = PRECISION_FLOAT_MAX;
while (i && value_i) {
if (value_i % 10) {
- dec_flag |= 1<<i;
- prec_min= i;
+ dec_flag |= 1 << i;
+ prec_min = i;
}
value_i /= 10;
i--;
@@ -480,7 +480,7 @@ static int ui_but_float_precision(uiBut *but, double value)
/* even though its a small value, if the second last digit is not 0, use it */
test_prec = prec_min;
- dec_flag= (dec_flag >> (prec_min + 1)) & ((1 << prec_span) - 1);
+ dec_flag = (dec_flag >> (prec_min + 1)) & ((1 << prec_span) - 1);
while (dec_flag) {
test_prec++;
@@ -488,7 +488,7 @@ static int ui_but_float_precision(uiBut *but, double value)
}
if (test_prec > prec) {
- prec= test_prec;
+ prec = test_prec;
}
}
}
@@ -502,17 +502,17 @@ static void ui_draw_linkline(uiLinkLine *line)
{
rcti rect;
- if (line->from==NULL || line->to==NULL) return;
+ if (line->from == NULL || line->to == NULL) return;
- rect.xmin = (line->from->x1+line->from->x2)/2.0f;
- rect.ymin = (line->from->y1+line->from->y2)/2.0f;
- rect.xmax = (line->to->x1+line->to->x2)/2.0f;
- rect.ymax = (line->to->y1+line->to->y2)/2.0f;
+ rect.xmin = (line->from->x1 + line->from->x2) / 2.0f;
+ rect.ymin = (line->from->y1 + line->from->y2) / 2.0f;
+ rect.xmax = (line->to->x1 + line->to->x2) / 2.0f;
+ rect.ymax = (line->to->y1 + line->to->y2) / 2.0f;
if (line->flag & UI_SELECT)
- glColor3ub(100,100,100);
+ glColor3ub(100, 100, 100);
else
- glColor3ub(0,0,0);
+ glColor3ub(0, 0, 0);
ui_draw_link_bezier(&rect);
}
@@ -522,16 +522,16 @@ static void ui_draw_links(uiBlock *block)
uiBut *but;
uiLinkLine *line;
- but= block->buttons.first;
+ but = block->buttons.first;
while (but) {
- if (but->type==LINK && but->link) {
- line= but->link->lines.first;
+ if (but->type == LINK && but->link) {
+ line = but->link->lines.first;
while (line) {
ui_draw_linkline(line);
- line= line->next;
+ line = line->next;
}
}
- but= but->next;
+ but = but->next;
}
}
@@ -550,7 +550,7 @@ static int ui_but_equals_old(uiBut *but, uiBut *oldbut)
if (but->funcN != oldbut->funcN) return 0;
if (oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) return 0;
if (oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) return 0;
- if (!but->funcN && ((but->poin != oldbut->poin && (uiBut*)oldbut->poin != oldbut) || but->pointype != oldbut->pointype)) return 0;
+ if (!but->funcN && ((but->poin != oldbut->poin && (uiBut *)oldbut->poin != oldbut) || but->pointype != oldbut->pointype)) return 0;
if (but->optype != oldbut->optype) return 0;
return 1;
@@ -563,26 +563,26 @@ static void ui_but_update_linklines(uiBlock *block, uiBut *oldbut, uiBut *newbut
uiBut *but;
/* if active button is LINK */
- if (newbut->type==LINK && newbut->link) {
+ if (newbut->type == LINK && newbut->link) {
SWAP(uiLink *, oldbut->link, newbut->link);
- for (line= oldbut->link->lines.first; line; line= line->next) {
- if (line->to==newbut)
- line->to= oldbut;
- if (line->from==newbut)
- line->from= oldbut;
+ for (line = oldbut->link->lines.first; line; line = line->next) {
+ if (line->to == newbut)
+ line->to = oldbut;
+ if (line->from == newbut)
+ line->from = oldbut;
}
}
/* check all other button links */
- for (but= block->buttons.first; but; but= but->next) {
- if (but!=newbut && but->type==LINK && but->link) {
- for (line= but->link->lines.first; line; line= line->next) {
- if (line->to==newbut)
- line->to= oldbut;
- if (line->from==newbut)
- line->from= oldbut;
+ for (but = block->buttons.first; but; but = but->next) {
+ if (but != newbut && but->type == LINK && but->link) {
+ for (line = but->link->lines.first; line; line = line->next) {
+ if (line->to == newbut)
+ line->to = oldbut;
+ if (line->from == newbut)
+ line->from = oldbut;
}
}
}
@@ -591,14 +591,14 @@ static void ui_but_update_linklines(uiBlock *block, uiBut *oldbut, uiBut *newbut
static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut **butpp)
{
uiBlock *oldblock;
- uiBut *oldbut, *but= *butpp;
- int found= 0;
+ uiBut *oldbut, *but = *butpp;
+ int found = 0;
- oldblock= block->oldblock;
+ oldblock = block->oldblock;
if (!oldblock)
return found;
- for (oldbut=oldblock->buttons.first; oldbut; oldbut=oldbut->next) {
+ for (oldbut = oldblock->buttons.first; oldbut; oldbut = oldbut->next) {
if (ui_but_equals_old(oldbut, but)) {
if (oldbut->active) {
#if 0
@@ -622,19 +622,19 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut
// but->softmax= oldbut->softmax;
// but->linkto[0]= oldbut->linkto[0];
// but->linkto[1]= oldbut->linkto[1];
- found= 1;
+ found = 1;
// oldbut->active= NULL;
/* move button over from oldblock to new block */
BLI_remlink(&oldblock->buttons, oldbut);
BLI_insertlink(&block->buttons, but, oldbut);
- oldbut->block= block;
- *butpp= oldbut;
+ oldbut->block = block;
+ *butpp = oldbut;
/* still stuff needs to be copied */
- oldbut->x1= but->x1; oldbut->y1= but->y1;
- oldbut->x2= but->x2; oldbut->y2= but->y2;
- oldbut->context= but->context; /* set by Layout */
+ oldbut->x1 = but->x1; oldbut->y1 = but->y1;
+ oldbut->x2 = but->x2; oldbut->y2 = but->y2;
+ oldbut->context = but->context; /* set by Layout */
/* typically the same pointers, but not on undo/redo */
/* XXX some menu buttons store button itself in but->poin. Ugly */
@@ -646,7 +646,7 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut
/* copy hardmin for list rows to prevent 'sticking' highlight to mouse position
* when scrolling without moving mouse (see [#28432]) */
if (ELEM(oldbut->type, ROW, LISTROW))
- oldbut->hardmax= but->hardmax;
+ oldbut->hardmax = but->hardmax;
ui_but_update_linklines(block, oldbut, but);
@@ -676,27 +676,27 @@ int uiButActiveOnly(const bContext *C, uiBlock *block, uiBut *but)
{
uiBlock *oldblock;
uiBut *oldbut;
- int activate= 0, found= 0, isactive= 0;
+ int activate = 0, found = 0, isactive = 0;
- oldblock= block->oldblock;
+ oldblock = block->oldblock;
if (!oldblock)
- activate= 1;
+ activate = 1;
else {
- for (oldbut=oldblock->buttons.first; oldbut; oldbut=oldbut->next) {
+ for (oldbut = oldblock->buttons.first; oldbut; oldbut = oldbut->next) {
if (ui_but_equals_old(oldbut, but)) {
- found= 1;
+ found = 1;
if (oldbut->active)
- isactive= 1;
+ isactive = 1;
break;
}
}
}
- if (activate || found==0) {
+ if (activate || found == 0) {
ui_button_activate_do( (bContext *)C, CTX_wm_region(C), but);
}
- else if (found && isactive==0) {
+ else if (found && isactive == 0) {
BLI_remlink(&block->buttons, but);
ui_free_but(C, but);
@@ -715,7 +715,7 @@ static int ui_but_is_rna_undo(uiBut *but)
* we could disable undo for buttons with no ID too but may have
* unforeseen consequences, so best check for ID's we _know_ are not
* handled by undo - campbell */
- ID *id= but->rnapoin.id.data;
+ ID *id = but->rnapoin.id.data;
if (ID_CHECK_UNDO(id) == FALSE) {
return FALSE;
}
@@ -736,34 +736,34 @@ static void ui_menu_block_set_keyaccels(uiBlock *block)
{
uiBut *but;
- unsigned int menu_key_mask= 0;
+ unsigned int menu_key_mask = 0;
unsigned char menu_key;
const char *str_pt;
int pass;
- int tot_missing= 0;
+ int tot_missing = 0;
/* only do it before bounding */
if (block->minx != block->maxx)
return;
- for (pass=0; pass<2; pass++) {
+ for (pass = 0; pass < 2; pass++) {
/* 2 Passes, on for first letter only, second for any letter if first fails
* fun first pass on all buttons so first word chars always get first priority */
- for (but=block->buttons.first; but; but=but->next) {
+ for (but = block->buttons.first; but; but = but->next) {
if (!ELEM4(but->type, BUT, MENU, BLOCK, PULLDOWN) || (but->flag & UI_HIDDEN)) {
/* pass */
}
- else if (but->menu_key=='\0') {
+ else if (but->menu_key == '\0') {
if (but->str) {
- for (str_pt= but->str; *str_pt; ) {
- menu_key= tolower(*str_pt);
- if ((menu_key >= 'a' && menu_key <= 'z') && !(menu_key_mask & 1<<(menu_key-'a'))) {
- menu_key_mask |= 1<<(menu_key-'a');
+ for (str_pt = but->str; *str_pt; ) {
+ menu_key = tolower(*str_pt);
+ if ((menu_key >= 'a' && menu_key <= 'z') && !(menu_key_mask & 1 << (menu_key - 'a'))) {
+ menu_key_mask |= 1 << (menu_key - 'a');
break;
}
- if (pass==0) {
+ if (pass == 0) {
/* Skip to next delimiter on first pass (be picky) */
while (isalpha(*str_pt))
str_pt++;
@@ -778,7 +778,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block)
}
if (*str_pt) {
- but->menu_key= menu_key;
+ but->menu_key = menu_key;
}
else {
/* run second pass */
@@ -786,7 +786,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block)
}
/* if all keys have been used just exit, unlikely */
- if (menu_key_mask == (1<<26)-1) {
+ if (menu_key_mask == (1 << 26) - 1) {
return;
}
}
@@ -807,9 +807,9 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const short do_st
{
if (do_strip) {
- char *cpoin= strchr(but->str, '|');
+ char *cpoin = strchr(but->str, '|');
if (cpoin) {
- *cpoin= '\0';
+ *cpoin = '\0';
}
}
@@ -840,36 +840,36 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
/* for menu's */
MenuType *mt;
- IDProperty *prop_menu= NULL;
- IDProperty *prop_menu_name= NULL;
+ IDProperty *prop_menu = NULL;
+ IDProperty *prop_menu_name = NULL;
/* only do it before bounding */
if (block->minx != block->maxx)
return;
- for (but=block->buttons.first; but; but=but->next) {
+ for (but = block->buttons.first; but; but = but->next) {
if (but->optype) {
- IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
+ IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
- buf, sizeof(buf)))
+ buf, sizeof(buf)))
{
ui_but_add_shortcut(but, buf, FALSE);
}
}
- else if ((mt= uiButGetMenuType(but))) {
+ else if ((mt = uiButGetMenuType(but))) {
/* only allocate menu property once */
if (prop_menu == NULL) {
/* annoying, create a property */
IDPropertyTemplate val = {0};
- prop_menu= IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */
- IDP_AddToGroup(prop_menu, (prop_menu_name= IDP_NewString("", "name", sizeof(mt->idname))));
+ prop_menu = IDP_New(IDP_GROUP, &val, __func__); /* dummy, name is unimportant */
+ IDP_AddToGroup(prop_menu, (prop_menu_name = IDP_NewString("", "name", sizeof(mt->idname))));
}
IDP_AssignString(prop_menu_name, mt->idname, sizeof(mt->idname));
if (WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, FALSE,
- buf, sizeof(buf)))
+ buf, sizeof(buf)))
{
ui_but_add_shortcut(but, buf, FALSE);
}
@@ -888,41 +888,41 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
void uiEndBlock(const bContext *C, uiBlock *block)
{
uiBut *but;
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
/* inherit flags from 'old' buttons that was drawn here previous, based
* on matching buttons, we need this to make button event handling non
* blocking, while still allowing buttons to be remade each redraw as it
* is expected by blender code */
- for (but=block->buttons.first; but; but=but->next) {
+ for (but = block->buttons.first; but; but = but->next) {
if (ui_but_update_from_old_block(C, block, &but))
ui_check_but(but);
/* temp? Proper check for greying out */
if (but->optype) {
- wmOperatorType *ot= but->optype;
+ wmOperatorType *ot = but->optype;
if (but->context)
- CTX_store_set((bContext*)C, but->context);
+ CTX_store_set((bContext *)C, but->context);
- if (ot == NULL || WM_operator_poll_context((bContext*)C, ot, but->opcontext)==0) {
+ if (ot == NULL || WM_operator_poll_context((bContext *)C, ot, but->opcontext) == 0) {
but->flag |= UI_BUT_DISABLED;
but->lock = 1;
}
if (but->context)
- CTX_store_set((bContext*)C, NULL);
+ CTX_store_set((bContext *)C, NULL);
}
- ui_but_anim_flag(but, (scene)? scene->r.cfra: 0.0f);
+ ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f);
}
if (block->oldblock) {
- block->auto_open= block->oldblock->auto_open;
- block->auto_open_last= block->oldblock->auto_open_last;
- block->tooltipdisabled= block->oldblock->tooltipdisabled;
+ block->auto_open = block->oldblock->auto_open;
+ block->auto_open_last = block->oldblock->auto_open_last;
+ block->tooltipdisabled = block->oldblock->tooltipdisabled;
- block->oldblock= NULL;
+ block->oldblock = NULL;
}
/* handle pending stuff */
@@ -939,10 +939,10 @@ void uiEndBlock(const bContext *C, uiBlock *block)
else if (block->dobounds == UI_BLOCK_BOUNDS_POPUP_CENTER) ui_centered_bounds_block(C, block);
else if (block->dobounds) ui_popup_bounds_block(C, block, block->dobounds);
- if (block->minx==0.0f && block->maxx==0.0f) uiBoundsBlock(block, 0);
+ if (block->minx == 0.0f && block->maxx == 0.0f) uiBoundsBlock(block, 0);
if (block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block);
- block->endblock= 1;
+ block->endblock = 1;
}
/* ************** BLOCK DRAWING FUNCTION ************* */
@@ -950,16 +950,16 @@ void uiEndBlock(const bContext *C, uiBlock *block)
void ui_fontscale(short *points, float aspect)
{
if (aspect < 0.9f || aspect > 1.1f) {
- float pointsf= *points;
+ float pointsf = *points;
/* for some reason scaling fonts goes too fast compared to widget size */
- aspect= sqrt(aspect);
+ aspect = sqrt(aspect);
pointsf /= aspect;
if (aspect > 1.0f)
- *points= ceilf(pointsf);
+ *points = ceilf(pointsf);
else
- *points= floorf(pointsf);
+ *points = floorf(pointsf);
}
}
@@ -969,42 +969,42 @@ static void ui_but_to_pixelrect(rcti *rect, const ARegion *ar, uiBlock *block, u
float gx, gy;
float getsizex, getsizey;
- getsizex= ar->winx;
- getsizey= ar->winy;
+ getsizex = ar->winx;
+ getsizey = ar->winy;
- gx= (but?but->x1:block->minx) + (block->panel?block->panel->ofsx:0.0f);
- gy= (but?but->y1:block->miny) + (block->panel?block->panel->ofsy:0.0f);
+ gx = (but ? but->x1 : block->minx) + (block->panel ? block->panel->ofsx : 0.0f);
+ gy = (but ? but->y1 : block->miny) + (block->panel ? block->panel->ofsy : 0.0f);
- rect->xmin = floorf(getsizex*(0.5f+ 0.5f*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0])));
- rect->ymin = floorf(getsizey*(0.5f+ 0.5f*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1])));
+ rect->xmin = floorf(getsizex * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] + block->winmat[3][0])));
+ rect->ymin = floorf(getsizey * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] + block->winmat[3][1])));
- gx= (but?but->x2:block->maxx) + (block->panel?block->panel->ofsx:0.0f);
- gy= (but?but->y2:block->maxy) + (block->panel?block->panel->ofsy:0.0f);
+ gx = (but ? but->x2 : block->maxx) + (block->panel ? block->panel->ofsx : 0.0f);
+ gy = (but ? but->y2 : block->maxy) + (block->panel ? block->panel->ofsy : 0.0f);
- rect->xmax = floorf(getsizex*(0.5f+ 0.5f*(gx*block->winmat[0][0]+ gy*block->winmat[1][0]+ block->winmat[3][0])));
- rect->ymax = floorf(getsizey*(0.5f+ 0.5f*(gx*block->winmat[0][1]+ gy*block->winmat[1][1]+ block->winmat[3][1])));
+ rect->xmax = floorf(getsizex * (0.5f + 0.5f * (gx * block->winmat[0][0] + gy * block->winmat[1][0] + block->winmat[3][0])));
+ rect->ymax = floorf(getsizey * (0.5f + 0.5f * (gx * block->winmat[0][1] + gy * block->winmat[1][1] + block->winmat[3][1])));
}
/* uses local copy of style, to scale things down, and allow widgets to change stuff */
void uiDrawBlock(const bContext *C, uiBlock *block)
{
- uiStyle style= *UI_GetStyle(); // XXX pass on as arg
+ uiStyle style = *UI_GetStyle(); // XXX pass on as arg
ARegion *ar;
uiBut *but;
rcti rect;
int multisample_enabled;
/* get menu region or area region */
- ar= CTX_wm_menu(C);
+ ar = CTX_wm_menu(C);
if (!ar)
- ar= CTX_wm_region(C);
+ ar = CTX_wm_region(C);
if (!block->endblock)
uiEndBlock(C, block);
/* disable AA, makes widgets too blurry */
- multisample_enabled= glIsEnabled(GL_MULTISAMPLE_ARB);
+ multisample_enabled = glIsEnabled(GL_MULTISAMPLE_ARB);
if (multisample_enabled)
glDisable(GL_MULTISAMPLE_ARB);
@@ -1027,7 +1027,7 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
glPushMatrix();
glLoadIdentity();
- wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f);
+ wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f);
/* back */
if (block->flag & UI_BLOCK_LOOP)
@@ -1036,8 +1036,8 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
ui_draw_aligned_panel(&style, block, &rect);
/* widgets */
- for (but= block->buttons.first; but; but= but->next) {
- if (!(but->flag & (UI_HIDDEN|UI_SCROLLED))) {
+ for (but = block->buttons.first; but; but = but->next) {
+ if (!(but->flag & (UI_HIDDEN | UI_SCROLLED))) {
ui_but_to_pixelrect(&rect, ar, block, but);
/* XXX: figure out why invalid coordinates happen when closing render window */
@@ -1063,64 +1063,64 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
static void ui_is_but_sel(uiBut *but, double *value)
{
- short is_push=0, is_true=1;
+ short is_push = 0, is_true = 1;
- if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) is_true= 0;
+ if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) is_true = 0;
- if ( but->bit ) {
+ if (but->bit) {
int lvalue;
UI_GET_BUT_VALUE_INIT(but, *value)
- lvalue= (int)*value;
- if ( BTST(lvalue, (but->bitnr)) ) is_push= is_true;
- else is_push= !is_true;
+ lvalue = (int)*value;
+ if (BTST(lvalue, (but->bitnr)) ) is_push = is_true;
+ else is_push = !is_true;
}
else {
- switch(but->type) {
- case BUT:
- is_push= 2;
- break;
- case HOTKEYEVT:
- case KEYEVT:
- is_push= 2;
- break;
- case TOGBUT:
- case TOG:
- case TOGR:
- case TOG3:
- case BUT_TOGDUAL:
- case ICONTOG:
- case OPTION:
- UI_GET_BUT_VALUE_INIT(but, *value)
- if (*value != (double)but->hardmin) is_push= 1;
- break;
- case ICONTOGN:
- case TOGN:
- case OPTIONN:
- UI_GET_BUT_VALUE_INIT(but, *value)
- if (*value==0.0) is_push= 1;
- break;
- case ROW:
- case LISTROW:
- UI_GET_BUT_VALUE_INIT(but, *value)
- /* support for rna enum buts */
- if (but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) {
- if ((int)*value & (int)but->hardmax) is_push= 1;
- }
- else {
- if (*value == (double)but->hardmax) is_push= 1;
- }
- break;
- case COL:
- is_push= 2;
- break;
- default:
- is_push= 2;
- break;
+ switch (but->type) {
+ case BUT:
+ is_push = 2;
+ break;
+ case HOTKEYEVT:
+ case KEYEVT:
+ is_push = 2;
+ break;
+ case TOGBUT:
+ case TOG:
+ case TOGR:
+ case TOG3:
+ case BUT_TOGDUAL:
+ case ICONTOG:
+ case OPTION:
+ UI_GET_BUT_VALUE_INIT(but, *value)
+ if (*value != (double)but->hardmin) is_push = 1;
+ break;
+ case ICONTOGN:
+ case TOGN:
+ case OPTIONN:
+ UI_GET_BUT_VALUE_INIT(but, *value)
+ if (*value == 0.0) is_push = 1;
+ break;
+ case ROW:
+ case LISTROW:
+ UI_GET_BUT_VALUE_INIT(but, *value)
+ /* support for rna enum buts */
+ if (but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) {
+ if ((int)*value & (int)but->hardmax) is_push = 1;
+ }
+ else {
+ if (*value == (double)but->hardmax) is_push = 1;
+ }
+ break;
+ case COL:
+ is_push = 2;
+ break;
+ default:
+ is_push = 2;
+ break;
}
}
- if (is_push==2);
- else if (is_push==1) but->flag |= UI_SELECT;
+ if (is_push == 2) ;
+ else if (is_push == 1) but->flag |= UI_SELECT;
else but->flag &= ~UI_SELECT;
}
@@ -1128,12 +1128,12 @@ static uiBut *ui_find_inlink(uiBlock *block, void *poin)
{
uiBut *but;
- but= block->buttons.first;
+ but = block->buttons.first;
while (but) {
- if (but->type==INLINK) {
+ if (but->type == INLINK) {
if (but->poin == poin) return but;
}
- but= but->next;
+ but = but->next;
}
return NULL;
}
@@ -1142,10 +1142,10 @@ static void ui_add_link_line(ListBase *listb, uiBut *but, uiBut *bt)
{
uiLinkLine *line;
- line= MEM_callocN(sizeof(uiLinkLine), "linkline");
+ line = MEM_callocN(sizeof(uiLinkLine), "linkline");
BLI_addtail(listb, line);
- line->from= but;
- line->to= bt;
+ line->from = but;
+ line->to = bt;
}
uiBut *uiFindInlink(uiBlock *block, void *poin)
@@ -1160,31 +1160,31 @@ void uiComposeLinks(uiBlock *block)
void ***ppoin;
int a;
- but= block->buttons.first;
+ but = block->buttons.first;
while (but) {
- if (but->type==LINK) {
- link= but->link;
+ if (but->type == LINK) {
+ link = but->link;
/* for all pointers in the array */
if (link) {
if (link->ppoin) {
- ppoin= link->ppoin;
- for (a=0; a < *(link->totlink); a++) {
- bt= ui_find_inlink(block, (*ppoin)[a] );
+ ppoin = link->ppoin;
+ for (a = 0; a < *(link->totlink); a++) {
+ bt = ui_find_inlink(block, (*ppoin)[a]);
if (bt) {
ui_add_link_line(&link->lines, but, bt);
}
}
}
else if (link->poin) {
- bt= ui_find_inlink(block, *(link->poin) );
+ bt = ui_find_inlink(block, *(link->poin) );
if (bt) {
ui_add_link_line(&link->lines, but, bt);
}
}
}
}
- but= but->next;
+ but = but->next;
}
}
@@ -1194,15 +1194,15 @@ void uiComposeLinks(uiBlock *block)
void uiBlockSetButLock(uiBlock *block, int val, const char *lockstr)
{
if (val) {
- block->lock= val ? 1:0;
- block->lockstr= lockstr;
+ block->lock = val ? 1 : 0;
+ block->lockstr = lockstr;
}
}
void uiBlockClearButLock(uiBlock *block)
{
- block->lock= 0;
- block->lockstr= NULL;
+ block->lock = 0;
+ block->lockstr = NULL;
}
/* *************************************************************** */
@@ -1214,22 +1214,22 @@ void ui_delete_linkline(uiLinkLine *line, uiBut *but)
BLI_remlink(&but->link->lines, line);
- link= line->from->link;
+ link = line->from->link;
/* are there more pointers allowed? */
if (link->ppoin) {
- if (*(link->totlink)==1) {
- *(link->totlink)= 0;
+ if (*(link->totlink) == 1) {
+ *(link->totlink) = 0;
MEM_freeN(*(link->ppoin));
- *(link->ppoin)= NULL;
+ *(link->ppoin) = NULL;
}
else {
- b= 0;
- for (a=0; a< (*(link->totlink)); a++) {
+ b = 0;
+ for (a = 0; a < (*(link->totlink)); a++) {
- if ( (*(link->ppoin))[a] != line->to->poin ) {
- (*(link->ppoin))[b]= (*(link->ppoin))[a];
+ if ( (*(link->ppoin))[a] != line->to->poin) {
+ (*(link->ppoin))[b] = (*(link->ppoin))[a];
b++;
}
}
@@ -1237,7 +1237,7 @@ void ui_delete_linkline(uiLinkLine *line, uiBut *but)
}
}
else {
- *(link->poin)= NULL;
+ *(link->poin) = NULL;
}
MEM_freeN(line);
@@ -1259,32 +1259,32 @@ void ui_get_but_vectorf(uiBut *but, float vec[3])
}
if (but->rnaprop) {
- prop= but->rnaprop;
+ prop = but->rnaprop;
- vec[0]= vec[1]= vec[2]= 0.0f;
+ vec[0] = vec[1] = vec[2] = 0.0f;
if (RNA_property_type(prop) == PROP_FLOAT) {
- tot= RNA_property_array_length(&but->rnapoin, prop);
- tot= MIN2(tot, 3);
+ tot = RNA_property_array_length(&but->rnapoin, prop);
+ tot = MIN2(tot, 3);
- for (a=0; a<tot; a++)
- vec[a]= RNA_property_float_get_index(&but->rnapoin, prop, a);
+ for (a = 0; a < tot; a++)
+ vec[a] = RNA_property_float_get_index(&but->rnapoin, prop, a);
}
}
else if (but->pointype == CHA) {
- char *cp= (char *)but->poin;
- vec[0]= ((float)cp[0])/255.0f;
- vec[1]= ((float)cp[1])/255.0f;
- vec[2]= ((float)cp[2])/255.0f;
+ char *cp = (char *)but->poin;
+ vec[0] = ((float)cp[0]) / 255.0f;
+ vec[1] = ((float)cp[1]) / 255.0f;
+ vec[2] = ((float)cp[2]) / 255.0f;
}
else if (but->pointype == FLO) {
- float *fp= (float *)but->poin;
+ float *fp = (float *)but->poin;
copy_v3_v3(vec, fp);
}
else {
- if (but->editvec==NULL) {
+ if (but->editvec == NULL) {
fprintf(stderr, "ui_get_but_vectorf: can't get color, should never happen\n");
- vec[0]= vec[1]= vec[2]= 0.0f;
+ vec[0] = vec[1] = vec[2] = 0.0f;
}
}
@@ -1303,35 +1303,35 @@ void ui_set_but_vectorf(uiBut *but, const float vec[3])
}
if (but->rnaprop) {
- prop= but->rnaprop;
+ prop = but->rnaprop;
if (RNA_property_type(prop) == PROP_FLOAT) {
int tot;
int a;
- tot= RNA_property_array_length(&but->rnapoin, prop);
- tot= MIN2(tot, 3);
+ tot = RNA_property_array_length(&but->rnapoin, prop);
+ tot = MIN2(tot, 3);
- for (a=0; a<tot; a++) {
+ for (a = 0; a < tot; a++) {
RNA_property_float_set_index(&but->rnapoin, prop, a, vec[a]);
}
}
}
else if (but->pointype == CHA) {
- char *cp= (char *)but->poin;
- cp[0]= (char)(0.5f + vec[0]*255.0f);
- cp[1]= (char)(0.5f + vec[1]*255.0f);
- cp[2]= (char)(0.5f + vec[2]*255.0f);
+ char *cp = (char *)but->poin;
+ cp[0] = (char)(0.5f + vec[0] * 255.0f);
+ cp[1] = (char)(0.5f + vec[1] * 255.0f);
+ cp[2] = (char)(0.5f + vec[2] * 255.0f);
}
else if (but->pointype == FLO) {
- float *fp= (float *)but->poin;
+ float *fp = (float *)but->poin;
copy_v3_v3(fp, vec);
}
}
int ui_is_but_float(uiBut *but)
{
- if (but->pointype==FLO && but->poin)
+ if (but->pointype == FLO && but->poin)
return 1;
if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_FLOAT)
@@ -1342,8 +1342,8 @@ int ui_is_but_float(uiBut *but)
int ui_is_but_unit(uiBut *but)
{
- UnitSettings *unit= but->block->unit;
- const int unit_type= uiButGetUnitType(but);
+ UnitSettings *unit = but->block->unit;
+ const int unit_type = uiButGetUnitType(but);
if (unit_type == PROP_UNIT_NONE)
return 0;
@@ -1368,7 +1368,7 @@ int ui_is_but_unit(uiBut *but)
int ui_is_but_rna_valid(uiBut *but)
{
- if (but->rnaprop==NULL || RNA_struct_contains_property(&but->rnapoin, but->rnaprop)) {
+ if (but->rnaprop == NULL || RNA_struct_contains_property(&but->rnapoin, but->rnaprop)) {
return TRUE;
}
else {
@@ -1383,61 +1383,61 @@ double ui_get_but_val(uiBut *but)
double value = 0.0;
if (but->editval) { return *(but->editval); }
- if (but->poin==NULL && but->rnapoin.data==NULL) return 0.0;
+ if (but->poin == NULL && but->rnapoin.data == NULL) return 0.0;
if (but->rnaprop) {
- prop= but->rnaprop;
+ prop = but->rnaprop;
- switch(RNA_property_type(prop)) {
+ switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
if (RNA_property_array_check(prop))
- value= RNA_property_boolean_get_index(&but->rnapoin, prop, but->rnaindex);
+ value = RNA_property_boolean_get_index(&but->rnapoin, prop, but->rnaindex);
else
- value= RNA_property_boolean_get(&but->rnapoin, prop);
+ value = RNA_property_boolean_get(&but->rnapoin, prop);
break;
case PROP_INT:
if (RNA_property_array_check(prop))
- value= RNA_property_int_get_index(&but->rnapoin, prop, but->rnaindex);
+ value = RNA_property_int_get_index(&but->rnapoin, prop, but->rnaindex);
else
- value= RNA_property_int_get(&but->rnapoin, prop);
+ value = RNA_property_int_get(&but->rnapoin, prop);
break;
case PROP_FLOAT:
if (RNA_property_array_check(prop))
- value= RNA_property_float_get_index(&but->rnapoin, prop, but->rnaindex);
+ value = RNA_property_float_get_index(&but->rnapoin, prop, but->rnaindex);
else
- value= RNA_property_float_get(&but->rnapoin, prop);
+ value = RNA_property_float_get(&but->rnapoin, prop);
break;
case PROP_ENUM:
- value= RNA_property_enum_get(&but->rnapoin, prop);
+ value = RNA_property_enum_get(&but->rnapoin, prop);
break;
default:
- value= 0.0;
+ value = 0.0;
break;
}
}
- else if (but->type== HSVSLI) {
+ else if (but->type == HSVSLI) {
float h, s, v, *fp;
- fp= (but->editvec)? but->editvec: (float *)but->poin;
+ fp = (but->editvec) ? but->editvec : (float *)but->poin;
rgb_to_hsv(fp[0], fp[1], fp[2], &h, &s, &v);
- switch(but->str[0]) {
- case 'H': value= h; break;
- case 'S': value= s; break;
- case 'V': value= v; break;
+ switch (but->str[0]) {
+ case 'H': value = h; break;
+ case 'S': value = s; break;
+ case 'V': value = v; break;
}
}
- else if ( but->pointype == CHA ) {
- value= *(char *)but->poin;
+ else if (but->pointype == CHA) {
+ value = *(char *)but->poin;
}
- else if ( but->pointype == SHO ) {
- value= *(short *)but->poin;
+ else if (but->pointype == SHO) {
+ value = *(short *)but->poin;
}
- else if ( but->pointype == INT ) {
- value= *(int *)but->poin;
+ else if (but->pointype == INT) {
+ value = *(int *)but->poin;
}
- else if ( but->pointype == FLO ) {
- value= *(float *)but->poin;
+ else if (but->pointype == FLO) {
+ value = *(float *)but->poin;
}
return value;
@@ -1449,10 +1449,10 @@ void ui_set_but_val(uiBut *but, double value)
/* value is a hsv value: convert to rgb */
if (but->rnaprop) {
- prop= but->rnaprop;
+ prop = but->rnaprop;
if (RNA_property_editable(&but->rnapoin, prop)) {
- switch(RNA_property_type(prop)) {
+ switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
if (RNA_property_array_length(&but->rnapoin, prop))
RNA_property_boolean_set_index(&but->rnapoin, prop, but->rnaindex, value);
@@ -1473,7 +1473,7 @@ void ui_set_but_val(uiBut *but, double value)
break;
case PROP_ENUM:
if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
- int ivalue= (int)value;
+ int ivalue = (int)value;
ivalue ^= RNA_property_enum_get(&but->rnapoin, prop); /* toggle for enum/flag buttons */
RNA_property_enum_set(&but->rnapoin, prop, ivalue);
}
@@ -1488,56 +1488,56 @@ void ui_set_but_val(uiBut *but, double value)
/* we can't be sure what RNA set functions actually do,
* so leave this unset */
- value= UI_BUT_VALUE_UNSET;
+ value = UI_BUT_VALUE_UNSET;
}
- else if (but->pointype==0);
- else if (but->type==HSVSLI ) {
+ else if (but->pointype == 0) ;
+ else if (but->type == HSVSLI) {
float h, s, v, *fp;
- fp= (but->editvec)? but->editvec: (float *)but->poin;
+ fp = (but->editvec) ? but->editvec : (float *)but->poin;
rgb_to_hsv(fp[0], fp[1], fp[2], &h, &s, &v);
- switch(but->str[0]) {
- case 'H': h= value; break;
- case 'S': s= value; break;
- case 'V': v= value; break;
+ switch (but->str[0]) {
+ case 'H': h = value; break;
+ case 'S': s = value; break;
+ case 'V': v = value; break;
}
- hsv_to_rgb(h, s, v, fp, fp+1, fp+2);
+ hsv_to_rgb(h, s, v, fp, fp + 1, fp + 2);
}
else {
/* first do rounding */
- if (but->pointype==CHA)
- value= (char)floor(value+0.5);
- else if (but->pointype==SHO ) {
+ if (but->pointype == CHA)
+ value = (char)floor(value + 0.5);
+ else if (but->pointype == SHO) {
/* gcc 3.2.1 seems to have problems
* casting a double like 32772.0 to
* a short so we cast to an int, then
* to a short */
int gcckludge;
- gcckludge = (int) floor(value+0.5);
- value= (short)gcckludge;
+ gcckludge = (int) floor(value + 0.5);
+ value = (short)gcckludge;
}
- else if (but->pointype==INT )
- value= (int)floor(value+0.5);
- else if (but->pointype==FLO ) {
- float fval= (float)value;
- if (fval>= -0.00001f && fval<= 0.00001f) fval= 0.0f; /* prevent negative zero */
- value= fval;
+ else if (but->pointype == INT)
+ value = (int)floor(value + 0.5);
+ else if (but->pointype == FLO) {
+ float fval = (float)value;
+ if (fval >= -0.00001f && fval <= 0.00001f) fval = 0.0f; /* prevent negative zero */
+ value = fval;
}
/* then set value with possible edit override */
if (but->editval)
- value= *but->editval= value;
- else if (but->pointype==CHA)
- value= *((char *)but->poin)= (char)value;
- else if (but->pointype==SHO)
- value= *((short *)but->poin)= (short)value;
- else if (but->pointype==INT)
- value= *((int *)but->poin)= (int)value;
- else if (but->pointype==FLO)
- value= *((float *)but->poin)= (float)value;
+ value = *but->editval = value;
+ else if (but->pointype == CHA)
+ value = *((char *)but->poin) = (char)value;
+ else if (but->pointype == SHO)
+ value = *((short *)but->poin) = (short)value;
+ else if (but->pointype == INT)
+ value = *((int *)but->poin) = (int)value;
+ else if (but->pointype == FLO)
+ value = *((float *)but->poin) = (float)value;
}
/* update select flag */
@@ -1549,15 +1549,15 @@ int ui_get_but_string_max_length(uiBut *but)
if (ELEM(but->type, TEX, SEARCH_MENU))
return but->hardmax;
else if (but->type == IDPOIN)
- return MAX_ID_NAME-2;
+ return MAX_ID_NAME - 2;
else
return UI_MAX_DRAW_STR;
}
static double ui_get_but_scale_unit(uiBut *but, double value)
{
- UnitSettings *unit= but->block->unit;
- int unit_type= uiButGetUnitType(but);
+ UnitSettings *unit = but->block->unit;
+ int unit_type = uiButGetUnitType(but);
if (unit_type == PROP_UNIT_LENGTH) {
return value * (double)unit->scale_length;
@@ -1569,7 +1569,7 @@ static double ui_get_but_scale_unit(uiBut *but, double value)
return value * pow(unit->scale_length, 3);
}
else if (unit_type == PROP_UNIT_TIME) { /* WARNING - using evil_C :| */
- Scene *scene= CTX_data_scene(but->block->evil_C);
+ Scene *scene = CTX_data_scene(but->block->evil_C);
return FRA2TIME(value);
}
else {
@@ -1581,14 +1581,14 @@ static double ui_get_but_scale_unit(uiBut *but, double value)
void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen)
{
if (ui_is_but_unit(but)) {
- UnitSettings *unit= but->block->unit;
- int unit_type= uiButGetUnitType(but);
+ UnitSettings *unit = but->block->unit;
+ int unit_type = uiButGetUnitType(but);
char *orig_str;
- orig_str= MEM_callocN(sizeof(char)*maxlen + 1, "textedit sub str");
+ orig_str = MEM_callocN(sizeof(char) * maxlen + 1, "textedit sub str");
memcpy(orig_str, str, maxlen);
- bUnit_ToUnitAltName(str, maxlen, orig_str, unit->system, unit_type>>16);
+ bUnit_ToUnitAltName(str, maxlen, orig_str, unit->system, unit_type >> 16);
MEM_freeN(orig_str);
}
@@ -1596,29 +1596,29 @@ void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen)
static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double value, int pad)
{
- UnitSettings *unit= but->block->unit;
- int do_split= unit->flag & USER_UNIT_OPT_SPLIT;
- int unit_type= uiButGetUnitType(but);
- int precision= but->a2;
+ UnitSettings *unit = but->block->unit;
+ int do_split = unit->flag & USER_UNIT_OPT_SPLIT;
+ int unit_type = uiButGetUnitType(but);
+ int precision = but->a2;
- if (unit->scale_length<0.0001f) unit->scale_length= 1.0f; // XXX do_versions
+ if (unit->scale_length < 0.0001f) unit->scale_length = 1.0f; // XXX do_versions
/* Sanity checks */
- if (precision > PRECISION_FLOAT_MAX) precision= PRECISION_FLOAT_MAX;
- else if (precision==0) precision= 2;
+ if (precision > PRECISION_FLOAT_MAX) precision = PRECISION_FLOAT_MAX;
+ else if (precision == 0) precision = 2;
- bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precision, unit->system, unit_type>>16, do_split, pad);
+ bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precision, unit->system, unit_type >> 16, do_split, pad);
}
static float ui_get_but_step_unit(uiBut *but, float step_default)
{
- int unit_type= uiButGetUnitType(but)>>16;
+ int unit_type = uiButGetUnitType(but) >> 16;
float step;
step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, step_default), but->block->unit->system, unit_type);
if (step > 0.0f) { /* -1 is an error value */
- return (float)((double)step/ui_get_but_scale_unit(but, 1.0))*100.0f;
+ return (float)((double)step / ui_get_but_scale_unit(but, 1.0)) * 100.0f;
}
else {
return step_default;
@@ -1630,19 +1630,19 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
{
if (but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
PropertyType type;
- char *buf= NULL;
+ char *buf = NULL;
int buf_len;
- type= RNA_property_type(but->rnaprop);
+ type = RNA_property_type(but->rnaprop);
if (type == PROP_STRING) {
/* RNA string */
- buf= RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen, &buf_len);
+ buf = RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen, &buf_len);
}
else if (type == PROP_POINTER) {
/* RNA pointer */
- PointerRNA ptr= RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
- buf= RNA_struct_name_get_alloc(&ptr, str, maxlen, &buf_len);
+ PointerRNA ptr = RNA_property_pointer_get(&but->rnapoin, but->rnaprop);
+ buf = RNA_struct_name_get_alloc(&ptr, str, maxlen, &buf_len);
}
if (!buf) {
@@ -1650,16 +1650,16 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
}
else if (buf && buf != str) {
/* string was too long, we have to truncate */
- memcpy(str, buf, MIN2(maxlen, buf_len+1));
+ memcpy(str, buf, MIN2(maxlen, buf_len + 1));
MEM_freeN(buf);
}
}
else if (but->type == IDPOIN) {
/* ID pointer */
if (but->idpoin_idpp) { /* Can be NULL for ID properties by python */
- ID *id= *(but->idpoin_idpp);
+ ID *id = *(but->idpoin_idpp);
if (id) {
- BLI_strncpy(str, id->name+2, maxlen);
+ BLI_strncpy(str, id->name + 2, maxlen);
return;
}
}
@@ -1677,19 +1677,19 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
return;
}
else if (ui_but_anim_expression_get(but, str, maxlen))
- ; /* driver expression */
+ ; /* driver expression */
else {
/* number editing */
double value;
- value= ui_get_but_val(but);
+ value = ui_get_but_val(but);
if (ui_is_but_float(but)) {
if (ui_is_but_unit(but)) {
ui_get_but_string_unit(but, str, maxlen, value, 0);
}
else {
- const int prec= ui_but_float_precision(but, value);
+ const int prec = ui_but_float_precision(but, value);
BLI_snprintf(str, maxlen, "%.*f", prec, value);
}
}
@@ -1703,12 +1703,12 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen)
static int ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char *str, double *value)
{
char str_unit_convert[256];
- const int unit_type= uiButGetUnitType(but);
+ const int unit_type = uiButGetUnitType(but);
BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert));
/* ugly, use the draw string to get the value, this could cause problems if it includes some text which resolves to a unit */
- bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), but->block->unit->system, unit_type>>16);
+ bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), but->block->unit->system, unit_type >> 16);
return (BPY_button_exec(C, str_unit_convert, value, TRUE) != -1);
}
@@ -1718,28 +1718,28 @@ static int ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char *
int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double *value)
{
- int ok= FALSE;
+ int ok = FALSE;
#ifdef WITH_PYTHON
if (str[0] != '\0') {
- int is_unit_but= ui_is_but_unit(but);
+ int is_unit_but = ui_is_but_unit(but);
/* only enable verbose if we won't run again with units */
- if (BPY_button_exec(C, str, value, is_unit_but==FALSE) != -1) {
+ if (BPY_button_exec(C, str, value, is_unit_but == FALSE) != -1) {
/* if the value parsed ok without unit conversion this button may still need a unit multiplier */
if (is_unit_but) {
char str_new[128];
BLI_snprintf(str_new, sizeof(str_new), "%f", *value);
- ok= ui_set_but_string_eval_num_unit(C, but, str_new, value);
+ ok = ui_set_but_string_eval_num_unit(C, but, str_new, value);
}
else {
- ok= TRUE; /* parse normal string via py (no unit conversion needed) */
+ ok = TRUE; /* parse normal string via py (no unit conversion needed) */
}
}
else if (is_unit_but) {
/* parse failed, this is a unit but so run replacements and parse again */
- ok= ui_set_but_string_eval_num_unit(C, but, str, value);
+ ok = ui_set_but_string_eval_num_unit(C, but, str, value);
}
}
@@ -1763,7 +1763,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
if (RNA_property_editable(&but->rnapoin, but->rnaprop)) {
PropertyType type;
- type= RNA_property_type(but->rnaprop);
+ type = RNA_property_type(but->rnaprop);
if (type == PROP_STRING) {
/* RNA string */
@@ -1780,8 +1780,8 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
return 1;
}
else {
- ptr= but->rnasearchpoin;
- prop= but->rnasearchprop;
+ ptr = but->rnasearchpoin;
+ prop = but->rnasearchprop;
if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr))
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr);
@@ -1801,7 +1801,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
else if (but->type == TEX) {
/* string */
if (ui_is_but_utf8(but)) BLI_strncpy_utf8(but->poin, str, but->hardmax);
- else BLI_strncpy(but->poin, str, but->hardmax);
+ else BLI_strncpy(but->poin, str, but->hardmax);
return 1;
}
@@ -1814,9 +1814,9 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
/* driver expression */
return 1;
}
- else if (str[0]=='#') {
+ else if (str[0] == '#') {
/* shortcut to create new driver expression (versus immediate Py-execution) */
- return ui_but_anim_expression_create(but, str+1);
+ return ui_but_anim_expression_create(but, str + 1);
}
else {
/* number editing */
@@ -1826,12 +1826,12 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
return 0;
}
- if (!ui_is_but_float(but)) value= (int)floor(value + 0.5);
- if (but->type==NUMABS) value= fabs(value);
+ if (!ui_is_but_float(but)) value = (int)floor(value + 0.5);
+ if (but->type == NUMABS) value = fabs(value);
/* not that we use hard limits here */
- if (value < (double)but->hardmin) value= but->hardmin;
- if (value > (double)but->hardmax) value= but->hardmax;
+ if (value < (double)but->hardmin) value = but->hardmin;
+ if (value > (double)but->hardmax) value = but->hardmax;
ui_set_but_val(but, value);
return 1;
@@ -1853,12 +1853,12 @@ void ui_set_but_default(bContext *C, short all)
static double soft_range_round_up(double value, double max)
{
/* round up to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, .. */
- double newmax= pow(10.0, ceil(log(value)/M_LN10));
+ double newmax = pow(10.0, ceil(log(value) / M_LN10));
- if (newmax*0.2 >= max && newmax*0.2 >= value)
- return newmax*0.2;
- else if (newmax*0.5 >= max && newmax*0.5 >= value)
- return newmax*0.5;
+ if (newmax * 0.2 >= max && newmax * 0.2 >= value)
+ return newmax * 0.2;
+ else if (newmax * 0.5 >= max && newmax * 0.5 >= value)
+ return newmax * 0.5;
else
return newmax;
}
@@ -1866,12 +1866,12 @@ static double soft_range_round_up(double value, double max)
static double soft_range_round_down(double value, double max)
{
/* round down to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, .. */
- double newmax= pow(10.0, floor(log(value)/M_LN10));
+ double newmax = pow(10.0, floor(log(value) / M_LN10));
- if (newmax*5.0 <= max && newmax*5.0 <= value)
- return newmax*5.0;
- else if (newmax*2.0 <= max && newmax*2.0 <= value)
- return newmax*2.0;
+ if (newmax * 5.0 <= max && newmax * 5.0 <= value)
+ return newmax * 5.0;
+ else if (newmax * 2.0 <= max && newmax * 2.0 <= value)
+ return newmax * 2.0;
else
return newmax;
}
@@ -1883,72 +1883,72 @@ void ui_set_but_soft_range(uiBut *but, double value)
* which isn't so bad. */
if (but->rnaprop) {
- const PropertyType type= RNA_property_type(but->rnaprop);
+ const PropertyType type = RNA_property_type(but->rnaprop);
double softmin, softmax /*, step, precision*/;
- double value_min= value;
- double value_max= value;
+ double value_min = value;
+ double value_max = value;
/* clamp button range to something reasonable in case
* we get -inf/inf from RNA properties */
if (type == PROP_INT) {
int imin, imax, istep;
- const int array_len= RNA_property_array_length(&but->rnapoin, but->rnaprop);
+ const int array_len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
RNA_property_int_ui_range(&but->rnapoin, but->rnaprop, &imin, &imax, &istep);
- softmin= (imin == INT_MIN)? -1e4: imin;
- softmax= (imin == INT_MAX)? 1e4: imax;
+ softmin = (imin == INT_MIN) ? -1e4 : imin;
+ softmax = (imin == INT_MAX) ? 1e4 : imax;
/*step= istep;*/ /*UNUSED*/
/*precision= 1;*/ /*UNUSED*/
if (array_len >= 2) {
int value_range[2];
RNA_property_int_get_array_range(&but->rnapoin, but->rnaprop, value_range);
- value_min= (double)value_range[0];
- value_max= (double)value_range[1];
+ value_min = (double)value_range[0];
+ value_max = (double)value_range[1];
}
}
else if (type == PROP_FLOAT) {
float fmin, fmax, fstep, fprecision;
- const int array_len= RNA_property_array_length(&but->rnapoin, but->rnaprop);
+ const int array_len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
RNA_property_float_ui_range(&but->rnapoin, but->rnaprop, &fmin, &fmax, &fstep, &fprecision);
- softmin= (fmin == -FLT_MAX)? (float)-1e4: fmin;
- softmax= (fmax == FLT_MAX)? (float)1e4: fmax;
+ softmin = (fmin == -FLT_MAX) ? (float)-1e4 : fmin;
+ softmax = (fmax == FLT_MAX) ? (float)1e4 : fmax;
/*step= fstep;*/ /*UNUSED*/
/*precision= fprecision;*/ /*UNUSED*/
if (array_len >= 2) {
float value_range[2];
RNA_property_float_get_array_range(&but->rnapoin, but->rnaprop, value_range);
- value_min= (double)value_range[0];
- value_max= (double)value_range[1];
+ value_min = (double)value_range[0];
+ value_max = (double)value_range[1];
}
}
else
return;
/* if the value goes out of the soft/max range, adapt the range */
- if (value_min+1e-10 < softmin) {
+ if (value_min + 1e-10 < softmin) {
if (value_min < 0.0)
- softmin= -soft_range_round_up(-value_min, -softmin);
+ softmin = -soft_range_round_up(-value_min, -softmin);
else
- softmin= soft_range_round_down(value_min, softmin);
+ softmin = soft_range_round_down(value_min, softmin);
if (softmin < (double)but->hardmin)
- softmin= (double)but->hardmin;
+ softmin = (double)but->hardmin;
}
- if (value_max-1e-10 > softmax) {
+ if (value_max - 1e-10 > softmax) {
if (value_max < 0.0)
- softmax= -soft_range_round_down(-value_max, -softmax);
+ softmax = -soft_range_round_down(-value_max, -softmax);
else
- softmax= soft_range_round_up(value_max, softmax);
+ softmax = soft_range_round_up(value_max, softmax);
if (softmax > (double)but->hardmax)
- softmax= but->hardmax;
+ softmax = but->hardmax;
}
- but->softmin= softmin;
- but->softmax= softmax;
+ but->softmin = softmin;
+ but->softmax = softmax;
}
}
@@ -2004,7 +2004,7 @@ void uiFreeBlock(const bContext *C, uiBlock *block)
{
uiBut *but;
- while ( (but= block->buttons.first) ) {
+ while ( (but = block->buttons.first) ) {
BLI_remlink(&block->buttons, but);
ui_free_but(C, but);
}
@@ -2029,7 +2029,7 @@ void uiFreeBlocks(const bContext *C, ListBase *lb)
{
uiBlock *block;
- while ( (block= lb->first) ) {
+ while ( (block = lb->first) ) {
BLI_remlink(lb, block);
uiFreeBlock(C, block);
}
@@ -2039,8 +2039,8 @@ void uiFreeInactiveBlocks(const bContext *C, ListBase *lb)
{
uiBlock *block, *nextblock;
- for (block=lb->first; block; block=nextblock) {
- nextblock= block->next;
+ for (block = lb->first; block; block = nextblock) {
+ nextblock = block->next;
if (!block->handle) {
if (!block->active) {
@@ -2048,31 +2048,31 @@ void uiFreeInactiveBlocks(const bContext *C, ListBase *lb)
uiFreeBlock(C, block);
}
else
- block->active= 0;
+ block->active = 0;
}
}
}
void uiBlockSetRegion(uiBlock *block, ARegion *region)
{
- ListBase *lb= &region->uiblocks;
- uiBlock *oldblock= NULL;
+ ListBase *lb = &region->uiblocks;
+ uiBlock *oldblock = NULL;
/* each listbase only has one block with this name, free block
* if is already there so it can be rebuilt from scratch */
if (lb) {
- oldblock= BLI_findstring(lb, block->name, offsetof(uiBlock, name));
+ oldblock = BLI_findstring(lb, block->name, offsetof(uiBlock, name));
if (oldblock) {
- oldblock->active= 0;
- oldblock->panel= NULL;
+ oldblock->active = 0;
+ oldblock->panel = NULL;
}
/* at the beginning of the list! for dynamical menus/blocks */
BLI_addhead(lb, block);
}
- block->oldblock= oldblock;
+ block->oldblock = oldblock;
}
uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, short dt)
@@ -2082,19 +2082,19 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor
Scene *scn;
int getsizex, getsizey;
- window= CTX_wm_window(C);
+ window = CTX_wm_window(C);
scn = CTX_data_scene(C);
- block= MEM_callocN(sizeof(uiBlock), "uiBlock");
- block->active= 1;
- block->dt= dt;
- block->evil_C= (void*)C; // XXX
+ block = MEM_callocN(sizeof(uiBlock), "uiBlock");
+ block->active = 1;
+ block->dt = dt;
+ block->evil_C = (void *)C; // XXX
if (scn) {
- block->color_profile= (scn->r.color_mgt_flag & R_COLOR_MANAGEMENT);
+ block->color_profile = (scn->r.color_mgt_flag & R_COLOR_MANAGEMENT);
/* copy to avoid crash when scene gets deleted with ui still open */
- block->unit= MEM_mallocN(sizeof(scn->unit), "UI UnitSettings");
+ block->unit = MEM_mallocN(sizeof(scn->unit), "UI UnitSettings");
memcpy(block->unit, &scn->unit, sizeof(scn->unit));
}
@@ -2110,7 +2110,7 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor
/* TODO - investigate why block->winmat[0][0] is negative
* in the image view when viewRedrawForce is called */
- block->aspect= 2.0/fabs( (getsizex)*block->winmat[0][0]);
+ block->aspect = 2.0 / fabs( (getsizex) * block->winmat[0][0]);
}
else {
/* no subwindow created yet, for menus for example, so we
@@ -2119,8 +2119,8 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor
wm_subwindow_getmatrix(window, window->screen->mainwin, block->winmat);
wm_subwindow_getsize(window, window->screen->mainwin, &getsizex, &getsizey);
- block->aspect= 2.0/fabs(getsizex*block->winmat[0][0]);
- block->auto_open= TRUE;
+ block->aspect = 2.0 / fabs(getsizex * block->winmat[0][0]);
+ block->auto_open = TRUE;
block->flag |= UI_BLOCK_LOOP; /* tag as menu */
}
@@ -2134,13 +2134,13 @@ uiBlock *uiGetBlock(const char *name, ARegion *ar)
void uiBlockSetEmboss(uiBlock *block, char dt)
{
- block->dt= dt;
+ block->dt = dt;
}
void ui_check_but(uiBut *but)
{
/* if something changed in the button */
- double value= UI_BUT_VALUE_UNSET;
+ double value = UI_BUT_VALUE_UNSET;
// float okwidth; // UNUSED
ui_is_but_sel(but, &value);
@@ -2152,7 +2152,7 @@ void ui_check_but(uiBut *but)
}
/* test for min and max, icon sliders, etc */
- switch( but->type ) {
+ switch (but->type) {
case NUM:
case SLI:
case SCROLL:
@@ -2167,7 +2167,7 @@ void ui_check_but(uiBut *but)
{
double value_abs;
UI_GET_BUT_VALUE_INIT(but, value)
- value_abs= fabs(value);
+ value_abs = fabs(value);
if (value_abs < (double)but->hardmin) ui_set_but_val(but, but->hardmin);
else if (value_abs > (double)but->hardmax) ui_set_but_val(but, but->hardmax);
break;
@@ -2175,22 +2175,22 @@ void ui_check_but(uiBut *but)
case ICONTOG:
case ICONTOGN:
if (!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) {
- if (but->flag & UI_SELECT) but->iconadd= 1;
- else but->iconadd= 0;
+ if (but->flag & UI_SELECT) but->iconadd = 1;
+ else but->iconadd = 0;
}
break;
case ICONROW:
if (!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) {
UI_GET_BUT_VALUE_INIT(but, value)
- but->iconadd= (int)value- (int)(but->hardmin);
+ but->iconadd = (int)value - (int)(but->hardmin);
}
break;
case ICONTEXTROW:
if (!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) {
UI_GET_BUT_VALUE_INIT(but, value)
- but->iconadd= (int)value- (int)(but->hardmin);
+ but->iconadd = (int)value - (int)(but->hardmin);
}
break;
}
@@ -2200,125 +2200,125 @@ void ui_check_but(uiBut *but)
// okwidth= -4 + (but->x2 - but->x1); // UNUSED
/* name: */
- switch( but->type ) {
+ switch (but->type) {
- case MENU:
- case ICONTEXTROW:
+ case MENU:
+ case ICONTEXTROW:
- if (but->x2 - but->x1 > 24) {
- UI_GET_BUT_VALUE_INIT(but, value)
- ui_set_name_menu(but, (int)value);
- }
- break;
+ if (but->x2 - but->x1 > 24) {
+ UI_GET_BUT_VALUE_INIT(but, value)
+ ui_set_name_menu(but, (int)value);
+ }
+ break;
- case NUM:
- case NUMSLI:
- case HSVSLI:
- case NUMABS:
+ case NUM:
+ case NUMSLI:
+ case HSVSLI:
+ case NUMABS:
- UI_GET_BUT_VALUE_INIT(but, value)
+ UI_GET_BUT_VALUE_INIT(but, value)
- if (ui_is_but_float(but)) {
- if (value == (double) FLT_MAX) BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%sinf", but->str);
- else if (value == (double) -FLT_MAX) BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s-inf", but->str);
- /* support length type buttons */
- else if (ui_is_but_unit(but)) {
- char new_str[sizeof(but->drawstr)];
- ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE);
- BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str);
+ if (ui_is_but_float(but)) {
+ if (value == (double) FLT_MAX) BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%sinf", but->str);
+ else if (value == (double) -FLT_MAX) BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s-inf", but->str);
+ /* support length type buttons */
+ else if (ui_is_but_unit(but)) {
+ char new_str[sizeof(but->drawstr)];
+ ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE);
+ BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str);
+ }
+ else {
+ const int prec = ui_but_float_precision(but, value);
+ BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value);
+ }
}
else {
- const int prec= ui_but_float_precision(but, value);
- BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value);
+ BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%d", but->str, (int)value);
}
- }
- else {
- BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%d", but->str, (int)value);
- }
- if (but->rnaprop) {
- PropertySubType pstype = RNA_property_subtype(but->rnaprop);
+ if (but->rnaprop) {
+ PropertySubType pstype = RNA_property_subtype(but->rnaprop);
- if (pstype == PROP_PERCENTAGE)
- strcat(but->drawstr, "%");
- }
- break;
+ if (pstype == PROP_PERCENTAGE)
+ strcat(but->drawstr, "%");
+ }
+ break;
- case LABEL:
- if (ui_is_but_float(but)) {
- int prec;
- UI_GET_BUT_VALUE_INIT(but, value)
- prec= ui_but_float_precision(but, value);
- BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value);
- }
- else {
- BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
- }
+ case LABEL:
+ if (ui_is_but_float(but)) {
+ int prec;
+ UI_GET_BUT_VALUE_INIT(but, value)
+ prec = ui_but_float_precision(but, value);
+ BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value);
+ }
+ else {
+ BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
+ }
- break;
+ break;
- case IDPOIN:
- case TEX:
- case SEARCH_MENU:
- if (!but->editstr) {
- char str[UI_MAX_DRAW_STR];
+ case IDPOIN:
+ case TEX:
+ case SEARCH_MENU:
+ if (!but->editstr) {
+ char str[UI_MAX_DRAW_STR];
- ui_get_but_string(but, str, UI_MAX_DRAW_STR-strlen(but->str));
+ ui_get_but_string(but, str, UI_MAX_DRAW_STR - strlen(but->str));
- BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, str);
- }
- break;
+ BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, str);
+ }
+ break;
- case KEYEVT:
- BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
- if (but->flag & UI_SELECT) {
- strcat(but->drawstr, "Press a key");
- }
- else {
- UI_GET_BUT_VALUE_INIT(but, value)
- strcat(but->drawstr, WM_key_event_string((short)value));
- }
- break;
+ case KEYEVT:
+ BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
+ if (but->flag & UI_SELECT) {
+ strcat(but->drawstr, "Press a key");
+ }
+ else {
+ UI_GET_BUT_VALUE_INIT(but, value)
+ strcat(but->drawstr, WM_key_event_string((short)value));
+ }
+ break;
- case HOTKEYEVT:
- if (but->flag & UI_SELECT) {
- but->drawstr[0]= '\0';
-
- if (but->modifier_key) {
- char *str= but->drawstr;
-
- if (but->modifier_key & KM_SHIFT)
- str= strcat(str, "Shift ");
- if (but->modifier_key & KM_CTRL)
- str= strcat(str, "Ctrl ");
- if (but->modifier_key & KM_ALT)
- str= strcat(str, "Alt ");
- if (but->modifier_key & KM_OSKEY)
- str= strcat(str, "Cmd ");
-
- (void)str; /* UNUSED */
+ case HOTKEYEVT:
+ if (but->flag & UI_SELECT) {
+ but->drawstr[0] = '\0';
+
+ if (but->modifier_key) {
+ char *str = but->drawstr;
+
+ if (but->modifier_key & KM_SHIFT)
+ str = strcat(str, "Shift ");
+ if (but->modifier_key & KM_CTRL)
+ str = strcat(str, "Ctrl ");
+ if (but->modifier_key & KM_ALT)
+ str = strcat(str, "Alt ");
+ if (but->modifier_key & KM_OSKEY)
+ str = strcat(str, "Cmd ");
+
+ (void)str; /* UNUSED */
+ }
+ else
+ strcat(but->drawstr, "Press a key ");
}
else
- strcat(but->drawstr, "Press a key ");
- }
- else
- BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
+ BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
+
+ break;
- break;
+ case BUT_TOGDUAL:
+ /* trying to get the dual-icon to left of text... not very nice */
+ if (but->str[0]) {
+ BLI_strncpy(but->drawstr, " ", UI_MAX_DRAW_STR);
+ BLI_strncpy(but->drawstr + 2, but->str, UI_MAX_DRAW_STR - 2);
+ }
+ break;
- case BUT_TOGDUAL:
- /* trying to get the dual-icon to left of text... not very nice */
- if (but->str[0]) {
- BLI_strncpy(but->drawstr, " ", UI_MAX_DRAW_STR);
- BLI_strncpy(but->drawstr+2, but->str, UI_MAX_DRAW_STR-2);
- }
- break;
-
- case HSVCUBE:
- case HSVCIRCLE:
- break;
- default:
- BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
+ case HSVCUBE:
+ case HSVCIRCLE:
+ break;
+ default:
+ BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR);
}
@@ -2345,8 +2345,8 @@ static int buts_are_horiz(uiBut *but1, uiBut *but2)
{
float dx, dy;
- dx= fabs( but1->x2 - but2->x1);
- dy= fabs( but1->y1 - but2->y2);
+ dx = fabs(but1->x2 - but2->x1);
+ dy = fabs(but1->y1 - but2->y2);
if (dx > dy) return 0;
return 1;
@@ -2354,7 +2354,7 @@ static int buts_are_horiz(uiBut *but1, uiBut *but2)
void uiBlockEndAlign(uiBlock *block)
{
- block->flag &= ~UI_BUT_ALIGN; // all 4 flags
+ block->flag &= ~UI_BUT_ALIGN; // all 4 flags
}
int ui_but_can_align(uiBut *but)
@@ -2364,12 +2364,12 @@ int ui_but_can_align(uiBut *but)
static void ui_block_do_align_but(uiBut *first, short nr)
{
- uiBut *prev, *but=NULL, *next;
- int flag= 0, cols=0, rows=0;
+ uiBut *prev, *but = NULL, *next;
+ int flag = 0, cols = 0, rows = 0;
/* auto align */
- for (but=first; but && but->alignnr == nr; but=but->next) {
+ for (but = first; but && but->alignnr == nr; but = but->next) {
if (but->next && but->next->alignnr == nr) {
if (buts_are_horiz(but, but->next)) cols++;
else rows++;
@@ -2379,60 +2379,60 @@ static void ui_block_do_align_but(uiBut *first, short nr)
/* rows==0: 1 row, cols==0: 1 column */
/* note; how it uses 'flag' in loop below (either set it, or OR it) is confusing */
- for (but=first, prev=NULL; but && but->alignnr == nr; prev=but, but=but->next) {
- next= but->next;
+ for (but = first, prev = NULL; but && but->alignnr == nr; prev = but, but = but->next) {
+ next = but->next;
if (next && next->alignnr != nr)
- next= NULL;
+ next = NULL;
/* clear old flag */
but->flag &= ~UI_BUT_ALIGN;
- if (flag==0) { /* first case */
+ if (flag == 0) { /* first case */
if (next) {
if (buts_are_horiz(but, next)) {
- if (rows==0)
- flag= UI_BUT_ALIGN_RIGHT;
+ if (rows == 0)
+ flag = UI_BUT_ALIGN_RIGHT;
else
- flag= UI_BUT_ALIGN_DOWN|UI_BUT_ALIGN_RIGHT;
+ flag = UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_RIGHT;
}
else {
- flag= UI_BUT_ALIGN_DOWN;
+ flag = UI_BUT_ALIGN_DOWN;
}
}
}
- else if (next==NULL) { /* last case */
+ else if (next == NULL) { /* last case */
if (prev) {
if (buts_are_horiz(prev, but)) {
- if (rows==0)
- flag= UI_BUT_ALIGN_LEFT;
+ if (rows == 0)
+ flag = UI_BUT_ALIGN_LEFT;
else
- flag= UI_BUT_ALIGN_TOP|UI_BUT_ALIGN_LEFT;
+ flag = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT;
}
- else flag= UI_BUT_ALIGN_TOP;
+ else flag = UI_BUT_ALIGN_TOP;
}
}
else if (buts_are_horiz(but, next)) {
/* check if this is already second row */
- if ( prev && buts_are_horiz(prev, but)==0) {
+ if (prev && buts_are_horiz(prev, but) == 0) {
flag &= ~UI_BUT_ALIGN_LEFT;
flag |= UI_BUT_ALIGN_TOP;
/* exception case: bottom row */
- if (rows>0) {
- uiBut *bt= but;
+ if (rows > 0) {
+ uiBut *bt = but;
while (bt && bt->alignnr == nr) {
- if (bt->next && bt->next->alignnr == nr && buts_are_horiz(bt, bt->next)==0 ) break;
- bt= bt->next;
+ if (bt->next && bt->next->alignnr == nr && buts_are_horiz(bt, bt->next) == 0) break;
+ bt = bt->next;
}
- if (bt==NULL || bt->alignnr != nr) flag= UI_BUT_ALIGN_TOP|UI_BUT_ALIGN_RIGHT;
+ if (bt == NULL || bt->alignnr != nr) flag = UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_RIGHT;
}
}
else flag |= UI_BUT_ALIGN_LEFT;
}
else {
- if (cols==0) {
+ if (cols == 0) {
flag |= UI_BUT_ALIGN_TOP;
}
- else { /* next button switches to new row */
+ else { /* next button switches to new row */
if (prev && buts_are_horiz(prev, but))
flag |= UI_BUT_ALIGN_LEFT;
@@ -2441,13 +2441,13 @@ static void ui_block_do_align_but(uiBut *first, short nr)
flag |= UI_BUT_ALIGN_TOP;
}
- if ( (flag & UI_BUT_ALIGN_TOP)==0) { /* stil top row */
+ if ( (flag & UI_BUT_ALIGN_TOP) == 0) { /* stil top row */
if (prev) {
if (next && buts_are_horiz(but, next))
- flag = UI_BUT_ALIGN_DOWN|UI_BUT_ALIGN_LEFT|UI_BUT_ALIGN_RIGHT;
+ flag = UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_LEFT | UI_BUT_ALIGN_RIGHT;
else {
/* last button in top row */
- flag = UI_BUT_ALIGN_DOWN|UI_BUT_ALIGN_LEFT;
+ flag = UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_LEFT;
}
}
else
@@ -2463,33 +2463,33 @@ static void ui_block_do_align_but(uiBut *first, short nr)
/* merge coordinates */
if (prev) {
// simple cases
- if (rows==0) {
- but->x1= (prev->x2+but->x1)/2.0f;
- prev->x2= but->x1;
+ if (rows == 0) {
+ but->x1 = (prev->x2 + but->x1) / 2.0f;
+ prev->x2 = but->x1;
}
- else if (cols==0) {
- but->y2= (prev->y1+but->y2)/2.0f;
- prev->y1= but->y2;
+ else if (cols == 0) {
+ but->y2 = (prev->y1 + but->y2) / 2.0f;
+ prev->y1 = but->y2;
}
else {
if (buts_are_horiz(prev, but)) {
- but->x1= (prev->x2+but->x1)/2.0f;
- prev->x2= but->x1;
+ but->x1 = (prev->x2 + but->x1) / 2.0f;
+ prev->x2 = but->x1;
/* copy height too */
- but->y2= prev->y2;
+ but->y2 = prev->y2;
}
- else if (prev->prev && buts_are_horiz(prev->prev, prev)==0) {
+ else if (prev->prev && buts_are_horiz(prev->prev, prev) == 0) {
/* the previous button is a single one in its row */
- but->y2= (prev->y1+but->y2)/2.0f;
- prev->y1= but->y2;
+ but->y2 = (prev->y1 + but->y2) / 2.0f;
+ prev->y1 = but->y2;
- but->x1= prev->x1;
- if (next && buts_are_horiz(but, next)==0)
- but->x2= prev->x2;
+ but->x1 = prev->x1;
+ if (next && buts_are_horiz(but, next) == 0)
+ but->x2 = prev->x2;
}
else {
/* the previous button is not a single one in its row */
- but->y2= prev->y1;
+ but->y2 = prev->y1;
}
}
}
@@ -2502,19 +2502,19 @@ void ui_block_do_align(uiBlock *block)
short nr;
/* align buttons with same align nr */
- for (but=block->buttons.first; but;) {
+ for (but = block->buttons.first; but; ) {
if (but->alignnr) {
- nr= but->alignnr;
+ nr = but->alignnr;
ui_block_do_align_but(but, nr);
/* skip with same number */
- for (; but && but->alignnr == nr; but=but->next);
+ for (; but && but->alignnr == nr; but = but->next) ;
if (!but)
break;
}
else
- but= but->next;
+ but = but->next;
}
}
@@ -2531,76 +2531,76 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
uiBut *but;
int slen;
- if (type & BUTPOIN) { /* a pointer is required */
- if (poin==NULL)
+ if (type & BUTPOIN) { /* a pointer is required */
+ if (poin == NULL)
return NULL;
}
- but= MEM_callocN(sizeof(uiBut), "uiBut");
+ but = MEM_callocN(sizeof(uiBut), "uiBut");
- but->type= type & BUTTYPE;
- but->pointype= type & BUTPOIN;
- but->bit= type & BIT;
- but->bitnr= type & 31;
+ but->type = type & BUTTYPE;
+ but->pointype = type & BUTPOIN;
+ but->bit = type & BIT;
+ but->bitnr = type & 31;
but->icon = ICON_NONE;
- but->iconadd=0;
+ but->iconadd = 0;
- but->retval= retval;
+ but->retval = retval;
- slen= strlen(str);
- if (slen >= UI_MAX_NAME_STR-1) {
- but->str= MEM_mallocN(slen+2, "ui_def_but str"); /* why +2 ? */
+ slen = strlen(str);
+ if (slen >= UI_MAX_NAME_STR - 1) {
+ but->str = MEM_mallocN(slen + 2, "ui_def_but str"); /* why +2 ? */
}
else {
- but->str= but->strdata;
+ but->str = but->strdata;
}
- memcpy(but->str, str, slen+1);
+ memcpy(but->str, str, slen + 1);
- but->x1= x1;
- but->y1= y1;
- but->x2= (x1+x2);
- but->y2= (y1+y2);
-
- but->poin= poin;
- but->hardmin= but->softmin= min;
- but->hardmax= but->softmax= max;
- but->a1= a1;
- but->a2= a2;
- but->tip= tip;
-
- but->lock= block->lock;
- but->lockstr= block->lockstr;
- but->dt= block->dt;
+ but->x1 = x1;
+ but->y1 = y1;
+ but->x2 = (x1 + x2);
+ but->y2 = (y1 + y2);
+
+ but->poin = poin;
+ but->hardmin = but->softmin = min;
+ but->hardmax = but->softmax = max;
+ but->a1 = a1;
+ but->a2 = a2;
+ but->tip = tip;
- but->aspect= 1.0f; //XXX block->aspect;
- but->block= block; // pointer back, used for frontbuffer status, and picker
+ but->lock = block->lock;
+ but->lockstr = block->lockstr;
+ but->dt = block->dt;
+
+ but->aspect = 1.0f; //XXX block->aspect;
+ but->block = block; // pointer back, used for frontbuffer status, and picker
if ((block->flag & UI_BUT_ALIGN) && ui_but_can_align(but))
- but->alignnr= block->alignnr;
+ but->alignnr = block->alignnr;
- but->func= block->func;
- but->func_arg1= block->func_arg1;
- but->func_arg2= block->func_arg2;
+ but->func = block->func;
+ but->func_arg1 = block->func_arg1;
+ but->func_arg2 = block->func_arg2;
- but->funcN= block->funcN;
+ but->funcN = block->funcN;
if (block->func_argN)
- but->func_argN= MEM_dupallocN(block->func_argN);
+ but->func_argN = MEM_dupallocN(block->func_argN);
- but->pos= -1; /* cursor invisible */
+ but->pos = -1; /* cursor invisible */
- if (ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI)) { /* add a space to name */
+ if (ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI)) { /* add a space to name */
/* slen remains unchanged from previous assignment, ensure this stays true */
- if (slen>0 && slen<UI_MAX_NAME_STR-2) {
- if (but->str[slen-1]!=' ') {
- but->str[slen]= ' ';
- but->str[slen+1]= 0;
+ if (slen > 0 && slen < UI_MAX_NAME_STR - 2) {
+ if (but->str[slen - 1] != ' ') {
+ but->str[slen] = ' ';
+ but->str[slen + 1] = 0;
}
}
}
if ((block->flag & UI_BLOCK_LOOP) || ELEM8(but->type, MENU, TEX, LABEL, IDPOIN, BLOCK, BUTM, SEARCH_MENU, PROGRESSBAR))
- but->flag |= (UI_TEXT_LEFT|UI_ICON_LEFT);
- else if (but->type==BUT_TOGDUAL)
+ but->flag |= (UI_TEXT_LEFT | UI_ICON_LEFT);
+ else if (but->type == BUT_TOGDUAL)
but->flag |= UI_ICON_LEFT;
but->flag |= (block->flag & UI_BUT_ALIGN);
@@ -2612,9 +2612,9 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
}
/* keep track of UI_interface.h */
- if (ELEM7(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM));
- else if (ELEM3(but->type, SCROLL, SEPR, FTPREVIEW));
- else if (but->type >= SEARCH_MENU);
+ if (ELEM7(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM)) ;
+ else if (ELEM3(but->type, SCROLL, SEPR, FTPREVIEW)) ;
+ else if (but->type >= SEARCH_MENU) ;
else but->flag |= UI_BUT_UNDO;
BLI_addtail(&block->buttons, but);
@@ -2641,16 +2641,16 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
*/
#define UI_DEF_BUT_RNA_DISABLE(but) \
- but->flag |= UI_BUT_DISABLED; \
- but->lock = 1; \
- but->lockstr = ""
+ but->flag |= UI_BUT_DISABLED; \
+ but->lock = 1; \
+ but->lockstr = ""
static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip)
{
- const PropertyType proptype= RNA_property_type(prop);
+ const PropertyType proptype = RNA_property_type(prop);
uiBut *but;
- int freestr= 0, icon= 0;
+ int freestr = 0, icon = 0;
/* use rna values if parameters are not specified */
if (!str) {
@@ -2660,11 +2660,11 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
int i, totitem, value, free;
RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free);
- value= RNA_property_enum_get(ptr, prop);
+ value = RNA_property_enum_get(ptr, prop);
- dynstr= BLI_dynstr_new();
+ dynstr = BLI_dynstr_new();
BLI_dynstr_appendf(dynstr, "%s%%t", RNA_property_ui_name(prop));
- for (i=0; i<totitem; i++) {
+ for (i = 0; i < totitem; i++) {
if (!item[i].identifier[0]) {
if (item[i].name)
BLI_dynstr_appendf(dynstr, "|%s%%l", item[i].name);
@@ -2677,26 +2677,26 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
BLI_dynstr_appendf(dynstr, "|%s %%x%d", item[i].name, item[i].value);
if (value == item[i].value)
- icon= item[i].icon;
+ icon = item[i].icon;
}
- str= BLI_dynstr_get_cstring(dynstr);
+ str = BLI_dynstr_get_cstring(dynstr);
BLI_dynstr_free(dynstr);
if (free) {
MEM_freeN(item);
}
- freestr= 1;
+ freestr = 1;
}
else if (ELEM(type, ROW, LISTROW) && proptype == PROP_ENUM) {
EnumPropertyItem *item;
int i, totitem, free;
RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free);
- for (i=0; i<totitem; i++) {
+ for (i = 0; i < totitem; i++) {
if (item[i].identifier[0] && item[i].value == (int)max) {
- str= item[i].name;
- icon= item[i].icon;
+ str = item[i].name;
+ icon = item[i].icon;
}
}
@@ -2708,13 +2708,13 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
}
}
else {
- str= RNA_property_ui_name(prop);
- icon= RNA_property_ui_icon(prop);
+ str = RNA_property_ui_name(prop);
+ icon = RNA_property_ui_icon(prop);
}
}
if (!tip && proptype != PROP_ENUM)
- tip= RNA_property_ui_description(prop);
+ tip = RNA_property_ui_description(prop);
if (min == max || a1 == -1 || a2 == -1) {
if (proptype == PROP_INT) {
@@ -2724,13 +2724,13 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
RNA_property_int_ui_range(ptr, prop, &softmin, &softmax, &step);
if (!ELEM(type, ROW, LISTROW) && min == max) {
- min= hardmin;
- max= hardmax;
+ min = hardmin;
+ max = hardmax;
}
if (a1 == -1)
- a1= step;
+ a1 = step;
if (a2 == -1)
- a2= 0;
+ a2 = 0;
}
else if (proptype == PROP_FLOAT) {
float hardmin, hardmax, softmin, softmax, step, precision;
@@ -2739,37 +2739,37 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
if (!ELEM(type, ROW, LISTROW) && min == max) {
- min= hardmin;
- max= hardmax;
+ min = hardmin;
+ max = hardmax;
}
if (a1 == -1)
- a1= step;
+ a1 = step;
if (a2 == -1)
- a2= precision;
+ a2 = precision;
}
else if (proptype == PROP_STRING) {
- min= 0;
- max= RNA_property_string_maxlength(prop);
+ min = 0;
+ max = RNA_property_string_maxlength(prop);
if (max == 0) /* interface code should ideally support unlimited length */
- max= UI_MAX_DRAW_STR;
+ max = UI_MAX_DRAW_STR;
}
}
/* now create button */
- but= ui_def_but(block, type, retval, str, x1, y1, x2, y2, NULL, min, max, a1, a2, tip);
+ but = ui_def_but(block, type, retval, str, x1, y1, x2, y2, NULL, min, max, a1, a2, tip);
- but->rnapoin= *ptr;
- but->rnaprop= prop;
+ but->rnapoin = *ptr;
+ but->rnaprop = prop;
if (RNA_property_array_length(&but->rnapoin, but->rnaprop))
- but->rnaindex= index;
+ but->rnaindex = index;
else
- but->rnaindex= 0;
+ but->rnaindex = 0;
if (icon) {
- but->icon= (BIFIconID)icon;
+ but->icon = (BIFIconID)icon;
but->flag |= UI_HAS_ICON;
- but->flag|= UI_ICON_LEFT;
+ but->flag |= UI_ICON_LEFT;
}
if (!RNA_property_editable(&but->rnapoin, prop)) {
@@ -2782,7 +2782,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
/* If this button uses units, calculate the step from this */
if ((proptype == PROP_FLOAT) && ui_is_but_unit(but)) {
- but->a1= ui_get_but_step_unit(but, but->a1);
+ but->a1 = ui_get_but_step_unit(but, but->a1);
}
if (freestr) {
@@ -2794,14 +2794,14 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
static uiBut *ui_def_but_rna_propname(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip)
{
- PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
uiBut *but;
if (prop) {
- but= ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip);
+ but = ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip);
}
else {
- but= ui_def_but(block, type, retval, propname, x1, y1, x2, y2, NULL, min, max, a1, a2, tip);
+ but = ui_def_but(block, type, retval, propname, x1, y1, x2, y2, NULL, min, max, a1, a2, tip);
UI_DEF_BUT_RNA_DISABLE(but);
}
@@ -2820,13 +2820,13 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType *
str = "";
}
- if ((!tip || tip[0]=='\0') && ot && ot->srna) {
+ if ((!tip || tip[0] == '\0') && ot && ot->srna) {
tip = RNA_struct_ui_description(ot->srna);
}
- but= ui_def_but(block, type, -1, str, x1, y1, x2, y2, NULL, 0, 0, 0, 0, tip);
- but->optype= ot;
- but->opcontext= opcontext;
+ but = ui_def_but(block, type, -1, str, x1, y1, x2, y2, NULL, 0, 0, 0, 0, tip);
+ but->optype = ot;
+ but->opcontext = opcontext;
but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_undo(), we never need undo here */
if (!ot) {
@@ -2839,7 +2839,7 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType *
}
#if 0 /* UNUSED */
-static uiBut *UNUSED_FUNCTION(ui_def_but_operator)(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
+static uiBut *UNUSED_FUNCTION(ui_def_but_operator) (uiBlock * block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
{
wmOperatorType *ot = WM_operatortype_find(opname, 0);
if (str == NULL && ot == NULL) str = opname;
@@ -2852,20 +2852,20 @@ static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opn
uiBut *but;
wmOperatorType *ot;
- ot= WM_operatortype_find(opname, 0);
+ ot = WM_operatortype_find(opname, 0);
if (!str) {
- if (ot) str= ot->name;
- else str= opname;
+ if (ot) str = ot->name;
+ else str = opname;
}
- if ((!tip || tip[0]=='\0') && ot && ot->description) {
- tip= ot->description;
+ if ((!tip || tip[0] == '\0') && ot && ot->description) {
+ tip = ot->description;
}
- but= ui_def_but(block, type, -1, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
- but->optype= ot;
- but->opcontext= opcontext;
+ but = ui_def_but(block, type, -1, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
+ but->optype = ot;
+ but->opcontext = opcontext;
but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_undo(), we never need undo here */
if (!ot) {
@@ -2879,30 +2879,30 @@ static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opn
uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip)
{
- uiBut *but= ui_def_but(block, type, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
+ uiBut *but = ui_def_but(block, type, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
ui_check_but(but);
return but;
}
- /* if _x_ is a power of two (only one bit) return the power,
- * otherwise return -1.
- * (1<<findBitIndex(x))==x for powers of two.
- */
+/* if _x_ is a power of two (only one bit) return the power,
+ * otherwise return -1.
+ * (1<<findBitIndex(x))==x for powers of two.
+ */
static int findBitIndex(unsigned int x)
{
if (!x || !is_power_of_2_i(x)) { /* is_power_of_2_i(x) strips lowest bit */
return -1;
}
else {
- int idx= 0;
+ int idx = 0;
- if (x&0xFFFF0000) idx+=16, x>>=16;
- if (x&0xFF00) idx+=8, x>>=8;
- if (x&0xF0) idx+=4, x>>=4;
- if (x&0xC) idx+=2, x>>=2;
- if (x&0x2) idx+=1;
+ if (x & 0xFFFF0000) idx += 16, x >>= 16;
+ if (x & 0xFF00) idx += 8, x >>= 8;
+ if (x & 0xF0) idx += 4, x >>= 4;
+ if (x & 0xC) idx += 2, x >>= 2;
+ if (x & 0x2) idx += 1;
return idx;
}
@@ -2919,38 +2919,38 @@ AutoComplete *autocomplete_begin(const char *startname, size_t maxlen)
{
AutoComplete *autocpl;
- autocpl= MEM_callocN(sizeof(AutoComplete), "AutoComplete");
- autocpl->maxlen= maxlen;
- autocpl->truncate= MEM_callocN(sizeof(char)*maxlen, "AutoCompleteTruncate");
- autocpl->startname= startname;
+ autocpl = MEM_callocN(sizeof(AutoComplete), "AutoComplete");
+ autocpl->maxlen = maxlen;
+ autocpl->truncate = MEM_callocN(sizeof(char) * maxlen, "AutoCompleteTruncate");
+ autocpl->startname = startname;
return autocpl;
}
void autocomplete_do_name(AutoComplete *autocpl, const char *name)
{
- char *truncate= autocpl->truncate;
- const char *startname= autocpl->startname;
+ char *truncate = autocpl->truncate;
+ const char *startname = autocpl->startname;
int a;
- for (a=0; a<autocpl->maxlen-1; a++) {
- if (startname[a]==0 || startname[a]!=name[a])
+ for (a = 0; a < autocpl->maxlen - 1; a++) {
+ if (startname[a] == 0 || startname[a] != name[a])
break;
}
/* found a match */
- if (startname[a]==0) {
+ if (startname[a] == 0) {
/* first match */
- if (truncate[0]==0)
+ if (truncate[0] == 0)
BLI_strncpy(truncate, name, autocpl->maxlen);
else {
/* remove from truncate what is not in bone->name */
- for (a=0; a<autocpl->maxlen-1; a++) {
+ for (a = 0; a < autocpl->maxlen - 1; a++) {
if (name[a] == 0) {
- truncate[a]= 0;
+ truncate[a] = 0;
break;
}
- else if (truncate[a]!=name[a])
- truncate[a]= 0;
+ else if (truncate[a] != name[a])
+ truncate[a] = 0;
}
}
}
@@ -2971,18 +2971,18 @@ void autocomplete_end(AutoComplete *autocpl, char *autoname)
/* autocomplete callback for ID buttons */
static void autocomplete_id(bContext *C, char *str, void *arg_v)
{
- int blocktype= (intptr_t)arg_v;
- ListBase *listb= which_libbase(CTX_data_main(C), blocktype);
+ int blocktype = (intptr_t)arg_v;
+ ListBase *listb = which_libbase(CTX_data_main(C), blocktype);
- if (listb==NULL) return;
+ if (listb == NULL) return;
/* search if str matches the beginning of an ID struct */
if (str[0]) {
- AutoComplete *autocpl= autocomplete_begin(str, MAX_ID_NAME-2);
+ AutoComplete *autocpl = autocomplete_begin(str, MAX_ID_NAME - 2);
ID *id;
- for (id= listb->first; id; id= id->next)
- autocomplete_do_name(autocpl, id->name+2);
+ for (id = listb->first; id; id = id->next)
+ autocomplete_do_name(autocpl, id->name + 2);
autocomplete_end(autocpl, str);
}
@@ -2991,8 +2991,8 @@ static void autocomplete_id(bContext *C, char *str, void *arg_v)
static void ui_check_but_and_iconize(uiBut *but, int icon)
{
if (icon) {
- but->icon= (BIFIconID) icon;
- but->flag|= UI_HAS_ICON;
+ but->icon = (BIFIconID) icon;
+ but->flag |= UI_HAS_ICON;
}
ui_check_but(but);
@@ -3000,57 +3000,57 @@ static void ui_check_but_and_iconize(uiBut *but, int icon)
static uiBut *uiDefButBit(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip)
{
- int bitIdx= findBitIndex(bit);
- if (bitIdx==-1) {
+ int bitIdx = findBitIndex(bit);
+ if (bitIdx == -1) {
return NULL;
}
else {
- return uiDefBut(block, type|BIT|bitIdx, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
+ return uiDefBut(block, type | BIT | bitIdx, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
}
}
uiBut *uiDefButF(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefBut(block, type|FLO, retval, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefBut(block, type | FLO, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButBitF(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefButBit(block, type|FLO, bit, retval, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefButBit(block, type | FLO, bit, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButI(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefBut(block, type|INT, retval, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefBut(block, type | INT, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButBitI(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefButBit(block, type|INT, bit, retval, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefButBit(block, type | INT, bit, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButS(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefBut(block, type|SHO, retval, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefBut(block, type | SHO, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButBitS(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefButBit(block, type|SHO, bit, retval, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefButBit(block, type | SHO, bit, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButC(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefBut(block, type|CHA, retval, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefBut(block, type | CHA, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefButBit(block, type|CHA, bit, retval, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefButBit(block, type | CHA, bit, retval, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip)
{
uiBut *but;
- but= ui_def_but_rna_propname(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip);
+ but = ui_def_but_rna_propname(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip);
ui_check_but(but);
return but;
}
uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip)
{
uiBut *but;
- but= ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip);
+ but = ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip);
ui_check_but(but);
return but;
}
@@ -3058,7 +3058,7 @@ uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int
uiBut *uiDefButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip)
{
uiBut *but;
- but= ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip);
+ but = ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip);
ui_check_but(but);
return but;
}
@@ -3071,7 +3071,7 @@ uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, co
uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip)
{
- uiBut *but= ui_def_but_operator_text(block, type, opname, opcontext, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
+ uiBut *but = ui_def_but_operator_text(block, type, opname, opcontext, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
ui_check_but(but);
return but;
}
@@ -3079,64 +3079,64 @@ uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext
/* if a1==1.0 then a2 is an extra icon blending factor (alpha 0.0 - 1.0) */
uiBut *uiDefIconBut(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip)
{
- uiBut *but= ui_def_but(block, type, retval, "", x1, y1, x2, y2, poin, min, max, a1, a2, tip);
+ uiBut *but = ui_def_but(block, type, retval, "", x1, y1, x2, y2, poin, min, max, a1, a2, tip);
ui_check_but_and_iconize(but, icon);
return but;
}
static uiBut *uiDefIconButBit(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip)
{
- int bitIdx= findBitIndex(bit);
- if (bitIdx==-1) {
+ int bitIdx = findBitIndex(bit);
+ if (bitIdx == -1) {
return NULL;
}
else {
- return uiDefIconBut(block, type|BIT|bitIdx, retval, icon, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
+ return uiDefIconBut(block, type | BIT | bitIdx, retval, icon, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
}
}
uiBut *uiDefIconButF(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconBut(block, type|FLO, retval, icon, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconBut(block, type | FLO, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconButBitF(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconButBit(block, type|FLO, bit, retval, icon, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconButBit(block, type | FLO, bit, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconBut(block, type|INT, retval, icon, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconBut(block, type | INT, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconButBitI(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconButBit(block, type|INT, bit, retval, icon, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconButBit(block, type | INT, bit, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconButS(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconBut(block, type|SHO, retval, icon, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconBut(block, type | SHO, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconButBitS(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconButBit(block, type|SHO, bit, retval, icon, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconButBit(block, type | SHO, bit, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconButC(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconBut(block, type|CHA, retval, icon, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconBut(block, type | CHA, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconButBit(block, type|CHA, bit, retval, icon, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconButBit(block, type | CHA, bit, retval, icon, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip)
{
uiBut *but;
- but= ui_def_but_rna_propname(block, type, retval, "", x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip);
+ but = ui_def_but_rna_propname(block, type, retval, "", x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip);
ui_check_but_and_iconize(but, icon);
return but;
}
uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip)
{
uiBut *but;
- but= ui_def_but_rna(block, type, retval, "", x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip);
+ but = ui_def_but_rna(block, type, retval, "", x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip);
ui_check_but_and_iconize(but, icon);
return but;
}
@@ -3144,7 +3144,7 @@ uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1
uiBut *uiDefIconButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip)
{
uiBut *but;
- but= ui_def_but_operator_ptr(block, type, ot, opcontext, "", x1, y1, x2, y2, tip);
+ but = ui_def_but_operator_ptr(block, type, ot, opcontext, "", x1, y1, x2, y2, tip);
ui_check_but_and_iconize(but, icon);
return but;
}
@@ -3157,76 +3157,76 @@ uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext
/* Button containing both string label and icon */
uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip)
{
- uiBut *but= ui_def_but(block, type, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
+ uiBut *but = ui_def_but(block, type, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
ui_check_but_and_iconize(but, icon);
- but->flag|= UI_ICON_LEFT;
+ but->flag |= UI_ICON_LEFT;
return but;
}
static uiBut *uiDefIconTextButBit(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip)
{
- int bitIdx= findBitIndex(bit);
- if (bitIdx==-1) {
+ int bitIdx = findBitIndex(bit);
+ if (bitIdx == -1) {
return NULL;
}
else {
- return uiDefIconTextBut(block, type|BIT|bitIdx, retval, icon, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
+ return uiDefIconTextBut(block, type | BIT | bitIdx, retval, icon, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
}
}
uiBut *uiDefIconTextButF(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconTextBut(block, type|FLO, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconTextBut(block, type | FLO, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconTextButBitF(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, float *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconTextButBit(block, type|FLO, bit, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconTextButBit(block, type | FLO, bit, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconTextButI(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconTextBut(block, type|INT, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconTextBut(block, type | INT, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconTextButBitI(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, int *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconTextButBit(block, type|INT, bit, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconTextButBit(block, type | INT, bit, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconTextButS(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconTextBut(block, type|SHO, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconTextBut(block, type | SHO, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconTextButBitS(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, short *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconTextButBit(block, type|SHO, bit, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconTextButBit(block, type | SHO, bit, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconTextButC(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconTextBut(block, type|CHA, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconTextBut(block, type | CHA, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, char *poin, float min, float max, float a1, float a2, const char *tip)
{
- return uiDefIconTextButBit(block, type|CHA, bit, retval, icon, str, x1, y1, x2, y2, (void*) poin, min, max, a1, a2, tip);
+ return uiDefIconTextButBit(block, type | CHA, bit, retval, icon, str, x1, y1, x2, y2, (void *) poin, min, max, a1, a2, tip);
}
uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip)
{
uiBut *but;
- but= ui_def_but_rna_propname(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip);
+ but = ui_def_but_rna_propname(block, type, retval, str, x1, y1, x2, y2, ptr, propname, index, min, max, a1, a2, tip);
ui_check_but_and_iconize(but, icon);
- but->flag|= UI_ICON_LEFT;
+ but->flag |= UI_ICON_LEFT;
return but;
}
uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip)
{
uiBut *but;
- but= ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip);
+ but = ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip);
ui_check_but_and_iconize(but, icon);
- but->flag|= UI_ICON_LEFT;
+ but->flag |= UI_ICON_LEFT;
return but;
}
uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip)
{
uiBut *but;
- but= ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip);
+ but = ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip);
ui_check_but_and_iconize(but, icon);
- but->flag|= UI_ICON_LEFT;
+ but->flag |= UI_ICON_LEFT;
return but;
}
uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip)
@@ -3241,13 +3241,13 @@ void uiSetButLink(uiBut *but, void **poin, void ***ppoin, short *tot, int from,
{
uiLink *link;
- link= but->link= MEM_callocN(sizeof(uiLink), "new uilink");
+ link = but->link = MEM_callocN(sizeof(uiLink), "new uilink");
- link->poin= poin;
- link->ppoin= ppoin;
- link->totlink= tot;
- link->fromcode= from;
- link->tocode= to;
+ link->poin = poin;
+ link->ppoin = ppoin;
+ link->totlink = tot;
+ link->fromcode = from;
+ link->tocode = to;
}
/* cruft to make uiBlock and uiBut private */
@@ -3255,18 +3255,18 @@ void uiSetButLink(uiBut *but, void **poin, void ***ppoin, short *tot, int from,
int uiBlocksGetYMin(ListBase *lb)
{
uiBlock *block;
- int min= 0;
+ int min = 0;
- for (block= lb->first; block; block= block->next)
- if (block==lb->first || block->miny<min)
- min= block->miny;
+ for (block = lb->first; block; block = block->next)
+ if (block == lb->first || block->miny < min)
+ min = block->miny;
return min;
}
void uiBlockSetDirection(uiBlock *block, int direction)
{
- block->direction= direction;
+ block->direction = direction;
}
/* this call escapes if there's alignment flags */
@@ -3274,62 +3274,62 @@ void uiBlockFlipOrder(uiBlock *block)
{
ListBase lb;
uiBut *but, *next;
- float centy, miny=10000, maxy= -10000;
+ float centy, miny = 10000, maxy = -10000;
if (U.uiflag & USER_MENUFIXEDORDER)
return;
else if (block->flag & UI_BLOCK_NO_FLIP)
return;
- for (but= block->buttons.first; but; but= but->next) {
+ for (but = block->buttons.first; but; but = but->next) {
if (but->flag & UI_BUT_ALIGN) return;
- if (but->y1 < miny) miny= but->y1;
- if (but->y2 > maxy) maxy= but->y2;
+ if (but->y1 < miny) miny = but->y1;
+ if (but->y2 > maxy) maxy = but->y2;
}
/* mirror trick */
- centy= (miny+maxy)/2.0f;
- for (but= block->buttons.first; but; but= but->next) {
- but->y1 = centy-(but->y1-centy);
- but->y2 = centy-(but->y2-centy);
+ centy = (miny + maxy) / 2.0f;
+ for (but = block->buttons.first; but; but = but->next) {
+ but->y1 = centy - (but->y1 - centy);
+ but->y2 = centy - (but->y2 - centy);
SWAP(float, but->y1, but->y2);
}
/* also flip order in block itself, for example for arrowkey */
- lb.first= lb.last= NULL;
- but= block->buttons.first;
+ lb.first = lb.last = NULL;
+ but = block->buttons.first;
while (but) {
- next= but->next;
+ next = but->next;
BLI_remlink(&block->buttons, but);
BLI_addtail(&lb, but);
- but= next;
+ but = next;
}
- block->buttons= lb;
+ block->buttons = lb;
}
void uiBlockSetFlag(uiBlock *block, int flag)
{
- block->flag|= flag;
+ block->flag |= flag;
}
void uiBlockClearFlag(uiBlock *block, int flag)
{
- block->flag&= ~flag;
+ block->flag &= ~flag;
}
void uiBlockSetXOfs(uiBlock *block, int xofs)
{
- block->xofs= xofs;
+ block->xofs = xofs;
}
void uiButSetFlag(uiBut *but, int flag)
{
- but->flag|= flag;
+ but->flag |= flag;
}
void uiButClearFlag(uiBut *but, int flag)
{
- but->flag&= ~flag;
+ but->flag &= ~flag;
}
int uiButGetRetVal(uiBut *but)
@@ -3339,47 +3339,47 @@ int uiButGetRetVal(uiBut *but)
void uiButSetDragID(uiBut *but, ID *id)
{
- but->dragtype= WM_DRAG_ID;
- but->dragpoin= (void *)id;
+ but->dragtype = WM_DRAG_ID;
+ but->dragpoin = (void *)id;
}
void uiButSetDragRNA(uiBut *but, PointerRNA *ptr)
{
- but->dragtype= WM_DRAG_RNA;
- but->dragpoin= (void *)ptr;
+ but->dragtype = WM_DRAG_RNA;
+ but->dragpoin = (void *)ptr;
}
void uiButSetDragPath(uiBut *but, const char *path)
{
- but->dragtype= WM_DRAG_PATH;
- but->dragpoin= (void *)path;
+ but->dragtype = WM_DRAG_PATH;
+ but->dragpoin = (void *)path;
}
void uiButSetDragName(uiBut *but, const char *name)
{
- but->dragtype= WM_DRAG_NAME;
- but->dragpoin= (void *)name;
+ but->dragtype = WM_DRAG_NAME;
+ but->dragpoin = (void *)name;
}
/* value from button itself */
void uiButSetDragValue(uiBut *but)
{
- but->dragtype= WM_DRAG_VALUE;
+ but->dragtype = WM_DRAG_VALUE;
}
void uiButSetDragImage(uiBut *but, const char *path, int icon, struct ImBuf *imb, float scale)
{
- but->dragtype= WM_DRAG_PATH;
- but->icon= icon; /* no flag UI_HAS_ICON, so icon doesnt draw in button */
- but->dragpoin= (void *)path;
- but->imb= imb;
- but->imb_scale= scale;
+ but->dragtype = WM_DRAG_PATH;
+ but->icon = icon; /* no flag UI_HAS_ICON, so icon doesnt draw in button */
+ but->dragpoin = (void *)path;
+ but->imb = imb;
+ but->imb_scale = scale;
}
PointerRNA *uiButGetOperatorPtrRNA(uiBut *but)
{
if (but->optype && !but->opptr) {
- but->opptr= MEM_callocN(sizeof(PointerRNA), "uiButOpPtr");
+ but->opptr = MEM_callocN(sizeof(PointerRNA), "uiButOpPtr");
WM_operator_properties_create_ptr(but->opptr, but->optype);
}
@@ -3388,7 +3388,7 @@ PointerRNA *uiButGetOperatorPtrRNA(uiBut *but)
void uiButSetUnitType(uiBut *but, const int unit_type)
{
- but->unit_type= (unsigned char)(unit_type>>16);
+ but->unit_type = (unsigned char)(unit_type >> 16);
}
int uiButGetUnitType(uiBut *but)
@@ -3409,21 +3409,21 @@ int uiButGetUnitType(uiBut *but)
void uiBlockSetHandleFunc(uiBlock *block, uiBlockHandleFunc func, void *arg)
{
- block->handle_func= func;
- block->handle_func_arg= arg;
+ block->handle_func = func;
+ block->handle_func_arg = arg;
}
void uiBlockSetButmFunc(uiBlock *block, uiMenuHandleFunc func, void *arg)
{
- block->butm_func= func;
- block->butm_func_arg= arg;
+ block->butm_func = func;
+ block->butm_func_arg = arg;
}
void uiBlockSetFunc(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2)
{
- block->func= func;
- block->func_arg1= arg1;
- block->func_arg2= arg2;
+ block->func = func;
+ block->func_arg1 = arg1;
+ block->func_arg2 = arg2;
}
void uiBlockSetNFunc(uiBlock *block, uiButHandleFunc func, void *argN, void *arg2)
@@ -3432,29 +3432,29 @@ void uiBlockSetNFunc(uiBlock *block, uiButHandleFunc func, void *argN, void *arg
MEM_freeN(block->func_argN);
}
- block->funcN= func;
- block->func_argN= argN;
- block->func_arg2= arg2;
+ block->funcN = func;
+ block->func_argN = argN;
+ block->func_arg2 = arg2;
}
void uiButSetRenameFunc(uiBut *but, uiButHandleRenameFunc func, void *arg1)
{
- but->rename_func= func;
- but->rename_arg1= arg1;
+ but->rename_func = func;
+ but->rename_arg1 = arg1;
}
void uiBlockSetDrawExtraFunc(uiBlock *block, void (*func)(const bContext *C, void *idv, void *arg1, void *arg2, rcti *rect), void *arg1, void *arg2)
{
- block->drawextra= func;
- block->drawextra_arg1= arg1;
- block->drawextra_arg2= arg2;
+ block->drawextra = func;
+ block->drawextra_arg1 = arg1;
+ block->drawextra_arg2 = arg2;
}
void uiButSetFunc(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2)
{
- but->func= func;
- but->func_arg1= arg1;
- but->func_arg2= arg2;
+ but->func = func;
+ but->func_arg1 = arg1;
+ but->func_arg2 = arg2;
}
void uiButSetNFunc(uiBut *but, uiButHandleNFunc funcN, void *argN, void *arg2)
@@ -3463,22 +3463,22 @@ void uiButSetNFunc(uiBut *but, uiButHandleNFunc funcN, void *argN, void *arg2)
MEM_freeN(but->func_argN);
}
- but->funcN= funcN;
- but->func_argN= argN;
- but->func_arg2= arg2;
+ but->funcN = funcN;
+ but->func_argN = argN;
+ but->func_arg2 = arg2;
}
void uiButSetCompleteFunc(uiBut *but, uiButCompleteFunc func, void *arg)
{
- but->autocomplete_func= func;
- but->autofunc_arg= arg;
+ but->autocomplete_func = func;
+ but->autofunc_arg = arg;
}
uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, const char *str, int x1, int y1, short x2, short y2, void *idpp, const char *tip)
{
- uiBut *but= ui_def_but(block, IDPOIN, retval, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip);
- but->idpoin_func= func;
- but->idpoin_idpp= (ID**) idpp;
+ uiBut *but = ui_def_but(block, IDPOIN, retval, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip);
+ but->idpoin_func = func;
+ but->idpoin_idpp = (ID **) idpp;
ui_check_but(but);
if (blocktype)
@@ -3489,20 +3489,20 @@ uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int
uiBut *uiDefBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip)
{
- uiBut *but= ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
- but->block_create_func= func;
+ uiBut *but = ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
+ but->block_create_func = func;
ui_check_but(but);
return but;
}
uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const char *str, int x1, int y1, short x2, short y2, const char *tip)
{
- uiBut *but= ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip);
- but->block_create_func= func;
+ uiBut *but = ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip);
+ but->block_create_func = func;
if (but->func_argN) {
MEM_freeN(but->func_argN);
}
- but->func_argN= argN;
+ but->func_argN = argN;
ui_check_but(but);
return but;
}
@@ -3510,31 +3510,31 @@ uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const
uiBut *uiDefPulldownBut(uiBlock *block, uiBlockCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip)
{
- uiBut *but= ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
- but->block_create_func= func;
+ uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
+ but->block_create_func = func;
ui_check_but(but);
return but;
}
uiBut *uiDefMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, const char *str, int x1, int y1, short x2, short y2, const char *tip)
{
- uiBut *but= ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
- but->menu_create_func= func;
+ uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
+ but->menu_create_func = func;
ui_check_but(but);
return but;
}
uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip)
{
- uiBut *but= ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
+ uiBut *but = ui_def_but(block, PULLDOWN, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
- but->icon= (BIFIconID) icon;
- but->flag|= UI_HAS_ICON;
+ but->icon = (BIFIconID) icon;
+ but->flag |= UI_HAS_ICON;
- but->flag|= UI_ICON_LEFT;
- but->flag|= UI_ICON_SUBMENU;
+ but->flag |= UI_ICON_LEFT;
+ but->flag |= UI_ICON_SUBMENU;
- but->menu_create_func= func;
+ but->menu_create_func = func;
ui_check_but(but);
return but;
@@ -3542,13 +3542,13 @@ uiBut *uiDefIconTextMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, in
uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int icon, int x1, int y1, short x2, short y2, const char *tip)
{
- uiBut *but= ui_def_but(block, PULLDOWN, 0, "", x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
+ uiBut *but = ui_def_but(block, PULLDOWN, 0, "", x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
- but->icon= (BIFIconID) icon;
+ but->icon = (BIFIconID) icon;
but->flag |= UI_HAS_ICON;
- but->flag &=~ UI_ICON_LEFT;
+ but->flag &= ~UI_ICON_LEFT;
- but->menu_create_func= func;
+ but->menu_create_func = func;
ui_check_but(but);
return but;
@@ -3557,17 +3557,17 @@ uiBut *uiDefIconMenuBut(uiBlock *block, uiMenuCreateFunc func, void *arg, int ic
/* Block button containing both string label and icon */
uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip)
{
- uiBut *but= ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
+ uiBut *but = ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
/* XXX temp, old menu calls pass on icon arrow, which is now UI_ICON_SUBMENU flag */
- if (icon!=ICON_RIGHTARROW_THIN) {
- but->icon= (BIFIconID) icon;
- but->flag|= UI_ICON_LEFT;
+ if (icon != ICON_RIGHTARROW_THIN) {
+ but->icon = (BIFIconID) icon;
+ but->flag |= UI_ICON_LEFT;
}
- but->flag|= UI_HAS_ICON;
- but->flag|= UI_ICON_SUBMENU;
+ but->flag |= UI_HAS_ICON;
+ but->flag |= UI_ICON_SUBMENU;
- but->block_create_func= func;
+ but->block_create_func = func;
ui_check_but(but);
return but;
@@ -3576,14 +3576,14 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg,
/* Block button containing icon */
uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, int x1, int y1, short x2, short y2, const char *tip)
{
- uiBut *but= ui_def_but(block, BLOCK, retval, "", x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
+ uiBut *but = ui_def_but(block, BLOCK, retval, "", x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip);
- but->icon= (BIFIconID) icon;
- but->flag|= UI_HAS_ICON;
+ but->icon = (BIFIconID) icon;
+ but->flag |= UI_HAS_ICON;
- but->flag|= UI_ICON_LEFT;
+ but->flag |= UI_ICON_LEFT;
- but->block_create_func= func;
+ but->block_create_func = func;
ui_check_but(but);
return but;
@@ -3591,7 +3591,7 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int
uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *spoin, const char *tip)
{
- uiBut *but= ui_def_but(block, KEYEVT|SHO, retval, str, x1, y1, x2, y2, spoin, 0.0, 0.0, 0.0, 0.0, tip);
+ uiBut *but = ui_def_but(block, KEYEVT | SHO, retval, str, x1, y1, x2, y2, spoin, 0.0, 0.0, 0.0, 0.0, tip);
ui_check_but(but);
return but;
}
@@ -3600,8 +3600,8 @@ uiBut *uiDefKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int
/* modkeypoin will be set to KM_SHIFT, KM_ALT, KM_CTRL, KM_OSKEY bits */
uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x1, int y1, short x2, short y2, short *keypoin, short *modkeypoin, const char *tip)
{
- uiBut *but= ui_def_but(block, HOTKEYEVT|SHO, retval, str, x1, y1, x2, y2, keypoin, 0.0, 0.0, 0.0, 0.0, tip);
- but->modifier_key= *modkeypoin;
+ uiBut *but = ui_def_but(block, HOTKEYEVT | SHO, retval, str, x1, y1, x2, y2, keypoin, 0.0, 0.0, 0.0, 0.0, tip);
+ but->modifier_key = *modkeypoin;
ui_check_but(but);
return but;
}
@@ -3611,12 +3611,12 @@ uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x1, i
/* here a1 and a2, if set, control thumbnail preview rows/cols */
uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x1, int y1, short x2, short y2, float a1, float a2, const char *tip)
{
- uiBut *but= ui_def_but(block, SEARCH_MENU, retval, "", x1, y1, x2, y2, arg, 0.0, maxlen, a1, a2, tip);
+ uiBut *but = ui_def_but(block, SEARCH_MENU, retval, "", x1, y1, x2, y2, arg, 0.0, maxlen, a1, a2, tip);
- but->icon= (BIFIconID) icon;
- but->flag|= UI_HAS_ICON;
+ but->icon = (BIFIconID) icon;
+ but->flag |= UI_HAS_ICON;
- but->flag|= UI_ICON_LEFT|UI_TEXT_LEFT;
+ but->flag |= UI_ICON_LEFT | UI_TEXT_LEFT;
ui_check_but(but);
@@ -3628,13 +3628,13 @@ uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxle
/* if active set, button opens with this item visible and selected */
void uiButSetSearchFunc(uiBut *but, uiButSearchFunc sfunc, void *arg, uiButHandleFunc bfunc, void *active)
{
- but->search_func= sfunc;
- but->search_arg= arg;
+ but->search_func = sfunc;
+ but->search_arg = arg;
uiButSetFunc(but, bfunc, arg, active);
/* search buttons show red-alert if item doesn't exist, not for menus */
- if (0==(but->block->flag & UI_BLOCK_LOOP)) {
+ if (0 == (but->block->flag & UI_BLOCK_LOOP)) {
/* skip empty buttons, not all buttons need input, we only show invalid */
if (but->drawstr[0])
ui_but_search_test(but);
@@ -3648,11 +3648,11 @@ void uiButSetFocusOnEnter(wmWindow *win, uiBut *but)
{
wmEvent event;
- event= *(win->eventstate);
- event.type= EVT_BUT_OPEN;
- event.val= KM_PRESS;
- event.customdata= but;
- event.customdatafree= FALSE;
+ event = *(win->eventstate);
+ event.type = EVT_BUT_OPEN;
+ event.val = KM_PRESS;
+ event.customdata = but;
+ event.customdatafree = FALSE;
wm_event_add(win, &event);
}
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index 9b48e956468..955d564e111 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -65,9 +65,9 @@ void ui_but_anim_flag(uiBut *but, float cfra)
FCurve *fcu;
int driven;
- but->flag &= ~(UI_BUT_ANIMATED|UI_BUT_ANIMATED_KEY|UI_BUT_DRIVEN);
+ but->flag &= ~(UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN);
- fcu= ui_but_get_fcurve(but, NULL, &driven);
+ fcu = ui_but_get_fcurve(but, NULL, &driven);
if (fcu) {
if (!driven) {
@@ -88,10 +88,10 @@ int ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
ChannelDriver *driver;
int driven;
- fcu= ui_but_get_fcurve(but, NULL, &driven);
+ fcu = ui_but_get_fcurve(but, NULL, &driven);
if (fcu && driven) {
- driver= fcu->driver;
+ driver = fcu->driver;
if (driver && driver->type == DRIVER_TYPE_PYTHON) {
BLI_strncpy(str, driver->expression, maxlen);
@@ -108,15 +108,15 @@ int ui_but_anim_expression_set(uiBut *but, const char *str)
ChannelDriver *driver;
int driven;
- fcu= ui_but_get_fcurve(but, NULL, &driven);
+ fcu = ui_but_get_fcurve(but, NULL, &driven);
if (fcu && driven) {
- driver= fcu->driver;
+ driver = fcu->driver;
if (driver && driver->type == DRIVER_TYPE_PYTHON) {
BLI_strncpy_utf8(driver->expression, str, sizeof(driver->expression));
driver->flag |= DRIVER_FLAG_RECOMPILE;
- WM_event_add_notifier(but->block->evil_C, NC_ANIMATION|ND_KEYFRAME, NULL);
+ WM_event_add_notifier(but->block->evil_C, NC_ANIMATION | ND_KEYFRAME, NULL);
return 1;
}
}
@@ -131,7 +131,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str)
ID *id;
FCurve *fcu;
char *path;
- short ok=0;
+ short ok = 0;
/* button must have RNA-pointer to a numeric-capable property */
if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) {
@@ -143,7 +143,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str)
/* make sure we have animdata for this */
// FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them
id = (ID *)but->rnapoin.id.data;
- if ((id == NULL) || (GS(id->name)==ID_MA) || (GS(id->name)==ID_TE)) {
+ if ((id == NULL) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) {
if (G.f & G_DEBUG)
printf("ERROR: create expression failed - invalid id-datablock for adding drivers (%p)\n", id);
return 0;
@@ -155,7 +155,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str)
/* create driver */
fcu = verify_driver_fcurve(id, path, but->rnaindex, 1);
if (fcu) {
- ChannelDriver *driver= fcu->driver;
+ ChannelDriver *driver = fcu->driver;
if (driver) {
/* set type of driver */
@@ -167,7 +167,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str)
/* updates */
driver->flag |= DRIVER_FLAG_RECOMPILE;
- WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME, NULL);
}
}
@@ -183,10 +183,10 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
FCurve *fcu;
int driven;
- fcu= ui_but_get_fcurve(but, &action, &driven);
+ fcu = ui_but_get_fcurve(but, &action, &driven);
if (fcu && !driven) {
- id= but->rnapoin.id.data;
+ id = but->rnapoin.id.data;
// TODO: this should probably respect the keyingset only option for anim
if (autokeyframe_cfra_can_key(scene, id)) {
@@ -194,8 +194,8 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
short flag = ANIM_get_keyframing_flags(scene, 1);
fcu->flag &= ~FCURVE_SELECTED;
- insert_keyframe(reports, id, action, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
- WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
+ insert_keyframe(reports, id, action, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
+ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
}
}
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index a2f253cecaf..91d3c890df3 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -58,16 +58,16 @@
/* own include */
#include "interface_intern.h"
-#define UI_DISABLED_ALPHA_OFFS -160
+#define UI_DISABLED_ALPHA_OFFS -160
-static int roundboxtype= UI_CNR_ALL;
+static int roundboxtype = UI_CNR_ALL;
void uiSetRoundBox(int type)
{
/* Not sure the roundbox function is the best place to change this
* if this is undone, its not that big a deal, only makes curves edges
* square for the */
- roundboxtype= type;
+ roundboxtype = type;
}
@@ -78,54 +78,54 @@ int uiGetRoundBox(void)
void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float rad)
{
- float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
- {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+ float vec[7][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
+ {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
int a;
/* mult */
- for (a=0; a<7; a++) {
- vec[a][0]*= rad; vec[a][1]*= rad;
+ for (a = 0; a < 7; a++) {
+ vec[a][0] *= rad; vec[a][1] *= rad;
}
glBegin(mode);
/* start with corner right-bottom */
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
- glVertex2f(maxx-rad, miny);
- for (a=0; a<7; a++) {
- glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]);
+ glVertex2f(maxx - rad, miny);
+ for (a = 0; a < 7; a++) {
+ glVertex2f(maxx - rad + vec[a][0], miny + vec[a][1]);
}
- glVertex2f(maxx, miny+rad);
+ glVertex2f(maxx, miny + rad);
}
else glVertex2f(maxx, miny);
/* corner right-top */
if (roundboxtype & UI_CNR_TOP_RIGHT) {
- glVertex2f(maxx, maxy-rad);
- for (a=0; a<7; a++) {
- glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]);
+ glVertex2f(maxx, maxy - rad);
+ for (a = 0; a < 7; a++) {
+ glVertex2f(maxx - vec[a][1], maxy - rad + vec[a][0]);
}
- glVertex2f(maxx-rad, maxy);
+ glVertex2f(maxx - rad, maxy);
}
else glVertex2f(maxx, maxy);
/* corner left-top */
if (roundboxtype & UI_CNR_TOP_LEFT) {
- glVertex2f(minx+rad, maxy);
- for (a=0; a<7; a++) {
- glVertex2f(minx+rad-vec[a][0], maxy-vec[a][1]);
+ glVertex2f(minx + rad, maxy);
+ for (a = 0; a < 7; a++) {
+ glVertex2f(minx + rad - vec[a][0], maxy - vec[a][1]);
}
- glVertex2f(minx, maxy-rad);
+ glVertex2f(minx, maxy - rad);
}
else glVertex2f(minx, maxy);
/* corner left-bottom */
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
- glVertex2f(minx, miny+rad);
- for (a=0; a<7; a++) {
- glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]);
+ glVertex2f(minx, miny + rad);
+ for (a = 0; a < 7; a++) {
+ glVertex2f(minx + vec[a][1], miny + rad - vec[a][0]);
}
- glVertex2f(minx+rad, miny);
+ glVertex2f(minx + rad, miny);
}
else glVertex2f(minx, miny);
@@ -136,9 +136,9 @@ static void round_box_shade_col(const float col1[3], float const col2[3], const
{
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]);
+ 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]);
glColor3fv(col);
}
@@ -146,27 +146,27 @@ static void round_box_shade_col(const float col1[3], float const col2[3], const
/* view2d scrollers use it */
void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown)
{
- float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
- {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
- const float div= maxy - miny;
- const float idiv= 1.0f / div;
+ float vec[7][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
+ {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+ const float div = maxy - miny;
+ const float idiv = 1.0f / div;
float coltop[3], coldown[3], color[4];
int a;
/* mult */
- for (a=0; a<7; a++) {
- vec[a][0]*= rad; vec[a][1]*= rad;
+ for (a = 0; a < 7; a++) {
+ vec[a][0] *= rad; vec[a][1] *= rad;
}
/* get current color, needs to be outside of glBegin/End */
glGetFloatv(GL_CURRENT_COLOR, color);
/* 'shade' defines strength of shading */
- coltop[0]= color[0]+shadetop; if (coltop[0]>1.0f) coltop[0]= 1.0f;
- coltop[1]= color[1]+shadetop; if (coltop[1]>1.0f) coltop[1]= 1.0f;
- coltop[2]= color[2]+shadetop; if (coltop[2]>1.0f) coltop[2]= 1.0f;
- coldown[0]= color[0]+shadedown; if (coldown[0]<0.0f) coldown[0]= 0.0f;
- coldown[1]= color[1]+shadedown; if (coldown[1]<0.0f) coldown[1]= 0.0f;
- coldown[2]= color[2]+shadedown; if (coldown[2]<0.0f) coldown[2]= 0.0f;
+ coltop[0] = color[0] + shadetop; if (coltop[0] > 1.0f) coltop[0] = 1.0f;
+ coltop[1] = color[1] + shadetop; if (coltop[1] > 1.0f) coltop[1] = 1.0f;
+ coltop[2] = color[2] + shadetop; if (coltop[2] > 1.0f) coltop[2] = 1.0f;
+ coldown[0] = color[0] + shadedown; if (coldown[0] < 0.0f) coldown[0] = 0.0f;
+ coldown[1] = color[1] + shadedown; if (coldown[1] < 0.0f) coldown[1] = 0.0f;
+ coldown[2] = color[2] + shadedown; if (coldown[2] < 0.0f) coldown[2] = 0.0f;
glShadeModel(GL_SMOOTH);
glBegin(mode);
@@ -175,15 +175,15 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
round_box_shade_col(coltop, coldown, 0.0);
- glVertex2f(maxx-rad, miny);
+ glVertex2f(maxx - rad, miny);
- for (a=0; a<7; a++) {
- round_box_shade_col(coltop, coldown, vec[a][1]*idiv);
- glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]);
+ for (a = 0; a < 7; a++) {
+ round_box_shade_col(coltop, coldown, vec[a][1] * idiv);
+ glVertex2f(maxx - rad + vec[a][0], miny + vec[a][1]);
}
- round_box_shade_col(coltop, coldown, rad*idiv);
- glVertex2f(maxx, miny+rad);
+ round_box_shade_col(coltop, coldown, rad * idiv);
+ glVertex2f(maxx, miny + rad);
}
else {
round_box_shade_col(coltop, coldown, 0.0);
@@ -193,15 +193,15 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl
/* corner right-top */
if (roundboxtype & UI_CNR_TOP_RIGHT) {
- round_box_shade_col(coltop, coldown, (div-rad)*idiv);
- glVertex2f(maxx, maxy-rad);
+ round_box_shade_col(coltop, coldown, (div - rad) * idiv);
+ glVertex2f(maxx, maxy - rad);
- for (a=0; a<7; a++) {
- round_box_shade_col(coltop, coldown, (div-rad+vec[a][1])*idiv);
- glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]);
+ for (a = 0; a < 7; a++) {
+ round_box_shade_col(coltop, coldown, (div - rad + vec[a][1]) * idiv);
+ glVertex2f(maxx - vec[a][1], maxy - rad + vec[a][0]);
}
round_box_shade_col(coltop, coldown, 1.0);
- glVertex2f(maxx-rad, maxy);
+ glVertex2f(maxx - rad, maxy);
}
else {
round_box_shade_col(coltop, coldown, 1.0);
@@ -212,15 +212,15 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl
if (roundboxtype & UI_CNR_TOP_LEFT) {
round_box_shade_col(coltop, coldown, 1.0);
- glVertex2f(minx+rad, maxy);
+ glVertex2f(minx + rad, maxy);
- for (a=0; a<7; a++) {
- round_box_shade_col(coltop, coldown, (div-vec[a][1])*idiv);
- glVertex2f(minx+rad-vec[a][0], maxy-vec[a][1]);
+ for (a = 0; a < 7; a++) {
+ round_box_shade_col(coltop, coldown, (div - vec[a][1]) * idiv);
+ glVertex2f(minx + rad - vec[a][0], maxy - vec[a][1]);
}
- round_box_shade_col(coltop, coldown, (div-rad)*idiv);
- glVertex2f(minx, maxy-rad);
+ round_box_shade_col(coltop, coldown, (div - rad) * idiv);
+ glVertex2f(minx, maxy - rad);
}
else {
round_box_shade_col(coltop, coldown, 1.0);
@@ -230,16 +230,16 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl
/* corner left-bottom */
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
- round_box_shade_col(coltop, coldown, rad*idiv);
- glVertex2f(minx, miny+rad);
+ round_box_shade_col(coltop, coldown, rad * idiv);
+ glVertex2f(minx, miny + rad);
- for (a=0; a<7; a++) {
- round_box_shade_col(coltop, coldown, (rad-vec[a][1])*idiv);
- glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]);
+ for (a = 0; a < 7; a++) {
+ round_box_shade_col(coltop, coldown, (rad - vec[a][1]) * idiv);
+ glVertex2f(minx + vec[a][1], miny + rad - vec[a][0]);
}
round_box_shade_col(coltop, coldown, 0.0);
- glVertex2f(minx+rad, miny);
+ glVertex2f(minx + rad, miny);
}
else {
round_box_shade_col(coltop, coldown, 0.0);
@@ -254,27 +254,27 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl
/* view2d scrollers use it */
void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight)
{
- float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
- {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
- const float div= maxx - minx;
- const float idiv= 1.0f / div;
+ float vec[7][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293},
+ {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
+ const float div = maxx - minx;
+ const float idiv = 1.0f / div;
float colLeft[3], colRight[3], color[4];
int a;
/* mult */
- for (a=0; a<7; a++) {
- vec[a][0]*= rad; vec[a][1]*= rad;
+ for (a = 0; a < 7; a++) {
+ vec[a][0] *= rad; vec[a][1] *= rad;
}
/* get current color, needs to be outside of glBegin/End */
glGetFloatv(GL_CURRENT_COLOR, color);
/* 'shade' defines strength of shading */
- colLeft[0]= color[0]+shadeLeft; if (colLeft[0]>1.0f) colLeft[0]= 1.0f;
- colLeft[1]= color[1]+shadeLeft; if (colLeft[1]>1.0f) colLeft[1]= 1.0f;
- colLeft[2]= color[2]+shadeLeft; if (colLeft[2]>1.0f) colLeft[2]= 1.0f;
- colRight[0]= color[0]+shadeRight; if (colRight[0]<0.0f) colRight[0]= 0.0f;
- colRight[1]= color[1]+shadeRight; if (colRight[1]<0.0f) colRight[1]= 0.0f;
- colRight[2]= color[2]+shadeRight; if (colRight[2]<0.0f) colRight[2]= 0.0f;
+ colLeft[0] = color[0] + shadeLeft; if (colLeft[0] > 1.0f) colLeft[0] = 1.0f;
+ colLeft[1] = color[1] + shadeLeft; if (colLeft[1] > 1.0f) colLeft[1] = 1.0f;
+ colLeft[2] = color[2] + shadeLeft; if (colLeft[2] > 1.0f) colLeft[2] = 1.0f;
+ colRight[0] = color[0] + shadeRight; if (colRight[0] < 0.0f) colRight[0] = 0.0f;
+ colRight[1] = color[1] + shadeRight; if (colRight[1] < 0.0f) colRight[1] = 0.0f;
+ colRight[2] = color[2] + shadeRight; if (colRight[2] < 0.0f) colRight[2] = 0.0f;
glShadeModel(GL_SMOOTH);
glBegin(mode);
@@ -282,15 +282,15 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float
/* start with corner right-bottom */
if (roundboxtype & UI_CNR_BOTTOM_RIGHT) {
round_box_shade_col(colLeft, colRight, 0.0);
- glVertex2f(maxx-rad, miny);
+ glVertex2f(maxx - rad, miny);
- for (a=0; a<7; a++) {
- round_box_shade_col(colLeft, colRight, vec[a][0]*idiv);
- glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]);
+ for (a = 0; a < 7; a++) {
+ round_box_shade_col(colLeft, colRight, vec[a][0] * idiv);
+ glVertex2f(maxx - rad + vec[a][0], miny + vec[a][1]);
}
- round_box_shade_col(colLeft, colRight, rad*idiv);
- glVertex2f(maxx, miny+rad);
+ round_box_shade_col(colLeft, colRight, rad * idiv);
+ glVertex2f(maxx, miny + rad);
}
else {
round_box_shade_col(colLeft, colRight, 0.0);
@@ -300,15 +300,15 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float
/* corner right-top */
if (roundboxtype & UI_CNR_TOP_RIGHT) {
round_box_shade_col(colLeft, colRight, 0.0);
- glVertex2f(maxx, maxy-rad);
+ glVertex2f(maxx, maxy - rad);
- for (a=0; a<7; a++) {
+ for (a = 0; a < 7; a++) {
- round_box_shade_col(colLeft, colRight, (div-rad-vec[a][0])*idiv);
- glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]);
+ round_box_shade_col(colLeft, colRight, (div - rad - vec[a][0]) * idiv);
+ glVertex2f(maxx - vec[a][1], maxy - rad + vec[a][0]);
}
- round_box_shade_col(colLeft, colRight, (div-rad)*idiv);
- glVertex2f(maxx-rad, maxy);
+ round_box_shade_col(colLeft, colRight, (div - rad) * idiv);
+ glVertex2f(maxx - rad, maxy);
}
else {
round_box_shade_col(colLeft, colRight, 0.0);
@@ -317,16 +317,16 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float
/* corner left-top */
if (roundboxtype & UI_CNR_TOP_LEFT) {
- round_box_shade_col(colLeft, colRight, (div-rad)*idiv);
- glVertex2f(minx+rad, maxy);
+ round_box_shade_col(colLeft, colRight, (div - rad) * idiv);
+ glVertex2f(minx + rad, maxy);
- for (a=0; a<7; a++) {
- round_box_shade_col(colLeft, colRight, (div-rad+vec[a][0])*idiv);
- glVertex2f(minx+rad-vec[a][0], maxy-vec[a][1]);
+ for (a = 0; a < 7; a++) {
+ round_box_shade_col(colLeft, colRight, (div - rad + vec[a][0]) * idiv);
+ glVertex2f(minx + rad - vec[a][0], maxy - vec[a][1]);
}
round_box_shade_col(colLeft, colRight, 1.0);
- glVertex2f(minx, maxy-rad);
+ glVertex2f(minx, maxy - rad);
}
else {
round_box_shade_col(colLeft, colRight, 1.0);
@@ -336,15 +336,15 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float
/* corner left-bottom */
if (roundboxtype & UI_CNR_BOTTOM_LEFT) {
round_box_shade_col(colLeft, colRight, 1.0);
- glVertex2f(minx, miny+rad);
+ glVertex2f(minx, miny + rad);
- for (a=0; a<7; a++) {
- round_box_shade_col(colLeft, colRight, (vec[a][0])*idiv);
- glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]);
+ for (a = 0; a < 7; a++) {
+ round_box_shade_col(colLeft, colRight, (vec[a][0]) * idiv);
+ glVertex2f(minx + vec[a][1], miny + rad - vec[a][0]);
}
round_box_shade_col(colLeft, colRight, 1.0);
- glVertex2f(minx+rad, miny);
+ glVertex2f(minx + rad, miny);
}
else {
round_box_shade_col(colLeft, colRight, 1.0);
@@ -362,19 +362,19 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad)
if (roundboxtype & UI_RB_ALPHA) {
glGetFloatv(GL_CURRENT_COLOR, color);
- color[3]= 0.5;
+ color[3] = 0.5;
glColor4fv(color);
- glEnable( GL_BLEND );
+ glEnable(GL_BLEND);
}
/* set antialias line */
- glEnable( GL_LINE_SMOOTH );
- glEnable( GL_BLEND );
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_BLEND);
uiDrawBox(GL_LINE_LOOP, minx, miny, maxx, maxy, rad);
- glDisable( GL_BLEND );
- glDisable( GL_LINE_SMOOTH );
+ glDisable(GL_BLEND);
+ glDisable(GL_LINE_SMOOTH);
}
/* (old, used in outliner) plain antialiased filled box */
@@ -384,9 +384,9 @@ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad)
if (roundboxtype & UI_RB_ALPHA) {
glGetFloatv(GL_CURRENT_COLOR, color);
- color[3]= 0.5;
+ color[3] = 0.5;
glColor4fv(color);
- glEnable( GL_BLEND );
+ glEnable(GL_BLEND);
}
ui_draw_anti_roundbox(GL_POLYGON, minx, miny, maxx, maxy, rad);
@@ -401,16 +401,16 @@ void uiEmboss(float x1, float y1, float x2, float y2, int sel)
{
/* below */
- if (sel) glColor3ub(200,200,200);
- else glColor3ub(50,50,50);
+ if (sel) glColor3ub(200, 200, 200);
+ else glColor3ub(50, 50, 50);
fdrawline(x1, y1, x2, y1);
/* right */
fdrawline(x2, y1, x2, y2);
/* top */
- if (sel) glColor3ub(50,50,50);
- else glColor3ub(200,200,200);
+ if (sel) glColor3ub(50, 50, 50);
+ else glColor3ub(200, 200, 200);
fdrawline(x1, y2, x2, y2);
/* left */
@@ -426,7 +426,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w
(void)rect;
(void)but;
#else
- ImBuf *ibuf= (ImBuf *)but->poin;
+ ImBuf *ibuf = (ImBuf *)but->poin;
//GLint scissor[4];
//int w, h;
@@ -545,14 +545,14 @@ static void ui_draw_but_CHARTAB(uiBut *but)
// Draw one grid cell
glBegin(GL_LINE_LOOP);
- glVertex2f(sx, sy);
- glVertex2f(ex, sy);
- glVertex2f(ex, ey);
- glVertex2f(sx, ey);
+ glVertex2f(sx, sy);
+ glVertex2f(ex, sy);
+ glVertex2f(ex, ey);
+ glVertex2f(sx, ey);
glEnd();
// Draw character inside the cell
- memset(wstr, 0, sizeof(wchar_t)*2);
+ memset(wstr, 0, sizeof(wchar_t) * 2);
memset(ustr, 0, 16);
// Set the font to be either unicode or FO_BUILTIN_NAME
@@ -580,25 +580,25 @@ static void ui_draw_but_CHARTAB(uiBut *but)
// Calculate the position
wid = FTF_GetStringWidth((char *) ustr, FTF_USE_GETTEXT | FTF_INPUT_UTF8);
- FTF_GetBoundingBox((char *) ustr, &llx,&lly,&llz,&urx,&ury,&urz, FTF_USE_GETTEXT | FTF_INPUT_UTF8);
- dx = urx-llx;
- dy = ury-lly;
+ FTF_GetBoundingBox((char *) ustr, &llx, &lly, &llz, &urx, &ury, &urz, FTF_USE_GETTEXT | FTF_INPUT_UTF8);
+ dx = urx - llx;
+ dy = ury - lly;
// This isn't fully functional since the but->aspect isn't working like I suspected
- px = sx + ((butw/but->aspect)-dx)/2;
- py = sy + ((buth/but->aspect)-dy)/2;
+ px = sx + ((butw / but->aspect) - dx) / 2;
+ py = sy + ((buth / but->aspect) - dy) / 2;
// Set the position and draw the character
ui_rasterpos_safe(px, py, but->aspect);
FTF_DrawString((char *) ustr, FTF_USE_GETTEXT | FTF_INPUT_UTF8);
}
else {
- ui_rasterpos_safe(sx + butw/2, sy + buth/2, but->aspect);
+ ui_rasterpos_safe(sx + butw / 2, sy + buth / 2, but->aspect);
UI_DrawString(but->font, (char *) ustr, 0);
}
// Calculate the next position and character
- sx += butw; ex +=butw;
+ sx += butw; ex += butw;
cs++;
}
/* Add the y position and reset x position */
@@ -637,23 +637,23 @@ static void draw_scope_end(rctf *rect, GLint *scissor)
/* restore scissortest */
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* scale widget */
- scaler_x1 = rect->xmin + (rect->xmax - rect->xmin)/2 - SCOPE_RESIZE_PAD;
- scaler_x2 = rect->xmin + (rect->xmax - rect->xmin)/2 + SCOPE_RESIZE_PAD;
+ scaler_x1 = rect->xmin + (rect->xmax - rect->xmin) / 2 - SCOPE_RESIZE_PAD;
+ scaler_x2 = rect->xmin + (rect->xmax - rect->xmin) / 2 + SCOPE_RESIZE_PAD;
glColor4f(0.f, 0.f, 0.f, 0.25f);
- fdrawline(scaler_x1, rect->ymin-4, scaler_x2, rect->ymin-4);
- fdrawline(scaler_x1, rect->ymin-7, scaler_x2, rect->ymin-7);
+ fdrawline(scaler_x1, rect->ymin - 4, scaler_x2, rect->ymin - 4);
+ fdrawline(scaler_x1, rect->ymin - 7, scaler_x2, rect->ymin - 7);
glColor4f(1.f, 1.f, 1.f, 0.25f);
- fdrawline(scaler_x1, rect->ymin-5, scaler_x2, rect->ymin-5);
- fdrawline(scaler_x1, rect->ymin-8, scaler_x2, rect->ymin-8);
+ fdrawline(scaler_x1, rect->ymin - 5, scaler_x2, rect->ymin - 5);
+ fdrawline(scaler_x1, rect->ymin - 8, scaler_x2, rect->ymin - 8);
/* outline */
glColor4f(0.f, 0.f, 0.f, 0.5f);
uiSetRoundBox(UI_CNR_ALL);
- uiDrawBox(GL_LINE_LOOP, rect->xmin-1, rect->ymin, rect->xmax+1, rect->ymax+1, 3.0f);
+ uiDrawBox(GL_LINE_LOOP, rect->xmin - 1, rect->ymin, rect->xmax + 1, rect->ymax + 1, 3.0f);
}
static void histogram_draw_one(float r, float g, float b, float alpha, float x, float y, float w, float h, float *data, int res)
@@ -667,10 +667,10 @@ static void histogram_draw_one(float r, float g, float b, float alpha, float x,
glShadeModel(GL_FLAT);
glBegin(GL_QUAD_STRIP);
glVertex2f(x, y);
- glVertex2f(x, y + (data[0]*h));
- for (i=1; i < res; i++) {
- float x2 = x + i * (w/(float)res);
- glVertex2f(x2, y + (data[i]*h));
+ glVertex2f(x, y + (data[0] * h));
+ for (i = 1; i < res; i++) {
+ float x2 = x + i * (w / (float)res);
+ glVertex2f(x2, y + (data[i] * h));
glVertex2f(x2, y);
}
glEnd();
@@ -681,9 +681,9 @@ static void histogram_draw_one(float r, float g, float b, float alpha, float x,
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glBegin(GL_LINE_STRIP);
- for (i=0; i < res; i++) {
- float x2 = x + i * (w/(float)res);
- glVertex2f(x2, y + (data[i]*h));
+ for (i = 0; i < res; i++) {
+ float x2 = x + i * (w / (float)res);
+ glVertex2f(x2, y + (data[i] * h));
}
glEnd();
glDisable(GL_LINE_SMOOTH);
@@ -699,30 +699,30 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol)
//float alpha;
GLint scissor[4];
- rect.xmin = (float)recti->xmin+1;
- rect.xmax = (float)recti->xmax-1;
- rect.ymin = (float)recti->ymin+SCOPE_RESIZE_PAD+2;
- rect.ymax = (float)recti->ymax-1;
+ rect.xmin = (float)recti->xmin + 1;
+ rect.xmax = (float)recti->xmax - 1;
+ rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
+ rect.ymax = (float)recti->ymax - 1;
w = rect.xmax - rect.xmin;
h = (rect.ymax - rect.ymin) * hist->ymax;
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.f, 0.f, 0.f, 0.3f);
uiSetRoundBox(UI_CNR_ALL);
- uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
+ uiDrawBox(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 */
glGetIntegerv(GL_VIEWPORT, scissor);
- glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1));
+ glScissor(ar->winrct.xmin + (rect.xmin - 1), ar->winrct.ymin + (rect.ymin - 1), (rect.xmax + 1) - (rect.xmin - 1), (rect.ymax + 1) - (rect.ymin - 1));
glColor4f(1.f, 1.f, 1.f, 0.08f);
/* draw grid lines here */
- for (i=1; i<4; i++) {
- fdrawline(rect.xmin, rect.ymin+(i/4.f)*h, rect.xmax, rect.ymin+(i/4.f)*h);
- fdrawline(rect.xmin+(i/4.f)*w, rect.ymin, rect.xmin+(i/4.f)*w, rect.ymax);
+ for (i = 1; i < 4; i++) {
+ fdrawline(rect.xmin, rect.ymin + (i / 4.f) * h, rect.xmax, rect.ymin + (i / 4.f) * h);
+ fdrawline(rect.xmin + (i / 4.f) * w, rect.ymin, rect.xmin + (i / 4.f) * w, rect.ymax);
}
if (hist->mode == HISTO_MODE_LUMA)
@@ -747,88 +747,88 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
int i, c;
float w, w3, h, alpha, yofs;
GLint scissor[4];
- float colors[3][3]= MAT3_UNITY;
- float colorsycc[3][3] = {{1,0,1},{1,1,0},{0,1,1}};
+ float colors[3][3] = MAT3_UNITY;
+ float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}};
float colors_alpha[3][3], colorsycc_alpha[3][3]; /* colors pre multiplied by alpha for speed up */
float min, max;
- if (scopes==NULL) return;
-
- rect.xmin = (float)recti->xmin+1;
- rect.xmax = (float)recti->xmax-1;
- rect.ymin = (float)recti->ymin+SCOPE_RESIZE_PAD+2;
- rect.ymax = (float)recti->ymax-1;
+ if (scopes == NULL) return;
- if (scopes->wavefrm_yfac < 0.5f )
- scopes->wavefrm_yfac =0.98f;
- w = rect.xmax - rect.xmin-7;
- h = (rect.ymax - rect.ymin)*scopes->wavefrm_yfac;
- yofs= rect.ymin + (rect.ymax - rect.ymin -h)/2.0f;
- w3=w/3.0f;
+ rect.xmin = (float)recti->xmin + 1;
+ rect.xmax = (float)recti->xmax - 1;
+ rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
+ rect.ymax = (float)recti->ymax - 1;
+
+ if (scopes->wavefrm_yfac < 0.5f)
+ scopes->wavefrm_yfac = 0.98f;
+ w = rect.xmax - rect.xmin - 7;
+ h = (rect.ymax - rect.ymin) * scopes->wavefrm_yfac;
+ yofs = rect.ymin + (rect.ymax - rect.ymin - h) / 2.0f;
+ w3 = w / 3.0f;
/* log scale for alpha */
- alpha = scopes->wavefrm_alpha*scopes->wavefrm_alpha;
+ alpha = scopes->wavefrm_alpha * scopes->wavefrm_alpha;
- for (c=0; c<3; c++) {
- for (i=0; i<3; i++) {
+ for (c = 0; c < 3; c++) {
+ for (i = 0; i < 3; i++) {
colors_alpha[c][i] = colors[c][i] * alpha;
colorsycc_alpha[c][i] = colorsycc[c][i] * alpha;
}
}
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.f, 0.f, 0.f, 0.3f);
uiSetRoundBox(UI_CNR_ALL);
- uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
+ uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f);
/* need scissor test, waveform can draw outside of boundary */
glGetIntegerv(GL_VIEWPORT, scissor);
- glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1));
+ glScissor(ar->winrct.xmin + (rect.xmin - 1), ar->winrct.ymin + (rect.ymin - 1), (rect.xmax + 1) - (rect.xmin - 1), (rect.ymax + 1) - (rect.ymin - 1));
glColor4f(1.f, 1.f, 1.f, 0.08f);
/* draw grid lines here */
- for (i=0; i<6; i++) {
+ for (i = 0; i < 6; i++) {
char str[4];
- BLI_snprintf(str, sizeof(str), "%-3d",i*20);
- str[3]='\0';
- fdrawline(rect.xmin+22, yofs+(i/5.f)*h, rect.xmax+1, yofs+(i/5.f)*h);
- BLF_draw_default(rect.xmin+1, yofs-5+(i/5.f)*h, 0, str, sizeof(str)-1);
+ BLI_snprintf(str, sizeof(str), "%-3d", i * 20);
+ str[3] = '\0';
+ fdrawline(rect.xmin + 22, yofs + (i / 5.f) * h, rect.xmax + 1, yofs + (i / 5.f) * h);
+ BLF_draw_default(rect.xmin + 1, yofs - 5 + (i / 5.f) * h, 0, str, sizeof(str) - 1);
/* in the loop because blf_draw reset it */
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
/* 3 vertical separation */
- if (scopes->wavefrm_mode!= SCOPES_WAVEFRM_LUMA) {
- for (i=1; i<3; i++) {
- fdrawline(rect.xmin+i*w3, rect.ymin, rect.xmin+i*w3, rect.ymax);
+ if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) {
+ for (i = 1; i < 3; i++) {
+ fdrawline(rect.xmin + i * w3, rect.ymin, rect.xmin + i * w3, rect.ymax);
}
}
/* separate min max zone on the right */
- fdrawline(rect.xmin+w, rect.ymin, rect.xmin+w, rect.ymax);
+ fdrawline(rect.xmin + w, rect.ymin, rect.xmin + w, rect.ymax);
/* 16-235-240 level in case of ITU-R BT601/709 */
glColor4f(1.f, 0.4f, 0.f, 0.2f);
if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)) {
- fdrawline(rect.xmin+22, yofs+h*16.0f/255.0f, rect.xmax+1, yofs+h*16.0f/255.0f);
- fdrawline(rect.xmin+22, yofs+h*235.0f/255.0f, rect.xmin+w3, yofs+h*235.0f/255.0f);
- fdrawline(rect.xmin+3*w3, yofs+h*235.0f/255.0f, rect.xmax+1, yofs+h*235.0f/255.0f);
- fdrawline(rect.xmin+w3, yofs+h*240.0f/255.0f, rect.xmax+1, yofs+h*240.0f/255.0f);
+ fdrawline(rect.xmin + 22, yofs + h * 16.0f / 255.0f, rect.xmax + 1, yofs + h * 16.0f / 255.0f);
+ fdrawline(rect.xmin + 22, yofs + h * 235.0f / 255.0f, rect.xmin + w3, yofs + h * 235.0f / 255.0f);
+ fdrawline(rect.xmin + 3 * w3, yofs + h * 235.0f / 255.0f, rect.xmax + 1, yofs + h * 235.0f / 255.0f);
+ fdrawline(rect.xmin + w3, yofs + h * 240.0f / 255.0f, rect.xmax + 1, yofs + h * 240.0f / 255.0f);
}
/* 7.5 IRE black point level for NTSC */
- if (scopes->wavefrm_mode== SCOPES_WAVEFRM_LUMA)
- fdrawline(rect.xmin, yofs+h*0.075f, rect.xmax+1, yofs+h*0.075f);
+ if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA)
+ fdrawline(rect.xmin, yofs + h * 0.075f, rect.xmax + 1, yofs + h * 0.075f);
if (scopes->ok && scopes->waveform_1 != NULL) {
/* LUMA (1 channel) */
- glBlendFunc(GL_ONE,GL_ONE);
+ glBlendFunc(GL_ONE, GL_ONE);
glColor3f(alpha, alpha, alpha);
if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
- glBlendFunc(GL_ONE,GL_ONE);
+ glBlendFunc(GL_ONE, GL_ONE);
glPushMatrix();
glEnableClientState(GL_VERTEX_ARRAY);
@@ -843,18 +843,18 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
/* min max */
glColor3f(.5f, .5f, .5f);
- min= yofs+scopes->minmax[0][0]*h;
- max= yofs+scopes->minmax[0][1]*h;
+ min = yofs + scopes->minmax[0][0] * h;
+ max = yofs + scopes->minmax[0][1] * h;
CLAMP(min, rect.ymin, rect.ymax);
CLAMP(max, rect.ymin, rect.ymax);
- fdrawline(rect.xmax-3,min,rect.xmax-3,max);
+ fdrawline(rect.xmax - 3, min, rect.xmax - 3, max);
}
/* RGB / YCC (3 channels) */
else if (ELEM4(scopes->wavefrm_mode, SCOPES_WAVEFRM_RGB, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709, SCOPES_WAVEFRM_YCC_JPEG)) {
int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB);
- glBlendFunc(GL_ONE,GL_ONE);
+ glBlendFunc(GL_ONE, GL_ONE);
glPushMatrix();
glEnableClientState(GL_VERTEX_ARRAY);
@@ -862,17 +862,17 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
glTranslatef(rect.xmin, yofs, 0.f);
glScalef(w3, h, 0.f);
- glColor3fv((rgb)?colors_alpha[0]:colorsycc_alpha[0]);
+ glColor3fv((rgb) ? colors_alpha[0] : colorsycc_alpha[0]);
glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_1);
glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
glTranslatef(1.f, 0.f, 0.f);
- glColor3fv((rgb)?colors_alpha[1]:colorsycc_alpha[1]);
+ glColor3fv((rgb) ? colors_alpha[1] : colorsycc_alpha[1]);
glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_2);
glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
glTranslatef(1.f, 0.f, 0.f);
- glColor3fv((rgb)?colors_alpha[2]:colorsycc_alpha[2]);
+ glColor3fv((rgb) ? colors_alpha[2] : colorsycc_alpha[2]);
glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_3);
glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
@@ -881,16 +881,16 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
/* min max */
- for (c=0; c<3; c++) {
+ for (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);
+ glColor3f(colors[c][0] * 0.75f, colors[c][1] * 0.75f, colors[c][2] * 0.75f);
else
- glColor3f(colorsycc[c][0]*0.75f, colorsycc[c][1]*0.75f, colorsycc[c][2]*0.75f);
- min= yofs+scopes->minmax[c][0]*h;
- max= yofs+scopes->minmax[c][1]*h;
+ glColor3f(colorsycc[c][0] * 0.75f, colorsycc[c][1] * 0.75f, colorsycc[c][2] * 0.75f);
+ min = yofs + scopes->minmax[c][0] * h;
+ max = yofs + scopes->minmax[c][1] * h;
CLAMP(min, rect.ymin, rect.ymax);
CLAMP(max, rect.ymin, rect.ymax);
- fdrawline(rect.xmin+w+2+c*2,min,rect.xmin+w+2+c*2,max);
+ fdrawline(rect.xmin + w + 2 + c * 2, min, rect.xmin + w + 2 + c * 2, max);
}
}
@@ -902,128 +902,128 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
static float polar_to_x(float center, float diam, float ampli, float angle)
{
- return center + diam * ampli * cosf(angle);
+ return center + diam *ampli *cosf(angle);
}
static float polar_to_y(float center, float diam, float ampli, float angle)
{
- return center + diam * ampli * sinf(angle);
+ return center + diam *ampli *sinf(angle);
}
static void vectorscope_draw_target(float centerx, float centery, float diam, const float colf[3])
{
- float y,u,v;
- float tangle=0.f, tampli;
+ float y, u, v;
+ float tangle = 0.f, tampli;
float dangle, dampli, dangle2, dampli2;
rgb_to_yuv(colf[0], colf[1], colf[2], &y, &u, &v);
- if (u>0 && v>=0) tangle=atanf(v/u);
- else if (u>0 && v<0) tangle= atanf(v/u) + 2.0f * (float)M_PI;
- else if (u<0) tangle=atanf(v/u) + (float)M_PI;
- else if (u==0 && v > 0.0f) tangle= (float)M_PI/2.0f;
- else if (u==0 && v < 0.0f) tangle=-(float)M_PI/2.0f;
- tampli= sqrtf(u*u+v*v);
+ if (u > 0 && v >= 0) tangle = atanf(v / u);
+ else if (u > 0 && v < 0) tangle = atanf(v / u) + 2.0f * (float)M_PI;
+ else if (u < 0) tangle = atanf(v / u) + (float)M_PI;
+ else if (u == 0 && v > 0.0f) tangle = (float)M_PI / 2.0f;
+ else if (u == 0 && v < 0.0f) tangle = -(float)M_PI / 2.0f;
+ tampli = sqrtf(u * u + v * v);
/* small target vary by 2.5 degree and 2.5 IRE unit */
glColor4f(1.0f, 1.0f, 1.0, 0.12f);
- dangle= DEG2RADF(2.5f);
- dampli= 2.5f/200.0f;
+ dangle = DEG2RADF(2.5f);
+ dampli = 2.5f / 200.0f;
glBegin(GL_LINE_STRIP);
- glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle+dangle), polar_to_y(centery,diam,tampli+dampli,tangle+dangle));
- glVertex2f(polar_to_x(centerx,diam,tampli-dampli,tangle+dangle), polar_to_y(centery,diam,tampli-dampli,tangle+dangle));
- glVertex2f(polar_to_x(centerx,diam,tampli-dampli,tangle-dangle), polar_to_y(centery,diam,tampli-dampli,tangle-dangle));
- glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle-dangle), polar_to_y(centery,diam,tampli+dampli,tangle-dangle));
- glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle+dangle), polar_to_y(centery,diam,tampli+dampli,tangle+dangle));
+ glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
+ glVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle));
+ glVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle));
+ glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), polar_to_y(centery, diam, tampli + dampli, tangle - dangle));
+ glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
glEnd();
/* big target vary by 10 degree and 20% amplitude */
glColor4f(1.0f, 1.0f, 1.0, 0.12f);
- dangle= DEG2RADF(10.0f);
- dampli= 0.2f*tampli;
- dangle2= DEG2RADF(5.0f);
- dampli2= 0.5f*dampli;
+ dangle = DEG2RADF(10.0f);
+ dampli = 0.2f * tampli;
+ dangle2 = DEG2RADF(5.0f);
+ dampli2 = 0.5f * dampli;
glBegin(GL_LINE_STRIP);
- glVertex2f(polar_to_x(centerx,diam,tampli+dampli-dampli2,tangle+dangle), polar_to_y(centery,diam,tampli+dampli-dampli2,tangle+dangle));
- glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle+dangle), polar_to_y(centery,diam,tampli+dampli,tangle+dangle));
- glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle+dangle-dangle2), polar_to_y(centery,diam,tampli+dampli,tangle+dangle-dangle2));
+ glVertex2f(polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle + dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle + dangle));
+ glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle));
+ glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli + dampli, tangle + dangle - dangle2));
glEnd();
glBegin(GL_LINE_STRIP);
- glVertex2f(polar_to_x(centerx,diam,tampli-dampli+dampli2,tangle+dangle), polar_to_y(centery ,diam,tampli-dampli+dampli2,tangle+dangle));
- glVertex2f(polar_to_x(centerx,diam,tampli-dampli,tangle+dangle), polar_to_y(centery,diam,tampli-dampli,tangle+dangle));
- glVertex2f(polar_to_x(centerx,diam,tampli-dampli,tangle+dangle-dangle2), polar_to_y(centery,diam,tampli-dampli,tangle+dangle-dangle2));
+ glVertex2f(polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle + dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle + dangle));
+ glVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle));
+ glVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli - dampli, tangle + dangle - dangle2));
glEnd();
glBegin(GL_LINE_STRIP);
- glVertex2f(polar_to_x(centerx,diam,tampli-dampli+dampli2,tangle-dangle), polar_to_y(centery,diam,tampli-dampli+dampli2,tangle-dangle));
- glVertex2f(polar_to_x(centerx,diam,tampli-dampli,tangle-dangle), polar_to_y(centery,diam,tampli-dampli,tangle-dangle));
- glVertex2f(polar_to_x(centerx,diam,tampli-dampli,tangle-dangle+dangle2), polar_to_y(centery,diam,tampli-dampli,tangle-dangle+dangle2));
+ glVertex2f(polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle - dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle - dangle));
+ glVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle));
+ glVertex2f(polar_to_x(centerx, diam, tampli - dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli - dampli, tangle - dangle + dangle2));
glEnd();
glBegin(GL_LINE_STRIP);
- glVertex2f(polar_to_x(centerx,diam,tampli+dampli-dampli2,tangle-dangle), polar_to_y(centery,diam,tampli+dampli-dampli2,tangle-dangle));
- glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle-dangle), polar_to_y(centery,diam,tampli+dampli,tangle-dangle));
- glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle-dangle+dangle2), polar_to_y(centery,diam,tampli+dampli,tangle-dangle+dangle2));
+ glVertex2f(polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle - dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle - dangle));
+ glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), polar_to_y(centery, diam, tampli + dampli, tangle - dangle));
+ glVertex2f(polar_to_x(centerx, diam, tampli + dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli + dampli, tangle - dangle + dangle2));
glEnd();
}
void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti)
{
- const float skin_rad= DEG2RADF(123.0f); /* angle in radians of the skin tone line */
+ 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]={{.75,0,0},{.75,.75,0},{0,.75,0},{0,.75,.75},{0,0,.75},{.75,0,.75}};
+ const float colors[6][3] = {{.75, 0, 0}, {.75, .75, 0}, {0, .75, 0}, {0, .75, .75}, {0, 0, .75}, {.75, 0, .75}};
GLint scissor[4];
- rect.xmin = (float)recti->xmin+1;
- rect.xmax = (float)recti->xmax-1;
- rect.ymin = (float)recti->ymin+SCOPE_RESIZE_PAD+2;
- rect.ymax = (float)recti->ymax-1;
+ rect.xmin = (float)recti->xmin + 1;
+ rect.xmax = (float)recti->xmax - 1;
+ rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
+ rect.ymax = (float)recti->ymax - 1;
w = rect.xmax - rect.xmin;
h = rect.ymax - rect.ymin;
- centerx = rect.xmin + w/2;
- centery = rect.ymin + h/2;
- diam= (w<h)?w:h;
+ centerx = rect.xmin + w / 2;
+ centery = rect.ymin + h / 2;
+ diam = (w < h) ? w : h;
- alpha = scopes->vecscope_alpha*scopes->vecscope_alpha*scopes->vecscope_alpha;
+ alpha = scopes->vecscope_alpha * scopes->vecscope_alpha * scopes->vecscope_alpha;
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0.f, 0.f, 0.f, 0.3f);
uiSetRoundBox(UI_CNR_ALL);
- uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f);
+ uiDrawBox(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 */
glGetIntegerv(GL_VIEWPORT, scissor);
- glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1));
+ glScissor(ar->winrct.xmin + (rect.xmin - 1), ar->winrct.ymin + (rect.ymin - 1), (rect.xmax + 1) - (rect.xmin - 1), (rect.ymax + 1) - (rect.ymin - 1));
glColor4f(1.f, 1.f, 1.f, 0.08f);
/* draw grid elements */
/* cross */
- fdrawline(centerx - (diam/2)-5, centery, centerx + (diam/2)+5, centery);
- fdrawline(centerx, centery - (diam/2)-5, centerx, centery + (diam/2)+5);
+ 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 (j = 0; j < 5; j++) {
glBegin(GL_LINE_STRIP);
- for (i=0; i<=360; i=i+15) {
- 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));
+ for (i = 0; i <= 360; i = i + 15) {
+ 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));
}
glEnd();
}
/* skin tone line */
glColor4f(1.f, 0.4f, 0.f, 0.2f);
- 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));
+ 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 (i = 0; i < 6; i++)
vectorscope_draw_target(centerx, centery, diam, colors[i]);
if (scopes->ok && scopes->vecscope != NULL) {
/* pixel point cloud */
- glBlendFunc(GL_ONE,GL_ONE);
+ glBlendFunc(GL_ONE, GL_ONE);
glColor3f(alpha, alpha, alpha);
glPushMatrix();
@@ -1052,49 +1052,49 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect)
float x1, y1, sizex, sizey;
float v3[2], v1[2], v2[2], v1a[2], v2a[2];
int a;
- float pos, colf[4]= {0,0,0,0}; /* initialize in case the colorband isn't valid */
+ float pos, colf[4] = {0, 0, 0, 0}; /* initialize in case the colorband isn't valid */
- coba= (ColorBand *)(but->editcoba? but->editcoba: but->poin);
- if (coba==NULL) return;
+ coba = (ColorBand *)(but->editcoba ? but->editcoba : but->poin);
+ if (coba == NULL) return;
- x1= rect->xmin;
- y1= rect->ymin;
- sizex= rect->xmax-x1;
- sizey= rect->ymax-y1;
+ x1 = rect->xmin;
+ y1 = rect->ymin;
+ sizex = rect->xmax - x1;
+ sizey = rect->ymax - y1;
/* first background, to show tranparency */
glColor4ub(UI_TRANSP_DARK, UI_TRANSP_DARK, UI_TRANSP_DARK, 255);
- glRectf(x1, y1, x1+sizex, y1+sizey);
+ 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);
- glRectf(x1, y1, x1+sizex, y1+sizey);
+ glRectf(x1, y1, x1 + sizex, y1 + sizey);
glDisable(GL_POLYGON_STIPPLE);
glShadeModel(GL_FLAT);
glEnable(GL_BLEND);
- cbd= coba->data;
+ cbd = coba->data;
- v1[0]= v2[0]= x1;
- v1[1]= y1;
- v2[1]= y1+sizey;
+ v1[0] = v2[0] = x1;
+ v1[1] = y1;
+ v2[1] = y1 + sizey;
glBegin(GL_QUAD_STRIP);
- glColor4fv( &cbd->r );
+ glColor4fv(&cbd->r);
glVertex2fv(v1); glVertex2fv(v2);
- for ( a = 1; a <= sizex; a++ ) {
- pos = ((float)a) / (sizex-1);
+ for (a = 1; a <= sizex; a++) {
+ pos = ((float)a) / (sizex - 1);
do_colorband(coba, pos, colf);
if (but->block->color_profile != BLI_PR_NONE)
linearrgb_to_srgb_v3_v3(colf, colf);
- v1[0]=v2[0]= x1 + a;
+ v1[0] = v2[0] = x1 + a;
- glColor4fv( colf );
+ glColor4fv(colf);
glVertex2fv(v1); glVertex2fv(v2);
}
@@ -1104,23 +1104,23 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect)
/* outline */
glColor4f(0.0, 0.0, 0.0, 1.0);
- fdrawbox(x1, y1, x1+sizex, y1+sizey);
+ fdrawbox(x1, y1, x1 + sizex, y1 + sizey);
/* help lines */
- v1[0]= v2[0]=v3[0]= x1;
- v1[1]= y1;
- v1a[1]= y1+0.25f*sizey;
- v2[1]= y1+0.5f*sizey;
- v2a[1]= y1+0.75f*sizey;
- v3[1]= y1+sizey;
+ v1[0] = v2[0] = v3[0] = x1;
+ v1[1] = y1;
+ v1a[1] = y1 + 0.25f * sizey;
+ v2[1] = y1 + 0.5f * sizey;
+ v2a[1] = y1 + 0.75f * sizey;
+ v3[1] = y1 + sizey;
- cbd= coba->data;
+ cbd = coba->data;
glBegin(GL_LINES);
- for (a=0; a<coba->tot; a++, cbd++) {
- v1[0]=v2[0]=v3[0]=v1a[0]=v2a[0]= x1+ cbd->pos*sizex;
+ for (a = 0; a < coba->tot; a++, cbd++) {
+ v1[0] = v2[0] = v3[0] = v1a[0] = v2a[0] = x1 + cbd->pos * sizex;
- if (a==coba->cur) {
+ if (a == coba->cur) {
glColor3ub(0, 0, 0);
glVertex2fv(v1);
glVertex2fv(v3);
@@ -1166,17 +1166,17 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect)
void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
{
- static GLuint displist=0;
+ static GLuint displist = 0;
int a, old[8];
- GLfloat diff[4], diffn[4]={1.0f, 1.0f, 1.0f, 1.0f};
- float vec0[4]={0.0f, 0.0f, 0.0f, 0.0f};
+ GLfloat diff[4], diffn[4] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float vec0[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float dir[4], size;
/* store stuff */
glGetMaterialfv(GL_FRONT, GL_DIFFUSE, diff);
/* backdrop */
- glColor3ubv((unsigned char*)wcol->inner);
+ glColor3ubv((unsigned char *)wcol->inner);
uiSetRoundBox(UI_CNR_ALL);
uiDrawBox(GL_POLYGON, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f);
@@ -1185,9 +1185,9 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
glCullFace(GL_BACK); glEnable(GL_CULL_FACE);
/* disable blender light */
- for (a=0; a<8; a++) {
- old[a]= glIsEnabled(GL_LIGHT0+a);
- glDisable(GL_LIGHT0+a);
+ for (a = 0; a < 8; a++) {
+ old[a] = glIsEnabled(GL_LIGHT0 + a);
+ glDisable(GL_LIGHT0 + a);
}
/* own light */
@@ -1196,7 +1196,7 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
ui_get_but_vectorf(but, dir);
- dir[3]= 0.0f; /* glLight needs 4 args, 0.0 is sun */
+ dir[3] = 0.0f; /* glLight needs 4 args, 0.0 is sun */
glLightfv(GL_LIGHT7, GL_POSITION, dir);
glLightfv(GL_LIGHT7, GL_DIFFUSE, diffn);
glLightfv(GL_LIGHT7, GL_SPECULAR, vec0);
@@ -1205,25 +1205,25 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
/* transform to button */
glPushMatrix();
- glTranslatef(rect->xmin + 0.5f*(rect->xmax-rect->xmin), rect->ymin+ 0.5f*(rect->ymax-rect->ymin), 0.0f);
+ glTranslatef(rect->xmin + 0.5f * (rect->xmax - rect->xmin), rect->ymin + 0.5f * (rect->ymax - rect->ymin), 0.0f);
- if ( rect->xmax-rect->xmin < rect->ymax-rect->ymin)
- size= (rect->xmax-rect->xmin)/200.f;
+ if (rect->xmax - rect->xmin < rect->ymax - rect->ymin)
+ size = (rect->xmax - rect->xmin) / 200.f;
else
- size= (rect->ymax-rect->ymin)/200.f;
+ size = (rect->ymax - rect->ymin) / 200.f;
glScalef(size, size, size);
- if (displist==0) {
- GLUquadricObj *qobj;
+ if (displist == 0) {
+ GLUquadricObj *qobj;
- displist= glGenLists(1);
+ displist = glGenLists(1);
glNewList(displist, GL_COMPILE_AND_EXECUTE);
- qobj= gluNewQuadric();
+ qobj = gluNewQuadric();
gluQuadricDrawStyle(qobj, GLU_FILL);
glShadeModel(GL_SMOOTH);
- gluSphere( qobj, 100.0, 32, 24);
+ gluSphere(qobj, 100.0, 32, 24);
glShadeModel(GL_FLAT);
gluDeleteQuadric(qobj);
@@ -1239,19 +1239,19 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect)
/* AA circle */
glEnable(GL_BLEND);
- glEnable(GL_LINE_SMOOTH );
- glColor3ubv((unsigned char*)wcol->inner);
- glutil_draw_lined_arc(0.0f, M_PI*2.0, 100.0f, 32);
+ glEnable(GL_LINE_SMOOTH);
+ glColor3ubv((unsigned char *)wcol->inner);
+ glutil_draw_lined_arc(0.0f, M_PI * 2.0, 100.0f, 32);
glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH );
+ glDisable(GL_LINE_SMOOTH);
/* matrix after circle */
glPopMatrix();
/* enable blender light */
- for (a=0; a<8; a++) {
+ for (a = 0; a < 8; a++) {
if (old[a])
- glEnable(GL_LIGHT0+a);
+ glEnable(GL_LIGHT0 + a);
}
}
@@ -1260,22 +1260,22 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o
float dx, dy, fx, fy;
glBegin(GL_LINES);
- dx= step*zoomx;
- fx= rect->xmin + zoomx*(-offsx);
- if (fx > rect->xmin) fx -= dx*(floorf(fx-rect->xmin));
+ dx = step * zoomx;
+ fx = rect->xmin + zoomx * (-offsx);
+ if (fx > rect->xmin) fx -= dx * (floorf(fx - rect->xmin));
while (fx < rect->xmax) {
glVertex2f(fx, rect->ymin);
glVertex2f(fx, rect->ymax);
- fx+= dx;
+ fx += dx;
}
- dy= step*zoomy;
- fy= rect->ymin + zoomy*(-offsy);
- if (fy > rect->ymin) fy -= dy*(floorf(fy-rect->ymin));
+ dy = step * zoomy;
+ fy = rect->ymin + zoomy * (-offsy);
+ if (fy > rect->ymin) fy -= dy * (floorf(fy - rect->ymin));
while (fy < rect->ymax) {
glVertex2f(rect->xmin, fy);
glVertex2f(rect->xmax, fy);
- fy+= dy;
+ fy += dy;
}
glEnd();
@@ -1283,9 +1283,9 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o
static void glColor3ubvShade(unsigned char *col, int shade)
{
- glColor3ub(col[0]-shade>0?col[0]-shade:0,
- col[1]-shade>0?col[1]-shade:0,
- col[2]-shade>0?col[2]-shade:0);
+ glColor3ub(col[0] - shade > 0 ? col[0] - shade : 0,
+ col[1] - shade > 0 ? col[1] - shade : 0,
+ col[2] - shade > 0 ? col[2] - shade : 0);
}
void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect)
@@ -1298,8 +1298,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
rcti scissor_new;
int a;
- cumap= (CurveMapping *)(but->editcumap? but->editcumap: but->poin);
- cuma= cumap->cm+cumap->cur;
+ cumap = (CurveMapping *)(but->editcumap ? but->editcumap : but->poin);
+ cuma = cumap->cm + cumap->cur;
/* need scissor test, curve can draw outside of boundary */
glGetIntegerv(GL_VIEWPORT, scissor);
@@ -1308,26 +1308,26 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
scissor_new.xmax = ar->winrct.xmin + rect->xmax;
scissor_new.ymax = ar->winrct.ymin + rect->ymax;
BLI_isect_rcti(&scissor_new, &ar->winrct, &scissor_new);
- glScissor(scissor_new.xmin, scissor_new.ymin, scissor_new.xmax-scissor_new.xmin, scissor_new.ymax-scissor_new.ymin);
+ glScissor(scissor_new.xmin, scissor_new.ymin, scissor_new.xmax - scissor_new.xmin, scissor_new.ymax - scissor_new.ymin);
/* calculate offset and zoom */
- zoomx= (rect->xmax-rect->xmin-2.0f*but->aspect)/(cumap->curr.xmax - cumap->curr.xmin);
- zoomy= (rect->ymax-rect->ymin-2.0f*but->aspect)/(cumap->curr.ymax - cumap->curr.ymin);
- offsx= cumap->curr.xmin-but->aspect/zoomx;
- offsy= cumap->curr.ymin-but->aspect/zoomy;
+ zoomx = (rect->xmax - rect->xmin - 2.0f * but->aspect) / (cumap->curr.xmax - cumap->curr.xmin);
+ zoomy = (rect->ymax - rect->ymin - 2.0f * but->aspect) / (cumap->curr.ymax - cumap->curr.ymin);
+ offsx = cumap->curr.xmin - but->aspect / zoomx;
+ offsy = cumap->curr.ymin - but->aspect / zoomy;
/* backdrop */
if (cumap->flag & CUMA_DO_CLIP) {
glColor3ubvShade((unsigned char *)wcol->inner, -20);
glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
- glColor3ubv((unsigned char*)wcol->inner);
- glRectf(rect->xmin + zoomx*(cumap->clipr.xmin-offsx),
- rect->ymin + zoomy*(cumap->clipr.ymin-offsy),
- rect->xmin + zoomx*(cumap->clipr.xmax-offsx),
- rect->ymin + zoomy*(cumap->clipr.ymax-offsy));
+ glColor3ubv((unsigned char *)wcol->inner);
+ glRectf(rect->xmin + zoomx * (cumap->clipr.xmin - offsx),
+ rect->ymin + zoomy * (cumap->clipr.ymin - offsy),
+ rect->xmin + zoomx * (cumap->clipr.xmax - offsx),
+ rect->ymin + zoomy * (cumap->clipr.ymax - offsy));
}
else {
- glColor3ubv((unsigned char*)wcol->inner);
+ glColor3ubv((unsigned char *)wcol->inner);
glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
}
@@ -1340,22 +1340,22 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
/* axes */
glColor3ubvShade((unsigned char *)wcol->inner, -50);
glBegin(GL_LINES);
- glVertex2f(rect->xmin, rect->ymin + zoomy*(-offsy));
- glVertex2f(rect->xmax, rect->ymin + zoomy*(-offsy));
- glVertex2f(rect->xmin + zoomx*(-offsx), rect->ymin);
- glVertex2f(rect->xmin + zoomx*(-offsx), rect->ymax);
+ glVertex2f(rect->xmin, rect->ymin + zoomy * (-offsy));
+ glVertex2f(rect->xmax, rect->ymin + zoomy * (-offsy));
+ glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymin);
+ glVertex2f(rect->xmin + zoomx * (-offsx), rect->ymax);
glEnd();
/* magic trigger for curve backgrounds */
if (but->a1 != -1) {
if (but->a1 == UI_GRAD_H) {
rcti grid;
- float col[3]= {0.0f, 0.0f, 0.0f}; /* dummy arg */
+ float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */
- grid.xmin = rect->xmin + zoomx*(-offsx);
- grid.xmax = rect->xmax + zoomx*(-offsx);
- grid.ymin = rect->ymin + zoomy*(-offsy);
- grid.ymax = rect->ymax + zoomy*(-offsy);
+ grid.xmin = rect->xmin + zoomx * (-offsx);
+ grid.xmax = rect->xmax + zoomx * (-offsx);
+ grid.ymin = rect->ymin + zoomy * (-offsy);
+ grid.ymax = rect->ymax + zoomy * (-offsy);
glEnable(GL_BLEND);
ui_draw_gradient(&grid, col, UI_GRAD_H, 0.5f);
@@ -1370,8 +1370,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
if (cumap->flag & CUMA_DRAW_CFRA) {
glColor3ub(0x60, 0xc0, 0x40);
glBegin(GL_LINES);
- glVertex2f(rect->xmin + zoomx*(cumap->sample[0]-offsx), rect->ymin);
- glVertex2f(rect->xmin + zoomx*(cumap->sample[0]-offsx), rect->ymax);
+ glVertex2f(rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymin);
+ glVertex2f(rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymax);
glEnd();
}
#endif
@@ -1380,60 +1380,60 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
/* XXX 2.48 */
#if 0
if (cumap->flag & CUMA_DRAW_SAMPLE) {
- if (cumap->cur==3) {
- float lum= cumap->sample[0]*0.35f + cumap->sample[1]*0.45f + cumap->sample[2]*0.2f;
+ if (cumap->cur == 3) {
+ float lum = cumap->sample[0] * 0.35f + cumap->sample[1] * 0.45f + cumap->sample[2] * 0.2f;
glColor3ub(240, 240, 240);
glBegin(GL_LINES);
- glVertex2f(rect->xmin + zoomx*(lum-offsx), rect->ymin);
- glVertex2f(rect->xmin + zoomx*(lum-offsx), rect->ymax);
+ glVertex2f(rect->xmin + zoomx * (lum - offsx), rect->ymin);
+ glVertex2f(rect->xmin + zoomx * (lum - offsx), rect->ymax);
glEnd();
}
else {
- if (cumap->cur==0)
+ if (cumap->cur == 0)
glColor3ub(240, 100, 100);
- else if (cumap->cur==1)
+ else if (cumap->cur == 1)
glColor3ub(100, 240, 100);
else
glColor3ub(100, 100, 240);
glBegin(GL_LINES);
- glVertex2f(rect->xmin + zoomx*(cumap->sample[cumap->cur]-offsx), rect->ymin);
- glVertex2f(rect->xmin + zoomx*(cumap->sample[cumap->cur]-offsx), rect->ymax);
+ glVertex2f(rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymin);
+ glVertex2f(rect->xmin + zoomx * (cumap->sample[cumap->cur] - offsx), rect->ymax);
glEnd();
}
}
#endif
/* the curve */
- glColor3ubv((unsigned char*)wcol->item);
+ glColor3ubv((unsigned char *)wcol->item);
glEnable(GL_LINE_SMOOTH);
glEnable(GL_BLEND);
glBegin(GL_LINE_STRIP);
- if (cuma->table==NULL)
- curvemapping_changed(cumap, 0); /* 0 = no remove doubles */
- cmp= cuma->table;
+ if (cuma->table == NULL)
+ curvemapping_changed(cumap, 0); /* 0 = no remove doubles */
+ cmp = cuma->table;
/* first point */
- if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0)
- glVertex2f(rect->xmin, rect->ymin + zoomy*(cmp[0].y-offsy));
+ 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]);
+ fx = rect->xmin + zoomx * (cmp[0].x - offsx + cuma->ext_in[0]);
+ 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 (a = 0; a <= CM_TABLE; a++) {
+ fx = rect->xmin + zoomx * (cmp[a].x - offsx);
+ fy = rect->ymin + zoomy * (cmp[a].y - offsy);
glVertex2f(fx, fy);
}
/* last point */
- if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0)
- glVertex2f(rect->xmax, rect->ymin + zoomy*(cmp[CM_TABLE].y-offsy));
+ if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0)
+ 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]);
+ 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]);
glVertex2f(fx, fy);
}
glEnd();
@@ -1441,16 +1441,16 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
glDisable(GL_BLEND);
/* the points, use aspect to make them visible on edges */
- cmp= cuma->curve;
+ cmp = cuma->curve;
glPointSize(3.0f);
bglBegin(GL_POINTS);
- for (a=0; a<cuma->totpoint; a++) {
+ for (a = 0; a < cuma->totpoint; a++) {
if (cmp[a].flag & 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);
+ fac[0] = rect->xmin + zoomx * (cmp[a].x - offsx);
+ fac[1] = rect->ymin + zoomy * (cmp[a].y - offsy);
bglVertex2fv(fac);
}
bglEnd();
@@ -1460,25 +1460,25 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
/* outline */
- glColor3ubv((unsigned char*)wcol->outline);
+ glColor3ubv((unsigned char *)wcol->outline);
fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax);
}
static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float track_pos[2], int width, float height, int margin)
{
ImBuf *scaleibuf;
- const float scalex= ((float)ibuf->x-2*margin) / width;
- const float scaley= ((float)ibuf->y-2*margin) / height;
- float off_x= (int)track_pos[0]-track_pos[0]+0.5f;
- float off_y= (int)track_pos[1]-track_pos[1]+0.5f;
+ const float scalex = ((float)ibuf->x - 2 * margin) / width;
+ const float scaley = ((float)ibuf->y - 2 * margin) / height;
+ float off_x = (int)track_pos[0] - track_pos[0] + 0.5f;
+ float off_y = (int)track_pos[1] - track_pos[1] + 0.5f;
int x, y;
- scaleibuf= IMB_allocImBuf(width, height, 32, IB_rect);
+ scaleibuf = IMB_allocImBuf(width, height, 32, IB_rect);
- for (y= 0; y<height; y++) {
- for (x= 0; x<width; x++) {
- float src_x= scalex*(x)+margin-off_x;
- float src_y= scaley*(y)+margin-off_y;
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ float src_x = scalex * (x) + margin - off_x;
+ float src_y = scaley * (y) + margin - off_y;
bicubic_interpolation(ibuf, scaleibuf, src_x, src_y, x, y);
}
@@ -1490,67 +1490,67 @@ static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float track_pos[2], int width
void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti)
{
rctf rect;
- int ok= 0;
+ int ok = 0;
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+SCOPE_RESIZE_PAD+2;
- rect.ymax = (float)recti->ymax-1;
+ rect.xmin = (float)recti->xmin + 1;
+ rect.xmax = (float)recti->xmax - 1;
+ rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2;
+ rect.ymax = (float)recti->ymax - 1;
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/* need scissor test, preview image can draw outside of boundary */
glGetIntegerv(GL_VIEWPORT, scissor);
- glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1));
+ glScissor(ar->winrct.xmin + (rect.xmin - 1), ar->winrct.ymin + (rect.ymin - 1), (rect.xmax + 1) - (rect.xmin - 1), (rect.ymax + 1) - (rect.ymin - 1));
if (scopes->track_disabled) {
glColor4f(0.7f, 0.3f, 0.3f, 0.3f);
uiSetRoundBox(15);
- uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f);
+ uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f);
- ok= 1;
+ ok = 1;
}
else if (scopes->track_preview) {
/* additional margin around image */
/* NOTE: should be kept in sync with value from BKE_movieclip_update_scopes */
- const int margin= 3;
+ const int margin = 3;
float zoomx, zoomy, track_pos[2], off_x, off_y;
int a, width, height;
ImBuf *drawibuf;
glPushMatrix();
- track_pos[0]= scopes->track_pos[0]-margin;
- track_pos[1]= scopes->track_pos[1]-margin;
+ track_pos[0] = scopes->track_pos[0] - margin;
+ track_pos[1] = scopes->track_pos[1] - margin;
/* draw content of pattern area */
- glScissor(ar->winrct.xmin+rect.xmin, ar->winrct.ymin+rect.ymin, scissor[2], scissor[3]);
+ glScissor(ar->winrct.xmin + rect.xmin, ar->winrct.ymin + rect.ymin, scissor[2], scissor[3]);
- width= rect.xmax-rect.xmin+1;
- height = rect.ymax-rect.ymin;
+ width = rect.xmax - rect.xmin + 1;
+ height = rect.ymax - rect.ymin;
if (width > 0 && height > 0) {
- zoomx= (float)width / (scopes->track_preview->x-2*margin);
- zoomy= (float)height / (scopes->track_preview->y-2*margin);
+ zoomx = (float)width / (scopes->track_preview->x - 2 * margin);
+ zoomy = (float)height / (scopes->track_preview->y - 2 * margin);
- off_x= ((int)track_pos[0]-track_pos[0]+0.5f)*zoomx;
- off_y= ((int)track_pos[1]-track_pos[1]+0.5f)*zoomy;
+ off_x = ((int)track_pos[0] - track_pos[0] + 0.5f) * zoomx;
+ off_y = ((int)track_pos[1] - track_pos[1] + 0.5f) * zoomy;
- drawibuf= scale_trackpreview_ibuf(scopes->track_preview, track_pos, width, height, margin);
+ drawibuf = scale_trackpreview_ibuf(scopes->track_preview, track_pos, width, height, margin);
- glaDrawPixelsSafe(rect.xmin, rect.ymin+1, drawibuf->x, drawibuf->y,
+ glaDrawPixelsSafe(rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y,
drawibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, drawibuf->rect);
IMB_freeImBuf(drawibuf);
/* draw cross for pizel position */
- glTranslatef(off_x+rect.xmin+track_pos[0]*zoomx, off_y+rect.ymin+track_pos[1]*zoomy, 0.f);
- glScissor(ar->winrct.xmin + rect.xmin, ar->winrct.ymin+rect.ymin, rect.xmax-rect.xmin, rect.ymax-rect.ymin);
+ glTranslatef(off_x + rect.xmin + track_pos[0] * zoomx, off_y + rect.ymin + track_pos[1] * zoomy, 0.f);
+ glScissor(ar->winrct.xmin + rect.xmin, ar->winrct.ymin + rect.ymin, rect.xmax - rect.xmin, rect.ymax - rect.ymin);
- for (a= 0; a< 2; a++) {
- if (a==1) {
+ for (a = 0; a < 2; a++) {
+ if (a == 1) {
glLineStipple(3, 0xaaaa);
glEnable(GL_LINE_STIPPLE);
UI_ThemeColor(TH_SEL_MARKER);
@@ -1560,24 +1560,24 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
}
glBegin(GL_LINES);
- glVertex2f(-10.0f, 0.0f);
- glVertex2f(10.0f, 0.0f);
- glVertex2f(0.0f, -10.0f);
- glVertex2f(0.0f, 10.0f);
- glEnd();
+ glVertex2f(-10.0f, 0.0f);
+ glVertex2f(10.0f, 0.0f);
+ glVertex2f(0.0f, -10.0f);
+ glVertex2f(0.0f, 10.0f);
+ glEnd();
}
}
glDisable(GL_LINE_STIPPLE);
glPopMatrix();
- ok= 1;
+ ok = 1;
}
if (!ok) {
glColor4f(0.f, 0.f, 0.f, 0.3f);
uiSetRoundBox(15);
- uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f);
+ uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f);
}
/* outline, scale gripper */
@@ -1598,10 +1598,10 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s
glBegin(GL_POLYGON);
glColor4ub(0, 0, 0, alpha);
glVertex2f(maxx, miny);
- glVertex2f(maxx, maxy-0.3f*shadsize);
+ glVertex2f(maxx, maxy - 0.3f * shadsize);
glColor4ub(0, 0, 0, 0);
- glVertex2f(maxx+shadsize, maxy-0.75f*shadsize);
- glVertex2f(maxx+shadsize, miny);
+ glVertex2f(maxx + shadsize, maxy - 0.75f * shadsize);
+ glVertex2f(maxx + shadsize, miny);
glEnd();
/* corner shape */
@@ -1609,19 +1609,19 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s
glColor4ub(0, 0, 0, alpha);
glVertex2f(maxx, miny);
glColor4ub(0, 0, 0, 0);
- glVertex2f(maxx+shadsize, miny);
- glVertex2f(maxx+0.7f*shadsize, miny-0.7f*shadsize);
- glVertex2f(maxx, miny-shadsize);
+ glVertex2f(maxx + shadsize, miny);
+ glVertex2f(maxx + 0.7f * shadsize, miny - 0.7f * shadsize);
+ glVertex2f(maxx, miny - shadsize);
glEnd();
/* bottom quad */
glBegin(GL_POLYGON);
glColor4ub(0, 0, 0, alpha);
- glVertex2f(minx+0.3f*shadsize, miny);
+ glVertex2f(minx + 0.3f * shadsize, miny);
glVertex2f(maxx, miny);
glColor4ub(0, 0, 0, 0);
- glVertex2f(maxx, miny-shadsize);
- glVertex2f(minx+0.5f*shadsize, miny-shadsize);
+ glVertex2f(maxx, miny - shadsize);
+ glVertex2f(minx + 0.5f * shadsize, miny - shadsize);
glEnd();
glDisable(GL_BLEND);
@@ -1631,9 +1631,9 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s
void uiDrawBoxShadow(unsigned char alpha, float minx, float miny, float maxx, float maxy)
{
/* accumulated outline boxes to make shade not linear, is more pleasant */
- ui_shadowbox(minx, miny, maxx, maxy, 11.0, (20*alpha)>>8);
- ui_shadowbox(minx, miny, maxx, maxy, 7.0, (40*alpha)>>8);
- ui_shadowbox(minx, miny, maxx, maxy, 5.0, (80*alpha)>>8);
+ ui_shadowbox(minx, miny, maxx, maxy, 11.0, (20 * alpha) >> 8);
+ ui_shadowbox(minx, miny, maxx, maxy, 7.0, (40 * alpha) >> 8);
+ ui_shadowbox(minx, miny, maxx, maxy, 5.0, (80 * alpha) >> 8);
}
@@ -1643,39 +1643,39 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, int UNUSED(select))
int i;
float rad;
float a;
- char alpha= 2;
+ char alpha = 2;
glEnable(GL_BLEND);
- if (radius > (rct->ymax-rct->ymin-10.0f)/2.0f)
- rad= (rct->ymax-rct->ymin-10.0f)/2.0f;
+ if (radius > (rct->ymax - rct->ymin - 10.0f) / 2.0f)
+ rad = (rct->ymax - rct->ymin - 10.0f) / 2.0f;
else
- rad= radius;
+ rad = radius;
- i= 12;
+ i = 12;
#if 0
if (select) {
- a= i*aspect; /* same as below */
+ a = i * aspect; /* same as below */
}
else
#endif
{
- a= i*aspect;
+ a = i * aspect;
}
- for (; i--; a-=aspect) {
+ for (; i--; a -= aspect) {
/* alpha ranges from 2 to 20 or so */
glColor4ub(0, 0, 0, alpha);
- alpha+= 2;
+ alpha += 2;
- uiDrawBox(GL_POLYGON, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax-10.0f + a, rad+a);
+ uiDrawBox(GL_POLYGON, rct->xmin - a, rct->ymin - a, rct->xmax + a, rct->ymax - 10.0f + a, rad + a);
}
/* outline emphasis */
- glEnable( GL_LINE_SMOOTH );
+ glEnable(GL_LINE_SMOOTH);
glColor4ub(0, 0, 0, 100);
- uiDrawBox(GL_LINE_LOOP, rct->xmin-0.5f, rct->ymin-0.5f, rct->xmax+0.5f, rct->ymax+0.5f, radius+0.5f);
- glDisable( GL_LINE_SMOOTH );
+ uiDrawBox(GL_LINE_LOOP, rct->xmin - 0.5f, rct->ymin - 0.5f, rct->xmax + 0.5f, rct->ymax + 0.5f, radius + 0.5f);
+ glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
}
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index ce437fde69e..4213a67130b 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -81,11 +81,11 @@ static void ui_add_link(bContext *C, uiBut *from, uiBut *to);
/***************** structs and defines ****************/
-#define BUTTON_TOOLTIP_DELAY 0.500
-#define BUTTON_FLASH_DELAY 0.020
-#define MENU_SCROLL_INTERVAL 0.1
-#define BUTTON_AUTO_OPEN_THRESH 0.3
-#define BUTTON_MOUSE_TOWARDS_THRESH 1.0
+#define BUTTON_TOOLTIP_DELAY 0.500
+#define BUTTON_FLASH_DELAY 0.020
+#define MENU_SCROLL_INTERVAL 0.1
+#define BUTTON_AUTO_OPEN_THRESH 0.3
+#define BUTTON_MOUSE_TOWARDS_THRESH 1.0
typedef enum uiButtonActivateType {
BUTTON_ACTIVATE_OVER,
@@ -213,7 +213,7 @@ static int ui_but_editable(uiBut *but)
static uiBut *ui_but_prev(uiBut *but)
{
while (but->prev) {
- but= but->prev;
+ but = but->prev;
if (!ui_but_editable(but)) return but;
}
return NULL;
@@ -222,7 +222,7 @@ static uiBut *ui_but_prev(uiBut *but)
static uiBut *ui_but_next(uiBut *but)
{
while (but->next) {
- but= but->next;
+ but = but->next;
if (!ui_but_editable(but)) return but;
}
return NULL;
@@ -232,10 +232,10 @@ static uiBut *ui_but_first(uiBlock *block)
{
uiBut *but;
- but= block->buttons.first;
+ but = block->buttons.first;
while (but) {
if (!ui_but_editable(but)) return but;
- but= but->next;
+ but = but->next;
}
return NULL;
}
@@ -244,10 +244,10 @@ static uiBut *ui_but_last(uiBlock *block)
{
uiBut *but;
- but= block->buttons.last;
+ but = block->buttons.last;
while (but) {
if (!ui_but_editable(but)) return but;
- but= but->prev;
+ but = but->prev;
}
return NULL;
}
@@ -265,7 +265,7 @@ static int ui_is_a_warp_but(uiBut *but)
int ui_is_but_utf8(uiBut *but)
{
if (but->rnaprop) {
- const int subtype= RNA_property_subtype(but->rnaprop);
+ const int subtype = RNA_property_subtype(but->rnaprop);
return !(ELEM4(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME, PROP_BYTESTRING));
}
else {
@@ -280,56 +280,56 @@ static ListBase UIAfterFuncs = {NULL, NULL};
static void ui_apply_but_func(bContext *C, uiBut *but)
{
uiAfterFunc *after;
- uiBlock *block= but->block;
+ uiBlock *block = but->block;
/* these functions are postponed and only executed after all other
* handling is done, i.e. menus are closed, in order to avoid conflicts
* with these functions removing the buttons we are working with */
if (but->func || but->funcN || block->handle_func || but->rename_func || (but->type == BUTM && block->butm_func) || but->optype || but->rnaprop) {
- after= MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc");
+ after = MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc");
if (but->func && ELEM(but, but->func_arg1, but->func_arg2)) {
/* exception, this will crash due to removed button otherwise */
but->func(C, but->func_arg1, but->func_arg2);
}
else
- after->func= but->func;
+ after->func = but->func;
- after->func_arg1= but->func_arg1;
- after->func_arg2= but->func_arg2;
- after->func_arg3= but->func_arg3;
+ after->func_arg1 = but->func_arg1;
+ after->func_arg2 = but->func_arg2;
+ after->func_arg3 = but->func_arg3;
- after->funcN= but->funcN;
- after->func_argN= MEM_dupallocN(but->func_argN);
+ after->funcN = but->funcN;
+ after->func_argN = MEM_dupallocN(but->func_argN);
- after->rename_func= but->rename_func;
- after->rename_arg1= but->rename_arg1;
- after->rename_orig= but->rename_orig; /* needs free! */
-
- after->handle_func= block->handle_func;
- after->handle_func_arg= block->handle_func_arg;
- after->retval= but->retval;
+ after->rename_func = but->rename_func;
+ after->rename_arg1 = but->rename_arg1;
+ after->rename_orig = but->rename_orig; /* needs free! */
+
+ after->handle_func = block->handle_func;
+ after->handle_func_arg = block->handle_func_arg;
+ after->retval = but->retval;
if (but->type == BUTM) {
- after->butm_func= block->butm_func;
- after->butm_func_arg= block->butm_func_arg;
- after->a2= but->a2;
+ after->butm_func = block->butm_func;
+ after->butm_func_arg = block->butm_func_arg;
+ after->a2 = but->a2;
}
- after->optype= but->optype;
- after->opcontext= but->opcontext;
- after->opptr= but->opptr;
+ after->optype = but->optype;
+ after->opcontext = but->opcontext;
+ after->opptr = but->opptr;
- after->rnapoin= but->rnapoin;
- after->rnaprop= but->rnaprop;
+ after->rnapoin = but->rnapoin;
+ after->rnaprop = but->rnaprop;
if (but->context)
- after->context= CTX_store_copy(but->context);
+ after->context = CTX_store_copy(but->context);
- but->optype= NULL;
- but->opcontext= 0;
- but->opptr= NULL;
+ but->optype = NULL;
+ but->opcontext = 0;
+ but->opptr = NULL;
BLI_addtail(&UIAfterFuncs, after);
}
@@ -337,25 +337,25 @@ static void ui_apply_but_func(bContext *C, uiBut *but)
static void ui_apply_autokey_undo(bContext *C, uiBut *but)
{
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
uiAfterFunc *after;
if (but->flag & UI_BUT_UNDO) {
- const char *str= NULL;
+ const char *str = NULL;
/* define which string to use for undo */
if (ELEM(but->type, LINK, INLINK)) str = "Add button link";
else if (ELEM(but->type, MENU, ICONTEXTROW)) str = but->drawstr;
- else if (but->drawstr[0]) str= but->drawstr;
- else str= but->tip;
+ else if (but->drawstr[0]) str = but->drawstr;
+ else str = but->tip;
/* fallback, else we don't get an undo! */
if (str == NULL || str[0] == '\0') {
- str= "Unknown Action";
+ str = "Unknown Action";
}
/* delayed, after all other funcs run, popups are closed, etc */
- after= MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc");
+ after = MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc");
BLI_strncpy(after->undostr, str, sizeof(after->undostr));
BLI_addtail(&UIAfterFuncs, after);
}
@@ -371,11 +371,11 @@ static void ui_apply_but_funcs_after(bContext *C)
ListBase funcs;
/* copy to avoid recursive calls */
- funcs= UIAfterFuncs;
- UIAfterFuncs.first= UIAfterFuncs.last= NULL;
+ funcs = UIAfterFuncs;
+ UIAfterFuncs.first = UIAfterFuncs.last = NULL;
- for (afterf=funcs.first; afterf; afterf=after.next) {
- after= *afterf; /* copy to avoid memleak on exit() */
+ for (afterf = funcs.first; afterf; afterf = after.next) {
+ after = *afterf; /* copy to avoid memleak on exit() */
BLI_freelinkN(&funcs, afterf);
if (after.context)
@@ -383,12 +383,12 @@ static void ui_apply_but_funcs_after(bContext *C)
if (after.opptr) {
/* free in advance to avoid leak on exit */
- opptr= *after.opptr,
+ opptr = *after.opptr,
MEM_freeN(after.opptr);
}
if (after.optype)
- WM_operator_name_call(C, after.optype->idname, after.opcontext, (after.opptr)? &opptr: NULL);
+ WM_operator_name_call(C, after.optype->idname, after.opcontext, (after.opptr) ? &opptr : NULL);
if (after.opptr)
WM_operator_properties_free(&opptr);
@@ -427,8 +427,8 @@ static void ui_apply_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data)
{
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_BUTM(bContext *C, uiBut *but, uiHandleButtonData *data)
@@ -436,8 +436,8 @@ static void ui_apply_but_BUTM(bContext *C, uiBut *but, uiHandleButtonData *data)
ui_set_but_val(but, but->hardmin);
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data)
@@ -447,8 +447,8 @@ static void ui_apply_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data
ui_check_but(but);
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data)
@@ -457,57 +457,57 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data)
int w, lvalue, push;
/* local hack... */
- if (but->type==BUT_TOGDUAL && data->togdual) {
- if (but->pointype==SHO)
+ if (but->type == BUT_TOGDUAL && data->togdual) {
+ if (but->pointype == SHO)
but->poin += 2;
- else if (but->pointype==INT)
+ else if (but->pointype == INT)
but->poin += 4;
}
- value= ui_get_but_val(but);
- lvalue= (int)value;
+ value = ui_get_but_val(but);
+ lvalue = (int)value;
if (but->bit) {
- w= BTST(lvalue, but->bitnr);
+ w = BTST(lvalue, but->bitnr);
if (w) lvalue = BCLR(lvalue, but->bitnr);
else lvalue = BSET(lvalue, but->bitnr);
- if (but->type==TOGR) {
+ if (but->type == TOGR) {
if (!data->togonly) {
- lvalue= 1<<(but->bitnr);
+ lvalue = 1 << (but->bitnr);
ui_set_but_val(but, (double)lvalue);
}
else {
- if (lvalue==0) lvalue= 1<<(but->bitnr);
+ if (lvalue == 0) lvalue = 1 << (but->bitnr);
}
}
ui_set_but_val(but, (double)lvalue);
- if (but->type==ICONTOG || but->type==ICONTOGN) ui_check_but(but);
+ if (but->type == ICONTOG || but->type == ICONTOGN) ui_check_but(but);
}
else {
- if (value==0.0) push= 1;
- else push= 0;
+ if (value == 0.0) push = 1;
+ else push = 0;
- if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) push= !push;
+ if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) push = !push;
ui_set_but_val(but, (double)push);
- if (but->type==ICONTOG || but->type==ICONTOGN) ui_check_but(but);
+ if (but->type == ICONTOG || but->type == ICONTOGN) ui_check_but(but);
}
/* end local hack... */
- if (but->type==BUT_TOGDUAL && data->togdual) {
- if (but->pointype==SHO)
+ if (but->type == BUT_TOGDUAL && data->togdual) {
+ if (but->pointype == SHO)
but->poin -= 2;
- else if (but->pointype==INT)
+ else if (but->pointype == INT)
but->poin -= 4;
}
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_ROW(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data)
@@ -517,14 +517,14 @@ static void ui_apply_but_ROW(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
ui_set_but_val(but, but->hardmax);
/* states of other row buttons */
- for (bt= block->buttons.first; bt; bt= bt->next)
- if (bt!=but && bt->poin==but->poin && ELEM(bt->type, ROW, LISTROW))
+ for (bt = block->buttons.first; bt; bt = bt->next)
+ if (bt != but && bt->poin == but->poin && ELEM(bt->type, ROW, LISTROW))
ui_check_but(bt);
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
@@ -538,22 +538,22 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data)
/* give butfunc the original text too */
/* feature used for bone renaming, channels, etc */
/* afterfunc frees origstr */
- but->rename_orig= data->origstr;
- data->origstr= NULL;
+ but->rename_orig = data->origstr;
+ data->origstr = NULL;
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data)
{
if (data->str) {
if (ui_set_but_string(C, but, data->str)) {
- data->value= ui_get_but_val(but);
+ data->value = ui_get_but_val(but);
}
else {
- data->cancel= 1;
+ data->cancel = 1;
return;
}
}
@@ -563,43 +563,43 @@ static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data)
ui_check_but(but);
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_TOG3(bContext *C, uiBut *but, uiHandleButtonData *data)
{
- if (but->pointype==SHO ) {
- short *sp= (short *)but->poin;
+ if (but->pointype == SHO) {
+ short *sp = (short *)but->poin;
- if ( BTST(sp[1], but->bitnr)) {
- sp[1]= BCLR(sp[1], but->bitnr);
- sp[0]= BCLR(sp[0], but->bitnr);
+ if (BTST(sp[1], but->bitnr)) {
+ sp[1] = BCLR(sp[1], but->bitnr);
+ sp[0] = BCLR(sp[0], but->bitnr);
}
- else if ( BTST(sp[0], but->bitnr)) {
- sp[1]= BSET(sp[1], but->bitnr);
+ else if (BTST(sp[0], but->bitnr)) {
+ sp[1] = BSET(sp[1], but->bitnr);
}
else {
- sp[0]= BSET(sp[0], but->bitnr);
+ sp[0] = BSET(sp[0], but->bitnr);
}
}
else {
- if ( BTST(*(but->poin+2), but->bitnr)) {
- *(but->poin+2)= BCLR(*(but->poin+2), but->bitnr);
- *(but->poin)= BCLR(*(but->poin), but->bitnr);
+ if (BTST(*(but->poin + 2), but->bitnr)) {
+ *(but->poin + 2) = BCLR(*(but->poin + 2), but->bitnr);
+ *(but->poin) = BCLR(*(but->poin), but->bitnr);
}
- else if ( BTST(*(but->poin), but->bitnr)) {
- *(but->poin+2)= BSET(*(but->poin+2), but->bitnr);
+ else if (BTST(*(but->poin), but->bitnr)) {
+ *(but->poin + 2) = BSET(*(but->poin + 2), but->bitnr);
}
else {
- *(but->poin)= BSET(*(but->poin), but->bitnr);
+ *(but->poin) = BSET(*(but->poin), but->bitnr);
}
}
ui_check_but(but);
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_VEC(bContext *C, uiBut *but, uiHandleButtonData *data)
@@ -608,22 +608,22 @@ static void ui_apply_but_VEC(bContext *C, uiBut *but, uiHandleButtonData *data)
ui_check_but(but);
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_COLORBAND(bContext *C, uiBut *but, uiHandleButtonData *data)
{
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_CURVE(bContext *C, uiBut *but, uiHandleButtonData *data)
{
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_IDPOIN(bContext *C, uiBut *but, uiHandleButtonData *data)
@@ -631,16 +631,16 @@ static void ui_apply_but_IDPOIN(bContext *C, uiBut *but, uiHandleButtonData *dat
ui_set_but_string(C, but, data->str);
ui_check_but(but);
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
#ifdef WITH_INTERNATIONAL
static void ui_apply_but_CHARTAB(bContext *C, uiBut *but, uiHandleButtonData *data)
{
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
#endif
@@ -649,21 +649,21 @@ static void ui_apply_but_CHARTAB(bContext *C, uiBut *but, uiHandleButtonData *da
static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event)
{
rcti rect;
- int x= event->x, y= event->y;
+ int x = event->x, y = event->y;
ui_window_to_block(ar, but->block, &x, &y);
rect.xmin = but->x1; rect.xmax = but->x2;
rect.ymin = but->y1; rect.ymax = but->y2;
- if (but->imb); /* use button size itself */
+ if (but->imb) ; /* use button size itself */
else if (but->flag & UI_ICON_LEFT) {
- rect.xmax = rect.xmin + (rect.ymax-rect.ymin);
+ rect.xmax = rect.xmin + (rect.ymax - rect.ymin);
}
else {
- int delta= (rect.xmax-rect.xmin) - (rect.ymax-rect.ymin);
- rect.xmin += delta/2;
- rect.xmax -= delta/2;
+ int delta = (rect.xmax - rect.xmin) - (rect.ymax - rect.ymin);
+ rect.xmin += delta / 2;
+ rect.xmax -= delta / 2;
}
return BLI_in_rcti(&rect, x, y);
@@ -674,15 +674,15 @@ static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data,
/* prevent other WM gestures to start while we try to drag */
WM_gestures_remove(C);
- if ( ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > U.dragthreshold ) {
+ if (ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > U.dragthreshold) {
wmDrag *drag;
button_activate_state(C, but, BUTTON_STATE_EXIT);
- data->cancel= 1;
+ data->cancel = 1;
- drag= WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but));
+ drag = WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but));
if (but->imb)
- WM_event_drag_image(drag, but->imb, but->imb_scale, but->x2-but->x1, but->y2-but->y1);
+ WM_event_drag_image(drag, but->imb, but->imb_scale, but->x2 - but->x1, but->y2 - but->y1);
return 1;
}
@@ -698,33 +698,33 @@ static void ui_delete_active_linkline(uiBlock *block)
uiLinkLine *line, *nline;
int a, b;
- but= block->buttons.first;
+ but = block->buttons.first;
while (but) {
- if (but->type==LINK && but->link) {
- line= but->link->lines.first;
+ if (but->type == LINK && but->link) {
+ line = but->link->lines.first;
while (line) {
- nline= line->next;
+ nline = line->next;
if (line->flag & UI_SELECT) {
BLI_remlink(&but->link->lines, line);
- link= line->from->link;
+ link = line->from->link;
/* are there more pointers allowed? */
if (link->ppoin) {
- if (*(link->totlink)==1) {
- *(link->totlink)= 0;
+ if (*(link->totlink) == 1) {
+ *(link->totlink) = 0;
MEM_freeN(*(link->ppoin));
- *(link->ppoin)= NULL;
+ *(link->ppoin) = NULL;
}
else {
- b= 0;
- for (a=0; a< (*(link->totlink)); a++) {
+ b = 0;
+ for (a = 0; a < (*(link->totlink)); a++) {
- if ( (*(link->ppoin))[a] != line->to->poin ) {
- (*(link->ppoin))[b]= (*(link->ppoin))[a];
+ if ( (*(link->ppoin))[a] != line->to->poin) {
+ (*(link->ppoin))[b] = (*(link->ppoin))[a];
b++;
}
}
@@ -732,15 +732,15 @@ static void ui_delete_active_linkline(uiBlock *block)
}
}
else {
- *(link->poin)= NULL;
+ *(link->poin) = NULL;
}
MEM_freeN(line);
}
- line= nline;
+ line = nline;
}
}
- but= but->next;
+ but = but->next;
}
}
@@ -750,12 +750,12 @@ static uiLinkLine *ui_is_a_link(uiBut *from, uiBut *to)
uiLinkLine *line;
uiLink *link;
- link= from->link;
+ link = from->link;
if (link) {
- line= link->lines.first;
+ line = link->lines.first;
while (line) {
- if (line->from==from && line->to==to) return line;
- line= line->next;
+ if (line->from == from && line->to == to) return line;
+ line = line->next;
}
}
return NULL;
@@ -765,27 +765,27 @@ static uiLinkLine *ui_is_a_link(uiBut *from, uiBut *to)
/* Try to add an AND Controller between the sensor and the actuator logic bricks and to connect them all */
static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
{
- Object *ob= NULL;
+ Object *ob = NULL;
bSensor *sens_iter;
bActuator *act_to, *act_iter;
bController *cont;
bController ***sens_from_links;
uiBut *tmp_but;
- uiLink *link= from->link;
+ uiLink *link = from->link;
if (link->ppoin)
- sens_from_links= (bController ***)(link->ppoin);
+ sens_from_links = (bController ***)(link->ppoin);
else return;
act_to = (bActuator *)(to->poin);
/* (1) get the object */
- CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) {
- for (sens_iter= ob_iter->sensors.first; sens_iter; sens_iter= sens_iter->next)
+ CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) {
+ for (sens_iter = ob_iter->sensors.first; sens_iter; sens_iter = sens_iter->next)
{
if (&(sens_iter->links) == sens_from_links) {
- ob= ob_iter;
+ ob = ob_iter;
break;
}
}
@@ -795,7 +795,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
if (!ob) return;
/* (2) check if the sensor and the actuator are from the same object */
- for (act_iter= ob->actuators.first; act_iter; act_iter= (bActuator *)act_iter->next) {
+ for (act_iter = ob->actuators.first; act_iter; act_iter = (bActuator *)act_iter->next) {
if (act_iter == act_to)
break;
}
@@ -810,13 +810,13 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
/* (4) link the sensor->controller->actuator */
tmp_but = MEM_callocN(sizeof(uiBut), "uiBut");
uiSetButLink(tmp_but, (void **)&cont, (void ***)&(cont->links), &(cont->totlinks), from->link->tocode, (int)to->hardmin);
- tmp_but->hardmin= from->link->tocode;
- tmp_but->poin= (char *)cont;
+ tmp_but->hardmin = from->link->tocode;
+ tmp_but->poin = (char *)cont;
- tmp_but->type= INLINK;
+ tmp_but->type = INLINK;
ui_add_link(C, from, tmp_but);
- tmp_but->type= LINK;
+ tmp_but->type = LINK;
ui_add_link(C, tmp_but, to);
/* (5) garbage collection */
@@ -833,45 +833,45 @@ static void ui_add_link(bContext *C, uiBut *from, uiBut *to)
void **oldppoin;
int a;
- if ( (line= ui_is_a_link(from, to)) ) {
+ if ( (line = ui_is_a_link(from, to)) ) {
line->flag |= UI_SELECT;
ui_delete_active_linkline(from->block);
return;
}
- if (from->type==INLINK && to->type==INLINK) {
+ if (from->type == INLINK && to->type == INLINK) {
return;
}
- else if (from->type==LINK && to->type==INLINK) {
- if ( from->link->tocode != (int)to->hardmin ) {
+ else if (from->type == LINK && to->type == INLINK) {
+ if (from->link->tocode != (int)to->hardmin) {
ui_add_smart_controller(C, from, to);
return;
}
}
- else if (from->type==INLINK && to->type==LINK) {
- if ( to->link->tocode == (int)from->hardmin ) {
+ else if (from->type == INLINK && to->type == LINK) {
+ if (to->link->tocode == (int)from->hardmin) {
return;
}
}
- link= from->link;
+ link = from->link;
/* are there more pointers allowed? */
if (link->ppoin) {
- oldppoin= *(link->ppoin);
+ oldppoin = *(link->ppoin);
(*(link->totlink))++;
- *(link->ppoin)= MEM_callocN( *(link->totlink)*sizeof(void *), "new link");
+ *(link->ppoin) = MEM_callocN(*(link->totlink) * sizeof(void *), "new link");
- for (a=0; a< (*(link->totlink))-1; a++) {
- (*(link->ppoin))[a]= oldppoin[a];
+ for (a = 0; a < (*(link->totlink)) - 1; a++) {
+ (*(link->ppoin))[a] = oldppoin[a];
}
- (*(link->ppoin))[a]= to->poin;
+ (*(link->ppoin))[a] = to->poin;
if (oldppoin) MEM_freeN(oldppoin);
}
else {
- *(link->poin)= to->poin;
+ *(link->poin) = to->poin;
}
}
@@ -879,52 +879,52 @@ static void ui_add_link(bContext *C, uiBut *from, uiBut *to)
static void ui_apply_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data)
{
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
uiBut *bt;
- for (bt= but->block->buttons.first; bt; bt= bt->next) {
- if ( ui_mouse_inside_button(ar, bt, but->linkto[0]+ar->winrct.xmin, but->linkto[1]+ar->winrct.ymin) )
+ for (bt = but->block->buttons.first; bt; bt = bt->next) {
+ if (ui_mouse_inside_button(ar, bt, but->linkto[0] + ar->winrct.xmin, but->linkto[1] + ar->winrct.ymin) )
break;
}
- if (bt && bt!=but) {
+ if (bt && bt != but) {
if (!ELEM(bt->type, LINK, INLINK) || !ELEM(but->type, LINK, INLINK))
return;
- if (but->type==LINK) ui_add_link(C, but, bt);
+ if (but->type == LINK) ui_add_link(C, but, bt);
else ui_add_link(C, bt, but);
ui_apply_but_func(C, but);
- data->retval= but->retval;
+ data->retval = but->retval;
}
- data->applied= 1;
+ data->applied = 1;
}
static void ui_apply_but_IMAGE(bContext *C, uiBut *but, uiHandleButtonData *data)
{
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_HISTOGRAM(bContext *C, uiBut *but, uiHandleButtonData *data)
{
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_WAVEFORM(bContext *C, uiBut *but, uiHandleButtonData *data)
{
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
static void ui_apply_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonData *data)
{
ui_apply_but_func(C, but);
- data->retval= but->retval;
- data->applied= 1;
+ data->retval = but->retval;
+ data->applied = 1;
}
@@ -936,7 +936,7 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
ColorBand *editcoba;
CurveMapping *editcumap;
- data->retval= 0;
+ data->retval = 0;
/* if we cancel and have not applied yet, there is nothing to do,
* otherwise we have to restore the original value again */
@@ -945,36 +945,36 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
return;
if (data->str) MEM_freeN(data->str);
- data->str= data->origstr;
- data->origstr= NULL;
- data->value= data->origvalue;
- data->origvalue= 0.0;
+ data->str = data->origstr;
+ data->origstr = NULL;
+ data->value = data->origvalue;
+ data->origvalue = 0.0;
copy_v3_v3(data->vec, data->origvec);
- data->origvec[0]= data->origvec[1]= data->origvec[2]= 0.0f;
+ data->origvec[0] = data->origvec[1] = data->origvec[2] = 0.0f;
}
else {
/* we avoid applying interactive edits a second time
* at the end with the appliedinteractive flag */
if (interactive)
- data->appliedinteractive= 1;
+ data->appliedinteractive = 1;
else if (data->appliedinteractive)
return;
}
/* ensures we are writing actual values */
- editstr= but->editstr;
- editval= but->editval;
- editvec= but->editvec;
- editcoba= but->editcoba;
- editcumap= but->editcumap;
- but->editstr= NULL;
- but->editval= NULL;
- but->editvec= NULL;
- but->editcoba= NULL;
- but->editcumap= NULL;
+ editstr = but->editstr;
+ editval = but->editval;
+ editvec = but->editvec;
+ editcoba = but->editcoba;
+ editcumap = but->editcumap;
+ but->editstr = NULL;
+ but->editval = NULL;
+ but->editvec = NULL;
+ but->editcoba = NULL;
+ but->editcumap = NULL;
/* handle different types */
- switch(but->type) {
+ switch (but->type) {
case BUT:
ui_apply_but_BUT(C, but, data);
break;
@@ -1063,11 +1063,11 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
break;
}
- but->editstr= editstr;
- but->editval= editval;
- but->editvec= editvec;
- but->editcoba= editcoba;
- but->editcumap= editcumap;
+ but->editstr = editstr;
+ but->editval = editval;
+ but->editvec = editvec;
+ but->editcoba = editcoba;
+ but->editcumap = editcumap;
}
/* ******************* drop event ******************** */
@@ -1076,17 +1076,17 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
static void ui_but_drop(bContext *C, wmEvent *event, uiBut *but, uiHandleButtonData *data)
{
wmDrag *wmd;
- ListBase *drags= event->customdata; /* drop event type has listbase customdata by default */
+ ListBase *drags = event->customdata; /* drop event type has listbase customdata by default */
- for (wmd= drags->first; wmd; wmd= wmd->next) {
- if (wmd->type==WM_DRAG_ID) {
+ for (wmd = drags->first; wmd; wmd = wmd->next) {
+ if (wmd->type == WM_DRAG_ID) {
/* align these types with UI_but_active_drop_name */
if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
- ID *id= (ID *)wmd->poin;
+ ID *id = (ID *)wmd->poin;
- if (but->poin==NULL && but->rnapoin.data==NULL) {}
+ if (but->poin == NULL && but->rnapoin.data == NULL) {}
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
- BLI_strncpy(data->str, id->name+2, data->maxlen);
+ BLI_strncpy(data->str, id->name + 2, data->maxlen);
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
}
@@ -1100,22 +1100,22 @@ static void ui_but_drop(bContext *C, wmEvent *event, uiBut *but, uiHandleButtonD
static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, char mode)
{
static ColorBand but_copypaste_coba = {0};
- char buf[UI_MAX_DRAW_STR+1]= {0};
+ char buf[UI_MAX_DRAW_STR + 1] = {0};
- if (mode=='v' && but->lock)
+ if (mode == 'v' && but->lock)
return;
- if (mode=='v') {
+ if (mode == 'v') {
/* extract first line from clipboard in case of multi-line copies */
- char *p, *pbuf= WM_clipboard_text_get(0);
- p= pbuf;
+ char *p, *pbuf = WM_clipboard_text_get(0);
+ p = pbuf;
if (p) {
int i = 0;
- while (*p && *p!='\r' && *p!='\n' && i<UI_MAX_DRAW_STR) {
- buf[i++]=*p;
+ while (*p && *p != '\r' && *p != '\n' && i < UI_MAX_DRAW_STR) {
+ buf[i++] = *p;
p++;
}
- buf[i]= 0;
+ buf[i] = 0;
MEM_freeN(pbuf);
}
}
@@ -1123,8 +1123,8 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
/* numeric value */
if (ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI)) {
- if (but->poin==NULL && but->rnapoin.data==NULL);
- else if (mode=='c') {
+ if (but->poin == NULL && but->rnapoin.data == NULL) ;
+ else if (mode == 'c') {
ui_get_but_string(but, buf, sizeof(buf));
WM_clipboard_text_set(buf, 0);
}
@@ -1133,7 +1133,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
if (ui_set_but_string_eval_num(C, but, buf, &val)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
- data->value= val;
+ data->value = val;
ui_set_but_string(C, but, buf);
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -1141,11 +1141,11 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
}
/* RGB triple */
- else if (but->type==COL) {
+ else if (but->type == COL) {
float rgb[3];
- if (but->poin==NULL && but->rnapoin.data==NULL);
- else if (mode=='c') {
+ if (but->poin == NULL && but->rnapoin.data == NULL) ;
+ else if (mode == 'c') {
ui_get_but_vectorf(but, rgb);
BLI_snprintf(buf, sizeof(buf), "[%f, %f, %f]", rgb[0], rgb[1], rgb[2]);
@@ -1163,21 +1163,21 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
/* text/string and ID data */
else if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
- uiHandleButtonData *active_data= but->active;
+ uiHandleButtonData *active_data = but->active;
- if (but->poin==NULL && but->rnapoin.data==NULL);
- else if (mode=='c') {
+ if (but->poin == NULL && but->rnapoin.data == NULL) ;
+ else if (mode == 'c') {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
BLI_strncpy(buf, active_data->str, UI_MAX_DRAW_STR);
WM_clipboard_text_set(active_data->str, 0);
- active_data->cancel= 1;
+ active_data->cancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
if (ui_is_but_utf8(but)) BLI_strncpy_utf8(active_data->str, buf, active_data->maxlen);
- else BLI_strncpy(active_data->str, buf, active_data->maxlen);
+ else BLI_strncpy(active_data->str, buf, active_data->maxlen);
if (but->type == SEARCH_MENU) {
/* else uiSearchboxData.active member is not updated [#26856] */
@@ -1187,19 +1187,19 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
}
}
/* colorband (not supported by system clipboard) */
- else if (but->type==BUT_COLORBAND) {
- if (mode=='c') {
- if (but->poin==NULL)
+ else if (but->type == BUT_COLORBAND) {
+ if (mode == 'c') {
+ if (but->poin == NULL)
return;
memcpy(&but_copypaste_coba, but->poin, sizeof(ColorBand));
}
else {
- if (but_copypaste_coba.tot==0)
+ if (but_copypaste_coba.tot == 0)
return;
if (!but->poin)
- but->poin= MEM_callocN(sizeof(ColorBand), "colorband");
+ but->poin = MEM_callocN(sizeof(ColorBand), "colorband");
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
memcpy(data->coba, &but_copypaste_coba, sizeof(ColorBand) );
@@ -1208,12 +1208,12 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
}
/* operator button (any type) */
else if (but->optype) {
- if (mode=='c') {
+ if (mode == 'c') {
PointerRNA *opptr;
char *str;
- opptr= uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */
+ opptr = uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */
- str= WM_operator_pystring(C, but->optype, opptr, 0);
+ str = WM_operator_pystring(C, but->optype, opptr, 0);
WM_clipboard_text_set(str, 0);
@@ -1227,12 +1227,12 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
static int ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data)
{
- char *str= data->str;
- int len= strlen(str);
- int change= 0;
+ char *str = data->str;
+ int len = strlen(str);
+ int change = 0;
if (but->selsta != but->selend && len) {
memmove(str + but->selsta, str + but->selend, (len - but->selend) + 1);
- change= 1;
+ change = 1;
}
but->pos = but->selend = but->selsta;
@@ -1242,23 +1242,23 @@ static int ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data)
/* note, but->block->aspect is used here, when drawing button style is getting scaled too */
static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, short x)
{
- uiStyle *style= UI_GetStyle(); // XXX pass on as arg
+ uiStyle *style = UI_GetStyle(); // XXX pass on as arg
uiFontStyle *fstyle = &style->widget;
- int startx= but->x1;
+ int startx = but->x1;
char *origstr;
uiStyleFontSet(fstyle);
- if (fstyle->kerning==1) /* for BLF_width */
+ if (fstyle->kerning == 1) /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
- origstr= MEM_callocN(sizeof(char)*data->maxlen, "ui_textedit origstr");
+ origstr = MEM_callocN(sizeof(char) * data->maxlen, "ui_textedit origstr");
BLI_strncpy(origstr, but->drawstr, data->maxlen);
/* XXX solve generic */
- if (but->type==NUM || but->type==NUMSLI)
- startx += (int)(0.5f*(but->y2 - but->y1));
+ if (but->type == NUM || but->type == NUMSLI)
+ startx += (int)(0.5f * (but->y2 - but->y1));
else if (ELEM(but->type, TEX, SEARCH_MENU)) {
startx += 5;
if (but->flag & UI_HAS_ICON)
@@ -1273,7 +1273,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
while (i > 0) {
if (BLI_str_cursor_step_prev_utf8(origstr, but->ofs, &i)) {
- if (BLF_width(fstyle->uifont_id, origstr+i) > (startx - x)*0.25f) break; // 0.25 == scale factor for less sensitivity
+ if (BLF_width(fstyle->uifont_id, origstr + i) > (startx - x) * 0.25f) break; // 0.25 == scale factor for less sensitivity
}
else {
break; /* unlikely but possible */
@@ -1290,13 +1290,13 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
float cdist, cdist_prev = 0.0f;
short pos_prev;
- const float aspect_sqrt= sqrtf(but->block->aspect);
+ const float aspect_sqrt = sqrtf(but->block->aspect);
but->pos = pos_prev = strlen(origstr) - but->ofs;
while (TRUE) {
/* XXX does not take zoom level into account */
- cdist = startx + aspect_sqrt * BLF_width(fstyle->uifont_id, origstr + but->ofs);
+ cdist = startx + aspect_sqrt *BLF_width(fstyle->uifont_id, origstr + but->ofs);
/* check if position is found */
if (cdist < x) {
@@ -1321,7 +1321,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho
}
}
but->pos += but->ofs;
- if (but->pos<0) but->pos= 0;
+ if (but->pos < 0) but->pos = 0;
}
if (fstyle->kerning == 1)
@@ -1350,25 +1350,25 @@ static int ui_textedit_type_buf(uiBut *but, uiHandleButtonData *data,
const char *utf8_buf, int utf8_buf_len)
{
char *str;
- int len, changed= 0;
+ int len, changed = 0;
- str= data->str;
- len= strlen(str);
+ str = data->str;
+ len = strlen(str);
- if (len-(but->selend - but->selsta)+1 <= data->maxlen) {
- int step= utf8_buf_len;
+ if (len - (but->selend - but->selsta) + 1 <= data->maxlen) {
+ int step = utf8_buf_len;
/* type over the current selection */
if ((but->selend - but->selsta) > 0) {
- changed= ui_textedit_delete_selection(but, data);
- len= strlen(str);
+ changed = ui_textedit_delete_selection(but, data);
+ len = strlen(str);
}
if (len + step < data->maxlen) {
memmove(&str[but->pos + step], &str[but->pos], (len + 1) - but->pos);
memcpy(&str[but->pos], utf8_buf, step * sizeof(char));
but->pos += step;
- changed= 1;
+ changed = 1;
}
}
@@ -1377,7 +1377,7 @@ static int ui_textedit_type_buf(uiBut *but, uiHandleButtonData *data,
static int ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char ascii)
{
- char buf[2]= {ascii, '\0'};
+ char buf[2] = {ascii, '\0'};
if (ui_is_but_utf8(but) && (BLI_str_utf8_size(buf) == -1)) {
printf("%s: entering invalid ascii char into an ascii key (%d)\n",
@@ -1392,17 +1392,17 @@ static int ui_textedit_type_ascii(uiBut *but, uiHandleButtonData *data, char asc
static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, strCursorJumpDirection direction, int select, strCursorJumpType jump)
{
- const char *str= data->str;
- const int len= strlen(str);
- const int pos_prev= but->pos;
- const int has_sel= (but->selend - but->selsta) > 0;
+ const char *str = data->str;
+ const int len = strlen(str);
+ const int pos_prev = but->pos;
+ const int has_sel = (but->selend - but->selsta) > 0;
ui_check_but(but);
/* special case, quit selection and set cursor */
if (has_sel && !select) {
if (jump == STRCUR_JUMP_ALL) {
- but->selsta = but->selend= but->pos = direction ? len : 0;
+ but->selsta = but->selend = but->pos = direction ? len : 0;
}
else {
if (direction) {
@@ -1424,42 +1424,42 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, strCursorJump
if (has_sel) {
if (data->selextend == 0) {
- data->selextend= EXTEND_RIGHT;
+ data->selextend = EXTEND_RIGHT;
}
if (direction) {
if (data->selextend == EXTEND_RIGHT) {
- but->selend= but->pos;
+ but->selend = but->pos;
}
else {
- but->selsta= but->pos;
+ but->selsta = but->pos;
}
}
else {
if (data->selextend == EXTEND_LEFT) {
- but->selsta= but->pos;
+ but->selsta = but->pos;
}
else {
- but->selend= but->pos;
+ but->selend = but->pos;
}
}
if (but->selend < but->selsta) {
SWAP(short, but->selsta, but->selend);
- data->selextend= (data->selextend == EXTEND_RIGHT) ? EXTEND_LEFT : EXTEND_RIGHT;
+ data->selextend = (data->selextend == EXTEND_RIGHT) ? EXTEND_LEFT : EXTEND_RIGHT;
}
} /* new selection */
else {
if (direction) {
- data->selextend= EXTEND_RIGHT;
- but->selend= but->pos;
- but->selsta= pos_prev;
+ data->selextend = EXTEND_RIGHT;
+ but->selend = but->pos;
+ but->selsta = pos_prev;
}
else {
- data->selextend= EXTEND_LEFT;
- but->selend= pos_prev;
- but->selsta= but->pos;
+ data->selextend = EXTEND_LEFT;
+ but->selend = pos_prev;
+ but->selsta = but->pos;
}
}
}
@@ -1468,43 +1468,43 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, strCursorJump
static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int direction, strCursorJumpType jump)
{
- char *str= data->str;
- const int len= strlen(str);
+ char *str = data->str;
+ const int len = strlen(str);
- int changed= 0;
+ int changed = 0;
if (jump == STRCUR_JUMP_ALL) {
- if (len) changed=1;
- str[0]= '\0';
- but->pos= 0;
+ if (len) changed = 1;
+ str[0] = '\0';
+ but->pos = 0;
}
else if (direction) { /* delete */
if ((but->selend - but->selsta) > 0) {
- changed= ui_textedit_delete_selection(but, data);
+ changed = ui_textedit_delete_selection(but, data);
}
- else if (but->pos>=0 && but->pos<len) {
+ else if (but->pos >= 0 && but->pos < len) {
int pos = but->pos;
int step;
BLI_str_cursor_step_utf8(str, len, &pos, direction, jump);
step = pos - but->pos;
memmove(&str[but->pos], &str[but->pos + step], (len + 1) - but->pos);
- changed= 1;
+ changed = 1;
}
}
else { /* backspace */
if (len != 0) {
if ((but->selend - but->selsta) > 0) {
- changed= ui_textedit_delete_selection(but, data);
+ changed = ui_textedit_delete_selection(but, data);
}
- else if (but->pos>0) {
+ else if (but->pos > 0) {
int pos = but->pos;
int step;
BLI_str_cursor_step_utf8(str, len, &pos, direction, jump);
- step= but->pos - pos;
+ step = but->pos - pos;
memmove(&str[but->pos - step], &str[but->pos], (len + 1) - but->pos);
but->pos -= step;
- changed= 1;
+ changed = 1;
}
}
}
@@ -1515,64 +1515,64 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio
static int ui_textedit_autocomplete(bContext *C, uiBut *but, uiHandleButtonData *data)
{
char *str;
- int changed= 1;
+ int changed = 1;
- str= data->str;
+ str = data->str;
if (data->searchbox)
ui_searchbox_autocomplete(C, data->searchbox, but, data->str);
else
but->autocomplete_func(C, str, but->autofunc_arg);
- but->pos= strlen(str);
- but->selsta= but->selend= but->pos;
+ but->pos = strlen(str);
+ but->selsta = but->selend = but->pos;
return changed;
}
static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste, int copy, int cut)
{
- char buf[UI_MAX_DRAW_STR]={0};
+ char buf[UI_MAX_DRAW_STR] = {0};
char *str, *p, *pbuf;
- int len, x, i, changed= 0;
+ int len, x, i, changed = 0;
- str= data->str;
- len= strlen(str);
+ str = data->str;
+ len = strlen(str);
/* paste */
if (paste) {
/* extract the first line from the clipboard */
- p = pbuf= WM_clipboard_text_get(0);
+ p = pbuf = WM_clipboard_text_get(0);
if (p && p[0]) {
unsigned int y;
- i= 0;
- while (*p && *p!='\r' && *p!='\n' && i<UI_MAX_DRAW_STR-1) {
- buf[i++]=*p;
+ i = 0;
+ while (*p && *p != '\r' && *p != '\n' && i < UI_MAX_DRAW_STR - 1) {
+ buf[i++] = *p;
p++;
}
- buf[i]= 0;
+ buf[i] = 0;
/* paste over the current selection */
if ((but->selend - but->selsta) > 0) {
ui_textedit_delete_selection(but, data);
- len= strlen(str);
+ len = strlen(str);
}
- for (y=0; y<strlen(buf); y++)
+ for (y = 0; y < strlen(buf); y++)
{
/* add contents of buffer */
- if (len+1 < data->maxlen) {
- for (x= data->maxlen; x>but->pos; x--)
- str[x]= str[x-1];
- str[but->pos]= buf[y];
+ if (len + 1 < data->maxlen) {
+ for (x = data->maxlen; x > but->pos; x--)
+ str[x] = str[x - 1];
+ str[but->pos] = buf[y];
but->pos++;
len++;
- str[len]= '\0';
+ str[len] = '\0';
}
}
- changed= 1;
+ changed = 1;
}
if (pbuf) {
@@ -1582,8 +1582,8 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste
/* cut & copy */
else if (copy || cut) {
/* copy the contents to the copypaste buffer */
- for (x= but->selsta; x <= but->selend; x++) {
- if (x==but->selend)
+ for (x = but->selsta; x <= but->selend; x++) {
+ if (x == but->selend)
buf[x] = '\0';
else
buf[(x - but->selsta)] = str[x];
@@ -1594,7 +1594,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste
/* for cut only, delete the selection afterwards */
if (cut)
if ((but->selend - but->selsta) > 0)
- changed= ui_textedit_delete_selection(but, data);
+ changed = ui_textedit_delete_selection(but, data);
}
return changed;
@@ -1606,12 +1606,12 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
if (data->str) {
MEM_freeN(data->str);
- data->str= NULL;
+ data->str = NULL;
}
/* retrieve string */
- data->maxlen= ui_get_but_string_max_length(but);
- data->str= MEM_callocN(sizeof(char)*data->maxlen + 1, "textedit str");
+ data->maxlen = ui_get_but_string_max_length(but);
+ data->str = MEM_callocN(sizeof(char) * data->maxlen + 1, "textedit str");
ui_get_but_string(but, data->str, data->maxlen);
if (ELEM3(but->type, NUM, NUMABS, NUMSLI)) {
@@ -1632,8 +1632,8 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
but->selend = len;
/* optional searchbox */
- if (but->type==SEARCH_MENU) {
- data->searchbox= ui_searchbox_create(C, data->region, but);
+ if (but->type == SEARCH_MENU) {
+ data->searchbox = ui_searchbox_create(C, data->region, but);
ui_searchbox_update(C, data->searchbox, but, 1); /* 1= reset */
}
@@ -1646,7 +1646,7 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
{
if (but) {
if (ui_is_but_utf8(but)) {
- int strip= BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr));
+ int strip = BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr));
/* not a file?, strip non utf-8 chars */
if (strip) {
/* wont happen often so isn't that annoying to keep it here for a while */
@@ -1655,15 +1655,15 @@ static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data)
}
if (data->searchbox) {
- if (data->cancel==0)
+ if (data->cancel == 0)
ui_searchbox_apply(but, data->searchbox);
ui_searchbox_free(C, data->searchbox);
- data->searchbox= NULL;
+ data->searchbox = NULL;
}
- but->editstr= NULL;
- but->pos= -1;
+ but->editstr = NULL;
+ but->pos = -1;
}
WM_cursor_restore(CTX_wm_window(C));
@@ -1677,20 +1677,20 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
return;
- for (but= actbut->next; but; but= but->next) {
+ for (but = actbut->next; but; but = but->next) {
if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) {
if (!(but->flag & UI_BUT_DISABLED)) {
- data->postbut= but;
- data->posttype= BUTTON_ACTIVATE_TEXT_EDITING;
+ data->postbut = but;
+ data->posttype = BUTTON_ACTIVATE_TEXT_EDITING;
return;
}
}
}
- for (but= block->buttons.first; but!=actbut; but= but->next) {
+ for (but = block->buttons.first; but != actbut; but = but->next) {
if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) {
if (!(but->flag & UI_BUT_DISABLED)) {
- data->postbut= but;
- data->posttype= BUTTON_ACTIVATE_TEXT_EDITING;
+ data->postbut = but;
+ data->posttype = BUTTON_ACTIVATE_TEXT_EDITING;
return;
}
}
@@ -1705,20 +1705,20 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX))
return;
- for (but= actbut->prev; but; but= but->prev) {
+ for (but = actbut->prev; but; but = but->prev) {
if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) {
if (!(but->flag & UI_BUT_DISABLED)) {
- data->postbut= but;
- data->posttype= BUTTON_ACTIVATE_TEXT_EDITING;
+ data->postbut = but;
+ data->posttype = BUTTON_ACTIVATE_TEXT_EDITING;
return;
}
}
}
- for (but= block->buttons.last; but!=actbut; but= but->prev) {
+ for (but = block->buttons.last; but != actbut; but = but->prev) {
if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) {
if (!(but->flag & UI_BUT_DISABLED)) {
- data->postbut= but;
- data->posttype= BUTTON_ACTIVATE_TEXT_EDITING;
+ data->postbut = but;
+ data->posttype = BUTTON_ACTIVATE_TEXT_EDITING;
return;
}
}
@@ -1728,9 +1728,9 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa
static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
- int mx, my, changed= 0, inbox=0, update= 0, retval= WM_UI_HANDLER_CONTINUE;
+ int mx, my, changed = 0, inbox = 0, update = 0, retval = WM_UI_HANDLER_CONTINUE;
- switch(event->type) {
+ switch (event->type) {
case WHEELUPMOUSE:
case WHEELDOWNMOUSE:
case MOUSEMOVE:
@@ -1740,110 +1740,110 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
break;
case RIGHTMOUSE:
case ESCKEY:
- data->cancel= 1;
- data->escapecancel= 1;
+ data->cancel = 1;
+ data->escapecancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
break;
case LEFTMOUSE: {
/* exit on LMB only on RELEASE for searchbox, to mimic other popups, and allow multiple menu levels */
if (data->searchbox)
- inbox= ui_searchbox_inside(data->searchbox, event->x, event->y);
+ inbox = ui_searchbox_inside(data->searchbox, event->x, event->y);
- if (event->val==KM_PRESS) {
- mx= event->x;
- my= event->y;
+ if (event->val == KM_PRESS) {
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (ui_but_contains_pt(but, mx, my)) {
ui_textedit_set_cursor_pos(but, data, mx);
but->selsta = but->selend = but->pos;
- data->selstartx= mx;
+ data->selstartx = mx;
button_activate_state(C, but, BUTTON_STATE_TEXT_SELECTING);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
- else if (inbox==0) {
+ else if (inbox == 0) {
/* if searchbox, click outside will cancel */
if (data->searchbox)
- data->cancel= data->escapecancel= 1;
+ data->cancel = data->escapecancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
}
else if (inbox) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
break;
}
}
- if (event->val==KM_PRESS) {
+ if (event->val == KM_PRESS) {
switch (event->type) {
case VKEY:
case XKEY:
case CKEY:
if (event->ctrl || event->oskey) {
if (event->type == VKEY)
- changed= ui_textedit_copypaste(but, data, 1, 0, 0);
+ changed = ui_textedit_copypaste(but, data, 1, 0, 0);
else if (event->type == CKEY)
- changed= ui_textedit_copypaste(but, data, 0, 1, 0);
+ changed = ui_textedit_copypaste(but, data, 0, 1, 0);
else if (event->type == XKEY)
- changed= ui_textedit_copypaste(but, data, 0, 0, 1);
+ changed = ui_textedit_copypaste(but, data, 0, 0, 1);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
break;
case RIGHTARROWKEY:
ui_textedit_move(but, data, STRCUR_DIR_NEXT, event->shift, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
break;
case LEFTARROWKEY:
ui_textedit_move(but, data, STRCUR_DIR_PREV, event->shift, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
break;
case DOWNARROWKEY:
if (data->searchbox) {
ui_searchbox_event(C, data->searchbox, but, event);
break;
}
- /* pass on purposedly */
+ /* pass on purposedly */
case ENDKEY:
ui_textedit_move(but, data, STRCUR_DIR_NEXT, event->shift, STRCUR_JUMP_ALL);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
break;
case UPARROWKEY:
if (data->searchbox) {
ui_searchbox_event(C, data->searchbox, but, event);
break;
}
- /* pass on purposedly */
+ /* pass on purposedly */
case HOMEKEY:
ui_textedit_move(but, data, STRCUR_DIR_PREV, event->shift, STRCUR_JUMP_ALL);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
break;
case PADENTER:
case RETKEY:
button_activate_state(C, but, BUTTON_STATE_EXIT);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
break;
case DELKEY:
- changed= ui_textedit_delete(but, data, 1, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
- retval= WM_UI_HANDLER_BREAK;
+ changed = ui_textedit_delete(but, data, 1, event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE);
+ retval = WM_UI_HANDLER_BREAK;
break;
case BACKSPACEKEY:
- changed= ui_textedit_delete(but, data, 0, event->shift ? STRCUR_JUMP_ALL : (event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE));
- retval= WM_UI_HANDLER_BREAK;
+ changed = ui_textedit_delete(but, data, 0, event->shift ? STRCUR_JUMP_ALL : (event->ctrl ? STRCUR_JUMP_DELIM : STRCUR_JUMP_NONE));
+ retval = WM_UI_HANDLER_BREAK;
break;
case TABKEY:
/* there is a key conflict here, we can't tab with autocomplete */
if (but->autocomplete_func || data->searchbox) {
- changed= ui_textedit_autocomplete(C, but, data);
- update= 1; /* do live update for tab key */
+ changed = ui_textedit_autocomplete(C, but, data);
+ update = 1; /* do live update for tab key */
}
/* the hotkey here is not well defined, was G.qual so we check all */
else if (event->shift || event->ctrl || event->alt || event->oskey) {
@@ -1854,53 +1854,53 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
ui_textedit_next_but(block, but, data);
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
break;
}
if ((event->ascii || event->utf8_buf[0]) && (retval == WM_UI_HANDLER_CONTINUE)) {
char ascii = event->ascii;
- const char *utf8_buf= event->utf8_buf;
+ const char *utf8_buf = event->utf8_buf;
/* exception that's useful for number buttons, some keyboard
* numpads have a comma instead of a period */
if (ELEM3(but->type, NUM, NUMABS, NUMSLI)) { /* could use data->min*/
if (event->type == PADPERIOD && ascii == ',') {
ascii = '.';
- utf8_buf= NULL; /* force ascii fallback */
+ utf8_buf = NULL; /* force ascii fallback */
}
}
if (utf8_buf && utf8_buf[0]) {
- int utf8_buf_len= BLI_str_utf8_size(utf8_buf);
+ int utf8_buf_len = BLI_str_utf8_size(utf8_buf);
/* keep this printf until utf8 is well tested */
if (utf8_buf_len != 1) {
printf("%s: utf8 char '%.*s'\n", __func__, utf8_buf_len, utf8_buf);
}
// strcpy(utf8_buf, "12345");
- changed= ui_textedit_type_buf(but, data, event->utf8_buf, utf8_buf_len);
+ changed = ui_textedit_type_buf(but, data, event->utf8_buf, utf8_buf_len);
}
else {
- changed= ui_textedit_type_ascii(but, data, ascii);
+ changed = ui_textedit_type_ascii(but, data, ascii);
}
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
/* textbutton with magnifier icon: do live update for search button */
- if (but->icon==ICON_VIEWZOOM)
- update= 1;
+ if (but->icon == ICON_VIEWZOOM)
+ update = 1;
}
if (changed) {
/* only update when typing for TAB key */
if (update && data->interactive) ui_apply_button(C, block, but, data, 1);
else ui_check_but(but);
- but->changed= TRUE;
+ but->changed = TRUE;
if (data->searchbox)
- ui_searchbox_update(C, data->searchbox, but, 1); /* 1 = reset */
+ ui_searchbox_update(C, data->searchbox, but, 1); /* 1 = reset */
}
if (changed || (retval == WM_UI_HANDLER_BREAK))
@@ -1909,22 +1909,22 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle
static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
- int mx, my, retval= WM_UI_HANDLER_CONTINUE;
+ int mx, my, retval = WM_UI_HANDLER_CONTINUE;
- switch(event->type) {
+ switch (event->type) {
case MOUSEMOVE: {
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
ui_textedit_set_cursor_select(but, data, mx);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
break;
}
case LEFTMOUSE:
if (event->val == KM_RELEASE)
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
break;
}
@@ -1939,49 +1939,49 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u
static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data)
{
if (but->type == BUT_CURVE) {
- but->editcumap= (CurveMapping*)but->poin;
+ but->editcumap = (CurveMapping *)but->poin;
}
else if (but->type == BUT_COLORBAND) {
- data->coba= (ColorBand*)but->poin;
- but->editcoba= data->coba;
+ data->coba = (ColorBand *)but->poin;
+ but->editcoba = data->coba;
}
else if (ELEM3(but->type, BUT_NORMAL, HSVCUBE, HSVCIRCLE)) {
ui_get_but_vectorf(but, data->origvec);
copy_v3_v3(data->vec, data->origvec);
- but->editvec= data->vec;
+ but->editvec = data->vec;
}
else {
float softrange, softmin, softmax;
- data->startvalue= ui_get_but_val(but);
- data->origvalue= data->startvalue;
- data->value= data->origvalue;
- but->editval= &data->value;
+ data->startvalue = ui_get_but_val(but);
+ data->origvalue = data->startvalue;
+ data->value = data->origvalue;
+ but->editval = &data->value;
- softmin= but->softmin;
- softmax= but->softmax;
- softrange= softmax - softmin;
+ softmin = but->softmin;
+ softmax = but->softmax;
+ softrange = softmax - softmin;
- data->dragfstart= (softrange == 0.0f)? 0.0f: ((float)data->value - softmin)/softrange;
- data->dragf= data->dragfstart;
+ data->dragfstart = (softrange == 0.0f) ? 0.0f : ((float)data->value - softmin) / softrange;
+ data->dragf = data->dragfstart;
}
- data->dragchange= 0;
- data->draglock= 1;
+ data->dragchange = 0;
+ data->draglock = 1;
}
static void ui_numedit_end(uiBut *but, uiHandleButtonData *data)
{
- but->editval= NULL;
- but->editvec= NULL;
- but->editcoba= NULL;
- but->editcumap= NULL;
+ but->editval = NULL;
+ but->editvec = NULL;
+ but->editcoba = NULL;
+ but->editcumap = NULL;
- data->dragstartx= 0;
- data->draglastx= 0;
- data->dragchange= 0;
- data->dragcbd= NULL;
- data->dragsel= 0;
+ data->dragstartx = 0;
+ data->draglastx = 0;
+ data->dragchange = 0;
+ data->dragcbd = NULL;
+ data->dragsel = 0;
}
static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data)
@@ -1996,64 +1996,64 @@ static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data)
{
- uiBlockCreateFunc func= NULL;
- uiBlockHandleCreateFunc handlefunc= NULL;
- uiMenuCreateFunc menufunc= NULL;
- char *menustr= NULL;
- void *arg= NULL;
+ uiBlockCreateFunc func = NULL;
+ uiBlockHandleCreateFunc handlefunc = NULL;
+ uiMenuCreateFunc menufunc = NULL;
+ char *menustr = NULL;
+ void *arg = NULL;
- switch(but->type) {
+ switch (but->type) {
case BLOCK:
case PULLDOWN:
if (but->menu_create_func) {
- menufunc= but->menu_create_func;
- arg= but->poin;
+ menufunc = but->menu_create_func;
+ arg = but->poin;
}
else {
- func= but->block_create_func;
- arg= but->poin?but->poin:but->func_argN;
+ func = but->block_create_func;
+ arg = but->poin ? but->poin : but->func_argN;
}
break;
case MENU:
if (but->menu_create_func) {
- menufunc= but->menu_create_func;
- arg= but->poin;
+ menufunc = but->menu_create_func;
+ arg = but->poin;
}
else {
- data->origvalue= ui_get_but_val(but);
- data->value= data->origvalue;
- but->editval= &data->value;
+ data->origvalue = ui_get_but_val(but);
+ data->value = data->origvalue;
+ but->editval = &data->value;
- menustr= but->str;
+ menustr = but->str;
}
break;
case ICONROW:
- menufunc= ui_block_func_ICONROW;
- arg= but;
+ menufunc = ui_block_func_ICONROW;
+ arg = but;
break;
case ICONTEXTROW:
- menufunc= ui_block_func_ICONTEXTROW;
- arg= but;
+ menufunc = ui_block_func_ICONTEXTROW;
+ arg = but;
break;
case COL:
ui_get_but_vectorf(but, data->origvec);
copy_v3_v3(data->vec, data->origvec);
- but->editvec= data->vec;
+ but->editvec = data->vec;
- handlefunc= ui_block_func_COL;
- arg= but;
+ handlefunc = ui_block_func_COL;
+ arg = but;
break;
}
if (func || handlefunc) {
- data->menu= ui_popup_block_create(C, data->region, but, func, handlefunc, arg);
+ data->menu = ui_popup_block_create(C, data->region, but, func, handlefunc, arg);
if (but->block->handle)
- data->menu->popup= but->block->handle->popup;
+ data->menu->popup = but->block->handle->popup;
}
else if (menufunc || menustr) {
- data->menu= ui_popup_menu_create(C, data->region, but, menufunc, arg, menustr);
+ data->menu = ui_popup_menu_create(C, data->region, but, menufunc, arg, menustr);
if (but->block->handle)
- data->menu->popup= but->block->handle->popup;
+ data->menu->popup = but->block->handle->popup;
}
/* this makes adjacent blocks auto open from now on */
@@ -2063,15 +2063,15 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data
static void ui_blockopen_end(bContext *C, uiBut *but, uiHandleButtonData *data)
{
if (but) {
- but->editval= NULL;
- but->editvec= NULL;
+ but->editval = NULL;
+ but->editvec = NULL;
- but->block->auto_open_last= PIL_check_seconds_timer();
+ but->block->auto_open_last = PIL_check_seconds_timer();
}
if (data->menu) {
ui_popup_block_free(C, data->menu);
- data->menu= NULL;
+ data->menu = NULL;
}
}
@@ -2080,7 +2080,7 @@ static void ui_blockopen_end(bContext *C, uiBut *but, uiHandleButtonData *data)
static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type == LEFTMOUSE && event->val==KM_PRESS) {
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_WAIT_RELEASE);
return WM_UI_HANDLER_BREAK;
}
@@ -2088,15 +2088,15 @@ static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEv
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
- else if (ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS) {
+ else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_WAIT_FLASH);
return WM_UI_HANDLER_BREAK;
}
}
else if (data->state == BUTTON_STATE_WAIT_RELEASE) {
- if (event->type == LEFTMOUSE && event->val!=KM_PRESS) {
+ if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
if (!(but->flag & UI_SELECT))
- data->cancel= 1;
+ data->cancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
@@ -2108,9 +2108,9 @@ static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEv
static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
- but->drawstr[0]= 0;
- but->modifier_key= 0;
+ if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
+ but->drawstr[0] = 0;
+ but->modifier_key = 0;
button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT);
return WM_UI_HANDLER_BREAK;
}
@@ -2120,14 +2120,14 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
if (event->type == MOUSEMOVE)
return WM_UI_HANDLER_CONTINUE;
- if (event->type == LEFTMOUSE && event->val==KM_PRESS) {
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
/* only cancel if click outside the button */
if (ui_mouse_inside_button(but->active->region, but, event->x, event->y) == 0) {
/* data->cancel doesnt work, this button opens immediate */
if (but->flag & UI_BUT_IMMEDIATE)
ui_set_but_val(but, 0);
else
- data->cancel= 1;
+ data->cancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
@@ -2136,27 +2136,27 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
/* always set */
but->modifier_key = 0;
if (event->shift) but->modifier_key |= KM_SHIFT;
- if (event->alt) but->modifier_key |= KM_ALT;
- if (event->ctrl) but->modifier_key |= KM_CTRL;
+ if (event->alt) but->modifier_key |= KM_ALT;
+ if (event->ctrl) but->modifier_key |= KM_CTRL;
if (event->oskey) but->modifier_key |= KM_OSKEY;
ui_check_but(but);
ED_region_tag_redraw(data->region);
- if (event->val==KM_PRESS) {
+ if (event->val == KM_PRESS) {
if (ISHOTKEY(event->type)) {
if (WM_key_event_string(event->type)[0])
ui_set_but_val(but, event->type);
else
- data->cancel= 1;
+ data->cancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
else if (event->type == ESCKEY) {
- data->cancel= 1;
- data->escapecancel= 1;
+ data->cancel = 1;
+ data->escapecancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -2169,7 +2169,7 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data
static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
+ if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT);
return WM_UI_HANDLER_BREAK;
}
@@ -2178,11 +2178,11 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, w
if (event->type == MOUSEMOVE)
return WM_UI_HANDLER_CONTINUE;
- if (event->val==KM_PRESS) {
+ if (event->val == KM_PRESS) {
if (WM_key_event_string(event->type)[0])
ui_set_but_val(but, event->type);
else
- data->cancel= 1;
+ data->cancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -2194,8 +2194,8 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, w
static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN) && event->val==KM_PRESS) {
- if (but->dt == UI_EMBOSSN && !event->ctrl);
+ if (ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN) && event->val == KM_PRESS) {
+ if (but->dt == UI_EMBOSSN && !event->ctrl) ;
else {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
return WM_UI_HANDLER_BREAK;
@@ -2217,9 +2217,9 @@ static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
- data->togdual= event->ctrl;
- data->togonly= !event->shift;
+ if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
+ data->togdual = event->ctrl;
+ data->togonly = !event->shift;
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
@@ -2233,19 +2233,19 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
if (data->state == BUTTON_STATE_HIGHLIGHT) {
/* first handle click on icondrag type button */
- if (event->type==LEFTMOUSE && but->dragpoin) {
+ if (event->type == LEFTMOUSE && but->dragpoin) {
if (ui_but_mouse_inside_icon(but, data->region, event)) {
/* tell the button to wait and keep checking further events to
* see if it should start dragging */
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
- data->dragstartx= event->x;
- data->dragstarty= event->y;
+ data->dragstartx = event->x;
+ data->dragstarty = event->y;
return WM_UI_HANDLER_CONTINUE;
}
}
- if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
+ if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
int ret = WM_UI_HANDLER_BREAK;
/* XXX (a bit ugly) Special case handling for filebrowser drag button */
if (but->dragpoin && but->imb && ui_but_mouse_inside_icon(but, data->region, event)) {
@@ -2265,7 +2265,7 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
/* If the mouse has been pressed and released, getting to
* this point without triggering a drag, then clear the
* drag state for this button and continue to pass on the event */
- if (event->type==LEFTMOUSE && event->val==KM_RELEASE) {
+ if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_CONTINUE;
}
@@ -2281,18 +2281,18 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
/* var names match ui_numedit_but_NUM */
static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, float softmax, float softrange, int snap)
{
- if (tempf==softmin || tempf==softmax || snap==0) {
+ if (tempf == softmin || tempf == softmax || snap == 0) {
/* pass */
}
else {
- float fac= 1.0f;
+ float fac = 1.0f;
if (ui_is_but_unit(but)) {
- UnitSettings *unit= but->block->unit;
- int unit_type= uiButGetUnitType(but)>>16;
+ UnitSettings *unit = but->block->unit;
+ int unit_type = uiButGetUnitType(but) >> 16;
if (bUnit_IsValid(unit->system, unit_type)) {
- fac= (float)bUnit_BaseScalar(unit->system, unit_type);
+ fac = (float)bUnit_BaseScalar(unit->system, unit_type);
if (ELEM3(unit_type, B_UNIT_LENGTH, B_UNIT_AREA, B_UNIT_VOLUME)) {
fac /= unit->scale_length;
}
@@ -2307,15 +2307,15 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa
softrange /= fac;
}
- if (snap==1) {
- if (softrange < 2.10f) tempf= 0.1f*floorf(10.0f*tempf);
- else if (softrange < 21.0f) tempf= floorf(tempf);
- else tempf= 10.0f*floorf(tempf/10.0f);
+ if (snap == 1) {
+ if (softrange < 2.10f) tempf = 0.1f * floorf(10.0f * tempf);
+ else if (softrange < 21.0f) tempf = floorf(tempf);
+ else tempf = 10.0f * floorf(tempf / 10.0f);
}
- else if (snap==2) {
- if (softrange < 2.10f) tempf= 0.01f*floorf(100.0f*tempf);
- else if (softrange < 21.0f) tempf= 0.1f*floorf(10.0f*tempf);
- else tempf= floor(tempf);
+ else if (snap == 2) {
+ if (softrange < 2.10f) tempf = 0.01f * floorf(100.0f * tempf);
+ else if (softrange < 21.0f) tempf = 0.1f * floorf(10.0f * tempf);
+ else tempf = floor(tempf);
}
if (fac != 1.0f)
@@ -2327,18 +2327,18 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa
static float ui_numedit_apply_snap(int temp, float softmin, float softmax, int snap)
{
- if (temp==softmin || temp==softmax)
+ if (temp == softmin || temp == softmax)
return temp;
- switch(snap) {
- case 0:
- break;
- case 1:
- temp= 10*(temp/10);
- break;
- case 2:
- temp= 100*(temp/100);
- break;
+ switch (snap) {
+ case 0:
+ break;
+ case 1:
+ temp = 10 * (temp / 10);
+ break;
+ case 2:
+ temp = 100 * (temp / 100);
+ break;
}
return temp;
@@ -2347,7 +2347,7 @@ static float ui_numedit_apply_snap(int temp, float softmin, float softmax, int s
static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, int snap, int mx)
{
float deler, tempf, softmin, softmax, softrange;
- int lvalue, temp, changed= 0;
+ int lvalue, temp, changed = 0;
if (mx == data->draglastx)
return changed;
@@ -2355,93 +2355,93 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
/* drag-lock - prevent unwanted scroll adjustments */
/* change value (now 3) to adjust threshold in pixels */
if (data->draglock) {
- if (abs(mx-data->dragstartx) <= 3)
+ if (abs(mx - data->dragstartx) <= 3)
return changed;
- data->draglock= 0;
- data->dragstartx= mx; /* ignore mouse movement within drag-lock */
+ data->draglock = 0;
+ data->dragstartx = mx; /* ignore mouse movement within drag-lock */
}
- softmin= but->softmin;
- softmax= but->softmax;
- softrange= softmax - softmin;
+ softmin = but->softmin;
+ softmax = but->softmax;
+ softrange = softmax - softmin;
if (ui_is_a_warp_but(but)) {
/* Mouse location isn't screen clamped to the screen so use a linear mapping
* 2px == 1-int, or 1px == 1-ClickStep */
if (ui_is_but_float(but)) {
- fac *= 0.01f*but->a1;
+ fac *= 0.01f * but->a1;
tempf = (float)data->startvalue + ((float)(mx - data->dragstartx) * fac);
- tempf= ui_numedit_apply_snapf(but, tempf, softmin, softmax, softrange, snap);
+ tempf = ui_numedit_apply_snapf(but, tempf, softmin, softmax, softrange, snap);
-#if 1 /* fake moving the click start, nicer for dragging back after passing the limit */
+#if 1 /* fake moving the click start, nicer for dragging back after passing the limit */
if (tempf < softmin) {
- data->dragstartx -= (softmin-tempf) / fac;
- tempf= softmin;
+ data->dragstartx -= (softmin - tempf) / fac;
+ tempf = softmin;
}
else if (tempf > softmax) {
- data->dragstartx += (tempf-softmax) / fac;
- tempf= softmax;
+ data->dragstartx += (tempf - softmax) / fac;
+ tempf = softmax;
}
#else
CLAMP(tempf, softmin, softmax);
#endif
if (tempf != (float)data->value) {
- data->dragchange= 1;
- data->value= tempf;
- changed= 1;
+ data->dragchange = 1;
+ data->value = tempf;
+ changed = 1;
}
}
else {
- if (softrange > 256) fac= 1.0; /* 1px == 1 */
- else if (softrange > 32) fac= 1.0/2.0; /* 2px == 1 */
- else fac= 1.0/16.0; /* 16px == 1? */
+ if (softrange > 256) fac = 1.0; /* 1px == 1 */
+ else if (softrange > 32) fac = 1.0 / 2.0; /* 2px == 1 */
+ else fac = 1.0 / 16.0; /* 16px == 1? */
- temp= data->startvalue + (((double)mx - data->dragstartx) * (double)fac);
- temp= ui_numedit_apply_snap(temp, softmin, softmax, snap);
+ temp = data->startvalue + (((double)mx - data->dragstartx) * (double)fac);
+ temp = ui_numedit_apply_snap(temp, softmin, softmax, snap);
-#if 1 /* fake moving the click start, nicer for dragging back after passing the limit */
+#if 1 /* fake moving the click start, nicer for dragging back after passing the limit */
if (temp < softmin) {
- data->dragstartx -= (softmin-temp) / fac;
- temp= softmin;
+ data->dragstartx -= (softmin - temp) / fac;
+ temp = softmin;
}
else if (temp > softmax) {
- data->dragstartx += (temp-softmax) / fac;
- temp= softmax;
+ data->dragstartx += (temp - softmax) / fac;
+ temp = softmax;
}
#else
CLAMP(temp, softmin, softmax);
#endif
if (temp != data->value) {
- data->dragchange= 1;
- data->value= temp;
- changed= 1;
+ data->dragchange = 1;
+ data->value = temp;
+ changed = 1;
}
}
- data->draglastx= mx;
+ data->draglastx = mx;
}
else {
/* Use a non-linear mapping of the mouse drag especially for large floats (normal behavior) */
- deler= 500;
+ deler = 500;
if (!ui_is_but_float(but)) {
/* prevent large ranges from getting too out of control */
if (softrange > 600) deler = powf(softrange, 0.75);
- if (softrange < 100) deler= 200.0;
- if (softrange < 25) deler= 50.0;
+ if (softrange < 100) deler = 200.0;
+ if (softrange < 25) deler = 50.0;
}
deler /= fac;
if (softrange > 11) {
/* non linear change in mouse input- good for high precicsion */
- data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabsf(data->dragstartx-mx)*0.002f);
+ data->dragf += (((float)(mx - data->draglastx)) / deler) * (fabsf(data->dragstartx - mx) * 0.002f);
}
else if (softrange > 129) { /* only scale large int buttons */
/* non linear change in mouse input- good for high precicsionm ints need less fine tuning */
- data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabsf(data->dragstartx-mx)*0.004f);
+ data->dragf += (((float)(mx - data->draglastx)) / deler) * (fabsf(data->dragstartx - mx) * 0.004f);
}
else {
/*no scaling */
@@ -2449,34 +2449,34 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
}
CLAMP(data->dragf, 0.0f, 1.0f);
- data->draglastx= mx;
- tempf= (softmin + data->dragf*softrange);
+ data->draglastx = mx;
+ tempf = (softmin + data->dragf * softrange);
if (!ui_is_but_float(but)) {
- temp= floorf(tempf + 0.5f);
+ temp = floorf(tempf + 0.5f);
- temp= ui_numedit_apply_snap(temp, softmin, softmax, snap);
+ temp = ui_numedit_apply_snap(temp, softmin, softmax, snap);
CLAMP(temp, softmin, softmax);
- lvalue= (int)data->value;
+ lvalue = (int)data->value;
if (temp != lvalue) {
- data->dragchange= 1;
- data->value= (double)temp;
- changed= 1;
+ data->dragchange = 1;
+ data->value = (double)temp;
+ changed = 1;
}
}
else {
- temp= 0;
- tempf= ui_numedit_apply_snapf(but, tempf, softmin, softmax, softrange, snap);
+ temp = 0;
+ tempf = ui_numedit_apply_snapf(but, tempf, softmin, softmax, softrange, snap);
CLAMP(tempf, softmin, softmax);
if (tempf != (float)data->value) {
- data->dragchange= 1;
- data->value= tempf;
- changed= 1;
+ data->dragchange = 1;
+ data->value = tempf;
+ changed = 1;
}
}
}
@@ -2487,81 +2487,81 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i
static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
- int mx, my; /* mouse location scaled to fit the UI */
+ int mx, my; /* mouse location scaled to fit the UI */
int screen_mx, screen_my; /* mouse location kept at screen pixel coords */
- int click= 0;
- int retval= WM_UI_HANDLER_CONTINUE;
+ int click = 0;
+ int retval = WM_UI_HANDLER_CONTINUE;
- mx= screen_mx= event->x;
- my= screen_my= event->y;
+ mx = screen_mx = event->x;
+ my = screen_my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
/* XXX hardcoded keymap check.... */
if (event->type == WHEELDOWNMOUSE && event->alt) {
- mx= but->x1;
- click= 1;
+ mx = but->x1;
+ click = 1;
}
else if (event->type == WHEELUPMOUSE && event->alt) {
- mx= but->x2;
- click= 1;
+ mx = but->x2;
+ click = 1;
}
- else if (event->val==KM_PRESS) {
+ else if (event->val == KM_PRESS) {
if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->ctrl) {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
else if (event->type == LEFTMOUSE) {
- data->dragstartx= data->draglastx= ui_is_a_warp_but(but) ? screen_mx:mx;
+ data->dragstartx = data->draglastx = ui_is_a_warp_but(but) ? screen_mx : mx;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
- else if (ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS)
- click= 1;
- else if (event->type == MINUSKEY && event->val==KM_PRESS) {
+ else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS)
+ click = 1;
+ else if (event->type == MINUSKEY && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
data->value = -data->value;
button_activate_state(C, but, BUTTON_STATE_EXIT);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
}
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == ESCKEY) {
- data->cancel= 1;
- data->escapecancel= 1;
+ data->cancel = 1;
+ data->escapecancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else if (event->type == LEFTMOUSE && event->val!=KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
if (data->dragchange)
button_activate_state(C, but, BUTTON_STATE_EXIT);
else
- click= 1;
+ click = 1;
}
else if (event->type == MOUSEMOVE) {
float fac;
int snap;
- fac= 1.0f;
+ fac = 1.0f;
if (event->shift) fac /= 10.0f;
if (event->alt) fac /= 20.0f;
- snap= (event->ctrl)? (event->shift)? 2: 1: 0;
+ snap = (event->ctrl) ? (event->shift) ? 2 : 1 : 0;
- if (ui_numedit_but_NUM(but, data, fac, snap, (ui_is_a_warp_but(but) ? screen_mx:mx)))
+ if (ui_numedit_but_NUM(but, data, fac, snap, (ui_is_a_warp_but(but) ? screen_mx : mx)))
ui_numedit_apply(C, block, but, data);
}
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
else if (data->state == BUTTON_STATE_TEXT_EDITING) {
ui_do_but_textedit(C, block, but, data, event);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
else if (data->state == BUTTON_STATE_TEXT_SELECTING) {
ui_do_but_textedit_select(C, block, but, data, event);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
if (click) {
@@ -2570,29 +2570,29 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
float tempf, softmin, softmax;
int temp;
- softmin= but->softmin;
- softmax= but->softmax;
+ softmin = but->softmin;
+ softmax = but->softmax;
if (!ui_is_but_float(but)) {
- if (mx < (but->x1 + (but->x2 - but->x1)/3 - 3)) {
+ if (mx < (but->x1 + (but->x2 - but->x1) / 3 - 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
- temp= (int)data->value - 1;
- if (temp>=softmin && temp<=softmax)
- data->value= (double)temp;
+ temp = (int)data->value - 1;
+ if (temp >= softmin && temp <= softmax)
+ data->value = (double)temp;
else
- data->cancel= 1;
+ data->cancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else if (mx > (but->x1 + (2*(but->x2 - but->x1)/3) + 3)) {
+ else if (mx > (but->x1 + (2 * (but->x2 - but->x1) / 3) + 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
- temp= (int)data->value + 1;
- if (temp>=softmin && temp<=softmax)
- data->value= (double)temp;
+ temp = (int)data->value + 1;
+ if (temp >= softmin && temp <= softmax)
+ data->value = (double)temp;
else
- data->cancel= 1;
+ data->cancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -2600,21 +2600,21 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
}
else {
- if (mx < (but->x1 + (but->x2 - but->x1)/3 - 3)) {
+ if (mx < (but->x1 + (but->x2 - but->x1) / 3 - 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
- tempf= (float)data->value - 0.01f * but->a1;
+ tempf = (float)data->value - 0.01f * but->a1;
if (tempf < softmin) tempf = softmin;
- data->value= tempf;
+ data->value = tempf;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else if (mx > but->x1 + (2*((but->x2 - but->x1)/3) + 3)) {
+ else if (mx > but->x1 + (2 * ((but->x2 - but->x1) / 3) + 3)) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
- tempf= (float)data->value + 0.01f * but->a1;
+ tempf = (float)data->value + 0.01f * but->a1;
if (tempf > softmax) tempf = softmax;
- data->value= tempf;
+ data->value = tempf;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
@@ -2622,7 +2622,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
}
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
return retval;
@@ -2631,70 +2631,70 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, int ctrl, int mx)
{
float deler, f, tempf, softmin, softmax, softrange;
- int temp, lvalue, changed= 0;
+ int temp, lvalue, changed = 0;
- softmin= but->softmin;
- softmax= but->softmax;
- softrange= softmax - softmin;
+ softmin = but->softmin;
+ softmax = but->softmax;
+ softrange = softmax - softmin;
- if (but->type==NUMSLI) deler= ((but->x2-but->x1) - 5.0f*but->aspect);
- else if (but->type==HSVSLI) deler= ((but->x2-but->x1)/2.0f - 5.0f*but->aspect);
- else if (but->type==SCROLL) {
- int horizontal= (but->x2 - but->x1 > but->y2 - but->y1);
- float size= (horizontal)? (but->x2-but->x1): -(but->y2-but->y1);
- deler= size*(but->softmax - but->softmin)/(but->softmax - but->softmin + but->a1);
+ if (but->type == NUMSLI) deler = ((but->x2 - but->x1) - 5.0f * but->aspect);
+ else if (but->type == HSVSLI) deler = ((but->x2 - but->x1) / 2.0f - 5.0f * but->aspect);
+ else if (but->type == SCROLL) {
+ int horizontal = (but->x2 - but->x1 > but->y2 - but->y1);
+ float size = (horizontal) ? (but->x2 - but->x1) : -(but->y2 - but->y1);
+ deler = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1);
}
- else deler= (but->x2-but->x1- 5.0f*but->aspect);
+ else deler = (but->x2 - but->x1 - 5.0f * but->aspect);
- f= (float)(mx-data->dragstartx)/deler + data->dragfstart;
+ f = (float)(mx - data->dragstartx) / deler + data->dragfstart;
if (shift)
- f= (f-data->dragfstart)/10.0f + data->dragfstart;
+ f = (f - data->dragfstart) / 10.0f + data->dragfstart;
CLAMP(f, 0.0f, 1.0f);
- tempf= softmin + f*softrange;
- temp= floorf(tempf+0.5f);
+ tempf = softmin + f * softrange;
+ temp = floorf(tempf + 0.5f);
if (ctrl) {
- if (tempf==softmin || tempf==softmax);
+ if (tempf == softmin || tempf == softmax) ;
else if (ui_is_but_float(but)) {
if (shift) {
- if (tempf==softmin || tempf==softmax);
- else if (softmax-softmin < 2.10f) tempf= 0.01f * floorf(100.0f*tempf);
- else if (softmax-softmin < 21.0f) tempf= 0.1f * floorf(10.0f*tempf);
- else tempf= floorf(tempf);
+ if (tempf == softmin || tempf == softmax) ;
+ else if (softmax - softmin < 2.10f) tempf = 0.01f * floorf(100.0f * tempf);
+ else if (softmax - softmin < 21.0f) tempf = 0.1f * floorf(10.0f * tempf);
+ else tempf = floorf(tempf);
}
else {
- if (softmax-softmin < 2.10f) tempf= 0.1f * floorf(10.0f*tempf);
- else if (softmax-softmin < 21.0f) tempf= floorf(tempf);
- else tempf= 10.0f*floorf(tempf/10.0f);
+ if (softmax - softmin < 2.10f) tempf = 0.1f * floorf(10.0f * tempf);
+ else if (softmax - softmin < 21.0f) tempf = floorf(tempf);
+ else tempf = 10.0f * floorf(tempf / 10.0f);
}
}
else {
- temp= 10*(temp/10);
- tempf= temp;
+ temp = 10 * (temp / 10);
+ tempf = temp;
}
}
if (!ui_is_but_float(but)) {
- lvalue= floor(data->value+0.5);
+ lvalue = floor(data->value + 0.5);
CLAMP(temp, softmin, softmax);
if (temp != lvalue) {
- data->value= temp;
- data->dragchange= 1;
- changed= 1;
+ data->value = temp;
+ data->dragchange = 1;
+ changed = 1;
}
}
else {
CLAMP(tempf, softmin, softmax);
if (tempf != (float)data->value) {
- data->value= tempf;
- data->dragchange= 1;
- changed= 1;
+ data->value = tempf;
+ data->dragchange = 1;
+ changed = 1;
}
}
@@ -2703,27 +2703,27 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i
static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
- int mx, my, click= 0;
- int retval= WM_UI_HANDLER_CONTINUE;
+ int mx, my, click = 0;
+ int retval = WM_UI_HANDLER_CONTINUE;
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
/* XXX hardcoded keymap check.... */
if (event->type == WHEELDOWNMOUSE && event->alt) {
- mx= but->x1;
- click= 2;
+ mx = but->x1;
+ click = 2;
}
else if (event->type == WHEELUPMOUSE && event->alt) {
- mx= but->x2;
- click= 2;
+ mx = but->x2;
+ click = 2;
}
- else if (event->val==KM_PRESS) {
+ else if (event->val == KM_PRESS) {
if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->ctrl) {
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
/* alt-click on sides to get "arrows" like in NUM buttons, and match wheel usage above */
else if (event->type == LEFTMOUSE && event->alt) {
@@ -2735,101 +2735,101 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
mx = but->x2;
}
else if (event->type == LEFTMOUSE) {
- data->dragstartx= mx;
- data->draglastx= mx;
+ data->dragstartx = mx;
+ data->draglastx = mx;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
- else if (ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS)
- click= 1;
- else if (event->type == MINUSKEY && event->val==KM_PRESS) {
+ else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS)
+ click = 1;
+ else if (event->type == MINUSKEY && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
data->value = -data->value;
button_activate_state(C, but, BUTTON_STATE_EXIT);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
}
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == ESCKEY) {
- data->cancel= 1;
- data->escapecancel= 1;
+ data->cancel = 1;
+ data->escapecancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else if (event->type == LEFTMOUSE && event->val!=KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
if (data->dragchange)
button_activate_state(C, but, BUTTON_STATE_EXIT);
else
- click= 1;
+ click = 1;
}
else if (event->type == MOUSEMOVE) {
if (ui_numedit_but_SLI(but, data, event->shift, event->ctrl, mx))
ui_numedit_apply(C, block, but, data);
}
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
else if (data->state == BUTTON_STATE_TEXT_EDITING) {
ui_do_but_textedit(C, block, but, data, event);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
else if (data->state == BUTTON_STATE_TEXT_SELECTING) {
ui_do_but_textedit_select(C, block, but, data, event);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
if (click) {
- if (click==2) {
+ if (click == 2) {
/* nudge slider to the left or right */
float f, tempf, softmin, softmax, softrange;
int temp;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
- softmin= but->softmin;
- softmax= but->softmax;
- softrange= softmax - softmin;
+ softmin = but->softmin;
+ softmax = but->softmax;
+ softrange = softmax - softmin;
- tempf= data->value;
- temp= (int)data->value;
+ tempf = data->value;
+ temp = (int)data->value;
#if 0
- if (but->type==SLI) {
- f= (float)(mx-but->x1)/(but->x2-but->x1); /* same as below */
+ if (but->type == SLI) {
+ f = (float)(mx - but->x1) / (but->x2 - but->x1); /* same as below */
}
else
#endif
{
- f= (float)(mx- but->x1)/(but->x2-but->x1);
+ f = (float)(mx - but->x1) / (but->x2 - but->x1);
}
- f= softmin + f*softrange;
+ f = softmin + f * softrange;
if (!ui_is_but_float(but)) {
- if (f<temp) temp--;
+ if (f < temp) temp--;
else temp++;
- if (temp>=softmin && temp<=softmax)
- data->value= temp;
+ if (temp >= softmin && temp <= softmax)
+ data->value = temp;
else
- data->cancel= 1;
+ data->cancel = 1;
}
else {
- if (f<tempf) tempf -= 0.01f;
+ if (f < tempf) tempf -= 0.01f;
else tempf += 0.01f;
- if (tempf>=softmin && tempf<=softmax)
- data->value= tempf;
+ if (tempf >= softmin && tempf <= softmax)
+ data->value = tempf;
else
- data->cancel= 1;
+ data->cancel = 1;
}
button_activate_state(C, but, BUTTON_STATE_EXIT);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
else {
/* edit the value directly */
button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
}
@@ -2839,49 +2839,49 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton
static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
int mx, my /*, click= 0 */;
- int retval= WM_UI_HANDLER_CONTINUE;
- int horizontal= (but->x2 - but->x1 > but->y2 - but->y1);
+ int retval = WM_UI_HANDLER_CONTINUE;
+ int horizontal = (but->x2 - but->x1 > but->y2 - but->y1);
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->val==KM_PRESS) {
+ if (event->val == KM_PRESS) {
if (event->type == LEFTMOUSE) {
if (horizontal) {
- data->dragstartx= mx;
- data->draglastx= mx;
+ data->dragstartx = mx;
+ data->draglastx = mx;
}
else {
- data->dragstartx= my;
- data->draglastx= my;
+ data->dragstartx = my;
+ data->draglastx = my;
}
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
/* UNUSED - otherwise code is ok, add back if needed */
#if 0
- else if (ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS)
- click= 1;
+ else if (ELEM(event->type, PADENTER, RETKEY) && event->val == KM_PRESS)
+ click = 1;
#endif
}
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == ESCKEY) {
- data->cancel= 1;
- data->escapecancel= 1;
+ data->cancel = 1;
+ data->escapecancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else if (event->type == LEFTMOUSE && event->val!=KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (event->type == MOUSEMOVE) {
- if (ui_numedit_but_SLI(but, data, 0, 0, (horizontal)? mx: my))
+ if (ui_numedit_but_SLI(but, data, 0, 0, (horizontal) ? mx : my))
ui_numedit_apply(C, block, but, data);
}
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
return retval;
@@ -2894,24 +2894,24 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm
if (data->state == BUTTON_STATE_HIGHLIGHT) {
/* first handle click on icondrag type button */
- if (event->type==LEFTMOUSE && but->dragpoin && event->val==KM_PRESS) {
+ if (event->type == LEFTMOUSE && but->dragpoin && event->val == KM_PRESS) {
if (ui_but_mouse_inside_icon(but, data->region, event)) {
button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG);
- data->dragstartx= event->x;
- data->dragstarty= event->y;
+ data->dragstartx = event->x;
+ data->dragstarty = event->y;
return WM_UI_HANDLER_BREAK;
}
}
/* regular open menu */
- if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
+ if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
return WM_UI_HANDLER_BREAK;
}
else if (ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) {
if (event->type == WHEELDOWNMOUSE && event->alt) {
- data->value= ui_step_name_menu(but, -1);
+ data->value = ui_step_name_menu(but, -1);
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_apply_button(C, but->block, but, data, 1);
@@ -2922,37 +2922,37 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm
* all that mouse leave and cancel stuff, so quick scroll wouldn't be an issue anymore.
* same goes for scrolling wheel in another direction below (sergey)
*/
- data->postbut= but;
- data->posttype= BUTTON_ACTIVATE_OVER;
+ data->postbut = but;
+ data->posttype = BUTTON_ACTIVATE_OVER;
return WM_UI_HANDLER_BREAK;
}
else if (event->type == WHEELUPMOUSE && event->alt) {
- data->value= ui_step_name_menu(but, 1);
+ data->value = ui_step_name_menu(but, 1);
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_apply_button(C, but->block, but, data, 1);
/* why this is needed described above */
- data->postbut= but;
- data->posttype= BUTTON_ACTIVATE_OVER;
+ data->postbut = but;
+ data->posttype = BUTTON_ACTIVATE_OVER;
return WM_UI_HANDLER_BREAK;
}
}
- else if (but->type==COL) {
- if ( ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->alt) {
- float *hsv= ui_block_hsv_get(but->block);
+ else if (but->type == COL) {
+ if (ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->alt) {
+ float *hsv = ui_block_hsv_get(but->block);
float col[3];
ui_get_but_vectorf(but, col);
- rgb_to_hsv_compat(col[0], col[1], col[2], hsv, hsv+1, hsv+2);
+ rgb_to_hsv_compat(col[0], col[1], col[2], hsv, hsv + 1, hsv + 2);
- if (event->type==WHEELDOWNMOUSE)
- hsv[2]= CLAMPIS(hsv[2]-0.05f, 0.0f, 1.0f);
+ if (event->type == WHEELDOWNMOUSE)
+ hsv[2] = CLAMPIS(hsv[2] - 0.05f, 0.0f, 1.0f);
else
- hsv[2]= CLAMPIS(hsv[2]+0.05f, 0.0f, 1.0f);
+ hsv[2] = CLAMPIS(hsv[2] + 0.05f, 0.0f, 1.0f);
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], data->vec, data->vec+1, data->vec+2);
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], data->vec, data->vec + 1, data->vec + 2);
ui_set_but_vectorf(but, data->vec);
button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -2969,13 +2969,13 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm
}
/* outside icon quit, not needed if drag activated */
- if (0==ui_but_mouse_inside_icon(but, data->region, event)) {
+ if (0 == ui_but_mouse_inside_icon(but, data->region, event)) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
- data->cancel= 1;
+ data->cancel = 1;
return WM_UI_HANDLER_BREAK;
}
- if (event->type==LEFTMOUSE && event->val==KM_RELEASE) {
+ if (event->type == LEFTMOUSE && event->val == KM_RELEASE) {
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
return WM_UI_HANDLER_BREAK;
}
@@ -2988,7 +2988,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm
static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, int my)
{
float dx, dy, rad, radsq, mrad, *fp;
- int mdx, mdy, changed= 1;
+ int mdx, mdy, changed = 1;
/* button is presumed square */
/* if mouse moves outside of sphere, it does negative normal */
@@ -2996,50 +2996,50 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i
/* note that both data->vec and data->origvec should be normalized
* else we'll get a harmless but annoying jump when first clicking */
- fp= data->origvec;
- rad= (but->x2 - but->x1);
- radsq= rad*rad;
+ fp = data->origvec;
+ rad = (but->x2 - but->x1);
+ radsq = rad * rad;
- if (fp[2]>0.0f) {
- mdx= (rad*fp[0]);
- mdy= (rad*fp[1]);
+ if (fp[2] > 0.0f) {
+ mdx = (rad * fp[0]);
+ mdy = (rad * fp[1]);
}
- else if (fp[2]> -1.0f) {
- mrad= rad/sqrtf(fp[0]*fp[0] + fp[1]*fp[1]);
+ else if (fp[2] > -1.0f) {
+ mrad = rad / sqrtf(fp[0] * fp[0] + fp[1] * fp[1]);
- mdx= 2.0f*mrad*fp[0] - (rad*fp[0]);
- mdy= 2.0f*mrad*fp[1] - (rad*fp[1]);
+ mdx = 2.0f * mrad * fp[0] - (rad * fp[0]);
+ mdy = 2.0f * mrad * fp[1] - (rad * fp[1]);
}
- else mdx= mdy= 0;
+ else mdx = mdy = 0;
- dx= (float)(mx+mdx-data->dragstartx);
- dy= (float)(my+mdy-data->dragstarty);
+ dx = (float)(mx + mdx - data->dragstartx);
+ dy = (float)(my + mdy - data->dragstarty);
- fp= data->vec;
- mrad= dx*dx+dy*dy;
- if (mrad < radsq) { /* inner circle */
- fp[0]= dx;
- fp[1]= dy;
- fp[2]= sqrt( radsq-dx*dx-dy*dy );
+ fp = data->vec;
+ mrad = dx * dx + dy * dy;
+ if (mrad < radsq) { /* inner circle */
+ fp[0] = dx;
+ fp[1] = dy;
+ fp[2] = sqrt(radsq - dx * dx - dy * dy);
}
- else { /* outer circle */
+ else { /* outer circle */
- mrad= rad/sqrtf(mrad); // veclen
+ mrad = rad / sqrtf(mrad); // veclen
- dx*= (2.0f*mrad - 1.0f);
- dy*= (2.0f*mrad - 1.0f);
+ dx *= (2.0f * mrad - 1.0f);
+ dy *= (2.0f * mrad - 1.0f);
- mrad= dx*dx+dy*dy;
+ mrad = dx * dx + dy * dy;
if (mrad < radsq) {
- fp[0]= dx;
- fp[1]= dy;
- fp[2]= -sqrt( radsq-dx*dx-dy*dy );
+ fp[0] = dx;
+ fp[1] = dy;
+ fp[2] = -sqrt(radsq - dx * dx - dy * dy);
}
}
normalize_v3(fp);
- data->draglastx= mx;
- data->draglasty= my;
+ data->draglastx = mx;
+ data->draglasty = my;
return changed;
}
@@ -3048,16 +3048,16 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
{
int mx, my;
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
- data->dragstartx= mx;
- data->dragstarty= my;
- data->draglastx= mx;
- data->draglasty= my;
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ data->dragstartx = mx;
+ data->dragstarty = my;
+ data->draglastx = mx;
+ data->draglasty = my;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
@@ -3069,12 +3069,12 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == MOUSEMOVE) {
- if (mx!=data->draglastx || my!=data->draglasty) {
+ if (mx != data->draglastx || my != data->draglasty) {
if (ui_numedit_but_NORMAL(but, data, mx, my))
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type==LEFTMOUSE && event->val!=KM_PRESS)
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS)
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
@@ -3086,9 +3086,9 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx, int my)
{
float rgb[3];
- float *hsv= ui_block_hsv_get(but->block);
+ float *hsv = ui_block_hsv_get(but->block);
float x, y;
- int changed= 1;
+ int changed = 1;
int color_profile = but->block->color_profile;
if (but->rnaprop) {
@@ -3098,64 +3098,64 @@ static int ui_numedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, int mx,
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+ rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
/* relative position within box */
- x= ((float)mx-but->x1)/(but->x2-but->x1);
- y= ((float)my-but->y1)/(but->y2-but->y1);
+ x = ((float)mx - but->x1) / (but->x2 - but->x1);
+ y = ((float)my - but->y1) / (but->y2 - but->y1);
CLAMP(x, 0.0f, 1.0f);
CLAMP(y, 0.0f, 1.0f);
- switch((int)but->a1) {
- case UI_GRAD_SV:
- hsv[2]= x;
- hsv[1]= y;
- break;
- case UI_GRAD_HV:
- hsv[0]= x;
- hsv[2]= y;
- break;
- case UI_GRAD_HS:
- hsv[0]= x;
- hsv[1]= y;
- break;
- case UI_GRAD_H:
- hsv[0]= x;
- break;
- case UI_GRAD_S:
- hsv[1]= x;
- break;
- case UI_GRAD_V:
- hsv[2]= x;
- break;
- case UI_GRAD_V_ALT:
- /* vertical 'value' strip */
-
- /* exception only for value strip - use the range set in but->min/max */
- hsv[2] = y * (but->softmax - but->softmin) + but->softmin;
-
- if (color_profile)
- hsv[2] = srgb_to_linearrgb(hsv[2]);
-
- if (hsv[2] > but->softmax)
- hsv[2] = but->softmax;
- break;
- default:
- assert(!"invalid hsv type");
+ switch ((int)but->a1) {
+ case UI_GRAD_SV:
+ hsv[2] = x;
+ hsv[1] = y;
+ break;
+ case UI_GRAD_HV:
+ hsv[0] = x;
+ hsv[2] = y;
+ break;
+ case UI_GRAD_HS:
+ hsv[0] = x;
+ hsv[1] = y;
+ break;
+ case UI_GRAD_H:
+ hsv[0] = x;
+ break;
+ case UI_GRAD_S:
+ hsv[1] = x;
+ break;
+ case UI_GRAD_V:
+ hsv[2] = x;
+ break;
+ case UI_GRAD_V_ALT:
+ /* vertical 'value' strip */
+
+ /* exception only for value strip - use the range set in but->min/max */
+ hsv[2] = y * (but->softmax - but->softmin) + but->softmin;
+
+ if (color_profile)
+ hsv[2] = srgb_to_linearrgb(hsv[2]);
+
+ if (hsv[2] > but->softmax)
+ hsv[2] = but->softmax;
+ break;
+ default:
+ assert(!"invalid hsv type");
}
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
copy_v3_v3(data->vec, rgb);
- data->draglastx= mx;
- data->draglasty= my;
+ data->draglastx = mx;
+ data->draglasty = my;
return changed;
}
static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOFMotionData *ndof, int shift)
{
- float *hsv= ui_block_hsv_get(but->block);
+ float *hsv = ui_block_hsv_get(but->block);
float rgb[3];
float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt;
@@ -3167,9 +3167,9 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
}
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+ rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
- switch((int)but->a1) {
+ switch ((int)but->a1) {
case UI_GRAD_SV:
hsv[2] += ndof->ry * sensitivity;
hsv[1] += ndof->rx * sensitivity;
@@ -3205,7 +3205,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF
assert(!"invalid hsv type");
}
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
copy_v3_v3(data->vec, rgb);
ui_set_but_vectorf(but, data->vec);
}
@@ -3214,16 +3214,16 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
{
int mx, my;
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
- data->dragstartx= mx;
- data->dragstarty= my;
- data->draglastx= mx;
- data->draglasty= my;
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ data->dragstartx = mx;
+ data->dragstarty = my;
+ data->draglastx = mx;
+ data->draglasty = my;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
@@ -3233,7 +3233,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
return WM_UI_HANDLER_BREAK;
}
else if (event->type == NDOF_MOTION) {
- wmNDOFMotionData *ndof = (wmNDOFMotionData*) event->customdata;
+ wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata;
ui_ndofedit_but_HSVCUBE(but, data, ndof, event->shift);
@@ -3244,25 +3244,25 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
}
/* XXX hardcoded keymap check.... */
else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) {
- if (but->a1==UI_GRAD_V_ALT) {
+ if (but->a1 == UI_GRAD_V_ALT) {
int len;
/* reset only value */
- len= RNA_property_array_length(&but->rnapoin, but->rnaprop);
+ len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
if (len >= 3) {
float rgb[3], def_hsv[3];
float *def;
- float *hsv= ui_block_hsv_get(but->block);
- def= MEM_callocN(sizeof(float)*len, "reset_defaults - float");
+ float *hsv = ui_block_hsv_get(but->block);
+ def = MEM_callocN(sizeof(float) * len, "reset_defaults - float");
RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
- rgb_to_hsv(def[0], def[1], def[2], def_hsv, def_hsv+1, def_hsv+2);
+ rgb_to_hsv(def[0], def[1], def[2], def_hsv, def_hsv + 1, def_hsv + 2);
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+ rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
- hsv_to_rgb(hsv[0], hsv[1], def_hsv[2], rgb, rgb+1, rgb+2);
+ hsv_to_rgb(hsv[0], hsv[1], def_hsv[2], rgb, rgb + 1, rgb + 2);
ui_set_but_vectorf(but, rgb);
RNA_property_update(C, &but->rnapoin, but->rnaprop);
@@ -3275,17 +3275,17 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == ESCKEY) {
- data->cancel= 1;
- data->escapecancel= 1;
+ data->cancel = 1;
+ data->escapecancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (event->type == MOUSEMOVE) {
- if (mx!=data->draglastx || my!=data->draglasty) {
+ if (mx != data->draglastx || my != data->draglasty) {
if (ui_numedit_but_HSVCUBE(but, data, mx, my))
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type==LEFTMOUSE && event->val!=KM_PRESS)
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS)
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
@@ -3297,7 +3297,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu
static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx, int my, int shift)
{
rcti rect;
- int changed= 1;
+ int changed = 1;
float rgb[3];
float hsv[3];
@@ -3306,7 +3306,7 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx
ui_get_but_vectorf(but, rgb);
copy_v3_v3(hsv, ui_block_hsv_get(but->block));
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+ rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
/* exception, when using color wheel in 'locked' value state:
* allow choosing a hue for black values, by giving a tiny increment */
@@ -3315,18 +3315,18 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx
}
if (U.uiflag & USER_CONTINUOUS_MOUSE) {
- float fac= shift ? 0.05f : 1.0f;
+ float fac = shift ? 0.05f : 1.0f;
/* slow down the mouse, this is fairly picky */
- mx = (data->dragstartx*(1.0f-fac) + mx*fac);
- my = (data->dragstarty*(1.0f-fac) + my*fac);
+ mx = (data->dragstartx * (1.0f - fac) + mx * fac);
+ my = (data->dragstarty * (1.0f - fac) + my * fac);
}
- ui_hsvcircle_vals_from_pos(hsv, hsv+1, &rect, (float)mx, (float)my);
+ ui_hsvcircle_vals_from_pos(hsv, hsv + 1, &rect, (float)mx, (float)my);
if (but->flag & UI_BUT_COLOR_CUBIC)
- hsv[1]= 1.0f - sqrt3f(1.0f - hsv[1]);
+ hsv[1] = 1.0f - sqrt3f(1.0f - hsv[1]);
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) {
normalize_v3(rgb);
@@ -3335,21 +3335,21 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx
ui_set_but_vectorf(but, rgb);
- data->draglastx= mx;
- data->draglasty= my;
+ data->draglastx = mx;
+ data->draglasty = my;
return changed;
}
static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmNDOFMotionData *ndof, int shift)
{
- float *hsv= ui_block_hsv_get(but->block);
+ float *hsv = ui_block_hsv_get(but->block);
float rgb[3];
float phi, r /*, sqr */ /* UNUSED */, v[2];
float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt;
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+ rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
/* Convert current colour on hue/sat disc to circular coordinates phi, r */
phi = fmodf(hsv[0] + 0.25f, 1.0f) * -2.0f * (float)M_PI;
@@ -3365,7 +3365,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmND
v[1] += ndof->rx * sensitivity;
/* convert back to polar coords on circle */
- phi = atan2f(v[0], v[1])/(2.0f*(float)M_PI) + 0.5f;
+ phi = atan2f(v[0], v[1]) / (2.0f * (float)M_PI) + 0.5f;
/* use ndof z rotation to additionally rotate hue */
phi -= ndof->rz * sensitivity * 0.5f;
@@ -3383,7 +3383,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmND
if (hsv[2] == 0.0f) hsv[2] = 0.0001f;
}
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], data->vec, data->vec+1, data->vec+2);
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], data->vec, data->vec + 1, data->vec + 2);
if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) {
normalize_v3(data->vec);
@@ -3397,16 +3397,16 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmND
static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
int mx, my;
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
- data->dragstartx= mx;
- data->dragstarty= my;
- data->draglastx= mx;
- data->draglasty= my;
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ data->dragstartx = mx;
+ data->dragstarty = my;
+ data->draglastx = mx;
+ data->draglasty = my;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
@@ -3416,7 +3416,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
return WM_UI_HANDLER_BREAK;
}
else if (event->type == NDOF_MOTION) {
- wmNDOFMotionData *ndof = (wmNDOFMotionData*) event->customdata;
+ wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata;
ui_ndofedit_but_HSVCIRCLE(but, data, ndof, event->shift);
@@ -3431,20 +3431,20 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
/* reset only saturation */
- len= RNA_property_array_length(&but->rnapoin, but->rnaprop);
+ len = RNA_property_array_length(&but->rnapoin, but->rnaprop);
if (len >= 3) {
float rgb[3], def_hsv[3];
float *def;
- float *hsv= ui_block_hsv_get(but->block);
- def= MEM_callocN(sizeof(float)*len, "reset_defaults - float");
+ float *hsv = ui_block_hsv_get(but->block);
+ def = MEM_callocN(sizeof(float) * len, "reset_defaults - float");
RNA_property_float_get_default_array(&but->rnapoin, but->rnaprop, def);
- rgb_to_hsv(def[0], def[1], def[2], def_hsv, def_hsv+1, def_hsv+2);
+ rgb_to_hsv(def[0], def[1], def[2], def_hsv, def_hsv + 1, def_hsv + 2);
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+ rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
- hsv_to_rgb(hsv[0], def_hsv[1], hsv[2], rgb, rgb+1, rgb+2);
+ hsv_to_rgb(hsv[0], def_hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
ui_set_but_vectorf(but, rgb);
RNA_property_update(C, &but->rnapoin, but->rnaprop);
@@ -3456,30 +3456,30 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == ESCKEY) {
- data->cancel= 1;
- data->escapecancel= 1;
+ data->cancel = 1;
+ data->escapecancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
/* XXX hardcoded keymap check.... */
else if (event->type == WHEELDOWNMOUSE) {
- float *hsv= ui_block_hsv_get(but->block);
- hsv[2]= CLAMPIS(hsv[2]-0.05f, 0.0f, 1.0f);
- ui_set_but_hsv(but); // converts to rgb
+ float *hsv = ui_block_hsv_get(but->block);
+ hsv[2] = CLAMPIS(hsv[2] - 0.05f, 0.0f, 1.0f);
+ ui_set_but_hsv(but); // converts to rgb
ui_numedit_apply(C, block, but, data);
}
else if (event->type == WHEELUPMOUSE) {
- float *hsv= ui_block_hsv_get(but->block);
- hsv[2]= CLAMPIS(hsv[2]+0.05f, 0.0f, 1.0f);
- ui_set_but_hsv(but); // converts to rgb
+ float *hsv = ui_block_hsv_get(but->block);
+ hsv[2] = CLAMPIS(hsv[2] + 0.05f, 0.0f, 1.0f);
+ ui_set_but_hsv(but); // converts to rgb
ui_numedit_apply(C, block, but, data);
}
else if (event->type == MOUSEMOVE) {
- if (mx!=data->draglastx || my!=data->draglasty) {
+ if (mx != data->draglastx || my != data->draglasty) {
if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift))
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
return WM_UI_HANDLER_BREAK;
@@ -3492,20 +3492,20 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle
static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx)
{
float dx;
- int changed= 0;
+ int changed = 0;
if (data->draglastx == mx)
return changed;
- dx= ((float)(mx - data->draglastx))/(but->x2-but->x1);
+ dx = ((float)(mx - data->draglastx)) / (but->x2 - but->x1);
data->dragcbd->pos += dx;
CLAMP(data->dragcbd->pos, 0.0f, 1.0f);
colorband_update_sort(data->coba);
- data->dragcbd= data->coba->data + data->coba->cur; /* because qsort */
+ data->dragcbd = data->coba->data + data->coba->cur; /* because qsort */
- data->draglastx= mx;
- changed= 1;
+ data->draglastx = mx;
+ changed = 1;
return changed;
}
@@ -3514,40 +3514,40 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
{
ColorBand *coba;
CBData *cbd;
- int mx, my, a, xco, mindist= 12;
+ int mx, my, a, xco, mindist = 12;
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
- coba= (ColorBand*)but->poin;
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ coba = (ColorBand *)but->poin;
if (event->ctrl) {
/* insert new key on mouse location */
- float pos= ((float)(mx - but->x1))/(but->x2-but->x1);
+ float pos = ((float)(mx - but->x1)) / (but->x2 - but->x1);
colorband_element_add(coba, pos);
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else {
- data->dragstartx= mx;
- data->dragstarty= my;
- data->draglastx= mx;
- data->draglasty= my;
+ data->dragstartx = mx;
+ data->dragstarty = my;
+ data->draglastx = mx;
+ data->draglasty = my;
/* activate new key when mouse is close */
- for (a=0, cbd= coba->data; a<coba->tot; a++, cbd++) {
- xco= but->x1 + (cbd->pos*(but->x2-but->x1));
- xco= ABS(xco-mx);
- if (a==coba->cur) xco+= 5; // selected one disadvantage
- if (xco<mindist) {
- coba->cur= a;
- mindist= xco;
+ for (a = 0, cbd = coba->data; a < coba->tot; a++, cbd++) {
+ xco = but->x1 + (cbd->pos * (but->x2 - but->x1));
+ xco = ABS(xco - mx);
+ if (a == coba->cur) xco += 5; // selected one disadvantage
+ if (xco < mindist) {
+ coba->cur = a;
+ mindist = xco;
}
}
- data->dragcbd= coba->data + coba->cur;
+ data->dragcbd = coba->data + coba->cur;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
}
@@ -3556,12 +3556,12 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == MOUSEMOVE) {
- if (mx!=data->draglastx || my!=data->draglasty) {
+ if (mx != data->draglastx || my != data->draglasty) {
if (ui_numedit_but_COLORBAND(but, data, mx))
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type==LEFTMOUSE && event->val!=KM_PRESS)
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS)
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
@@ -3572,81 +3572,81 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle
static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, int mx, int my)
{
- CurveMapping *cumap= (CurveMapping*)but->poin;
- CurveMap *cuma= cumap->cm+cumap->cur;
- CurveMapPoint *cmp= cuma->curve;
+ CurveMapping *cumap = (CurveMapping *)but->poin;
+ CurveMap *cuma = cumap->cm + cumap->cur;
+ CurveMapPoint *cmp = cuma->curve;
float fx, fy, zoomx, zoomy /*, offsx, offsy */ /* UNUSED */;
- int a, changed= 0;
+ int a, changed = 0;
- zoomx= (but->x2-but->x1)/(cumap->curr.xmax-cumap->curr.xmin);
- zoomy= (but->y2-but->y1)/(cumap->curr.ymax-cumap->curr.ymin);
+ zoomx = (but->x2 - but->x1) / (cumap->curr.xmax - cumap->curr.xmin);
+ zoomy = (but->y2 - but->y1) / (cumap->curr.ymax - cumap->curr.ymin);
/* offsx= cumap->curr.xmin; */
/* offsy= cumap->curr.ymin; */
if (snap) {
float d[2];
- d[0]= mx - data->dragstartx;
- d[1]= my - data->dragstarty;
+ d[0] = mx - data->dragstartx;
+ d[1] = my - data->dragstarty;
if (len_v2(d) < 3.0f)
- snap= 0;
+ snap = 0;
}
if (data->dragsel != -1) {
- int moved_point= 0; /* for ctrl grid, can't use orig coords because of sorting */
+ int moved_point = 0; /* for ctrl grid, can't use orig coords because of sorting */
- fx= (mx-data->draglastx)/zoomx;
- fy= (my-data->draglasty)/zoomy;
- for (a=0; a<cuma->totpoint; a++) {
+ fx = (mx - data->draglastx) / zoomx;
+ fy = (my - data->draglasty) / zoomy;
+ for (a = 0; a < cuma->totpoint; a++) {
if (cmp[a].flag & SELECT) {
- float origx= cmp[a].x, origy= cmp[a].y;
- cmp[a].x+= fx;
- cmp[a].y+= fy;
+ float origx = cmp[a].x, origy = cmp[a].y;
+ cmp[a].x += fx;
+ cmp[a].y += fy;
if (snap) {
- cmp[a].x= 0.125f*floorf(0.5f + 8.0f*cmp[a].x);
- cmp[a].y= 0.125f*floorf(0.5f + 8.0f*cmp[a].y);
+ cmp[a].x = 0.125f * floorf(0.5f + 8.0f * cmp[a].x);
+ cmp[a].y = 0.125f * floorf(0.5f + 8.0f * cmp[a].y);
}
- if (cmp[a].x!=origx || cmp[a].y!=origy)
- moved_point= 1;
+ if (cmp[a].x != origx || cmp[a].y != origy)
+ moved_point = 1;
}
}
- curvemapping_changed(cumap, 0); /* no remove doubles */
+ curvemapping_changed(cumap, 0); /* no remove doubles */
if (moved_point) {
- data->draglastx= mx;
- data->draglasty= my;
- changed= 1;
+ data->draglastx = mx;
+ data->draglasty = my;
+ changed = 1;
}
- data->dragchange= 1; /* mark for selection */
+ data->dragchange = 1; /* mark for selection */
}
else {
- fx= (mx-data->draglastx)/zoomx;
- fy= (my-data->draglasty)/zoomy;
+ fx = (mx - data->draglastx) / zoomx;
+ fy = (my - data->draglasty) / zoomy;
/* clamp for clip */
if (cumap->flag & CUMA_DO_CLIP) {
- if (cumap->curr.xmin-fx < cumap->clipr.xmin)
- fx= cumap->curr.xmin - cumap->clipr.xmin;
- else if (cumap->curr.xmax-fx > cumap->clipr.xmax)
- fx= cumap->curr.xmax - cumap->clipr.xmax;
- if (cumap->curr.ymin-fy < cumap->clipr.ymin)
- fy= cumap->curr.ymin - cumap->clipr.ymin;
- else if (cumap->curr.ymax-fy > cumap->clipr.ymax)
- fy= cumap->curr.ymax - cumap->clipr.ymax;
- }
-
- cumap->curr.xmin-=fx;
- cumap->curr.ymin-=fy;
- cumap->curr.xmax-=fx;
- cumap->curr.ymax-=fy;
+ if (cumap->curr.xmin - fx < cumap->clipr.xmin)
+ fx = cumap->curr.xmin - cumap->clipr.xmin;
+ else if (cumap->curr.xmax - fx > cumap->clipr.xmax)
+ fx = cumap->curr.xmax - cumap->clipr.xmax;
+ if (cumap->curr.ymin - fy < cumap->clipr.ymin)
+ fy = cumap->curr.ymin - cumap->clipr.ymin;
+ else if (cumap->curr.ymax - fy > cumap->clipr.ymax)
+ fy = cumap->curr.ymax - cumap->clipr.ymax;
+ }
+
+ cumap->curr.xmin -= fx;
+ cumap->curr.ymin -= fy;
+ cumap->curr.xmax -= fx;
+ cumap->curr.ymax -= fy;
- data->draglastx= mx;
- data->draglasty= my;
+ data->draglastx = mx;
+ data->draglasty = my;
- changed= 1;
+ changed = 1;
}
return changed;
@@ -3654,44 +3654,44 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap,
static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event)
{
- int mx, my, a, changed= 0;
+ int mx, my, a, changed = 0;
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
- CurveMapping *cumap= (CurveMapping*)but->poin;
- CurveMap *cuma= cumap->cm+cumap->cur;
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ CurveMapping *cumap = (CurveMapping *)but->poin;
+ CurveMap *cuma = cumap->cm + cumap->cur;
CurveMapPoint *cmp;
float fx, fy, zoomx, zoomy, offsx, offsy;
- float dist, mindist= 200.0f; // 14 pixels radius
- int sel= -1;
+ float dist, mindist = 200.0f; // 14 pixels radius
+ int sel = -1;
- zoomx= (but->x2-but->x1)/(cumap->curr.xmax-cumap->curr.xmin);
- zoomy= (but->y2-but->y1)/(cumap->curr.ymax-cumap->curr.ymin);
- offsx= cumap->curr.xmin;
- offsy= cumap->curr.ymin;
+ zoomx = (but->x2 - but->x1) / (cumap->curr.xmax - cumap->curr.xmin);
+ zoomy = (but->y2 - but->y1) / (cumap->curr.ymax - cumap->curr.ymin);
+ offsx = cumap->curr.xmin;
+ offsy = cumap->curr.ymin;
if (event->ctrl) {
- fx= ((float)my - but->x1)/zoomx + offsx;
- fy= ((float)my - but->y1)/zoomy + offsy;
+ fx = ((float)my - but->x1) / zoomx + offsx;
+ fy = ((float)my - but->y1) / zoomy + offsy;
curvemap_insert(cuma, fx, fy);
curvemapping_changed(cumap, 0);
- changed= 1;
+ changed = 1;
}
/* check for selecting of a point */
- cmp= cuma->curve; /* ctrl adds point, new malloc */
- for (a=0; a<cuma->totpoint; a++) {
- fx= but->x1 + zoomx*(cmp[a].x-offsx);
- fy= but->y1 + zoomy*(cmp[a].y-offsy);
- dist= (fx-mx)*(fx-mx) + (fy-my)*(fy-my);
+ cmp = cuma->curve; /* ctrl adds point, new malloc */
+ for (a = 0; a < cuma->totpoint; a++) {
+ fx = but->x1 + zoomx * (cmp[a].x - offsx);
+ fy = but->y1 + zoomy * (cmp[a].y - offsy);
+ dist = (fx - mx) * (fx - mx) + (fy - my) * (fy - my);
if (dist < mindist) {
- sel= a;
- mindist= dist;
+ sel = a;
+ mindist = dist;
}
}
@@ -3700,14 +3700,14 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
/* if the click didn't select anything, check if it's clicked on the
* curve itself, and if so, add a point */
- fx= ((float)mx - but->x1)/zoomx + offsx;
- fy= ((float)my - but->y1)/zoomy + offsy;
+ fx = ((float)mx - but->x1) / zoomx + offsx;
+ fy = ((float)my - but->y1) / zoomy + offsy;
- cmp= cuma->table;
+ cmp = cuma->table;
/* loop through the curve segment table and find what's near the mouse.
* 0.05 is kinda arbitrary, but seems to be what works nicely. */
- for (i=0; i<=CM_TABLE; i++) {
+ for (i = 0; i <= CM_TABLE; i++) {
if ( (fabsf(fx - cmp[i].x) < 0.05f) &&
(fabsf(fy - cmp[i].y) < 0.05f))
{
@@ -3715,13 +3715,13 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
curvemap_insert(cuma, fx, fy);
curvemapping_changed(cumap, 0);
- changed= 1;
+ changed = 1;
/* reset cmp back to the curve points again, rather than drawing segments */
- cmp= cuma->curve;
+ cmp = cuma->curve;
/* find newly added point and make it 'sel' */
- for (a=0; a<cuma->totpoint; a++)
+ for (a = 0; a < cuma->totpoint; a++)
if (cmp[a].x == fx)
sel = a;
@@ -3730,11 +3730,11 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
}
}
- if (sel!= -1) {
+ if (sel != -1) {
/* ok, we move a point */
/* deselect all if this one is deselect. except if we hold shift */
if (event->shift == FALSE) {
- for (a=0; a<cuma->totpoint; a++)
+ for (a = 0; a < cuma->totpoint; a++)
cmp[a].flag &= ~SELECT;
cmp[sel].flag |= SELECT;
}
@@ -3743,15 +3743,15 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
}
else {
/* move the view */
- data->cancel= 1;
+ data->cancel = 1;
}
- data->dragsel= sel;
+ data->dragsel = sel;
- data->dragstartx= mx;
- data->dragstarty= my;
- data->draglastx= mx;
- data->draglasty= my;
+ data->dragstartx = mx;
+ data->dragstarty = my;
+ data->draglastx = mx;
+ data->draglasty = my;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
return WM_UI_HANDLER_BREAK;
@@ -3759,27 +3759,27 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == MOUSEMOVE) {
- if (mx!=data->draglastx || my!=data->draglasty) {
+ if (mx != data->draglastx || my != data->draglasty) {
if (ui_numedit_but_CURVE(but, data, event->ctrl, mx, my))
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
if (data->dragsel != -1) {
- CurveMapping *cumap= (CurveMapping*)but->poin;
- CurveMap *cuma= cumap->cm+cumap->cur;
- CurveMapPoint *cmp= cuma->curve;
+ CurveMapping *cumap = (CurveMapping *)but->poin;
+ CurveMap *cuma = cumap->cm + cumap->cur;
+ CurveMapPoint *cmp = cuma->curve;
if (!data->dragchange) {
/* deselect all, select one */
if (event->shift == FALSE) {
- for (a=0; a<cuma->totpoint; a++)
+ for (a = 0; a < cuma->totpoint; a++)
cmp[a].flag &= ~SELECT;
cmp[data->dragsel].flag |= SELECT;
}
}
else
- curvemapping_changed(cumap, 1); /* remove doubles */
+ curvemapping_changed(cumap, 1); /* remove doubles */
}
button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -3804,8 +3804,8 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx
{
Histogram *hist = (Histogram *)but->poin;
/* rcti rect; */
- int changed= 1;
- float /* dx, */ dy, yfac=1.f; /* UNUSED */
+ int changed = 1;
+ float /* dx, */ dy, yfac = 1.f; /* UNUSED */
/* rect.xmin = but->x1; rect.xmax = but->x2; */
/* rect.ymin = but->y1; rect.ymax = but->y2; */
@@ -3815,7 +3815,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
- /* resize histogram widget itself */
+ /* resize histogram widget itself */
hist->height = (but->y2 - but->y1) + (data->dragstarty - my);
}
else {
@@ -3826,8 +3826,8 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx
CLAMP(hist->ymax, 1.f, 100.f);
}
- data->draglastx= mx;
- data->draglasty= my;
+ data->draglastx = mx;
+ data->draglasty = my;
return changed;
}
@@ -3836,16 +3836,16 @@ static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandle
{
int mx, my;
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
- data->dragstartx= mx;
- data->dragstarty= my;
- data->draglastx= mx;
- data->draglasty= my;
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ data->dragstartx = mx;
+ data->dragstarty = my;
+ data->draglastx = mx;
+ data->draglasty = my;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
@@ -3865,17 +3865,17 @@ static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandle
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == ESCKEY) {
- data->cancel= 1;
- data->escapecancel= 1;
+ data->cancel = 1;
+ data->escapecancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (event->type == MOUSEMOVE) {
- if (mx!=data->draglastx || my!=data->draglasty) {
+ if (mx != data->draglastx || my != data->draglasty) {
if (ui_numedit_but_HISTOGRAM(but, data, mx, my))
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
return WM_UI_HANDLER_BREAK;
@@ -3888,7 +3888,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx,
{
Scopes *scopes = (Scopes *)but->poin;
/* rcti rect; */
- int changed= 1;
+ int changed = 1;
float /* dx, */ dy /* , yfac=1.f */; /* UNUSED */
/* rect.xmin = but->x1; rect.xmax = but->x2; */
@@ -3899,19 +3899,19 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx,
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
- /* resize waveform widget itself */
+ /* resize waveform widget itself */
scopes->wavefrm_height = (but->y2 - but->y1) + (data->dragstarty - my);
}
else {
/* scale waveform values */
/* yfac = scopes->wavefrm_yfac; */ /* UNUSED */
- scopes->wavefrm_yfac += dy/200.0f;
+ scopes->wavefrm_yfac += dy / 200.0f;
CLAMP(scopes->wavefrm_yfac, 0.5f, 2.f);
}
- data->draglastx= mx;
- data->draglasty= my;
+ data->draglastx = mx;
+ data->draglasty = my;
return changed;
}
@@ -3920,16 +3920,16 @@ static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleB
{
int mx, my;
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
- data->dragstartx= mx;
- data->dragstarty= my;
- data->draglastx= mx;
- data->draglasty= my;
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ data->dragstartx = mx;
+ data->dragstarty = my;
+ data->draglastx = mx;
+ data->draglasty = my;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
@@ -3949,17 +3949,17 @@ static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleB
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == ESCKEY) {
- data->cancel= 1;
- data->escapecancel= 1;
+ data->cancel = 1;
+ data->escapecancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (event->type == MOUSEMOVE) {
- if (mx!=data->draglastx || my!=data->draglasty) {
+ if (mx != data->draglastx || my != data->draglasty) {
if (ui_numedit_but_WAVEFORM(but, data, mx, my))
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
return WM_UI_HANDLER_BREAK;
@@ -3972,7 +3972,7 @@ static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int
{
Scopes *scopes = (Scopes *)but->poin;
/* rcti rect; */
- int changed= 1;
+ int changed = 1;
/* float dx, dy; */
/* rect.xmin = but->x1; rect.xmax = but->x2; */
@@ -3982,12 +3982,12 @@ static int ui_numedit_but_VECTORSCOPE(uiBut *but, uiHandleButtonData *data, int
/* dy = my - data->draglasty; */
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
- /* resize vectorscope widget itself */
+ /* resize vectorscope widget itself */
scopes->vecscope_height = (but->y2 - but->y1) + (data->dragstarty - my);
}
- data->draglastx= mx;
- data->draglasty= my;
+ data->draglastx = mx;
+ data->draglasty = my;
return changed;
}
@@ -3996,16 +3996,16 @@ static int ui_do_but_VECTORSCOPE(bContext *C, uiBlock *block, uiBut *but, uiHand
{
int mx, my;
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
- data->dragstartx= mx;
- data->dragstarty= my;
- data->draglastx= mx;
- data->draglasty= my;
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ data->dragstartx = mx;
+ data->dragstarty = my;
+ data->draglastx = mx;
+ data->draglasty = my;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
@@ -4017,17 +4017,17 @@ static int ui_do_but_VECTORSCOPE(bContext *C, uiBlock *block, uiBut *but, uiHand
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == ESCKEY) {
- data->cancel= 1;
- data->escapecancel= 1;
+ data->cancel = 1;
+ data->escapecancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (event->type == MOUSEMOVE) {
- if (mx!=data->draglastx || my!=data->draglasty) {
+ if (mx != data->draglastx || my != data->draglasty) {
if (ui_numedit_but_VECTORSCOPE(but, data, mx, my))
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
return WM_UI_HANDLER_BREAK;
@@ -4046,12 +4046,12 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut
float butw, buth;
int mx, my, x, y, cs, che;
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) {
+ if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_PRESS) {
/* Calculate the size of the button */
width = abs(but->x2 - but->x1);
height = abs(but->y2 - but->y1);
@@ -4071,22 +4071,22 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut
x = (int) ((mx / butw) - 0.5);
y = (int) (6 - ((my / buth) - 0.5));
- che = cs + (y*12) + x;
+ che = cs + (y * 12) + x;
if (che > G.charmax)
che = 0;
if (G.obedit) {
- do_textedit(0,0,che);
+ do_textedit(0, 0, che);
}
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
else if (ELEM(event->type, WHEELUPMOUSE, PAGEUPKEY)) {
- for (but= block->buttons.first; but; but= but->next) {
+ for (but = block->buttons.first; but; but = but->next) {
if (but->type == CHARTAB) {
- G.charstart = G.charstart - (12*6);
+ G.charstart = G.charstart - (12 * 6);
if (G.charstart < 0)
G.charstart = 0;
if (G.charstart < G.charmin)
@@ -4094,14 +4094,14 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut
ui_draw_but(but);
//Really nasty... to update the num button from the same butblock
- for (bt= block->buttons.first; bt; bt= bt->next)
+ for (bt = block->buttons.first; bt; bt = bt->next)
{
if (ELEM(bt->type, NUM, NUMABS)) {
ui_check_but(bt);
ui_draw_but(bt);
}
}
- retval=UI_CONT;
+ retval = UI_CONT;
break;
}
}
@@ -4109,16 +4109,16 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut
return WM_UI_HANDLER_BREAK;
}
else if (ELEM(event->type, WHEELDOWNMOUSE, PAGEDOWNKEY)) {
- for (but= block->buttons.first; but; but= but->next) {
+ for (but = block->buttons.first; but; but = but->next) {
if (but->type == CHARTAB) {
- G.charstart = G.charstart + (12*6);
- if (G.charstart > (0xffff - 12*6))
- G.charstart = 0xffff - (12*6);
- if (G.charstart > G.charmax - 12*6)
- G.charstart = G.charmax - 12*6;
+ G.charstart = G.charstart + (12 * 6);
+ if (G.charstart > (0xffff - 12 * 6))
+ G.charstart = 0xffff - (12 * 6);
+ if (G.charstart > G.charmax - 12 * 6)
+ G.charstart = G.charmax - 12 * 6;
ui_draw_but(but);
- for (bt= block->buttons.first; bt; bt= bt->next)
+ for (bt = block->buttons.first; bt; bt = bt->next)
{
if (ELEM(bt->type, NUM, NUMABS)) {
ui_check_but(bt);
@@ -4127,7 +4127,7 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut
}
but->flag |= UI_ACTIVE;
- retval=UI_RETURN_OK;
+ retval = UI_RETURN_OK;
break;
}
}
@@ -4147,7 +4147,7 @@ static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
VECCOPY2D(but->linkto, event->mval);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type == LEFTMOUSE && event->val==KM_PRESS) {
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_WAIT_RELEASE);
return WM_UI_HANDLER_BREAK;
}
@@ -4158,9 +4158,9 @@ static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
}
else if (data->state == BUTTON_STATE_WAIT_RELEASE) {
- if (event->type == LEFTMOUSE && event->val!=KM_PRESS) {
+ if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
if (!(but->flag & UI_SELECT))
- data->cancel= 1;
+ data->cancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
return WM_UI_HANDLER_BREAK;
}
@@ -4172,7 +4172,7 @@ static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, wmE
static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonData *data, int mx, int my, int shift)
{
MovieClipScopes *scopes = (MovieClipScopes *)but->poin;
- int changed= 1;
+ int changed = 1;
float dx, dy;
dx = mx - data->draglastx;
@@ -4184,26 +4184,26 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa
}
if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) {
- /* resize preview widget itself */
+ /* resize preview widget itself */
scopes->track_preview_height = (but->y2 - but->y1) + (data->dragstarty - my);
}
else {
if (scopes->marker) {
- if (scopes->marker->framenr!=scopes->framenr)
- scopes->marker= BKE_tracking_ensure_marker(scopes->track, scopes->framenr);
+ if (scopes->marker->framenr != scopes->framenr)
+ scopes->marker = BKE_tracking_ensure_marker(scopes->track, scopes->framenr);
- scopes->marker->flag&= ~(MARKER_DISABLED|MARKER_TRACKED);
- scopes->marker->pos[0]+= -dx*scopes->slide_scale[0] / (but->block->maxx-but->block->minx);
- scopes->marker->pos[1]+= -dy*scopes->slide_scale[1] / (but->block->maxy-but->block->miny);
+ scopes->marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED);
+ scopes->marker->pos[0] += -dx * scopes->slide_scale[0] / (but->block->maxx - but->block->minx);
+ scopes->marker->pos[1] += -dy * scopes->slide_scale[1] / (but->block->maxy - but->block->miny);
- WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL);
+ WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL);
}
- scopes->ok= 0;
+ scopes->ok = 0;
}
- data->draglastx= mx;
- data->draglasty= my;
+ data->draglastx = mx;
+ data->draglasty = my;
return changed;
}
@@ -4212,16 +4212,16 @@ static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHan
{
int mx, my;
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(data->region, block, &mx, &my);
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- if (event->type==LEFTMOUSE && event->val==KM_PRESS) {
- data->dragstartx= mx;
- data->dragstarty= my;
- data->draglastx= mx;
- data->draglasty= my;
+ if (event->type == LEFTMOUSE && event->val == KM_PRESS) {
+ data->dragstartx = mx;
+ data->dragstarty = my;
+ data->draglastx = mx;
+ data->draglasty = my;
button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
/* also do drag the first time */
@@ -4233,17 +4233,17 @@ static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHan
}
else if (data->state == BUTTON_STATE_NUM_EDITING) {
if (event->type == ESCKEY) {
- data->cancel= 1;
- data->escapecancel= 1;
+ data->cancel = 1;
+ data->escapecancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (event->type == MOUSEMOVE) {
- if (mx!=data->draglastx || my!=data->draglasty) {
+ if (mx != data->draglastx || my != data->draglasty) {
if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift))
ui_numedit_apply(C, block, but, data);
}
}
- else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) {
+ else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
return WM_UI_HANDLER_BREAK;
@@ -4259,11 +4259,11 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
if (but->optype) {
char shortcut_str[128];
- IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
+ IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
/* complex code to change name of button */
if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
- shortcut_str, sizeof(shortcut_str)))
+ shortcut_str, sizeof(shortcut_str)))
{
ui_but_add_shortcut(but, shortcut_str, TRUE);
}
@@ -4276,29 +4276,29 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
{
- wmWindowManager *wm= CTX_wm_manager(C);
+ wmWindowManager *wm = CTX_wm_manager(C);
uiBlock *block;
uiBut *but = (uiBut *)arg;
wmKeyMap *km;
wmKeyMapItem *kmi;
PointerRNA ptr;
uiLayout *layout;
- uiStyle *style= UI_GetStyle();
- IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
+ uiStyle *style = UI_GetStyle();
+ IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, 1, &km);
kmi = WM_keymap_item_find_id(km, kmi_id);
RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr);
- block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
+ block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
uiBlockSetHandleFunc(block, but_shortcut_name_func, but);
uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT);
uiBlockSetDirection(block, UI_CENTER);
- layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, style);
+ layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, style);
- uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT|UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
+ uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
uiPopupBoundsBlock(block, 6, -50, 26);
uiEndBlock(C, block);
@@ -4308,15 +4308,15 @@ static uiBlock *menu_change_shortcut(bContext *C, ARegion *ar, void *arg)
static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
{
- wmWindowManager *wm= CTX_wm_manager(C);
+ wmWindowManager *wm = CTX_wm_manager(C);
uiBlock *block;
uiBut *but = (uiBut *)arg;
wmKeyMap *km;
wmKeyMapItem *kmi;
PointerRNA ptr;
uiLayout *layout;
- uiStyle *style= UI_GetStyle();
- IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
+ uiStyle *style = UI_GetStyle();
+ IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
int kmi_id;
/* XXX this guess_opname can potentially return a different keymap than being found on adding later... */
@@ -4326,7 +4326,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
/* copy properties, prop can be NULL for reset */
if (prop)
- prop= IDP_CopyProperty(prop);
+ prop = IDP_CopyProperty(prop);
WM_keymap_properties_reset(kmi, prop);
/* update and get pointers again */
@@ -4337,14 +4337,14 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg)
RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr);
- block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
+ block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
uiBlockSetHandleFunc(block, but_shortcut_name_func, but);
uiBlockSetFlag(block, UI_BLOCK_RET_1);
uiBlockSetDirection(block, UI_CENTER);
- layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, style);
+ layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, style);
- uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT|UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
+ uiItemR(layout, &ptr, "type", UI_ITEM_R_FULL_EVENT | UI_ITEM_R_IMMEDIATE, "", ICON_NONE);
uiPopupBoundsBlock(block, 6, -50, 26);
uiEndBlock(C, block);
@@ -4364,7 +4364,7 @@ static void remove_shortcut_func(bContext *C, void *arg1, void *UNUSED(arg2))
uiBut *but = (uiBut *)arg1;
wmKeyMap *km;
wmKeyMapItem *kmi;
- IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
+ IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, 1, &km);
kmi = WM_keymap_item_find_id(km, kmi_id);
@@ -4388,31 +4388,31 @@ static int ui_but_menu(bContext *C, uiBut *but)
int length;
const char *name;
- if ((but->rnapoin.data && but->rnaprop)==0 && but->optype==NULL)
+ if ((but->rnapoin.data && but->rnaprop) == 0 && but->optype == NULL)
return 0;
button_timers_tooltip_remove(C, but);
if (but->rnaprop)
- name= RNA_property_ui_name(but->rnaprop);
+ name = RNA_property_ui_name(but->rnaprop);
else if (but->optype)
- name= but->optype->name;
+ name = but->optype->name;
else
- name= "<needs_name>"; // XXX - should never happen.
+ name = "<needs_name>"; // XXX - should never happen.
- pup= uiPupMenuBegin(C, name, ICON_NONE);
- layout= uiPupMenuLayout(pup);
+ pup = uiPupMenuBegin(C, name, ICON_NONE);
+ layout = uiPupMenuLayout(pup);
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
if (but->rnapoin.data && but->rnaprop) {
- short is_anim= RNA_property_animateable(&but->rnapoin, but->rnaprop);
+ short is_anim = RNA_property_animateable(&but->rnapoin, but->rnaprop);
/* second slower test, saved people finding keyframe items in menus when its not possible */
if (is_anim)
- is_anim= RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop);
+ is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop);
- length= RNA_property_array_length(&but->rnapoin, but->rnaprop);
+ length = RNA_property_array_length(&but->rnapoin, but->rnaprop);
/* Keyframes */
if (but->flag & UI_BUT_ANIMATED_KEY) {
@@ -4433,7 +4433,7 @@ static int ui_but_menu(bContext *C, uiBut *but)
}
- else if (but->flag & UI_BUT_DRIVEN);
+ else if (but->flag & UI_BUT_DRIVEN) ;
else if (is_anim) {
if (length) {
uiItemBooleanO(layout, "Insert Keyframes", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1);
@@ -4458,7 +4458,7 @@ static int ui_but_menu(bContext *C, uiBut *but)
if (ANIM_driver_can_paste())
uiItemO(layout, "Paste Driver", ICON_NONE, "ANIM_OT_paste_driver_button");
}
- else if (but->flag & (UI_BUT_ANIMATED_KEY|UI_BUT_ANIMATED));
+ else if (but->flag & (UI_BUT_ANIMATED_KEY | UI_BUT_ANIMATED)) ;
else if (is_anim) {
uiItemS(layout);
@@ -4513,11 +4513,11 @@ static int ui_but_menu(bContext *C, uiBut *but)
if (but->optype) {
uiBlock *block = uiLayoutGetBlock(layout);
uiBut *but2;
- IDProperty *prop= (but->opptr)? but->opptr->data: NULL;
+ IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
int w = uiLayoutGetWidth(layout);
wmKeyMap *km;
wmKeyMapItem *kmi = NULL;
- int kmi_id= WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, 1, &km);
+ int kmi_id = WM_key_event_operator_id(C, but->optype->idname, but->opcontext, prop, 1, &km);
if (kmi_id)
kmi = WM_keymap_item_find_id(km, kmi_id);
@@ -4544,7 +4544,7 @@ static int ui_but_menu(bContext *C, uiBut *but)
}
- { /* Docs */
+ { /* Docs */
char buf[512];
PointerRNA ptr_props;
@@ -4594,26 +4594,26 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
uiHandleButtonData *data;
int retval;
- data= but->active;
- retval= WM_UI_HANDLER_CONTINUE;
+ data = but->active;
+ retval = WM_UI_HANDLER_CONTINUE;
if (but->flag & UI_BUT_DISABLED)
return WM_UI_HANDLER_CONTINUE;
- if ( (data->state == BUTTON_STATE_HIGHLIGHT) &&
- /* check prevval because of modal operators [#24016],
- * modifier check is to allow Ctrl+C for copy.
- * if this causes other problems, remove this check and suffer the bug :) - campbell */
- ((event->prevval != KM_PRESS) || (ISKEYMODIFIER(event->prevtype)) || (event->type == EVT_DROP))
- ) {
+ if ((data->state == BUTTON_STATE_HIGHLIGHT) &&
+ /* check prevval because of modal operators [#24016],
+ * modifier check is to allow Ctrl+C for copy.
+ * if this causes other problems, remove this check and suffer the bug :) - campbell */
+ ((event->prevval != KM_PRESS) || (ISKEYMODIFIER(event->prevtype)) || (event->type == EVT_DROP)))
+ {
/* handle copy-paste */
- if (ELEM(event->type, CKEY, VKEY) && event->val==KM_PRESS && (event->ctrl || event->oskey)) {
- ui_but_copy_paste(C, but, data, (event->type == CKEY)? 'c': 'v');
+ if (ELEM(event->type, CKEY, VKEY) && event->val == KM_PRESS && (event->ctrl || event->oskey)) {
+ ui_but_copy_paste(C, but, data, (event->type == CKEY) ? 'c' : 'v');
return WM_UI_HANDLER_BREAK;
}
/* handle drop */
else if (event->type == EVT_DROP) {
- ui_but_drop (C, event, but, data);
+ ui_but_drop(C, event, but, data);
}
/* handle keyframing */
else if (event->type == IKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) {
@@ -4674,7 +4674,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
return WM_UI_HANDLER_BREAK;
}
}
- else if (but->pointype && but->poin==NULL) {
+ else if (but->pointype && but->poin == NULL) {
/* there's a pointer needed */
BKE_reportf(NULL, RPT_WARNING, "DoButton pointer error: %s", but->str);
button_activate_state(C, but, BUTTON_STATE_EXIT);
@@ -4682,107 +4682,107 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
}
}
- switch(but->type) {
- case BUT:
- retval= ui_do_but_BUT(C, but, data, event);
- break;
- case KEYEVT:
- retval= ui_do_but_KEYEVT(C, but, data, event);
- break;
- case HOTKEYEVT:
- retval= ui_do_but_HOTKEYEVT(C, but, data, event);
- break;
- case TOGBUT:
- case TOG:
- case TOGR:
- case ICONTOG:
- case ICONTOGN:
- case TOGN:
- case BUT_TOGDUAL:
- case OPTION:
- case OPTIONN:
- retval= ui_do_but_TOG(C, but, data, event);
- break;
- case SCROLL:
- retval= ui_do_but_SCROLL(C, block, but, data, event);
- break;
- case NUM:
- case NUMABS:
- retval= ui_do_but_NUM(C, block, but, data, event);
- break;
- case SLI:
- case NUMSLI:
- case HSVSLI:
- retval= ui_do_but_SLI(C, block, but, data, event);
- break;
- case ROUNDBOX:
- case LISTBOX:
- case LABEL:
- case TOG3:
- case ROW:
- case LISTROW:
- case BUT_IMAGE:
- case PROGRESSBAR:
- retval= ui_do_but_EXIT(C, but, data, event);
- break;
- case HISTOGRAM:
- retval= ui_do_but_HISTOGRAM(C, block, but, data, event);
- break;
- case WAVEFORM:
- retval= ui_do_but_WAVEFORM(C, block, but, data, event);
- break;
- case VECTORSCOPE:
- retval= ui_do_but_VECTORSCOPE(C, block, but, data, event);
- break;
- case TEX:
- case IDPOIN:
- case SEARCH_MENU:
- retval= ui_do_but_TEX(C, block, but, data, event);
- break;
- case MENU:
- case ICONROW:
- case ICONTEXTROW:
- case BLOCK:
- case PULLDOWN:
- retval= ui_do_but_BLOCK(C, but, data, event);
- break;
- case BUTM:
- retval= ui_do_but_BUT(C, but, data, event);
- break;
- case COL:
- if (but->a1 == UI_GRAD_V_ALT) // signal to prevent calling up color picker
- retval= ui_do_but_EXIT(C, but, data, event);
- else
- retval= ui_do_but_BLOCK(C, but, data, event);
- break;
- case BUT_NORMAL:
- retval= ui_do_but_NORMAL(C, block, but, data, event);
- break;
- case BUT_COLORBAND:
- retval= ui_do_but_COLORBAND(C, block, but, data, event);
- break;
- case BUT_CURVE:
- retval= ui_do_but_CURVE(C, block, but, data, event);
- break;
- case HSVCUBE:
- retval= ui_do_but_HSVCUBE(C, block, but, data, event);
- break;
- case HSVCIRCLE:
- retval= ui_do_but_HSVCIRCLE(C, block, but, data, event);
- break;
+ switch (but->type) {
+ case BUT:
+ retval = ui_do_but_BUT(C, but, data, event);
+ break;
+ case KEYEVT:
+ retval = ui_do_but_KEYEVT(C, but, data, event);
+ break;
+ case HOTKEYEVT:
+ retval = ui_do_but_HOTKEYEVT(C, but, data, event);
+ break;
+ case TOGBUT:
+ case TOG:
+ case TOGR:
+ case ICONTOG:
+ case ICONTOGN:
+ case TOGN:
+ case BUT_TOGDUAL:
+ case OPTION:
+ case OPTIONN:
+ retval = ui_do_but_TOG(C, but, data, event);
+ break;
+ case SCROLL:
+ retval = ui_do_but_SCROLL(C, block, but, data, event);
+ break;
+ case NUM:
+ case NUMABS:
+ retval = ui_do_but_NUM(C, block, but, data, event);
+ break;
+ case SLI:
+ case NUMSLI:
+ case HSVSLI:
+ retval = ui_do_but_SLI(C, block, but, data, event);
+ break;
+ case ROUNDBOX:
+ case LISTBOX:
+ case LABEL:
+ case TOG3:
+ case ROW:
+ case LISTROW:
+ case BUT_IMAGE:
+ case PROGRESSBAR:
+ retval = ui_do_but_EXIT(C, but, data, event);
+ break;
+ case HISTOGRAM:
+ retval = ui_do_but_HISTOGRAM(C, block, but, data, event);
+ break;
+ case WAVEFORM:
+ retval = ui_do_but_WAVEFORM(C, block, but, data, event);
+ break;
+ case VECTORSCOPE:
+ retval = ui_do_but_VECTORSCOPE(C, block, but, data, event);
+ break;
+ case TEX:
+ case IDPOIN:
+ case SEARCH_MENU:
+ retval = ui_do_but_TEX(C, block, but, data, event);
+ break;
+ case MENU:
+ case ICONROW:
+ case ICONTEXTROW:
+ case BLOCK:
+ case PULLDOWN:
+ retval = ui_do_but_BLOCK(C, but, data, event);
+ break;
+ case BUTM:
+ retval = ui_do_but_BUT(C, but, data, event);
+ break;
+ case COL:
+ if (but->a1 == UI_GRAD_V_ALT) // signal to prevent calling up color picker
+ retval = ui_do_but_EXIT(C, but, data, event);
+ else
+ retval = ui_do_but_BLOCK(C, but, data, event);
+ break;
+ case BUT_NORMAL:
+ retval = ui_do_but_NORMAL(C, block, but, data, event);
+ break;
+ case BUT_COLORBAND:
+ retval = ui_do_but_COLORBAND(C, block, but, data, event);
+ break;
+ case BUT_CURVE:
+ retval = ui_do_but_CURVE(C, block, but, data, event);
+ break;
+ case HSVCUBE:
+ retval = ui_do_but_HSVCUBE(C, block, but, data, event);
+ break;
+ case HSVCIRCLE:
+ retval = ui_do_but_HSVCIRCLE(C, block, but, data, event);
+ break;
#ifdef WITH_INTERNATIONAL
- case CHARTAB:
- retval= ui_do_but_CHARTAB(C, block, but, data, event);
- break;
+ case CHARTAB:
+ retval = ui_do_but_CHARTAB(C, block, but, data, event);
+ break;
#endif
- case LINK:
- case INLINK:
- retval= ui_do_but_LINK(C, but, data, event);
- break;
- case TRACKPREVIEW:
- retval= ui_do_but_TRACKPREVIEW(C, block, but, data, event);
- break;
+ case LINK:
+ case INLINK:
+ retval = ui_do_but_LINK(C, but, data, event);
+ break;
+ case TRACKPREVIEW:
+ retval = ui_do_but_TRACKPREVIEW(C, block, but, data, event);
+ break;
}
return retval;
@@ -4792,7 +4792,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event)
static int ui_but_contains_pt(uiBut *but, int mx, int my)
{
- return ((but->x1<mx && but->x2>=mx) && (but->y1<my && but->y2>=my));
+ return ((but->x1 < mx && but->x2 >= mx) && (but->y1 < my && but->y2 >= my));
}
static uiBut *ui_but_find_activated(ARegion *ar)
@@ -4800,8 +4800,8 @@ static uiBut *ui_but_find_activated(ARegion *ar)
uiBlock *block;
uiBut *but;
- for (block=ar->uiblocks.first; block; block=block->next)
- for (but=block->buttons.first; but; but= but->next)
+ for (block = ar->uiblocks.first; block; block = block->next)
+ for (but = block->buttons.first; but; but = but->next)
if (but->active)
return but;
@@ -4816,16 +4816,16 @@ int ui_button_is_active(ARegion *ar)
/* is called by notifier */
void uiFreeActiveButtons(const bContext *C, bScreen *screen)
{
- ScrArea *sa= screen->areabase.first;
+ ScrArea *sa = screen->areabase.first;
- for (;sa; sa= sa->next) {
- ARegion *ar= sa->regionbase.first;
- for (;ar; ar= ar->next) {
- uiBut *but= ui_but_find_activated(ar);
+ for (; sa; sa = sa->next) {
+ ARegion *ar = sa->regionbase.first;
+ for (; ar; ar = ar->next) {
+ uiBut *but = ui_but_find_activated(ar);
if (but) {
- uiHandleButtonData *data= but->active;
+ uiHandleButtonData *data = but->active;
- if (data->menu==NULL && data->searchbox==NULL)
+ if (data->menu == NULL && data->searchbox == NULL)
if (data->state == BUTTON_STATE_HIGHLIGHT)
ui_button_active_free(C, but);
}
@@ -4839,8 +4839,8 @@ void uiFreeActiveButtons(const bContext *C, bScreen *screen)
/* called in region context */
int UI_but_active_drop_name(bContext *C)
{
- ARegion *ar= CTX_wm_region(C);
- uiBut *but= ui_but_find_activated(ar);
+ ARegion *ar = CTX_wm_region(C);
+ uiBut *but = ui_but_find_activated(ar);
if (but) {
if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU))
@@ -4859,8 +4859,8 @@ static void ui_blocks_set_tooltips(ARegion *ar, int enable)
/* we disabled buttons when when they were already shown, and
* re-enable them on mouse move */
- for (block=ar->uiblocks.first; block; block=block->next)
- block->tooltipdisabled= !enable;
+ for (block = ar->uiblocks.first; block; block = block->next)
+ block->tooltipdisabled = !enable;
}
static int ui_mouse_inside_region(ARegion *ar, int x, int y)
@@ -4869,8 +4869,8 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y)
/* check if the mouse is in the region */
if (!BLI_in_rcti(&ar->winrct, x, y)) {
- for (block=ar->uiblocks.first; block; block=block->next)
- block->auto_open= FALSE;
+ for (block = ar->uiblocks.first; block; block = block->next)
+ block->auto_open = FALSE;
return 0;
}
@@ -4880,14 +4880,14 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y)
* even when they are not visible, so we need to make a copy of the mask to
* use to check
*/
- if (ar->v2d.mask.xmin!=ar->v2d.mask.xmax) {
- View2D *v2d= &ar->v2d;
+ if (ar->v2d.mask.xmin != ar->v2d.mask.xmax) {
+ View2D *v2d = &ar->v2d;
rcti mask_rct;
int mx, my;
/* convert window coordinates to region coordinates */
- mx= x;
- my= y;
+ mx = x;
+ my = y;
ui_window_to_region(ar, &mx, &my);
/* make a copy of the mask rect, and tweak accordingly for hidden scrollbars */
@@ -4896,14 +4896,14 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y)
mask_rct.ymin = v2d->mask.ymin;
mask_rct.ymax = v2d->mask.ymax;
- if (v2d->scroll & (V2D_SCROLL_VERTICAL_HIDE|V2D_SCROLL_VERTICAL_FULLR)) {
+ if (v2d->scroll & (V2D_SCROLL_VERTICAL_HIDE | V2D_SCROLL_VERTICAL_FULLR)) {
if (v2d->scroll & V2D_SCROLL_LEFT)
mask_rct.xmin = v2d->vert.xmin;
else if (v2d->scroll & V2D_SCROLL_RIGHT)
mask_rct.xmax = v2d->vert.xmax;
}
- if (v2d->scroll & (V2D_SCROLL_HORIZONTAL_HIDE|V2D_SCROLL_HORIZONTAL_FULLR)) {
- if (v2d->scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O))
+ if (v2d->scroll & (V2D_SCROLL_HORIZONTAL_HIDE | V2D_SCROLL_HORIZONTAL_FULLR)) {
+ if (v2d->scroll & (V2D_SCROLL_BOTTOM | V2D_SCROLL_BOTTOM_O))
mask_rct.ymin = v2d->hor.ymin;
else if (v2d->scroll & V2D_SCROLL_TOP)
mask_rct.ymax = v2d->hor.ymax;
@@ -4933,7 +4933,7 @@ static int ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y)
static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y)
{
uiBlock *block;
- uiBut *but, *butover= NULL;
+ uiBut *but, *butover = NULL;
int mx, my;
// if (!win->active)
@@ -4941,14 +4941,14 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y)
if (!ui_mouse_inside_region(ar, x, y))
return NULL;
- for (block=ar->uiblocks.first; block; block=block->next) {
- mx= x;
- my= y;
+ for (block = ar->uiblocks.first; block; block = block->next) {
+ mx = x;
+ my = y;
ui_window_to_block(ar, block, &mx, &my);
- for (but=block->buttons.first; but; but= but->next) {
+ for (but = block->buttons.first; but; but = but->next) {
/* note, LABEL is included for hilights, this allows drags */
- if (but->type==LABEL && but->dragpoin==NULL)
+ if (but->type == LABEL && but->dragpoin == NULL)
continue;
if (ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX))
continue;
@@ -4957,15 +4957,17 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y)
if (but->flag & UI_SCROLLED)
continue;
if (ui_but_contains_pt(but, mx, my))
- butover= but;
+ butover = but;
}
/* CLIP_EVENTS prevents the event from reaching other blocks */
if (block->flag & UI_BLOCK_CLIP_EVENTS) {
/* check if mouse is inside block */
if (block->minx <= mx && block->maxx >= mx &&
- block->miny <= my && block->maxy >= my)
+ block->miny <= my && block->maxy >= my)
+ {
break;
+ }
}
}
@@ -4983,12 +4985,12 @@ static uiBut *ui_list_find_mouse_over(ARegion *ar, int x, int y)
if (!ui_mouse_inside_region(ar, x, y))
return NULL;
- for (block=ar->uiblocks.first; block; block=block->next) {
- mx= x;
- my= y;
+ for (block = ar->uiblocks.first; block; block = block->next) {
+ mx = x;
+ my = y;
ui_window_to_block(ar, block, &mx, &my);
- for (but=block->buttons.last; but; but= but->prev)
+ for (but = block->buttons.last; but; but = but->prev)
if (but->type == LISTBOX && ui_but_contains_pt(but, mx, my))
return but;
}
@@ -5001,56 +5003,56 @@ static uiBut *ui_list_find_mouse_over(ARegion *ar, int x, int y)
static int button_modal_state(uiHandleButtonState state)
{
return ELEM6(state, BUTTON_STATE_WAIT_RELEASE, BUTTON_STATE_WAIT_KEY_EVENT,
- BUTTON_STATE_NUM_EDITING, BUTTON_STATE_TEXT_EDITING,
- BUTTON_STATE_TEXT_SELECTING, BUTTON_STATE_MENU_OPEN);
+ BUTTON_STATE_NUM_EDITING, BUTTON_STATE_TEXT_EDITING,
+ BUTTON_STATE_TEXT_SELECTING, BUTTON_STATE_MENU_OPEN);
}
static void button_timers_tooltip_remove(bContext *C, uiBut *but)
{
uiHandleButtonData *data;
- data= but->active;
+ data = but->active;
if (data) {
if (data->tooltiptimer) {
WM_event_remove_timer(data->wm, data->window, data->tooltiptimer);
- data->tooltiptimer= NULL;
+ data->tooltiptimer = NULL;
}
if (data->tooltip) {
ui_tooltip_free(C, data->tooltip);
- data->tooltip= NULL;
+ data->tooltip = NULL;
}
if (data->autoopentimer) {
WM_event_remove_timer(data->wm, data->window, data->autoopentimer);
- data->autoopentimer= NULL;
+ data->autoopentimer = NULL;
}
}
}
static void button_tooltip_timer_reset(bContext *C, uiBut *but)
{
- wmWindowManager *wm= CTX_wm_manager(C);
+ wmWindowManager *wm = CTX_wm_manager(C);
uiHandleButtonData *data;
- data= but->active;
+ data = but->active;
if (data->tooltiptimer) {
WM_event_remove_timer(data->wm, data->window, data->tooltiptimer);
- data->tooltiptimer= NULL;
+ data->tooltiptimer = NULL;
}
if (U.flag & USER_TOOLTIPS)
if (!but->block->tooltipdisabled)
if (!wm->drags.first)
- data->tooltiptimer= WM_event_add_timer(data->wm, data->window, TIMER, BUTTON_TOOLTIP_DELAY);
+ data->tooltiptimer = WM_event_add_timer(data->wm, data->window, TIMER, BUTTON_TOOLTIP_DELAY);
}
static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState state)
{
uiHandleButtonData *data;
- data= but->active;
+ data = but->active;
if (data->state == state)
return;
@@ -5065,13 +5067,13 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
if (data->used_mouse && !data->autoopentimer) {
int time;
- if (but->block->auto_open==TRUE) time= 1; // test for toolbox
- else if ((but->block->flag & UI_BLOCK_LOOP && but->type != BLOCK) || but->block->auto_open==TRUE) time= 5*U.menuthreshold2;
- else if (U.uiflag & USER_MENUOPENAUTO) time= 5*U.menuthreshold1;
- else time= -1;
+ if (but->block->auto_open == TRUE) time = 1; // test for toolbox
+ else if ((but->block->flag & UI_BLOCK_LOOP && but->type != BLOCK) || but->block->auto_open == TRUE) time = 5 * U.menuthreshold2;
+ else if (U.uiflag & USER_MENUOPENAUTO) time = 5 * U.menuthreshold1;
+ else time = -1;
if (time >= 0)
- data->autoopentimer= WM_event_add_timer(data->wm, data->window, TIMER, 0.02*(double)time);
+ data->autoopentimer = WM_event_add_timer(data->wm, data->window, TIMER, 0.02 * (double)time);
}
}
}
@@ -5107,11 +5109,11 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
/* add a short delay before exiting, to ensure there is some feedback */
if (state == BUTTON_STATE_WAIT_FLASH) {
- data->flashtimer= WM_event_add_timer(data->wm, data->window, TIMER, BUTTON_FLASH_DELAY);
+ data->flashtimer = WM_event_add_timer(data->wm, data->window, TIMER, BUTTON_FLASH_DELAY);
}
else if (data->flashtimer) {
WM_event_remove_timer(data->wm, data->window, data->flashtimer);
- data->flashtimer= NULL;
+ data->flashtimer = NULL;
}
/* add a blocking ui handler at the window handler for blocking, modal states
@@ -5123,7 +5125,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
}
else {
if (button_modal_state(data->state))
- WM_event_remove_ui_handler(&data->window->modalhandlers, ui_handler_region_menu, NULL, data, 1); /* 1 = postpone free */
+ WM_event_remove_ui_handler(&data->window->modalhandlers, ui_handler_region_menu, NULL, data, 1); /* 1 = postpone free */
}
}
@@ -5132,7 +5134,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s
but->flag &= ~UI_SELECT;
}
- data->state= state;
+ data->state = state;
if (state != BUTTON_STATE_EXIT) {
/* When objects for eg. are removed, running ui_check_but() can access
@@ -5153,34 +5155,34 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
uiHandleButtonData *data;
/* setup struct */
- data= MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData");
- data->wm= CTX_wm_manager(C);
- data->window= CTX_wm_window(C);
- data->region= ar;
- if ( ELEM(but->type, BUT_CURVE, SEARCH_MENU) ); // XXX curve is temp
- else data->interactive= 1;
+ data = MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData");
+ data->wm = CTX_wm_manager(C);
+ data->window = CTX_wm_window(C);
+ data->region = ar;
+ if (ELEM(but->type, BUT_CURVE, SEARCH_MENU) ) ; // XXX curve is temp
+ else data->interactive = 1;
data->state = BUTTON_STATE_INIT;
/* activate button */
but->flag |= UI_ACTIVE;
- but->active= data;
+ but->active = data;
/* we disable auto_open in the block after a threshold, because we still
* want to allow auto opening adjacent menus even if no button is activated
* in between going over to the other button, but only for a short while */
- if (type == BUTTON_ACTIVATE_OVER && but->block->auto_open==TRUE)
- if (but->block->auto_open_last+BUTTON_AUTO_OPEN_THRESH < PIL_check_seconds_timer())
- but->block->auto_open= FALSE;
+ if (type == BUTTON_ACTIVATE_OVER && but->block->auto_open == TRUE)
+ if (but->block->auto_open_last + BUTTON_AUTO_OPEN_THRESH < PIL_check_seconds_timer())
+ but->block->auto_open = FALSE;
if (type == BUTTON_ACTIVATE_OVER) {
- data->used_mouse= 1;
+ data->used_mouse = 1;
}
button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT);
/* activate right away */
if (but->flag & UI_BUT_IMMEDIATE) {
- if (but->type==HOTKEYEVT)
+ if (but->type == HOTKEYEVT)
button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT);
/* .. more to be added here */
}
@@ -5190,12 +5192,12 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
/* activate first button in submenu */
if (data->menu && data->menu->region) {
- ARegion *subar= data->menu->region;
- uiBlock *subblock= subar->uiblocks.first;
+ ARegion *subar = data->menu->region;
+ uiBlock *subblock = subar->uiblocks.first;
uiBut *subbut;
if (subblock) {
- subbut= ui_but_first(subblock);
+ subbut = ui_but_first(subblock);
if (subbut)
ui_handle_button_activate(C, subar, subbut, BUTTON_ACTIVATE);
@@ -5210,7 +5212,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *but, int mousemove, int onfree)
{
- uiBlock *block= but->block;
+ uiBlock *block = but->block;
uiBut *bt;
/* ensure we are in the exit state */
@@ -5228,9 +5230,9 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
if (!data->cancel || data->escapecancel) {
uiPopupBlockHandle *menu;
- menu= block->handle;
- menu->butretval= data->retval;
- menu->menuretval= (data->cancel)? UI_RETURN_CANCEL: UI_RETURN_OK;
+ menu = block->handle;
+ menu->butretval = data->retval;
+ menu->menuretval = (data->cancel) ? UI_RETURN_CANCEL : UI_RETURN_OK;
}
}
@@ -5244,11 +5246,11 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
}
/* disable tooltips until mousemove + last active flag */
- for (block=data->region->uiblocks.first; block; block=block->next) {
- for (bt=block->buttons.first; bt; bt=bt->next)
+ for (block = data->region->uiblocks.first; block; block = block->next) {
+ for (bt = block->buttons.first; bt; bt = bt->next)
bt->flag &= ~UI_BUT_LAST_ACTIVE;
- block->tooltipdisabled= 1;
+ block->tooltipdisabled = 1;
}
ui_blocks_set_tooltips(data->region, 0);
@@ -5264,8 +5266,8 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
/* clean up button */
MEM_freeN(but->active);
- but->active= NULL;
- but->flag &= ~(UI_ACTIVE|UI_SELECT);
+ but->active = NULL;
+ but->flag &= ~(UI_ACTIVE | UI_SELECT);
but->flag |= UI_BUT_LAST_ACTIVE;
if (!onfree)
ui_check_but(but);
@@ -5285,37 +5287,37 @@ void ui_button_active_free(const bContext *C, uiBut *but)
* active, this is bad for user interaction, but we need to handle this
* case cleanly anyway in case it happens */
if (but->active) {
- data= but->active;
- data->cancel= 1;
- button_activate_exit((bContext*)C, data, but, 0, 1);
+ data = but->active;
+ data->cancel = 1;
+ button_activate_exit((bContext *)C, data, but, 0, 1);
}
}
/* returns the active button with an optional checking function */
static uiBut *ui_context_button_active(const bContext *C, int (*but_check_cb)(uiBut *))
{
- uiBut *but_found= NULL;
+ uiBut *but_found = NULL;
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
while (ar) {
uiBlock *block;
- uiBut *but, *activebut= NULL;
+ uiBut *but, *activebut = NULL;
/* find active button */
- for (block=ar->uiblocks.first; block; block=block->next) {
- for (but=block->buttons.first; but; but= but->next) {
+ for (block = ar->uiblocks.first; block; block = block->next) {
+ for (but = block->buttons.first; but; but = but->next) {
if (but->active)
- activebut= but;
+ activebut = but;
else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE))
- activebut= but;
+ activebut = but;
}
}
if (activebut && (but_check_cb == NULL || but_check_cb(activebut))) {
- uiHandleButtonData *data= activebut->active;
+ uiHandleButtonData *data = activebut->active;
- but_found= activebut;
+ but_found = activebut;
/* recurse into opened menu, like colorpicker case */
if (data && data->menu && (ar != data->menu->region)) {
@@ -5351,29 +5353,29 @@ uiBut *uiContextActiveButton(const struct bContext *C)
/* helper function for insert keyframe, reset to default, etc operators */
void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index)
{
- uiBut *activebut= ui_context_rna_button_active(C);
+ uiBut *activebut = ui_context_rna_button_active(C);
memset(ptr, 0, sizeof(*ptr));
if (activebut && activebut->rnapoin.data) {
- *ptr= activebut->rnapoin;
- *prop= activebut->rnaprop;
- *index= activebut->rnaindex;
+ *ptr = activebut->rnapoin;
+ *prop = activebut->rnaprop;
+ *index = activebut->rnaindex;
}
else {
- *prop= NULL;
- *index= 0;
+ *prop = NULL;
+ *index = 0;
}
}
void uiContextActivePropertyHandle(bContext *C)
{
- uiBut *activebut= ui_context_rna_button_active(C);
+ uiBut *activebut = ui_context_rna_button_active(C);
if (activebut) {
/* TODO, look into a better way to handle the button change
* currently this is mainly so reset defaults works for the
* operator redo panel - campbell */
- uiBlock *block= activebut->block;
+ uiBlock *block = activebut->block;
if (block->handle_func) {
block->handle_func(C, block->handle_func_arg, 0);
}
@@ -5382,7 +5384,7 @@ void uiContextActivePropertyHandle(bContext *C)
wmOperator *uiContextActiveOperator(const struct bContext *C)
{
- ARegion *ar_ctx= CTX_wm_region(C);
+ ARegion *ar_ctx = CTX_wm_region(C);
uiBlock *block;
/* background mode */
@@ -5391,7 +5393,7 @@ wmOperator *uiContextActiveOperator(const struct bContext *C)
}
/* scan active regions ui */
- for (block=ar_ctx->uiblocks.first; block; block=block->next) {
+ for (block = ar_ctx->uiblocks.first; block; block = block->next) {
if (block->ui_operator) {
return block->ui_operator;
}
@@ -5399,14 +5401,14 @@ wmOperator *uiContextActiveOperator(const struct bContext *C)
/* scan popups */
{
- bScreen *sc= CTX_wm_screen(C);
+ bScreen *sc = CTX_wm_screen(C);
ARegion *ar;
- for (ar= sc->regionbase.first; ar; ar= ar->next) {
+ for (ar = sc->regionbase.first; ar; ar = ar->next) {
if (ar == ar_ctx) {
continue;
}
- for (block=ar->uiblocks.first; block; block=block->next) {
+ for (block = ar->uiblocks.first; block; block = block->next) {
if (block->ui_operator) {
return block->ui_operator;
}
@@ -5420,30 +5422,30 @@ wmOperator *uiContextActiveOperator(const struct bContext *C)
/* helper function for insert keyframe, reset to default, etc operators */
void uiContextAnimUpdate(const bContext *C)
{
- Scene *scene= CTX_data_scene(C);
- ARegion *ar= CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ ARegion *ar = CTX_wm_region(C);
uiBlock *block;
uiBut *but, *activebut;
while (ar) {
/* find active button */
- activebut= NULL;
+ activebut = NULL;
- for (block=ar->uiblocks.first; block; block=block->next) {
- for (but=block->buttons.first; but; but= but->next) {
- ui_but_anim_flag(but, (scene)? scene->r.cfra: 0.0f);
+ for (block = ar->uiblocks.first; block; block = block->next) {
+ for (but = block->buttons.first; but; but = but->next) {
+ ui_but_anim_flag(but, (scene) ? scene->r.cfra : 0.0f);
ED_region_tag_redraw(ar);
if (but->active)
- activebut= but;
+ activebut = but;
else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE))
- activebut= but;
+ activebut = but;
}
}
if (activebut) {
/* always recurse into opened menu, so all buttons update (like colorpicker) */
- uiHandleButtonData *data= activebut->active;
+ uiHandleButtonData *data = activebut->active;
if (data && data->menu)
ar = data->menu->region;
else
@@ -5463,9 +5465,9 @@ static uiBut *uit_but_find_open_event(ARegion *ar, wmEvent *event)
uiBlock *block;
uiBut *but;
- for (block=ar->uiblocks.first; block; block=block->next) {
- for (but=block->buttons.first; but; but= but->next)
- if (but==event->customdata)
+ for (block = ar->uiblocks.first; block; block = block->next) {
+ for (but = block->buttons.first; but; but = but->next)
+ if (but == event->customdata)
return but;
}
return NULL;
@@ -5476,12 +5478,12 @@ static int ui_handle_button_over(bContext *C, wmEvent *event, ARegion *ar)
uiBut *but;
if (event->type == MOUSEMOVE) {
- but= ui_but_find_mouse_over(ar, event->x, event->y);
+ but = ui_but_find_mouse_over(ar, event->x, event->y);
if (but)
button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
}
else if (event->type == EVT_BUT_OPEN) {
- but= uit_but_find_open_event(ar, event);
+ but = uit_but_find_open_event(ar, event);
if (but) {
button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
ui_do_button(C, but->block, but, event);
@@ -5494,16 +5496,16 @@ static int ui_handle_button_over(bContext *C, wmEvent *event, ARegion *ar)
/* exported to interface.c: uiButActiveOnly() */
void ui_button_activate_do(bContext *C, ARegion *ar, uiBut *but)
{
- wmWindow *win= CTX_wm_window(C);
+ wmWindow *win = CTX_wm_window(C);
wmEvent event;
button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER);
- event= *(win->eventstate); /* XXX huh huh? make api call */
- event.type= EVT_BUT_OPEN;
- event.val= KM_PRESS;
- event.customdata= but;
- event.customdatafree= FALSE;
+ event = *(win->eventstate); /* XXX huh huh? make api call */
+ event.type = EVT_BUT_OPEN;
+ event.val = KM_PRESS;
+ event.customdata = but;
+ event.customdatafree = FALSE;
ui_do_button(C, but->block, but, &event);
}
@@ -5513,10 +5515,10 @@ static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiBu
uiBut *oldbut;
uiHandleButtonData *data;
- oldbut= ui_but_find_activated(ar);
+ oldbut = ui_but_find_activated(ar);
if (oldbut) {
- data= oldbut->active;
- data->cancel= 1;
+ data = oldbut->active;
+ data->cancel = 1;
button_activate_exit(C, data, oldbut, 0, 0);
}
@@ -5534,31 +5536,31 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
uiButtonActivateType posttype;
int retval;
- data= but->active;
- block= but->block;
- ar= data->region;
+ data = but->active;
+ block = but->block;
+ ar = data->region;
- retval= WM_UI_HANDLER_CONTINUE;
+ retval = WM_UI_HANDLER_CONTINUE;
if (data->state == BUTTON_STATE_HIGHLIGHT) {
- switch(event->type) {
+ switch (event->type) {
case WINDEACTIVATE:
case EVT_BUT_CANCEL:
- data->cancel= 1;
+ data->cancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
- retval= WM_UI_HANDLER_CONTINUE;
+ retval = WM_UI_HANDLER_CONTINUE;
break;
case MOUSEMOVE:
/* verify if we are still over the button, if not exit */
if (!ui_mouse_inside_button(ar, but, event->x, event->y)) {
- data->cancel= 1;
+ data->cancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
else if (ui_but_find_mouse_over(ar, event->x, event->y) != but) {
- data->cancel= 1;
+ data->cancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
- else if (event->x!=event->prevx || event->y!=event->prevy) {
+ else if (event->x != event->prevx || event->y != event->prevy) {
/* re-enable tooltip on mouse move */
ui_blocks_set_tooltips(ar, 1);
button_tooltip_timer_reset(C, but);
@@ -5569,46 +5571,46 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
/* handle tooltip timer */
if (event->customdata == data->tooltiptimer) {
WM_event_remove_timer(data->wm, data->window, data->tooltiptimer);
- data->tooltiptimer= NULL;
+ data->tooltiptimer = NULL;
if (!data->tooltip)
- data->tooltip= ui_tooltip_create(C, data->region, but);
+ data->tooltip = ui_tooltip_create(C, data->region, but);
}
/* handle menu auto open timer */
else if (event->customdata == data->autoopentimer) {
WM_event_remove_timer(data->wm, data->window, data->autoopentimer);
- data->autoopentimer= NULL;
+ data->autoopentimer = NULL;
if (ui_mouse_inside_button(ar, but, event->x, event->y))
button_activate_state(C, but, BUTTON_STATE_MENU_OPEN);
}
- retval= WM_UI_HANDLER_CONTINUE;
+ retval = WM_UI_HANDLER_CONTINUE;
break;
- case WHEELUPMOUSE:
- case WHEELDOWNMOUSE:
- case MIDDLEMOUSE:
- /* XXX hardcoded keymap check... but anyway, while view changes, tooltips should be removed */
- if (data->tooltiptimer) {
- WM_event_remove_timer(data->wm, data->window, data->tooltiptimer);
- data->tooltiptimer= NULL;
- }
+ case WHEELUPMOUSE:
+ case WHEELDOWNMOUSE:
+ case MIDDLEMOUSE:
+ /* XXX hardcoded keymap check... but anyway, while view changes, tooltips should be removed */
+ if (data->tooltiptimer) {
+ WM_event_remove_timer(data->wm, data->window, data->tooltiptimer);
+ data->tooltiptimer = NULL;
+ }
/* pass on purposedly */
- default:
- /* handle button type specific events */
- retval= ui_do_button(C, block, but, event);
+ default:
+ /* handle button type specific events */
+ retval = ui_do_button(C, block, but, event);
}
}
}
else if (data->state == BUTTON_STATE_WAIT_RELEASE) {
- switch(event->type) {
+ switch (event->type) {
case WINDEACTIVATE:
- data->cancel= 1;
+ data->cancel = 1;
button_activate_state(C, but, BUTTON_STATE_EXIT);
break;
case MOUSEMOVE:
- if (ELEM(but->type,LINK, INLINK)) {
+ if (ELEM(but->type, LINK, INLINK)) {
but->flag |= UI_SELECT;
ui_do_button(C, block, but, event);
ED_region_tag_redraw(data->region);
@@ -5618,15 +5620,15 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
/* also de-activate for buttons that only show higlights */
if (ui_mouse_inside_button(ar, but, event->x, event->y)) {
if (!(but->flag & UI_SELECT)) {
- but->flag |= (UI_SELECT|UI_ACTIVE);
- data->cancel= 0;
+ but->flag |= (UI_SELECT | UI_ACTIVE);
+ data->cancel = 0;
ED_region_tag_redraw(data->region);
}
}
else {
if (but->flag & UI_SELECT) {
- but->flag &= ~(UI_SELECT|UI_ACTIVE);
- data->cancel= 1;
+ but->flag &= ~(UI_SELECT | UI_ACTIVE);
+ data->cancel = 1;
ED_region_tag_redraw(data->region);
}
}
@@ -5638,50 +5640,50 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
break;
}
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
else if (data->state == BUTTON_STATE_WAIT_FLASH) {
- switch(event->type) {
+ switch (event->type) {
case TIMER: {
if (event->customdata == data->flashtimer)
button_activate_state(C, but, BUTTON_STATE_EXIT);
}
}
- retval= WM_UI_HANDLER_CONTINUE;
+ retval = WM_UI_HANDLER_CONTINUE;
}
else if (data->state == BUTTON_STATE_MENU_OPEN) {
/* check for exit because of mouse-over another button */
- switch(event->type) {
+ switch (event->type) {
case MOUSEMOVE:
if (data->menu && data->menu->region)
if (ui_mouse_inside_region(data->menu->region, event->x, event->y))
break;
- {
- uiBut *bt= ui_but_find_mouse_over(ar, event->x, event->y);
+ {
+ uiBut *bt = ui_but_find_mouse_over(ar, event->x, event->y);
- if (bt && bt->active != data) {
- if (but->type != COL) /* exception */
- data->cancel= 1;
- button_activate_state(C, but, BUTTON_STATE_EXIT);
+ if (bt && bt->active != data) {
+ if (but->type != COL) /* exception */
+ data->cancel = 1;
+ button_activate_state(C, but, BUTTON_STATE_EXIT);
+ }
+ break;
}
- break;
- }
}
ui_do_button(C, block, but, event);
- retval= WM_UI_HANDLER_CONTINUE;
+ retval = WM_UI_HANDLER_CONTINUE;
}
else {
- retval= ui_do_button(C, block, but, event);
+ retval = ui_do_button(C, block, but, event);
// retval= WM_UI_HANDLER_BREAK; XXX why ?
}
if (data->state == BUTTON_STATE_EXIT) {
- postbut= data->postbut;
- posttype= data->posttype;
+ postbut = data->postbut;
+ posttype = data->posttype;
button_activate_exit(C, data, but, (postbut == NULL), 0);
@@ -5695,17 +5697,17 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but)
static int ui_handle_list_event(bContext *C, wmEvent *event, ARegion *ar)
{
- uiBut *but= ui_list_find_mouse_over(ar, event->x, event->y);
- int retval= WM_UI_HANDLER_CONTINUE;
+ uiBut *but = ui_list_find_mouse_over(ar, event->x, event->y);
+ int retval = WM_UI_HANDLER_CONTINUE;
int value, min, max;
if (but && (event->val == KM_PRESS)) {
- Panel *pa= but->block->panel;
+ Panel *pa = but->block->panel;
if (ELEM(event->type, UPARROWKEY, DOWNARROWKEY) ||
- ((ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->alt))) {
+ ((ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->alt))) {
/* activate up/down the list */
- value= RNA_property_int_get(&but->rnapoin, but->rnaprop);
+ value = RNA_property_int_get(&but->rnapoin, but->rnaprop);
if (ELEM(event->type, UPARROWKEY, WHEELUPMOUSE))
value--;
@@ -5713,34 +5715,34 @@ static int ui_handle_list_event(bContext *C, wmEvent *event, ARegion *ar)
value++;
if (value < pa->list_scroll)
- pa->list_scroll= value;
- else if (value >= pa->list_scroll+pa->list_size)
- pa->list_scroll= value - pa->list_size + 1;
+ pa->list_scroll = value;
+ else if (value >= pa->list_scroll + pa->list_size)
+ pa->list_scroll = value - pa->list_size + 1;
RNA_property_int_range(&but->rnapoin, but->rnaprop, &min, &max);
- value= CLAMPIS(value, min, max);
+ value = CLAMPIS(value, min, max);
RNA_property_int_set(&but->rnapoin, but->rnaprop, value);
RNA_property_update(C, &but->rnapoin, but->rnaprop);
ED_region_tag_redraw(ar);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
else if (ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->shift) {
/* silly replacement for proper grip */
if (pa->list_grip_size == 0)
- pa->list_grip_size= pa->list_size;
+ pa->list_grip_size = pa->list_size;
if (event->type == WHEELUPMOUSE)
pa->list_grip_size--;
else
pa->list_grip_size++;
- pa->list_grip_size= MAX2(pa->list_grip_size, 1);
+ pa->list_grip_size = MAX2(pa->list_grip_size, 1);
ED_region_tag_redraw(ar);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
else if (ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE)) {
if (pa->list_last_len > pa->list_size) {
@@ -5752,7 +5754,7 @@ static int ui_handle_list_event(bContext *C, wmEvent *event, ARegion *ar)
ED_region_tag_redraw(ar);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
}
}
@@ -5765,43 +5767,43 @@ static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut *
uiHandleButtonData *data;
uiPopupBlockHandle *menu;
- data= but->active;
- menu= data->menu;
+ data = but->active;
+ menu = data->menu;
/* copy over return values from the closing menu */
if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_UPDATE)) {
if (but->type == COL)
copy_v3_v3(data->vec, menu->retvec);
else if (ELEM3(but->type, MENU, ICONROW, ICONTEXTROW))
- data->value= menu->retvalue;
+ data->value = menu->retvalue;
}
if (menu->menuretval & UI_RETURN_UPDATE) {
if (data->interactive) ui_apply_button(C, but->block, but, data, 1);
else ui_check_but(but);
- menu->menuretval= 0;
+ menu->menuretval = 0;
}
/* now change button state or exit, which will close the submenu */
if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_CANCEL)) {
if (menu->menuretval != UI_RETURN_OK)
- data->cancel= 1;
+ data->cancel = 1;
button_activate_exit(C, data, but, 1, 0);
}
else if (menu->menuretval & UI_RETURN_OUT) {
- if (event->type==MOUSEMOVE && ui_mouse_inside_button(data->region, but, event->x, event->y)) {
+ if (event->type == MOUSEMOVE && ui_mouse_inside_button(data->region, but, event->x, event->y)) {
button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT);
}
else {
if (ISKEYBOARD(event->type)) {
/* keyboard menu hierarchy navigation, going back to previous level */
- but->active->used_mouse= 0;
+ but->active->used_mouse = 0;
button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT);
}
else {
- data->cancel= 1;
+ data->cancel = 1;
button_activate_exit(C, data, but, 1, 0);
}
}
@@ -5822,14 +5824,14 @@ static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut *
static void ui_mouse_motion_towards_init(uiPopupBlockHandle *menu, int mx, int my, int force)
{
if (!menu->dotowards || force) {
- menu->dotowards= 1;
- menu->towardsx= mx;
- menu->towardsy= my;
+ menu->dotowards = 1;
+ menu->towardsx = mx;
+ menu->towardsy = my;
if (force)
- menu->towardstime= DBL_MAX; /* unlimited time */
+ menu->towardstime = DBL_MAX; /* unlimited time */
else
- menu->towardstime= PIL_check_seconds_timer();
+ menu->towardstime = PIL_check_seconds_timer();
}
}
@@ -5843,51 +5845,51 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men
/* verify that we are moving towards one of the edges of the
* menu block, in other words, in the triangle formed by the
* initial mouse location and two edge points. */
- p1[0]= block->minx-20;
- p1[1]= block->miny-20;
+ p1[0] = block->minx - 20;
+ p1[1] = block->miny - 20;
- p2[0]= block->maxx+20;
- p2[1]= block->miny-20;
+ p2[0] = block->maxx + 20;
+ p2[1] = block->miny - 20;
- p3[0]= block->maxx+20;
- p3[1]= block->maxy+20;
+ p3[0] = block->maxx + 20;
+ p3[1] = block->maxy + 20;
- p4[0]= block->minx-20;
- p4[1]= block->maxy+20;
+ p4[0] = block->minx - 20;
+ p4[1] = block->maxy + 20;
- oldp[0]= menu->towardsx;
- oldp[1]= menu->towardsy;
+ oldp[0] = menu->towardsx;
+ oldp[1] = menu->towardsy;
- newp[0]= mx;
- newp[1]= my;
+ newp[0] = mx;
+ newp[1] = my;
if (len_v2v2(oldp, newp) < 4.0f)
return menu->dotowards;
- closer= 0;
+ closer = 0;
closer |= isect_point_tri_v2(newp, oldp, p1, p2);
closer |= isect_point_tri_v2(newp, oldp, p2, p3);
closer |= isect_point_tri_v2(newp, oldp, p3, p4);
closer |= isect_point_tri_v2(newp, oldp, p4, p1);
if (!closer)
- menu->dotowards= 0;
+ menu->dotowards = 0;
/* 1 second timer */
if (PIL_check_seconds_timer() - menu->towardstime > BUTTON_MOUSE_TOWARDS_THRESH)
- menu->dotowards= 0;
+ menu->dotowards = 0;
return menu->dotowards;
}
static char ui_menu_scroll_test(uiBlock *block, int my)
{
- if (block->flag & (UI_BLOCK_CLIPTOP|UI_BLOCK_CLIPBOTTOM)) {
+ if (block->flag & (UI_BLOCK_CLIPTOP | UI_BLOCK_CLIPBOTTOM)) {
if (block->flag & UI_BLOCK_CLIPTOP)
- if (my > block->maxy-14)
+ if (my > block->maxy - 14)
return 't';
if (block->flag & UI_BLOCK_CLIPBOTTOM)
- if (my < block->miny+14)
+ if (my < block->miny + 14)
return 'b';
}
return 0;
@@ -5895,46 +5897,46 @@ static char ui_menu_scroll_test(uiBlock *block, int my)
static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my)
{
- char test= ui_menu_scroll_test(block, my);
+ char test = ui_menu_scroll_test(block, my);
if (test) {
- uiBut *b1= block->buttons.first;
- uiBut *b2= block->buttons.last;
+ uiBut *b1 = block->buttons.first;
+ uiBut *b2 = block->buttons.last;
uiBut *bnext;
uiBut *bprev;
- int dy= 0;
+ int dy = 0;
/* get first and last visible buttons */
while (b1 && ui_but_next(b1) && (b1->flag & UI_SCROLLED))
- b1= ui_but_next(b1);
+ b1 = ui_but_next(b1);
while (b2 && ui_but_prev(b2) && (b2->flag & UI_SCROLLED))
- b2= ui_but_prev(b2);
+ b2 = ui_but_prev(b2);
/* skips separators */
- bnext= ui_but_next(b1);
- bprev= ui_but_prev(b2);
+ bnext = ui_but_next(b1);
+ bprev = ui_but_prev(b2);
- if (bnext==NULL || bprev==NULL)
+ if (bnext == NULL || bprev == NULL)
return 0;
- if (test=='t') {
+ if (test == 't') {
/* bottom button is first button */
if (b1->y1 < b2->y1)
- dy= bnext->y1 - b1->y1;
+ dy = bnext->y1 - b1->y1;
/* bottom button is last button */
else
- dy= bprev->y1 - b2->y1;
+ dy = bprev->y1 - b2->y1;
}
- else if (test=='b') {
+ else if (test == 'b') {
/* bottom button is first button */
if (b1->y1 < b2->y1)
- dy= b1->y1 - bnext->y1;
+ dy = b1->y1 - bnext->y1;
/* bottom button is last button */
else
- dy= b2->y1 - bprev->y1;
+ dy = b2->y1 - bprev->y1;
}
if (dy) {
- for (b1= block->buttons.first; b1; b1= b1->next) {
+ for (b1 = block->buttons.first; b1; b1 = b1->next) {
b1->y1 -= dy;
b1->y2 -= dy;
}
@@ -5957,25 +5959,25 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
uiBut *but, *bt;
int inside, act, count, mx, my, retval;
- ar= menu->region;
- block= ar->uiblocks.first;
+ ar = menu->region;
+ block = ar->uiblocks.first;
- act= 0;
- retval= WM_UI_HANDLER_CONTINUE;
+ act = 0;
+ retval = WM_UI_HANDLER_CONTINUE;
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(ar, block, &mx, &my);
/* check if mouse is inside block */
- inside= 0;
+ inside = 0;
if (block->minx <= mx && block->maxx >= mx)
if (block->miny <= my && block->maxy >= my)
- inside= 1;
+ inside = 1;
/* if there's an active modal button, don't check events or outside, except for search menu */
- but= ui_but_find_activated(ar);
- if (but && button_modal_state(but->active->state) && but->type!=SEARCH_MENU) {
+ but = ui_but_find_activated(ar);
+ if (but && button_modal_state(but->active->state) && but->type != SEARCH_MENU) {
/* if a button is activated modal, always reset the start mouse
* position of the towards mechanism to avoid loosing focus,
* and don't handle events */
@@ -5992,41 +5994,41 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
/* add menu scroll timer, if needed */
if (ui_menu_scroll_test(block, my))
- if (menu->scrolltimer==NULL)
- menu->scrolltimer=
- WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, MENU_SCROLL_INTERVAL);
+ if (menu->scrolltimer == NULL)
+ menu->scrolltimer =
+ WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, MENU_SCROLL_INTERVAL);
}
/* first block own event func */
- if (block->block_event_func && block->block_event_func(C, block, event));
+ if (block->block_event_func && block->block_event_func(C, block, event)) ;
/* events not for active search menu button */
- else if (but==NULL || but->type!=SEARCH_MENU) {
- switch(event->type) {
+ else if (but == NULL || but->type != SEARCH_MENU) {
+ switch (event->type) {
/* closing sublevels of pulldowns */
case LEFTARROWKEY:
- if (event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP))
+ if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP))
if (block->saferct.first)
- menu->menuretval= UI_RETURN_OUT;
+ menu->menuretval = UI_RETURN_OUT;
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
break;
/* opening sublevels of pulldowns */
case RIGHTARROWKEY:
- if (event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) {
- but= ui_but_find_activated(ar);
+ if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) {
+ but = ui_but_find_activated(ar);
if (!but) {
/* no item active, we make first active */
- if (block->direction & UI_TOP) but= ui_but_last(block);
- else but= ui_but_first(block);
+ if (block->direction & UI_TOP) but = ui_but_last(block);
+ else but = ui_but_first(block);
}
if (but && ELEM(but->type, BLOCK, PULLDOWN))
ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN);
}
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
break;
case UPARROWKEY:
@@ -6034,28 +6036,28 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
case WHEELUPMOUSE:
case WHEELDOWNMOUSE:
/* arrowkeys: only handle for block_loop blocks */
- if (event->alt || event->shift || event->ctrl || event->oskey);
+ if (event->alt || event->shift || event->ctrl || event->oskey) ;
else if (inside || (block->flag & UI_BLOCK_LOOP)) {
- if (event->val==KM_PRESS) {
- but= ui_but_find_activated(ar);
+ if (event->val == KM_PRESS) {
+ but = ui_but_find_activated(ar);
if (but) {
/* is there a situation where UI_LEFT or UI_RIGHT would also change navigation direction? */
- if ( ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DOWN)) ||
- ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_RIGHT)) ||
- ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_TOP))
- ) {
+ if (((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DOWN)) ||
+ ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_RIGHT)) ||
+ ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_TOP)))
+ {
/* the following is just a hack - uiBut->type set to BUT and BUTM have there menus built
* opposite ways - this should be changed so that all popup-menus use the same uiBlock->direction */
if (but->type & BUT)
- but= ui_but_next(but);
+ but = ui_but_next(but);
else
- but= ui_but_prev(but);
+ but = ui_but_prev(but);
}
else {
if (but->type & BUT)
- but= ui_but_prev(but);
+ but = ui_but_prev(but);
else
- but= ui_but_next(but);
+ but = ui_but_next(but);
}
if (but)
@@ -6063,23 +6065,23 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
}
if (!but) {
- if ( ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DOWN)) ||
- ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_RIGHT)) ||
- ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_TOP))
- ) {
- if ((bt= ui_but_first(block)) && (bt->type & BUT)) {
- bt= ui_but_last(block);
+ if (((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DOWN)) ||
+ ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_RIGHT)) ||
+ ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_TOP)))
+ {
+ if ((bt = ui_but_first(block)) && (bt->type & BUT)) {
+ bt = ui_but_last(block);
}
else {
/* keep ui_but_first() */
}
}
else {
- if ((bt= ui_but_first(block)) && (bt->type & BUT)) {
+ if ((bt = ui_but_first(block)) && (bt->type & BUT)) {
/* keep ui_but_first() */
}
else {
- bt= ui_but_last(block);
+ bt = ui_but_last(block);
}
}
@@ -6088,56 +6090,56 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
}
}
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
break;
- case ONEKEY: case PAD1:
- act= 1;
- case TWOKEY: case PAD2:
- if (act==0) act= 2;
- case THREEKEY: case PAD3:
- if (act==0) act= 3;
- case FOURKEY: case PAD4:
- if (act==0) act= 4;
- case FIVEKEY: case PAD5:
- if (act==0) act= 5;
- case SIXKEY: case PAD6:
- if (act==0) act= 6;
- case SEVENKEY: case PAD7:
- if (act==0) act= 7;
- case EIGHTKEY: case PAD8:
- if (act==0) act= 8;
- case NINEKEY: case PAD9:
- if (act==0) act= 9;
- case ZEROKEY: case PAD0:
- if (act==0) act= 10;
-
- if ((block->flag & UI_BLOCK_NUMSELECT) && event->val==KM_PRESS) {
- if (event->alt) act+= 10;
-
- count= 0;
- for (but= block->buttons.first; but; but= but->next) {
- int doit= 0;
+ case ONEKEY: case PAD1:
+ act = 1;
+ case TWOKEY: case PAD2:
+ if (act == 0) act = 2;
+ case THREEKEY: case PAD3:
+ if (act == 0) act = 3;
+ case FOURKEY: case PAD4:
+ if (act == 0) act = 4;
+ case FIVEKEY: case PAD5:
+ if (act == 0) act = 5;
+ case SIXKEY: case PAD6:
+ if (act == 0) act = 6;
+ case SEVENKEY: case PAD7:
+ if (act == 0) act = 7;
+ case EIGHTKEY: case PAD8:
+ if (act == 0) act = 8;
+ case NINEKEY: case PAD9:
+ if (act == 0) act = 9;
+ case ZEROKEY: case PAD0:
+ if (act == 0) act = 10;
+
+ if ((block->flag & UI_BLOCK_NUMSELECT) && event->val == KM_PRESS) {
+ if (event->alt) act += 10;
+
+ count = 0;
+ for (but = block->buttons.first; but; but = but->next) {
+ int doit = 0;
- if (but->type!=LABEL && but->type!=SEPR)
+ if (but->type != LABEL && but->type != SEPR)
count++;
/* exception for rna layer buts */
if (but->rnapoin.data && but->rnaprop) {
if (ELEM(RNA_property_subtype(but->rnaprop), PROP_LAYER, PROP_LAYER_MEMBER)) {
- if (but->rnaindex== act-1)
- doit=1;
+ if (but->rnaindex == act - 1)
+ doit = 1;
}
}
/* exception for menus like layer buts, with button aligning they're not drawn in order */
- else if (but->type==TOGR) {
- if (but->bitnr==act-1)
- doit= 1;
+ else if (but->type == TOGR) {
+ if (but->bitnr == act - 1)
+ doit = 1;
}
- else if (count==act)
- doit=1;
+ else if (count == act)
+ doit = 1;
if (doit) {
ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY);
@@ -6145,7 +6147,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
}
}
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
break;
@@ -6177,14 +6179,14 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
case YKEY:
case ZKEY:
{
- if ( (event->val == KM_PRESS) &&
+ if ((event->val == KM_PRESS) &&
(event->shift == FALSE) &&
(event->ctrl == FALSE) &&
- (event->oskey == FALSE)
- ) {
- for (but= block->buttons.first; but; but= but->next) {
+ (event->oskey == FALSE))
+ {
+ for (but = block->buttons.first; but; but = but->next) {
- if (but->menu_key==event->type) {
+ if (but->menu_key == event->type) {
if (but->type == BUT) {
/* mainly for operator buttons */
ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY);
@@ -6205,7 +6207,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
}
}
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
break;
}
@@ -6216,43 +6218,43 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
if (block->flag & UI_BLOCK_LOOP) {
/* if we click outside the block, verify if we clicked on the
* button that opened us, otherwise we need to close */
- if (inside==0) {
- uiSafetyRct *saferct= block->saferct.first;
+ if (inside == 0) {
+ uiSafetyRct *saferct = block->saferct.first;
- if (ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) && event->val==KM_PRESS) {
+ if (ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) && event->val == KM_PRESS) {
if (saferct && !BLI_in_rctf(&saferct->parent, event->x, event->y)) {
if (block->flag & (UI_BLOCK_OUT_1))
- menu->menuretval= UI_RETURN_OK;
+ menu->menuretval = UI_RETURN_OK;
else
- menu->menuretval= UI_RETURN_OUT;
+ menu->menuretval = UI_RETURN_OUT;
}
}
}
- if (menu->menuretval);
- else if (event->type==ESCKEY && event->val==KM_PRESS) {
+ if (menu->menuretval) ;
+ else if (event->type == ESCKEY && event->val == KM_PRESS) {
/* esc cancels this and all preceding menus */
- menu->menuretval= UI_RETURN_CANCEL;
+ menu->menuretval = UI_RETURN_CANCEL;
}
- else if (ELEM(event->type, RETKEY, PADENTER) && event->val==KM_PRESS) {
+ else if (ELEM(event->type, RETKEY, PADENTER) && event->val == KM_PRESS) {
/* enter will always close this block, we let the event
* get handled by the button if it is activated, otherwise we cancel */
if (!ui_but_find_activated(ar))
- menu->menuretval= UI_RETURN_CANCEL | UI_RETURN_POPUP_OK;
+ menu->menuretval = UI_RETURN_CANCEL | UI_RETURN_POPUP_OK;
}
else {
ui_mouse_motion_towards_check(block, menu, mx, my);
/* check mouse moving outside of the menu */
- if (inside==0 && (block->flag & UI_BLOCK_MOVEMOUSE_QUIT)) {
+ if (inside == 0 && (block->flag & UI_BLOCK_MOVEMOUSE_QUIT)) {
uiSafetyRct *saferct;
/* check for all parent rects, enables arrowkeys to be used */
- for (saferct=block->saferct.first; saferct; saferct= saferct->next) {
+ for (saferct = block->saferct.first; saferct; saferct = saferct->next) {
/* for mouse move we only check our own rect, for other
* events we check all preceding block rects too to make
* arrow keys navigation work */
- if (event->type!=MOUSEMOVE || saferct==block->saferct.first) {
+ if (event->type != MOUSEMOVE || saferct == block->saferct.first) {
if (BLI_in_rctf(&saferct->parent, (float)event->x, (float)event->y))
break;
if (BLI_in_rctf(&saferct->safety, (float)event->x, (float)event->y))
@@ -6263,12 +6265,12 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
/* strict check, and include the parent rect */
if (!menu->dotowards && !saferct) {
if (block->flag & (UI_BLOCK_OUT_1))
- menu->menuretval= UI_RETURN_OK;
+ menu->menuretval = UI_RETURN_OK;
else
- menu->menuretval= UI_RETURN_OUT;
+ menu->menuretval = UI_RETURN_OUT;
}
- else if (menu->dotowards && event->type==MOUSEMOVE)
- retval= WM_UI_HANDLER_BREAK;
+ else if (menu->dotowards && event->type == MOUSEMOVE)
+ retval = WM_UI_HANDLER_BREAK;
}
}
}
@@ -6279,22 +6281,22 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle
* anymore why it was there? but it meant enter didn't work
* for example when mouse was not over submenu */
if ((/*inside &&*/ (!menu->menuretval || (menu->menuretval & UI_RETURN_UPDATE)) && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) {
- but= ui_but_find_activated(ar);
+ but = ui_but_find_activated(ar);
if (but) {
- ScrArea *ctx_area= CTX_wm_area(C);
- ARegion *ctx_region= CTX_wm_region(C);
+ ScrArea *ctx_area = CTX_wm_area(C);
+ ARegion *ctx_region = CTX_wm_region(C);
if (menu->ctx_area) CTX_wm_area_set(C, menu->ctx_area);
if (menu->ctx_region) CTX_wm_region_set(C, menu->ctx_region);
- retval= ui_handle_button_event(C, event, but);
+ retval = ui_handle_button_event(C, event, but);
if (menu->ctx_area) CTX_wm_area_set(C, ctx_area);
if (menu->ctx_region) CTX_wm_region_set(C, ctx_region);
}
else
- retval= ui_handle_button_over(C, event, ar);
+ retval = ui_handle_button_over(C, event, ar);
}
/* if we set a menu return value, ensure we continue passing this on to
@@ -6317,24 +6319,24 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo
uiPopupBlockHandle *submenu;
int mx, my, update;
- ar= menu->region;
- block= ar->uiblocks.first;
+ ar = menu->region;
+ block = ar->uiblocks.first;
- but= ui_but_find_activated(ar);
- data= but->active;
- submenu= data->menu;
+ but = ui_but_find_activated(ar);
+ data = but->active;
+ submenu = data->menu;
if (submenu->menuretval) {
/* first decide if we want to close our own menu cascading, if
* so pass on the sub menu return value to our own menu handle */
if ((submenu->menuretval & UI_RETURN_OK) || (submenu->menuretval & UI_RETURN_CANCEL)) {
if (!(block->flag & UI_BLOCK_KEEP_OPEN)) {
- menu->menuretval= submenu->menuretval;
- menu->butretval= data->retval;
+ menu->menuretval = submenu->menuretval;
+ menu->butretval = data->retval;
}
}
- update= (submenu->menuretval & UI_RETURN_UPDATE);
+ update = (submenu->menuretval & UI_RETURN_UPDATE);
/* now let activated button in this menu exit, which
* will actually close the submenu too */
@@ -6346,8 +6348,8 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo
/* for cases where close does not cascade, allow the user to
* move the mouse back towards the menu without closing */
- mx= event->x;
- my= event->y;
+ mx = event->x;
+ my = event->y;
ui_window_to_block(ar, block, &mx, &my);
ui_mouse_motion_towards_init(menu, mx, my, 1);
@@ -6362,22 +6364,22 @@ static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHa
uiBut *but;
uiHandleButtonData *data;
uiPopupBlockHandle *submenu;
- int retval= WM_UI_HANDLER_CONTINUE;
+ int retval = WM_UI_HANDLER_CONTINUE;
/* check if we have a submenu, and handle events for it first */
- but= ui_but_find_activated(menu->region);
- data= (but)? but->active: NULL;
- submenu= (data)? data->menu: NULL;
+ but = ui_but_find_activated(menu->region);
+ data = (but) ? but->active : NULL;
+ submenu = (data) ? data->menu : NULL;
if (submenu)
- retval= ui_handle_menus_recursive(C, event, submenu);
+ retval = ui_handle_menus_recursive(C, event, submenu);
/* now handle events for our own menu */
if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) {
if (submenu && submenu->menuretval)
- retval= ui_handle_menu_return_submenu(C, event, menu);
+ retval = ui_handle_menu_return_submenu(C, event, menu);
else
- retval= ui_handle_menu_event(C, event, menu, (submenu == NULL));
+ retval = ui_handle_menu_event(C, event, menu, (submenu == NULL));
}
return retval;
@@ -6392,29 +6394,29 @@ static int ui_handler_region(bContext *C, wmEvent *event, void *UNUSED(userdata)
int retval;
/* here we handle buttons at the region level, non-modal */
- ar= CTX_wm_region(C);
- retval= WM_UI_HANDLER_CONTINUE;
+ ar = CTX_wm_region(C);
+ retval = WM_UI_HANDLER_CONTINUE;
- if (ar==NULL) return retval;
- if (ar->uiblocks.first==NULL) return retval;
+ if (ar == NULL) return retval;
+ if (ar->uiblocks.first == NULL) return retval;
/* either handle events for already activated button or try to activate */
- but= ui_but_find_activated(ar);
+ but = ui_but_find_activated(ar);
- retval= ui_handler_panel_region(C, event);
+ retval = ui_handler_panel_region(C, event);
if (retval == WM_UI_HANDLER_CONTINUE)
- retval= ui_handle_list_event(C, event, ar);
+ retval = ui_handle_list_event(C, event, ar);
if (retval == WM_UI_HANDLER_CONTINUE) {
if (but)
- retval= ui_handle_button_event(C, event, but);
+ retval = ui_handle_button_event(C, event, but);
else
- retval= ui_handle_button_over(C, event, ar);
+ retval = ui_handle_button_over(C, event, ar);
}
/* re-enable tooltips */
- if (event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy))
+ if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy))
ui_blocks_set_tooltips(ar, 1);
/* delayed apply callbacks */
@@ -6428,12 +6430,12 @@ static void ui_handler_remove_region(bContext *C, void *UNUSED(userdata))
bScreen *sc;
ARegion *ar;
- ar= CTX_wm_region(C);
+ ar = CTX_wm_region(C);
if (ar == NULL) return;
uiFreeBlocks(C, &ar->uiblocks);
- sc= CTX_wm_screen(C);
+ sc = CTX_wm_screen(C);
if (sc == NULL) return;
/* delayed apply callbacks, but not for screen level regions, those
@@ -6452,20 +6454,20 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *UNUSED(user
/* here we handle buttons at the window level, modal, for example
* while number sliding, text editing, or when a menu block is open */
- ar= CTX_wm_menu(C);
+ ar = CTX_wm_menu(C);
if (!ar)
- ar= CTX_wm_region(C);
+ ar = CTX_wm_region(C);
- but= ui_but_find_activated(ar);
+ but = ui_but_find_activated(ar);
if (but) {
/* handle activated button events */
- data= but->active;
+ data = but->active;
if (data->state == BUTTON_STATE_MENU_OPEN) {
/* handle events for menus and their buttons recursively,
* this will handle events from the top to the bottom menu */
- retval= ui_handle_menus_recursive(C, event, data->menu);
+ retval = ui_handle_menus_recursive(C, event, data->menu);
/* handle events for the activated button */
if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) {
@@ -6482,7 +6484,7 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *UNUSED(user
}
/* re-enable tooltips */
- if (event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy))
+ if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy))
ui_blocks_set_tooltips(ar, 1);
/* delayed apply callbacks */
@@ -6495,14 +6497,14 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *UNUSED(user
/* two types of popups, one with operator + enum, other with regular callbacks */
static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata)
{
- uiPopupBlockHandle *menu= userdata;
+ uiPopupBlockHandle *menu = userdata;
ui_handle_menus_recursive(C, event, menu);
/* free if done, does not free handle itself */
if (menu->menuretval) {
/* copy values, we have to free first (closes region) */
- uiPopupBlockHandle temp= *menu;
+ uiPopupBlockHandle temp = *menu;
ui_popup_block_free(C, menu);
UI_remove_popup_handlers(&CTX_wm_window(C)->modalhandlers, menu);
@@ -6518,7 +6520,7 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata)
}
else {
/* re-enable tooltips */
- if (event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy))
+ if (event->type == MOUSEMOVE && (event->x != event->prevx || event->y != event->prevy))
ui_blocks_set_tooltips(menu->region, 1);
}
@@ -6531,7 +6533,7 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata)
static void ui_handler_remove_popup(bContext *C, void *userdata)
{
- uiPopupBlockHandle *menu= userdata;
+ uiPopupBlockHandle *menu = userdata;
/* free menu block if window is closed for some reason */
ui_popup_block_free(C, menu);
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 4b5612c6408..24881c034f4 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -75,15 +75,15 @@
#include "interface_intern.h"
-#define ICON_IMAGE_W 600
-#define ICON_IMAGE_H 640
+#define ICON_IMAGE_W 600
+#define ICON_IMAGE_H 640
-#define ICON_GRID_COLS 26
-#define ICON_GRID_ROWS 30
+#define ICON_GRID_COLS 26
+#define ICON_GRID_ROWS 30
-#define ICON_GRID_MARGIN 5
-#define ICON_GRID_W 16
-#define ICON_GRID_H 16
+#define ICON_GRID_MARGIN 5
+#define ICON_GRID_W 16
+#define ICON_GRID_H 16
typedef struct IconImage {
int w;
@@ -93,10 +93,10 @@ typedef struct IconImage {
typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
-#define ICON_TYPE_PREVIEW 0
-#define ICON_TYPE_TEXTURE 1
-#define ICON_TYPE_BUFFER 2
-#define ICON_TYPE_VECTOR 3
+#define ICON_TYPE_PREVIEW 0
+#define ICON_TYPE_TEXTURE 1
+#define ICON_TYPE_BUFFER 2
+#define ICON_TYPE_VECTOR 3
typedef struct DrawInfo {
int type;
@@ -107,7 +107,7 @@ typedef struct DrawInfo {
VectorDrawFunc func;
} vector;
struct {
- IconImage* image;
+ IconImage *image;
} buffer;
struct {
int x, y, w, h;
@@ -145,24 +145,24 @@ static void def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, int
new_icon->type = 0;
di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
- di->type= type;
+ di->type = type;
if (type == ICON_TYPE_TEXTURE) {
- di->data.texture.x= xofs;
- di->data.texture.y= yofs;
- di->data.texture.w= size;
- di->data.texture.h= size;
+ di->data.texture.x = xofs;
+ di->data.texture.y = yofs;
+ di->data.texture.w = size;
+ di->data.texture.h = size;
}
else if (type == ICON_TYPE_BUFFER) {
iimg = MEM_mallocN(sizeof(IconImage), "icon_img");
- iimg->rect = MEM_mallocN(size*size*sizeof(unsigned int), "icon_rect");
+ iimg->rect = MEM_mallocN(size * size * sizeof(unsigned int), "icon_rect");
iimg->w = size;
iimg->h = size;
/* Here we store the rect in the icon - same as before */
imgsize = bbuf->x;
- for (y=0; y<size; y++) {
- memcpy(&iimg->rect[y*size], &bbuf->rect[(y+yofs)*imgsize+xofs], size*sizeof(int));
+ for (y = 0; y < size; y++) {
+ memcpy(&iimg->rect[y * size], &bbuf->rect[(y + yofs) * imgsize + xofs], size * sizeof(int));
}
di->data.buffer.image = iimg;
@@ -174,10 +174,10 @@ static void def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, int
BKE_icon_set(icon_id, new_icon);
}
-static void def_internal_vicon( int icon_id, VectorDrawFunc drawFunc)
+static void def_internal_vicon(int icon_id, VectorDrawFunc drawFunc)
{
Icon *new_icon = NULL;
- DrawInfo* di;
+ DrawInfo *di;
new_icon = MEM_callocN(sizeof(Icon), "texicon");
@@ -185,7 +185,7 @@ static void def_internal_vicon( int icon_id, VectorDrawFunc drawFunc)
new_icon->type = 0;
di = MEM_callocN(sizeof(DrawInfo), "drawinfo");
- di->type= ICON_TYPE_VECTOR;
+ di->type = ICON_TYPE_VECTOR;
di->data.vector.func = drawFunc;
new_icon->drawinfo_free = NULL;
@@ -196,7 +196,7 @@ static void def_internal_vicon( int icon_id, VectorDrawFunc drawFunc)
/* Vector Icon Drawing Routines */
- /* Utilities */
+/* Utilities */
static void viconutil_set_point(GLint pt[2], int x, int y)
{
@@ -204,7 +204,7 @@ static void viconutil_set_point(GLint pt[2], int x, int y)
pt[1] = y;
}
-static void viconutil_draw_tri(GLint (*pts)[2])
+static void viconutil_draw_tri(GLint(*pts)[2])
{
glBegin(GL_TRIANGLES);
glVertex2iv(pts[0]);
@@ -213,41 +213,41 @@ static void viconutil_draw_tri(GLint (*pts)[2])
glEnd();
}
-static void viconutil_draw_lineloop(GLint (*pts)[2], int numPoints)
+static void viconutil_draw_lineloop(GLint(*pts)[2], int numPoints)
{
int i;
glBegin(GL_LINE_LOOP);
- for (i=0; i<numPoints; i++) {
+ for (i = 0; i < numPoints; i++) {
glVertex2iv(pts[i]);
}
glEnd();
}
-static void viconutil_draw_lineloop_smooth(GLint (*pts)[2], int numPoints)
+static void viconutil_draw_lineloop_smooth(GLint(*pts)[2], int numPoints)
{
glEnable(GL_LINE_SMOOTH);
viconutil_draw_lineloop(pts, numPoints);
glDisable(GL_LINE_SMOOTH);
}
-static void viconutil_draw_points(GLint (*pts)[2], int numPoints, int pointSize)
+static void viconutil_draw_points(GLint(*pts)[2], int numPoints, int pointSize)
{
int i;
glBegin(GL_QUADS);
- for (i=0; i<numPoints; i++) {
+ for (i = 0; i < numPoints; i++) {
int x = pts[i][0], y = pts[i][1];
- glVertex2i(x-pointSize,y-pointSize);
- glVertex2i(x+pointSize,y-pointSize);
- glVertex2i(x+pointSize,y+pointSize);
- glVertex2i(x-pointSize,y+pointSize);
+ glVertex2i(x - pointSize, y - pointSize);
+ glVertex2i(x + pointSize, y - pointSize);
+ glVertex2i(x + pointSize, y + pointSize);
+ glVertex2i(x - pointSize, y + pointSize);
}
glEnd();
}
- /* Drawing functions */
+/* Drawing functions */
static void vicon_x_draw(int x, int y, int w, int h, float alpha)
{
@@ -256,48 +256,48 @@ static void vicon_x_draw(int x, int y, int w, int h, float alpha)
w -= 6;
h -= 6;
- glEnable( GL_LINE_SMOOTH );
+ glEnable(GL_LINE_SMOOTH);
glLineWidth(2.5);
glColor4f(0.0, 0.0, 0.0, alpha);
glBegin(GL_LINES);
- glVertex2i(x ,y );
- glVertex2i(x+w,y+h);
- glVertex2i(x+w,y );
- glVertex2i(x ,y+h);
+ glVertex2i(x, y);
+ glVertex2i(x + w, y + h);
+ glVertex2i(x + w, y);
+ glVertex2i(x, y + h);
glEnd();
glLineWidth(1.0);
- glDisable( GL_LINE_SMOOTH );
+ glDisable(GL_LINE_SMOOTH);
}
static void vicon_view3d_draw(int x, int y, int w, int h, float alpha)
{
- int cx = x + w/2;
- int cy = y + h/2;
- int d = MAX2(2, h/3);
+ int cx = x + w / 2;
+ int cy = y + h / 2;
+ int d = MAX2(2, h / 3);
glColor4f(0.5, 0.5, 0.5, alpha);
glBegin(GL_LINES);
- glVertex2i(x , cy-d);
- glVertex2i(x+w, cy-d);
- glVertex2i(x , cy+d);
- glVertex2i(x+w, cy+d);
-
- glVertex2i(cx-d, y );
- glVertex2i(cx-d, y+h);
- glVertex2i(cx+d, y );
- glVertex2i(cx+d, y+h);
+ glVertex2i(x, cy - d);
+ glVertex2i(x + w, cy - d);
+ glVertex2i(x, cy + d);
+ glVertex2i(x + w, cy + d);
+
+ glVertex2i(cx - d, y);
+ glVertex2i(cx - d, y + h);
+ glVertex2i(cx + d, y);
+ glVertex2i(cx + d, y + h);
glEnd();
glColor4f(0.0, 0.0, 0.0, alpha);
glBegin(GL_LINES);
- glVertex2i(x , cy);
- glVertex2i(x+w, cy);
- glVertex2i(cx, y );
- glVertex2i(cx, y+h);
+ glVertex2i(x, cy);
+ glVertex2i(x + w, cy);
+ glVertex2i(cx, y);
+ glVertex2i(cx, y + h);
glEnd();
}
@@ -305,10 +305,10 @@ static void vicon_edit_draw(int x, int y, int w, int h, float alpha)
{
GLint pts[4][2];
- viconutil_set_point(pts[0], x+3 , y+3 );
- viconutil_set_point(pts[1], x+w-3, y+3 );
- viconutil_set_point(pts[2], x+w-3, y+h-3);
- viconutil_set_point(pts[3], x+3 , y+h-3);
+ viconutil_set_point(pts[0], x + 3, y + 3);
+ viconutil_set_point(pts[1], x + w - 3, y + 3);
+ viconutil_set_point(pts[2], x + w - 3, y + h - 3);
+ viconutil_set_point(pts[3], x + 3, y + h - 3);
glColor4f(0.0, 0.0, 0.0, alpha);
viconutil_draw_lineloop(pts, 4);
@@ -321,9 +321,9 @@ static void vicon_editmode_hlt_draw(int x, int y, int w, int h, float alpha)
{
GLint pts[3][2];
- viconutil_set_point(pts[0], x+w/2, y+h-2);
- viconutil_set_point(pts[1], x+3, y+4);
- viconutil_set_point(pts[2], x+w-3, y+4);
+ viconutil_set_point(pts[0], x + w / 2, y + h - 2);
+ viconutil_set_point(pts[1], x + 3, y + 4);
+ viconutil_set_point(pts[2], x + w - 3, y + 4);
glColor4f(0.5, 0.5, 0.5, alpha);
viconutil_draw_tri(pts);
@@ -339,9 +339,9 @@ static void vicon_editmode_dehlt_draw(int x, int y, int w, int h, float UNUSED(a
{
GLint pts[3][2];
- viconutil_set_point(pts[0], x+w/2, y+h-2);
- viconutil_set_point(pts[1], x+3, y+4);
- viconutil_set_point(pts[2], x+w-3, y+4);
+ viconutil_set_point(pts[0], x + w / 2, y + h - 2);
+ viconutil_set_point(pts[1], x + 3, y + 4);
+ viconutil_set_point(pts[2], x + w - 3, y + 4);
glColor4f(0.0f, 0.0f, 0.0f, 1);
viconutil_draw_lineloop_smooth(pts, 3);
@@ -353,13 +353,13 @@ static void vicon_editmode_dehlt_draw(int x, int y, int w, int h, float UNUSED(a
static void vicon_disclosure_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha)
{
GLint pts[3][2];
- int cx = x+w/2;
- int cy = y+w/2;
- int d = w/3, d2 = w/5;
+ int cx = x + w / 2;
+ int cy = y + w / 2;
+ int d = w / 3, d2 = w / 5;
- viconutil_set_point(pts[0], cx-d2, cy+d);
- viconutil_set_point(pts[1], cx-d2, cy-d);
- viconutil_set_point(pts[2], cx+d2, cy);
+ viconutil_set_point(pts[0], cx - d2, cy + d);
+ viconutil_set_point(pts[1], cx - d2, cy - d);
+ viconutil_set_point(pts[2], cx + d2, cy);
glShadeModel(GL_SMOOTH);
glBegin(GL_TRIANGLES);
@@ -378,13 +378,13 @@ static void vicon_disclosure_tri_right_draw(int x, int y, int w, int UNUSED(h),
static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float alpha)
{
GLint pts[3][2];
- int cx = x+w/2-4;
- int cy = y+w/2;
- int d = w/5, d2 = w/7;
+ int cx = x + w / 2 - 4;
+ int cy = y + w / 2;
+ int d = w / 5, d2 = w / 7;
- viconutil_set_point(pts[0], cx-d2, cy+d);
- viconutil_set_point(pts[1], cx-d2, cy-d);
- viconutil_set_point(pts[2], cx+d2, cy);
+ viconutil_set_point(pts[0], cx - d2, cy + d);
+ viconutil_set_point(pts[1], cx - d2, cy - d);
+ viconutil_set_point(pts[2], cx + d2, cy);
glColor4f(0.2f, 0.2f, 0.2f, alpha);
@@ -400,13 +400,13 @@ static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float
static void vicon_disclosure_tri_down_draw(int x, int y, int w, int UNUSED(h), float alpha)
{
GLint pts[3][2];
- int cx = x+w/2;
- int cy = y+w/2;
- int d = w/3, d2 = w/5;
+ int cx = x + w / 2;
+ int cy = y + w / 2;
+ int d = w / 3, d2 = w / 5;
- viconutil_set_point(pts[0], cx+d, cy+d2);
- viconutil_set_point(pts[1], cx-d, cy+d2);
- viconutil_set_point(pts[2], cx, cy-d2);
+ viconutil_set_point(pts[0], cx + d, cy + d2);
+ viconutil_set_point(pts[1], cx - d, cy + d2);
+ viconutil_set_point(pts[2], cx, cy - d2);
glShadeModel(GL_SMOOTH);
glBegin(GL_TRIANGLES);
@@ -424,16 +424,16 @@ static void vicon_disclosure_tri_down_draw(int x, int y, int w, int UNUSED(h), f
static void vicon_move_up_draw(int x, int y, int w, int h, float UNUSED(alpha))
{
- int d=-2;
+ int d = -2;
glEnable(GL_LINE_SMOOTH);
glLineWidth(1);
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_LINE_STRIP);
- glVertex2i(x+w/2-d*2, y+h/2+d);
- glVertex2i(x+w/2, y+h/2-d + 1);
- glVertex2i(x+w/2+d*2, y+h/2+d);
+ glVertex2i(x + w / 2 - d * 2, y + h / 2 + d);
+ glVertex2i(x + w / 2, y + h / 2 - d + 1);
+ glVertex2i(x + w / 2 + d * 2, y + h / 2 + d);
glEnd();
glLineWidth(1.0);
@@ -442,16 +442,16 @@ static void vicon_move_up_draw(int x, int y, int w, int h, float UNUSED(alpha))
static void vicon_move_down_draw(int x, int y, int w, int h, float UNUSED(alpha))
{
- int d=2;
+ int d = 2;
glEnable(GL_LINE_SMOOTH);
glLineWidth(1);
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_LINE_STRIP);
- glVertex2i(x+w/2-d*2, y+h/2+d);
- glVertex2i(x+w/2, y+h/2-d - 1);
- glVertex2i(x+w/2+d*2, y+h/2+d);
+ glVertex2i(x + w / 2 - d * 2, y + h / 2 + d);
+ glVertex2i(x + w / 2, y + h / 2 - d - 1);
+ glVertex2i(x + w / 2 + d * 2, y + h / 2 + d);
glEnd();
glLineWidth(1.0);
@@ -462,12 +462,15 @@ static void vicon_move_down_draw(int x, int y, int w, int h, float UNUSED(alpha)
static void init_brush_icons(void)
{
-#define INIT_BRUSH_ICON(icon_id, name) \
- bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_ ##name## _png, \
- datatoc_ ##name## _png_size, IB_rect, "<brush icon>"); \
- def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \
- IMB_freeImBuf(bbuf);
- // end INIT_BRUSH_ICON
+#define INIT_BRUSH_ICON(icon_id, name) \
+ { \
+ bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_ ##name## _png, \
+ datatoc_ ##name## _png_size, \
+ IB_rect, "<brush icon>"); \
+ def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \
+ IMB_freeImBuf(bbuf); \
+ } (void)0
+ /* end INIT_BRUSH_ICON */
ImBuf *bbuf;
const int w = 96;
@@ -507,34 +510,34 @@ static void init_brush_icons(void)
static void init_internal_icons(void)
{
- bTheme *btheme= UI_GetTheme();
- ImBuf *bbuf= NULL;
+ bTheme *btheme = UI_GetTheme();
+ ImBuf *bbuf = NULL;
int x, y, icontype;
char iconfilestr[FILE_MAX];
- if ((btheme!=NULL) && btheme->tui.iconfile[0]) {
- char *icondir= BLI_get_folder(BLENDER_DATAFILES, "icons");
+ if ((btheme != NULL) && btheme->tui.iconfile[0]) {
+ char *icondir = BLI_get_folder(BLENDER_DATAFILES, "icons");
if (icondir) {
BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, btheme->tui.iconfile);
bbuf = IMB_loadiffname(iconfilestr, IB_rect); /* if the image is missing bbuf will just be NULL */
if (bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) {
printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr);
IMB_freeImBuf(bbuf);
- bbuf= NULL;
+ bbuf = NULL;
}
}
else {
printf("%s: 'icons' data path not found, continuing\n", __func__);
}
}
- if (bbuf==NULL)
- bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_blender_icons_png, datatoc_blender_icons_png_size, IB_rect, "<blender icons>");
+ if (bbuf == NULL)
+ bbuf = IMB_ibImageFromMemory((unsigned char *)datatoc_blender_icons_png, datatoc_blender_icons_png_size, IB_rect, "<blender icons>");
if (bbuf) {
/* free existing texture if any */
if (icongltex.id) {
glDeleteTextures(1, &icongltex.id);
- icongltex.id= 0;
+ icongltex.id = 0;
}
/* we only use a texture for cards with non-power of two */
@@ -544,8 +547,8 @@ static void init_internal_icons(void)
if (icongltex.id) {
icongltex.w = bbuf->x;
icongltex.h = bbuf->y;
- icongltex.invw = 1.0f/bbuf->x;
- icongltex.invh = 1.0f/bbuf->y;
+ icongltex.invw = 1.0f / bbuf->x;
+ icongltex.invh = 1.0f / bbuf->y;
glBindTexture(GL_TEXTURE_2D, icongltex.id);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bbuf->x, bbuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, bbuf->rect);
@@ -555,24 +558,24 @@ static void init_internal_icons(void)
if (glGetError() == GL_OUT_OF_MEMORY) {
glDeleteTextures(1, &icongltex.id);
- icongltex.id= 0;
+ icongltex.id = 0;
}
}
}
}
if (icongltex.id)
- icontype= ICON_TYPE_TEXTURE;
+ icontype = ICON_TYPE_TEXTURE;
else
- icontype= ICON_TYPE_BUFFER;
+ icontype = ICON_TYPE_BUFFER;
if (bbuf) {
- for (y=0; y<ICON_GRID_ROWS; y++) {
- for (x=0; x<ICON_GRID_COLS; x++) {
- def_internal_icon(bbuf, BIFICONID_FIRST + y*ICON_GRID_COLS + x,
- x*(ICON_GRID_W+ICON_GRID_MARGIN)+ICON_GRID_MARGIN,
- y*(ICON_GRID_H+ICON_GRID_MARGIN)+ICON_GRID_MARGIN, ICON_GRID_W,
- icontype);
+ for (y = 0; y < ICON_GRID_ROWS; y++) {
+ for (x = 0; x < ICON_GRID_COLS; x++) {
+ def_internal_icon(bbuf, BIFICONID_FIRST + y * ICON_GRID_COLS + x,
+ x * (ICON_GRID_W + ICON_GRID_MARGIN) + ICON_GRID_MARGIN,
+ y * (ICON_GRID_H + ICON_GRID_MARGIN) + ICON_GRID_MARGIN, ICON_GRID_W,
+ icontype);
}
}
}
@@ -597,14 +600,14 @@ static void init_iconfile_list(struct ListBase *list)
IconFile *ifile;
struct direntry *dir;
int restoredir = 1; /* restore to current directory */
- int totfile, i, index=1;
+ int totfile, i, index = 1;
const char *icondir;
char olddir[FILE_MAX];
list->first = list->last = NULL;
icondir = BLI_get_folder(BLENDER_DATAFILES, "icons");
- if (icondir==NULL)
+ if (icondir == NULL)
return;
/* since BLI_dir_contents changes the current working directory, restore it
@@ -614,7 +617,7 @@ static void init_iconfile_list(struct ListBase *list)
totfile = BLI_dir_contents(icondir, &dir);
if (restoredir && !chdir(olddir)) {} /* fix warning about checking return value */
- for (i=0; i<totfile; i++) {
+ for (i = 0; i < totfile; i++) {
if ( (dir[i].type & S_IFREG) ) {
char *filename = dir[i].relname;
@@ -623,13 +626,13 @@ static void init_iconfile_list(struct ListBase *list)
* its possible they change size after blender load anyway. */
#if 0
int ifilex, ifiley;
- char iconfilestr[FILE_MAX+16]; /* allow 256 chars for file+dir */
- ImBuf *bbuf= NULL;
+ char iconfilestr[FILE_MAX + 16]; /* allow 256 chars for file+dir */
+ ImBuf *bbuf = NULL;
/* check to see if the image is the right size, continue if not */
/* copying strings here should go ok, assuming that we never get back
* a complete path to file longer than 256 chars */
BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, filename);
- bbuf= IMB_loadiffname(iconfilestr, IB_rect);
+ bbuf = IMB_loadiffname(iconfilestr, IB_rect);
if (bbuf) {
ifilex = bbuf->x;
@@ -637,7 +640,7 @@ static void init_iconfile_list(struct ListBase *list)
IMB_freeImBuf(bbuf);
}
else {
- ifilex= ifiley= 0;
+ ifilex = ifiley = 0;
}
/* bad size or failed to load */
@@ -645,7 +648,7 @@ static void init_iconfile_list(struct ListBase *list)
printf("icon '%s' is wrong size %dx%d\n", iconfilestr, ifilex, ifiley);
continue;
}
-#endif /* removed */
+#endif /* removed */
/* found a potential icon file, so make an entry for it in the cache list */
ifile = MEM_callocN(sizeof(IconFile), "IconFile");
@@ -661,9 +664,9 @@ static void init_iconfile_list(struct ListBase *list)
}
/* free temporary direntry structure that's been created by BLI_dir_contents() */
- i= totfile-1;
+ i = totfile - 1;
- for (; i>=0; i--) {
+ for (; i >= 0; i--) {
MEM_freeN(dir[i].relname);
MEM_freeN(dir[i].path);
if (dir[i].string) {
@@ -671,14 +674,14 @@ static void init_iconfile_list(struct ListBase *list)
}
}
free(dir);
- dir= NULL;
+ dir = NULL;
}
static void free_iconfile_list(struct ListBase *list)
{
- IconFile *ifile=NULL, *next_ifile=NULL;
+ IconFile *ifile = NULL, *next_ifile = NULL;
- for (ifile=list->first; ifile; ifile=next_ifile) {
+ for (ifile = list->first; ifile; ifile = next_ifile) {
next_ifile = ifile->next;
BLI_freelinkN(list, ifile);
}
@@ -687,9 +690,9 @@ static void free_iconfile_list(struct ListBase *list)
int UI_iconfile_get_index(const char *filename)
{
IconFile *ifile;
- ListBase *list=&(iconfilelist);
+ ListBase *list = &(iconfilelist);
- for (ifile=list->first; ifile; ifile=ifile->next) {
+ for (ifile = list->first; ifile; ifile = ifile->next) {
if (BLI_path_cmp(filename, ifile->filename) == 0) {
return ifile->index;
}
@@ -700,7 +703,7 @@ int UI_iconfile_get_index(const char *filename)
ListBase *UI_iconfile_list(void)
{
- ListBase *list=&(iconfilelist);
+ ListBase *list = &(iconfilelist);
return list;
}
@@ -711,7 +714,7 @@ void UI_icons_free(void)
#ifndef WITH_HEADLESS
if (icongltex.id) {
glDeleteTextures(1, &icongltex.id);
- icongltex.id= 0;
+ icongltex.id = 0;
}
free_iconfile_list(&iconfilelist);
@@ -740,7 +743,7 @@ static DrawInfo *icon_create_drawinfo(void)
DrawInfo *di = NULL;
di = MEM_callocN(sizeof(DrawInfo), "di_icon");
- di->type= ICON_TYPE_PREVIEW;
+ di->type = ICON_TYPE_PREVIEW;
return di;
}
@@ -753,7 +756,7 @@ int UI_icon_get_width(int icon_id)
icon = BKE_icon_get(icon_id);
- if (icon==NULL) {
+ if (icon == NULL) {
if (G.f & G_DEBUG)
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
return 0;
@@ -778,13 +781,13 @@ int UI_icon_get_height(int icon_id)
icon = BKE_icon_get(icon_id);
- if (icon==NULL) {
+ if (icon == NULL) {
if (G.f & G_DEBUG)
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
return 0;
}
- di = (DrawInfo*)icon->drawinfo;
+ di = (DrawInfo *)icon->drawinfo;
if (!di) {
di = icon_create_drawinfo();
@@ -814,7 +817,7 @@ void UI_icons_init(int first_dyn_id)
static int preview_render_size(enum eIconSizes size)
{
switch (size) {
- case ICON_SIZE_ICON: return 32;
+ case ICON_SIZE_ICON: return 32;
case ICON_SIZE_PREVIEW: return PREVIEW_DEFAULT_HEIGHT;
}
return 0;
@@ -822,7 +825,7 @@ static int preview_render_size(enum eIconSizes size)
/* Create rect for the icon
*/
-static void icon_create_rect(struct PreviewImage* prv_img, enum eIconSizes size)
+static void icon_create_rect(struct PreviewImage *prv_img, enum eIconSizes size)
{
unsigned int render_size = preview_render_size(size);
@@ -835,13 +838,13 @@ static void icon_create_rect(struct PreviewImage* prv_img, enum eIconSizes size)
prv_img->h[size] = render_size;
prv_img->changed[size] = 1;
prv_img->changed_timestamp[size] = 0;
- prv_img->rect[size] = MEM_callocN(render_size*render_size*sizeof(unsigned int), "prv_rect");
+ prv_img->rect[size] = MEM_callocN(render_size * render_size * sizeof(unsigned int), "prv_rect");
}
}
/* only called when icon has changed */
/* only call with valid pointer from UI_icon_draw */
-static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, enum eIconSizes size)
+static void icon_set_image(bContext *C, ID *id, PreviewImage *prv_img, enum eIconSizes size)
{
if (!prv_img) {
if (G.f & G_DEBUG)
@@ -852,15 +855,15 @@ static void icon_set_image(bContext *C, ID *id, PreviewImage* prv_img, enum eIco
icon_create_rect(prv_img, size);
ED_preview_icon_job(C, prv_img, id, prv_img->rect[size],
- prv_img->w[size], prv_img->h[size]);
+ prv_img->w[size], prv_img->h[size]);
}
static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), int rw, int rh, unsigned int *rect, float alpha, float *rgb, short is_preview)
{
- ImBuf *ima= NULL;
+ ImBuf *ima = NULL;
/* sanity check */
- if (w<=0 || h<=0 || w>2000 || h>2000) {
+ if (w <= 0 || h <= 0 || w > 2000 || h > 2000) {
printf("%s: icons are %i x %i pixels?\n", __func__, w, h);
BLI_assert(!"invalid icon size");
return;
@@ -877,12 +880,12 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect),
}
/* rect contains image in 'rendersize', we only scale if needed */
- if (rw!=w && rh!=h) {
+ if (rw != w && rh != h) {
/* first allocate imbuf for scaling and copy preview into it */
ima = IMB_allocImBuf(rw, rh, 32, IB_rect);
- memcpy(ima->rect, rect, rw*rh*sizeof(unsigned int));
+ memcpy(ima->rect, rect, rw * rh * sizeof(unsigned int));
IMB_scaleImBuf(ima, w, h); /* scale it */
- rect= ima->rect;
+ rect = ima->rect;
}
/* draw */
@@ -915,10 +918,10 @@ static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy
if (rgb) glColor4f(rgb[0], rgb[1], rgb[2], alpha);
else glColor4f(1.0f, 1.0f, 1.0f, alpha);
- x1= ix*icongltex.invw;
- x2= (ix + ih)*icongltex.invw;
- y1= iy*icongltex.invh;
- y2= (iy + ih)*icongltex.invh;
+ x1 = ix * icongltex.invw;
+ x2 = (ix + ih) * icongltex.invw;
+ y1 = iy * icongltex.invh;
+ y2 = (iy + ih) * icongltex.invh;
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, icongltex.id);
@@ -928,13 +931,13 @@ static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy
glVertex2f(x, y);
glTexCoord2f(x2, y1);
- glVertex2f(x+w, y);
+ glVertex2f(x + w, y);
glTexCoord2f(x2, y2);
- glVertex2f(x+w, y+h);
+ glVertex2f(x + w, y + h);
glTexCoord2f(x1, y2);
- glVertex2f(x, y+h);
+ glVertex2f(x, y + h);
glEnd();
glBindTexture(GL_TEXTURE_2D, 0);
@@ -953,23 +956,23 @@ static int get_draw_size(enum eIconSizes size)
static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, enum eIconSizes size, int draw_size, int UNUSED(nocreate), short is_preview)
{
- bTheme *btheme= UI_GetTheme();
+ bTheme *btheme = UI_GetTheme();
Icon *icon = NULL;
DrawInfo *di = NULL;
IconImage *iimg;
- float fdraw_size= is_preview ? draw_size : (draw_size * UI_DPI_ICON_FAC);
+ float fdraw_size = is_preview ? draw_size : (draw_size * UI_DPI_ICON_FAC);
int w, h;
icon = BKE_icon_get(icon_id);
alpha *= btheme->tui.icon_alpha;
- if (icon==NULL) {
+ if (icon == NULL) {
if (G.f & G_DEBUG)
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
return;
}
- di = (DrawInfo*)icon->drawinfo;
+ di = (DrawInfo *)icon->drawinfo;
if (!di) {
di = icon_create_drawinfo();
@@ -979,8 +982,8 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
}
/* scale width and height according to aspect */
- w = (int)(fdraw_size/aspect + 0.5f);
- h = (int)(fdraw_size/aspect + 0.5f);
+ w = (int)(fdraw_size / aspect + 0.5f);
+ h = (int)(fdraw_size / aspect + 0.5f);
if (di->type == ICON_TYPE_VECTOR) {
/* vector icons use the uiBlock transformation, they are not drawn
@@ -989,22 +992,22 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
}
else if (di->type == ICON_TYPE_TEXTURE) {
icon_draw_texture(x, y, (float)w, (float)h, di->data.texture.x, di->data.texture.y,
- di->data.texture.w, di->data.texture.h, alpha, rgb);
+ di->data.texture.w, di->data.texture.h, alpha, rgb);
}
else if (di->type == ICON_TYPE_BUFFER) {
/* it is a builtin icon */
- iimg= di->data.buffer.image;
+ iimg = di->data.buffer.image;
- if (!iimg->rect) return; /* something has gone wrong! */
+ if (!iimg->rect) return; /* something has gone wrong! */
icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, is_preview);
}
else if (di->type == ICON_TYPE_PREVIEW) {
- PreviewImage* pi = BKE_previewimg_get((ID*)icon->obj);
+ PreviewImage *pi = BKE_previewimg_get((ID *)icon->obj);
if (pi) {
/* no create icon on this level in code */
- if (!pi->rect[size]) return; /* something has gone wrong! */
+ if (!pi->rect[size]) return; /* something has gone wrong! */
/* preview images use premul alpha ... */
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
@@ -1016,7 +1019,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al
static void ui_id_preview_image_render_size(bContext *C, ID *id, PreviewImage *pi, int size)
{
- if ((pi->changed[size] ||!pi->rect[size])) { /* changed only ever set by dynamic icons */
+ if ((pi->changed[size] || !pi->rect[size])) { /* changed only ever set by dynamic icons */
/* create the rect if necessary */
icon_set_image(C, id, pi, size);
@@ -1030,9 +1033,9 @@ static void ui_id_icon_render(bContext *C, ID *id, int big)
if (pi) {
if (big)
- ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_PREVIEW); /* bigger preview size */
+ ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_PREVIEW); /* bigger preview size */
else
- ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_ICON); /* icon size */
+ ui_id_preview_image_render_size(C, id, pi, ICON_SIZE_ICON); /* icon size */
}
}
@@ -1057,7 +1060,7 @@ static void ui_id_brush_render(bContext *C, ID *id)
static int ui_id_brush_get_icon(bContext *C, ID *id)
{
- Brush *br = (Brush*)id;
+ Brush *br = (Brush *)id;
if (br->flag & BRUSH_CUSTOM_ICON) {
BKE_icon_getid(id);
@@ -1076,13 +1079,14 @@ static int ui_id_brush_get_icon(bContext *C, ID *id)
if (CTX_wm_view3d(C) && ob) {
if (ob->mode & OB_MODE_SCULPT)
mode = OB_MODE_SCULPT;
- else if (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT))
+ else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT))
mode = OB_MODE_VERTEX_PAINT;
else if (ob->mode & OB_MODE_TEXTURE_PAINT)
mode = OB_MODE_TEXTURE_PAINT;
}
else if ((sima = CTX_wm_space_image(C)) &&
- (sima->flag & SI_DRAWTOOL)) {
+ (sima->flag & SI_DRAWTOOL))
+ {
mode = OB_MODE_TEXTURE_PAINT;
}
@@ -1109,19 +1113,19 @@ static int ui_id_brush_get_icon(bContext *C, ID *id)
int ui_id_icon_get(bContext *C, ID *id, int big)
{
- int iconid= 0;
+ int iconid = 0;
/* icon */
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_BR:
- iconid= ui_id_brush_get_icon(C, id);
+ iconid = ui_id_brush_get_icon(C, id);
break;
case ID_MA: /* fall through */
case ID_TE: /* fall through */
case ID_IM: /* fall through */
case ID_WO: /* fall through */
case ID_LA: /* fall through */
- iconid= BKE_icon_getid(id);
+ iconid = BKE_icon_getid(id);
/* checks if not exists, or changed */
ui_id_icon_render(C, id, big);
break;
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 88db06c5ec3..91e38e7d914 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -60,11 +60,11 @@
/************************ Structs and Defines *************************/
-#define RNA_NO_INDEX -1
-#define RNA_ENUM_VALUE -2
+#define RNA_NO_INDEX -1
+#define RNA_ENUM_VALUE -2
-#define EM_SEPR_X 6
-#define EM_SEPR_Y 6
+#define EM_SEPR_X 6
+#define EM_SEPR_Y 6
#define UI_OPERATOR_ERROR_RET(_ot, _opname, return_statement) \
if (ot == NULL) { \
@@ -170,12 +170,12 @@ typedef struct uiLayoutItemRoot {
static const char *ui_item_name_add_colon(const char *name, char namestr[UI_MAX_NAME_STR])
{
- int len= strlen(name);
+ int len = strlen(name);
- if (len != 0 && len+1 < UI_MAX_NAME_STR) {
+ if (len != 0 && len + 1 < UI_MAX_NAME_STR) {
BLI_strncpy(namestr, name, UI_MAX_NAME_STR);
- namestr[len]= ':';
- namestr[len+1]= '\0';
+ namestr[len] = ':';
+ namestr[len + 1] = '\0';
return namestr;
}
@@ -189,22 +189,22 @@ static int ui_item_fit(int item, int pos, int all, int available, int last, int
return item;
if (offset)
- *offset= 0;
+ *offset = 0;
if (all > available) {
/* contents is bigger than available space */
if (last)
- return available-pos;
+ return available - pos;
else
- return (item*available)/all;
+ return (item * available) / all;
}
else {
/* contents is smaller or equal to available space */
if (alignment == UI_LAYOUT_ALIGN_EXPAND) {
if (last)
- return available-pos;
+ return available - pos;
else
- return (item*available)/all;
+ return (item * available) / all;
}
else
return item;
@@ -212,12 +212,12 @@ static int ui_item_fit(int item, int pos, int all, int available, int last, int
}
/* variable button size in which direction? */
-#define UI_ITEM_VARY_X 1
-#define UI_ITEM_VARY_Y 2
+#define UI_ITEM_VARY_X 1
+#define UI_ITEM_VARY_Y 2
static int ui_layout_vary_direction(uiLayout *layout)
{
- return (layout->root->type == UI_LAYOUT_HEADER || layout->alignment != UI_LAYOUT_ALIGN_EXPAND)? UI_ITEM_VARY_X: UI_ITEM_VARY_Y;
+ return (layout->root->type == UI_LAYOUT_HEADER || layout->alignment != UI_LAYOUT_ALIGN_EXPAND) ? UI_ITEM_VARY_X : UI_ITEM_VARY_Y;
}
/* estimated size of text + icon */
@@ -226,62 +226,62 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, int
int variable = ui_layout_vary_direction(layout) == UI_ITEM_VARY_X;
if (icon && !name[0])
- return UI_UNIT_X; /* icon only */
+ return UI_UNIT_X; /* icon only */
else if (icon)
- return (variable)? UI_GetStringWidth(name) + (compact? 5: 10) + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */
+ return (variable) ? UI_GetStringWidth(name) + (compact ? 5 : 10) + UI_UNIT_X : 10 * UI_UNIT_X; /* icon + text */
else
- return (variable)? UI_GetStringWidth(name) + (compact? 5: 10) + UI_UNIT_X: 10*UI_UNIT_X; /* text only */
+ return (variable) ? UI_GetStringWidth(name) + (compact ? 5 : 10) + UI_UNIT_X : 10 * UI_UNIT_X; /* text only */
}
static void ui_item_size(uiItem *item, int *r_w, int *r_h)
{
if (item->type == ITEM_BUTTON) {
- uiButtonItem *bitem= (uiButtonItem*)item;
+ uiButtonItem *bitem = (uiButtonItem *)item;
- if (r_w) *r_w= bitem->but->x2 - bitem->but->x1;
- if (r_h) *r_h= bitem->but->y2 - bitem->but->y1;
+ if (r_w) *r_w = bitem->but->x2 - bitem->but->x1;
+ if (r_h) *r_h = bitem->but->y2 - bitem->but->y1;
}
else {
- uiLayout *litem= (uiLayout*)item;
+ uiLayout *litem = (uiLayout *)item;
- if (r_w) *r_w= litem->w;
- if (r_h) *r_h= litem->h;
+ if (r_w) *r_w = litem->w;
+ if (r_h) *r_h = litem->h;
}
}
static void ui_item_offset(uiItem *item, int *r_x, int *r_y)
{
if (item->type == ITEM_BUTTON) {
- uiButtonItem *bitem= (uiButtonItem*)item;
+ uiButtonItem *bitem = (uiButtonItem *)item;
- if (r_x) *r_x= bitem->but->x1;
- if (r_y) *r_y= bitem->but->y1;
+ if (r_x) *r_x = bitem->but->x1;
+ if (r_y) *r_y = bitem->but->y1;
}
else {
- if (r_x) *r_x= 0;
- if (r_y) *r_y= 0;
+ if (r_x) *r_x = 0;
+ if (r_y) *r_y = 0;
}
}
static void ui_item_position(uiItem *item, int x, int y, int w, int h)
{
if (item->type == ITEM_BUTTON) {
- uiButtonItem *bitem= (uiButtonItem*)item;
+ uiButtonItem *bitem = (uiButtonItem *)item;
- bitem->but->x1= x;
- bitem->but->y1= y;
- bitem->but->x2= x+w;
- bitem->but->y2= y+h;
+ bitem->but->x1 = x;
+ bitem->but->y1 = y;
+ bitem->but->x2 = x + w;
+ bitem->but->y2 = y + h;
ui_check_but(bitem->but); /* for strlen */
}
else {
- uiLayout *litem= (uiLayout*)item;
+ uiLayout *litem = (uiLayout *)item;
- litem->x= x;
- litem->y= y+h;
- litem->w= w;
- litem->h= h;
+ litem->x = x;
+ litem->y = y + h;
+ litem->w = w;
+ litem->h = h;
}
}
@@ -289,7 +289,7 @@ static void ui_item_position(uiItem *item, int x, int y, int w, int h)
static int ui_layout_local_dir(uiLayout *layout)
{
- switch(layout->item.type) {
+ switch (layout->item.type) {
case ITEM_LAYOUT_ROW:
case ITEM_LAYOUT_ROOT:
case ITEM_LAYOUT_OVERLAP:
@@ -309,34 +309,34 @@ static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, int a
uiLayout *sub;
if (ui_layout_local_dir(test) == UI_LAYOUT_HORIZONTAL)
- sub= uiLayoutRow(layout, align);
+ sub = uiLayoutRow(layout, align);
else
- sub= uiLayoutColumn(layout, align);
+ sub = uiLayoutColumn(layout, align);
- sub->space= 0;
+ sub->space = 0;
return sub;
}
static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index)
{
- wmWindow *win= CTX_wm_window(C);
- uiBut *but= arg_but, *cbut;
- PointerRNA *ptr= &but->rnapoin;
- PropertyRNA *prop= but->rnaprop;
- int i, index= GET_INT_FROM_POINTER(arg_index);
- int shift= win->eventstate->shift;
- int len= RNA_property_array_length(ptr, prop);
+ wmWindow *win = CTX_wm_window(C);
+ uiBut *but = arg_but, *cbut;
+ PointerRNA *ptr = &but->rnapoin;
+ PropertyRNA *prop = but->rnaprop;
+ int i, index = GET_INT_FROM_POINTER(arg_index);
+ int shift = win->eventstate->shift;
+ int len = RNA_property_array_length(ptr, prop);
if (!shift) {
RNA_property_boolean_set_index(ptr, prop, index, TRUE);
- for (i=0; i<len; i++)
+ for (i = 0; i < len; i++)
if (i != index)
RNA_property_boolean_set_index(ptr, prop, i, 0);
RNA_property_update(C, ptr, prop);
- for (cbut=but->block->buttons.first; cbut; cbut=cbut->next)
+ for (cbut = but->block->buttons.first; cbut; cbut = cbut->next)
ui_check_but(cbut);
}
}
@@ -344,7 +344,7 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index)
/* create buttons for an item with an RNA array */
static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int UNUSED(h), int expand, int slider, int toggle, int icon_only)
{
- uiStyle *style= layout->root->style;
+ uiStyle *style = layout->root->style;
uiBut *but;
PropertyType type;
PropertySubType subtype;
@@ -352,10 +352,10 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
int a, b;
/* retrieve type and subtype */
- type= RNA_property_type(prop);
- subtype= RNA_property_subtype(prop);
+ type = RNA_property_type(prop);
+ subtype = RNA_property_subtype(prop);
- sub= ui_item_local_sublayout(layout, layout, 1);
+ sub = ui_item_local_sublayout(layout, layout, 1);
uiBlockSetCurLayout(block, sub);
/* create label */
@@ -366,68 +366,68 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
if (type == PROP_BOOLEAN && ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) {
/* special check for layer layout */
int butw, buth, unit;
- int cols= (len >= 20)? 2: 1;
- int colbuts= len/(2*cols);
- int layer_used= 0;
+ int cols = (len >= 20) ? 2 : 1;
+ int colbuts = len / (2 * cols);
+ int layer_used = 0;
uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, 0));
- unit= UI_UNIT_X*0.75;
- butw= unit;
- buth= unit;
+ unit = UI_UNIT_X * 0.75;
+ butw = unit;
+ buth = unit;
if (ptr->type == &RNA_Armature) {
- bArmature *arm= (bArmature *)ptr->data;
- layer_used= arm->layer_used;
+ bArmature *arm = (bArmature *)ptr->data;
+ layer_used = arm->layer_used;
}
- for (b=0; b<cols; b++) {
+ for (b = 0; b < cols; b++) {
uiBlockBeginAlign(block);
- for (a=0; a<colbuts; a++) {
- if (layer_used & (1<<(a+b*colbuts))) icon= ICON_LAYER_USED;
- else icon= ICON_BLANK1;
+ for (a = 0; a < colbuts; a++) {
+ if (layer_used & (1 << (a + b * colbuts))) icon = ICON_LAYER_USED;
+ else icon = ICON_BLANK1;
- but = uiDefAutoButR(block, ptr, prop, a+b*colbuts, "", icon, x + butw*a, y+buth, butw, buth);
+ but = uiDefAutoButR(block, ptr, prop, a + b * colbuts, "", icon, x + butw * a, y + buth, butw, buth);
if (subtype == PROP_LAYER_MEMBER)
- uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a+b*colbuts));
+ uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a + b * colbuts));
}
- for (a=0; a<colbuts; a++) {
- if (layer_used & (1<<(a+len/2+b*colbuts))) icon= ICON_LAYER_USED;
- else icon= ICON_BLANK1;
+ for (a = 0; a < colbuts; a++) {
+ if (layer_used & (1 << (a + len / 2 + b * colbuts))) icon = ICON_LAYER_USED;
+ else icon = ICON_BLANK1;
- but = uiDefAutoButR(block, ptr, prop, a+len/2+b*colbuts, "", icon, x + butw*a, y, butw, buth);
+ but = uiDefAutoButR(block, ptr, prop, a + len / 2 + b * colbuts, "", icon, x + butw * a, y, butw, buth);
if (subtype == PROP_LAYER_MEMBER)
- uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a+len/2+b*colbuts));
+ uiButSetFunc(but, ui_layer_but_cb, but, SET_INT_IN_POINTER(a + len / 2 + b * colbuts));
}
uiBlockEndAlign(block);
- x += colbuts*butw + style->buttonspacex;
+ x += colbuts * butw + style->buttonspacex;
}
}
else if (subtype == PROP_MATRIX) {
- int totdim, dim_size[3]; /* 3 == RNA_MAX_ARRAY_DIMENSION */
+ int totdim, dim_size[3]; /* 3 == RNA_MAX_ARRAY_DIMENSION */
int row, col;
uiBlockSetCurLayout(block, uiLayoutAbsolute(layout, 1));
- totdim= RNA_property_array_dimension(ptr, prop, dim_size);
- if (totdim != 2) return; /* only 2D matrices supported in UI so far */
+ totdim = RNA_property_array_dimension(ptr, prop, dim_size);
+ if (totdim != 2) return; /* only 2D matrices supported in UI so far */
w /= dim_size[0];
/* h /= dim_size[1]; */ /* UNUSED */
- for (a=0; a<len; a++) {
- col= a % dim_size[0];
- row= a / dim_size[0];
-
- but = uiDefAutoButR(block, ptr, prop, a, "", ICON_NONE, x + w*col, y+(dim_size[1]*UI_UNIT_Y)-(row*UI_UNIT_Y), w, UI_UNIT_Y);
- if (slider && but->type==NUM)
- but->type= NUMSLI;
+ for (a = 0; a < len; a++) {
+ col = a % dim_size[0];
+ row = a / dim_size[0];
+
+ but = uiDefAutoButR(block, ptr, prop, a, "", ICON_NONE, x + w * col, y + (dim_size[1] * UI_UNIT_Y) - (row * UI_UNIT_Y), w, UI_UNIT_Y);
+ if (slider && but->type == NUM)
+ but->type = NUMSLI;
}
}
else if (subtype == PROP_DIRECTION) {
- uiDefButR_prop(block, BUT_NORMAL, 0, name, x, y, UI_UNIT_X*3, UI_UNIT_Y*3, ptr, prop, 0, 0, 0, -1, -1, NULL);
+ uiDefButR_prop(block, BUT_NORMAL, 0, name, x, y, UI_UNIT_X * 3, UI_UNIT_Y * 3, ptr, prop, 0, 0, 0, -1, -1, NULL);
}
else {
/* note, this block of code is a bit arbitrary and has just been made
@@ -438,33 +438,33 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in
uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, 0, 0, w, UI_UNIT_Y);
}
else {
- int *boolarr= NULL;
+ int *boolarr = NULL;
/* even if 'expand' is fale, expanding anyway */
/* layout for known array subtypes */
- char str[3]= {'\0'};
+ char str[3] = {'\0'};
if (!icon_only) {
if (type != PROP_BOOLEAN) {
- str[1]= ':';
+ str[1] = ':';
}
}
/* show checkboxes for rna on a non-emboss block (menu for eg) */
if (type == PROP_BOOLEAN && ELEM(layout->root->block->dt, UI_EMBOSSN, UI_EMBOSSP)) {
- boolarr= MEM_callocN(sizeof(int)*len, "ui_item_array");
+ boolarr = MEM_callocN(sizeof(int) * len, "ui_item_array");
RNA_property_boolean_get_array(ptr, prop, boolarr);
}
- for (a=0; a<len; a++) {
- if (!icon_only) str[0]= RNA_property_array_item_char(prop, a);
- if (boolarr) icon= boolarr[a] ? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT;
+ for (a = 0; a < len; a++) {
+ if (!icon_only) str[0] = RNA_property_array_item_char(prop, a);
+ if (boolarr) icon = boolarr[a] ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
but = uiDefAutoButR(block, ptr, prop, a, str, icon, 0, 0, w, UI_UNIT_Y);
- if (slider && but->type==NUM)
- but->type= NUMSLI;
- if (toggle && but->type==OPTION)
- but->type= TOG;
+ if (slider && but->type == NUM)
+ but->type = NUMSLI;
+ if (toggle && but->type == OPTION)
+ but->type = TOG;
}
if (boolarr) {
@@ -486,14 +486,14 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt
RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free);
uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, layout, 1));
- for (a=0; a<totitem; a++) {
+ for (a = 0; a < totitem; a++) {
if (!item[a].identifier[0])
continue;
- name= (!uiname || uiname[0])? item[a].name: "";
- icon= item[a].icon;
- value= item[a].value;
- itemw= ui_text_icon_width(block->curlayout, name, icon, 0);
+ name = (!uiname || uiname[0]) ? item[a].name : "";
+ icon = item[a].icon;
+ value = item[a].value;
+ itemw = ui_text_icon_width(block->curlayout, name, icon, 0);
if (icon && name[0] && !icon_only)
but = uiDefIconTextButR_prop(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL);
@@ -515,7 +515,7 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt
/* callback for keymap item change button */
static void ui_keymap_but_cb(bContext *UNUSED(C), void *but_v, void *UNUSED(key_v))
{
- uiBut *but= but_v;
+ uiBut *but = but_v;
RNA_boolean_set(&but->rnapoin, "shift", (but->modifier_key & KM_SHIFT) != 0);
RNA_boolean_set(&but->rnapoin, "ctrl", (but->modifier_key & KM_CTRL) != 0);
@@ -527,37 +527,37 @@ static void ui_keymap_but_cb(bContext *UNUSED(C), void *but_v, void *UNUSED(key_
static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int index, int x, int y, int w, int h, int flag)
{
uiLayout *sub;
- uiBut *but=NULL;
+ uiBut *but = NULL;
PropertyType type;
PropertySubType subtype;
int labelw;
- sub= uiLayoutRow(layout, 0);
+ sub = uiLayoutRow(layout, 0);
uiBlockSetCurLayout(block, sub);
if (name[0]) {
/* XXX UI_GetStringWidth is not accurate */
#if 0
labelw = UI_GetStringWidth(name);
- CLAMP(labelw, w/4, 3*w/4);
+ CLAMP(labelw, w / 4, 3 * w / 4);
#endif
- labelw= w/3;
+ labelw = w / 3;
uiDefBut(block, LABEL, 0, name, x, y, labelw, h, NULL, 0.0, 0.0, 0, 0, "");
- w= w-labelw;
+ w = w - labelw;
}
- type= RNA_property_type(prop);
- subtype= RNA_property_subtype(prop);
+ type = RNA_property_type(prop);
+ subtype = RNA_property_subtype(prop);
if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) {
uiBlockSetCurLayout(block, uiLayoutRow(sub, 1));
- uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w-UI_UNIT_X, h);
+ uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w - UI_UNIT_X, h);
/* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty */
- but = uiDefIconButO(block, BUT, subtype==PROP_DIRPATH ?
- "BUTTONS_OT_directory_browse" :
- "BUTTONS_OT_file_browse",
- WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL);
+ but = uiDefIconButO(block, BUT, subtype == PROP_DIRPATH ?
+ "BUTTONS_OT_directory_browse" :
+ "BUTTONS_OT_file_browse",
+ WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL);
}
else if (flag & UI_ITEM_R_EVENT) {
uiDefButR_prop(block, KEYEVT, 0, name, x, y, w, h, ptr, prop, index, 0, 0, -1, -1, NULL);
@@ -575,7 +575,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
}
}
else
- but = uiDefAutoButR(block, ptr, prop, index, (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY))? NULL: "", icon, x, y, w, h);
+ but = uiDefAutoButR(block, ptr, prop, index, (type == PROP_ENUM && !(flag & UI_ITEM_R_ICON_ONLY)) ? NULL : "", icon, x, y, w, h);
uiBlockSetCurLayout(block, layout);
return but;
@@ -583,25 +583,25 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
void uiFileBrowseContextProperty(const bContext *C, PointerRNA *ptr, PropertyRNA **prop)
{
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
uiBlock *block;
uiBut *but, *prevbut;
memset(ptr, 0, sizeof(*ptr));
- *prop= NULL;
+ *prop = NULL;
if (!ar)
return;
- for (block=ar->uiblocks.first; block; block=block->next) {
- for (but=block->buttons.first; but; but= but->next) {
- prevbut= but->prev;
+ for (block = ar->uiblocks.first; block; block = block->next) {
+ for (but = block->buttons.first; but; but = but->next) {
+ prevbut = but->prev;
/* find the button before the active one */
if ((but->flag & UI_BUT_LAST_ACTIVE) && prevbut && prevbut->rnapoin.data) {
if (RNA_property_type(prevbut->rnaprop) == PROP_STRING) {
- *ptr= prevbut->rnapoin;
- *prop= prevbut->rnaprop;
+ *ptr = prevbut->rnapoin;
+ *prop = prevbut->rnaprop;
return;
}
}
@@ -614,16 +614,16 @@ void uiFileBrowseContextProperty(const bContext *C, PointerRNA *ptr, PropertyRNA
/* disabled item */
static void ui_item_disabled(uiLayout *layout, const char *name)
{
- uiBlock *block= layout->root->block;
+ uiBlock *block = layout->root->block;
uiBut *but;
int w;
uiBlockSetCurLayout(block, layout);
if (!name)
- name= "";
+ name = "";
- w= ui_text_icon_width(layout, name, 0, 0);
+ w = ui_text_icon_width(layout, name, 0, 0);
but = uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
but->flag |= UI_BUT_DISABLED;
@@ -634,7 +634,7 @@ static void ui_item_disabled(uiLayout *layout, const char *name)
/* operator items */
PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, IDProperty *properties, int context, int flag)
{
- uiBlock *block= layout->root->block;
+ uiBlock *block = layout->root->block;
uiBut *but;
int w;
@@ -646,12 +646,12 @@ PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *nam
}
if (layout->root->type == UI_LAYOUT_MENU && !icon)
- icon= ICON_BLANK1;
+ icon = ICON_BLANK1;
/* create button */
uiBlockSetCurLayout(block, layout);
- w= ui_text_icon_width(layout, name, icon, 0);
+ w = ui_text_icon_width(layout, name, icon, 0);
if (flag & UI_ITEM_R_NO_BG)
uiBlockSetEmboss(block, UI_EMBOSSN);
@@ -683,14 +683,14 @@ PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *nam
/* assign properties */
if (properties || (flag & UI_ITEM_O_RETURN_PROPS)) {
- PointerRNA *opptr= uiButGetOperatorPtrRNA(but);
+ PointerRNA *opptr = uiButGetOperatorPtrRNA(but);
if (properties) {
- opptr->data= properties;
+ opptr->data = properties;
}
else {
IDPropertyTemplate val = {0};
- opptr->data= IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
+ opptr->data = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
}
return *opptr;
@@ -781,7 +781,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
PointerRNA ptr;
PropertyRNA *prop;
uiBut *bt;
- uiBlock *block= layout->root->block;
+ uiBlock *block = layout->root->block;
if (!ot || !ot->srna) {
ui_item_disabled(layout, opname);
@@ -798,12 +798,12 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
if (prop && RNA_property_type(prop) == PROP_ENUM) {
EnumPropertyItem *item;
int totitem, i, free;
- uiLayout *split= uiLayoutSplit(layout, 0, 0);
- uiLayout *column= uiLayoutColumn(split, 0);
+ uiLayout *split = uiLayoutSplit(layout, 0, 0);
+ uiLayout *column = uiLayoutColumn(split, 0);
RNA_property_enum_items_gettexted(block->evil_C, &ptr, prop, &item, &totitem, &free);
- for (i=0; i<totitem; i++) {
+ for (i = 0; i < totitem; i++) {
if (item[i].identifier[0]) {
if (properties) {
PointerRNA tptr;
@@ -813,7 +813,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
IDP_FreeProperty(tptr.data);
MEM_freeN(tptr.data);
}
- tptr.data= IDP_CopyProperty(properties);
+ tptr.data = IDP_CopyProperty(properties);
RNA_property_enum_set(&tptr, prop, item[i].value);
uiItemFullO_ptr(column, ot, item[i].name, item[i].icon, tptr.data, context, flag);
@@ -825,14 +825,14 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname
else {
if (item[i].name) {
if (i != 0) {
- column= uiLayoutColumn(split, 0);
+ column = uiLayoutColumn(split, 0);
/* inconsistent, but menus with labels do not look good flipped */
block->flag |= UI_BLOCK_NO_FLIP;
}
uiItemL(column, item[i].name, ICON_NONE);
- bt= block->buttons.last;
- bt->flag= UI_TEXT_LEFT;
+ bt = block->buttons.last;
+ bt->flag = UI_TEXT_LEFT;
}
else /* XXX bug here, collums draw bottom item badly */
uiItemS(column);
@@ -857,7 +857,7 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char
PointerRNA ptr;
PropertyRNA *prop;
- UI_OPERATOR_ERROR_RET(ot, opname, return);
+ UI_OPERATOR_ERROR_RET(ot, opname, return );
WM_operator_properties_create_ptr(&ptr, ot);
@@ -888,14 +888,14 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char
EnumPropertyItem *item;
int value, free;
- UI_OPERATOR_ERROR_RET(ot, opname, return);
+ UI_OPERATOR_ERROR_RET(ot, opname, return );
WM_operator_properties_create_ptr(&ptr, ot);
/* enum lookup */
- if ((prop= RNA_struct_find_property(&ptr, propname))) {
+ if ((prop = RNA_struct_find_property(&ptr, propname))) {
RNA_property_enum_items_gettexted(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free);
- if (item==NULL || RNA_enum_value_from_id(item, value_str, &value)==0) {
+ if (item == NULL || RNA_enum_value_from_id(item, value_str, &value) == 0) {
if (free) {
MEM_freeN(item);
}
@@ -926,7 +926,7 @@ void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *op
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
PointerRNA ptr;
- UI_OPERATOR_ERROR_RET(ot, opname, return);
+ UI_OPERATOR_ERROR_RET(ot, opname, return );
WM_operator_properties_create_ptr(&ptr, ot);
RNA_boolean_set(&ptr, propname, value);
@@ -939,7 +939,7 @@ void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
PointerRNA ptr;
- UI_OPERATOR_ERROR_RET(ot, opname, return);
+ UI_OPERATOR_ERROR_RET(ot, opname, return );
WM_operator_properties_create_ptr(&ptr, ot);
RNA_int_set(&ptr, propname, value);
@@ -952,7 +952,7 @@ void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opna
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
PointerRNA ptr;
- UI_OPERATOR_ERROR_RET(ot, opname, return);
+ UI_OPERATOR_ERROR_RET(ot, opname, return );
WM_operator_properties_create_ptr(&ptr, ot);
RNA_float_set(&ptr, propname, value);
@@ -965,7 +965,7 @@ void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opn
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
PointerRNA ptr;
- UI_OPERATOR_ERROR_RET(ot, opname, return);
+ UI_OPERATOR_ERROR_RET(ot, opname, return );
WM_operator_properties_create_ptr(&ptr, ot);
RNA_string_set(&ptr, propname, value);
@@ -987,46 +987,46 @@ static void ui_item_rna_size(uiLayout *layout, const char *name, int icon, Point
int len, w, h;
/* arbitrary extended width by type */
- type= RNA_property_type(prop);
- subtype= RNA_property_subtype(prop);
- len= RNA_property_array_length(ptr, prop);
+ type = RNA_property_type(prop);
+ subtype = RNA_property_subtype(prop);
+ len = RNA_property_array_length(ptr, prop);
if (ELEM3(type, PROP_STRING, PROP_POINTER, PROP_ENUM) && !name[0] && !icon_only)
- name= "non-empty text";
+ name = "non-empty text";
else if (type == PROP_BOOLEAN && !name[0] && !icon_only)
- icon= ICON_DOT;
+ icon = ICON_DOT;
- w= ui_text_icon_width(layout, name, icon, 0);
- h= UI_UNIT_Y;
+ w = ui_text_icon_width(layout, name, icon, 0);
+ h = UI_UNIT_Y;
/* increase height for arrays */
if (index == RNA_NO_INDEX && len > 0) {
if (!name[0] && icon == ICON_NONE)
- h= 0;
+ h = 0;
if (ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER))
- h += 2*UI_UNIT_Y;
+ h += 2 * UI_UNIT_Y;
else if (subtype == PROP_MATRIX)
- h += ceil(sqrt(len))*UI_UNIT_Y;
+ h += ceil(sqrt(len)) * UI_UNIT_Y;
else
- h += len*UI_UNIT_Y;
+ h += len * UI_UNIT_Y;
}
else if (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) {
if (type == PROP_BOOLEAN && name[0])
- w += UI_UNIT_X/5;
+ w += UI_UNIT_X / 5;
else if (type == PROP_ENUM)
- w += UI_UNIT_X/4;
+ w += UI_UNIT_X / 4;
else if (type == PROP_FLOAT || type == PROP_INT)
- w += UI_UNIT_X*3;
+ w += UI_UNIT_X * 3;
}
- *r_w= w;
- *r_h= h;
+ *r_w = w;
+ *r_h = h;
}
void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index, int value, int flag, const char *name, int icon)
{
- uiBlock *block= layout->root->block;
+ uiBlock *block = layout->root->block;
uiBut *but;
PropertyType type;
char namestr[UI_MAX_NAME_STR];
@@ -1035,44 +1035,44 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
uiBlockSetCurLayout(block, layout);
/* retrieve info */
- type= RNA_property_type(prop);
- is_array= RNA_property_array_check(prop);
- len= (is_array) ? RNA_property_array_length(ptr, prop) : 0;
+ type = RNA_property_type(prop);
+ is_array = RNA_property_array_check(prop);
+ len = (is_array) ? RNA_property_array_length(ptr, prop) : 0;
/* set name and icon */
if (!name)
- name= RNA_property_ui_name(prop);
+ name = RNA_property_ui_name(prop);
if (icon == ICON_NONE)
- icon= RNA_property_ui_icon(prop);
+ icon = RNA_property_ui_icon(prop);
if (ELEM4(type, PROP_INT, PROP_FLOAT, PROP_STRING, PROP_POINTER))
- name= ui_item_name_add_colon(name, namestr);
+ name = ui_item_name_add_colon(name, namestr);
else if (type == PROP_BOOLEAN && is_array && index == RNA_NO_INDEX)
- name= ui_item_name_add_colon(name, namestr);
+ name = ui_item_name_add_colon(name, namestr);
else if (type == PROP_ENUM && index != RNA_ENUM_VALUE)
- name= ui_item_name_add_colon(name, namestr);
+ name = ui_item_name_add_colon(name, namestr);
if (layout->root->type == UI_LAYOUT_MENU) {
if (type == PROP_BOOLEAN && ((is_array == FALSE) || (index != RNA_NO_INDEX))) {
- if (is_array) icon= (RNA_property_boolean_get_index(ptr, prop, index)) ? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT;
- else icon= (RNA_property_boolean_get(ptr, prop)) ? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT;
+ if (is_array) icon = (RNA_property_boolean_get_index(ptr, prop, index)) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
+ else icon = (RNA_property_boolean_get(ptr, prop)) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
}
else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) {
- int enum_value= RNA_property_enum_get(ptr, prop);
+ int enum_value = RNA_property_enum_get(ptr, prop);
if (RNA_property_flag(prop) & PROP_ENUM_FLAG) {
- icon= (enum_value & value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT;
+ icon = (enum_value & value) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
}
else {
- icon= (enum_value == value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT;
+ icon = (enum_value == value) ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
}
}
}
- slider= (flag & UI_ITEM_R_SLIDER);
- toggle= (flag & UI_ITEM_R_TOGGLE);
- expand= (flag & UI_ITEM_R_EXPAND);
- icon_only= (flag & UI_ITEM_R_ICON_ONLY);
- no_bg= (flag & UI_ITEM_R_NO_BG);
+ slider = (flag & UI_ITEM_R_SLIDER);
+ toggle = (flag & UI_ITEM_R_TOGGLE);
+ expand = (flag & UI_ITEM_R_EXPAND);
+ icon_only = (flag & UI_ITEM_R_ICON_ONLY);
+ no_bg = (flag & UI_ITEM_R_NO_BG);
/* get size */
ui_item_rna_size(layout, name, icon, ptr, prop, index, icon_only, &w, &h);
@@ -1097,7 +1097,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only);
/* property with separate label */
else if (type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) {
- but= ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag);
+ but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag);
ui_but_add_search(but, ptr, prop, NULL, NULL);
if (layout->redalert)
@@ -1107,11 +1107,11 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
else {
but = uiDefAutoButR(block, ptr, prop, index, name, icon, 0, 0, w, h);
- if (slider && but->type==NUM)
- but->type= NUMSLI;
+ if (slider && but->type == NUM)
+ but->type = NUMSLI;
- if (toggle && but->type==OPTION)
- but->type= TOG;
+ if (toggle && but->type == OPTION)
+ but->type = TOG;
if (layout->redalert)
uiButSetFlag(but, UI_BUT_REDALERT);
@@ -1123,7 +1123,7 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
{
- PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
ui_item_disabled(layout, propname);
@@ -1136,7 +1136,7 @@ void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, int flag,
void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA *ptr, const char *propname, int value)
{
- PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
if (!prop || RNA_property_type(prop) != PROP_ENUM) {
ui_item_disabled(layout, propname);
@@ -1149,7 +1149,7 @@ void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA
void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value, const char *name, int icon)
{
- PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
EnumPropertyItem *item;
int ivalue, a, free;
@@ -1170,7 +1170,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr
return;
}
- for (a=0; item[a].identifier; a++) {
+ for (a = 0; item[a].identifier; a++) {
if (item[a].value == ivalue) {
uiItemFullR(layout, ptr, prop, RNA_ENUM_VALUE, ivalue, 0, name ? name : item[a].name, icon ? icon : item[a].icon);
break;
@@ -1185,10 +1185,10 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr
void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname)
{
PropertyRNA *prop;
- uiBlock *block= layout->root->block;
+ uiBlock *block = layout->root->block;
uiBut *bt;
- prop= RNA_struct_find_property(ptr, propname);
+ prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
ui_item_disabled(layout, propname);
@@ -1203,26 +1203,26 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname
else {
EnumPropertyItem *item;
int totitem, i, free;
- uiLayout *split= uiLayoutSplit(layout, 0, 0);
- uiLayout *column= uiLayoutColumn(split, 0);
+ uiLayout *split = uiLayoutSplit(layout, 0, 0);
+ uiLayout *column = uiLayoutColumn(split, 0);
RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free);
- for (i=0; i<totitem; i++) {
+ for (i = 0; i < totitem; i++) {
if (item[i].identifier[0]) {
uiItemEnumR(column, item[i].name, ICON_NONE, ptr, propname, item[i].value);
}
else {
if (item[i].name) {
if (i != 0) {
- column= uiLayoutColumn(split, 0);
+ column = uiLayoutColumn(split, 0);
/* inconsistent, but menus with labels do not look good flipped */
block->flag |= UI_BLOCK_NO_FLIP;
}
uiItemL(column, item[i].name, ICON_NONE);
- bt= block->buttons.last;
- bt->flag= UI_TEXT_LEFT;
+ bt = block->buttons.last;
+ bt->flag = UI_TEXT_LEFT;
}
else
uiItemS(column);
@@ -1249,7 +1249,7 @@ static int sort_search_items_list(void *a, void *b)
CollItemSearch *cis1 = (CollItemSearch *)a;
CollItemSearch *cis2 = (CollItemSearch *)b;
- if (BLI_strcasecmp(cis1->name, cis2->name)>0)
+ if (BLI_strcasecmp(cis1->name, cis2->name) > 0)
return 1;
else
return 0;
@@ -1257,12 +1257,12 @@ static int sort_search_items_list(void *a, void *b)
static void rna_search_cb(const struct bContext *C, void *arg_but, const char *str, uiSearchItems *items)
{
- uiBut *but= arg_but;
+ uiBut *but = arg_but;
char *name;
- int i=0, iconid=0, flag= RNA_property_flag(but->rnaprop);
- ListBase *items_list= MEM_callocN(sizeof(ListBase), "items_list");
+ int i = 0, iconid = 0, flag = RNA_property_flag(but->rnaprop);
+ ListBase *items_list = MEM_callocN(sizeof(ListBase), "items_list");
CollItemSearch *cis;
- const int skip_filter= !but->changed;
+ const int skip_filter = !but->changed;
/* build a temporary list of relevant items first */
RNA_PROP_BEGIN(&but->rnasearchpoin, itemptr, but->rnasearchprop) {
@@ -1271,25 +1271,25 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s
continue;
/* use filter */
- if (RNA_property_type(but->rnaprop)==PROP_POINTER) {
- if (RNA_property_pointer_poll(&but->rnapoin, but->rnaprop, &itemptr)==0)
+ if (RNA_property_type(but->rnaprop) == PROP_POINTER) {
+ if (RNA_property_pointer_poll(&but->rnapoin, but->rnaprop, &itemptr) == 0)
continue;
}
if (itemptr.type && RNA_struct_is_ID(itemptr.type)) {
- ID *id= itemptr.data;
+ ID *id = itemptr.data;
char name_ui[MAX_ID_NAME];
-#if 0 /* this name is used for a string comparison and can't be modified, TODO */
+#if 0 /* this name is used for a string comparison and can't be modified, TODO */
name_uiprefix_id(name_ui, id);
#else
- BLI_strncpy(name_ui, id->name+2, sizeof(name_ui));
+ BLI_strncpy(name_ui, id->name + 2, sizeof(name_ui));
#endif
- name= BLI_strdup(name_ui);
- iconid= ui_id_icon_get((bContext*)C, id, 0);
+ name = BLI_strdup(name_ui);
+ iconid = ui_id_icon_get((bContext *)C, id, 0);
}
else {
- name= RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */
+ name = RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); /* could use the string length here */
iconid = 0;
}
@@ -1311,13 +1311,13 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s
BLI_sortlist(items_list, sort_search_items_list);
/* add search items from temporary list */
- for (cis=items_list->first; cis; cis=cis->next) {
+ for (cis = items_list->first; cis; cis = cis->next) {
if (!uiSearchItemAdd(items, cis->name, SET_INT_IN_POINTER(cis->index), cis->iconid)) {
break;
}
}
- for (cis=items_list->first; cis; cis=cis->next) {
+ for (cis = items_list->first; cis; cis = cis->next) {
MEM_freeN(cis->name);
}
BLI_freelistN(items_list);
@@ -1331,15 +1331,15 @@ static void search_id_collection(StructRNA *ptype, PointerRNA *ptr, PropertyRNA
/* look for collection property in Main */
RNA_main_pointer_create(G.main, ptr);
- *prop= NULL;
+ *prop = NULL;
RNA_STRUCT_BEGIN(ptr, iprop) {
/* if it's a collection and has same pointer type, we've got it */
if (RNA_property_type(iprop) == PROP_COLLECTION) {
- srna= RNA_property_pointer_type(ptr, iprop);
+ srna = RNA_property_pointer_type(ptr, iprop);
if (ptype == srna) {
- *prop= iprop;
+ *prop = iprop;
break;
}
}
@@ -1355,19 +1355,19 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN
/* for ID's we do automatic lookup */
if (!searchprop) {
if (RNA_property_type(prop) == PROP_POINTER) {
- ptype= RNA_property_pointer_type(ptr, prop);
+ ptype = RNA_property_pointer_type(ptr, prop);
search_id_collection(ptype, &sptr, &searchprop);
- searchptr= &sptr;
+ searchptr = &sptr;
}
}
/* turn button into search button */
if (searchprop) {
- but->type= SEARCH_MENU;
- but->hardmax= MAX2(but->hardmax, 256);
- but->rnasearchpoin= *searchptr;
- but->rnasearchprop= searchprop;
- but->flag |= UI_ICON_LEFT|UI_TEXT_LEFT;
+ but->type = SEARCH_MENU;
+ but->hardmax = MAX2(but->hardmax, 256);
+ but->rnasearchpoin = *searchptr;
+ but->rnasearchprop = searchprop;
+ but->flag |= UI_ICON_LEFT | UI_TEXT_LEFT;
uiButSetSearchFunc(but, rna_search_cb, but, NULL, NULL);
}
@@ -1383,20 +1383,20 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
int w, h;
/* validate arguments */
- prop= RNA_struct_find_property(ptr, propname);
+ prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
- type= RNA_property_type(prop);
+ type = RNA_property_type(prop);
if (!ELEM(type, PROP_POINTER, PROP_STRING)) {
RNA_warning("Property %s must be a pointer or string", propname);
return;
}
- searchprop= RNA_struct_find_property(searchptr, searchpropname);
+ searchprop = RNA_struct_find_property(searchptr, searchpropname);
if (!searchprop) {
@@ -1409,22 +1409,22 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
}
/* get icon & name */
- if (icon==ICON_NONE) {
+ if (icon == ICON_NONE) {
if (type == PROP_POINTER)
- icontype= RNA_property_pointer_type(ptr, prop);
+ icontype = RNA_property_pointer_type(ptr, prop);
else
- icontype= RNA_property_pointer_type(searchptr, searchprop);
+ icontype = RNA_property_pointer_type(searchptr, searchprop);
- icon= RNA_struct_ui_icon(icontype);
+ icon = RNA_struct_ui_icon(icontype);
}
if (!name)
- name= RNA_property_ui_name(prop);
+ name = RNA_property_ui_name(prop);
/* create button */
- block= uiLayoutGetBlock(layout);
+ block = uiLayoutGetBlock(layout);
ui_item_rna_size(layout, name, icon, ptr, prop, 0, 0, &w, &h);
- but= ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h, 0);
+ but = ui_item_with_label(layout, block, name, icon, ptr, prop, 0, 0, 0, w, h, 0);
ui_but_add_search(but, ptr, prop, searchptr, searchprop);
}
@@ -1432,17 +1432,17 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna
/* menu item */
static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
{
- MenuType *mt= (MenuType*)arg_mt;
+ MenuType *mt = (MenuType *)arg_mt;
Menu menu = {NULL};
- menu.type= mt;
- menu.layout= layout;
+ menu.type = mt;
+ menu.layout = layout;
mt->draw(C, &menu);
}
static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg, void *argN, const char *tip)
{
- uiBlock *block= layout->root->block;
+ uiBlock *block = layout->root->block;
uiBut *but;
int w, h;
@@ -1452,12 +1452,12 @@ static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCre
uiBlockSetEmboss(block, UI_EMBOSS);
if (!name)
- name= "";
+ name = "";
if (layout->root->type == UI_LAYOUT_MENU && !icon)
- icon= ICON_BLANK1;
+ icon = ICON_BLANK1;
- w= ui_text_icon_width(layout, name, icon, 1);
- h= UI_UNIT_Y;
+ w = ui_text_icon_width(layout, name, icon, 1);
+ h = UI_UNIT_Y;
if (layout->root->type == UI_LAYOUT_HEADER) /* ugly .. */
w -= 10;
@@ -1470,14 +1470,14 @@ static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCre
but = uiDefMenuBut(block, func, arg, name, 0, 0, w, h, tip);
if (argN) { /* ugly .. */
- but->poin= (char*)but;
- but->func_argN= argN;
+ but->poin = (char *)but;
+ but->func_argN = argN;
}
if (layout->root->type == UI_LAYOUT_HEADER)
uiBlockSetEmboss(block, UI_EMBOSS);
else if (ELEM(layout->root->type, UI_LAYOUT_PANEL, UI_LAYOUT_TOOLBAR)) {
- but->type= MENU;
+ but->type = MENU;
but->flag |= UI_TEXT_LEFT;
}
}
@@ -1488,7 +1488,7 @@ void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const
mt = WM_menutype_find(menuname, FALSE);
- if (mt==NULL) {
+ if (mt == NULL) {
RNA_warning("not found %s", menuname);
return;
}
@@ -1498,7 +1498,7 @@ void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const
}
if (layout->root->type == UI_LAYOUT_MENU && !icon)
- icon= ICON_BLANK1;
+ icon = ICON_BLANK1;
ui_item_menu(layout, name, icon, ui_item_menutype_func, mt, NULL, mt->description);
}
@@ -1506,18 +1506,18 @@ void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const
/* label item */
static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon)
{
- uiBlock *block= layout->root->block;
+ uiBlock *block = layout->root->block;
uiBut *but;
int w;
uiBlockSetCurLayout(block, layout);
if (!name)
- name= "";
+ name = "";
if (layout->root->type == UI_LAYOUT_MENU && !icon)
- icon= ICON_BLANK1;
+ icon = ICON_BLANK1;
- w= ui_text_icon_width(layout, name, icon, 0);
+ w = ui_text_icon_width(layout, name, icon, 0);
if (icon && name[0])
but = uiDefIconTextBut(block, LABEL, 0, icon, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
@@ -1536,7 +1536,7 @@ void uiItemL(uiLayout *layout, const char *name, int icon)
void uiItemLDrag(uiLayout *layout, PointerRNA *ptr, const char *name, int icon)
{
- uiBut *but= uiItemL_(layout, name, icon);
+ uiBut *but = uiItemL_(layout, name, icon);
if (ptr && ptr->type)
if (RNA_struct_is_ID(ptr->type))
@@ -1548,18 +1548,18 @@ void uiItemLDrag(uiLayout *layout, PointerRNA *ptr, const char *name, int icon)
void uiItemV(uiLayout *layout, const char *name, int icon, int argval)
{
/* label */
- uiBlock *block= layout->root->block;
- float *retvalue= (block->handle)? &block->handle->retvalue: NULL;
+ uiBlock *block = layout->root->block;
+ float *retvalue = (block->handle) ? &block->handle->retvalue : NULL;
int w;
uiBlockSetCurLayout(block, layout);
if (!name)
- name= "";
+ name = "";
if (layout->root->type == UI_LAYOUT_MENU && !icon)
- icon= ICON_BLANK1;
+ icon = ICON_BLANK1;
- w= ui_text_icon_width(layout, name, icon, 0);
+ w = ui_text_icon_width(layout, name, icon, 0);
if (icon && name[0])
uiDefIconTextButF(block, BUT, argval, icon, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, 0, "");
@@ -1572,7 +1572,7 @@ void uiItemV(uiLayout *layout, const char *name, int icon, int argval)
/* separator item */
void uiItemS(uiLayout *layout)
{
- uiBlock *block= layout->root->block;
+ uiBlock *block = layout->root->block;
uiBlockSetCurLayout(block, layout);
uiDefBut(block, SEPR, 0, "", 0, 0, EM_SEPR_X, EM_SEPR_Y, NULL, 0.0, 0.0, 0, 0, "");
@@ -1598,7 +1598,7 @@ typedef struct MenuItemLevel {
static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, void *arg)
{
- MenuItemLevel *lvl= (MenuItemLevel*)(((uiBut*)arg)->func_argN);
+ MenuItemLevel *lvl = (MenuItemLevel *)(((uiBut *)arg)->func_argN);
uiLayoutSetOperatorContext(layout, lvl->opcontext);
uiItemsEnumO(layout, lvl->opname, lvl->propname);
@@ -1609,7 +1609,7 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname,
wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
MenuItemLevel *lvl;
- UI_OPERATOR_ERROR_RET(ot, opname, return);
+ UI_OPERATOR_ERROR_RET(ot, opname, return );
if (!ot->srna) {
ui_item_disabled(layout, opname);
@@ -1618,21 +1618,21 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname,
}
if (!name)
- name= ot->name;
+ name = ot->name;
if (layout->root->type == UI_LAYOUT_MENU && !icon)
- icon= ICON_BLANK1;
+ icon = ICON_BLANK1;
- lvl= MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
+ lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
BLI_strncpy(lvl->opname, opname, sizeof(lvl->opname));
BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname));
- lvl->opcontext= layout->root->opcontext;
+ lvl->opcontext = layout->root->opcontext;
ui_item_menu(layout, name, icon, menu_item_enum_opname_menu, NULL, lvl, ot->description);
}
static void menu_item_enum_rna_menu(bContext *UNUSED(C), uiLayout *layout, void *arg)
{
- MenuItemLevel *lvl= (MenuItemLevel*)(((uiBut*)arg)->func_argN);
+ MenuItemLevel *lvl = (MenuItemLevel *)(((uiBut *)arg)->func_argN);
uiLayoutSetOperatorContext(layout, lvl->opcontext);
uiItemsEnumR(layout, &lvl->rnapoin, lvl->propname);
@@ -1643,7 +1643,7 @@ void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propn
MenuItemLevel *lvl;
PropertyRNA *prop;
- prop= RNA_struct_find_property(ptr, propname);
+ prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
ui_item_disabled(layout, propname);
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
@@ -1651,14 +1651,14 @@ void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propn
}
if (!name)
- name= RNA_property_ui_name(prop);
+ name = RNA_property_ui_name(prop);
if (layout->root->type == UI_LAYOUT_MENU && !icon)
- icon= ICON_BLANK1;
+ icon = ICON_BLANK1;
- lvl= MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
- lvl->rnapoin= *ptr;
+ lvl = MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel");
+ lvl->rnapoin = *ptr;
BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname));
- lvl->opcontext= layout->root->opcontext;
+ lvl->opcontext = layout->root->opcontext;
ui_item_menu(layout, name, icon, menu_item_enum_rna_menu, NULL, lvl, RNA_property_description(prop));
}
@@ -1671,14 +1671,14 @@ static void ui_litem_estimate_row(uiLayout *litem)
uiItem *item;
int itemw, itemh;
- litem->w= 0;
- litem->h= 0;
+ litem->w = 0;
+ litem->h = 0;
- for (item=litem->items.first; item; item=item->next) {
+ for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, &itemw, &itemh);
litem->w += itemw;
- litem->h= MAX2(itemh, litem->h);
+ litem->h = MAX2(itemh, litem->h);
if (item->next)
litem->w += litem->space;
@@ -1687,22 +1687,22 @@ static void ui_litem_estimate_row(uiLayout *litem)
static int ui_litem_min_width(int itemw)
{
- return MIN2(2*UI_UNIT_X, itemw);
+ return MIN2(2 * UI_UNIT_X, itemw);
}
static void ui_litem_layout_row(uiLayout *litem)
{
uiItem *item;
int x, y, w, tot, totw, neww, itemw, minw, itemh, offset;
- int fixedw, freew, fixedx, freex, flag= 0, lastw= 0;
+ int fixedw, freew, fixedx, freex, flag = 0, lastw = 0;
/* x= litem->x; */ /* UNUSED */
- y= litem->y;
- w= litem->w;
- totw= 0;
- tot= 0;
+ y = litem->y;
+ w = litem->w;
+ totw = 0;
+ tot = 0;
- for (item=litem->items.first; item; item=item->next) {
+ for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, &itemw, &itemh);
totw += itemw;
tot++;
@@ -1712,88 +1712,88 @@ static void ui_litem_layout_row(uiLayout *litem)
return;
if (w != 0)
- w -= (tot-1)*litem->space;
- fixedw= 0;
+ w -= (tot - 1) * litem->space;
+ fixedw = 0;
/* keep clamping items to fixed minimum size until all are done */
do {
- freew= 0;
- x= 0;
- flag= 0;
+ freew = 0;
+ x = 0;
+ flag = 0;
- for (item=litem->items.first; item; item=item->next) {
+ for (item = litem->items.first; item; item = item->next) {
if (item->flag)
continue;
ui_item_size(item, &itemw, &itemh);
- minw= ui_litem_min_width(itemw);
+ minw = ui_litem_min_width(itemw);
if (w - lastw > 0)
- neww= ui_item_fit(itemw, x, totw, w-lastw, !item->next, litem->alignment, NULL);
+ neww = ui_item_fit(itemw, x, totw, w - lastw, !item->next, litem->alignment, NULL);
else
- neww= 0; /* no space left, all will need clamping to minimum size */
+ neww = 0; /* no space left, all will need clamping to minimum size */
x += neww;
if ((neww < minw || itemw == minw) && w != 0) {
/* fixed size */
- item->flag= 1;
+ item->flag = 1;
fixedw += minw;
- flag= 1;
+ flag = 1;
totw -= itemw;
}
else {
/* keep free size */
- item->flag= 0;
+ item->flag = 0;
freew += itemw;
}
}
- lastw= fixedw;
+ lastw = fixedw;
} while (flag);
- freex= 0;
- fixedx= 0;
- x= litem->x;
+ freex = 0;
+ fixedx = 0;
+ x = litem->x;
- for (item=litem->items.first; item; item=item->next) {
+ for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, &itemw, &itemh);
- minw= ui_litem_min_width(itemw);
+ minw = ui_litem_min_width(itemw);
if (item->flag) {
/* fixed minimum size items */
- itemw= ui_item_fit(minw, fixedx, fixedw, MIN2(w, fixedw), !item->next, litem->alignment, NULL);
+ itemw = ui_item_fit(minw, fixedx, fixedw, MIN2(w, fixedw), !item->next, litem->alignment, NULL);
fixedx += itemw;
}
else {
/* free size item */
- itemw= ui_item_fit(itemw, freex, freew, w-fixedw, !item->next, litem->alignment, NULL);
+ itemw = ui_item_fit(itemw, freex, freew, w - fixedw, !item->next, litem->alignment, NULL);
freex += itemw;
}
/* align right/center */
- offset= 0;
+ offset = 0;
if (litem->alignment == UI_LAYOUT_ALIGN_RIGHT) {
- if (freew > 0 && freew < w-fixedw)
- offset= (w - fixedw) - freew;
+ if (freew > 0 && freew < w - fixedw)
+ offset = (w - fixedw) - freew;
}
else if (litem->alignment == UI_LAYOUT_ALIGN_CENTER) {
- if (freew > 0 && freew < w-fixedw)
- offset= ((w - fixedw) - freew)/2;
+ if (freew > 0 && freew < w - fixedw)
+ offset = ((w - fixedw) - freew) / 2;
}
/* position item */
- ui_item_position(item, x+offset, y-itemh, itemw, itemh);
+ ui_item_position(item, x + offset, y - itemh, itemw, itemh);
x += itemw;
if (item->next)
x += litem->space;
}
- litem->w= x - litem->x;
- litem->h= litem->y - y;
- litem->x= x;
- litem->y= y;
+ litem->w = x - litem->x;
+ litem->h = litem->y - y;
+ litem->x = x;
+ litem->y = y;
}
/* single-column layout */
@@ -1802,13 +1802,13 @@ static void ui_litem_estimate_column(uiLayout *litem)
uiItem *item;
int itemw, itemh;
- litem->w= 0;
- litem->h= 0;
+ litem->w = 0;
+ litem->h = 0;
- for (item=litem->items.first; item; item=item->next) {
+ for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, &itemw, &itemh);
- litem->w= MAX2(litem->w, itemw);
+ litem->w = MAX2(litem->w, itemw);
litem->h += itemh;
if (item->next)
@@ -1821,10 +1821,10 @@ static void ui_litem_layout_column(uiLayout *litem)
uiItem *item;
int itemh, x, y;
- x= litem->x;
- y= litem->y;
+ x = litem->x;
+ y = litem->y;
- for (item=litem->items.first; item; item=item->next) {
+ for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, NULL, &itemh);
y -= itemh;
@@ -1834,9 +1834,9 @@ static void ui_litem_layout_column(uiLayout *litem)
y -= litem->space;
}
- litem->h= litem->y - y;
- litem->x= x;
- litem->y= y;
+ litem->h = litem->y - y;
+ litem->x = x;
+ litem->y = y;
}
/* root layout */
@@ -1856,59 +1856,59 @@ static void ui_litem_layout_root(uiLayout *litem)
/* box layout */
static void ui_litem_estimate_box(uiLayout *litem)
{
- uiStyle *style= litem->root->style;
+ uiStyle *style = litem->root->style;
ui_litem_estimate_column(litem);
- litem->w += 2*style->boxspace;
+ litem->w += 2 * style->boxspace;
litem->h += style->boxspace;
}
static void ui_litem_layout_box(uiLayout *litem)
{
- uiLayoutItemBx *box= (uiLayoutItemBx*)litem;
- uiStyle *style= litem->root->style;
+ uiLayoutItemBx *box = (uiLayoutItemBx *)litem;
+ uiStyle *style = litem->root->style;
uiBut *but;
int w, h;
- w= litem->w;
- h= litem->h;
+ w = litem->w;
+ h = litem->h;
litem->x += style->boxspace;
- if (w != 0) litem->w -= 2*style->boxspace;
- if (h != 0) litem->h -= 2*style->boxspace;
+ if (w != 0) litem->w -= 2 * style->boxspace;
+ if (h != 0) litem->h -= 2 * style->boxspace;
ui_litem_layout_column(litem);
litem->x -= style->boxspace;
litem->y -= style->boxspace;
- if (w != 0) litem->w += 2*style->boxspace;
+ if (w != 0) litem->w += 2 * style->boxspace;
if (h != 0) litem->h += style->boxspace;
/* roundbox around the sublayout */
- but= box->roundbox;
- but->x1= litem->x;
- but->y1= litem->y;
- but->x2= litem->x+litem->w;
- but->y2= litem->y+litem->h;
+ but = box->roundbox;
+ but->x1 = litem->x;
+ but->y1 = litem->y;
+ but->x2 = litem->x + litem->w;
+ but->y2 = litem->y + litem->h;
}
/* multi-column layout, automatically flowing to the next */
static void ui_litem_estimate_column_flow(uiLayout *litem)
{
- uiStyle *style= litem->root->style;
- uiLayoutItemFlow *flow= (uiLayoutItemFlow*)litem;
+ uiStyle *style = litem->root->style;
+ uiLayoutItemFlow *flow = (uiLayoutItemFlow *)litem;
uiItem *item;
- int col, x, y, emh, emy, miny, itemw, itemh, maxw=0;
+ int col, x, y, emh, emy, miny, itemw, itemh, maxw = 0;
int toth, totitem;
/* compute max needed width and total height */
- toth= 0;
- totitem= 0;
- for (item=litem->items.first; item; item=item->next) {
+ toth = 0;
+ totitem = 0;
+ for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, &itemw, &itemh);
- maxw= MAX2(maxw, itemw);
+ maxw = MAX2(maxw, itemw);
toth += itemh;
totitem++;
}
@@ -1916,97 +1916,97 @@ static void ui_litem_estimate_column_flow(uiLayout *litem)
if (flow->number <= 0) {
/* auto compute number of columns, not very good */
if (maxw == 0) {
- flow->totcol= 1;
+ flow->totcol = 1;
return;
}
- flow->totcol= MAX2(litem->root->emw/maxw, 1);
- flow->totcol= MIN2(flow->totcol, totitem);
+ flow->totcol = MAX2(litem->root->emw / maxw, 1);
+ flow->totcol = MIN2(flow->totcol, totitem);
}
else
- flow->totcol= flow->number;
+ flow->totcol = flow->number;
/* compute sizes */
- x= 0;
- y= 0;
- emy= 0;
- miny= 0;
+ x = 0;
+ y = 0;
+ emy = 0;
+ miny = 0;
- maxw= 0;
- emh= toth/flow->totcol;
+ maxw = 0;
+ emh = toth / flow->totcol;
/* create column per column */
- col= 0;
- for (item=litem->items.first; item; item=item->next) {
+ col = 0;
+ for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, &itemw, &itemh);
y -= itemh + style->buttonspacey;
- miny= MIN2(miny, y);
+ miny = MIN2(miny, y);
emy -= itemh;
- maxw= MAX2(itemw, maxw);
+ maxw = MAX2(itemw, maxw);
/* decide to go to next one */
- if (col < flow->totcol-1 && emy <= -emh) {
+ if (col < flow->totcol - 1 && emy <= -emh) {
x += maxw + litem->space;
- maxw= 0;
- y= 0;
+ maxw = 0;
+ y = 0;
col++;
}
}
- litem->w= x;
- litem->h= litem->y - miny;
+ litem->w = x;
+ litem->h = litem->y - miny;
}
static void ui_litem_layout_column_flow(uiLayout *litem)
{
- uiStyle *style= litem->root->style;
- uiLayoutItemFlow *flow= (uiLayoutItemFlow*)litem;
+ uiStyle *style = litem->root->style;
+ uiLayoutItemFlow *flow = (uiLayoutItemFlow *)litem;
uiItem *item;
int col, x, y, w, emh, emy, miny, itemw, itemh;
int toth, totitem, offset;
/* compute max needed width and total height */
- toth= 0;
- totitem= 0;
- for (item=litem->items.first; item; item=item->next) {
+ toth = 0;
+ totitem = 0;
+ for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, &itemw, &itemh);
toth += itemh;
totitem++;
}
/* compute sizes */
- x= litem->x;
- y= litem->y;
- emy= 0;
- miny= 0;
+ x = litem->x;
+ y = litem->y;
+ emy = 0;
+ miny = 0;
- w= litem->w - (flow->totcol-1)*style->columnspace;
- emh= toth/flow->totcol;
+ w = litem->w - (flow->totcol - 1) * style->columnspace;
+ emh = toth / flow->totcol;
/* create column per column */
- col= 0;
- for (item=litem->items.first; item; item=item->next) {
+ col = 0;
+ for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, NULL, &itemh);
- itemw= ui_item_fit(1, x-litem->x, flow->totcol, w, col == flow->totcol-1, litem->alignment, &offset);
+ itemw = ui_item_fit(1, x - litem->x, flow->totcol, w, col == flow->totcol - 1, litem->alignment, &offset);
y -= itemh;
emy -= itemh;
- ui_item_position(item, x+offset, y, itemw, itemh);
+ ui_item_position(item, x + offset, y, itemw, itemh);
y -= style->buttonspacey;
- miny= MIN2(miny, y);
+ miny = MIN2(miny, y);
/* decide to go to next one */
- if (col < flow->totcol-1 && emy <= -emh) {
+ if (col < flow->totcol - 1 && emy <= -emh) {
x += itemw + style->columnspace;
- y= litem->y;
+ y = litem->y;
col++;
}
}
- litem->h= litem->y - miny;
- litem->x= x;
- litem->y= miny;
+ litem->h = litem->y - miny;
+ litem->x = x;
+ litem->y = miny;
}
/* free layout */
@@ -2015,20 +2015,20 @@ static void ui_litem_estimate_absolute(uiLayout *litem)
uiItem *item;
int itemx, itemy, itemw, itemh, minx, miny;
- minx= 1e6;
- miny= 1e6;
- litem->w= 0;
- litem->h= 0;
+ minx = 1e6;
+ miny = 1e6;
+ litem->w = 0;
+ litem->h = 0;
- for (item=litem->items.first; item; item=item->next) {
+ for (item = litem->items.first; item; item = item->next) {
ui_item_offset(item, &itemx, &itemy);
ui_item_size(item, &itemw, &itemh);
- minx= MIN2(minx, itemx);
- miny= MIN2(miny, itemy);
+ minx = MIN2(minx, itemx);
+ miny = MIN2(miny, itemy);
- litem->w= MAX2(litem->w, itemx+itemw);
- litem->h= MAX2(litem->h, itemy+itemh);
+ litem->w = MAX2(litem->w, itemx + itemw);
+ litem->h = MAX2(litem->h, itemy + itemh);
}
litem->w -= minx;
@@ -2038,59 +2038,59 @@ static void ui_litem_estimate_absolute(uiLayout *litem)
static void ui_litem_layout_absolute(uiLayout *litem)
{
uiItem *item;
- float scalex=1.0f, scaley=1.0f;
+ float scalex = 1.0f, scaley = 1.0f;
int x, y, newx, newy, itemx, itemy, itemh, itemw, minx, miny, totw, toth;
- minx= 1e6;
- miny= 1e6;
- totw= 0;
- toth= 0;
+ minx = 1e6;
+ miny = 1e6;
+ totw = 0;
+ toth = 0;
- for (item=litem->items.first; item; item=item->next) {
+ for (item = litem->items.first; item; item = item->next) {
ui_item_offset(item, &itemx, &itemy);
ui_item_size(item, &itemw, &itemh);
- minx= MIN2(minx, itemx);
- miny= MIN2(miny, itemy);
+ minx = MIN2(minx, itemx);
+ miny = MIN2(miny, itemy);
- totw= MAX2(totw, itemx+itemw);
- toth= MAX2(toth, itemy+itemh);
+ totw = MAX2(totw, itemx + itemw);
+ toth = MAX2(toth, itemy + itemh);
}
totw -= minx;
toth -= miny;
if (litem->w && totw > 0)
- scalex= (float)litem->w/(float)totw;
+ scalex = (float)litem->w / (float)totw;
if (litem->h && toth > 0)
- scaley= (float)litem->h/(float)toth;
+ scaley = (float)litem->h / (float)toth;
- x= litem->x;
- y= litem->y - scaley*toth;
+ x = litem->x;
+ y = litem->y - scaley * toth;
- for (item=litem->items.first; item; item=item->next) {
+ for (item = litem->items.first; item; item = item->next) {
ui_item_offset(item, &itemx, &itemy);
ui_item_size(item, &itemw, &itemh);
if (scalex != 1.0f) {
- newx= (itemx - minx)*scalex;
- itemw= (itemx - minx + itemw)*scalex - newx;
- itemx= minx + newx;
+ newx = (itemx - minx) * scalex;
+ itemw = (itemx - minx + itemw) * scalex - newx;
+ itemx = minx + newx;
}
if (scaley != 1.0f) {
- newy= (itemy - miny)*scaley;
- itemh= (itemy - miny + itemh)*scaley - newy;
- itemy= miny + newy;
+ newy = (itemy - miny) * scaley;
+ itemh = (itemy - miny + itemh) * scaley - newy;
+ itemy = miny + newy;
}
- ui_item_position(item, x+itemx-minx, y+itemy-miny, itemw, itemh);
+ ui_item_position(item, x + itemx - minx, y + itemy - miny, itemw, itemh);
}
- litem->w= scalex*totw;
- litem->h= litem->y - y;
- litem->x= x + litem->w;
- litem->y= y;
+ litem->w = scalex * totw;
+ litem->h = litem->y - y;
+ litem->x = x + litem->w;
+ litem->y = y;
}
/* split layout */
@@ -2101,42 +2101,42 @@ static void ui_litem_estimate_split(uiLayout *litem)
static void ui_litem_layout_split(uiLayout *litem)
{
- uiLayoutItemSplit *split= (uiLayoutItemSplit*)litem;
+ uiLayoutItemSplit *split = (uiLayoutItemSplit *)litem;
uiItem *item;
float percentage;
- const int tot= BLI_countlist(&litem->items);
- int itemh, x, y, w, colw=0;
+ const int tot = BLI_countlist(&litem->items);
+ int itemh, x, y, w, colw = 0;
if (tot == 0)
return;
- x= litem->x;
- y= litem->y;
+ x = litem->x;
+ y = litem->y;
- percentage= (split->percentage == 0.0f)? 1.0f/(float)tot: split->percentage;
+ percentage = (split->percentage == 0.0f) ? 1.0f / (float)tot : split->percentage;
- w= (litem->w - (tot-1)*litem->space);
- colw= w*percentage;
- colw= MAX2(colw, 0);
+ w = (litem->w - (tot - 1) * litem->space);
+ colw = w * percentage;
+ colw = MAX2(colw, 0);
- for (item=litem->items.first; item; item=item->next) {
+ for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, NULL, &itemh);
- ui_item_position(item, x, y-itemh, colw, itemh);
+ ui_item_position(item, x, y - itemh, colw, itemh);
x += colw;
if (item->next) {
- colw= (w - (int)(w*percentage))/(tot-1);
- colw= MAX2(colw, 0);
+ colw = (w - (int)(w * percentage)) / (tot - 1);
+ colw = MAX2(colw, 0);
x += litem->space;
}
}
- litem->w= x - litem->x;
- litem->h= litem->y - y;
- litem->x= x;
- litem->y= y;
+ litem->w = x - litem->x;
+ litem->h = litem->y - y;
+ litem->x = x;
+ litem->y = y;
}
/* overlap layout */
@@ -2145,14 +2145,14 @@ static void ui_litem_estimate_overlap(uiLayout *litem)
uiItem *item;
int itemw, itemh;
- litem->w= 0;
- litem->h= 0;
+ litem->w = 0;
+ litem->h = 0;
- for (item=litem->items.first; item; item=item->next) {
+ for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, &itemw, &itemh);
- litem->w= MAX2(itemw, litem->w);
- litem->h= MAX2(itemh, litem->h);
+ litem->w = MAX2(itemw, litem->w);
+ litem->h = MAX2(itemh, litem->h);
}
}
@@ -2161,18 +2161,18 @@ static void ui_litem_layout_overlap(uiLayout *litem)
uiItem *item;
int itemw, itemh, x, y;
- x= litem->x;
- y= litem->y;
+ x = litem->x;
+ y = litem->y;
- for (item=litem->items.first; item; item=item->next) {
+ for (item = litem->items.first; item; item = item->next) {
ui_item_size(item, &itemw, &itemh);
- ui_item_position(item, x, y-itemh, litem->w, itemh);
+ ui_item_position(item, x, y - itemh, litem->w, itemh);
- litem->h= MAX2(litem->h, itemh);
+ litem->h = MAX2(litem->h, itemh);
}
- litem->x= x;
- litem->y= y - litem->h;
+ litem->x = x;
+ litem->y = y - litem->h;
}
/* layout create functions */
@@ -2180,14 +2180,14 @@ uiLayout *uiLayoutRow(uiLayout *layout, int align)
{
uiLayout *litem;
- litem= MEM_callocN(sizeof(uiLayout), "uiLayoutRow");
- litem->item.type= ITEM_LAYOUT_ROW;
- litem->root= layout->root;
- litem->align= align;
- litem->active= 1;
- litem->enabled= 1;
- litem->context= layout->context;
- litem->space= (align)? 0: layout->root->style->buttonspacex;
+ litem = MEM_callocN(sizeof(uiLayout), "uiLayoutRow");
+ litem->item.type = ITEM_LAYOUT_ROW;
+ litem->root = layout->root;
+ litem->align = align;
+ litem->active = 1;
+ litem->enabled = 1;
+ litem->context = layout->context;
+ litem->space = (align) ? 0 : layout->root->style->buttonspacex;
litem->w = layout->w;
BLI_addtail(&layout->items, litem);
@@ -2200,14 +2200,14 @@ uiLayout *uiLayoutColumn(uiLayout *layout, int align)
{
uiLayout *litem;
- litem= MEM_callocN(sizeof(uiLayout), "uiLayoutColumn");
- litem->item.type= ITEM_LAYOUT_COLUMN;
- litem->root= layout->root;
- litem->align= align;
- litem->active= 1;
- litem->enabled= 1;
- litem->context= layout->context;
- litem->space= (litem->align)? 0: layout->root->style->buttonspacey;
+ litem = MEM_callocN(sizeof(uiLayout), "uiLayoutColumn");
+ litem->item.type = ITEM_LAYOUT_COLUMN;
+ litem->root = layout->root;
+ litem->align = align;
+ litem->active = 1;
+ litem->enabled = 1;
+ litem->context = layout->context;
+ litem->space = (litem->align) ? 0 : layout->root->style->buttonspacey;
litem->w = layout->w;
BLI_addtail(&layout->items, litem);
@@ -2220,16 +2220,16 @@ uiLayout *uiLayoutColumnFlow(uiLayout *layout, int number, int align)
{
uiLayoutItemFlow *flow;
- flow= MEM_callocN(sizeof(uiLayoutItemFlow), "uiLayoutItemFlow");
- flow->litem.item.type= ITEM_LAYOUT_COLUMN_FLOW;
- flow->litem.root= layout->root;
- flow->litem.align= align;
- flow->litem.active= 1;
- flow->litem.enabled= 1;
- flow->litem.context= layout->context;
- flow->litem.space= (flow->litem.align)? 0: layout->root->style->columnspace;
+ flow = MEM_callocN(sizeof(uiLayoutItemFlow), "uiLayoutItemFlow");
+ flow->litem.item.type = ITEM_LAYOUT_COLUMN_FLOW;
+ flow->litem.root = layout->root;
+ flow->litem.align = align;
+ flow->litem.active = 1;
+ flow->litem.enabled = 1;
+ flow->litem.context = layout->context;
+ flow->litem.space = (flow->litem.align) ? 0 : layout->root->style->columnspace;
flow->litem.w = layout->w;
- flow->number= number;
+ flow->number = number;
BLI_addtail(&layout->items, flow);
uiBlockSetCurLayout(layout->root->block, &flow->litem);
@@ -2241,52 +2241,52 @@ static uiLayoutItemBx *ui_layout_box(uiLayout *layout, int type)
{
uiLayoutItemBx *box;
- box= MEM_callocN(sizeof(uiLayoutItemBx), "uiLayoutItemBx");
- box->litem.item.type= ITEM_LAYOUT_BOX;
- box->litem.root= layout->root;
- box->litem.active= 1;
- box->litem.enabled= 1;
- box->litem.context= layout->context;
- box->litem.space= layout->root->style->columnspace;
+ box = MEM_callocN(sizeof(uiLayoutItemBx), "uiLayoutItemBx");
+ box->litem.item.type = ITEM_LAYOUT_BOX;
+ box->litem.root = layout->root;
+ box->litem.active = 1;
+ box->litem.enabled = 1;
+ box->litem.context = layout->context;
+ box->litem.space = layout->root->style->columnspace;
box->litem.w = layout->w;
BLI_addtail(&layout->items, box);
uiBlockSetCurLayout(layout->root->block, &box->litem);
- box->roundbox= uiDefBut(layout->root->block, type, 0, "", 0, 0, 0, 0, NULL, 0.0, 0.0, 0, 0, "");
+ box->roundbox = uiDefBut(layout->root->block, type, 0, "", 0, 0, 0, 0, NULL, 0.0, 0.0, 0, 0, "");
return box;
}
uiLayout *uiLayoutBox(uiLayout *layout)
{
- return (uiLayout*)ui_layout_box(layout, ROUNDBOX);
+ return (uiLayout *)ui_layout_box(layout, ROUNDBOX);
}
uiLayout *uiLayoutListBox(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *actptr, PropertyRNA *actprop)
{
- uiLayoutItemBx *box= ui_layout_box(layout, LISTBOX);
- uiBut *but= box->roundbox;
+ uiLayoutItemBx *box = ui_layout_box(layout, LISTBOX);
+ uiBut *but = box->roundbox;
- but->rnasearchpoin= *ptr;
- but->rnasearchprop= prop;
- but->rnapoin= *actptr;
- but->rnaprop= actprop;
+ but->rnasearchpoin = *ptr;
+ but->rnasearchprop = prop;
+ but->rnapoin = *actptr;
+ but->rnaprop = actprop;
- return (uiLayout*)box;
+ return (uiLayout *)box;
}
uiLayout *uiLayoutAbsolute(uiLayout *layout, int align)
{
uiLayout *litem;
- litem= MEM_callocN(sizeof(uiLayout), "uiLayoutAbsolute");
- litem->item.type= ITEM_LAYOUT_ABSOLUTE;
- litem->root= layout->root;
- litem->align= align;
- litem->active= 1;
- litem->enabled= 1;
- litem->context= layout->context;
+ litem = MEM_callocN(sizeof(uiLayout), "uiLayoutAbsolute");
+ litem->item.type = ITEM_LAYOUT_ABSOLUTE;
+ litem->root = layout->root;
+ litem->align = align;
+ litem->active = 1;
+ litem->enabled = 1;
+ litem->context = layout->context;
BLI_addtail(&layout->items, litem);
uiBlockSetCurLayout(layout->root->block, litem);
@@ -2298,7 +2298,7 @@ uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout)
{
uiBlock *block;
- block= uiLayoutGetBlock(layout);
+ block = uiLayoutGetBlock(layout);
uiLayoutAbsolute(layout, 0);
return block;
@@ -2308,12 +2308,12 @@ uiLayout *uiLayoutOverlap(uiLayout *layout)
{
uiLayout *litem;
- litem= MEM_callocN(sizeof(uiLayout), "uiLayoutOverlap");
- litem->item.type= ITEM_LAYOUT_OVERLAP;
- litem->root= layout->root;
- litem->active= 1;
- litem->enabled= 1;
- litem->context= layout->context;
+ litem = MEM_callocN(sizeof(uiLayout), "uiLayoutOverlap");
+ litem->item.type = ITEM_LAYOUT_OVERLAP;
+ litem->root = layout->root;
+ litem->active = 1;
+ litem->enabled = 1;
+ litem->context = layout->context;
BLI_addtail(&layout->items, litem);
uiBlockSetCurLayout(layout->root->block, litem);
@@ -2325,16 +2325,16 @@ uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align)
{
uiLayoutItemSplit *split;
- split= MEM_callocN(sizeof(uiLayoutItemSplit), "uiLayoutItemSplit");
- split->litem.item.type= ITEM_LAYOUT_SPLIT;
- split->litem.root= layout->root;
- split->litem.align= align;
- split->litem.active= 1;
- split->litem.enabled= 1;
- split->litem.context= layout->context;
- split->litem.space= layout->root->style->columnspace;
- split->litem.w= layout->w;
- split->percentage= percentage;
+ split = MEM_callocN(sizeof(uiLayoutItemSplit), "uiLayoutItemSplit");
+ split->litem.item.type = ITEM_LAYOUT_SPLIT;
+ split->litem.root = layout->root;
+ split->litem.align = align;
+ split->litem.active = 1;
+ split->litem.enabled = 1;
+ split->litem.context = layout->context;
+ split->litem.space = layout->root->style->columnspace;
+ split->litem.w = layout->w;
+ split->percentage = percentage;
BLI_addtail(&layout->items, split);
uiBlockSetCurLayout(layout->root->block, &split->litem);
@@ -2344,37 +2344,37 @@ uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align)
void uiLayoutSetActive(uiLayout *layout, int active)
{
- layout->active= active;
+ layout->active = active;
}
void uiLayoutSetEnabled(uiLayout *layout, int enabled)
{
- layout->enabled= enabled;
+ layout->enabled = enabled;
}
void uiLayoutSetRedAlert(uiLayout *layout, int redalert)
{
- layout->redalert= redalert;
+ layout->redalert = redalert;
}
void uiLayoutSetKeepAspect(uiLayout *layout, int keepaspect)
{
- layout->keepaspect= keepaspect;
+ layout->keepaspect = keepaspect;
}
void uiLayoutSetAlignment(uiLayout *layout, int alignment)
{
- layout->alignment= alignment;
+ layout->alignment = alignment;
}
void uiLayoutSetScaleX(uiLayout *layout, float scale)
{
- layout->scale[0]= scale;
+ layout->scale[0] = scale;
}
void uiLayoutSetScaleY(uiLayout *layout, float scale)
{
- layout->scale[1]= scale;
+ layout->scale[1] = scale;
}
int uiLayoutGetActive(uiLayout *layout)
@@ -2424,7 +2424,7 @@ static void ui_item_scale(uiLayout *litem, float scale[2])
uiItem *item;
int x, y, w, h;
- for (item=litem->items.last; item; item=item->prev) {
+ for (item = litem->items.last; item; item = item->prev) {
ui_item_size(item, &w, &h);
ui_item_offset(item, &x, &y);
@@ -2447,9 +2447,9 @@ static void ui_item_estimate(uiItem *item)
uiItem *subitem;
if (item->type != ITEM_BUTTON) {
- uiLayout *litem= (uiLayout*)item;
+ uiLayout *litem = (uiLayout *)item;
- for (subitem=litem->items.first; subitem; subitem=subitem->next)
+ for (subitem = litem->items.first; subitem; subitem = subitem->next)
ui_item_estimate(subitem);
if (litem->items.first == NULL)
@@ -2458,7 +2458,7 @@ static void ui_item_estimate(uiItem *item)
if (litem->scale[0] != 0.0f || litem->scale[1] != 0.0f)
ui_item_scale(litem, litem->scale);
- switch(litem->item.type) {
+ switch (litem->item.type) {
case ITEM_LAYOUT_COLUMN:
ui_litem_estimate_column(litem);
break;
@@ -2495,23 +2495,23 @@ static void ui_item_align(uiLayout *litem, short nr)
uiButtonItem *bitem;
uiLayoutItemBx *box;
- for (item=litem->items.last; item; item=item->prev) {
+ for (item = litem->items.last; item; item = item->prev) {
if (item->type == ITEM_BUTTON) {
- bitem= (uiButtonItem*)item;
+ bitem = (uiButtonItem *)item;
if (ui_but_can_align(bitem->but))
if (!bitem->but->alignnr)
- bitem->but->alignnr= nr;
+ bitem->but->alignnr = nr;
}
- else if (item->type == ITEM_LAYOUT_ABSOLUTE);
- else if (item->type == ITEM_LAYOUT_OVERLAP);
+ else if (item->type == ITEM_LAYOUT_ABSOLUTE) ;
+ else if (item->type == ITEM_LAYOUT_OVERLAP) ;
else if (item->type == ITEM_LAYOUT_BOX) {
- box= (uiLayoutItemBx*)item;
- box->roundbox->alignnr= nr;
+ box = (uiLayoutItemBx *)item;
+ box->roundbox->alignnr = nr;
BLI_remlink(&litem->root->block->buttons, box->roundbox);
BLI_addhead(&litem->root->block->buttons, box->roundbox);
}
else
- ui_item_align((uiLayout*)item, nr);
+ ui_item_align((uiLayout *)item, nr);
}
}
@@ -2520,13 +2520,13 @@ static void ui_item_flag(uiLayout *litem, int flag)
uiItem *item;
uiButtonItem *bitem;
- for (item=litem->items.last; item; item=item->prev) {
+ for (item = litem->items.last; item; item = item->prev) {
if (item->type == ITEM_BUTTON) {
- bitem= (uiButtonItem*)item;
+ bitem = (uiButtonItem *)item;
bitem->but->flag |= flag;
}
else
- ui_item_flag((uiLayout*)item, flag);
+ ui_item_flag((uiLayout *)item, flag);
}
}
@@ -2535,7 +2535,7 @@ static void ui_item_layout(uiItem *item)
uiItem *subitem;
if (item->type != ITEM_BUTTON) {
- uiLayout *litem= (uiLayout*)item;
+ uiLayout *litem = (uiLayout *)item;
if (litem->items.first == NULL)
return;
@@ -2547,7 +2547,7 @@ static void ui_item_layout(uiItem *item)
if (!litem->enabled)
ui_item_flag(litem, UI_BUT_DISABLED);
- switch(litem->item.type) {
+ switch (litem->item.type) {
case ITEM_LAYOUT_COLUMN:
ui_litem_layout_column(litem);
break;
@@ -2576,7 +2576,7 @@ static void ui_item_layout(uiItem *item)
break;
}
- for (subitem=litem->items.first; subitem; subitem=subitem->next)
+ for (subitem = litem->items.first; subitem; subitem = subitem->next)
ui_item_layout(subitem);
}
}
@@ -2589,21 +2589,21 @@ static void ui_layout_end(uiBlock *block, uiLayout *layout, int *x, int *y)
ui_item_estimate(&layout->item);
ui_item_layout(&layout->item);
- if (x) *x= layout->x;
- if (y) *y= layout->y;
+ if (x) *x = layout->x;
+ if (y) *y = layout->y;
}
static void ui_layout_free(uiLayout *layout)
{
uiItem *item, *next;
- for (item=layout->items.first; item; item=next) {
- next= item->next;
+ for (item = layout->items.first; item; item = next) {
+ next = item->next;
if (item->type == ITEM_BUTTON)
MEM_freeN(item);
else
- ui_layout_free((uiLayout*)item);
+ ui_layout_free((uiLayout *)item);
}
MEM_freeN(layout);
@@ -2614,37 +2614,37 @@ uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int siz
uiLayout *layout;
uiLayoutRoot *root;
- root= MEM_callocN(sizeof(uiLayoutRoot), "uiLayoutRoot");
- root->type= type;
- root->style= style;
- root->block= block;
- root->opcontext= WM_OP_INVOKE_REGION_WIN;
+ root = MEM_callocN(sizeof(uiLayoutRoot), "uiLayoutRoot");
+ root->type = type;
+ root->style = style;
+ root->block = block;
+ root->opcontext = WM_OP_INVOKE_REGION_WIN;
- layout= MEM_callocN(sizeof(uiLayout), "uiLayout");
- layout->item.type= ITEM_LAYOUT_ROOT;
+ layout = MEM_callocN(sizeof(uiLayout), "uiLayout");
+ layout->item.type = ITEM_LAYOUT_ROOT;
- layout->x= x;
- layout->y= y;
- layout->root= root;
- layout->space= style->templatespace;
- layout->active= 1;
- layout->enabled= 1;
- layout->context= NULL;
+ layout->x = x;
+ layout->y = y;
+ layout->root = root;
+ layout->space = style->templatespace;
+ layout->active = 1;
+ layout->enabled = 1;
+ layout->context = NULL;
if (type == UI_LAYOUT_MENU)
- layout->space= 0;
+ layout->space = 0;
if (dir == UI_LAYOUT_HORIZONTAL) {
- layout->h= size;
- layout->root->emh= em*UI_UNIT_Y;
+ layout->h = size;
+ layout->root->emh = em * UI_UNIT_Y;
}
else {
- layout->w= size;
- layout->root->emw= em*UI_UNIT_X;
+ layout->w = size;
+ layout->root->emw = em * UI_UNIT_X;
}
- block->curlayout= layout;
- root->layout= layout;
+ block->curlayout = layout;
+ root->layout = layout;
BLI_addtail(&block->layouts, root);
return layout;
@@ -2663,45 +2663,45 @@ int uiLayoutGetOperatorContext(uiLayout *layout)
void uiBlockSetCurLayout(uiBlock *block, uiLayout *layout)
{
- block->curlayout= layout;
+ block->curlayout = layout;
}
void ui_layout_add_but(uiLayout *layout, uiBut *but)
{
uiButtonItem *bitem;
- bitem= MEM_callocN(sizeof(uiButtonItem), "uiButtonItem");
- bitem->item.type= ITEM_BUTTON;
- bitem->but= but;
+ bitem = MEM_callocN(sizeof(uiButtonItem), "uiButtonItem");
+ bitem->item.type = ITEM_BUTTON;
+ bitem->but = but;
BLI_addtail(&layout->items, bitem);
if (layout->context) {
- but->context= layout->context;
- but->context->used= 1;
+ but->context = layout->context;
+ but->context->used = 1;
}
}
void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext)
{
- layout->root->opcontext= opcontext;
+ layout->root->opcontext = opcontext;
}
void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv)
{
- layout->root->handlefunc= handlefunc;
- layout->root->argv= argv;
+ layout->root->handlefunc = handlefunc;
+ layout->root->argv = argv;
}
void uiBlockLayoutResolve(uiBlock *block, int *x, int *y)
{
uiLayoutRoot *root;
- if (x) *x= 0;
- if (y) *y= 0;
+ if (x) *x = 0;
+ if (y) *y = 0;
- block->curlayout= NULL;
+ block->curlayout = NULL;
- for (root=block->layouts.first; root; root=root->next) {
+ for (root = block->layouts.first; root; root = root->next) {
/* NULL in advance so we don't interfere when adding button */
ui_layout_end(block, root->layout, x, y);
ui_layout_free(root->layout);
@@ -2718,8 +2718,8 @@ void uiBlockLayoutResolve(uiBlock *block, int *x, int *y)
void uiLayoutSetContextPointer(uiLayout *layout, const char *name, PointerRNA *ptr)
{
- uiBlock *block= layout->root->block;
- layout->context= CTX_store_add(&block->contexts, name, ptr);
+ uiBlock *block = layout->root->block;
+ layout->context = CTX_store_add(&block->contexts, name, ptr);
}
@@ -2751,33 +2751,33 @@ static void ui_intro_items(DynStr *ds, ListBase *lb)
BLI_dynstr_append(ds, "[");
- for (item=lb->first; item; item=item->next) {
+ for (item = lb->first; item; item = item->next) {
BLI_dynstr_append(ds, "{");
/* could also use the INT but this is nicer*/
- switch(item->type) {
- case ITEM_BUTTON: BLI_dynstr_append(ds, "'type':'BUTTON', ");break;
- case ITEM_LAYOUT_ROW: BLI_dynstr_append(ds, "'type':'ROW', "); break;
- case ITEM_LAYOUT_COLUMN: BLI_dynstr_append(ds, "'type':'COLUMN', "); break;
- case ITEM_LAYOUT_COLUMN_FLOW:BLI_dynstr_append(ds, "'type':'COLUMN_FLOW', "); break;
- case ITEM_LAYOUT_ROW_FLOW: BLI_dynstr_append(ds, "'type':'ROW_FLOW', "); break;
- case ITEM_LAYOUT_BOX: BLI_dynstr_append(ds, "'type':'BOX', "); break;
- case ITEM_LAYOUT_ABSOLUTE: BLI_dynstr_append(ds, "'type':'ABSOLUTE', "); break;
- case ITEM_LAYOUT_SPLIT: BLI_dynstr_append(ds, "'type':'SPLIT', "); break;
- case ITEM_LAYOUT_OVERLAP: BLI_dynstr_append(ds, "'type':'OVERLAP', "); break;
- case ITEM_LAYOUT_ROOT: BLI_dynstr_append(ds, "'type':'ROOT', "); break;
- default: BLI_dynstr_append(ds, "'type':'UNKNOWN', "); break;
+ switch (item->type) {
+ case ITEM_BUTTON: BLI_dynstr_append(ds, "'type':'BUTTON', "); break;
+ case ITEM_LAYOUT_ROW: BLI_dynstr_append(ds, "'type':'ROW', "); break;
+ case ITEM_LAYOUT_COLUMN: BLI_dynstr_append(ds, "'type':'COLUMN', "); break;
+ case ITEM_LAYOUT_COLUMN_FLOW: BLI_dynstr_append(ds, "'type':'COLUMN_FLOW', "); break;
+ case ITEM_LAYOUT_ROW_FLOW: BLI_dynstr_append(ds, "'type':'ROW_FLOW', "); break;
+ case ITEM_LAYOUT_BOX: BLI_dynstr_append(ds, "'type':'BOX', "); break;
+ case ITEM_LAYOUT_ABSOLUTE: BLI_dynstr_append(ds, "'type':'ABSOLUTE', "); break;
+ case ITEM_LAYOUT_SPLIT: BLI_dynstr_append(ds, "'type':'SPLIT', "); break;
+ case ITEM_LAYOUT_OVERLAP: BLI_dynstr_append(ds, "'type':'OVERLAP', "); break;
+ case ITEM_LAYOUT_ROOT: BLI_dynstr_append(ds, "'type':'ROOT', "); break;
+ default: BLI_dynstr_append(ds, "'type':'UNKNOWN', "); break;
}
- switch(item->type) {
- case ITEM_BUTTON:
- ui_intro_button(ds, (uiButtonItem *)item);
- break;
- default:
- BLI_dynstr_append(ds, "'items':");
- ui_intro_items(ds, &((uiLayout*)item)->items);
- break;
+ switch (item->type) {
+ case ITEM_BUTTON:
+ ui_intro_button(ds, (uiButtonItem *)item);
+ break;
+ default:
+ BLI_dynstr_append(ds, "'items':");
+ ui_intro_items(ds, &((uiLayout *)item)->items);
+ break;
}
BLI_dynstr_append(ds, "}");
@@ -2796,7 +2796,7 @@ static void ui_intro_uiLayout(DynStr *ds, uiLayout *layout)
static char *str = NULL; // XXX, constant re-freeing, far from ideal.
const char *uiLayoutIntrospect(uiLayout *layout)
{
- DynStr *ds= BLI_dynstr_new();
+ DynStr *ds = BLI_dynstr_new();
if (str) {
MEM_freeN(str);
@@ -2816,11 +2816,11 @@ static void ui_layout_operator_buts__reset_cb(bContext *UNUSED(C), void *op_pt,
}
/* this function does not initialize the layout, functions can be called on the layout before and after */
-void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag)
+void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag)
{
if (!op->properties) {
IDPropertyTemplate val = {0};
- op->properties= IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
+ op->properties = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
}
if (flag & UI_LAYOUT_OP_SHOW_TITLE) {
@@ -2840,37 +2840,37 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in
PointerRNA op_ptr;
uiLayout *row;
- uiLayoutGetBlock(layout)->ui_operator= op;
+ uiLayoutGetBlock(layout)->ui_operator = op;
- row= uiLayoutRow(layout, TRUE);
+ row = uiLayoutRow(layout, TRUE);
uiItemM(row, (bContext *)C, "WM_MT_operator_presets", NULL, ICON_NONE);
WM_operator_properties_create(&op_ptr, "WM_OT_operator_preset_add");
RNA_string_set(&op_ptr, "operator", op->type->idname);
- op_ptr= uiItemFullO(row, "WM_OT_operator_preset_add", "", ICON_ZOOMIN, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
+ op_ptr = uiItemFullO(row, "WM_OT_operator_preset_add", "", ICON_ZOOMIN, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
WM_operator_properties_create(&op_ptr, "WM_OT_operator_preset_add");
RNA_string_set(&op_ptr, "operator", op->type->idname);
RNA_boolean_set(&op_ptr, "remove_active", TRUE);
- op_ptr= uiItemFullO(row, "WM_OT_operator_preset_add", "", ICON_ZOOMOUT, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
+ op_ptr = uiItemFullO(row, "WM_OT_operator_preset_add", "", ICON_ZOOMOUT, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
}
if (op->type->ui) {
- op->layout= layout;
- op->type->ui((bContext*)C, op);
- op->layout= NULL;
+ op->layout = layout;
+ op->type->ui((bContext *)C, op);
+ op->layout = NULL;
/* UI_LAYOUT_OP_SHOW_EMPTY ignored */
}
else {
- wmWindowManager *wm= CTX_wm_manager(C);
+ wmWindowManager *wm = CTX_wm_manager(C);
PointerRNA ptr;
int empty;
RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
/* main draw call */
- empty= uiDefAutoButsRNA(layout, &ptr, check_prop, label_align) == 0;
+ empty = uiDefAutoButsRNA(layout, &ptr, check_prop, label_align) == 0;
if (empty && (flag & UI_LAYOUT_OP_SHOW_EMPTY)) {
uiItemL(layout, IFACE_("No Properties"), ICON_NONE);
@@ -2885,9 +2885,9 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in
uiBut *but;
uiLayout *col; /* needed to avoid alignment errors with previous buttons */
- col= uiLayoutColumn(layout, 0);
- block= uiLayoutGetBlock(col);
- but = uiDefIconTextBut(block , BUT, 0, ICON_FILE_REFRESH, IFACE_("Reset"), 0, 0, 18, 20,
+ col = uiLayoutColumn(layout, 0);
+ block = uiLayoutGetBlock(col);
+ but = uiDefIconTextBut(block, BUT, 0, ICON_FILE_REFRESH, IFACE_("Reset"), 0, 0, 18, 20,
NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Reset operator defaults"));
uiButSetFunc(but, ui_layout_operator_buts__reset_cb, op, NULL);
}
@@ -2896,7 +2896,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in
{
uiBut *but;
- for (but= uiLayoutGetBlock(layout)->buttons.first; but; but= but->next) {
+ for (but = uiLayoutGetBlock(layout)->buttons.first; but; but = but->next) {
/* no undo for buttons for operator redo panels */
uiButClearFlag(but, UI_BUT_UNDO);
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 4e97a38fe25..34116f24901 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -78,7 +78,7 @@ static int eyedropper_init(bContext *C, wmOperator *op)
{
Eyedropper *eye;
- op->customdata= eye= MEM_callocN(sizeof(Eyedropper), "Eyedropper");
+ op->customdata = eye = MEM_callocN(sizeof(Eyedropper), "Eyedropper");
uiContextActiveProperty(C, &eye->ptr, &eye->prop, &eye->index);
@@ -91,7 +91,7 @@ static void eyedropper_exit(bContext *C, wmOperator *op)
if (op->customdata)
MEM_freeN(op->customdata);
- op->customdata= NULL;
+ op->customdata = NULL;
}
static int eyedropper_cancel(bContext *C, wmOperator *op)
@@ -130,12 +130,12 @@ static int eyedropper_modal(bContext *C, wmOperator *op, wmEvent *event)
{
Eyedropper *eye = (Eyedropper *)op->customdata;
- switch(event->type) {
+ switch (event->type) {
case ESCKEY:
case RIGHTMOUSE:
return eyedropper_cancel(C, op);
case LEFTMOUSE:
- if (event->val==KM_RELEASE) {
+ if (event->val == KM_RELEASE) {
eyedropper_sample(C, eye, event->x, event->y);
eyedropper_exit(C, op);
return OPERATOR_FINISHED;
@@ -165,7 +165,7 @@ static int eyedropper_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
}
/* Repeat operator */
-static int eyedropper_exec (bContext *C, wmOperator *op)
+static int eyedropper_exec(bContext *C, wmOperator *op)
{
/* init */
if (eyedropper_init(C, op)) {
@@ -239,14 +239,14 @@ static int copy_data_path_button_exec(bContext *C, wmOperator *UNUSED(op))
PointerRNA ptr;
PropertyRNA *prop;
char *path;
- int success= 0;
+ int success = 0;
int index;
/* try to create driver using property retrieved from UI */
uiContextActiveProperty(C, &ptr, &prop, &index);
if (ptr.id.data && ptr.data && prop) {
- path= RNA_path_from_ID_to_property(&ptr, prop);
+ path = RNA_path_from_ID_to_property(&ptr, prop);
if (path) {
WM_clipboard_text_set(path, FALSE);
@@ -255,7 +255,7 @@ static int copy_data_path_button_exec(bContext *C, wmOperator *UNUSED(op))
}
/* since we're just copying, we don't really need to do anything else...*/
- return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
+ return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
static void UI_OT_copy_data_path_button(wmOperatorType *ot)
@@ -290,7 +290,7 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
{
PointerRNA ptr;
PropertyRNA *prop;
- int success= 0;
+ int success = 0;
int index, all = RNA_boolean_get(op->ptr, "all");
/* try to reset the nominated setting to its default value */
@@ -298,14 +298,14 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
/* if there is a valid property that is editable... */
if (ptr.data && prop && RNA_property_editable(&ptr, prop)) {
- if (RNA_property_reset(&ptr, prop, (all)? -1: index)) {
+ if (RNA_property_reset(&ptr, prop, (all) ? -1 : index)) {
/* perform updates required for this property */
RNA_property_update(C, &ptr, prop);
/* as if we pressed the button */
uiContextActivePropertyHandle(C);
- success= 1;
+ success = 1;
}
}
@@ -313,7 +313,7 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
* edits on the screen or on operator settings.
* it might be better to move undo's inline - campbell */
if (success) {
- ID *id= ptr.id.data;
+ ID *id = ptr.id.data;
if (id && ID_CHECK_UNDO(id)) {
/* do nothing, go ahead with undo */
}
@@ -323,7 +323,7 @@ static int reset_default_button_exec(bContext *C, wmOperator *op)
}
/* end hack */
- return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
+ return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
static void UI_OT_reset_default_button(wmOperatorType *ot)
@@ -366,7 +366,7 @@ static int copy_to_selected_button_poll(bContext *C)
{
PointerRNA ptr;
PropertyRNA *prop;
- int index, success= 0;
+ int index, success = 0;
uiContextActiveProperty(C, &ptr, &prop, &index);
@@ -375,9 +375,9 @@ static int copy_to_selected_button_poll(bContext *C)
ListBase lb;
if (copy_to_selected_list(C, &ptr, &lb)) {
- for (link= lb.first; link; link=link->next)
+ for (link = lb.first; link; link = link->next)
if (link->ptr.data != ptr.data && RNA_property_editable(&link->ptr, prop))
- success= 1;
+ success = 1;
BLI_freelistN(&lb);
}
@@ -390,7 +390,7 @@ static int copy_to_selected_button_exec(bContext *C, wmOperator *op)
{
PointerRNA ptr;
PropertyRNA *prop;
- int success= 0;
+ int success = 0;
int index, all = RNA_boolean_get(op->ptr, "all");
/* try to reset the nominated setting to its default value */
@@ -402,11 +402,11 @@ static int copy_to_selected_button_exec(bContext *C, wmOperator *op)
ListBase lb;
if (copy_to_selected_list(C, &ptr, &lb)) {
- for (link= lb.first; link; link=link->next) {
+ for (link = lb.first; link; link = link->next) {
if (link->ptr.data != ptr.data && RNA_property_editable(&link->ptr, prop)) {
- if (RNA_property_copy(&link->ptr, &ptr, prop, (all)? -1: index)) {
+ if (RNA_property_copy(&link->ptr, &ptr, prop, (all) ? -1 : index)) {
RNA_property_update(C, &link->ptr, prop);
- success= 1;
+ success = 1;
}
}
}
@@ -415,7 +415,7 @@ static int copy_to_selected_button_exec(bContext *C, wmOperator *op)
}
}
- return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED;
+ return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
static void UI_OT_copy_to_selected_button(wmOperatorType *ot)
@@ -430,7 +430,7 @@ static void UI_OT_copy_to_selected_button(wmOperatorType *ot)
ot->exec = copy_to_selected_button_exec;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "all", 1, "All", "Reset to default values all elements of the array");
@@ -460,7 +460,7 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op))
* - if commandline debug option enabled, show debug reports too
* - otherwise, up to info (which is what users normally see)
*/
- str = BKE_reports_string(reports, (G.f & G_DEBUG)? RPT_DEBUG : RPT_INFO);
+ str = BKE_reports_string(reports, (G.f & G_DEBUG) ? RPT_DEBUG : RPT_INFO);
if (str) {
write_text(txt, str);
@@ -502,7 +502,7 @@ struct uiEditSourceButStore {
} uiEditSourceButStore;
/* should only ever be set while the edit source operator is running */
-static struct uiEditSourceStore *ui_editsource_info= NULL;
+static struct uiEditSourceStore *ui_editsource_info = NULL;
int UI_editsource_enable_check(void)
{
@@ -513,7 +513,7 @@ static void ui_editsource_active_but_set(uiBut *but)
{
BLI_assert(ui_editsource_info == NULL);
- ui_editsource_info= MEM_callocN(sizeof(uiEditSourceStore), __func__);
+ ui_editsource_info = MEM_callocN(sizeof(uiEditSourceStore), __func__);
memcpy(&ui_editsource_info->but_orig, but, sizeof(uiBut));
ui_editsource_info->hash = BLI_ghash_new(BLI_ghashutil_ptrhash,
@@ -525,7 +525,7 @@ static void ui_editsource_active_but_clear(void)
{
BLI_ghash_free(ui_editsource_info->hash, NULL, (GHashValFreeFP)MEM_freeN);
MEM_freeN(ui_editsource_info);
- ui_editsource_info= NULL;
+ ui_editsource_info = NULL;
}
static int ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b)
@@ -538,16 +538,16 @@ static int ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b)
/* this just needs to be a 'good-enough' comparison so we can know beyond
* reasonable doubt that these buttons are the same between redraws.
* if this fails it only means edit-source fails - campbell */
- if ( (but_a->x1 == but_b->x1) &&
- (but_a->x2 == but_b->x2) &&
- (but_a->y1 == but_b->y1) &&
- (but_a->y2 == but_b->y2) &&
- (but_a->type == but_b->type) &&
- (but_a->rnaprop == but_b->rnaprop) &&
- (but_a->optype == but_b->optype) &&
- (but_a->unit_type == but_b->unit_type) &&
- strncmp(but_a->drawstr, but_b->drawstr, UI_MAX_DRAW_STR) == 0
- ) {
+ if ((but_a->x1 == but_b->x1) &&
+ (but_a->x2 == but_b->x2) &&
+ (but_a->y1 == but_b->y1) &&
+ (but_a->y2 == but_b->y2) &&
+ (but_a->type == but_b->type) &&
+ (but_a->rnaprop == but_b->rnaprop) &&
+ (but_a->optype == but_b->optype) &&
+ (but_a->unit_type == but_b->unit_type) &&
+ (strncmp(but_a->drawstr, but_b->drawstr, UI_MAX_DRAW_STR) == 0))
+ {
return TRUE;
}
else {
@@ -559,10 +559,10 @@ void UI_editsource_active_but_test(uiBut *but)
{
extern void PyC_FileAndNum_Safe(const char **filename, int *lineno);
- struct uiEditSourceButStore *but_store= MEM_callocN(sizeof(uiEditSourceButStore), __func__);
+ struct uiEditSourceButStore *but_store = MEM_callocN(sizeof(uiEditSourceButStore), __func__);
const char *fn;
- int lineno= -1;
+ int lineno = -1;
#if 0
printf("comparing buttons: '%s' == '%s'\n",
@@ -573,12 +573,12 @@ void UI_editsource_active_but_test(uiBut *but)
if (lineno != -1) {
BLI_strncpy(but_store->py_dbg_fn, fn,
- sizeof(but_store->py_dbg_fn));
- but_store->py_dbg_ln= lineno;
+ sizeof(but_store->py_dbg_fn));
+ but_store->py_dbg_ln = lineno;
}
else {
- but_store->py_dbg_fn[0]= '\0';
- but_store->py_dbg_ln= -1;
+ but_store->py_dbg_fn[0] = '\0';
+ but_store->py_dbg_ln = -1;
}
BLI_ghash_insert(ui_editsource_info->hash, but, but_store);
@@ -589,17 +589,17 @@ void UI_editsource_active_but_test(uiBut *but)
static int editsource_text_edit(bContext *C, wmOperator *op,
char filepath[FILE_MAX], int line)
{
- struct Main *bmain= CTX_data_main(C);
+ struct Main *bmain = CTX_data_main(C);
Text *text;
- for (text=bmain->text.first; text; text=text->id.next) {
+ for (text = bmain->text.first; text; text = text->id.next) {
if (text->name && BLI_path_cmp(text->name, filepath) == 0) {
break;
}
}
if (text == NULL) {
- text= add_text(filepath, bmain->name);
+ text = add_text(filepath, bmain->name);
}
if (text == NULL) {
@@ -610,10 +610,10 @@ static int editsource_text_edit(bContext *C, wmOperator *op,
else {
/* naughty!, find text area to set, not good behavior
* but since this is a dev tool lets allow it - campbell */
- ScrArea *sa= BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
+ ScrArea *sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0);
if (sa) {
- SpaceText *st= sa->spacedata.first;
- st->text= text;
+ SpaceText *st = sa->spacedata.first;
+ st->text = text;
}
else {
BKE_reportf(op->reports, RPT_INFO,
@@ -621,7 +621,7 @@ static int editsource_text_edit(bContext *C, wmOperator *op,
}
txt_move_toline(text, line - 1, FALSE);
- WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text);
+ WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, text);
}
return OPERATOR_FINISHED;
@@ -629,13 +629,13 @@ static int editsource_text_edit(bContext *C, wmOperator *op,
static int editsource_exec(bContext *C, wmOperator *op)
{
- uiBut *but= uiContextActiveButton(C);
+ uiBut *but = uiContextActiveButton(C);
if (but) {
GHashIterator ghi;
- struct uiEditSourceButStore *but_store= NULL;
+ struct uiEditSourceButStore *but_store = NULL;
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
int ret;
/* needed else the active button does not get tested */
@@ -650,12 +650,12 @@ static int editsource_exec(bContext *C, wmOperator *op)
ED_region_do_draw(C, ar);
for (BLI_ghashIterator_init(&ghi, ui_editsource_info->hash);
- !BLI_ghashIterator_isDone(&ghi);
- BLI_ghashIterator_step(&ghi))
+ !BLI_ghashIterator_isDone(&ghi);
+ BLI_ghashIterator_step(&ghi))
{
- uiBut *but= BLI_ghashIterator_getKey(&ghi);
+ uiBut *but = BLI_ghashIterator_getKey(&ghi);
if (but && ui_editsource_uibut_match(&ui_editsource_info->but_orig, but)) {
- but_store= BLI_ghashIterator_getValue(&ghi);
+ but_store = BLI_ghashIterator_getValue(&ghi);
break;
}
@@ -663,20 +663,20 @@ static int editsource_exec(bContext *C, wmOperator *op)
if (but_store) {
if (but_store->py_dbg_ln != -1) {
- ret= editsource_text_edit(C, op,
- but_store->py_dbg_fn,
- but_store->py_dbg_ln);
+ ret = editsource_text_edit(C, op,
+ but_store->py_dbg_fn,
+ but_store->py_dbg_ln);
}
else {
BKE_report(op->reports, RPT_ERROR,
- "Active button isn't from a script, cant edit source.");
- ret= OPERATOR_CANCELLED;
+ "Active button isn't from a script, cant edit source.");
+ ret = OPERATOR_CANCELLED;
}
}
else {
BKE_report(op->reports, RPT_ERROR,
- "Active button match can't be found.");
- ret= OPERATOR_CANCELLED;
+ "Active button match can't be found.");
+ ret = OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 08c96aaf0fb..0be1761eaf5 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -65,15 +65,15 @@
/*********************** defines and structs ************************/
-#define ANIMATION_TIME 0.30
-#define ANIMATION_INTERVAL 0.02
+#define ANIMATION_TIME 0.30
+#define ANIMATION_INTERVAL 0.02
-#define PNL_LAST_ADDED 1
-#define PNL_ACTIVE 2
-#define PNL_WAS_ACTIVE 4
-#define PNL_ANIM_ALIGN 8
-#define PNL_NEW_ADDED 16
-#define PNL_FIRST 32
+#define PNL_LAST_ADDED 1
+#define PNL_ACTIVE 2
+#define PNL_WAS_ACTIVE 4
+#define PNL_ANIM_ALIGN 8
+#define PNL_NEW_ADDED 16
+#define PNL_FIRST 32
typedef enum uiHandlePanelState {
PANEL_STATE_DRAG,
@@ -103,15 +103,15 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
static int panel_aligned(ScrArea *sa, ARegion *ar)
{
- if (sa->spacetype==SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) {
- SpaceButs *sbuts= sa->spacedata.first;
+ if (sa->spacetype == SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) {
+ SpaceButs *sbuts = sa->spacedata.first;
return sbuts->align;
}
- else if (sa->spacetype==SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW)
+ else if (sa->spacetype == SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW)
return BUT_VERTICAL;
- else if (sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
+ else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
return BUT_VERTICAL;
- else if (sa->spacetype==SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW)
+ else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW)
return BUT_VERTICAL;
else if (ELEM3(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS))
return BUT_VERTICAL;
@@ -122,39 +122,39 @@ static int panel_aligned(ScrArea *sa, ARegion *ar)
static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa)
{
Panel *pa;
- int active= 0;
+ int active = 0;
- *r_pa= NULL;
+ *r_pa = NULL;
- if (sa->spacetype==SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) {
- SpaceButs *sbuts= sa->spacedata.first;
+ if (sa->spacetype == SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) {
+ SpaceButs *sbuts = sa->spacedata.first;
if (sbuts->align)
- if (sbuts->re_align || sbuts->mainbo!=sbuts->mainb)
+ if (sbuts->re_align || sbuts->mainbo != sbuts->mainb)
return 1;
}
- else if (ar->regiontype==RGN_TYPE_UI)
+ else if (ar->regiontype == RGN_TYPE_UI)
return 1;
- else if (sa->spacetype==SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW)
+ else if (sa->spacetype == SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW)
return 1;
- else if (sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
+ else if (sa->spacetype == SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
return 1;
/* in case panel is added or disappears */
- for (pa=ar->panels.first; pa; pa=pa->next) {
+ for (pa = ar->panels.first; pa; pa = pa->next) {
if ((pa->runtime_flag & PNL_WAS_ACTIVE) && !(pa->runtime_flag & PNL_ACTIVE))
return 1;
if (!(pa->runtime_flag & PNL_WAS_ACTIVE) && (pa->runtime_flag & PNL_ACTIVE))
return 1;
if (pa->activedata)
- active= 1;
+ active = 1;
}
/* in case we need to do an animation (size changes) */
- for (pa=ar->panels.first; pa; pa=pa->next) {
+ for (pa = ar->panels.first; pa; pa = pa->next) {
if (pa->runtime_flag & PNL_ANIM_ALIGN) {
if (!active)
- *r_pa= pa;
+ *r_pa = pa;
return 1;
}
}
@@ -168,35 +168,35 @@ static void ui_panel_copy_offset(Panel *pa, Panel *papar)
{
/* with respect to sizes... papar is parent */
- pa->ofsx= papar->ofsx;
- pa->ofsy= papar->ofsy + papar->sizey-pa->sizey;
+ pa->ofsx = papar->ofsx;
+ pa->ofsy = papar->ofsy + papar->sizey - pa->sizey;
}
Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int *open)
{
Panel *pa, *patab, *palast, *panext;
- char *drawname= pt->label;
- char *idname= pt->idname;
- char *tabname= pt->idname;
- char *hookname= NULL;
+ char *drawname = pt->label;
+ char *idname = pt->idname;
+ char *tabname = pt->idname;
+ char *hookname = NULL;
int newpanel;
- int align= panel_aligned(sa, ar);
+ int align = panel_aligned(sa, ar);
/* check if Panel exists, then use that one */
- for (pa=ar->panels.first; pa; pa=pa->next)
- if (strncmp(pa->panelname, idname, UI_MAX_NAME_STR)==0)
- if (strncmp(pa->tabname, tabname, UI_MAX_NAME_STR)==0)
+ for (pa = ar->panels.first; pa; pa = pa->next)
+ if (strncmp(pa->panelname, idname, UI_MAX_NAME_STR) == 0)
+ if (strncmp(pa->tabname, tabname, UI_MAX_NAME_STR) == 0)
break;
- newpanel= (pa == NULL);
+ newpanel = (pa == NULL);
if (!newpanel) {
- pa->type= pt;
+ pa->type = pt;
}
else {
/* new panel */
- pa= MEM_callocN(sizeof(Panel), "new panel");
- pa->type= pt;
+ pa = MEM_callocN(sizeof(Panel), "new panel");
+ pa->type = pt;
BLI_strncpy(pa->panelname, idname, UI_MAX_NAME_STR);
BLI_strncpy(pa->tabname, tabname, UI_MAX_NAME_STR);
@@ -207,21 +207,21 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int
pa->flag |= PNL_CLOSEDX;
}
- pa->ofsx= 0;
- pa->ofsy= 0;
- pa->sizex= 0;
- pa->sizey= 0;
+ pa->ofsx = 0;
+ pa->ofsy = 0;
+ pa->sizex = 0;
+ pa->sizey = 0;
pa->runtime_flag |= PNL_NEW_ADDED;
BLI_addtail(&ar->panels, pa);
/* make new Panel tabbed? */
if (hookname) {
- for (patab= ar->panels.first; patab; patab= patab->next) {
- if ((patab->runtime_flag & PNL_ACTIVE) && patab->paneltab==NULL) {
- if (strncmp(hookname, patab->panelname, UI_MAX_NAME_STR)==0) {
- if (strncmp(tabname, patab->tabname, UI_MAX_NAME_STR)==0) {
- pa->paneltab= patab;
+ for (patab = ar->panels.first; patab; patab = patab->next) {
+ if ((patab->runtime_flag & PNL_ACTIVE) && patab->paneltab == NULL) {
+ if (strncmp(hookname, patab->panelname, UI_MAX_NAME_STR) == 0) {
+ if (strncmp(tabname, patab->tabname, UI_MAX_NAME_STR) == 0) {
+ pa->paneltab = patab;
ui_panel_copy_offset(pa, patab);
break;
}
@@ -236,14 +236,14 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int
/* if a new panel is added, we insert it right after the panel
* that was last added. this way new panels are inserted in the
* right place between versions */
- for (palast=ar->panels.first; palast; palast=palast->next)
+ for (palast = ar->panels.first; palast; palast = palast->next)
if (palast->runtime_flag & PNL_LAST_ADDED)
break;
if (newpanel) {
- pa->sortorder= (palast)? palast->sortorder+1: 0;
+ pa->sortorder = (palast) ? palast->sortorder + 1 : 0;
- for (panext=ar->panels.first; panext; panext=panext->next)
+ for (panext = ar->panels.first; panext; panext = panext->next)
if (panext != pa && panext->sortorder >= pa->sortorder)
panext->sortorder++;
}
@@ -252,63 +252,63 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int
palast->runtime_flag &= ~PNL_LAST_ADDED;
/* assign to block */
- block->panel= pa;
- pa->runtime_flag |= PNL_ACTIVE|PNL_LAST_ADDED;
+ block->panel = pa;
+ pa->runtime_flag |= PNL_ACTIVE | PNL_LAST_ADDED;
- *open= 0;
+ *open = 0;
if (pa->paneltab) return pa;
if (pa->flag & PNL_CLOSED) return pa;
- *open= 1;
+ *open = 1;
return pa;
}
void uiEndPanel(uiBlock *block, int width, int height)
{
- Panel *pa= block->panel;
+ Panel *pa = block->panel;
if (pa->runtime_flag & PNL_NEW_ADDED) {
pa->runtime_flag &= ~PNL_NEW_ADDED;
- pa->sizex= width;
- pa->sizey= height;
+ pa->sizex = width;
+ pa->sizey = height;
}
else {
/* check if we need to do an animation */
if (!ELEM(width, 0, pa->sizex) || !ELEM(height, 0, pa->sizey)) {
pa->runtime_flag |= PNL_ANIM_ALIGN;
if (height != 0)
- pa->ofsy += pa->sizey-height;
+ pa->ofsy += pa->sizey - height;
}
/* update width/height if non-zero */
if (width != 0)
- pa->sizex= width;
+ pa->sizex = width;
if (height != 0)
- pa->sizey= height;
+ pa->sizey = height;
}
}
static void ui_offset_panel_block(uiBlock *block)
{
- uiStyle *style= UI_GetStyle();
+ uiStyle *style = UI_GetStyle();
uiBut *but;
int ofsy;
/* compute bounds and offset */
ui_bounds_block(block);
- ofsy= block->panel->sizey - style->panelspace;
+ ofsy = block->panel->sizey - style->panelspace;
- for (but= block->buttons.first; but; but=but->next) {
+ for (but = block->buttons.first; but; but = but->next) {
but->y1 += ofsy;
but->y2 += ofsy;
}
- block->maxx= block->panel->sizex;
- block->maxy= block->panel->sizey;
- block->minx= block->miny= 0.0;
+ block->maxx = block->panel->sizex;
+ block->maxy = block->panel->sizey;
+ block->minx = block->miny = 0.0;
}
/**************************** drawing *******************************/
@@ -332,27 +332,27 @@ static void uiPanelPop(uiBlock *UNUSED(block))
/* triangle 'icon' for panel header */
void UI_DrawTriIcon(float x, float y, char dir)
{
- if (dir=='h') {
- ui_draw_anti_tria( x-3, y-5, x-3, y+5, x+7,y );
+ if (dir == 'h') {
+ ui_draw_anti_tria(x - 3, y - 5, x - 3, y + 5, x + 7, y);
}
- else if (dir=='t') {
- ui_draw_anti_tria( x-5, y-7, x+5, y-7, x, y+3);
+ else if (dir == 't') {
+ ui_draw_anti_tria(x - 5, y - 7, x + 5, y - 7, x, y + 3);
}
else { /* 'v' = vertical, down */
- ui_draw_anti_tria( x-5, y+3, x+5, y+3, x, y-7);
+ ui_draw_anti_tria(x - 5, y + 3, x + 5, y + 3, x, y - 7);
}
}
/* triangle 'icon' inside rect */
static void ui_draw_tria_rect(rctf *rect, char dir)
{
- if (dir=='h') {
- float half= 0.5f*(rect->ymax - rect->ymin);
- ui_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin+half);
+ if (dir == 'h') {
+ float half = 0.5f * (rect->ymax - rect->ymin);
+ ui_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin + half);
}
else {
- float half= 0.5f*(rect->xmax - rect->xmin);
- ui_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin+half, rect->ymin);
+ float half = 0.5f * (rect->xmax - rect->xmin);
+ ui_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin + half, rect->ymin);
}
}
@@ -379,33 +379,33 @@ static void ui_draw_anti_x(float x1, float y1, float x2, float y2)
static void ui_draw_x_icon(float x, float y)
{
- ui_draw_anti_x(x, y, x+9.375f, y+9.375f);
+ ui_draw_anti_x(x, y, x + 9.375f, y + 9.375f);
}
-#define PNL_ICON UI_UNIT_X /* could be UI_UNIT_Y too */
+#define PNL_ICON UI_UNIT_X /* could be UI_UNIT_Y too */
static void ui_draw_panel_scalewidget(rcti *rect)
{
float xmin, xmax, dx;
float ymin, ymax, dy;
- xmin= rect->xmax-PNL_HEADER+2;
- xmax= rect->xmax-3;
- ymin= rect->ymin+3;
- ymax= rect->ymin+PNL_HEADER-2;
+ xmin = rect->xmax - PNL_HEADER + 2;
+ xmax = rect->xmax - 3;
+ ymin = rect->ymin + 3;
+ ymax = rect->ymin + PNL_HEADER - 2;
- dx= 0.5f*(xmax-xmin);
- dy= 0.5f*(ymax-ymin);
+ dx = 0.5f * (xmax - xmin);
+ dy = 0.5f * (ymax - ymin);
glEnable(GL_BLEND);
glColor4ub(255, 255, 255, 50);
fdrawline(xmin, ymin, xmax, ymax);
- fdrawline(xmin+dx, ymin, xmax, ymax-dy);
+ fdrawline(xmin + dx, ymin, xmax, ymax - dy);
glColor4ub(0, 0, 0, 50);
- fdrawline(xmin, ymin+1, xmax, ymax+1);
- fdrawline(xmin+dx, ymin+1, xmax, ymax-dy+1);
+ fdrawline(xmin, ymin + 1, xmax, ymax + 1);
+ fdrawline(xmin + dx, ymin + 1, xmax, ymax - dy + 1);
glDisable(GL_BLEND);
}
@@ -414,64 +414,64 @@ static void ui_draw_panel_dragwidget(rctf *rect)
float xmin, xmax, dx;
float ymin, ymax, dy;
- xmin= rect->xmin;
- xmax= rect->xmax;
- ymin= rect->ymin;
- ymax= rect->ymax;
+ xmin = rect->xmin;
+ xmax = rect->xmax;
+ ymin = rect->ymin;
+ ymax = rect->ymax;
- dx= 0.333f*(xmax-xmin);
- dy= 0.333f*(ymax-ymin);
+ dx = 0.333f * (xmax - xmin);
+ dy = 0.333f * (ymax - ymin);
glEnable(GL_BLEND);
glColor4ub(255, 255, 255, 50);
fdrawline(xmin, ymax, xmax, ymin);
- fdrawline(xmin+dx, ymax, xmax, ymin+dy);
- fdrawline(xmin+2*dx, ymax, xmax, ymin+2*dy);
+ fdrawline(xmin + dx, ymax, xmax, ymin + dy);
+ fdrawline(xmin + 2 * dx, ymax, xmax, ymin + 2 * dy);
glColor4ub(0, 0, 0, 50);
- fdrawline(xmin, ymax+1, xmax, ymin+1);
- fdrawline(xmin+dx, ymax+1, xmax, ymin+dy+1);
- fdrawline(xmin+2*dx, ymax+1, xmax, ymin+2*dy+1);
+ fdrawline(xmin, ymax + 1, xmax, ymin + 1);
+ fdrawline(xmin + dx, ymax + 1, xmax, ymin + dy + 1);
+ fdrawline(xmin + 2 * dx, ymax + 1, xmax, ymin + 2 * dy + 1);
glDisable(GL_BLEND);
}
static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, rcti *rect, char dir)
{
- Panel *panel= block->panel;
+ Panel *panel = block->panel;
rcti hrect;
- int pnl_icons;
+ int pnl_icons;
const char *activename = IFACE_(panel->drawname[0] ? panel->drawname : panel->panelname);
/* + 0.001f to avoid flirting with float inaccuracy */
- if (panel->control & UI_PNL_CLOSE) pnl_icons=(panel->labelofs+2*PNL_ICON+5)/block->aspect + 0.001f;
- else pnl_icons= (panel->labelofs+PNL_ICON+5)/block->aspect + 0.001f;
+ if (panel->control & UI_PNL_CLOSE) pnl_icons = (panel->labelofs + 2 * PNL_ICON + 5) / block->aspect + 0.001f;
+ else pnl_icons = (panel->labelofs + PNL_ICON + 5) / block->aspect + 0.001f;
/* active tab */
/* draw text label */
UI_ThemeColor(TH_TITLE);
- hrect= *rect;
+ hrect = *rect;
if (dir == 'h') {
- hrect.xmin = rect->xmin+pnl_icons;
- hrect.ymin += 2.0f/block->aspect;
+ hrect.xmin = rect->xmin + pnl_icons;
+ hrect.ymin += 2.0f / block->aspect;
uiStyleFontDraw(&style->paneltitle, &hrect, activename);
}
else {
/* ignore 'pnl_icons', otherwise the text gets offset horizontally
* + 0.001f to avoid flirting with float inaccuracy
*/
- hrect.xmin = rect->xmin + (PNL_ICON+5)/block->aspect + 0.001f;
+ hrect.xmin = rect->xmin + (PNL_ICON + 5) / block->aspect + 0.001f;
uiStyleFontDrawRotated(&style->paneltitle, &hrect, activename);
}
}
static void rectf_scale(rctf *rect, float scale)
{
- float centx= 0.5f*(rect->xmin+rect->xmax);
- float centy= 0.5f*(rect->ymin+rect->ymax);
- float sizex= 0.5f*scale*(rect->xmax - rect->xmin);
- float sizey= 0.5f*scale*(rect->ymax - rect->ymin);
+ float centx = 0.5f * (rect->xmin + rect->xmax);
+ float centy = 0.5f * (rect->ymin + rect->ymax);
+ float sizex = 0.5f * scale * (rect->xmax - rect->xmin);
+ float sizey = 0.5f * scale * (rect->ymax - rect->ymin);
rect->xmin = centx - sizex;
rect->xmax = centx + sizex;
@@ -482,8 +482,8 @@ static void rectf_scale(rctf *rect, float scale)
/* panel integrated in buttonswindow, tool/property lists etc */
void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
{
- bTheme *btheme= UI_GetTheme();
- Panel *panel= block->panel;
+ bTheme *btheme = UI_GetTheme();
+ Panel *panel = block->panel;
rcti headrect;
rctf itemrect;
int ofsx;
@@ -493,35 +493,35 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
/* calculate header rect */
/* + 0.001f to prevent flicker due to float inaccuracy */
- headrect= *rect;
+ headrect = *rect;
headrect.ymin = headrect.ymax;
- headrect.ymax = headrect.ymin + floor(PNL_HEADER/block->aspect + 0.001f);
+ headrect.ymax = headrect.ymin + floor(PNL_HEADER / block->aspect + 0.001f);
{
- float minx= rect->xmin;
- float maxx= rect->xmax;
- float y= headrect.ymax;
+ float minx = rect->xmin;
+ float maxx = rect->xmax;
+ float y = headrect.ymax;
glEnable(GL_BLEND);
if (btheme->tui.panel.show_header) {
/* draw with background color */
glEnable(GL_BLEND);
- glColor4ubv((unsigned char*)btheme->tui.panel.header);
- glRectf(minx, headrect.ymin+1, maxx, y);
+ glColor4ubv((unsigned char *)btheme->tui.panel.header);
+ glRectf(minx, headrect.ymin + 1, maxx, y);
fdrawline(minx, y, maxx, y);
fdrawline(minx, y, maxx, y);
}
else if (!(panel->runtime_flag & PNL_FIRST)) {
/* draw embossed separator */
- minx += 5.0f/block->aspect;
- maxx -= 5.0f/block->aspect;
+ minx += 5.0f / block->aspect;
+ maxx -= 5.0f / block->aspect;
glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
fdrawline(minx, y, maxx, y);
glColor4f(1.0f, 1.0f, 1.0f, 0.25f);
- fdrawline(minx, y-1, maxx, y-1);
+ fdrawline(minx, y - 1, maxx, y - 1);
glDisable(GL_BLEND);
}
@@ -533,8 +533,8 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
ui_draw_aligned_panel_header(style, block, &headrect, 'h');
/* itemrect smaller */
- itemrect.xmax = headrect.xmax - 5.0f/block->aspect;
- itemrect.xmin = itemrect.xmax - (headrect.ymax-headrect.ymin);
+ itemrect.xmax = headrect.xmax - 5.0f / block->aspect;
+ itemrect.xmin = itemrect.xmax - (headrect.ymax - headrect.ymin);
itemrect.ymin = headrect.ymin;
itemrect.ymax = headrect.ymax;
@@ -561,7 +561,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
else uiSetRoundBox(UI_CNR_NONE);
UI_ThemeColorShade(TH_BACK, -120);
- uiRoundRect(0.5f + rect->xmin, 0.5f + rect->ymin, 0.5f + rect->xmax, 0.5f + headrect.ymax+1, 8);
+ uiRoundRect(0.5f + rect->xmin, 0.5f + rect->ymin, 0.5f + rect->xmax, 0.5f + headrect.ymax + 1, 8);
}
if (panel->control & UI_PNL_SCALE)
@@ -570,20 +570,20 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
/* draw optional close icon */
- ofsx= 6;
+ ofsx = 6;
if (panel->control & UI_PNL_CLOSE) {
UI_ThemeColor(TH_TEXT);
- ui_draw_x_icon(rect->xmin+2+ofsx, rect->ymax+2);
- ofsx= 22;
+ ui_draw_x_icon(rect->xmin + 2 + ofsx, rect->ymax + 2);
+ ofsx = 22;
}
/* draw collapse icon */
UI_ThemeColor(TH_TEXT);
/* itemrect smaller */
- itemrect.xmin = headrect.xmin + 5.0f/block->aspect;
- itemrect.xmax = itemrect.xmin + (headrect.ymax-headrect.ymin);
+ itemrect.xmin = headrect.xmin + 5.0f / block->aspect;
+ itemrect.xmax = itemrect.xmin + (headrect.ymax - headrect.ymin);
itemrect.ymin = headrect.ymin;
itemrect.ymax = headrect.ymax;
@@ -621,17 +621,17 @@ static int get_panel_size_y(Panel *pa)
* change sizey or location when closed */
static int get_panel_real_ofsy(Panel *pa)
{
- if (pa->flag & PNL_CLOSEDY) return pa->ofsy+pa->sizey;
- else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDY)) return pa->ofsy+pa->sizey;
+ if (pa->flag & PNL_CLOSEDY) return pa->ofsy + pa->sizey;
+ else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDY)) return pa->ofsy + pa->sizey;
else if (pa->paneltab) return pa->paneltab->ofsy;
else return pa->ofsy;
}
static int get_panel_real_ofsx(Panel *pa)
{
- if (pa->flag & PNL_CLOSEDX) return pa->ofsx+get_panel_header(pa);
- else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDX)) return pa->ofsx+get_panel_header(pa);
- else return pa->ofsx+pa->sizex;
+ if (pa->flag & PNL_CLOSEDX) return pa->ofsx + get_panel_header(pa);
+ else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDX)) return pa->ofsx + get_panel_header(pa);
+ else return pa->ofsx + pa->sizex;
}
typedef struct PanelSort {
@@ -646,7 +646,7 @@ typedef struct PanelSort {
static int find_leftmost_panel(const void *a1, const void *a2)
{
- const PanelSort *ps1=a1, *ps2=a2;
+ const PanelSort *ps1 = a1, *ps2 = a2;
if (ps1->pa->ofsx > ps2->pa->ofsx) return 1;
else if (ps1->pa->ofsx < ps2->pa->ofsx) return -1;
@@ -659,14 +659,14 @@ static int find_leftmost_panel(const void *a1, const void *a2)
static int find_highest_panel(const void *a1, const void *a2)
{
- const PanelSort *ps1=a1, *ps2=a2;
+ const PanelSort *ps1 = a1, *ps2 = a2;
/* stick uppermost header-less panels to the top of the region -
* prevent them from being sorted */
if (ps1->pa->sortorder < ps2->pa->sortorder && ps1->pa->type->flag & PNL_NO_HEADER) return -1;
- if (ps1->pa->ofsy+ps1->pa->sizey < ps2->pa->ofsy+ps2->pa->sizey) return 1;
- else if (ps1->pa->ofsy+ps1->pa->sizey > ps2->pa->ofsy+ps2->pa->sizey) return -1;
+ if (ps1->pa->ofsy + ps1->pa->sizey < ps2->pa->ofsy + ps2->pa->sizey) return 1;
+ else if (ps1->pa->ofsy + ps1->pa->sizey > ps2->pa->ofsy + ps2->pa->sizey) return -1;
else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
@@ -675,7 +675,7 @@ static int find_highest_panel(const void *a1, const void *a2)
static int compare_panel(const void *a1, const void *a2)
{
- const PanelSort *ps1=a1, *ps2=a2;
+ const PanelSort *ps1 = a1, *ps2 = a2;
if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
@@ -689,85 +689,85 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag)
{
Panel *pa;
PanelSort *ps, *panelsort, *psnext;
- int a, tot=0, done;
- int align= panel_aligned(sa, ar);
+ int a, tot = 0, done;
+ int align = panel_aligned(sa, ar);
/* count active, not tabbed panels */
- for (pa= ar->panels.first; pa; pa= pa->next)
- if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab==NULL)
+ for (pa = ar->panels.first; pa; pa = pa->next)
+ if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL)
tot++;
- if (tot==0) return 0;
+ if (tot == 0) return 0;
/* extra; change close direction? */
- for (pa= ar->panels.first; pa; pa= pa->next) {
- if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab==NULL) {
- if ((pa->flag & PNL_CLOSEDX) && (align==BUT_VERTICAL))
+ for (pa = ar->panels.first; pa; pa = pa->next) {
+ if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) {
+ if ((pa->flag & PNL_CLOSEDX) && (align == BUT_VERTICAL))
pa->flag ^= PNL_CLOSED;
- else if ((pa->flag & PNL_CLOSEDY) && (align==BUT_HORIZONTAL))
+ else if ((pa->flag & PNL_CLOSEDY) && (align == BUT_HORIZONTAL))
pa->flag ^= PNL_CLOSED;
}
}
/* sort panels */
- panelsort= MEM_callocN(tot*sizeof(PanelSort), "panelsort");
+ panelsort = MEM_callocN(tot * sizeof(PanelSort), "panelsort");
- ps= panelsort;
- for (pa= ar->panels.first; pa; pa= pa->next) {
- if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab==NULL) {
- ps->pa= MEM_dupallocN(pa);
- ps->orig= pa;
+ ps = panelsort;
+ for (pa = ar->panels.first; pa; pa = pa->next) {
+ if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab == NULL) {
+ ps->pa = MEM_dupallocN(pa);
+ ps->orig = pa;
ps++;
}
}
if (drag) {
/* while we are dragging, we sort on location and update sortorder */
- if (align==BUT_VERTICAL)
+ if (align == BUT_VERTICAL)
qsort(panelsort, tot, sizeof(PanelSort), find_highest_panel);
else
qsort(panelsort, tot, sizeof(PanelSort), find_leftmost_panel);
- for (ps=panelsort, a=0; a<tot; a++, ps++)
- ps->orig->sortorder= a;
+ for (ps = panelsort, a = 0; a < tot; a++, ps++)
+ ps->orig->sortorder = a;
}
else
/* otherwise use sortorder */
qsort(panelsort, tot, sizeof(PanelSort), compare_panel);
/* no smart other default start loc! this keeps switching f5/f6/etc compatible */
- ps= panelsort;
- ps->pa->ofsx= 0;
- ps->pa->ofsy= -get_panel_size_y(ps->pa);
+ ps = panelsort;
+ ps->pa->ofsx = 0;
+ ps->pa->ofsy = -get_panel_size_y(ps->pa);
- for (a=0; a<tot-1; a++, ps++) {
- psnext= ps+1;
-
- if (align==BUT_VERTICAL) {
- psnext->pa->ofsx= ps->pa->ofsx;
- psnext->pa->ofsy= get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa);
+ for (a = 0; a < tot - 1; a++, ps++) {
+ psnext = ps + 1;
+
+ if (align == BUT_VERTICAL) {
+ psnext->pa->ofsx = ps->pa->ofsx;
+ psnext->pa->ofsy = get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa);
}
else {
- psnext->pa->ofsx= get_panel_real_ofsx(ps->pa);
- psnext->pa->ofsy= ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa);
+ psnext->pa->ofsx = get_panel_real_ofsx(ps->pa);
+ psnext->pa->ofsy = ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa);
}
}
/* we interpolate */
- done= 0;
- ps= panelsort;
- for (a=0; a<tot; a++, ps++) {
- if ((ps->pa->flag & PNL_SELECT)==0) {
+ done = 0;
+ ps = panelsort;
+ for (a = 0; a < tot; a++, ps++) {
+ if ((ps->pa->flag & PNL_SELECT) == 0) {
if ((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) {
- ps->orig->ofsx= floorf(0.5f + fac*(float)ps->pa->ofsx + (1.0f-fac)*(float)ps->orig->ofsx);
- ps->orig->ofsy= floorf(0.5f + fac*(float)ps->pa->ofsy + (1.0f-fac)*(float)ps->orig->ofsy);
- done= 1;
+ ps->orig->ofsx = floorf(0.5f + fac * (float)ps->pa->ofsx + (1.0f - fac) * (float)ps->orig->ofsx);
+ ps->orig->ofsy = floorf(0.5f + fac * (float)ps->pa->ofsy + (1.0f - fac) * (float)ps->orig->ofsy);
+ done = 1;
}
}
}
/* copy locations to tabs */
- for (pa= ar->panels.first; pa; pa= pa->next)
+ for (pa = ar->panels.first; pa; pa = pa->next)
if (pa->paneltab && (pa->runtime_flag & PNL_ACTIVE))
ui_panel_copy_offset(pa, pa->paneltab);
@@ -783,49 +783,49 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag)
static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y)
{
Panel *pa;
- int align= panel_aligned(sa, ar);
+ int align = panel_aligned(sa, ar);
int sizex = UI_PANEL_WIDTH;
int sizey = UI_PANEL_WIDTH;
/* compute size taken up by panels, for setting in view2d */
- for (pa= ar->panels.first; pa; pa= pa->next) {
+ for (pa = ar->panels.first; pa; pa = pa->next) {
if (pa->runtime_flag & PNL_ACTIVE) {
int pa_sizex, pa_sizey;
- if (align==BUT_VERTICAL) {
- pa_sizex= pa->ofsx + pa->sizex;
- pa_sizey= get_panel_real_ofsy(pa);
+ if (align == BUT_VERTICAL) {
+ pa_sizex = pa->ofsx + pa->sizex;
+ pa_sizey = get_panel_real_ofsy(pa);
}
else {
- pa_sizex= get_panel_real_ofsx(pa) + pa->sizex;
- pa_sizey= pa->ofsy + get_panel_size_y(pa);
+ pa_sizex = get_panel_real_ofsx(pa) + pa->sizex;
+ pa_sizey = pa->ofsy + get_panel_size_y(pa);
}
- sizex= MAX2(sizex, pa_sizex);
- sizey= MIN2(sizey, pa_sizey);
+ sizex = MAX2(sizex, pa_sizex);
+ sizey = MIN2(sizey, pa_sizey);
}
}
- *x= sizex;
- *y= sizey;
+ *x = sizex;
+ *y = sizey;
}
static void ui_do_animate(const bContext *C, Panel *panel)
{
- uiHandlePanelData *data= panel->activedata;
- ScrArea *sa= CTX_wm_area(C);
- ARegion *ar= CTX_wm_region(C);
+ uiHandlePanelData *data = panel->activedata;
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
float fac;
- fac= (PIL_check_seconds_timer()-data->starttime)/ANIMATION_TIME;
- fac= sqrt(fac);
- fac= MIN2(fac, 1.0f);
+ fac = (PIL_check_seconds_timer() - data->starttime) / ANIMATION_TIME;
+ fac = sqrt(fac);
+ fac = MIN2(fac, 1.0f);
/* for max 1 second, interpolate positions */
if (uiAlignPanelStep(sa, ar, fac, 0))
ED_region_tag_redraw(ar);
else
- fac= 1.0f;
+ fac = 1.0f;
if (fac >= 1.0f) {
panel_activate_state(C, panel, PANEL_STATE_EXIT);
@@ -839,46 +839,46 @@ void uiBeginPanels(const bContext *UNUSED(C), ARegion *ar)
/* set all panels as inactive, so that at the end we know
* which ones were used */
- for (pa=ar->panels.first; pa; pa=pa->next) {
+ for (pa = ar->panels.first; pa; pa = pa->next) {
if (pa->runtime_flag & PNL_ACTIVE)
- pa->runtime_flag= PNL_WAS_ACTIVE;
+ pa->runtime_flag = PNL_WAS_ACTIVE;
else
- pa->runtime_flag= 0;
+ pa->runtime_flag = 0;
}
}
/* only draws blocks with panels */
void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y)
{
- ScrArea *sa= CTX_wm_area(C);
+ ScrArea *sa = CTX_wm_area(C);
uiBlock *block;
Panel *panot, *panew, *patest, *pa, *firstpa;
/* offset contents */
- for (block= ar->uiblocks.first; block; block= block->next)
+ for (block = ar->uiblocks.first; block; block = block->next)
if (block->active && block->panel)
ui_offset_panel_block(block);
/* consistency; are panels not made, whilst they have tabs */
- for (panot= ar->panels.first; panot; panot= panot->next) {
- if ((panot->runtime_flag & PNL_ACTIVE)==0) { // not made
+ for (panot = ar->panels.first; panot; panot = panot->next) {
+ if ((panot->runtime_flag & PNL_ACTIVE) == 0) { // not made
- for (panew= ar->panels.first; panew; panew= panew->next) {
+ for (panew = ar->panels.first; panew; panew = panew->next) {
if ((panew->runtime_flag & PNL_ACTIVE)) {
- if (panew->paneltab==panot) { // panew is tab in notmade pa
+ if (panew->paneltab == panot) { // panew is tab in notmade pa
break;
}
}
}
/* now panew can become the new parent, check all other tabs */
if (panew) {
- for (patest= ar->panels.first; patest; patest= patest->next) {
+ for (patest = ar->panels.first; patest; patest = patest->next) {
if (patest->paneltab == panot) {
- patest->paneltab= panew;
+ patest->paneltab = panew;
}
}
- panot->paneltab= panew;
- panew->paneltab= NULL;
+ panot->paneltab = panew;
+ panew->paneltab = NULL;
ED_region_tag_redraw(ar); // the buttons panew were not made
}
}
@@ -893,11 +893,11 @@ void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y)
}
/* tag first panel */
- firstpa= NULL;
- for (block= ar->uiblocks.first; block; block=block->next)
+ firstpa = NULL;
+ for (block = ar->uiblocks.first; block; block = block->next)
if (block->active && block->panel)
if (!firstpa || block->panel->sortorder < firstpa->sortorder)
- firstpa= block->panel;
+ firstpa = block->panel;
if (firstpa)
firstpa->runtime_flag |= PNL_FIRST;
@@ -913,13 +913,13 @@ void uiDrawPanels(const bContext *C, ARegion *ar)
UI_ThemeClearColor(TH_BACK);
/* draw panels, selected on top */
- for (block= ar->uiblocks.first; block; block=block->next) {
+ for (block = ar->uiblocks.first; block; block = block->next) {
if (block->active && block->panel && !(block->panel->flag & PNL_SELECT)) {
uiDrawBlock(C, block);
}
}
- for (block= ar->uiblocks.first; block; block=block->next) {
+ for (block = ar->uiblocks.first; block; block = block->next) {
if (block->active && block->panel && (block->panel->flag & PNL_SELECT)) {
uiDrawBlock(C, block);
}
@@ -934,22 +934,22 @@ static void check_panel_overlap(ARegion *ar, Panel *panel)
/* also called with panel==NULL for clear */
- for (pa=ar->panels.first; pa; pa=pa->next) {
+ for (pa = ar->panels.first; pa; pa = pa->next) {
pa->flag &= ~PNL_OVERLAP;
if (panel && (pa != panel)) {
- if (pa->paneltab==NULL && (pa->runtime_flag & PNL_ACTIVE)) {
- float safex= 0.2, safey= 0.2;
-
- if (pa->flag & PNL_CLOSEDX) safex= 0.05;
- else if (pa->flag & PNL_CLOSEDY) safey= 0.05;
- else if (panel->flag & PNL_CLOSEDX) safex= 0.05;
- else if (panel->flag & PNL_CLOSEDY) safey= 0.05;
+ if (pa->paneltab == NULL && (pa->runtime_flag & PNL_ACTIVE)) {
+ float safex = 0.2, safey = 0.2;
- if (pa->ofsx > panel->ofsx- safex*panel->sizex)
- if (pa->ofsx+pa->sizex < panel->ofsx+ (1.0f+safex)*panel->sizex)
- if (pa->ofsy > panel->ofsy- safey*panel->sizey)
- if (pa->ofsy+pa->sizey < panel->ofsy+ (1.0f+safey)*panel->sizey)
- pa->flag |= PNL_OVERLAP;
+ if (pa->flag & PNL_CLOSEDX) safex = 0.05;
+ else if (pa->flag & PNL_CLOSEDY) safey = 0.05;
+ else if (panel->flag & PNL_CLOSEDX) safex = 0.05;
+ else if (panel->flag & PNL_CLOSEDY) safey = 0.05;
+
+ if (pa->ofsx > panel->ofsx - safex * panel->sizex)
+ if (pa->ofsx + pa->sizex < panel->ofsx + (1.0f + safex) * panel->sizex)
+ if (pa->ofsy > panel->ofsy - safey * panel->sizey)
+ if (pa->ofsy + pa->sizey < panel->ofsy + (1.0f + safey) * panel->sizey)
+ pa->flag |= PNL_OVERLAP;
}
}
}
@@ -959,36 +959,36 @@ static void check_panel_overlap(ARegion *ar, Panel *panel)
static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel)
{
- uiHandlePanelData *data= panel->activedata;
- ScrArea *sa= CTX_wm_area(C);
- ARegion *ar= CTX_wm_region(C);
- short align= panel_aligned(sa, ar), dx=0, dy=0;
+ uiHandlePanelData *data = panel->activedata;
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+ short align = panel_aligned(sa, ar), dx = 0, dy = 0;
/* first clip for window, no dragging outside */
if (!BLI_in_rcti(&ar->winrct, event->x, event->y))
return;
- dx= (event->x-data->startx) & ~(PNL_GRID-1);
- dy= (event->y-data->starty) & ~(PNL_GRID-1);
+ dx = (event->x - data->startx) & ~(PNL_GRID - 1);
+ dy = (event->y - data->starty) & ~(PNL_GRID - 1);
- dx *= (float)(ar->v2d.cur.xmax - ar->v2d.cur.xmin)/(float)(ar->winrct.xmax - ar->winrct.xmin);
- dy *= (float)(ar->v2d.cur.ymax - ar->v2d.cur.ymin)/(float)(ar->winrct.ymax - ar->winrct.ymin);
+ dx *= (float)(ar->v2d.cur.xmax - ar->v2d.cur.xmin) / (float)(ar->winrct.xmax - ar->winrct.xmin);
+ dy *= (float)(ar->v2d.cur.ymax - ar->v2d.cur.ymin) / (float)(ar->winrct.ymax - ar->winrct.ymin);
if (data->state == PANEL_STATE_DRAG_SCALE) {
- panel->sizex = MAX2(data->startsizex+dx, UI_PANEL_MINX);
+ panel->sizex = MAX2(data->startsizex + dx, UI_PANEL_MINX);
- if (data->startsizey-dy < UI_PANEL_MINY)
- dy= -UI_PANEL_MINY+data->startsizey;
+ if (data->startsizey - dy < UI_PANEL_MINY)
+ dy = -UI_PANEL_MINY + data->startsizey;
- panel->sizey= data->startsizey-dy;
- panel->ofsy= data->startofsy+dy;
+ panel->sizey = data->startsizey - dy;
+ panel->ofsy = data->startofsy + dy;
}
else {
/* reset the panel snapping, to allow dragging away from snapped edges */
panel->snap = PNL_SNAP_NONE;
- panel->ofsx = data->startofsx+dx;
- panel->ofsy = data->startofsy+dy;
+ panel->ofsx = data->startofsx + dx;
+ panel->ofsy = data->startofsy + dy;
check_panel_overlap(ar, panel);
if (align) uiAlignPanelStep(sa, ar, 0.2, 1);
@@ -1004,55 +1004,55 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel)
/* also it supposes a block has panel, and isn't a menu */
static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, int my, int event)
{
- ScrArea *sa= CTX_wm_area(C);
- ARegion *ar= CTX_wm_region(C);
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
Panel *pa;
- int align= panel_aligned(sa, ar), button= 0;
+ int align = panel_aligned(sa, ar), button = 0;
/* mouse coordinates in panel space! */
/* XXX weak code, currently it assumes layout style for location of widgets */
/* check open/collapsed button */
- if (event==RETKEY)
- button= 1;
- else if (event==AKEY)
- button= 1;
+ if (event == RETKEY)
+ button = 1;
+ else if (event == AKEY)
+ button = 1;
else if (block->panel->flag & PNL_CLOSEDX) {
- if (my >= block->maxy) button= 1;
+ if (my >= block->maxy) button = 1;
}
else if (block->panel->control & UI_PNL_CLOSE) {
/* whole of header can be used to collapse panel (except top-right corner) */
- if (mx <= block->maxx-8-PNL_ICON) button= 2;
+ if (mx <= block->maxx - 8 - PNL_ICON) button = 2;
//else if (mx <= block->minx+10+2*PNL_ICON+2) button= 1;
}
- else if (mx <= block->maxx-PNL_ICON-12) {
- button= 1;
+ else if (mx <= block->maxx - PNL_ICON - 12) {
+ button = 1;
}
if (button) {
- if (button==2) { // close
+ if (button == 2) { // close
ED_region_tag_redraw(ar);
}
- else { // collapse
+ else { // collapse
if (block->panel->flag & PNL_CLOSED) {
block->panel->flag &= ~PNL_CLOSED;
/* snap back up so full panel aligns with screen edge */
if (block->panel->snap & PNL_SNAP_BOTTOM)
- block->panel->ofsy= 0;
+ block->panel->ofsy = 0;
}
- else if (align==BUT_HORIZONTAL) {
+ else if (align == BUT_HORIZONTAL) {
block->panel->flag |= PNL_CLOSEDX;
}
else {
/* snap down to bottom screen edge*/
block->panel->flag |= PNL_CLOSEDY;
if (block->panel->snap & PNL_SNAP_BOTTOM)
- block->panel->ofsy= -block->panel->sizey;
+ block->panel->ofsy = -block->panel->sizey;
}
- for (pa= ar->panels.first; pa; pa= pa->next) {
- if (pa->paneltab==block->panel) {
+ for (pa = ar->panels.first; pa; pa = pa->next) {
+ if (pa->paneltab == block->panel) {
if (block->panel->flag & PNL_CLOSED) pa->flag |= PNL_CLOSED;
else pa->flag &= ~PNL_CLOSED;
}
@@ -1064,7 +1064,7 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
else
ED_region_tag_redraw(ar);
}
- else if (mx <= (block->maxx-PNL_ICON-12)+PNL_ICON+2) {
+ else if (mx <= (block->maxx - PNL_ICON - 12) + PNL_ICON + 2) {
panel_activate_state(C, block->panel, PANEL_STATE_DRAG);
}
}
@@ -1074,35 +1074,35 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
int ui_handler_panel_region(bContext *C, wmEvent *event)
{
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
uiBlock *block;
Panel *pa;
- int retval, mx, my, inside_header= 0, inside_scale= 0, inside;
+ int retval, mx, my, inside_header = 0, inside_scale = 0, inside;
- retval= WM_UI_HANDLER_CONTINUE;
- for (block=ar->uiblocks.last; block; block=block->prev) {
- mx= event->x;
- my= event->y;
+ retval = WM_UI_HANDLER_CONTINUE;
+ for (block = ar->uiblocks.last; block; block = block->prev) {
+ mx = event->x;
+ my = event->y;
ui_window_to_block(ar, block, &mx, &my);
/* check if inside boundbox */
- inside= 0;
- pa= block->panel;
+ inside = 0;
+ pa = block->panel;
- if (!pa || pa->paneltab!=NULL)
+ if (!pa || pa->paneltab != NULL)
continue;
if (pa->type && pa->type->flag & PNL_NO_HEADER) // XXX - accessed freed panels when scripts reload, need to fix.
continue;
if (block->minx <= mx && block->maxx >= mx)
- if (block->miny <= my && block->maxy+PNL_HEADER >= my)
- inside= 1;
+ if (block->miny <= my && block->maxy + PNL_HEADER >= my)
+ inside = 1;
- if (inside && event->val==KM_PRESS) {
+ if (inside && event->val == KM_PRESS) {
if (event->type == AKEY && !ELEM4(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift, event->alt)) {
if (pa->flag & PNL_CLOSEDY) {
- if ((block->maxy <= my) && (block->maxy+PNL_HEADER >= my))
+ if ((block->maxy <= my) && (block->maxy + PNL_HEADER >= my))
ui_handle_panel_header(C, block, mx, my, event->type);
}
else
@@ -1119,19 +1119,19 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
if (inside) {
/* clicked at panel header? */
if (pa->flag & PNL_CLOSEDX) {
- if (block->minx <= mx && block->minx+PNL_HEADER >= mx)
- inside_header= 1;
+ if (block->minx <= mx && block->minx + PNL_HEADER >= mx)
+ inside_header = 1;
}
- else if ((block->maxy <= my) && (block->maxy+PNL_HEADER >= my)) {
- inside_header= 1;
+ else if ((block->maxy <= my) && (block->maxy + PNL_HEADER >= my)) {
+ inside_header = 1;
}
else if (pa->control & UI_PNL_SCALE) {
- if (block->maxx-PNL_HEADER <= mx)
- if (block->miny+PNL_HEADER >= my)
- inside_scale= 1;
+ if (block->maxx - PNL_HEADER <= mx)
+ if (block->miny + PNL_HEADER >= my)
+ inside_scale = 1;
}
- if (event->val==KM_PRESS) {
+ if (event->val == KM_PRESS) {
/* open close on header */
if (ELEM(event->type, RETKEY, PADENTER)) {
if (inside_header) {
@@ -1155,34 +1155,34 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
if (block->handler) {
rem_blockhandler(sa, block->handler);
ED_region_tag_redraw(ar);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
#endif
}
- else if (event->type==PADPLUSKEY || event->type==PADMINUS) {
+ else if (event->type == PADPLUSKEY || event->type == PADMINUS) {
#if 0 // XXX make float panel exception?
- int zoom=0;
+ int zoom = 0;
/* if panel is closed, only zoom if mouse is over the header */
- if (pa->flag & (PNL_CLOSEDX|PNL_CLOSEDY)) {
+ if (pa->flag & (PNL_CLOSEDX | PNL_CLOSEDY)) {
if (inside_header)
- zoom=1;
+ zoom = 1;
}
else
- zoom=1;
+ zoom = 1;
if (zoom) {
- ScrArea *sa= CTX_wm_area(C);
- SpaceLink *sl= sa->spacedata.first;
+ ScrArea *sa = CTX_wm_area(C);
+ SpaceLink *sl = sa->spacedata.first;
- if (sa->spacetype!=SPACE_BUTS) {
+ if (sa->spacetype != SPACE_BUTS) {
if (!(pa->control & UI_PNL_SCALE)) {
- if (event->type==PADPLUSKEY) sl->blockscale+= 0.1;
- else sl->blockscale-= 0.1;
+ if (event->type == PADPLUSKEY) sl->blockscale += 0.1;
+ else sl->blockscale -= 0.1;
CLAMP(sl->blockscale, 0.6, 1.0);
ED_region_tag_redraw(ar);
- retval= WM_UI_HANDLER_BREAK;
+ retval = WM_UI_HANDLER_BREAK;
}
}
}
@@ -1200,14 +1200,14 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
/* note, this is modal handler and should not swallow events for animation */
static int ui_handler_panel(bContext *C, wmEvent *event, void *userdata)
{
- Panel *panel= userdata;
- uiHandlePanelData *data= panel->activedata;
+ Panel *panel = userdata;
+ uiHandlePanelData *data = panel->activedata;
/* verify if we can stop */
- if (event->type == LEFTMOUSE && event->val!=KM_PRESS) {
- ScrArea *sa= CTX_wm_area(C);
- ARegion *ar= CTX_wm_region(C);
- int align= panel_aligned(sa, ar);
+ if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+ int align = panel_aligned(sa, ar);
if (align)
panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
@@ -1225,7 +1225,7 @@ static int ui_handler_panel(bContext *C, wmEvent *event, void *userdata)
ui_do_drag(C, event, panel);
}
- data= panel->activedata;
+ data = panel->activedata;
if (data && data->state == PANEL_STATE_ANIMATION)
return WM_UI_HANDLER_CONTINUE;
@@ -1235,16 +1235,16 @@ static int ui_handler_panel(bContext *C, wmEvent *event, void *userdata)
static void ui_handler_remove_panel(bContext *C, void *userdata)
{
- Panel *pa= userdata;
+ Panel *pa = userdata;
panel_activate_state(C, pa, PANEL_STATE_EXIT);
}
static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelState state)
{
- uiHandlePanelData *data= pa->activedata;
- wmWindow *win= CTX_wm_window(C);
- ARegion *ar= CTX_wm_region(C);
+ uiHandlePanelData *data = pa->activedata;
+ wmWindow *win = CTX_wm_window(C);
+ ARegion *ar = CTX_wm_region(C);
if (data && data->state == state)
return;
@@ -1267,49 +1267,49 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
if (data && data->animtimer) {
WM_event_remove_timer(CTX_wm_manager(C), win, data->animtimer);
- data->animtimer= NULL;
+ data->animtimer = NULL;
}
if (state == PANEL_STATE_EXIT) {
MEM_freeN(data);
- pa->activedata= NULL;
+ pa->activedata = NULL;
WM_event_remove_ui_handler(&win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, 0);
}
else {
if (!data) {
- data= MEM_callocN(sizeof(uiHandlePanelData), "uiHandlePanelData");
- pa->activedata= data;
+ data = MEM_callocN(sizeof(uiHandlePanelData), "uiHandlePanelData");
+ pa->activedata = data;
WM_event_add_ui_handler(C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa);
}
if (ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG))
- data->animtimer= WM_event_add_timer(CTX_wm_manager(C), win, TIMER, ANIMATION_INTERVAL);
-
- data->state= state;
- data->startx= win->eventstate->x;
- data->starty= win->eventstate->y;
- data->startofsx= pa->ofsx;
- data->startofsy= pa->ofsy;
- data->startsizex= pa->sizex;
- data->startsizey= pa->sizey;
- data->starttime= PIL_check_seconds_timer();
+ data->animtimer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, ANIMATION_INTERVAL);
+
+ data->state = state;
+ data->startx = win->eventstate->x;
+ data->starty = win->eventstate->y;
+ data->startofsx = pa->ofsx;
+ data->startofsy = pa->ofsy;
+ data->startsizex = pa->sizex;
+ data->startsizey = pa->sizey;
+ data->starttime = PIL_check_seconds_timer();
}
ED_region_tag_redraw(ar);
/* XXX exception handling, 3d window preview panel */
#if 0
- if (block->drawextra==BIF_view3d_previewdraw)
+ if (block->drawextra == BIF_view3d_previewdraw)
BIF_view3d_previewrender_clear(curarea);
#endif
/* XXX exception handling, 3d window preview panel */
#if 0
- if (block->drawextra==BIF_view3d_previewdraw)
+ if (block->drawextra == BIF_view3d_previewdraw)
BIF_view3d_previewrender_signal(curarea, PR_DISPRECT);
- else if (strcmp(block->name, "image_panel_preview")==0)
+ else if (strcmp(block->name, "image_panel_preview") == 0)
image_preview_event(2);
#endif
}
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index 13962777da3..1c37fcdd488 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -68,11 +68,11 @@
#include "interface_intern.h"
-#define MENU_SEPR_HEIGHT 6
-#define B_NOP -1
-#define MENU_SHADOW_SIDE 8
-#define MENU_SHADOW_BOTTOM 10
-#define MENU_TOP 8
+#define MENU_SEPR_HEIGHT 6
+#define B_NOP -1
+#define MENU_SHADOW_SIDE 8
+#define MENU_SHADOW_BOTTOM 10
+#define MENU_TOP 8
/*********************** Menu Data Parsing ********************* */
@@ -94,13 +94,13 @@ typedef struct MenuData {
static MenuData *menudata_new(const char *instr)
{
- MenuData *md= MEM_mallocN(sizeof(*md), "MenuData");
+ MenuData *md = MEM_mallocN(sizeof(*md), "MenuData");
- md->instr= instr;
- md->title= NULL;
- md->titleicon= 0;
- md->items= NULL;
- md->nitems= md->itemssize= 0;
+ md->instr = instr;
+ md->title = NULL;
+ md->titleicon = 0;
+ md->items = NULL;
+ md->nitems = md->itemssize = 0;
return md;
}
@@ -108,30 +108,30 @@ static MenuData *menudata_new(const char *instr)
static void menudata_set_title(MenuData *md, const char *title, int titleicon)
{
if (!md->title)
- md->title= title;
+ md->title = title;
if (!md->titleicon)
- md->titleicon= titleicon;
+ md->titleicon = titleicon;
}
static void menudata_add_item(MenuData *md, const char *str, int retval, int icon, int sepr)
{
- if (md->nitems==md->itemssize) {
- int nsize= md->itemssize?(md->itemssize<<1):1;
- MenuEntry *oitems= md->items;
+ if (md->nitems == md->itemssize) {
+ int nsize = md->itemssize ? (md->itemssize << 1) : 1;
+ MenuEntry *oitems = md->items;
- md->items= MEM_mallocN(nsize*sizeof(*md->items), "md->items");
+ md->items = MEM_mallocN(nsize * sizeof(*md->items), "md->items");
if (oitems) {
- memcpy(md->items, oitems, md->nitems*sizeof(*md->items));
+ memcpy(md->items, oitems, md->nitems * sizeof(*md->items));
MEM_freeN(oitems);
}
- md->itemssize= nsize;
+ md->itemssize = nsize;
}
- md->items[md->nitems].str= str;
- md->items[md->nitems].retval= retval;
- md->items[md->nitems].icon= icon;
- md->items[md->nitems].sepr= sepr;
+ md->items[md->nitems].str = str;
+ md->items[md->nitems].retval = retval;
+ md->items[md->nitems].icon = icon;
+ md->items[md->nitems].sepr = sepr;
md->nitems++;
}
@@ -144,86 +144,86 @@ static void menudata_free(MenuData *md)
MEM_freeN(md);
}
- /**
- * Parse menu description strings, string is of the
- * form "[sss%t|]{(sss[%xNN]|), (%l|), (sss%l|)}", ssss%t indicates the
- * menu title, sss or sss%xNN indicates an option,
- * if %xNN is given then NN is the return value if
- * that option is selected otherwise the return value
- * is the index of the option (starting with 1). %l
- * indicates a seperator, sss%l indicates a label and
- * new column.
- *
- * \param str String to be parsed.
- * \retval new menudata structure, free with menudata_free()
- */
+/**
+ * Parse menu description strings, string is of the
+ * form "[sss%t|]{(sss[%xNN]|), (%l|), (sss%l|)}", ssss%t indicates the
+ * menu title, sss or sss%xNN indicates an option,
+ * if %xNN is given then NN is the return value if
+ * that option is selected otherwise the return value
+ * is the index of the option (starting with 1). %l
+ * indicates a seperator, sss%l indicates a label and
+ * new column.
+ *
+ * \param str String to be parsed.
+ * \retval new menudata structure, free with menudata_free()
+ */
static MenuData *decompose_menu_string(const char *str)
{
- char *instr= BLI_strdup(str);
- MenuData *md= menudata_new(instr);
- const char *nitem= NULL;
- char *s= instr;
- int nicon=0, nretval= 1, nitem_is_title= 0, nitem_is_sepr= 0;
+ char *instr = BLI_strdup(str);
+ MenuData *md = menudata_new(instr);
+ const char *nitem = NULL;
+ char *s = instr;
+ int nicon = 0, nretval = 1, nitem_is_title = 0, nitem_is_sepr = 0;
while (1) {
- char c= *s;
+ char c = *s;
- if (c=='%') {
- if (s[1]=='x') {
- nretval= atoi(s+2);
+ if (c == '%') {
+ if (s[1] == 'x') {
+ nretval = atoi(s + 2);
- *s= '\0';
+ *s = '\0';
s++;
}
- else if (s[1]=='t') {
- nitem_is_title= (s != instr); /* check for empty title */
+ else if (s[1] == 't') {
+ nitem_is_title = (s != instr); /* check for empty title */
- *s= '\0';
+ *s = '\0';
s++;
}
- else if (s[1]=='l') {
- nitem_is_sepr= 1;
- if (!nitem) nitem= "";
+ else if (s[1] == 'l') {
+ nitem_is_sepr = 1;
+ if (!nitem) nitem = "";
- *s= '\0';
+ *s = '\0';
s++;
}
- else if (s[1]=='i') {
- nicon= atoi(s+2);
+ else if (s[1] == 'i') {
+ nicon = atoi(s + 2);
- *s= '\0';
+ *s = '\0';
s++;
}
}
- else if (c=='|' || c == '\n' || c=='\0') {
+ else if (c == '|' || c == '\n' || c == '\0') {
if (nitem) {
- *s= '\0';
+ *s = '\0';
if (nitem_is_title) {
menudata_set_title(md, nitem, nicon);
- nitem_is_title= 0;
+ nitem_is_title = 0;
}
else if (nitem_is_sepr) {
/* prevent separator to get a value */
menudata_add_item(md, nitem, -1, nicon, 1);
- nretval= md->nitems+1;
- nitem_is_sepr= 0;
+ nretval = md->nitems + 1;
+ nitem_is_sepr = 0;
}
else {
menudata_add_item(md, nitem, nretval, nicon, 0);
- nretval= md->nitems+1;
+ nretval = md->nitems + 1;
}
- nitem= NULL;
- nicon= 0;
+ nitem = NULL;
+ nicon = 0;
}
- if (c=='\0') {
+ if (c == '\0') {
break;
}
}
else if (!nitem) {
- nitem= s;
+ nitem = s;
}
s++;
@@ -237,9 +237,9 @@ void ui_set_name_menu(uiBut *but, int value)
MenuData *md;
int i;
- md= decompose_menu_string(but->str);
- for (i=0; i<md->nitems; i++) {
- if (md->items[i].retval==value) {
+ md = decompose_menu_string(but->str);
+ for (i = 0; i < md->nitems; i++) {
+ if (md->items[i].retval == value) {
BLI_strncpy(but->drawstr, md->items[i].str, sizeof(but->drawstr));
break;
}
@@ -251,29 +251,29 @@ void ui_set_name_menu(uiBut *but, int value)
int ui_step_name_menu(uiBut *but, int step)
{
MenuData *md;
- int value= ui_get_but_val(but);
+ int value = ui_get_but_val(but);
int i;
- md= decompose_menu_string(but->str);
- for (i=0; i<md->nitems; i++)
- if (md->items[i].retval==value)
+ md = decompose_menu_string(but->str);
+ for (i = 0; i < md->nitems; i++)
+ if (md->items[i].retval == value)
break;
- if (step==1) {
+ if (step == 1) {
/* skip separators */
- for (; i<md->nitems-1; i++) {
- if (md->items[i+1].retval != -1) {
- value= md->items[i+1].retval;
+ for (; i < md->nitems - 1; i++) {
+ if (md->items[i + 1].retval != -1) {
+ value = md->items[i + 1].retval;
break;
}
}
}
else {
- if (i>0) {
+ if (i > 0) {
/* skip separators */
- for (; i>0; i--) {
- if (md->items[i-1].retval != -1) {
- value= md->items[i-1].retval;
+ for (; i > 0; i--) {
+ if (md->items[i - 1].retval != -1) {
+ value = md->items[i - 1].retval;
break;
}
}
@@ -292,11 +292,11 @@ static ARegion *ui_add_temporary_region(bScreen *sc)
{
ARegion *ar;
- ar= MEM_callocN(sizeof(ARegion), "area region");
+ ar = MEM_callocN(sizeof(ARegion), "area region");
BLI_addtail(&sc->regionbase, ar);
- ar->regiontype= RGN_TYPE_TEMPORARY;
- ar->alignment= RGN_ALIGN_FLOAT;
+ ar->regiontype = RGN_TYPE_TEMPORARY;
+ ar->alignment = RGN_ALIGN_FLOAT;
return ar;
}
@@ -307,7 +307,7 @@ static void ui_remove_temporary_region(bContext *C, bScreen *sc, ARegion *ar)
wm_draw_region_clear(CTX_wm_window(C), ar);
ED_region_exit(C, ar);
- BKE_area_region_free(NULL, ar); /* NULL: no spacetype */
+ BKE_area_region_free(NULL, ar); /* NULL: no spacetype */
BLI_freelinkN(&sc->regionbase, ar);
}
@@ -350,9 +350,9 @@ static void rgb_tint(float col[3],
static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
{
- uiTooltipData *data= ar->regiondata;
- uiWidgetColors* theme = ui_tooltip_get_theme();
- rcti bbox= data->bbox;
+ uiTooltipData *data = ar->regiondata;
+ uiWidgetColors *theme = ui_tooltip_get_theme();
+ rcti bbox = data->bbox;
float tip_colors[UI_TIP_LC_MAX][3];
float *main_color = tip_colors[UI_TIP_LC_MAIN]; /* the color from the theme */
@@ -391,7 +391,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
/* draw text */
uiStyleFontSet(&data->fstyle);
- bbox.ymax = bbox.ymax - 0.5f*((bbox.ymax - bbox.ymin) - data->toth);
+ bbox.ymax = bbox.ymax - 0.5f * ((bbox.ymax - bbox.ymin) - data->toth);
bbox.ymin = bbox.ymax - data->lineh;
for (i = 0; i < data->totline; i++) {
@@ -406,20 +406,20 @@ static void ui_tooltip_region_free_cb(ARegion *ar)
{
uiTooltipData *data;
- data= ar->regiondata;
+ data = ar->regiondata;
MEM_freeN(data);
- ar->regiondata= NULL;
+ ar->regiondata = NULL;
}
ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
{
- uiStyle *style= UI_GetStyle();
+ uiStyle *style = UI_GetStyle();
static ARegionType type;
ARegion *ar;
uiTooltipData *data;
IDProperty *prop;
char buf[512];
- float fonth, fontw, aspect= but->block->aspect;
+ float fonth, fontw, aspect = but->block->aspect;
float x1f, x2f, y1f, y2f;
int x1, x2, y1, y2, winx, winy, ofsx, ofsy, w, h, a;
@@ -427,11 +427,11 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
return NULL;
/* create tooltip data */
- data= MEM_callocN(sizeof(uiTooltipData), "uiTooltipData");
+ data = MEM_callocN(sizeof(uiTooltipData), "uiTooltipData");
/* special case, enum rna buttons only have enum item description, use general enum description too before the specific one */
if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) {
- const char *descr= RNA_property_description(but->rnaprop);
+ const char *descr = RNA_property_description(but->rnaprop);
if (descr && descr[0]) {
BLI_strncpy(data->lines[data->totline], descr, sizeof(data->lines[0]));
data->color_id[data->totline] = UI_TIP_LC_MAIN;
@@ -441,11 +441,11 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
if (ELEM(but->type, ROW, MENU)) {
EnumPropertyItem *item;
int i, totitem, free;
- int value = (but->type == ROW)? but->hardmax: ui_get_but_val(but);
+ int value = (but->type == ROW) ? but->hardmax : ui_get_but_val(but);
RNA_property_enum_items_gettexted(C, &but->rnapoin, but->rnaprop, &item, &totitem, &free);
- for (i=0; i<totitem; i++) {
+ for (i = 0; i < totitem; i++) {
if (item[i].identifier[0] && item[i].value == value) {
if (item[i].description && item[i].description[0]) {
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "%s: %s", item[i].name, item[i].description);
@@ -470,10 +470,10 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
if (but->optype && !(but->block->flag & UI_BLOCK_LOOP)) {
/* operator keymap (not menus, they already have it) */
- prop= (but->opptr)? but->opptr->data: NULL;
+ prop = (but->opptr) ? but->opptr->data : NULL;
if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE,
- buf, sizeof(buf)))
+ buf, sizeof(buf)))
{
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Shortcut: %s"), buf);
data->color_id[data->totline] = UI_TIP_LC_NORMAL;
@@ -492,11 +492,11 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
}
if (but->rnaprop) {
- int unit_type= uiButGetUnitType(but);
+ int unit_type = uiButGetUnitType(but);
if (unit_type == PROP_UNIT_ROTATION) {
if (RNA_property_type(but->rnaprop) == PROP_FLOAT) {
- float value= RNA_property_array_check(but->rnaprop) ? RNA_property_float_get_index(&but->rnapoin, but->rnaprop, but->rnaindex) : RNA_property_float_get(&but->rnapoin, but->rnaprop);
+ float value = RNA_property_array_check(but->rnaprop) ? RNA_property_float_get_index(&but->rnapoin, but->rnaprop, but->rnaindex) : RNA_property_float_get(&but->rnapoin, but->rnaprop);
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Radians: %f"), value);
data->color_id[data->totline] = UI_TIP_LC_NORMAL;
data->totline++;
@@ -520,7 +520,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
}
if (but->rnapoin.id.data) {
- ID *id= but->rnapoin.id.data;
+ ID *id = but->rnapoin.id.data;
if (id->lib && id->lib->name) {
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Library: %s"), id->lib->name);
data->color_id[data->totline] = UI_TIP_LC_NORMAL;
@@ -531,9 +531,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
else if (but->optype) {
PointerRNA *opptr;
char *str;
- opptr= uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */
+ opptr = uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */
- str= WM_operator_pystring(C, but->optype, opptr, 0);
+ str = WM_operator_pystring(C, but->optype, opptr, 0);
/* operator info */
if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
@@ -549,7 +549,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
const char *poll_msg;
CTX_wm_operator_poll_msg_set(C, NULL);
WM_operator_poll_context(C, but->optype, but->opcontext);
- poll_msg= CTX_wm_operator_poll_msg_get(C);
+ poll_msg = CTX_wm_operator_poll_msg_get(C);
if (poll_msg) {
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Disabled: %s"), poll_msg);
data->color_id[data->totline] = UI_TIP_LC_ALERT; /* alert */
@@ -559,7 +559,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
}
else if (ELEM(but->type, MENU, PULLDOWN)) {
if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
- MenuType *mt= uiButGetMenuType(but);
+ MenuType *mt = uiButGetMenuType(but);
if (mt) {
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s"), mt->idname);
data->color_id[data->totline] = UI_TIP_LC_PYTHON;
@@ -577,16 +577,16 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
}
/* create area region */
- ar= ui_add_temporary_region(CTX_wm_screen(C));
+ ar = ui_add_temporary_region(CTX_wm_screen(C));
memset(&type, 0, sizeof(ARegionType));
- type.draw= ui_tooltip_region_draw_cb;
- type.free= ui_tooltip_region_free_cb;
- ar->type= &type;
+ type.draw = ui_tooltip_region_draw_cb;
+ type.free = ui_tooltip_region_free_cb;
+ ar->type = &type;
/* set font, get bb */
- data->fstyle= style->widget; /* copy struct */
- data->fstyle.align= UI_STYLE_TEXT_CENTER;
+ data->fstyle = style->widget; /* copy struct */
+ data->fstyle.align = UI_STYLE_TEXT_CENTER;
uiStyleFontSet(&data->fstyle);
/* these defines may need to be tweaked depending on font */
@@ -594,38 +594,38 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
#define TIP_BORDER_X 16.0f
#define TIP_BORDER_Y 6.0f
- h= BLF_height_max(data->fstyle.uifont_id);
+ h = BLF_height_max(data->fstyle.uifont_id);
- for (a=0, fontw=0, fonth=0; a<data->totline; a++) {
- w= BLF_width(data->fstyle.uifont_id, data->lines[a]);
- fontw= MAX2(fontw, w);
- fonth += (a == 0)? h: h+TIP_MARGIN_Y;
+ for (a = 0, fontw = 0, fonth = 0; a < data->totline; a++) {
+ w = BLF_width(data->fstyle.uifont_id, data->lines[a]);
+ fontw = MAX2(fontw, w);
+ fonth += (a == 0) ? h : h + TIP_MARGIN_Y;
}
fontw *= aspect;
- ar->regiondata= data;
+ ar->regiondata = data;
- data->toth= fonth;
- data->lineh= h;
- data->spaceh= TIP_MARGIN_Y;
+ data->toth = fonth;
+ data->lineh = h;
+ data->spaceh = TIP_MARGIN_Y;
/* compute position */
- ofsx= (but->block->panel)? but->block->panel->ofsx: 0;
- ofsy= (but->block->panel)? but->block->panel->ofsy: 0;
+ ofsx = (but->block->panel) ? but->block->panel->ofsx : 0;
+ ofsy = (but->block->panel) ? but->block->panel->ofsy : 0;
- x1f= (but->x1 + but->x2) * 0.5f + ofsx - (TIP_BORDER_X * aspect);
- x2f= x1f + fontw + (TIP_BORDER_X * aspect);
- y2f= but->y1 + ofsy - (TIP_BORDER_Y * aspect);
- y1f= y2f - fonth*aspect - (TIP_BORDER_Y * aspect);
+ x1f = (but->x1 + but->x2) * 0.5f + ofsx - (TIP_BORDER_X * aspect);
+ x2f = x1f + fontw + (TIP_BORDER_X * aspect);
+ y2f = but->y1 + ofsy - (TIP_BORDER_Y * aspect);
+ y1f = y2f - fonth * aspect - (TIP_BORDER_Y * aspect);
#undef TIP_MARGIN_Y
#undef TIP_BORDER_X
#undef TIP_BORDER_Y
/* copy to int, gets projected if possible too */
- x1= x1f; y1= y1f; x2= x2f; y2= y2f;
+ x1 = x1f; y1 = y1f; x2 = x2f; y2 = y2f;
if (butregion) {
/* XXX temp, region v2ds can be empty still */
@@ -645,12 +645,12 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
if (x2 > winx) {
/* super size */
if (x2 > winx + x1) {
- x2= winx;
- x1= 0;
+ x2 = winx;
+ x1 = 0;
}
else {
- x1 -= x2-winx;
- x2= winx;
+ x1 -= x2 - winx;
+ x2 = winx;
}
}
/* ensure at least 5 px above screen bounds
@@ -662,9 +662,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
/* widget rect, in region coords */
data->bbox.xmin = MENU_SHADOW_SIDE;
- data->bbox.xmax = x2-x1 + MENU_SHADOW_SIDE;
+ data->bbox.xmax = x2 - x1 + MENU_SHADOW_SIDE;
data->bbox.ymin = MENU_SHADOW_BOTTOM;
- data->bbox.ymax = y2-y1 + MENU_SHADOW_BOTTOM;
+ data->bbox.ymax = y2 - y1 + MENU_SHADOW_BOTTOM;
/* region bigger for shadow */
ar->winrct.xmin = x1 - MENU_SHADOW_SIDE;
@@ -707,13 +707,13 @@ typedef struct uiSearchboxData {
rcti bbox;
uiFontStyle fstyle;
uiSearchItems items;
- int active; /* index in items array */
- int noback; /* when menu opened with enough space for this */
- int preview; /* draw thumbnail previews, rather than list */
+ int active; /* index in items array */
+ int noback; /* when menu opened with enough space for this */
+ int preview; /* draw thumbnail previews, rather than list */
int prv_rows, prv_cols;
} uiSearchboxData;
-#define SEARCH_ITEMS 10
+#define SEARCH_ITEMS 10
/* exported for use by search callbacks */
/* returns zero if nothing to add */
@@ -727,14 +727,14 @@ int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int icon
/* hijack for finding active item */
if (items->active) {
- if (poin==items->active)
- items->offset_i= items->totitem;
+ if (poin == items->active)
+ items->offset_i = items->totitem;
items->totitem++;
return 1;
}
- if (items->totitem>=items->maxitem) {
- items->more= 1;
+ if (items->totitem >= items->maxitem) {
+ items->more = 1;
return 0;
}
@@ -747,9 +747,9 @@ int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int icon
if (items->names)
BLI_strncpy(items->names[items->totitem], name, items->maxstrlen);
if (items->pointers)
- items->pointers[items->totitem]= poin;
+ items->pointers[items->totitem] = poin;
if (items->icons)
- items->icons[items->totitem]= iconid;
+ items->icons[items->totitem] = iconid;
items->totitem++;
@@ -758,36 +758,36 @@ int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int icon
int uiSearchBoxhHeight(void)
{
- return SEARCH_ITEMS*UI_UNIT_Y + 2*MENU_TOP;
+ return SEARCH_ITEMS * UI_UNIT_Y + 2 * MENU_TOP;
}
/* ar is the search box itself */
static void ui_searchbox_select(bContext *C, ARegion *ar, uiBut *but, int step)
{
- uiSearchboxData *data= ar->regiondata;
+ uiSearchboxData *data = ar->regiondata;
/* apply step */
- data->active+= step;
+ data->active += step;
- if (data->items.totitem==0)
- data->active= 0;
+ if (data->items.totitem == 0)
+ data->active = 0;
else if (data->active > data->items.totitem) {
if (data->items.more) {
data->items.offset++;
- data->active= data->items.totitem;
+ data->active = data->items.totitem;
ui_searchbox_update(C, ar, but, 0);
}
else
- data->active= data->items.totitem;
+ data->active = data->items.totitem;
}
else if (data->active < 1) {
if (data->items.offset) {
data->items.offset--;
- data->active= 1;
+ data->active = 1;
ui_searchbox_update(C, ar, but, 0);
}
else if (data->active < 0)
- data->active= 0;
+ data->active = 0;
}
ED_region_tag_redraw(ar);
@@ -797,11 +797,11 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr)
{
/* thumbnail preview */
if (data->preview) {
- int buth = (data->bbox.ymax - data->bbox.ymin - 2*MENU_TOP) / data->prv_rows;
+ int buth = (data->bbox.ymax - data->bbox.ymin - 2 * MENU_TOP) / data->prv_rows;
int butw = (data->bbox.xmax - data->bbox.xmin) / data->prv_cols;
int row, col;
- *rect= data->bbox;
+ *rect = data->bbox;
col = itemnr % data->prv_cols;
row = itemnr / data->prv_cols;
@@ -814,13 +814,13 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr)
}
/* list view */
else {
- int buth= (data->bbox.ymax-data->bbox.ymin - 2*MENU_TOP)/SEARCH_ITEMS;
+ int buth = (data->bbox.ymax - data->bbox.ymin - 2 * MENU_TOP) / SEARCH_ITEMS;
- *rect= data->bbox;
+ *rect = data->bbox;
rect->xmin = data->bbox.xmin + 3.0f;
rect->xmax = data->bbox.xmax - 3.0f;
- rect->ymax = data->bbox.ymax - MENU_TOP - itemnr*buth;
+ rect->ymax = data->bbox.ymax - MENU_TOP - itemnr * buth;
rect->ymin = rect->ymax - buth;
}
@@ -829,35 +829,35 @@ static void ui_searchbox_butrect(rcti *rect, uiSearchboxData *data, int itemnr)
/* x and y in screencoords */
int ui_searchbox_inside(ARegion *ar, int x, int y)
{
- uiSearchboxData *data= ar->regiondata;
+ uiSearchboxData *data = ar->regiondata;
- return(BLI_in_rcti(&data->bbox, x-ar->winrct.xmin, y-ar->winrct.ymin));
+ return(BLI_in_rcti(&data->bbox, x - ar->winrct.xmin, y - ar->winrct.ymin));
}
/* string validated to be of correct length (but->hardmax) */
void ui_searchbox_apply(uiBut *but, ARegion *ar)
{
- uiSearchboxData *data= ar->regiondata;
+ uiSearchboxData *data = ar->regiondata;
- but->func_arg2= NULL;
+ but->func_arg2 = NULL;
if (data->active) {
- char *name= data->items.names[data->active-1];
- char *cpoin= strchr(name, '|');
+ char *name = data->items.names[data->active - 1];
+ char *cpoin = strchr(name, '|');
- if (cpoin) cpoin[0]= 0;
+ if (cpoin) cpoin[0] = 0;
BLI_strncpy(but->editstr, name, data->items.maxstrlen);
- if (cpoin) cpoin[0]= '|';
+ if (cpoin) cpoin[0] = '|';
- but->func_arg2= data->items.pointers[data->active-1];
+ but->func_arg2 = data->items.pointers[data->active - 1];
}
}
void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, wmEvent *event)
{
- uiSearchboxData *data= ar->regiondata;
+ uiSearchboxData *data = ar->regiondata;
- switch(event->type) {
+ switch (event->type) {
case WHEELUPMOUSE:
case UPARROWKEY:
ui_searchbox_select(C, ar, but, -1);
@@ -871,11 +871,11 @@ void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, wmEvent *event)
rcti rect;
int a;
- for (a=0; a<data->items.totitem; a++) {
+ for (a = 0; a < data->items.totitem; a++) {
ui_searchbox_butrect(&rect, data, a);
if (BLI_in_rcti(&rect, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) {
- if ( data->active!= a+1) {
- data->active= a+1;
+ if (data->active != a + 1) {
+ data->active = a + 1;
ui_searchbox_select(C, ar, but, 0);
break;
}
@@ -889,46 +889,46 @@ void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, wmEvent *event)
/* ar is the search box itself */
void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, int reset)
{
- uiSearchboxData *data= ar->regiondata;
+ uiSearchboxData *data = ar->regiondata;
/* reset vars */
- data->items.totitem= 0;
- data->items.more= 0;
- if (reset==0) {
- data->items.offset_i= data->items.offset;
+ data->items.totitem = 0;
+ data->items.more = 0;
+ if (reset == 0) {
+ data->items.offset_i = data->items.offset;
}
else {
- data->items.offset_i= data->items.offset= 0;
- data->active= 0;
+ data->items.offset_i = data->items.offset = 0;
+ data->active = 0;
/* handle active */
if (but->search_func && but->func_arg2) {
- data->items.active= but->func_arg2;
+ data->items.active = but->func_arg2;
but->search_func(C, but->search_arg, but->editstr, &data->items);
- data->items.active= NULL;
+ data->items.active = NULL;
/* found active item, calculate real offset by centering it */
if (data->items.totitem) {
/* first case, begin of list */
if (data->items.offset_i < data->items.maxitem) {
- data->active= data->items.offset_i+1;
- data->items.offset_i= 0;
+ data->active = data->items.offset_i + 1;
+ data->items.offset_i = 0;
}
else {
/* second case, end of list */
if (data->items.totitem - data->items.offset_i <= data->items.maxitem) {
- data->active= 1 + data->items.offset_i - data->items.totitem + data->items.maxitem;
- data->items.offset_i= data->items.totitem - data->items.maxitem;
+ data->active = 1 + data->items.offset_i - data->items.totitem + data->items.maxitem;
+ data->items.offset_i = data->items.totitem - data->items.maxitem;
}
else {
/* center active item */
- data->items.offset_i -= data->items.maxitem/2;
- data->active= 1 + data->items.maxitem/2;
+ data->items.offset_i -= data->items.maxitem / 2;
+ data->active = 1 + data->items.maxitem / 2;
}
}
}
- data->items.offset= data->items.offset_i;
- data->items.totitem= 0;
+ data->items.offset = data->items.offset_i;
+ data->items.totitem = 0;
}
}
@@ -937,19 +937,19 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, int reset)
but->search_func(C, but->search_arg, but->editstr, &data->items);
/* handle case where editstr is equal to one of items */
- if (reset && data->active==0) {
+ if (reset && data->active == 0) {
int a;
- for (a=0; a<data->items.totitem; a++) {
- char *cpoin= strchr(data->items.names[a], '|');
+ for (a = 0; a < data->items.totitem; a++) {
+ char *cpoin = strchr(data->items.names[a], '|');
- if (cpoin) cpoin[0]= 0;
- if (0==strcmp(but->editstr, data->items.names[a]))
- data->active= a+1;
- if (cpoin) cpoin[0]= '|';
+ if (cpoin) cpoin[0] = 0;
+ if (0 == strcmp(but->editstr, data->items.names[a]))
+ data->active = a + 1;
+ if (cpoin) cpoin[0] = '|';
}
- if (data->items.totitem==1 && but->editstr[0])
- data->active= 1;
+ if (data->items.totitem == 1 && but->editstr[0])
+ data->active = 1;
}
/* validate selected item */
@@ -960,27 +960,27 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, int reset)
void ui_searchbox_autocomplete(bContext *C, ARegion *ar, uiBut *but, char *str)
{
- uiSearchboxData *data= ar->regiondata;
+ uiSearchboxData *data = ar->regiondata;
if (str[0]) {
- data->items.autocpl= autocomplete_begin(str, ui_get_but_string_max_length(but));
+ data->items.autocpl = autocomplete_begin(str, ui_get_but_string_max_length(but));
but->search_func(C, but->search_arg, but->editstr, &data->items);
autocomplete_end(data->items.autocpl, str);
- data->items.autocpl= NULL;
+ data->items.autocpl = NULL;
}
}
static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
{
- uiSearchboxData *data= ar->regiondata;
+ uiSearchboxData *data = ar->regiondata;
/* pixel space */
- wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f);
+ wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f);
if (!data->noback)
- ui_draw_search_back(NULL, NULL, &data->bbox); /* style not used yet */
+ ui_draw_search_back(NULL, NULL, &data->bbox); /* style not used yet */
/* draw text */
if (data->items.totitem) {
@@ -989,51 +989,51 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
if (data->preview) {
/* draw items */
- for (a=0; a<data->items.totitem; a++) {
+ for (a = 0; a < data->items.totitem; a++) {
ui_searchbox_butrect(&rect, data, a);
/* widget itself */
if (data->preview)
- ui_draw_preview_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a], (a+1)==data->active?UI_ACTIVE:0);
+ ui_draw_preview_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a], (a + 1) == data->active ? UI_ACTIVE : 0);
else
- ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a], (a+1)==data->active?UI_ACTIVE:0);
+ ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a], (a + 1) == data->active ? UI_ACTIVE : 0);
}
/* indicate more */
if (data->items.more) {
- ui_searchbox_butrect(&rect, data, data->items.maxitem-1);
+ ui_searchbox_butrect(&rect, data, data->items.maxitem - 1);
glEnable(GL_BLEND);
- UI_icon_draw(rect.xmax-18, rect.ymin-7, ICON_TRIA_DOWN);
+ UI_icon_draw(rect.xmax - 18, rect.ymin - 7, ICON_TRIA_DOWN);
glDisable(GL_BLEND);
}
if (data->items.offset) {
ui_searchbox_butrect(&rect, data, 0);
glEnable(GL_BLEND);
- UI_icon_draw(rect.xmin, rect.ymax-9, ICON_TRIA_UP);
+ UI_icon_draw(rect.xmin, rect.ymax - 9, ICON_TRIA_UP);
glDisable(GL_BLEND);
}
}
else {
/* draw items */
- for (a=0; a<data->items.totitem; a++) {
+ for (a = 0; a < data->items.totitem; a++) {
ui_searchbox_butrect(&rect, data, a);
/* widget itself */
- ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a], (a+1)==data->active?UI_ACTIVE:0);
+ ui_draw_menu_item(&data->fstyle, &rect, data->items.names[a], data->items.icons[a], (a + 1) == data->active ? UI_ACTIVE : 0);
}
/* indicate more */
if (data->items.more) {
- ui_searchbox_butrect(&rect, data, data->items.maxitem-1);
+ ui_searchbox_butrect(&rect, data, data->items.maxitem - 1);
glEnable(GL_BLEND);
- UI_icon_draw((rect.xmax-rect.xmin)/2, rect.ymin-9, ICON_TRIA_DOWN);
+ UI_icon_draw((rect.xmax - rect.xmin) / 2, rect.ymin - 9, ICON_TRIA_DOWN);
glDisable(GL_BLEND);
}
if (data->items.offset) {
ui_searchbox_butrect(&rect, data, 0);
glEnable(GL_BLEND);
- UI_icon_draw((rect.xmax-rect.xmin)/2, rect.ymax-7, ICON_TRIA_UP);
+ UI_icon_draw((rect.xmax - rect.xmin) / 2, rect.ymax - 7, ICON_TRIA_UP);
glDisable(GL_BLEND);
}
}
@@ -1042,7 +1042,7 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
static void ui_searchbox_region_free_cb(ARegion *ar)
{
- uiSearchboxData *data= ar->regiondata;
+ uiSearchboxData *data = ar->regiondata;
int a;
/* free search data */
@@ -1054,42 +1054,42 @@ static void ui_searchbox_region_free_cb(ARegion *ar)
MEM_freeN(data->items.icons);
MEM_freeN(data);
- ar->regiondata= NULL;
+ ar->regiondata = NULL;
}
ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
{
- uiStyle *style= UI_GetStyle();
+ uiStyle *style = UI_GetStyle();
static ARegionType type;
ARegion *ar;
uiSearchboxData *data;
- float aspect= but->block->aspect;
+ float aspect = but->block->aspect;
float x1f, x2f, y1f, y2f;
int x1, x2, y1, y2, winx, winy, ofsx, ofsy;
/* create area region */
- ar= ui_add_temporary_region(CTX_wm_screen(C));
+ ar = ui_add_temporary_region(CTX_wm_screen(C));
memset(&type, 0, sizeof(ARegionType));
- type.draw= ui_searchbox_region_draw_cb;
- type.free= ui_searchbox_region_free_cb;
- ar->type= &type;
+ type.draw = ui_searchbox_region_draw_cb;
+ type.free = ui_searchbox_region_free_cb;
+ ar->type = &type;
/* create searchbox data */
- data= MEM_callocN(sizeof(uiSearchboxData), "uiSearchboxData");
+ data = MEM_callocN(sizeof(uiSearchboxData), "uiSearchboxData");
/* set font, get bb */
- data->fstyle= style->widget; /* copy struct */
- data->fstyle.align= UI_STYLE_TEXT_CENTER;
+ data->fstyle = style->widget; /* copy struct */
+ data->fstyle.align = UI_STYLE_TEXT_CENTER;
ui_fontscale(&data->fstyle.points, aspect);
uiStyleFontSet(&data->fstyle);
- ar->regiondata= data;
+ ar->regiondata = data;
/* special case, hardcoded feature, not draw backdrop when called from menus,
* assume for design that popup already added it */
if (but->block->flag & UI_BLOCK_LOOP)
- data->noback= 1;
+ data->noback = 1;
if (but->a1 > 0 && but->a2 > 0) {
data->preview = 1;
@@ -1102,30 +1102,30 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
/* this case is search menu inside other menu */
/* we copy region size */
- ar->winrct= butregion->winrct;
+ ar->winrct = butregion->winrct;
/* widget rect, in region coords */
data->bbox.xmin = MENU_SHADOW_SIDE;
- data->bbox.xmax = (ar->winrct.xmax-ar->winrct.xmin) - MENU_SHADOW_SIDE;
+ data->bbox.xmax = (ar->winrct.xmax - ar->winrct.xmin) - MENU_SHADOW_SIDE;
data->bbox.ymin = MENU_SHADOW_BOTTOM;
- data->bbox.ymax = (ar->winrct.ymax-ar->winrct.ymin) - MENU_SHADOW_BOTTOM;
+ data->bbox.ymax = (ar->winrct.ymax - ar->winrct.ymin) - MENU_SHADOW_BOTTOM;
/* check if button is lower half */
- if ( but->y2 < (but->block->miny+but->block->maxy)/2 ) {
- data->bbox.ymin += (but->y2-but->y1);
+ if (but->y2 < (but->block->miny + but->block->maxy) / 2) {
+ data->bbox.ymin += (but->y2 - but->y1);
}
else {
- data->bbox.ymax -= (but->y2-but->y1);
+ data->bbox.ymax -= (but->y2 - but->y1);
}
}
else {
- x1f= but->x1 - 5; /* align text with button */
- x2f= but->x2 + 5; /* symmetrical */
- y2f= but->y1;
- y1f= y2f - uiSearchBoxhHeight();
+ x1f = but->x1 - 5; /* align text with button */
+ x2f = but->x2 + 5; /* symmetrical */
+ y2f = but->y1;
+ y1f = y2f - uiSearchBoxhHeight();
- ofsx= (but->block->panel)? but->block->panel->ofsx: 0;
- ofsy= (but->block->panel)? but->block->panel->ofsy: 0;
+ ofsx = (but->block->panel) ? but->block->panel->ofsx : 0;
+ ofsy = (but->block->panel) ? but->block->panel->ofsy : 0;
x1f += ofsx;
x2f += ofsx;
@@ -1133,10 +1133,10 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
y2f += ofsy;
/* minimal width */
- if (x2f - x1f < 150) x2f= x1f+150; // XXX arbitrary
+ if (x2f - x1f < 150) x2f = x1f + 150; // XXX arbitrary
/* copy to int, gets projected if possible too */
- x1= x1f; y1= y1f; x2= x2f; y2= y2f;
+ x1 = x1f; y1 = y1f; x2 = x2f; y2 = y2f;
if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) {
UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1);
@@ -1153,12 +1153,12 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
if (x2 > winx) {
/* super size */
if (x2 > winx + x1) {
- x2= winx;
- x1= 0;
+ x2 = winx;
+ x1 = 0;
}
else {
- x1 -= x2-winx;
- x2= winx;
+ x1 -= x2 - winx;
+ x2 = winx;
}
}
@@ -1167,15 +1167,15 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->y2 + ofsy, NULL, &newy1);
newy1 += butregion->winrct.ymin;
- y2= y2-y1 + newy1;
- y1= newy1;
+ y2 = y2 - y1 + newy1;
+ y1 = newy1;
}
/* widget rect, in region coords */
data->bbox.xmin = MENU_SHADOW_SIDE;
- data->bbox.xmax = x2-x1 + MENU_SHADOW_SIDE;
+ data->bbox.xmax = x2 - x1 + MENU_SHADOW_SIDE;
data->bbox.ymin = MENU_SHADOW_BOTTOM;
- data->bbox.ymax = y2-y1 + MENU_SHADOW_BOTTOM;
+ data->bbox.ymax = y2 - y1 + MENU_SHADOW_BOTTOM;
/* region bigger for shadow */
ar->winrct.xmin = x1 - MENU_SHADOW_SIDE;
@@ -1192,18 +1192,18 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but)
/* prepare search data */
if (data->preview) {
- data->items.maxitem= data->prv_rows * data->prv_cols;
+ data->items.maxitem = data->prv_rows * data->prv_cols;
}
else {
- data->items.maxitem= SEARCH_ITEMS;
+ data->items.maxitem = SEARCH_ITEMS;
}
- data->items.maxstrlen= but->hardmax;
- data->items.totitem= 0;
- data->items.names= MEM_callocN(data->items.maxitem*sizeof(void *), "search names");
- data->items.pointers= MEM_callocN(data->items.maxitem*sizeof(void *), "search pointers");
- data->items.icons= MEM_callocN(data->items.maxitem*sizeof(int), "search icons");
- for (x1=0; x1<data->items.maxitem; x1++)
- data->items.names[x1]= MEM_callocN(but->hardmax+1, "search pointers");
+ data->items.maxstrlen = but->hardmax;
+ data->items.totitem = 0;
+ data->items.names = MEM_callocN(data->items.maxitem * sizeof(void *), "search names");
+ data->items.pointers = MEM_callocN(data->items.maxitem * sizeof(void *), "search pointers");
+ data->items.icons = MEM_callocN(data->items.maxitem * sizeof(int), "search icons");
+ for (x1 = 0; x1 < data->items.maxitem; x1++)
+ data->items.names[x1] = MEM_callocN(but->hardmax + 1, "search pointers");
return ar;
}
@@ -1226,25 +1226,25 @@ void ui_but_search_test(uiBut *but)
return;
}
- items= MEM_callocN(sizeof(uiSearchItems), "search items");
+ items = MEM_callocN(sizeof(uiSearchItems), "search items");
/* setup search struct */
- items->maxitem= 10;
- items->maxstrlen= 256;
- items->names= MEM_callocN(items->maxitem*sizeof(void *), "search names");
- for (x1=0; x1<items->maxitem; x1++)
- items->names[x1]= MEM_callocN(but->hardmax+1, "search names");
+ items->maxitem = 10;
+ items->maxstrlen = 256;
+ items->names = MEM_callocN(items->maxitem * sizeof(void *), "search names");
+ for (x1 = 0; x1 < items->maxitem; x1++)
+ items->names[x1] = MEM_callocN(but->hardmax + 1, "search names");
but->search_func(but->block->evil_C, but->search_arg, but->drawstr, items);
/* only redalert when we are sure of it, this can miss cases when >10 matches */
- if (items->totitem==0)
+ if (items->totitem == 0)
uiButSetFlag(but, UI_BUT_REDALERT);
- else if (items->more==0) {
- for (x1= 0; x1<items->totitem; x1++)
- if (strcmp(but->drawstr, items->names[x1])==0)
+ else if (items->more == 0) {
+ for (x1 = 0; x1 < items->totitem; x1++)
+ if (strcmp(but->drawstr, items->names[x1]) == 0)
break;
- if (x1==items->totitem)
+ if (x1 == items->totitem)
uiButSetFlag(but, UI_BUT_REDALERT);
}
@@ -1265,8 +1265,8 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
uiSafetyRct *saferct;
rctf butrct;
/*float aspect;*/ /*UNUSED*/
- int xsize, ysize, xof=0, yof=0, center;
- short dir1= 0, dir2=0;
+ int xsize, ysize, xof = 0, yof = 0, center;
+ short dir1 = 0, dir2 = 0;
/* transform to window coordinates, using the source button region/block */
butrct.xmin = but->x1; butrct.xmax = but->x2;
@@ -1278,24 +1278,24 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
/* calc block rect */
if (block->minx == 0.0f && block->maxx == 0.0f) {
if (block->buttons.first) {
- block->minx= block->miny= 10000;
- block->maxx= block->maxy= -10000;
+ block->minx = block->miny = 10000;
+ block->maxx = block->maxy = -10000;
- bt= block->buttons.first;
+ bt = block->buttons.first;
while (bt) {
- if (bt->x1 < block->minx) block->minx= bt->x1;
- if (bt->y1 < block->miny) block->miny= bt->y1;
+ if (bt->x1 < block->minx) block->minx = bt->x1;
+ if (bt->y1 < block->miny) block->miny = bt->y1;
- if (bt->x2 > block->maxx) block->maxx= bt->x2;
- if (bt->y2 > block->maxy) block->maxy= bt->y2;
+ if (bt->x2 > block->maxx) block->maxx = bt->x2;
+ if (bt->y2 > block->maxy) block->maxy = bt->y2;
- bt= bt->next;
+ bt = bt->next;
}
}
else {
/* we're nice and allow empty blocks too */
- block->minx= block->miny= 0;
- block->maxx= block->maxy= 20;
+ block->minx = block->miny = 0;
+ block->maxx = block->maxy = 20;
}
}
@@ -1306,124 +1306,124 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
//block->minx-= 2.0; block->miny-= 2.0;
//block->maxx+= 2.0; block->maxy+= 2.0;
- xsize= block->maxx - block->minx+4; // 4 for shadow
- ysize= block->maxy - block->miny+4;
+ xsize = block->maxx - block->minx + 4; // 4 for shadow
+ ysize = block->maxy - block->miny + 4;
/*aspect/= (float)xsize;*/ /*UNUSED*/
{
- int left=0, right=0, top=0, down=0;
+ int left = 0, right = 0, top = 0, down = 0;
int winx, winy;
// int offscreen;
wm_window_get_size(window, &winx, &winy);
- if (block->direction & UI_CENTER) center= ysize/2;
- else center= 0;
+ if (block->direction & UI_CENTER) center = ysize / 2;
+ else center = 0;
/* check if there's space at all */
- if ( butrct.xmin-xsize > 0.0f) left= 1;
- if ( butrct.xmax+xsize < winx) right= 1;
- if ( butrct.ymin-ysize+center > 0.0f) down= 1;
- if ( butrct.ymax+ysize-center < winy) top= 1;
-
- if (top==0 && down==0) {
- if (butrct.ymin-ysize < winy-butrct.ymax-ysize)
- top= 1;
+ if (butrct.xmin - xsize > 0.0f) left = 1;
+ if (butrct.xmax + xsize < winx) right = 1;
+ if (butrct.ymin - ysize + center > 0.0f) down = 1;
+ if (butrct.ymax + ysize - center < winy) top = 1;
+
+ if (top == 0 && down == 0) {
+ if (butrct.ymin - ysize < winy - butrct.ymax - ysize)
+ top = 1;
else
- down= 1;
+ down = 1;
}
- dir1= block->direction & UI_DIRECTION;
+ dir1 = block->direction & UI_DIRECTION;
/* secundary directions */
- if (dir1 & (UI_TOP|UI_DOWN)) {
- if (dir1 & UI_LEFT) dir2= UI_LEFT;
- else if (dir1 & UI_RIGHT) dir2= UI_RIGHT;
- dir1 &= (UI_TOP|UI_DOWN);
+ if (dir1 & (UI_TOP | UI_DOWN)) {
+ if (dir1 & UI_LEFT) dir2 = UI_LEFT;
+ else if (dir1 & UI_RIGHT) dir2 = UI_RIGHT;
+ dir1 &= (UI_TOP | UI_DOWN);
}
- if (dir2==0) if (dir1==UI_LEFT || dir1==UI_RIGHT) dir2= UI_DOWN;
- if (dir2==0) if (dir1==UI_TOP || dir1==UI_DOWN) dir2= UI_LEFT;
+ if (dir2 == 0) if (dir1 == UI_LEFT || dir1 == UI_RIGHT) dir2 = UI_DOWN;
+ if (dir2 == 0) if (dir1 == UI_TOP || dir1 == UI_DOWN) dir2 = UI_LEFT;
/* no space at all? don't change */
if (left || right) {
- if (dir1==UI_LEFT && left==0) dir1= UI_RIGHT;
- if (dir1==UI_RIGHT && right==0) dir1= UI_LEFT;
+ if (dir1 == UI_LEFT && left == 0) dir1 = UI_RIGHT;
+ if (dir1 == UI_RIGHT && right == 0) dir1 = UI_LEFT;
/* this is aligning, not append! */
- if (dir2==UI_LEFT && right==0) dir2= UI_RIGHT;
- if (dir2==UI_RIGHT && left==0) dir2= UI_LEFT;
+ if (dir2 == UI_LEFT && right == 0) dir2 = UI_RIGHT;
+ if (dir2 == UI_RIGHT && left == 0) dir2 = UI_LEFT;
}
if (down || top) {
- if (dir1==UI_TOP && top==0) dir1= UI_DOWN;
- if (dir1==UI_DOWN && down==0) dir1= UI_TOP;
- if (dir2==UI_TOP && top==0) dir2= UI_DOWN;
- if (dir2==UI_DOWN && down==0) dir2= UI_TOP;
- }
-
- if (dir1==UI_LEFT) {
- xof= butrct.xmin - block->maxx;
- if (dir2==UI_TOP) yof= butrct.ymin - block->miny-center;
- else yof= butrct.ymax - block->maxy+center;
- }
- else if (dir1==UI_RIGHT) {
- xof= butrct.xmax - block->minx;
- if (dir2==UI_TOP) yof= butrct.ymin - block->miny-center;
- else yof= butrct.ymax - block->maxy+center;
- }
- else if (dir1==UI_TOP) {
- yof= butrct.ymax - block->miny;
- if (dir2==UI_RIGHT) xof= butrct.xmax - block->maxx;
- else xof= butrct.xmin - block->minx;
+ if (dir1 == UI_TOP && top == 0) dir1 = UI_DOWN;
+ if (dir1 == UI_DOWN && down == 0) dir1 = UI_TOP;
+ if (dir2 == UI_TOP && top == 0) dir2 = UI_DOWN;
+ if (dir2 == UI_DOWN && down == 0) dir2 = UI_TOP;
+ }
+
+ if (dir1 == UI_LEFT) {
+ xof = butrct.xmin - block->maxx;
+ if (dir2 == UI_TOP) yof = butrct.ymin - block->miny - center;
+ else yof = butrct.ymax - block->maxy + center;
+ }
+ else if (dir1 == UI_RIGHT) {
+ xof = butrct.xmax - block->minx;
+ if (dir2 == UI_TOP) yof = butrct.ymin - block->miny - center;
+ else yof = butrct.ymax - block->maxy + center;
+ }
+ else if (dir1 == UI_TOP) {
+ yof = butrct.ymax - block->miny;
+ if (dir2 == UI_RIGHT) xof = butrct.xmax - block->maxx;
+ else xof = butrct.xmin - block->minx;
// changed direction?
- if ((dir1 & block->direction)==0) {
+ if ((dir1 & block->direction) == 0) {
if (block->direction & UI_SHIFT_FLIPPED)
- xof+= dir2==UI_LEFT?25:-25;
+ xof += dir2 == UI_LEFT ? 25 : -25;
uiBlockFlipOrder(block);
}
}
- else if (dir1==UI_DOWN) {
- yof= butrct.ymin - block->maxy;
- if (dir2==UI_RIGHT) xof= butrct.xmax - block->maxx;
- else xof= butrct.xmin - block->minx;
+ else if (dir1 == UI_DOWN) {
+ yof = butrct.ymin - block->maxy;
+ if (dir2 == UI_RIGHT) xof = butrct.xmax - block->maxx;
+ else xof = butrct.xmin - block->minx;
// changed direction?
- if ((dir1 & block->direction)==0) {
+ if ((dir1 & block->direction) == 0) {
if (block->direction & UI_SHIFT_FLIPPED)
- xof+= dir2==UI_LEFT?25:-25;
+ xof += dir2 == UI_LEFT ? 25 : -25;
uiBlockFlipOrder(block);
}
}
/* and now we handle the exception; no space below or to top */
- if (top==0 && down==0) {
- if (dir1==UI_LEFT || dir1==UI_RIGHT) {
+ if (top == 0 && down == 0) {
+ if (dir1 == UI_LEFT || dir1 == UI_RIGHT) {
// align with bottom of screen
// yof= ysize; (not with menu scrolls)
}
}
/* or no space left or right */
- if (left==0 && right==0) {
- if (dir1==UI_TOP || dir1==UI_DOWN) {
+ if (left == 0 && right == 0) {
+ if (dir1 == UI_TOP || dir1 == UI_DOWN) {
// align with left size of screen
- xof= -block->minx+5;
+ xof = -block->minx + 5;
}
}
// apply requested offset in the block
- xof += block->xofs/block->aspect;
- yof += block->yofs/block->aspect;
+ xof += block->xofs / block->aspect;
+ yof += block->yofs / block->aspect;
#if 0
/* clamp to window bounds, could be made into an option if its ever annoying */
- if ( (offscreen= (block->miny+yof)) < 0) yof -= offscreen; /* bottom */
- else if ((offscreen= (block->maxy+yof)-winy) > 0) yof -= offscreen; /* top */
- if ( (offscreen= (block->minx+xof)) < 0) xof -= offscreen; /* left */
- else if ((offscreen= (block->maxx+xof)-winx) > 0) xof -= offscreen; /* right */
+ if ( (offscreen = (block->miny + yof)) < 0) yof -= offscreen; /* bottom */
+ else if ((offscreen = (block->maxy + yof) - winy) > 0) yof -= offscreen; /* top */
+ if ( (offscreen = (block->minx + xof)) < 0) xof -= offscreen; /* left */
+ else if ((offscreen = (block->maxx + xof) - winx) > 0) xof -= offscreen; /* right */
#endif
}
/* apply offset, buttons in window coords */
- for (bt= block->buttons.first; bt; bt= bt->next) {
+ for (bt = block->buttons.first; bt; bt = bt->next) {
ui_block_to_window_fl(butregion, but->block, &bt->x1, &bt->y1);
ui_block_to_window_fl(butregion, but->block, &bt->x2, &bt->y2);
@@ -1432,7 +1432,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
bt->y1 += yof;
bt->y2 += yof;
- bt->aspect= 1.0;
+ bt->aspect = 1.0;
// ui_check_but recalculates drawstring size in pixels
ui_check_but(bt);
}
@@ -1444,43 +1444,43 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but,
/* safety calculus */
if (but) {
- float midx= (butrct.xmin+butrct.xmax)/2.0f;
- float midy= (butrct.ymin+butrct.ymax)/2.0f;
+ float midx = (butrct.xmin + butrct.xmax) / 2.0f;
+ float midy = (butrct.ymin + butrct.ymax) / 2.0f;
/* when you are outside parent button, safety there should be smaller */
// parent button to left
- if ( midx < block->minx ) block->safety.xmin = block->minx-3;
- else block->safety.xmin = block->minx-40;
+ if (midx < block->minx) block->safety.xmin = block->minx - 3;
+ else block->safety.xmin = block->minx - 40;
// parent button to right
- if ( midx > block->maxx ) block->safety.xmax = block->maxx+3;
- else block->safety.xmax = block->maxx+40;
+ if (midx > block->maxx) block->safety.xmax = block->maxx + 3;
+ else block->safety.xmax = block->maxx + 40;
// parent button on bottom
- if ( midy < block->miny ) block->safety.ymin = block->miny-3;
- else block->safety.ymin = block->miny-40;
+ if (midy < block->miny) block->safety.ymin = block->miny - 3;
+ else block->safety.ymin = block->miny - 40;
// parent button on top
- if ( midy > block->maxy ) block->safety.ymax = block->maxy+3;
- else block->safety.ymax = block->maxy+40;
+ if (midy > block->maxy) block->safety.ymax = block->maxy + 3;
+ else block->safety.ymax = block->maxy + 40;
// exception for switched pulldowns...
- if (dir1 && (dir1 & block->direction)==0) {
- if (dir2==UI_RIGHT) block->safety.xmax = block->maxx+3;
- if (dir2==UI_LEFT) block->safety.xmin = block->minx-3;
+ if (dir1 && (dir1 & block->direction) == 0) {
+ if (dir2 == UI_RIGHT) block->safety.xmax = block->maxx + 3;
+ if (dir2 == UI_LEFT) block->safety.xmin = block->minx - 3;
}
- block->direction= dir1;
+ block->direction = dir1;
}
else {
- block->safety.xmin = block->minx-40;
- block->safety.ymin = block->miny-40;
- block->safety.xmax = block->maxx+40;
- block->safety.ymax = block->maxy+40;
+ block->safety.xmin = block->minx - 40;
+ block->safety.ymin = block->miny - 40;
+ block->safety.xmax = block->maxx + 40;
+ block->safety.ymax = block->maxy + 40;
}
/* keep a list of these, needed for pulldown menus */
- saferct= MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct");
- saferct->parent= butrct;
- saferct->safety= block->safety;
+ saferct = MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct");
+ saferct->parent = butrct;
+ saferct->safety = block->safety;
BLI_freelistN(&block->saferct);
if (but)
BLI_duplicatelist(&block->saferct, &but->block->saferct);
@@ -1491,7 +1491,7 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar)
{
uiBlock *block;
- for (block=ar->uiblocks.first; block; block=block->next)
+ for (block = ar->uiblocks.first; block; block = block->next)
uiDrawBlock(C, block);
}
@@ -1502,14 +1502,14 @@ static void ui_popup_block_clip(wmWindow *window, uiBlock *block)
wm_window_get_size(window, &winx, &winy);
if (block->minx < MENU_SHADOW_SIDE)
- block->minx= MENU_SHADOW_SIDE;
- if (block->maxx > winx-MENU_SHADOW_SIDE)
- block->maxx= winx-MENU_SHADOW_SIDE;
+ block->minx = MENU_SHADOW_SIDE;
+ if (block->maxx > winx - MENU_SHADOW_SIDE)
+ block->maxx = winx - MENU_SHADOW_SIDE;
if (block->miny < MENU_SHADOW_BOTTOM)
- block->miny= MENU_SHADOW_BOTTOM;
- if (block->maxy > winy-MENU_TOP)
- block->maxy= winy-MENU_TOP;
+ block->miny = MENU_SHADOW_BOTTOM;
+ if (block->maxy > winy - MENU_TOP)
+ block->maxy = winy - MENU_TOP;
}
void ui_popup_block_scrolltest(uiBlock *block)
@@ -1518,21 +1518,21 @@ void ui_popup_block_scrolltest(uiBlock *block)
/* Knowing direction is necessary for multi-column menus... */
int is_flip = (block->direction & UI_TOP) && !(block->flag & UI_BLOCK_NO_FLIP);
- block->flag &= ~(UI_BLOCK_CLIPBOTTOM|UI_BLOCK_CLIPTOP);
+ block->flag &= ~(UI_BLOCK_CLIPBOTTOM | UI_BLOCK_CLIPTOP);
- for (bt= block->buttons.first; bt; bt= bt->next)
+ for (bt = block->buttons.first; bt; bt = bt->next)
bt->flag &= ~UI_SCROLLED;
- if (block->buttons.first==block->buttons.last)
+ if (block->buttons.first == block->buttons.last)
return;
/* mark buttons that are outside boundary and the ones next to it for arrow(s) */
- for (bt= block->buttons.first; bt; bt= bt->next) {
+ for (bt = block->buttons.first; bt; bt = bt->next) {
if (bt->y1 < block->miny) {
bt->flag |= UI_SCROLLED;
block->flag |= UI_BLOCK_CLIPBOTTOM;
/* make space for arrow */
- if (bt->y2 < block->miny +10) {
+ if (bt->y2 < block->miny + 10) {
if (is_flip && bt->next && bt->next->y1 > bt->y1)
bt->next->flag |= UI_SCROLLED;
else if (!is_flip && bt->prev && bt->prev->y1 > bt->y1)
@@ -1543,7 +1543,7 @@ void ui_popup_block_scrolltest(uiBlock *block)
bt->flag |= UI_SCROLLED;
block->flag |= UI_BLOCK_CLIPTOP;
/* make space for arrow */
- if (bt->y1 > block->maxy -10) {
+ if (bt->y1 > block->maxy - 10) {
if (!is_flip && bt->next && bt->next->y2 < bt->y2)
bt->next->flag |= UI_SCROLLED;
else if (is_flip && bt->prev && bt->prev->y2 < bt->y2)
@@ -1555,7 +1555,7 @@ void ui_popup_block_scrolltest(uiBlock *block)
uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut *but, uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg)
{
- wmWindow *window= CTX_wm_window(C);
+ wmWindow *window = CTX_wm_window(C);
static ARegionType type;
ARegion *ar;
uiBlock *block;
@@ -1564,37 +1564,37 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
uiSafetyRct *saferct;
/* create handle */
- handle= MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
+ handle = MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
/* store context for operator */
- handle->ctx_area= CTX_wm_area(C);
- handle->ctx_region= CTX_wm_region(C);
+ handle->ctx_area = CTX_wm_area(C);
+ handle->ctx_region = CTX_wm_region(C);
/* create area region */
- ar= ui_add_temporary_region(CTX_wm_screen(C));
- handle->region= ar;
+ ar = ui_add_temporary_region(CTX_wm_screen(C));
+ handle->region = ar;
memset(&type, 0, sizeof(ARegionType));
- type.draw= ui_block_region_draw;
- ar->type= &type;
+ type.draw = ui_block_region_draw;
+ ar->type = &type;
UI_add_region_handlers(&ar->handlers);
/* create ui block */
if (create_func)
- block= create_func(C, handle->region, arg);
+ block = create_func(C, handle->region, arg);
else
- block= handle_create_func(C, handle, arg);
+ block = handle_create_func(C, handle, arg);
if (block->handle) {
memcpy(block->handle, handle, sizeof(uiPopupBlockHandle));
MEM_freeN(handle);
- handle= block->handle;
+ handle = block->handle;
}
else
- block->handle= handle;
+ block->handle = handle;
- ar->regiondata= handle;
+ ar->regiondata = handle;
if (!block->endblock)
uiEndBlock(C, block);
@@ -1602,7 +1602,7 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
/* if this is being created from a button */
if (but) {
if (ELEM(but->type, BLOCK, PULLDOWN))
- block->xofs = -2; /* for proper alignment */
+ block->xofs = -2; /* for proper alignment */
block->aspect = but->block->aspect;
@@ -1610,10 +1610,10 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
}
else {
/* keep a list of these, needed for pulldown menus */
- saferct= MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct");
- saferct->safety= block->safety;
+ saferct = MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct");
+ saferct->safety = block->safety;
BLI_addhead(&block->saferct, saferct);
- block->flag |= UI_BLOCK_POPUP|UI_BLOCK_NUMSELECT;
+ block->flag |= UI_BLOCK_POPUP | UI_BLOCK_NUMSELECT;
}
/* clip block with window boundary */
@@ -1632,7 +1632,7 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut
block->miny -= ar->winrct.ymin;
block->maxy -= ar->winrct.ymin;
- for (bt= block->buttons.first; bt; bt= bt->next) {
+ for (bt = block->buttons.first; bt; bt = bt->next) {
bt->x1 -= ar->winrct.xmin;
bt->x2 -= ar->winrct.xmin;
bt->y1 -= ar->winrct.ymin;
@@ -1672,32 +1672,32 @@ void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle)
static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *arg_str)
{
- uiBlock *block= uiLayoutGetBlock(layout);
- uiPopupBlockHandle *handle= block->handle;
- uiLayout *split, *column=NULL;
+ uiBlock *block = uiLayoutGetBlock(layout);
+ uiPopupBlockHandle *handle = block->handle;
+ uiLayout *split, *column = NULL;
uiBut *bt;
MenuData *md;
MenuEntry *entry;
- const char *instr= arg_str;
+ const char *instr = arg_str;
int columns, rows, a, b;
- int column_start= 0, column_end= 0;
+ int column_start = 0, column_end = 0;
uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT);
/* compute menu data */
- md= decompose_menu_string(instr);
+ md = decompose_menu_string(instr);
/* columns and row estimation */
- columns= (md->nitems+20)/20;
- if (columns<1)
- columns= 1;
- if (columns>8)
- columns= (md->nitems+25)/25;
-
- rows= md->nitems/columns;
- if (rows<1)
- rows= 1;
- while (rows*columns<md->nitems)
+ columns = (md->nitems + 20) / 20;
+ if (columns < 1)
+ columns = 1;
+ if (columns > 8)
+ columns = (md->nitems + 25) / 25;
+
+ rows = md->nitems / columns;
+ if (rows < 1)
+ rows = 1;
+ while (rows * columns < md->nitems)
rows++;
/* create title */
@@ -1707,14 +1707,14 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
}
else {
uiItemL(layout, md->title, ICON_NONE);
- bt= block->buttons.last;
- bt->flag= UI_TEXT_LEFT;
+ bt = block->buttons.last;
+ bt->flag = UI_TEXT_LEFT;
}
}
/* inconsistent, but menus with labels do not look good flipped */
- entry= md->items;
- for (a=0; a<md->nitems; a++, entry++) {
+ entry = md->items;
+ for (a = 0; a < md->nitems; a++, entry++) {
if (entry->sepr && entry->str[0]) {
block->flag |= UI_BLOCK_NO_FLIP;
break;
@@ -1722,45 +1722,45 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
}
/* create items */
- split= uiLayoutSplit(layout, 0, 0);
+ split = uiLayoutSplit(layout, 0, 0);
- for (a=0; a<md->nitems; a++) {
+ for (a = 0; a < md->nitems; a++) {
if (a == column_end) {
/* start new column, and find out where it ends in advance, so we
* can flip the order of items properly per column */
- column_start= a;
- column_end= md->nitems;
+ column_start = a;
+ column_end = md->nitems;
- for (b=a+1; b<md->nitems; b++) {
- entry= &md->items[b];
+ for (b = a + 1; b < md->nitems; b++) {
+ entry = &md->items[b];
/* new column on N rows or on separation label */
- if (((b-a) % rows == 0) || (entry->sepr && entry->str[0])) {
+ if (((b - a) % rows == 0) || (entry->sepr && entry->str[0])) {
column_end = b;
break;
}
}
- column= uiLayoutColumn(split, 0);
+ column = uiLayoutColumn(split, 0);
}
if (block->flag & UI_BLOCK_NO_FLIP)
- entry= &md->items[a];
+ entry = &md->items[a];
else
- entry= &md->items[column_start + column_end-1-a];
+ entry = &md->items[column_start + column_end - 1 - a];
if (entry->sepr) {
uiItemL(column, entry->str, entry->icon);
- bt= block->buttons.last;
- bt->flag= UI_TEXT_LEFT;
+ bt = block->buttons.last;
+ bt->flag = UI_TEXT_LEFT;
}
else if (entry->icon) {
- uiDefIconTextButF(block, BUTM|FLO, B_NOP, entry->icon, entry->str, 0, 0,
- UI_UNIT_X*5, UI_UNIT_Y, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, "");
+ uiDefIconTextButF(block, BUTM | FLO, B_NOP, entry->icon, entry->str, 0, 0,
+ UI_UNIT_X * 5, UI_UNIT_Y, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, "");
}
else {
- uiDefButF(block, BUTM|FLO, B_NOP, entry->str, 0, 0,
- UI_UNIT_X*5, UI_UNIT_X, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, "");
+ uiDefButF(block, BUTM | FLO, B_NOP, entry->str, 0, 0,
+ UI_UNIT_X * 5, UI_UNIT_X, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, "");
}
}
@@ -1769,46 +1769,46 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a
void ui_block_func_ICONROW(bContext *UNUSED(C), uiLayout *layout, void *arg_but)
{
- uiBlock *block= uiLayoutGetBlock(layout);
- uiPopupBlockHandle *handle= block->handle;
- uiBut *but= arg_but;
+ uiBlock *block = uiLayoutGetBlock(layout);
+ uiPopupBlockHandle *handle = block->handle;
+ uiBut *but = arg_but;
int a;
uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT);
- for (a=(int)but->hardmin; a<=(int)but->hardmax; a++)
- uiDefIconButF(block, BUTM|FLO, B_NOP, but->icon+(a-but->hardmin), 0, 0, UI_UNIT_X*5, UI_UNIT_Y,
- &handle->retvalue, (float)a, 0.0, 0, 0, "");
+ for (a = (int)but->hardmin; a <= (int)but->hardmax; a++)
+ uiDefIconButF(block, BUTM | FLO, B_NOP, but->icon + (a - but->hardmin), 0, 0, UI_UNIT_X * 5, UI_UNIT_Y,
+ &handle->retvalue, (float)a, 0.0, 0, 0, "");
}
void ui_block_func_ICONTEXTROW(bContext *UNUSED(C), uiLayout *layout, void *arg_but)
{
- uiBlock *block= uiLayoutGetBlock(layout);
- uiPopupBlockHandle *handle= block->handle;
- uiBut *but= arg_but, *bt;
+ uiBlock *block = uiLayoutGetBlock(layout);
+ uiPopupBlockHandle *handle = block->handle;
+ uiBut *but = arg_but, *bt;
MenuData *md;
MenuEntry *entry;
int a;
uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT);
- md= decompose_menu_string(but->str);
+ md = decompose_menu_string(but->str);
/* title */
if (md->title) {
- bt= uiDefBut(block, LABEL, 0, md->title, 0, 0, UI_UNIT_X*5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
- bt->flag= UI_TEXT_LEFT;
+ bt = uiDefBut(block, LABEL, 0, md->title, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+ bt->flag = UI_TEXT_LEFT;
}
/* loop through the menu options and draw them out with icons & text labels */
- for (a=0; a<md->nitems; a++) {
- entry= &md->items[md->nitems-a-1];
+ for (a = 0; a < md->nitems; a++) {
+ entry = &md->items[md->nitems - a - 1];
if (entry->sepr)
uiItemS(layout);
else
- uiDefIconTextButF(block, BUTM|FLO, B_NOP, (short)((but->icon)+(entry->retval-but->hardmin)), entry->str,
- 0, 0, UI_UNIT_X*5, UI_UNIT_Y, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, "");
+ uiDefIconTextButF(block, BUTM | FLO, B_NOP, (short)((but->icon) + (entry->retval - but->hardmin)), entry->str,
+ 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, "");
}
menudata_free(md);
@@ -1829,18 +1829,18 @@ static void ui_warp_pointer(int x, int y)
/********************* Color Button ****************/
/* picker sizes S hsize, F full size, D spacer, B button/pallette height */
-#define SPICK 110.0
-#define FPICK 180.0
-#define DPICK 6.0
-#define BPICK 24.0
+#define SPICK 110.0
+#define FPICK 180.0
+#define DPICK 6.0
+#define BPICK 24.0
/* for picker, while editing hsv */
void ui_set_but_hsv(uiBut *but)
{
float col[3];
- float *hsv= ui_block_hsv_get(but->block);
+ float *hsv = ui_block_hsv_get(but->block);
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2);
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col + 1, col + 2);
ui_set_but_vectorf(but, col);
}
@@ -1848,21 +1848,21 @@ void ui_set_but_hsv(uiBut *but)
static void ui_update_block_buts_rgb(uiBlock *block, float *rgb)
{
uiBut *bt;
- float *hsv= ui_block_hsv_get(block);
+ float *hsv = ui_block_hsv_get(block);
/* this is to keep the H and S value when V is equal to zero
* and we are working in HSV mode, of course!
*/
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+ rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
// this updates button strings, is hackish... but button pointers are on stack of caller function
- for (bt= block->buttons.first; bt; bt= bt->next) {
+ for (bt = block->buttons.first; bt; bt = bt->next) {
if (bt->rnaprop) {
ui_set_but_vectorf(bt, rgb);
}
- else if (strcmp(bt->str, "Hex: ")==0) {
+ else if (strcmp(bt->str, "Hex: ") == 0) {
float rgb_gamma[3];
double intpart;
char col[16];
@@ -1885,23 +1885,23 @@ static void ui_update_block_buts_rgb(uiBlock *block, float *rgb)
strcpy(bt->poin, col);
}
- else if (bt->str[1]==' ') {
- if (bt->str[0]=='R') {
+ else if (bt->str[1] == ' ') {
+ if (bt->str[0] == 'R') {
ui_set_but_val(bt, rgb[0]);
}
- else if (bt->str[0]=='G') {
+ else if (bt->str[0] == 'G') {
ui_set_but_val(bt, rgb[1]);
}
- else if (bt->str[0]=='B') {
+ else if (bt->str[0] == 'B') {
ui_set_but_val(bt, rgb[2]);
}
- else if (bt->str[0]=='H') {
+ else if (bt->str[0] == 'H') {
ui_set_but_val(bt, hsv[0]);
}
- else if (bt->str[0]=='S') {
+ else if (bt->str[0] == 'S') {
ui_set_but_val(bt, hsv[1]);
}
- else if (bt->str[0]=='V') {
+ else if (bt->str[0] == 'V') {
ui_set_but_val(bt, hsv[2]);
}
}
@@ -1912,8 +1912,8 @@ static void ui_update_block_buts_rgb(uiBlock *block, float *rgb)
static void do_picker_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
{
- uiBut *but= (uiBut *)bt1;
- uiPopupBlockHandle *popup= but->block->handle;
+ uiBut *but = (uiBut *)bt1;
+ uiPopupBlockHandle *popup = but->block->handle;
PropertyRNA *prop = but->rnaprop;
PointerRNA ptr = but->rnapoin;
float rgb[4];
@@ -1924,32 +1924,32 @@ static void do_picker_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
}
if (popup)
- popup->menuretval= UI_RETURN_UPDATE;
+ popup->menuretval = UI_RETURN_UPDATE;
}
static void do_hsv_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
{
- uiBut *but= (uiBut *)bt1;
- uiPopupBlockHandle *popup= but->block->handle;
+ uiBut *but = (uiBut *)bt1;
+ uiPopupBlockHandle *popup = but->block->handle;
float rgb[3];
- float *hsv= ui_block_hsv_get(but->block);
+ float *hsv = ui_block_hsv_get(but->block);
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
ui_update_block_buts_rgb(but->block, rgb);
if (popup)
- popup->menuretval= UI_RETURN_UPDATE;
+ popup->menuretval = UI_RETURN_UPDATE;
}
static void do_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexcl)
{
- uiBut *but= (uiBut *)bt1;
- uiPopupBlockHandle *popup= but->block->handle;
- char *hexcol= (char *)hexcl;
+ uiBut *but = (uiBut *)bt1;
+ uiPopupBlockHandle *popup = but->block->handle;
+ char *hexcol = (char *)hexcl;
float rgb[3];
- hex_to_rgb(hexcol, rgb, rgb+1, rgb+2);
+ hex_to_rgb(hexcol, rgb, rgb + 1, rgb + 2);
/* Hex code is assumed to be in sRGB space (coming from other applications, web, etc) */
if (but->block->color_profile != BLI_PR_NONE) {
@@ -1960,16 +1960,16 @@ static void do_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexcl)
ui_update_block_buts_rgb(but->block, rgb);
if (popup)
- popup->menuretval= UI_RETURN_UPDATE;
+ popup->menuretval = UI_RETURN_UPDATE;
}
static void close_popup_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
{
- uiBut *but= (uiBut *)bt1;
- uiPopupBlockHandle *popup= but->block->handle;
+ uiBut *but = (uiBut *)bt1;
+ uiPopupBlockHandle *popup = but->block->handle;
if (popup)
- popup->menuretval= UI_RETURN_OK;
+ popup->menuretval = UI_RETURN_OK;
}
static void picker_new_hide_reveal(uiBlock *block, short colormode)
@@ -1977,26 +1977,26 @@ static void picker_new_hide_reveal(uiBlock *block, short colormode)
uiBut *bt;
/* tag buttons */
- for (bt= block->buttons.first; bt; bt= bt->next) {
+ for (bt = block->buttons.first; bt; bt = bt->next) {
if (bt->type == LABEL) {
- if ( bt->str[1]=='G') {
- if (colormode==2) bt->flag &= ~UI_HIDDEN;
+ if (bt->str[1] == 'G') {
+ if (colormode == 2) bt->flag &= ~UI_HIDDEN;
else bt->flag |= UI_HIDDEN;
}
}
- if (bt->type==NUMSLI || bt->type==TEX) {
- if ( bt->str[1]=='e') {
- if (colormode==2) bt->flag &= ~UI_HIDDEN;
+ if (bt->type == NUMSLI || bt->type == TEX) {
+ if (bt->str[1] == 'e') {
+ if (colormode == 2) bt->flag &= ~UI_HIDDEN;
else bt->flag |= UI_HIDDEN;
}
- else if ( ELEM3(bt->str[0], 'R', 'G', 'B')) {
- if (colormode==0) bt->flag &= ~UI_HIDDEN;
+ else if (ELEM3(bt->str[0], 'R', 'G', 'B')) {
+ if (colormode == 0) bt->flag &= ~UI_HIDDEN;
else bt->flag |= UI_HIDDEN;
}
- else if ( ELEM3(bt->str[0], 'H', 'S', 'V')) {
- if (colormode==1) bt->flag &= ~UI_HIDDEN;
+ else if (ELEM3(bt->str[0], 'H', 'S', 'V')) {
+ if (colormode == 1) bt->flag &= ~UI_HIDDEN;
else bt->flag |= UI_HIDDEN;
}
}
@@ -2005,32 +2005,32 @@ static void picker_new_hide_reveal(uiBlock *block, short colormode)
static void do_picker_new_mode_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
{
- uiBut *bt= bt1;
- short colormode= ui_get_but_val(bt);
+ uiBut *bt = bt1;
+ short colormode = ui_get_but_val(bt);
picker_new_hide_reveal(bt->block, colormode);
}
/* picker sizes S hsize, F full size, D spacer, B button/pallette height */
-#define SPICK1 150.0
-#define DPICK1 6.0
+#define SPICK1 150.0
+#define DPICK1 6.0
-#define PICKER_H 150
-#define PICKER_W 150
-#define PICKER_SPACE 6
-#define PICKER_BAR 14
+#define PICKER_H 150
+#define PICKER_W 150
+#define PICKER_SPACE 6
+#define PICKER_BAR 14
-#define PICKER_TOTAL_W (PICKER_W+PICKER_SPACE+PICKER_BAR)
+#define PICKER_TOTAL_W (PICKER_W + PICKER_SPACE + PICKER_BAR)
static void circle_picker(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop)
{
uiBut *bt;
/* HS circle */
- bt= uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, PICKER_H, PICKER_W, ptr, prop, 0, 0.0, 0.0, 0, 0, "Color");
+ bt = uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, PICKER_H, PICKER_W, ptr, prop, 0, 0.0, 0.0, 0, 0, "Color");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
/* value */
- bt= uiDefButR_prop(block, HSVCUBE, 0, "", PICKER_W+PICKER_SPACE,0,PICKER_BAR,PICKER_H, ptr, prop, 0, 0.0, 0.0, UI_GRAD_V_ALT, 0, "Value");
+ bt = uiDefButR_prop(block, HSVCUBE, 0, "", PICKER_W + PICKER_SPACE, 0, PICKER_BAR, PICKER_H, ptr, prop, 0, 0.0, 0.0, UI_GRAD_V_ALT, 0, "Value");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
}
@@ -2041,11 +2041,11 @@ static void square_picker(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, in
int bartype = type + 3;
/* HS square */
- bt= uiDefButR_prop(block, HSVCUBE, 0, "", 0, PICKER_BAR+PICKER_SPACE, PICKER_TOTAL_W, PICKER_H, ptr, prop, 0, 0.0, 0.0, type, 0, "Color");
+ bt = uiDefButR_prop(block, HSVCUBE, 0, "", 0, PICKER_BAR + PICKER_SPACE, PICKER_TOTAL_W, PICKER_H, ptr, prop, 0, 0.0, 0.0, type, 0, "Color");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
/* value */
- bt= uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, PICKER_TOTAL_W, PICKER_BAR, ptr, prop, 0, 0.0, 0.0, bartype, 0, "Value");
+ bt = uiDefButR_prop(block, HSVCUBE, 0, "", 0, 0, PICKER_TOTAL_W, PICKER_BAR, ptr, prop, 0, 0.0, 0.0, bartype, 0, "Value");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
}
@@ -2053,18 +2053,18 @@ static void square_picker(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, in
/* a HS circle, V slider, rgb/hsv/hex sliders */
static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyRNA *prop)
{
- static short colormode= 0; /* temp? 0=rgb, 1=hsv, 2=hex */
+ static short colormode = 0; /* temp? 0=rgb, 1=hsv, 2=hex */
uiBut *bt;
int width, butwidth;
static char tip[50];
static char hexcol[128];
float rgb_gamma[3];
float min, max, step, precision;
- float *hsv= ui_block_hsv_get(block);
+ float *hsv = ui_block_hsv_get(block);
ui_block_hsv_get(block);
- width= PICKER_TOTAL_W;
+ width = PICKER_TOTAL_W;
butwidth = width - UI_UNIT_X - 10;
/* existence of profile means storage is in linear color space, with display correction */
@@ -2079,7 +2079,7 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR
}
/* sneaky way to check for alpha */
- rgb[3]= FLT_MAX;
+ rgb[3] = FLT_MAX;
RNA_property_float_ui_range(ptr, prop, &min, &max, &step, &precision);
RNA_property_float_get_array(ptr, prop, rgb);
@@ -2101,24 +2101,24 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR
/* mode */
uiBlockBeginAlign(block);
- bt= uiDefButS(block, ROW, 0, "RGB", 0, -30, width/3, UI_UNIT_Y, &colormode, 0.0, 0.0, 0, 0, "");
+ bt = uiDefButS(block, ROW, 0, "RGB", 0, -30, width / 3, UI_UNIT_Y, &colormode, 0.0, 0.0, 0, 0, "");
uiButSetFunc(bt, do_picker_new_mode_cb, bt, NULL);
- bt= uiDefButS(block, ROW, 0, "HSV", width/3, -30, width/3, UI_UNIT_Y, &colormode, 0.0, 1.0, 0, 0, "");
+ bt = uiDefButS(block, ROW, 0, "HSV", width / 3, -30, width / 3, UI_UNIT_Y, &colormode, 0.0, 1.0, 0, 0, "");
uiButSetFunc(bt, do_picker_new_mode_cb, bt, NULL);
- bt= uiDefButS(block, ROW, 0, "Hex", 2*width/3, -30, width/3, UI_UNIT_Y, &colormode, 0.0, 2.0, 0, 0, "");
+ bt = uiDefButS(block, ROW, 0, "Hex", 2 * width / 3, -30, width / 3, UI_UNIT_Y, &colormode, 0.0, 2.0, 0, 0, "");
uiButSetFunc(bt, do_picker_new_mode_cb, bt, NULL);
uiBlockEndAlign(block);
- bt= uiDefIconButO(block, BUT, "UI_OT_eyedropper", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, butwidth+10, -60, UI_UNIT_X, UI_UNIT_Y, NULL);
+ bt = uiDefIconButO(block, BUT, "UI_OT_eyedropper", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, butwidth + 10, -60, UI_UNIT_X, UI_UNIT_Y, NULL);
uiButSetFunc(bt, close_popup_cb, bt, NULL);
/* RGB values */
uiBlockBeginAlign(block);
- bt= uiDefButR_prop(block, NUMSLI, 0, "R ", 0, -60, butwidth, UI_UNIT_Y, ptr, prop, 0, 0.0, 0.0, 0, 3, "Red");
+ bt = uiDefButR_prop(block, NUMSLI, 0, "R ", 0, -60, butwidth, UI_UNIT_Y, ptr, prop, 0, 0.0, 0.0, 0, 3, "Red");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
- bt= uiDefButR_prop(block, NUMSLI, 0, "G ", 0, -80, butwidth, UI_UNIT_Y, ptr, prop, 1, 0.0, 0.0, 0, 3, "Green");
+ bt = uiDefButR_prop(block, NUMSLI, 0, "G ", 0, -80, butwidth, UI_UNIT_Y, ptr, prop, 1, 0.0, 0.0, 0, 3, "Green");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
- bt= uiDefButR_prop(block, NUMSLI, 0, "B ", 0, -100, butwidth, UI_UNIT_Y, ptr, prop, 2, 0.0, 0.0, 0, 3, "Blue");
+ bt = uiDefButR_prop(block, NUMSLI, 0, "B ", 0, -100, butwidth, UI_UNIT_Y, ptr, prop, 2, 0.0, 0.0, 0, 3, "Blue");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
// could use uiItemFullR(col, ptr, prop, -1, 0, UI_ITEM_R_EXPAND|UI_ITEM_R_SLIDER, "", ICON_NONE);
@@ -2126,29 +2126,29 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR
/* HSV values */
uiBlockBeginAlign(block);
- bt= uiDefButF(block, NUMSLI, 0, "H ", 0, -60, butwidth, UI_UNIT_Y, hsv, 0.0, 1.0, 10, 3, "Hue");
+ bt = uiDefButF(block, NUMSLI, 0, "H ", 0, -60, butwidth, UI_UNIT_Y, hsv, 0.0, 1.0, 10, 3, "Hue");
uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
- bt= uiDefButF(block, NUMSLI, 0, "S ", 0, -80, butwidth, UI_UNIT_Y, hsv+1, 0.0, 1.0, 10, 3, "Saturation");
+ bt = uiDefButF(block, NUMSLI, 0, "S ", 0, -80, butwidth, UI_UNIT_Y, hsv + 1, 0.0, 1.0, 10, 3, "Saturation");
uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
- bt= uiDefButF(block, NUMSLI, 0, "V ", 0, -100, butwidth, UI_UNIT_Y, hsv+2, 0.0, max, 10, 3, "Value");
+ bt = uiDefButF(block, NUMSLI, 0, "V ", 0, -100, butwidth, UI_UNIT_Y, hsv + 2, 0.0, max, 10, 3, "Value");
uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv);
uiBlockEndAlign(block);
if (rgb[3] != FLT_MAX) {
- bt= uiDefButR_prop(block, NUMSLI, 0, "A ", 0, -120, butwidth, UI_UNIT_Y, ptr, prop, 3, 0.0, 0.0, 0, 0, "Alpha");
+ bt = uiDefButR_prop(block, NUMSLI, 0, "A ", 0, -120, butwidth, UI_UNIT_Y, ptr, prop, 3, 0.0, 0.0, 0, 0, "Alpha");
uiButSetFunc(bt, do_picker_rna_cb, bt, NULL);
}
else {
- rgb[3]= 1.0f;
+ rgb[3] = 1.0f;
}
BLI_snprintf(hexcol, sizeof(hexcol), "%02X%02X%02X", FTOCHAR(rgb_gamma[0]), FTOCHAR(rgb_gamma[1]), FTOCHAR(rgb_gamma[2]));
- bt= uiDefBut(block, TEX, 0, "Hex: ", 0, -60, butwidth, UI_UNIT_Y, hexcol, 0, 8, 0, 0, "Hex triplet for color (#RRGGBB)");
+ bt = uiDefBut(block, TEX, 0, "Hex: ", 0, -60, butwidth, UI_UNIT_Y, hexcol, 0, 8, 0, 0, "Hex triplet for color (#RRGGBB)");
uiButSetFunc(bt, do_hex_rna_cb, bt, hexcol);
uiDefBut(block, LABEL, 0, "(Gamma Corrected)", 0, -80, butwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
- rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+ rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
picker_new_hide_reveal(block, colormode);
}
@@ -2156,33 +2156,33 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR
static int ui_picker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *block, wmEvent *event)
{
- float add= 0.0f;
+ float add = 0.0f;
- if (event->type==WHEELUPMOUSE)
- add= 0.05f;
- else if (event->type==WHEELDOWNMOUSE)
- add= -0.05f;
+ if (event->type == WHEELUPMOUSE)
+ add = 0.05f;
+ else if (event->type == WHEELDOWNMOUSE)
+ add = -0.05f;
- if (add!=0.0f) {
+ if (add != 0.0f) {
uiBut *but;
- for (but= block->buttons.first; but; but= but->next) {
- if (but->type==HSVCUBE && but->active==NULL) {
- uiPopupBlockHandle *popup= block->handle;
+ for (but = block->buttons.first; but; but = but->next) {
+ if (but->type == HSVCUBE && but->active == NULL) {
+ uiPopupBlockHandle *popup = block->handle;
float col[3];
- float *hsv= ui_block_hsv_get(block);
+ float *hsv = ui_block_hsv_get(block);
ui_get_but_vectorf(but, col);
- rgb_to_hsv_compat(col[0], col[1], col[2], hsv, hsv+1, hsv+2);
- hsv[2]= CLAMPIS(hsv[2]+add, 0.0f, 1.0f);
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2);
+ rgb_to_hsv_compat(col[0], col[1], col[2], hsv, hsv + 1, hsv + 2);
+ hsv[2] = CLAMPIS(hsv[2] + add, 0.0f, 1.0f);
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col + 1, col + 2);
ui_set_but_vectorf(but, col);
ui_update_block_buts_rgb(block, col);
if (popup)
- popup->menuretval= UI_RETURN_UPDATE;
+ popup->menuretval = UI_RETURN_UPDATE;
return 1;
}
@@ -2193,10 +2193,10 @@ static int ui_picker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *block, w
uiBlock *ui_block_func_COL(bContext *C, uiPopupBlockHandle *handle, void *arg_but)
{
- uiBut *but= arg_but;
+ uiBut *but = arg_but;
uiBlock *block;
- block= uiBeginBlock(C, handle->region, __func__, UI_EMBOSS);
+ block = uiBeginBlock(C, handle->region, __func__, UI_EMBOSS);
if (but->rnaprop) {
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) {
@@ -2210,13 +2210,13 @@ uiBlock *ui_block_func_COL(bContext *C, uiPopupBlockHandle *handle, void *arg_bu
uiBlockPicker(block, handle->retvec, &but->rnapoin, but->rnaprop);
- block->flag= UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_KEEP_OPEN|UI_BLOCK_OUT_1;
+ block->flag = UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_KEEP_OPEN | UI_BLOCK_OUT_1;
uiBoundsBlock(block, 10);
- block->block_event_func= ui_picker_small_wheel_cb;
+ block->block_event_func = ui_picker_small_wheel_cb;
/* and lets go */
- block->direction= UI_TOP;
+ block->direction = UI_TOP;
return block;
}
@@ -2227,11 +2227,11 @@ static int ui_popup_string_hash(char *str)
{
/* sometimes button contains hotkey, sometimes not, strip for proper compare */
int hash;
- char *delimit= strchr(str, '|');
+ char *delimit = strchr(str, '|');
- if (delimit) *delimit= 0;
- hash= BLI_ghashutil_strhash(str);
- if (delimit) *delimit= '|';
+ if (delimit) *delimit = 0;
+ hash = BLI_ghashutil_strhash(str);
+ if (delimit) *delimit = '|';
return hash;
}
@@ -2244,23 +2244,23 @@ static int ui_popup_menu_hash(const char *str)
/* but == NULL read, otherwise set */
uiBut *ui_popup_menu_memory(uiBlock *block, uiBut *but)
{
- static int mem[256], first=1;
- int hash= block->puphash;
+ static int mem[256], first = 1;
+ int hash = block->puphash;
if (first) {
/* init */
memset(mem, -1, sizeof(mem));
- first= 0;
+ first = 0;
}
if (but) {
/* set */
- mem[hash & 255 ]= ui_popup_string_hash(but->str);
+ mem[hash & 255] = ui_popup_string_hash(but->str);
return NULL;
}
else {
/* get */
- for (but=block->buttons.first; but; but=but->next)
+ for (but = block->buttons.first; but; but = but->next)
if (ui_popup_string_hash(but->str) == mem[hash & 255])
return but;
@@ -2286,80 +2286,81 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
{
uiBlock *block;
uiBut *bt;
- uiPopupMenu *pup= arg_pup;
+ uiPopupMenu *pup = arg_pup;
int offset[2], direction, minwidth, width, height, flip;
if (pup->menu_func) {
- pup->block->handle= handle;
+ pup->block->handle = handle;
pup->menu_func(C, pup->layout, pup->menu_arg);
- pup->block->handle= NULL;
+ pup->block->handle = NULL;
}
if (pup->but) {
/* minimum width to enforece */
- minwidth= pup->but->x2 - pup->but->x1;
+ minwidth = pup->but->x2 - pup->but->x1;
if (pup->but->type == PULLDOWN || pup->but->menu_create_func) {
- direction= UI_DOWN;
- flip= 1;
+ direction = UI_DOWN;
+ flip = 1;
}
else {
- direction= UI_TOP;
- flip= 0;
+ direction = UI_TOP;
+ flip = 0;
}
}
else {
- minwidth= 50;
- direction= UI_DOWN;
- flip= 1;
+ minwidth = 50;
+ direction = UI_DOWN;
+ flip = 1;
}
- block= pup->block;
+ block = pup->block;
/* in some cases we create the block before the region,
* so we set it delayed here if necessary */
if (BLI_findindex(&handle->region->uiblocks, block) == -1)
uiBlockSetRegion(block, handle->region);
- block->direction= direction;
+ block->direction = direction;
uiBlockLayoutResolve(block, &width, &height);
uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT);
if (pup->popup) {
- uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT|UI_BLOCK_RET_1);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_NUMSELECT | UI_BLOCK_RET_1);
uiBlockSetDirection(block, direction);
/* offset the mouse position, possibly based on earlier selection */
if ((block->flag & UI_BLOCK_POPUP_MEMORY) &&
- (bt= ui_popup_menu_memory(block, NULL))) {
+ (bt = ui_popup_menu_memory(block, NULL)))
+ {
/* position mouse on last clicked item, at 0.8*width of the
* button, so it doesn't overlap the text too much, also note
* the offset is negative because we are inverse moving the
* block to be under the mouse */
- offset[0]= -(bt->x1 + 0.8f*(bt->x2 - bt->x1));
- offset[1]= -(bt->y1 + 0.5f*UI_UNIT_Y);
+ offset[0] = -(bt->x1 + 0.8f * (bt->x2 - bt->x1));
+ offset[1] = -(bt->y1 + 0.5f * UI_UNIT_Y);
}
else {
/* position mouse at 0.8*width of the button and below the tile
* on the first item */
- offset[0]= 0;
- for (bt=block->buttons.first; bt; bt=bt->next)
- offset[0]= MIN2(offset[0], -(bt->x1 + 0.8f*(bt->x2 - bt->x1)));
+ offset[0] = 0;
+ for (bt = block->buttons.first; bt; bt = bt->next)
+ offset[0] = MIN2(offset[0], -(bt->x1 + 0.8f * (bt->x2 - bt->x1)));
- offset[1]= 1.5*UI_UNIT_Y;
+ offset[1] = 1.5 * UI_UNIT_Y;
}
- block->minbounds= minwidth;
+ block->minbounds = minwidth;
uiMenuPopupBoundsBlock(block, 1, offset[0], offset[1]);
}
else {
/* for a header menu we set the direction automatic */
if (!pup->slideout && flip) {
- ScrArea *sa= CTX_wm_area(C);
- if (sa && sa->headertype==HEADERDOWN) {
- ARegion *ar= CTX_wm_region(C);
+ ScrArea *sa = CTX_wm_area(C);
+ if (sa && sa->headertype == HEADERDOWN) {
+ ARegion *ar = CTX_wm_region(C);
if (ar && ar->regiontype == RGN_TYPE_HEADER) {
uiBlockSetDirection(block, UI_TOP);
uiBlockFlipOrder(block);
@@ -2367,7 +2368,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
}
}
- block->minbounds= minwidth;
+ block->minbounds = minwidth;
uiTextBoundsBlock(block, 50);
}
@@ -2382,22 +2383,22 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi
uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut *but, uiMenuCreateFunc menu_func, void *arg, char *str)
{
- wmWindow *window= CTX_wm_window(C);
- uiStyle *style= UI_GetStyle();
+ wmWindow *window = CTX_wm_window(C);
+ uiStyle *style = UI_GetStyle();
uiPopupBlockHandle *handle;
uiPopupMenu *pup;
- pup= MEM_callocN(sizeof(uiPopupMenu), __func__);
- pup->block= uiBeginBlock(C, NULL, __func__, UI_EMBOSSP);
- pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
- pup->slideout= (but && (but->block->flag & UI_BLOCK_LOOP));
- pup->but= but;
+ pup = MEM_callocN(sizeof(uiPopupMenu), __func__);
+ pup->block = uiBeginBlock(C, NULL, __func__, UI_EMBOSSP);
+ pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
+ pup->slideout = (but && (but->block->flag & UI_BLOCK_LOOP));
+ pup->but = but;
uiLayoutSetOperatorContext(pup->layout, WM_OP_INVOKE_REGION_WIN);
if (!but) {
/* no button to start from, means we are a popup */
- pup->mx= window->eventstate->x;
- pup->my= window->eventstate->y;
- pup->popup= 1;
+ pup->mx = window->eventstate->x;
+ pup->my = window->eventstate->y;
+ pup->popup = 1;
pup->block->flag |= UI_BLOCK_NO_FLIP;
}
/* some enums reversing is strange, currently we have no good way to
@@ -2416,19 +2417,19 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut
if (str) {
/* menu is created from a string */
- pup->menu_func= ui_block_func_MENUSTR;
- pup->menu_arg= str;
+ pup->menu_func = ui_block_func_MENUSTR;
+ pup->menu_arg = str;
}
else {
/* menu is created from a callback */
- pup->menu_func= menu_func;
- pup->menu_arg= arg;
+ pup->menu_func = menu_func;
+ pup->menu_arg = arg;
}
- handle= ui_popup_block_create(C, butregion, but, NULL, ui_block_func_POPUP, pup);
+ handle = ui_popup_block_create(C, butregion, but, NULL, ui_block_func_POPUP, pup);
if (!but) {
- handle->popup= 1;
+ handle->popup = 1;
UI_add_popup_handlers(C, &window->modalhandlers, handle);
WM_event_add_mousemove(C);
@@ -2444,18 +2445,18 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut
/* only return handler, and set optional title */
uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
{
- uiStyle *style= UI_GetStyle();
- uiPopupMenu *pup= MEM_callocN(sizeof(uiPopupMenu), "popup menu");
+ uiStyle *style = UI_GetStyle();
+ uiPopupMenu *pup = MEM_callocN(sizeof(uiPopupMenu), "popup menu");
uiBut *but;
- pup->block= uiBeginBlock(C, NULL, __func__, UI_EMBOSSP);
+ pup->block = uiBeginBlock(C, NULL, __func__, UI_EMBOSSP);
pup->block->flag |= UI_BLOCK_POPUP_MEMORY;
- pup->block->puphash= ui_popup_menu_hash(title);
- pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
+ pup->block->puphash = ui_popup_menu_hash(title);
+ pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style);
uiLayoutSetOperatorContext(pup->layout, WM_OP_EXEC_REGION_WIN);
/* create in advance so we can let buttons point to retval already */
- pup->block->handle= MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
+ pup->block->handle = MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle");
/* create title button */
if (title && title[0]) {
@@ -2467,7 +2468,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
}
else {
but = uiDefBut(pup->block, LABEL, 0, title, 0, 0, 200, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
- but->flag= UI_TEXT_LEFT;
+ but->flag = UI_TEXT_LEFT;
}
}
@@ -2477,15 +2478,15 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon)
/* set the whole structure to work */
void uiPupMenuEnd(bContext *C, uiPopupMenu *pup)
{
- wmWindow *window= CTX_wm_window(C);
+ wmWindow *window = CTX_wm_window(C);
uiPopupBlockHandle *menu;
- pup->popup= 1;
- pup->mx= window->eventstate->x;
- pup->my= window->eventstate->y;
+ pup->popup = 1;
+ pup->mx = window->eventstate->x;
+ pup->my = window->eventstate->y;
- menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_POPUP, pup);
- menu->popup= 1;
+ menu = ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_POPUP, pup);
+ menu->popup = 1;
UI_add_popup_handlers(C, &window->modalhandlers, menu);
WM_event_add_mousemove(C);
@@ -2502,7 +2503,7 @@ uiLayout *uiPupMenuLayout(uiPopupMenu *pup)
static void operator_name_cb(bContext *C, void *arg, int retval)
{
- const char *opname= arg;
+ const char *opname = arg;
if (opname && retval > 0)
WM_operator_name_call(C, opname, WM_OP_EXEC_DEFAULT, NULL);
@@ -2510,7 +2511,7 @@ static void operator_name_cb(bContext *C, void *arg, int retval)
static void operator_cb(bContext *C, void *arg, int retval)
{
- wmOperator *op= arg;
+ wmOperator *op = arg;
if (op && retval > 0)
WM_operator_call(C, op);
@@ -2528,15 +2529,15 @@ static void vconfirm_opname(bContext *C, const char *opname, const char *title,
uiPopupBlockHandle *handle;
char *s, buf[512];
- s= buf;
- if (title) s+= sprintf(s, "%s%%t|", title);
+ s = buf;
+ if (title) s += sprintf(s, "%s%%t|", title);
vsnprintf(s, sizeof(buf) - (s - buf), itemfmt, ap);
- buf[sizeof(buf) - 1]= '\0';
+ buf[sizeof(buf) - 1] = '\0';
- handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf);
+ handle = ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf);
- handle->popup_func= operator_name_cb;
- handle->popup_arg= (void *)opname;
+ handle->popup_func = operator_name_cb;
+ handle->popup_arg = (void *)opname;
}
static void confirm_operator(bContext *C, wmOperator *op, const char *title, const char *item)
@@ -2544,15 +2545,15 @@ static void confirm_operator(bContext *C, wmOperator *op, const char *title, con
uiPopupBlockHandle *handle;
char *s, buf[512];
- s= buf;
- if (title) s+= BLI_snprintf(s, sizeof(buf), "%s%%t|%s", title, item);
+ s = buf;
+ if (title) s += BLI_snprintf(s, sizeof(buf), "%s%%t|%s", title, item);
(void)s;
- handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf);
+ handle = ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf);
- handle->popup_func= operator_cb;
- handle->popup_arg= op;
- handle->cancel_func= confirm_cancel_operator;
+ handle->popup_func = operator_cb;
+ handle->popup_arg = op;
+ handle->cancel_func = confirm_cancel_operator;
}
void uiPupMenuOkee(bContext *C, const char *opname, const char *str, ...)
@@ -2612,11 +2613,11 @@ void uiPupMenuReports(bContext *C, ReportList *reports)
if (!CTX_wm_window(C))
return;
- ds= BLI_dynstr_new();
+ ds = BLI_dynstr_new();
- for (report=reports->list.first; report; report=report->next) {
+ for (report = reports->list.first; report; report = report->next) {
if (report->type < reports->printlevel)
- ; /* pass */
+ ; /* pass */
else if (report->type >= RPT_ERROR)
BLI_dynstr_appendf(ds, "Error %%i%d%%t|%s", ICON_ERROR, report->message);
else if (report->type >= RPT_WARNING)
@@ -2625,7 +2626,7 @@ void uiPupMenuReports(bContext *C, ReportList *reports)
BLI_dynstr_appendf(ds, "Info %%i%d%%t|%s", ICON_INFO, report->message);
}
- str= BLI_dynstr_get_cstring(ds);
+ str = BLI_dynstr_get_cstring(ds);
if (str[0] != '\0')
ui_popup_menu_create(C, NULL, NULL, NULL, NULL, str);
MEM_freeN(str);
@@ -2640,19 +2641,19 @@ void uiPupMenuInvoke(bContext *C, const char *idname)
Menu menu;
MenuType *mt = WM_menutype_find(idname, TRUE);
- if (mt==NULL) {
+ if (mt == NULL) {
printf("%s: named menu \"%s\" not found\n", __func__, idname);
return;
}
- if (mt->poll && mt->poll(C, mt)==0)
+ if (mt->poll && mt->poll(C, mt) == 0)
return;
- pup= uiPupMenuBegin(C, mt->label, ICON_NONE);
- layout= uiPupMenuLayout(pup);
+ pup = uiPupMenuBegin(C, mt->label, ICON_NONE);
+ layout = uiPupMenuLayout(pup);
- menu.layout= layout;
- menu.type= mt;
+ menu.layout = layout;
+ menu.type = mt;
mt->draw(C, &menu);
@@ -2664,13 +2665,13 @@ void uiPupMenuInvoke(bContext *C, const char *idname)
void uiPupBlockO(bContext *C, uiBlockCreateFunc func, void *arg, const char *opname, int opcontext)
{
- wmWindow *window= CTX_wm_window(C);
+ wmWindow *window = CTX_wm_window(C);
uiPopupBlockHandle *handle;
- handle= ui_popup_block_create(C, NULL, NULL, func, NULL, arg);
- handle->popup= 1;
- handle->optype= (opname)? WM_operatortype_find(opname, 0): NULL;
- handle->opcontext= opcontext;
+ handle = ui_popup_block_create(C, NULL, NULL, func, NULL, arg);
+ handle->popup = 1;
+ handle->optype = (opname) ? WM_operatortype_find(opname, 0) : NULL;
+ handle->opcontext = opcontext;
UI_add_popup_handlers(C, &window->modalhandlers, handle);
WM_event_add_mousemove(C);
@@ -2683,16 +2684,16 @@ void uiPupBlock(bContext *C, uiBlockCreateFunc func, void *arg)
void uiPupBlockEx(bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_func, uiBlockCancelFunc cancel_func, void *arg)
{
- wmWindow *window= CTX_wm_window(C);
+ wmWindow *window = CTX_wm_window(C);
uiPopupBlockHandle *handle;
- handle= ui_popup_block_create(C, NULL, NULL, func, NULL, arg);
- handle->popup= 1;
- handle->retvalue= 1;
+ handle = ui_popup_block_create(C, NULL, NULL, func, NULL, arg);
+ handle->popup = 1;
+ handle->retvalue = 1;
- handle->popup_arg= arg;
- handle->popup_func= popup_func;
- handle->cancel_func= cancel_func;
+ handle->popup_arg = arg;
+ handle->popup_func = popup_func;
+ handle->cancel_func = cancel_func;
// handle->opcontext= opcontext;
UI_add_popup_handlers(C, &window->modalhandlers, handle);
@@ -2702,17 +2703,17 @@ void uiPupBlockEx(bContext *C, uiBlockCreateFunc func, uiBlockHandleFunc popup_f
#if 0 /* UNUSED */
void uiPupBlockOperator(bContext *C, uiBlockCreateFunc func, wmOperator *op, int opcontext)
{
- wmWindow *window= CTX_wm_window(C);
+ wmWindow *window = CTX_wm_window(C);
uiPopupBlockHandle *handle;
- handle= ui_popup_block_create(C, NULL, NULL, func, NULL, op);
- handle->popup= 1;
- handle->retvalue= 1;
+ handle = ui_popup_block_create(C, NULL, NULL, func, NULL, op);
+ handle->popup = 1;
+ handle->retvalue = 1;
- handle->popup_arg= op;
- handle->popup_func= operator_cb;
- handle->cancel_func= confirm_cancel_operator;
- handle->opcontext= opcontext;
+ handle->popup_arg = op;
+ handle->popup_func = operator_cb;
+ handle->cancel_func = confirm_cancel_operator;
+ handle->opcontext = opcontext;
UI_add_popup_handlers(C, &window->modalhandlers, handle);
WM_event_add_mousemove(C);
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 6a2038b18bc..91e3b99e23b 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -79,61 +79,61 @@
static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id)
{
- uiStyle *style= MEM_callocN(sizeof(uiStyle), "new style");
+ uiStyle *style = MEM_callocN(sizeof(uiStyle), "new style");
BLI_addtail(styles, style);
BLI_strncpy(style->name, name, MAX_STYLE_NAME);
- style->panelzoom= 1.0; /* unused */
-
- style->paneltitle.uifont_id= uifont_id;
- style->paneltitle.points= 12;
- style->paneltitle.kerning= 1;
- style->paneltitle.shadow= 1;
- style->paneltitle.shadx= 0;
- style->paneltitle.shady= -1;
- style->paneltitle.shadowalpha= 0.15f;
- style->paneltitle.shadowcolor= 1.0f;
-
- style->grouplabel.uifont_id= uifont_id;
- style->grouplabel.points= 12;
- style->grouplabel.kerning= 1;
- style->grouplabel.shadow= 3;
- style->grouplabel.shadx= 0;
- style->grouplabel.shady= -1;
- style->grouplabel.shadowalpha= 0.25f;
-
- style->widgetlabel.uifont_id= uifont_id;
- style->widgetlabel.points= 11;
- style->widgetlabel.kerning= 1;
- style->widgetlabel.shadow= 3;
- style->widgetlabel.shadx= 0;
- style->widgetlabel.shady= -1;
- style->widgetlabel.shadowalpha= 0.15f;
- style->widgetlabel.shadowcolor= 1.0f;
-
- style->widget.uifont_id= uifont_id;
- style->widget.points= 11;
- style->widget.kerning= 1;
- style->widget.shadowalpha= 0.25f;
-
- style->columnspace= 8;
- style->templatespace= 5;
- style->boxspace= 5;
- style->buttonspacex= 8;
- style->buttonspacey= 2;
- style->panelspace= 8;
- style->panelouter= 4;
+ style->panelzoom = 1.0; /* unused */
+
+ style->paneltitle.uifont_id = uifont_id;
+ style->paneltitle.points = 12;
+ style->paneltitle.kerning = 1;
+ style->paneltitle.shadow = 1;
+ style->paneltitle.shadx = 0;
+ style->paneltitle.shady = -1;
+ style->paneltitle.shadowalpha = 0.15f;
+ style->paneltitle.shadowcolor = 1.0f;
+
+ style->grouplabel.uifont_id = uifont_id;
+ style->grouplabel.points = 12;
+ style->grouplabel.kerning = 1;
+ style->grouplabel.shadow = 3;
+ style->grouplabel.shadx = 0;
+ style->grouplabel.shady = -1;
+ style->grouplabel.shadowalpha = 0.25f;
+
+ style->widgetlabel.uifont_id = uifont_id;
+ style->widgetlabel.points = 11;
+ style->widgetlabel.kerning = 1;
+ style->widgetlabel.shadow = 3;
+ style->widgetlabel.shadx = 0;
+ style->widgetlabel.shady = -1;
+ style->widgetlabel.shadowalpha = 0.15f;
+ style->widgetlabel.shadowcolor = 1.0f;
+
+ style->widget.uifont_id = uifont_id;
+ style->widget.points = 11;
+ style->widget.kerning = 1;
+ style->widget.shadowalpha = 0.25f;
+
+ style->columnspace = 8;
+ style->templatespace = 5;
+ style->boxspace = 5;
+ style->buttonspacex = 8;
+ style->buttonspacey = 2;
+ style->panelspace = 8;
+ style->panelouter = 4;
return style;
}
static uiFont *uifont_to_blfont(int id)
{
- uiFont *font= U.uifonts.first;
+ uiFont *font = U.uifonts.first;
- for (; font; font= font->next) {
- if (font->uifont_id==id) {
+ for (; font; font = font->next) {
+ if (font->uifont_id == id) {
return font;
}
}
@@ -144,31 +144,31 @@ static uiFont *uifont_to_blfont(int id)
void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
- float *r_xofs, float *r_yofs)
+ float *r_xofs, float *r_yofs)
{
float height;
- int xofs=0, yofs;
+ int xofs = 0, yofs;
uiStyleFontSet(fs);
- height= BLF_ascender(fs->uifont_id);
- yofs= ceil( 0.5f*(rect->ymax - rect->ymin - height));
+ height = BLF_ascender(fs->uifont_id);
+ yofs = ceil(0.5f * (rect->ymax - rect->ymin - height));
- if (fs->align==UI_STYLE_TEXT_CENTER) {
- xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str)));
+ if (fs->align == UI_STYLE_TEXT_CENTER) {
+ xofs = floor(0.5f * (rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str)));
/* don't center text if it chops off the start of the text, 2 gives some margin */
if (xofs < 2) {
- xofs= 2;
+ xofs = 2;
}
}
- else if (fs->align==UI_STYLE_TEXT_RIGHT) {
- xofs= rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str) - 1;
+ else if (fs->align == UI_STYLE_TEXT_RIGHT) {
+ xofs = rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str) - 1;
}
/* clip is very strict, so we give it some space */
- BLF_clipping(fs->uifont_id, rect->xmin-1, rect->ymin-4, rect->xmax+1, rect->ymax+4);
+ BLF_clipping(fs->uifont_id, rect->xmin - 1, rect->ymin - 4, rect->xmax + 1, rect->ymax + 4);
BLF_enable(fs->uifont_id, BLF_CLIPPING);
- BLF_position(fs->uifont_id, rect->xmin+xofs, rect->ymin+yofs, 0.0f);
+ BLF_position(fs->uifont_id, rect->xmin + xofs, rect->ymin + yofs, 0.0f);
if (fs->shadow) {
BLF_enable(fs->uifont_id, BLF_SHADOW);
@@ -186,15 +186,15 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
if (fs->kerning == 1)
BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
- *r_xofs= xofs;
- *r_yofs= yofs;
+ *r_xofs = xofs;
+ *r_yofs = yofs;
}
void uiStyleFontDraw(uiFontStyle *fs, rcti *rect, const char *str)
{
float xofs, yofs;
uiStyleFontDrawExt(fs, rect, str,
- &xofs, &yofs);
+ &xofs, &yofs);
}
/* drawn same as above, but at 90 degree angle */
@@ -207,16 +207,16 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
uiStyleFontSet(fs);
- height= BLF_ascender(fs->uifont_id);
+ height = BLF_ascender(fs->uifont_id);
/* becomes x-offset when rotated */
- xofs= ceil( 0.5f*(rect->ymax - rect->ymin - height));
+ xofs = ceil(0.5f * (rect->ymax - rect->ymin - height));
/* ignore UI_STYLE, always aligned to top */
/* rotate counter-clockwise for now (assumes left-to-right language)*/
- xofs+= height;
- yofs= BLF_width(fs->uifont_id, str) + 5;
- angle= 90.0f;
+ xofs += height;
+ yofs = BLF_width(fs->uifont_id, str) + 5;
+ angle = 90.0f;
/* translate rect to vertical */
txtrect.xmin = rect->xmin - (rect->ymax - rect->ymin);
@@ -226,9 +226,9 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
/* clip is very strict, so we give it some space */
/* clipping is done without rotation, so make rect big enough to contain both positions */
- BLF_clipping(fs->uifont_id, txtrect.xmin-1, txtrect.ymin-yofs-xofs-4, rect->xmax+1, rect->ymax+4);
+ BLF_clipping(fs->uifont_id, txtrect.xmin - 1, txtrect.ymin - yofs - xofs - 4, rect->xmax + 1, rect->ymax + 4);
BLF_enable(fs->uifont_id, BLF_CLIPPING);
- BLF_position(fs->uifont_id, txtrect.xmin+xofs, txtrect.ymax-yofs, 0.0f);
+ BLF_position(fs->uifont_id, txtrect.xmin + xofs, txtrect.ymax - yofs, 0.0f);
BLF_enable(fs->uifont_id, BLF_ROTATION);
BLF_rotation(fs->uifont_id, angle);
@@ -253,7 +253,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
/* ************** helpers ************************ */
/* XXX: read a style configure */
-uiStyle* UI_GetStyle(void)
+uiStyle *UI_GetStyle(void)
{
uiStyle *style = NULL;
/* offset is two struct uiStyle pointers */
@@ -264,17 +264,17 @@ uiStyle* UI_GetStyle(void)
/* temporarily, does widget font */
int UI_GetStringWidth(const char *str)
{
- uiStyle *style= UI_GetStyle();
- uiFontStyle *fstyle= &style->widget;
+ uiStyle *style = UI_GetStyle();
+ uiFontStyle *fstyle = &style->widget;
int width;
- if (fstyle->kerning==1) /* for BLF_width */
+ if (fstyle->kerning == 1) /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
uiStyleFontSet(fstyle);
- width= BLF_width(fstyle->uifont_id, str);
+ width = BLF_width(fstyle->uifont_id, str);
- if (fstyle->kerning==1)
+ if (fstyle->kerning == 1)
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
return width;
@@ -283,7 +283,7 @@ int UI_GetStringWidth(const char *str)
/* temporarily, does widget font */
void UI_DrawString(float x, float y, const char *str)
{
- uiStyle *style= UI_GetStyle();
+ uiStyle *style = UI_GetStyle();
if (style->widget.kerning == 1)
BLF_enable(style->widget.uifont_id, BLF_KERNING_DEFAULT);
@@ -302,39 +302,39 @@ void UI_DrawString(float x, float y, const char *str)
/* reading without uifont will create one */
void uiStyleInit(void)
{
- uiFont *font= U.uifonts.first;
- uiStyle *style= U.uistyles.first;
+ uiFont *font = U.uifonts.first;
+ uiStyle *style = U.uistyles.first;
/* recover from uninitialized dpi */
if (U.dpi == 0)
- U.dpi= 72;
+ U.dpi = 72;
CLAMP(U.dpi, 48, 128);
/* default builtin */
- if (font==NULL) {
- font= MEM_callocN(sizeof(uiFont), "ui font");
+ if (font == NULL) {
+ font = MEM_callocN(sizeof(uiFont), "ui font");
BLI_addtail(&U.uifonts, font);
BLI_strncpy(font->filename, "default", sizeof(font->filename));
- font->uifont_id= UIFONT_DEFAULT;
+ font->uifont_id = UIFONT_DEFAULT;
}
- for (font= U.uifonts.first; font; font= font->next) {
+ for (font = U.uifonts.first; font; font = font->next) {
- if (font->uifont_id==UIFONT_DEFAULT) {
+ if (font->uifont_id == UIFONT_DEFAULT) {
#ifdef WITH_INTERNATIONAL
- int font_size= datatoc_bfont_ttf_size;
- unsigned char *font_ttf= (unsigned char*)datatoc_bfont_ttf;
+ int font_size = datatoc_bfont_ttf_size;
+ unsigned char *font_ttf = (unsigned char *)datatoc_bfont_ttf;
static int last_font_size = 0;
/* use unicode font for translation */
if (U.transopts & USER_DOTRANSLATE) {
- font_ttf= BLF_get_unifont(&font_size);
+ font_ttf = BLF_get_unifont(&font_size);
if (!font_ttf) {
/* fall back if not found */
- font_size= datatoc_bfont_ttf_size;
- font_ttf= (unsigned char*)datatoc_bfont_ttf;
+ font_size = datatoc_bfont_ttf_size;
+ font_ttf = (unsigned char *)datatoc_bfont_ttf;
}
}
@@ -344,15 +344,15 @@ void uiStyleInit(void)
last_font_size = font_size;
}
- font->blf_id= BLF_load_mem("default", font_ttf, font_size);
+ font->blf_id = BLF_load_mem("default", font_ttf, font_size);
#else
- font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
+ font->blf_id = BLF_load_mem("default", (unsigned char *)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
#endif
}
else {
- font->blf_id= BLF_load(font->filename);
+ font->blf_id = BLF_load(font->filename);
if (font->blf_id == -1)
- font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
+ font->blf_id = BLF_load_mem("default", (unsigned char *)datatoc_bfont_ttf, datatoc_bfont_ttf_size);
}
if (font->blf_id == -1) {
@@ -370,26 +370,26 @@ void uiStyleInit(void)
}
}
- if (style==NULL) {
- ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT );
+ if (style == NULL) {
+ ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT);
}
// XXX, this should be moved into a style, but for now best only load the monospaced font once.
if (blf_mono_font == -1)
- blf_mono_font= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
+ blf_mono_font = BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
BLF_size(blf_mono_font, 12, 72);
/* second for rendering else we get threading problems */
if (blf_mono_font_render == -1)
- blf_mono_font_render= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
+ blf_mono_font_render = BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size);
BLF_size(blf_mono_font_render, 12, 72);
}
void uiStyleFontSet(uiFontStyle *fs)
{
- uiFont *font= uifont_to_blfont(fs->uifont_id);
+ uiFont *font = uifont_to_blfont(fs->uifont_id);
BLF_size(font->blf_id, fs->points, U.dpi);
}
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 91ff4000541..81db18aa0f8 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -83,7 +83,7 @@ void uiTemplateHeader(uiLayout *layout, bContext *C, int menus)
{
uiBlock *block;
- block= uiLayoutAbsoluteBlock(layout);
+ block = uiLayoutAbsoluteBlock(layout);
if (menus) ED_area_header_standardbuttons(C, block, 0);
else ED_area_header_switchbutton(C, block, 0);
}
@@ -102,7 +102,7 @@ typedef struct TemplateID {
/* Search browse menu, assign */
static void id_search_call_cb(bContext *C, void *arg_template, void *item)
{
- TemplateID *template= (TemplateID*)arg_template;
+ TemplateID *template = (TemplateID *)arg_template;
/* ID */
if (item) {
@@ -117,34 +117,34 @@ static void id_search_call_cb(bContext *C, void *arg_template, void *item)
/* ID Search browse menu, do the search */
static void id_search_cb(const bContext *C, void *arg_template, const char *str, uiSearchItems *items)
{
- TemplateID *template= (TemplateID*)arg_template;
- ListBase *lb= template->idlb;
- ID *id, *id_from= template->ptr.id.data;
+ TemplateID *template = (TemplateID *)arg_template;
+ ListBase *lb = template->idlb;
+ ID *id, *id_from = template->ptr.id.data;
int iconid;
- int flag= RNA_property_flag(template->prop);
+ int flag = RNA_property_flag(template->prop);
/* ID listbase */
- for (id= lb->first; id; id= id->next) {
+ for (id = lb->first; id; id = id->next) {
if (!((flag & PROP_ID_SELF_CHECK) && id == id_from)) {
/* use filter */
- if (RNA_property_type(template->prop)==PROP_POINTER) {
+ if (RNA_property_type(template->prop) == PROP_POINTER) {
PointerRNA ptr;
RNA_id_pointer_create(id, &ptr);
- if (RNA_property_pointer_poll(&template->ptr, template->prop, &ptr)==0)
+ if (RNA_property_pointer_poll(&template->ptr, template->prop, &ptr) == 0)
continue;
}
/* hide dot-datablocks, but only if filter does not force it visible */
if (U.uiflag & USER_HIDE_DOT)
- if ((id->name[2]=='.') && (str[0] != '.'))
+ if ((id->name[2] == '.') && (str[0] != '.'))
continue;
- if (BLI_strcasestr(id->name+2, str)) {
+ if (BLI_strcasestr(id->name + 2, str)) {
char name_ui[MAX_ID_NAME];
name_uiprefix_id(name_ui, id);
- iconid= ui_id_icon_get((bContext*)C, id, template->preview);
+ iconid = ui_id_icon_get((bContext *)C, id, template->preview);
if (!uiSearchItemAdd(items, name_ui, id, iconid))
break;
@@ -159,20 +159,20 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
static char search[256];
static TemplateID template;
PointerRNA idptr;
- wmWindow *win= CTX_wm_window(C);
+ wmWindow *win = CTX_wm_window(C);
uiBlock *block;
uiBut *but;
/* clear initial search string, then all items show */
- search[0]= 0;
+ search[0] = 0;
/* arg_litem is malloced, can be freed by parent button */
- template= *((TemplateID*)arg_litem);
+ template = *((TemplateID *)arg_litem);
/* get active id for showing first item */
- idptr= RNA_property_pointer_get(&template.ptr, template.prop);
+ idptr = RNA_property_pointer_get(&template.ptr, template.prop);
- block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
- uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1);
+ block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_RET_1);
/* preview thumbnails */
if (template.prv_rows > 0 && template.prv_cols > 0) {
@@ -214,24 +214,24 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem)
void uiIDContextProperty(bContext *C, PointerRNA *ptr, PropertyRNA **prop)
{
TemplateID *template;
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
uiBlock *block;
uiBut *but;
memset(ptr, 0, sizeof(*ptr));
- *prop= NULL;
+ *prop = NULL;
if (!ar)
return;
- for (block=ar->uiblocks.first; block; block=block->next) {
- for (but=block->buttons.first; but; but= but->next) {
+ for (block = ar->uiblocks.first; block; block = block->next) {
+ for (but = block->buttons.first; but; but = but->next) {
/* find the button before the active one */
- if ((but->flag & (UI_BUT_LAST_ACTIVE|UI_ACTIVE))) {
+ if ((but->flag & (UI_BUT_LAST_ACTIVE | UI_ACTIVE))) {
if (but->func_argN) {
- template= but->func_argN;
- *ptr= template->ptr;
- *prop= template->prop;
+ template = but->func_argN;
+ *ptr = template->ptr;
+ *prop = template->prop;
return;
}
}
@@ -242,12 +242,12 @@ void uiIDContextProperty(bContext *C, PointerRNA *ptr, PropertyRNA **prop)
static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
{
- TemplateID *template= (TemplateID*)arg_litem;
- PointerRNA idptr= RNA_property_pointer_get(&template->ptr, template->prop);
- ID *id= idptr.data;
- int event= GET_INT_FROM_POINTER(arg_event);
+ TemplateID *template = (TemplateID *)arg_litem;
+ PointerRNA idptr = RNA_property_pointer_get(&template->ptr, template->prop);
+ ID *id = idptr.data;
+ int event = GET_INT_FROM_POINTER(arg_event);
- switch(event) {
+ switch (event) {
case UI_ID_BROWSE:
case UI_ID_PIN:
RNA_warning("warning, id event %d shouldnt come here", event);
@@ -262,7 +262,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
RNA_property_update(C, &template->ptr, template->prop);
if (id && CTX_wm_window(C)->eventstate->shift) /* useful hidden functionality, */
- id->us= 0;
+ id->us = 0;
break;
case UI_ID_FAKE_USER:
@@ -276,7 +276,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
if (id) {
if (id_make_local(id, 0)) {
/* reassign to get get proper updates/notifiers */
- idptr= RNA_property_pointer_get(&template->ptr, template->prop);
+ idptr = RNA_property_pointer_get(&template->ptr, template->prop);
RNA_property_pointer_set(&template->ptr, template->prop, idptr);
RNA_property_update(C, &template->ptr, template->prop);
}
@@ -284,14 +284,14 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
break;
case UI_ID_ALONE:
if (id) {
- const int do_scene_obj= (GS(id->name) == ID_OB) &&
- (template->ptr.type == &RNA_SceneObjects);
+ const int do_scene_obj = (GS(id->name) == ID_OB) &&
+ (template->ptr.type == &RNA_SceneObjects);
/* make copy */
if (do_scene_obj) {
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
ED_object_single_user(scene, (struct Object *)id);
- WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
}
else {
if (id) {
@@ -310,7 +310,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
static const char *template_id_browse_tip(StructRNA *type)
{
if (type) {
- switch(RNA_type_to_ID_code(type)) {
+ switch (RNA_type_to_ID_code(type)) {
case ID_SCE: return N_("Browse Scene to be linked");
case ID_OB: return N_("Browse Object to be linked");
case ID_ME: return N_("Browse Mesh Data to be linked");
@@ -345,42 +345,42 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
PointerRNA idptr;
// ListBase *lb; // UNUSED
ID *id, *idfrom;
- int editable= RNA_property_editable(&template->ptr, template->prop);
+ int editable = RNA_property_editable(&template->ptr, template->prop);
- idptr= RNA_property_pointer_get(&template->ptr, template->prop);
- id= idptr.data;
- idfrom= template->ptr.id.data;
+ idptr = RNA_property_pointer_get(&template->ptr, template->prop);
+ id = idptr.data;
+ idfrom = template->ptr.id.data;
// lb= template->idlb;
- block= uiLayoutGetBlock(layout);
+ block = uiLayoutGetBlock(layout);
uiBlockBeginAlign(block);
if (idptr.type)
- type= idptr.type;
+ type = idptr.type;
if (flag & UI_ID_PREVIEWS) {
- but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6,
- TIP_(template_id_browse_tip(type)));
+ but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6,
+ TIP_(template_id_browse_tip(type)));
if (type) {
- but->icon= RNA_struct_ui_icon(type);
+ but->icon = RNA_struct_ui_icon(type);
if (id) but->icon = ui_id_icon_get(C, id, 1);
- uiButSetFlag(but, UI_HAS_ICON|UI_ICON_PREVIEW);
+ uiButSetFlag(but, UI_HAS_ICON | UI_ICON_PREVIEW);
}
if ((idfrom && idfrom->lib) || !editable)
uiButSetFlag(but, UI_BUT_DISABLED);
uiLayoutRow(layout, 1);
- template->preview= 1;
+ template->preview = 1;
}
else if (flag & UI_ID_BROWSE) {
- but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X*1.6, UI_UNIT_Y,
- TIP_(template_id_browse_tip(type)));
+ but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X * 1.6, UI_UNIT_Y,
+ TIP_(template_id_browse_tip(type)));
if (type) {
- but->icon= RNA_struct_ui_icon(type);
+ but->icon = RNA_struct_ui_icon(type);
/* default dragging of icon for id browse buttons */
uiButSetDragID(but, id);
- uiButSetFlag(but, UI_HAS_ICON|UI_ICON_LEFT);
+ uiButSetFlag(but, UI_HAS_ICON | UI_ICON_LEFT);
}
if ((idfrom && idfrom->lib) || !editable)
@@ -390,23 +390,23 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
/* text button with name */
if (id) {
char name[UI_MAX_NAME_STR];
- const short user_alert= (id->us <= 0);
+ const short user_alert = (id->us <= 0);
//text_idbutton(id, name);
- name[0]= '\0';
- but = uiDefButR(block, TEX, 0, name, 0, 0, UI_UNIT_X*6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, NULL);
+ name[0] = '\0';
+ but = uiDefButR(block, TEX, 0, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, NULL);
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_RENAME));
if (user_alert) uiButSetFlag(but, UI_BUT_REDALERT);
if (id->lib) {
if (id->flag & LIB_INDIRECT) {
- but = uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_INDIRECT, 0,0,UI_UNIT_X,UI_UNIT_Y, NULL, 0, 0, 0, 0,
- TIP_("Indirect library datablock, cannot change"));
+ but = uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_INDIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0,
+ TIP_("Indirect library datablock, cannot change"));
uiButSetFlag(but, UI_BUT_DISABLED);
}
else {
- but = uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0,0,UI_UNIT_X,UI_UNIT_Y, NULL, 0, 0, 0, 0,
- TIP_("Direct linked library datablock, click to make local"));
+ but = uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0,
+ TIP_("Direct linked library datablock, click to make local"));
if (!id_make_local(id, 1 /* test */) || (idfrom && idfrom->lib))
uiButSetFlag(but, UI_BUT_DISABLED);
}
@@ -419,8 +419,8 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
BLI_snprintf(numstr, sizeof(numstr), "%d", id->us);
- but = uiDefBut(block, BUT, 0, numstr, 0,0,UI_UNIT_X + ((id->us < 10) ? 0:10), UI_UNIT_Y, NULL, 0, 0, 0, 0,
- TIP_("Display number of users of this data (click to make a single-user copy)"));
+ but = uiDefBut(block, BUT, 0, numstr, 0, 0, UI_UNIT_X + ((id->us < 10) ? 0 : 10), UI_UNIT_Y, NULL, 0, 0, 0, 0,
+ TIP_("Display number of users of this data (click to make a single-user copy)"));
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE));
if (!id_copy(id, NULL, 1 /* test only */) || (idfrom && idfrom->lib) || !editable)
@@ -435,14 +435,14 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
}
if (flag & UI_ID_ADD_NEW) {
- int w= id?UI_UNIT_X: (flag & UI_ID_OPEN)? UI_UNIT_X*3: UI_UNIT_X*6;
+ int w = id ? UI_UNIT_X : (flag & UI_ID_OPEN) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
if (newop) {
- but = uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, (id)? "": IFACE_("New"), 0, 0, w, UI_UNIT_Y, NULL);
+ but = uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, (id) ? "" : IFACE_("New"), 0, 0, w, UI_UNIT_Y, NULL);
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
}
else {
- but = uiDefIconTextBut(block, BUT, 0, ICON_ZOOMIN, (id)? "": IFACE_("New"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+ but = uiDefIconTextBut(block, BUT, 0, ICON_ZOOMIN, (id) ? "" : IFACE_("New"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
}
@@ -451,14 +451,14 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
}
if (flag & UI_ID_OPEN) {
- int w= id?UI_UNIT_X: (flag & UI_ID_ADD_NEW)? UI_UNIT_X*3: UI_UNIT_X*6;
+ int w = id ? UI_UNIT_X : (flag & UI_ID_ADD_NEW) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
if (openop) {
- but = uiDefIconTextButO(block, BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id)? "": IFACE_("Open"), 0, 0, w, UI_UNIT_Y, NULL);
+ but = uiDefIconTextButO(block, BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y, NULL);
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN));
}
else {
- but = uiDefIconTextBut(block, BUT, 0, ICON_FILESEL, (id)? "": IFACE_("Open"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
+ but = uiDefIconTextBut(block, BUT, 0, ICON_FILESEL, (id) ? "" : IFACE_("Open"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL);
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN));
}
@@ -467,7 +467,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
}
/* delete button */
- if (id && (flag & UI_ID_DELETE) && (RNA_property_flag(template->prop) & PROP_NEVER_UNLINK)==0) {
+ if (id && (flag & UI_ID_DELETE) && (RNA_property_flag(template->prop) & PROP_NEVER_UNLINK) == 0) {
if (unlinkop) {
but = uiDefIconButO(block, BUT, unlinkop, WM_OP_INVOKE_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL);
/* so we can access the template from operators, font unlinking needs this */
@@ -475,7 +475,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str
}
else {
but = uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0,
- TIP_("Unlink datablock. Shift + Click to set users to zero, data will then not be saved"));
+ TIP_("Unlink datablock. Shift + Click to set users to zero, data will then not be saved"));
uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_DELETE));
if (RNA_property_flag(template->prop) & PROP_NEVER_NULL)
@@ -499,16 +499,16 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const
StructRNA *type;
short idcode;
- prop= RNA_struct_find_property(ptr, propname);
+ prop = RNA_struct_find_property(ptr, propname);
if (!prop || RNA_property_type(prop) != PROP_POINTER) {
RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
- template= MEM_callocN(sizeof(TemplateID), "TemplateID");
- template->ptr= *ptr;
- template->prop= prop;
+ template = MEM_callocN(sizeof(TemplateID), "TemplateID");
+ template->ptr = *ptr;
+ template->prop = prop;
template->prv_rows = prv_rows;
template->prv_cols = prv_cols;
@@ -517,9 +517,9 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const
if (openop)
flag |= UI_ID_OPEN;
- type= RNA_property_pointer_type(ptr, prop);
- idcode= RNA_type_to_ID_code(type);
- template->idlb= which_libbase(CTX_data_main(C), idcode);
+ type = RNA_property_pointer_type(ptr, prop);
+ idcode = RNA_type_to_ID_code(type);
+ template->idlb = which_libbase(CTX_data_main(C), idcode);
/* create UI elements for this template
* - template_ID makes a copy of the template data and assigns it to the relevant buttons
@@ -534,17 +534,17 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const
void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop)
{
- ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE, 0, 0);
+ ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE, 0, 0);
}
void uiTemplateIDBrowse(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop)
{
- ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME, 0, 0);
+ ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME, 0, 0);
}
void uiTemplateIDPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int rows, int cols)
{
- ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_DELETE|UI_ID_PREVIEWS, rows, cols);
+ ui_template_id(layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS, rows, cols);
}
/************************ ID Chooser Template ***************************/
@@ -560,8 +560,8 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co
uiLayout *row;
/* get properties... */
- propID= RNA_struct_find_property(ptr, propname);
- propType= RNA_struct_find_property(ptr, proptypename);
+ propID = RNA_struct_find_property(ptr, propname);
+ propType = RNA_struct_find_property(ptr, proptypename);
if (!propID || RNA_property_type(propID) != PROP_POINTER) {
RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
@@ -573,7 +573,7 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co
}
/* Start drawing UI Elements using standard defines */
- row= uiLayoutRow(layout, 1);
+ row = uiLayoutRow(layout, 1);
/* Label - either use the provided text, or will become "ID-Block:" */
if (text)
@@ -605,14 +605,14 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna
uiLayout *row;
/* check that properties are valid */
- propPath= RNA_struct_find_property(ptr, propname);
+ propPath = RNA_struct_find_property(ptr, propname);
if (!propPath || RNA_property_type(propPath) != PROP_STRING) {
RNA_warning("path property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
/* Start drawing UI Elements using standard defines */
- row= uiLayoutRow(layout, 1);
+ row = uiLayoutRow(layout, 1);
/* Path (existing string) Widget */
uiItemR(row, ptr, propname, 0, text, ICON_RNA);
@@ -643,13 +643,13 @@ static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v)
{
Scene *scene = CTX_data_scene(C);
Object *ob = ob_v;
- ModifierData *md= md_v;
+ ModifierData *md = md_v;
int i, cageIndex = modifiers_getCageIndex(scene, ob, NULL, 0);
/* undo button operation */
md->mode ^= eModifierMode_OnCage;
- for (i = 0, md=ob->modifiers.first; md; ++i, md=md->next) {
+ for (i = 0, md = ob->modifiers.first; md; ++i, md = md->next) {
if (md == md_v) {
if (i >= cageIndex)
md->mode ^= eModifierMode_OnCage;
@@ -657,7 +657,7 @@ static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v)
}
}
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
@@ -676,7 +676,7 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v)
ob->partype = PAROBJECT;
- WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
ED_undo_push(C, "Modifier convert to real");
@@ -697,7 +697,7 @@ static int modifier_is_simulation(ModifierData *md)
{
/* Physic Tab */
if (ELEM7(md->type, eModifierType_Cloth, eModifierType_Collision, eModifierType_Fluidsim, eModifierType_Smoke,
- eModifierType_Softbody, eModifierType_Surface, eModifierType_DynamicPaint))
+ eModifierType_Softbody, eModifierType_Surface, eModifierType_DynamicPaint))
{
return 1;
}
@@ -718,30 +718,30 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
uiBut *but;
uiBlock *block;
uiLayout *box, *column, *row;
- uiLayout *result= NULL;
+ uiLayout *result = NULL;
int isVirtual = (md->mode & eModifierMode_Virtual);
char str[128];
/* create RNA pointer */
RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr);
- column= uiLayoutColumn(layout, 1);
+ column = uiLayoutColumn(layout, 1);
uiLayoutSetContextPointer(column, "modifier", &ptr);
/* rounded header ------------------------------------------------------------------- */
- box= uiLayoutBox(column);
+ box = uiLayoutBox(column);
if (isVirtual) {
- row= uiLayoutRow(box, 0);
+ row = uiLayoutRow(box, 0);
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_EXPAND);
- block= uiLayoutGetBlock(row);
+ block = uiLayoutGetBlock(row);
/* VIRTUAL MODIFIER */
// XXX this is not used now, since these cannot be accessed via RNA
BLI_snprintf(str, sizeof(str), "%s parent deform", md->name);
uiDefBut(block, LABEL, 0, str, 0, 0, 185, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, "Modifier name");
but = uiDefBut(block, BUT, 0, IFACE_("Make Real"), 0, 0, 80, 16, NULL, 0.0, 0.0, 0.0, 0.0,
- TIP_("Convert virtual modifier to a real modifier"));
+ TIP_("Convert virtual modifier to a real modifier"));
uiButSetFunc(but, modifiers_convertToReal, ob, md);
}
else {
@@ -763,8 +763,8 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
/* mode enabling buttons */
uiBlockBeginAlign(block);
/* Softbody not allowed in this situation, enforce! */
- if ( ((md->type!=eModifierType_Softbody && md->type!=eModifierType_Collision) || !(ob->pd && ob->pd->deflect))
- && (md->type!=eModifierType_Surface) )
+ if ( ((md->type != eModifierType_Softbody && md->type != eModifierType_Collision) || !(ob->pd && ob->pd->deflect))
+ && (md->type != eModifierType_Surface) )
{
uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE);
uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE);
@@ -773,11 +773,11 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
uiItemR(row, &ptr, "show_in_editmode", 0, "", ICON_NONE);
}
- if (ob->type==OB_MESH) {
+ if (ob->type == OB_MESH) {
if (modifier_couldBeCage(scene, md) && (index <= lastCageIndex)) {
/* -- convert to rna ? */
- but = uiDefIconButBitI(block, TOG, eModifierMode_OnCage, 0, ICON_MESH_DATA, 0, 0, UI_UNIT_X-2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0,
- TIP_("Apply modifier to editing cage during Editmode"));
+ but = uiDefIconButBitI(block, TOG, eModifierMode_OnCage, 0, ICON_MESH_DATA, 0, 0, UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0,
+ TIP_("Apply modifier to editing cage during Editmode"));
if (index < cageIndex)
uiButSetFlag(but, UI_BUT_DISABLED);
uiButSetFunc(but, modifiers_setOnCage, ob, md);
@@ -787,7 +787,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
/* place holder button */
uiBlockSetEmboss(block, UI_EMBOSSN);
- but = uiDefIconBut(block, BUT, 0, ICON_NONE, 0, 0, UI_UNIT_X-2, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, NULL);
+ but = uiDefIconBut(block, BUT, 0, ICON_NONE, 0, 0, UI_UNIT_X - 2, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, NULL);
uiButSetFlag(but, UI_BUT_DISABLED);
uiBlockSetEmboss(block, UI_EMBOSS);
}
@@ -797,8 +797,8 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
if (ELEM3(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) {
/* add disabled pre-tessellated button, so users could have
* message for this modifiers */
- but = uiDefIconButBitI(block, TOG, eModifierMode_ApplyOnSpline, 0, ICON_SURFACE_DATA, 0, 0, UI_UNIT_X-2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0,
- TIP_("This modifier could be applied on splines' points only"));
+ but = uiDefIconButBitI(block, TOG, eModifierMode_ApplyOnSpline, 0, ICON_SURFACE_DATA, 0, 0, UI_UNIT_X - 2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0,
+ TIP_("This modifier could be applied on splines' points only"));
uiButSetFlag(but, UI_BUT_DISABLED);
}
else if (mti->type != eModifierTypeType_Constructive) {
@@ -830,15 +830,15 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
/* modifier settings (under the header) --------------------------------------------------- */
if (!isVirtual && (md->mode & eModifierMode_Expanded)) {
/* apply/convert/copy */
- box= uiLayoutBox(column);
- row= uiLayoutRow(box, 0);
+ box = uiLayoutBox(column);
+ row = uiLayoutRow(box, 0);
if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) {
/* only here obdata, the rest of modifiers is ob level */
uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
- if (md->type==eModifierType_ParticleSystem) {
- ParticleSystem *psys= ((ParticleSystemModifierData *)md)->psys;
+ if (md->type == eModifierType_ParticleSystem) {
+ ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys;
if (!(ob->mode & OB_MODE_PARTICLE_EDIT) && psys->pathcache) {
if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB))
@@ -863,8 +863,8 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob,
}
/* result is the layout block inside the box, that we return so that modifier settings can be drawn */
- result= uiLayoutColumn(box, 0);
- block= uiLayoutAbsoluteBlock(box);
+ result = uiLayoutColumn(box, 0);
+ block = uiLayoutAbsoluteBlock(box);
}
/* error messages */
@@ -890,8 +890,8 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
return NULL;
}
- ob= ptr->id.data;
- md= ptr->data;
+ ob = ptr->id.data;
+ md = ptr->data;
if (!ob || !(GS(ob->id.name) == ID_OB)) {
RNA_warning("Expected modifier on object");
@@ -906,7 +906,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
// XXX virtual modifiers are not accesible for python
vmd = modifiers_getVirtualModifierList(ob);
- for (i=0; vmd; i++, vmd=vmd->next) {
+ for (i = 0; vmd; i++, vmd = vmd->next) {
if (md == vmd)
return draw_modifier(layout, scene, ob, md, i, cageIndex, lastCageIndex);
else if (vmd->mode & eModifierMode_Virtual)
@@ -923,30 +923,30 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
#include "BKE_action.h"
#include "BKE_constraint.h"
-#define REDRAWIPO 1
-#define REDRAWNLA 2
-#define REDRAWBUTSOBJECT 3
-#define REDRAWACTION 4
-#define B_CONSTRAINT_TEST 5
-#define B_CONSTRAINT_CHANGETARGET 6
-#define REMAKEIPO 8
-#define B_DIFF 9
+#define REDRAWIPO 1
+#define REDRAWNLA 2
+#define REDRAWBUTSOBJECT 3
+#define REDRAWACTION 4
+#define B_CONSTRAINT_TEST 5
+#define B_CONSTRAINT_CHANGETARGET 6
+#define REMAKEIPO 8
+#define B_DIFF 9
static void do_constraint_panels(bContext *C, void *ob_pt, int event)
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
- Object *ob= (Object *)ob_pt;
-
- switch(event) {
- case B_CONSTRAINT_TEST:
- break; // no handling
- case B_CONSTRAINT_CHANGETARGET:
- if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels
- DAG_scene_sort(bmain, scene);
- break;
- default:
- break;
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = (Object *)ob_pt;
+
+ switch (event) {
+ case B_CONSTRAINT_TEST:
+ break; // no handling
+ case B_CONSTRAINT_CHANGETARGET:
+ if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels
+ DAG_scene_sort(bmain, scene);
+ break;
+ default:
+ break;
}
// note: RNA updates now call this, commenting else it gets called twice.
@@ -955,10 +955,10 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event)
// object_test_constraints(ob);
// if (ob->pose) update_pose_constraint_flags(ob->pose);
- if (ob->type==OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB);
+ if (ob->type == OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
else DAG_id_tag_update(&ob->id, OB_RECALC_OB);
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
}
static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v)
@@ -969,17 +969,17 @@ static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v)
/* draw panel showing settings for a constraint */
static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
{
- bPoseChannel *pchan= get_active_posechannel(ob);
+ bPoseChannel *pchan = get_active_posechannel(ob);
bConstraintTypeInfo *cti;
uiBlock *block;
- uiLayout *result= NULL, *col, *box, *row;
+ uiLayout *result = NULL, *col, *box, *row;
PointerRNA ptr;
char typestr[32];
- short proxy_protected, xco=0, yco=0;
+ short proxy_protected, xco = 0, yco = 0;
// int rb_col; // UNUSED
/* get constraint typeinfo */
- cti= constraint_get_typeinfo(con);
+ cti = constraint_get_typeinfo(con);
if (cti == NULL) {
/* exception for 'Null' constraint - it doesn't have constraint typeinfo! */
BLI_strncpy(typestr, (con->type == CONSTRAINT_TYPE_NULL) ? "Null" : "Unknown", sizeof(typestr));
@@ -989,23 +989,23 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
/* determine whether constraint is proxy protected or not */
if (proxylocked_constraints_owner(ob, pchan))
- proxy_protected= (con->flag & CONSTRAINT_PROXY_LOCAL)==0;
+ proxy_protected = (con->flag & CONSTRAINT_PROXY_LOCAL) == 0;
else
- proxy_protected= 0;
+ proxy_protected = 0;
/* unless button has own callback, it adds this callback to button */
- block= uiLayoutGetBlock(layout);
+ block = uiLayoutGetBlock(layout);
uiBlockSetHandleFunc(block, do_constraint_panels, ob);
uiBlockSetFunc(block, constraint_active_func, ob, con);
RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr);
- col= uiLayoutColumn(layout, 1);
+ col = uiLayoutColumn(layout, 1);
uiLayoutSetContextPointer(col, "constraint", &ptr);
- box= uiLayoutBox(col);
+ box = uiLayoutBox(col);
row = uiLayoutRow(box, 0);
- block= uiLayoutGetBlock(box);
+ block = uiLayoutGetBlock(box);
/* Draw constraint header */
@@ -1015,7 +1015,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
uiBlockSetEmboss(block, UI_EMBOSS);
/* name */
- uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, xco+10, yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
+ uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, xco + 10, yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, "");
if (con->flag & CONSTRAINT_DISABLE)
uiLayoutSetRedAlert(row, 1);
@@ -1033,8 +1033,8 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
uiBlockSetEmboss(block, UI_EMBOSSN);
/* draw a ghost icon (for proxy) and also a lock beside it, to show that constraint is "proxy locked" */
- uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_GHOST, xco+244, yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
- uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco+262, yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
+ uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_GHOST, xco + 244, yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
+ uiDefIconBut(block, BUT, B_CONSTRAINT_TEST, ICON_LOCKED, xco + 262, yco, 19, 19, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Proxy Protected"));
uiBlockSetEmboss(block, UI_EMBOSS);
}
@@ -1046,20 +1046,20 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
* as that poses problems when restoring them, so disable the "up" button where
* it may cause this situation.
*
- * Up/Down buttons should only be shown (or not greyed - todo) if they serve some purpose.
+ * Up/Down buttons should only be shown (or not greyed - todo) if they serve some purpose.
*/
if (proxylocked_constraints_owner(ob, pchan)) {
if (con->prev) {
- prev_proxylock= (con->prev->flag & CONSTRAINT_PROXY_LOCAL) ? 0 : 1;
+ prev_proxylock = (con->prev->flag & CONSTRAINT_PROXY_LOCAL) ? 0 : 1;
}
else
- prev_proxylock= 0;
+ prev_proxylock = 0;
}
else
- prev_proxylock= 0;
+ prev_proxylock = 0;
- show_upbut= ((prev_proxylock == 0) && (con->prev));
- show_downbut= (con->next) ? 1 : 0;
+ show_upbut = ((prev_proxylock == 0) && (con->prev));
+ show_downbut = (con->next) ? 1 : 0;
/* enabled */
uiBlockSetEmboss(block, UI_EMBOSSN);
@@ -1094,9 +1094,9 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
(yco) -= 21;
}
else {
- box= uiLayoutBox(col);
- block= uiLayoutAbsoluteBlock(box);
- result= box;
+ box = uiLayoutBox(col);
+ block = uiLayoutAbsoluteBlock(box);
+ result = box;
}
/* clear any locks set up for proxies/lib-linking */
@@ -1116,8 +1116,8 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
return NULL;
}
- ob= ptr->id.data;
- con= ptr->data;
+ ob = ptr->id.data;
+ con = ptr->data;
if (!ob || !(GS(ob->id.name) == ID_OB)) {
RNA_warning("Expected constraint on object");
@@ -1127,8 +1127,8 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
uiBlockSetButLock(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE);
/* hrms, the temporal constraint should not draw! */
- if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
- bKinematicConstraint *data= con->data;
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
+ bKinematicConstraint *data = con->data;
if (data->flag & CONSTRAINT_IK_TEMP)
return NULL;
}
@@ -1147,9 +1147,9 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
static void do_preview_buttons(bContext *C, void *arg, int event)
{
- switch(event) {
+ switch (event) {
case B_MATPRV:
- WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, arg);
+ WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING, arg);
break;
}
}
@@ -1158,10 +1158,10 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M
{
uiLayout *row, *col;
uiBlock *block;
- Material *ma= NULL;
- Tex *tex = (Tex*)id;
+ Material *ma = NULL;
+ Tex *tex = (Tex *)id;
ID *pid, *pparent;
- short *pr_texture= NULL;
+ short *pr_texture = NULL;
PointerRNA material_ptr;
PointerRNA texture_ptr;
@@ -1171,41 +1171,41 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M
}
/* decide what to render */
- pid= id;
- pparent= NULL;
+ pid = id;
+ pparent = NULL;
if (id && (GS(id->name) == ID_TE)) {
if (parent && (GS(parent->name) == ID_MA))
- pr_texture= &((Material*)parent)->pr_texture;
+ pr_texture = &((Material *)parent)->pr_texture;
else if (parent && (GS(parent->name) == ID_WO))
- pr_texture= &((World*)parent)->pr_texture;
+ pr_texture = &((World *)parent)->pr_texture;
else if (parent && (GS(parent->name) == ID_LA))
- pr_texture= &((Lamp*)parent)->pr_texture;
+ pr_texture = &((Lamp *)parent)->pr_texture;
if (pr_texture) {
if (*pr_texture == TEX_PR_OTHER)
- pid= parent;
+ pid = parent;
else if (*pr_texture == TEX_PR_BOTH)
- pparent= parent;
+ pparent = parent;
}
}
/* layout */
- block= uiLayoutGetBlock(layout);
- row= uiLayoutRow(layout, 0);
- col= uiLayoutColumn(row, 0);
+ block = uiLayoutGetBlock(layout);
+ row = uiLayoutRow(layout, 0);
+ col = uiLayoutColumn(row, 0);
uiLayoutSetKeepAspect(col, 1);
/* add preview */
- uiDefBut(block, BUT_EXTRA, 0, "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6, pid, 0.0, 0.0, 0, 0, "");
+ uiDefBut(block, BUT_EXTRA, 0, "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6, pid, 0.0, 0.0, 0, 0, "");
uiBlockSetDrawExtraFunc(block, ED_preview_draw, pparent, slot);
uiBlockSetHandleFunc(block, do_preview_buttons, NULL);
/* add buttons */
if (pid && show_buttons) {
if (GS(pid->name) == ID_MA || (pparent && GS(pparent->name) == ID_MA)) {
- if (GS(pid->name) == ID_MA) ma= (Material*)pid;
- else ma= (Material*)pparent;
+ if (GS(pid->name) == ID_MA) ma = (Material *)pid;
+ else ma = (Material *)pparent;
/* Create RNA Pointer */
RNA_pointer_create(id, &RNA_Material, ma, &material_ptr);
@@ -1220,17 +1220,17 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M
RNA_pointer_create(id, &RNA_Texture, tex, &texture_ptr);
uiLayoutRow(layout, 1);
- uiDefButS(block, ROW, B_MATPRV, IFACE_("Texture"), 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_TEXTURE, 0, 0, "");
+ uiDefButS(block, ROW, B_MATPRV, IFACE_("Texture"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_TEXTURE, 0, 0, "");
if (GS(parent->name) == ID_MA)
- uiDefButS(block, ROW, B_MATPRV, IFACE_("Material"), 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
+ uiDefButS(block, ROW, B_MATPRV, IFACE_("Material"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
else if (GS(parent->name) == ID_LA)
- uiDefButS(block, ROW, B_MATPRV, IFACE_("Lamp"), 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
+ uiDefButS(block, ROW, B_MATPRV, IFACE_("Lamp"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
else if (GS(parent->name) == ID_WO)
- uiDefButS(block, ROW, B_MATPRV, IFACE_("World"), 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
- uiDefButS(block, ROW, B_MATPRV, IFACE_("Both"), 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_BOTH, 0, 0, "");
+ uiDefButS(block, ROW, B_MATPRV, IFACE_("World"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, "");
+ uiDefButS(block, ROW, B_MATPRV, IFACE_("Both"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, pr_texture, 10, TEX_PR_BOTH, 0, 0, "");
/* Alpha button for texture preview */
- if (*pr_texture!=TEX_PR_OTHER) {
+ if (*pr_texture != TEX_PR_OTHER) {
row = uiLayoutRow(layout, 0);
uiItemR(row, &texture_ptr, "use_preview_alpha", 0, NULL, ICON_NONE);
}
@@ -1248,7 +1248,7 @@ typedef struct RNAUpdateCb {
static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
{
- RNAUpdateCb *cb= (RNAUpdateCb*)arg_cb;
+ RNAUpdateCb *cb = (RNAUpdateCb *)arg_cb;
/* we call update here on the pointer property, this way the
* owner of the curve mapping can still define it's own update
@@ -1260,12 +1260,12 @@ static void rna_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg))
static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v)
{
- ColorBand *coba= coba_v;
- float pos= 0.5f;
+ ColorBand *coba = coba_v;
+ float pos = 0.5f;
if (coba->tot > 1) {
- if (coba->cur > 0) pos= (coba->data[coba->cur-1].pos + coba->data[coba->cur].pos) * 0.5f;
- else pos= (coba->data[coba->cur+1].pos + coba->data[coba->cur].pos) * 0.5f;
+ if (coba->cur > 0) pos = (coba->data[coba->cur - 1].pos + coba->data[coba->cur].pos) * 0.5f;
+ else pos = (coba->data[coba->cur + 1].pos + coba->data[coba->cur].pos) * 0.5f;
}
if (colorband_element_add(coba, pos)) {
@@ -1276,7 +1276,7 @@ static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v)
static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v)
{
- ColorBand *coba= coba_v;
+ ColorBand *coba = coba_v;
if (colorband_element_remove(coba, coba->cur)) {
ED_undo_push(C, "Delete colorband");
@@ -1288,19 +1288,19 @@ static void colorband_flip_cb(bContext *C, void *cb_v, void *coba_v)
{
CBData data_tmp[MAXCOLORBAND];
- ColorBand *coba= coba_v;
+ ColorBand *coba = coba_v;
int a;
- for (a=0; a<coba->tot; a++) {
- data_tmp[a]= coba->data[coba->tot - (a + 1)];
+ for (a = 0; a < coba->tot; a++) {
+ data_tmp[a] = coba->data[coba->tot - (a + 1)];
}
- for (a=0; a<coba->tot; a++) {
+ for (a = 0; a < coba->tot; a++) {
data_tmp[a].pos = 1.0f - data_tmp[a].pos;
- coba->data[a]= data_tmp[a];
+ coba->data[a] = data_tmp[a];
}
/* may as well flip the cur*/
- coba->cur= coba->tot - (coba->cur + 1);
+ coba->cur = coba->tot - (coba->cur + 1);
ED_undo_push(C, "Flip colorband");
@@ -1309,8 +1309,8 @@ static void colorband_flip_cb(bContext *C, void *cb_v, void *coba_v)
static void colorband_update_cb(bContext *UNUSED(C), void *bt_v, void *coba_v)
{
- uiBut *bt= bt_v;
- ColorBand *coba= coba_v;
+ uiBut *bt = bt_v;
+ ColorBand *coba = coba_v;
/* sneaky update here, we need to sort the colorband points to be in order,
* however the RNA pointer then is wrong, so we update it */
@@ -1323,46 +1323,46 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
{
uiBut *bt;
uiLayout *row;
- const int line1_y= yoffs + 65 + UI_UNIT_Y + 2; /* 2 for some space between the buttons */
- const int line2_y= yoffs + 65;
+ const int line1_y = yoffs + 65 + UI_UNIT_Y + 2; /* 2 for some space between the buttons */
+ const int line2_y = yoffs + 65;
- if (coba==NULL) return;
+ if (coba == NULL) return;
- bt= uiDefBut(block, BUT, 0, IFACE_("Add"), 0+xoffs,line1_y,40,UI_UNIT_Y, NULL, 0, 0, 0, 0,
- TIP_("Add a new color stop to the colorband"));
+ bt = uiDefBut(block, BUT, 0, IFACE_("Add"), 0 + xoffs, line1_y, 40, UI_UNIT_Y, NULL, 0, 0, 0, 0,
+ TIP_("Add a new color stop to the colorband"));
uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba);
- bt= uiDefBut(block, BUT, 0, IFACE_("Delete"), 45+xoffs,line1_y,45,UI_UNIT_Y, NULL, 0, 0, 0, 0,
- TIP_("Delete the active position"));
+ bt = uiDefBut(block, BUT, 0, IFACE_("Delete"), 45 + xoffs, line1_y, 45, UI_UNIT_Y, NULL, 0, 0, 0, 0,
+ TIP_("Delete the active position"));
uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba);
/* XXX, todo for later - convert to operator - campbell */
- bt= uiDefBut(block, BUT, 0, "F", 95+xoffs,line1_y,20,UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Flip colorband"));
+ bt = uiDefBut(block, BUT, 0, "F", 95 + xoffs, line1_y, 20, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Flip colorband"));
uiButSetNFunc(bt, colorband_flip_cb, MEM_dupallocN(cb), coba);
- uiDefButS(block, NUM, 0, "", 120+xoffs,line1_y,80, UI_UNIT_Y, &coba->cur, 0.0, (float)(MAX2(0, coba->tot-1)), 0, 0, TIP_("Choose active color stop"));
+ uiDefButS(block, NUM, 0, "", 120 + xoffs, line1_y, 80, UI_UNIT_Y, &coba->cur, 0.0, (float)(MAX2(0, coba->tot - 1)), 0, 0, TIP_("Choose active color stop"));
- bt= uiDefButS(block, MENU, 0, IFACE_("Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4"),
- 210+xoffs, line1_y, 90, UI_UNIT_Y, &coba->ipotype, 0.0, 0.0, 0, 0, TIP_("Set interpolation between color stops"));
+ bt = uiDefButS(block, MENU, 0, IFACE_("Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4"),
+ 210 + xoffs, line1_y, 90, UI_UNIT_Y, &coba->ipotype, 0.0, 0.0, 0, 0, TIP_("Set interpolation between color stops"));
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
uiBlockEndAlign(block);
- bt= uiDefBut(block, BUT_COLORBAND, 0, "", xoffs,line2_y,300,UI_UNIT_Y, coba, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, BUT_COLORBAND, 0, "", xoffs, line2_y, 300, UI_UNIT_Y, coba, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
if (coba->tot) {
- CBData *cbd= coba->data + coba->cur;
+ CBData *cbd = coba->data + coba->cur;
/* better to use rna so we can animate them */
PointerRNA ptr;
RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr);
- row= uiLayoutRow(layout, 0);
+ row = uiLayoutRow(layout, 0);
uiItemR(row, &ptr, "position", 0, "Pos", ICON_NONE);
- bt= block->buttons.last;
+ bt = block->buttons.last;
uiButSetFunc(bt, colorband_update_cb, bt, coba);
uiItemR(row, &ptr, "color", 0, "", ICON_NONE);
@@ -1373,33 +1373,33 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand
static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand *coba, rctf *butr, RNAUpdateCb *cb)
{
uiBut *bt;
- float unit= (butr->xmax-butr->xmin)/14.0f;
- float xs= butr->xmin;
+ float unit = (butr->xmax - butr->xmin) / 14.0f;
+ float xs = butr->xmin;
uiBlockBeginAlign(block);
- bt= uiDefBut(block, BUT, 0, IFACE_("Add"), xs,butr->ymin+UI_UNIT_Y,2.0f*unit,UI_UNIT_Y, NULL, 0, 0, 0, 0,
- TIP_("Add a new color stop to the colorband"));
+ bt = uiDefBut(block, BUT, 0, IFACE_("Add"), xs, butr->ymin + UI_UNIT_Y, 2.0f * unit, UI_UNIT_Y, NULL, 0, 0, 0, 0,
+ TIP_("Add a new color stop to the colorband"));
uiButSetNFunc(bt, colorband_add_cb, MEM_dupallocN(cb), coba);
- bt= uiDefBut(block, BUT, 0, IFACE_("Delete"), xs+2.0f*unit,butr->ymin+UI_UNIT_Y,1.5f*unit,UI_UNIT_Y, NULL, 0, 0, 0, 0,
- TIP_("Delete the active position"));
+ bt = uiDefBut(block, BUT, 0, IFACE_("Delete"), xs + 2.0f * unit, butr->ymin + UI_UNIT_Y, 1.5f * unit, UI_UNIT_Y, NULL, 0, 0, 0, 0,
+ TIP_("Delete the active position"));
uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba);
- bt= uiDefBut(block, BUT, 0, "F", xs+3.5f*unit,butr->ymin+UI_UNIT_Y,0.5f*unit,UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Flip the color ramp"));
+ bt = uiDefBut(block, BUT, 0, "F", xs + 3.5f * unit, butr->ymin + UI_UNIT_Y, 0.5f * unit, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Flip the color ramp"));
uiButSetNFunc(bt, colorband_flip_cb, MEM_dupallocN(cb), coba);
uiBlockEndAlign(block);
if (coba->tot) {
- CBData *cbd= coba->data + coba->cur;
+ CBData *cbd = coba->data + coba->cur;
PointerRNA ptr;
RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr);
uiItemR(layout, &ptr, "color", 0, "", ICON_NONE);
}
- bt= uiDefButS(block, MENU, 0, TIP_("Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4"),
- xs+10.0f*unit, butr->ymin+UI_UNIT_Y, unit*4, UI_UNIT_Y, &coba->ipotype, 0.0, 0.0, 0, 0,
- TIP_("Set interpolation between color stops"));
+ bt = uiDefButS(block, MENU, 0, TIP_("Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4"),
+ xs + 10.0f * unit, butr->ymin + UI_UNIT_Y, unit * 4, UI_UNIT_Y, &coba->ipotype, 0.0, 0.0, 0, 0,
+ TIP_("Set interpolation between color stops"));
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
- bt= uiDefBut(block, BUT_COLORBAND, 0, "", xs,butr->ymin,butr->xmax-butr->xmin,UI_UNIT_Y, coba, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, butr->ymin, butr->xmax - butr->xmin, UI_UNIT_Y, coba, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
uiBlockEndAlign(block);
@@ -1415,7 +1415,7 @@ static void colorband_buttons_layout(uiLayout *layout, uiBlock *block, ColorBand
void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname, int expand)
{
- PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
PointerRNA cptr;
RNAUpdateCb *cb;
uiBlock *block;
@@ -1424,18 +1424,18 @@ void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname
if (!prop || RNA_property_type(prop) != PROP_POINTER)
return;
- cptr= RNA_property_pointer_get(ptr, prop);
+ cptr = RNA_property_pointer_get(ptr, prop);
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_ColorRamp))
return;
- cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
- cb->ptr= *ptr;
- cb->prop= prop;
+ cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
+ cb->ptr = *ptr;
+ cb->prop = prop;
rect.xmin = 0; rect.xmax = 200;
rect.ymin = 0; rect.ymax = 190;
- block= uiLayoutAbsoluteBlock(layout);
+ block = uiLayoutAbsoluteBlock(layout);
colorband_buttons_layout(layout, block, cptr.data, &rect, !expand, cb);
MEM_freeN(cb);
@@ -1445,7 +1445,7 @@ void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname
void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname)
{
- PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
PointerRNA cptr;
RNAUpdateCb *cb;
uiBlock *block;
@@ -1456,25 +1456,25 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname
if (!prop || RNA_property_type(prop) != PROP_POINTER)
return;
- cptr= RNA_property_pointer_get(ptr, prop);
+ cptr = RNA_property_pointer_get(ptr, prop);
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Histogram))
return;
- cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
- cb->ptr= *ptr;
- cb->prop= prop;
+ cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
+ cb->ptr = *ptr;
+ cb->prop = prop;
rect.xmin = 0; rect.xmax = 200;
rect.ymin = 0; rect.ymax = 190;
- block= uiLayoutAbsoluteBlock(layout);
+ block = uiLayoutAbsoluteBlock(layout);
//colorband_buttons_layout(layout, block, cptr.data, &rect, !expand, cb);
hist = (Histogram *)cptr.data;
- hist->height= (hist->height<=UI_UNIT_Y)?UI_UNIT_Y:hist->height;
+ hist->height = (hist->height <= UI_UNIT_Y) ? UI_UNIT_Y : hist->height;
- bt= uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, hist->height, hist, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, HISTOGRAM, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, hist->height, hist, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
MEM_freeN(cb);
@@ -1484,7 +1484,7 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname
void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname)
{
- PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
PointerRNA cptr;
RNAUpdateCb *cb;
uiBlock *block;
@@ -1495,23 +1495,23 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname)
if (!prop || RNA_property_type(prop) != PROP_POINTER)
return;
- cptr= RNA_property_pointer_get(ptr, prop);
+ cptr = RNA_property_pointer_get(ptr, prop);
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes))
return;
scopes = (Scopes *)cptr.data;
- cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
- cb->ptr= *ptr;
- cb->prop= prop;
+ cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
+ cb->ptr = *ptr;
+ cb->prop = prop;
rect.xmin = 0; rect.xmax = 200;
rect.ymin = 0; rect.ymax = 190;
- block= uiLayoutAbsoluteBlock(layout);
+ block = uiLayoutAbsoluteBlock(layout);
- scopes->wavefrm_height= (scopes->wavefrm_height<=UI_UNIT_Y)?UI_UNIT_Y:scopes->wavefrm_height;
+ scopes->wavefrm_height = (scopes->wavefrm_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->wavefrm_height;
- bt= uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->wavefrm_height, scopes, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, WAVEFORM, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, scopes->wavefrm_height, scopes, 0, 0, 0, 0, "");
(void)bt; // UNUSED
MEM_freeN(cb);
@@ -1521,7 +1521,7 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname)
void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propname)
{
- PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
PointerRNA cptr;
RNAUpdateCb *cb;
uiBlock *block;
@@ -1532,23 +1532,23 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna
if (!prop || RNA_property_type(prop) != PROP_POINTER)
return;
- cptr= RNA_property_pointer_get(ptr, prop);
+ cptr = RNA_property_pointer_get(ptr, prop);
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes))
return;
scopes = (Scopes *)cptr.data;
- cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
- cb->ptr= *ptr;
- cb->prop= prop;
+ cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
+ cb->ptr = *ptr;
+ cb->prop = prop;
rect.xmin = 0; rect.xmax = 200;
rect.ymin = 0; rect.ymax = 190;
- block= uiLayoutAbsoluteBlock(layout);
+ block = uiLayoutAbsoluteBlock(layout);
- scopes->vecscope_height= (scopes->vecscope_height<=UI_UNIT_Y)?UI_UNIT_Y:scopes->vecscope_height;
+ scopes->vecscope_height = (scopes->vecscope_height <= UI_UNIT_Y) ? UI_UNIT_Y : scopes->vecscope_height;
- bt= uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->vecscope_height, scopes, 0, 0, 0, 0, "");
+ bt = uiDefBut(block, VECTORSCOPE, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, scopes->vecscope_height, scopes, 0, 0, 0, 0, "");
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
MEM_freeN(cb);
@@ -1563,13 +1563,13 @@ static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(ar
float d;
/* we allow 20 times zoom */
- if ( (cumap->curr.xmax - cumap->curr.xmin) > 0.04f*(cumap->clipr.xmax - cumap->clipr.xmin) ) {
- d= 0.1154f*(cumap->curr.xmax - cumap->curr.xmin);
- cumap->curr.xmin+= d;
- cumap->curr.xmax-= d;
- d= 0.1154f*(cumap->curr.ymax - cumap->curr.ymin);
- cumap->curr.ymin+= d;
- cumap->curr.ymax-= d;
+ if ( (cumap->curr.xmax - cumap->curr.xmin) > 0.04f * (cumap->clipr.xmax - cumap->clipr.xmin) ) {
+ d = 0.1154f * (cumap->curr.xmax - cumap->curr.xmin);
+ cumap->curr.xmin += d;
+ cumap->curr.xmax -= d;
+ d = 0.1154f * (cumap->curr.ymax - cumap->curr.ymin);
+ cumap->curr.ymin += d;
+ cumap->curr.ymax -= d;
}
ED_region_tag_redraw(CTX_wm_region(C));
@@ -1581,32 +1581,32 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u
float d, d1;
/* we allow 20 times zoom, but don't view outside clip */
- if ( (cumap->curr.xmax - cumap->curr.xmin) < 20.0f*(cumap->clipr.xmax - cumap->clipr.xmin) ) {
- d= d1= 0.15f*(cumap->curr.xmax - cumap->curr.xmin);
+ if ( (cumap->curr.xmax - cumap->curr.xmin) < 20.0f * (cumap->clipr.xmax - cumap->clipr.xmin) ) {
+ d = d1 = 0.15f * (cumap->curr.xmax - cumap->curr.xmin);
if (cumap->flag & CUMA_DO_CLIP)
- if (cumap->curr.xmin-d < cumap->clipr.xmin)
- d1= cumap->curr.xmin - cumap->clipr.xmin;
- cumap->curr.xmin-= d1;
+ if (cumap->curr.xmin - d < cumap->clipr.xmin)
+ d1 = cumap->curr.xmin - cumap->clipr.xmin;
+ cumap->curr.xmin -= d1;
- d1= d;
+ d1 = d;
if (cumap->flag & CUMA_DO_CLIP)
- if (cumap->curr.xmax+d > cumap->clipr.xmax)
- d1= -cumap->curr.xmax + cumap->clipr.xmax;
- cumap->curr.xmax+= d1;
+ if (cumap->curr.xmax + d > cumap->clipr.xmax)
+ d1 = -cumap->curr.xmax + cumap->clipr.xmax;
+ cumap->curr.xmax += d1;
- d= d1= 0.15f*(cumap->curr.ymax - cumap->curr.ymin);
+ d = d1 = 0.15f * (cumap->curr.ymax - cumap->curr.ymin);
if (cumap->flag & CUMA_DO_CLIP)
- if (cumap->curr.ymin-d < cumap->clipr.ymin)
- d1= cumap->curr.ymin - cumap->clipr.ymin;
- cumap->curr.ymin-= d1;
+ if (cumap->curr.ymin - d < cumap->clipr.ymin)
+ d1 = cumap->curr.ymin - cumap->clipr.ymin;
+ cumap->curr.ymin -= d1;
- d1= d;
+ d1 = d;
if (cumap->flag & CUMA_DO_CLIP)
- if (cumap->curr.ymax+d > cumap->clipr.ymax)
- d1= -cumap->curr.ymax + cumap->clipr.ymax;
- cumap->curr.ymax+= d1;
+ if (cumap->curr.ymax + d > cumap->clipr.ymax)
+ d1 = -cumap->curr.ymax + cumap->clipr.ymax;
+ cumap->curr.ymax += d1;
}
ED_region_tag_redraw(CTX_wm_region(C));
@@ -1623,7 +1623,7 @@ static void curvemap_buttons_delete(bContext *C, void *cb_v, void *cumap_v)
{
CurveMapping *cumap = cumap_v;
- curvemap_remove(cumap->cm+cumap->cur, SELECT);
+ curvemap_remove(cumap->cm + cumap->cur, SELECT);
curvemapping_changed(cumap, 0);
rna_update_cb(C, cb_v, NULL);
@@ -1635,22 +1635,22 @@ static uiBlock *curvemap_clipping_func(bContext *C, struct ARegion *ar, void *cu
CurveMapping *cumap = cumap_v;
uiBlock *block;
uiBut *bt;
- float width= 8*UI_UNIT_X;
+ float width = 8 * UI_UNIT_X;
block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
/* use this for a fake extra empy space around the buttons */
- uiDefBut(block, LABEL, 0, "", -4, 16, width+8, 6*UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+ uiDefBut(block, LABEL, 0, "", -4, 16, width + 8, 6 * UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
- bt= uiDefButBitI(block, TOG, CUMA_DO_CLIP, 1, "Use Clipping",
- 0,5*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->flag, 0.0, 0.0, 10, 0, "");
+ bt = uiDefButBitI(block, TOG, CUMA_DO_CLIP, 1, "Use Clipping",
+ 0, 5 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->flag, 0.0, 0.0, 10, 0, "");
uiButSetFunc(bt, curvemap_buttons_setclip, cumap, NULL);
uiBlockBeginAlign(block);
- uiDefButF(block, NUM, 0, IFACE_("Min X "), 0,4*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 0, "");
- uiDefButF(block, NUM, 0, IFACE_("Min Y "), 0,3*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 0, "");
- uiDefButF(block, NUM, 0, IFACE_("Max X "), 0,2*UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 0, "");
- uiDefButF(block, NUM, 0, IFACE_("Max Y "), 0,UI_UNIT_Y,width,UI_UNIT_Y, &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 0, "");
+ uiDefButF(block, NUM, 0, IFACE_("Min X "), 0, 4 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->clipr.xmin, -100.0, cumap->clipr.xmax, 10, 0, "");
+ uiDefButF(block, NUM, 0, IFACE_("Min Y "), 0, 3 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->clipr.ymin, -100.0, cumap->clipr.ymax, 10, 0, "");
+ uiDefButF(block, NUM, 0, IFACE_("Max X "), 0, 2 * UI_UNIT_Y, width, UI_UNIT_Y, &cumap->clipr.xmax, cumap->clipr.xmin, 100.0, 10, 0, "");
+ uiDefButF(block, NUM, 0, IFACE_("Max Y "), 0, UI_UNIT_Y, width, UI_UNIT_Y, &cumap->clipr.ymax, cumap->clipr.ymin, 100.0, 10, 0, "");
uiBlockSetDirection(block, UI_RIGHT);
@@ -1661,17 +1661,17 @@ static uiBlock *curvemap_clipping_func(bContext *C, struct ARegion *ar, void *cu
static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
{
CurveMapping *cumap = cumap_v;
- CurveMap *cuma= cumap->cm+cumap->cur;
+ CurveMap *cuma = cumap->cm + cumap->cur;
- switch(event) {
+ switch (event) {
case 0: /* reset */
- curvemap_reset(cuma, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE);
+ curvemap_reset(cuma, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE);
curvemapping_changed(cumap, 0);
break;
case 1:
- cumap->curr= cumap->clipr;
+ cumap->curr = cumap->clipr;
break;
- case 2: /* set vector */
+ case 2: /* set vector */
curvemap_sethandle(cuma, 1);
curvemapping_changed(cumap, 0);
break;
@@ -1694,17 +1694,17 @@ static void curvemap_tools_dofunc(bContext *C, void *cumap_v, int event)
static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap_v)
{
uiBlock *block;
- short yco= 0, menuwidth=10*UI_UNIT_X;
+ short yco = 0, menuwidth = 10 * UI_UNIT_X;
- block= uiBeginBlock(C, ar, __func__, UI_EMBOSS);
+ block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v);
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Horizontal"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 4, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Extrapolated"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 5, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Horizontal"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 4, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Extend Extrapolated"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 5, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 50);
@@ -1716,15 +1716,15 @@ static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap
static uiBlock *curvemap_brush_tools_func(bContext *C, struct ARegion *ar, void *cumap_v)
{
uiBlock *block;
- short yco= 0, menuwidth=10*UI_UNIT_X;
+ short yco = 0, menuwidth = 10 * UI_UNIT_X;
- block= uiBeginBlock(C, ar, __func__, UI_EMBOSS);
+ block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v);
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Vector Handle"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 2, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Auto Handle"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 3, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset Curve"), 0, yco -= UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
uiBlockSetDirection(block, UI_RIGHT);
uiTextBoundsBlock(block, 50);
@@ -1744,11 +1744,11 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
int a;
cumap->preset = CURVE_PRESET_LINE;
- for (a=0; a<CM_TOT; a++)
- curvemap_reset(cumap->cm+a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE);
+ for (a = 0; a < CM_TOT; a++)
+ curvemap_reset(cumap->cm + a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE);
- cumap->black[0]=cumap->black[1]=cumap->black[2]= 0.0f;
- cumap->white[0]=cumap->white[1]=cumap->white[2]= 1.0f;
+ cumap->black[0] = cumap->black[1] = cumap->black[2] = 0.0f;
+ cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f;
curvemapping_set_black_white(cumap, NULL, NULL);
curvemapping_changed(cumap, 0);
@@ -1759,106 +1759,106 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v)
/* still unsure how this call evolves... we use labeltype for defining what curve-channels to show */
static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labeltype, int levels, int brush, RNAUpdateCb *cb)
{
- CurveMapping *cumap= ptr->data;
+ CurveMapping *cumap = ptr->data;
uiLayout *row, *sub, *split;
uiBlock *block;
uiBut *bt;
- float dx= UI_UNIT_X;
+ float dx = UI_UNIT_X;
int icon, size;
- int bg=-1;
+ int bg = -1;
- block= uiLayoutGetBlock(layout);
+ block = uiLayoutGetBlock(layout);
/* curve chooser */
- row= uiLayoutRow(layout, 0);
+ row = uiLayoutRow(layout, 0);
- if (labeltype=='v') {
+ if (labeltype == 'v') {
/* vector */
- sub= uiLayoutRow(row, 1);
+ sub = uiLayoutRow(row, 1);
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);
if (cumap->cm[0].curve) {
- bt= uiDefButI(block, ROW, 0, "X", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
+ bt = uiDefButI(block, ROW, 0, "X", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
}
if (cumap->cm[1].curve) {
- bt= uiDefButI(block, ROW, 0, "Y", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
+ bt = uiDefButI(block, ROW, 0, "Y", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
}
if (cumap->cm[2].curve) {
- bt= uiDefButI(block, ROW, 0, "Z", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
+ bt = uiDefButI(block, ROW, 0, "Z", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
}
}
- else if (labeltype=='c') {
+ else if (labeltype == 'c') {
/* color */
- sub= uiLayoutRow(row, 1);
+ sub = uiLayoutRow(row, 1);
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);
if (cumap->cm[3].curve) {
- bt= uiDefButI(block, ROW, 0, "C", 0, 0, dx, dx, &cumap->cur, 0.0, 3.0, 0.0, 0.0, "");
+ bt = uiDefButI(block, ROW, 0, "C", 0, 0, dx, dx, &cumap->cur, 0.0, 3.0, 0.0, 0.0, "");
uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
}
if (cumap->cm[0].curve) {
- bt= uiDefButI(block, ROW, 0, "R", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
+ bt = uiDefButI(block, ROW, 0, "R", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
}
if (cumap->cm[1].curve) {
- bt= uiDefButI(block, ROW, 0, "G", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
+ bt = uiDefButI(block, ROW, 0, "G", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
}
if (cumap->cm[2].curve) {
- bt= uiDefButI(block, ROW, 0, "B", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
+ bt = uiDefButI(block, ROW, 0, "B", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
}
}
else if (labeltype == 'h') {
/* HSV */
- sub= uiLayoutRow(row, 1);
+ sub = uiLayoutRow(row, 1);
uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT);
if (cumap->cm[0].curve) {
- bt= uiDefButI(block, ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
+ bt = uiDefButI(block, ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, "");
uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
}
if (cumap->cm[1].curve) {
- bt= uiDefButI(block, ROW, 0, "S", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
+ bt = uiDefButI(block, ROW, 0, "S", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, "");
uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
}
if (cumap->cm[2].curve) {
- bt= uiDefButI(block, ROW, 0, "V", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
+ bt = uiDefButI(block, ROW, 0, "V", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, "");
uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL);
}
}
else
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT);
- if (labeltype=='h')
+ if (labeltype == 'h')
bg = UI_GRAD_H;
/* operation buttons */
- sub= uiLayoutRow(row, 1);
+ sub = uiLayoutRow(row, 1);
uiBlockSetEmboss(block, UI_EMBOSSN);
- bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMIN, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Zoom in"));
+ bt = uiDefIconBut(block, BUT, 0, ICON_ZOOMIN, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Zoom in"));
uiButSetFunc(bt, curvemap_buttons_zoom_in, cumap, NULL);
- bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMOUT, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Zoom out"));
+ bt = uiDefIconBut(block, BUT, 0, ICON_ZOOMOUT, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Zoom out"));
uiButSetFunc(bt, curvemap_buttons_zoom_out, cumap, NULL);
if (brush)
- bt= uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, TIP_("Tools"));
+ bt = uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, TIP_("Tools"));
else
- bt= uiDefIconBlockBut(block, curvemap_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, TIP_("Tools"));
+ bt = uiDefIconBlockBut(block, curvemap_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, TIP_("Tools"));
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
- if (cumap->flag & CUMA_DO_CLIP) icon= ICON_CLIPUV_HLT; else icon= ICON_CLIPUV_DEHLT;
- bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options"));
+ if (cumap->flag & CUMA_DO_CLIP) icon = ICON_CLIPUV_HLT; else icon = ICON_CLIPUV_DEHLT;
+ bt = uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options"));
uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL);
- bt= uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete points"));
+ bt = uiDefIconBut(block, BUT, 0, ICON_X, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete points"));
uiButSetNFunc(bt, curvemap_buttons_delete, MEM_dupallocN(cb), cumap);
uiBlockSetEmboss(block, UI_EMBOSS);
@@ -1866,19 +1866,19 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe
uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL);
/* curve itself */
- size= uiLayoutGetWidth(layout);
- row= uiLayoutRow(layout, 0);
+ size = uiLayoutGetWidth(layout);
+ row = uiLayoutRow(layout, 0);
uiDefBut(block, BUT_CURVE, 0, "", 0, 0, size, MIN2(size, 200), cumap, 0.0f, 1.0f, bg, 0, "");
/* black/white levels */
if (levels) {
- split= uiLayoutSplit(layout, 0, 0);
+ split = uiLayoutSplit(layout, 0, 0);
uiItemR(uiLayoutColumn(split, 0), ptr, "black_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiItemR(uiLayoutColumn(split, 0), ptr, "white_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
uiLayoutRow(layout, 0);
- bt=uiDefBut(block, BUT, 0, IFACE_("Reset"), 0, 0, UI_UNIT_X*10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0,
- TIP_("Reset Black/White point and curves"));
+ bt = uiDefBut(block, BUT, 0, IFACE_("Reset"), 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0,
+ TIP_("Reset Black/White point and curves"));
uiButSetNFunc(bt, curvemap_buttons_reset, MEM_dupallocN(cb), cumap);
}
@@ -1888,7 +1888,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe
void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propname, int type, int levels, int brush)
{
RNAUpdateCb *cb;
- PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
PointerRNA cptr;
if (!prop) {
@@ -1903,13 +1903,13 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propn
return;
}
- cptr= RNA_property_pointer_get(ptr, prop);
+ cptr = RNA_property_pointer_get(ptr, prop);
if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping))
return;
- cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
- cb->ptr= *ptr;
- cb->prop= prop;
+ cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
+ cb->ptr = *ptr;
+ cb->prop = prop;
curvemap_buttons_layout(layout, &cptr, type, levels, brush, cb);
@@ -1918,12 +1918,12 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propn
/********************* ColorWheel Template ************************/
-#define WHEEL_SIZE 100
+#define WHEEL_SIZE 100
void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propname, int value_slider, int lock, int lock_luminosity, int cubic)
{
- PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
- uiBlock *block= uiLayoutGetBlock(layout);
+ PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
+ uiBlock *block = uiLayoutGetBlock(layout);
uiLayout *col, *row;
uiBut *but;
float softmin, softmax, step, precision;
@@ -1936,9 +1936,9 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam
RNA_property_float_ui_range(ptr, prop, &softmin, &softmax, &step, &precision);
col = uiLayoutColumn(layout, 0);
- row= uiLayoutRow(col, 1);
+ row = uiLayoutRow(col, 1);
- but = uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, 0, 0, "");
+ but = uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, 0, 0, "");
if (lock) {
but->flag |= UI_BUT_COLOR_LOCK;
@@ -1948,7 +1948,7 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam
float color[4]; /* in case of alpha */
but->flag |= UI_BUT_VEC_SIZE_LOCK;
RNA_property_float_get_array(ptr, prop, color);
- but->a2= len_v3(color);
+ but->a2 = len_v3(color);
}
if (cubic)
@@ -1957,7 +1957,7 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam
uiItemS(row);
if (value_slider)
- uiDefButR_prop(block, HSVCUBE, 0, "", WHEEL_SIZE+6, 0, 14, WHEEL_SIZE, ptr, prop, -1, softmin, softmax, UI_GRAD_V_ALT, 0, "");
+ uiDefButR_prop(block, HSVCUBE, 0, "", WHEEL_SIZE + 6, 0, 14, WHEEL_SIZE, ptr, prop, -1, softmin, softmax, UI_GRAD_V_ALT, 0, "");
}
/********************* Layer Buttons Template ************************/
@@ -1966,11 +1966,11 @@ static void handle_layer_buttons(bContext *C, void *arg1, void *arg2)
{
uiBut *but = arg1;
int cur = GET_INT_FROM_POINTER(arg2);
- wmWindow *win= CTX_wm_window(C);
- int i, tot, shift= win->eventstate->shift;
+ wmWindow *win = CTX_wm_window(C);
+ int i, tot, shift = win->eventstate->shift;
if (!shift) {
- tot= RNA_property_array_length(&but->rnapoin, but->rnaprop);
+ tot = RNA_property_array_length(&but->rnapoin, but->rnaprop);
/* Normally clicking only selects one layer */
RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, cur, TRUE);
@@ -1989,15 +1989,15 @@ static void handle_layer_buttons(bContext *C, void *arg1, void *arg2)
// the array of layer bitflags
void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname,
- PointerRNA *used_ptr, const char *used_propname, int active_layer)
+ PointerRNA *used_ptr, const char *used_propname, int active_layer)
{
uiLayout *uRow, *uCol;
- PropertyRNA *prop, *used_prop= NULL;
+ PropertyRNA *prop, *used_prop = NULL;
int groups, cols, layers;
int group, col, layer, row;
int cols_per_group = 5;
- prop= RNA_struct_find_property(ptr, propname);
+ prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
RNA_warning("layers property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
@@ -2009,12 +2009,12 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname,
* the 'remainder' is added to this, as it will be ok to have first row slightly wider if need be
* - for now, only split into groups if group will have at least 5 items
*/
- layers= RNA_property_array_length(ptr, prop);
- cols= (layers / 2) + (layers % 2);
- groups= ((cols / 2) < cols_per_group) ? (1) : (cols / cols_per_group);
+ layers = RNA_property_array_length(ptr, prop);
+ cols = (layers / 2) + (layers % 2);
+ groups = ((cols / 2) < cols_per_group) ? (1) : (cols / cols_per_group);
if (used_ptr && used_propname) {
- used_prop= RNA_struct_find_property(used_ptr, used_propname);
+ used_prop = RNA_struct_find_property(used_ptr, used_propname);
if (!used_prop) {
RNA_warning("used layers property not found: %s.%s", RNA_struct_identifier(ptr->type), used_propname);
return;
@@ -2026,19 +2026,19 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname,
/* layers are laid out going across rows, with the columns being divided into groups */
- for (group= 0; group < groups; group++) {
- uCol= uiLayoutColumn(layout, 1);
+ for (group = 0; group < groups; group++) {
+ uCol = uiLayoutColumn(layout, 1);
- for (row= 0; row < 2; row++) {
+ for (row = 0; row < 2; row++) {
uiBlock *block;
uiBut *but;
- uRow= uiLayoutRow(uCol, 1);
- block= uiLayoutGetBlock(uRow);
- layer= groups*cols_per_group*row + cols_per_group*group;
+ uRow = uiLayoutRow(uCol, 1);
+ block = uiLayoutGetBlock(uRow);
+ layer = groups * cols_per_group * row + cols_per_group * group;
/* add layers as toggle buts */
- for (col= 0; (col < cols_per_group) && (layer < layers); col++, layer++) {
+ for (col = 0; (col < cols_per_group) && (layer < layers); col++, layer++) {
int icon = 0;
int butlay = 1 << layer;
@@ -2047,9 +2047,9 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname,
else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, layer))
icon = ICON_LAYER_USED;
- but = uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, UI_UNIT_X/2, UI_UNIT_Y/2);
+ but = uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, UI_UNIT_X / 2, UI_UNIT_Y / 2);
uiButSetFunc(but, handle_layer_buttons, but, SET_INT_IN_POINTER(layer));
- but->type= TOG;
+ but->type = TOG;
}
}
}
@@ -2060,7 +2060,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname,
static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon, int big)
{
- ID *id= NULL;
+ ID *id = NULL;
int icon;
if (!itemptr->data)
@@ -2068,16 +2068,16 @@ static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon, int
/* try ID, material or texture slot */
if (RNA_struct_is_ID(itemptr->type)) {
- id= itemptr->id.data;
+ id = itemptr->id.data;
}
else if (RNA_struct_is_a(itemptr->type, &RNA_MaterialSlot)) {
- id= RNA_pointer_get(itemptr, "material").data;
+ id = RNA_pointer_get(itemptr, "material").data;
}
else if (RNA_struct_is_a(itemptr->type, &RNA_TextureSlot)) {
- id= RNA_pointer_get(itemptr, "texture").data;
+ id = RNA_pointer_get(itemptr, "texture").data;
}
else if (RNA_struct_is_a(itemptr->type, &RNA_DynamicPaintSurface)) {
- DynamicPaintSurface *surface= (DynamicPaintSurface*)itemptr->data;
+ DynamicPaintSurface *surface = (DynamicPaintSurface *)itemptr->data;
if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) return ICON_TEXTURE_SHADED;
else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) return ICON_OUTLINER_DATA_MESH;
@@ -2086,7 +2086,7 @@ static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon, int
/* get icon from ID */
if (id) {
- icon= ui_id_icon_get(C, id, big);
+ icon = ui_id_icon_get(C, id, big);
if (icon)
return icon;
@@ -2097,30 +2097,30 @@ static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon, int
static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *itemptr, int i, int rnaicon, PointerRNA *activeptr, PropertyRNA *activeprop, const char *prop_list_id)
{
- uiBlock *block= uiLayoutGetBlock(layout);
+ uiBlock *block = uiLayoutGetBlock(layout);
uiBut *but;
uiLayout *split, *overlap, *sub, *row;
char *namebuf;
const char *name;
int icon;
- overlap= uiLayoutOverlap(layout);
+ overlap = uiLayoutOverlap(layout);
/* list item behind label & other buttons */
- sub= uiLayoutRow(overlap, 0);
+ sub = uiLayoutRow(overlap, 0);
- but = uiDefButR_prop(block, LISTROW, 0, "", 0,0, UI_UNIT_X*10,UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, "");
+ but = uiDefButR_prop(block, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, "");
uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
- sub= uiLayoutRow(overlap, 0);
+ sub = uiLayoutRow(overlap, 0);
/* retrieve icon and name */
- icon= list_item_icon_get(C, itemptr, rnaicon, 0);
+ icon = list_item_icon_get(C, itemptr, rnaicon, 0);
if (icon == ICON_NONE || icon == ICON_DOT)
- icon= 0;
+ icon = 0;
- namebuf= RNA_struct_name_get_alloc(itemptr, NULL, 0, NULL);
- name= (namebuf)? namebuf: "";
+ namebuf = RNA_struct_name_get_alloc(itemptr, NULL, 0, NULL);
+ name = (namebuf) ? namebuf : "";
/* hardcoded types */
if (itemptr->type == &RNA_MeshTexturePolyLayer || itemptr->type == &RNA_MeshLoopColorLayer) {
@@ -2142,19 +2142,19 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
else if (RNA_struct_is_a(itemptr->type, &RNA_MaterialSlot)) {
/* provision to draw active node name */
Material *ma, *manode;
- Scene *scene= CTX_data_scene(C);
- Object *ob= (Object*)ptr->id.data;
- int index= (Material**)itemptr->data - ob->mat;
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = (Object *)ptr->id.data;
+ int index = (Material **)itemptr->data - ob->mat;
/* default item with material base name */
uiItemL(sub, name, icon);
- ma= give_current_material(ob, index+1);
+ ma = give_current_material(ob, index + 1);
if (ma && !scene_use_new_shading_nodes(scene)) {
- manode= give_node_material(ma);
+ manode = give_node_material(ma);
if (manode) {
char str[MAX_ID_NAME + 12];
- BLI_snprintf(str, sizeof(str), "Node %s", manode->id.name+2);
+ BLI_snprintf(str, sizeof(str), "Node %s", manode->id.name + 2);
uiItemL(sub, str, ui_id_icon_get(C, &manode->id, 1));
}
else if (ma->use_nodes) {
@@ -2163,28 +2163,28 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
}
}
else if (itemptr->type == &RNA_ShapeKey) {
- Object *ob= (Object*)activeptr->data;
- Key *key= (Key*)itemptr->id.data;
+ Object *ob = (Object *)activeptr->data;
+ Key *key = (Key *)itemptr->id.data;
- split= uiLayoutSplit(sub, 0.66f, 0);
+ split = uiLayoutSplit(sub, 0.66f, 0);
uiItemL(split, name, icon);
uiBlockSetEmboss(block, UI_EMBOSSN);
- row= uiLayoutRow(split, 1);
+ row = uiLayoutRow(split, 1);
if (i == 0 || (key->type != KEY_RELATIVE)) uiItemL(row, "", ICON_NONE);
else uiItemR(row, itemptr, "value", 0, "", ICON_NONE);
uiItemR(row, itemptr, "mute", 0, "", 0);
if ( (key->flag & KEYBLOCK_MUTE) ||
- (ob->mode == OB_MODE_EDIT && !((ob->shapeflag & OB_SHAPE_EDIT_MODE) && ob->type == OB_MESH)) )
+ (ob->mode == OB_MODE_EDIT && !((ob->shapeflag & OB_SHAPE_EDIT_MODE) && ob->type == OB_MESH)) )
{
uiLayoutSetActive(row, 0);
}
uiBlockSetEmboss(block, UI_EMBOSS);
}
else if (itemptr->type == &RNA_VertexGroup) {
- bDeformGroup *dg= (bDeformGroup *)itemptr->data;
+ bDeformGroup *dg = (bDeformGroup *)itemptr->data;
uiItemL(sub, name, icon);
/* RNA does not allow nice lock icons, use lower level buttons */
#if 0
@@ -2196,7 +2196,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
#endif
}
else if (itemptr->type == &RNA_KeyingSetPath) {
- KS_Path *ksp = (KS_Path*)itemptr->data;
+ KS_Path *ksp = (KS_Path *)itemptr->data;
/* icon needs to be the type of ID which is currently active */
RNA_enum_icon_from_value(id_type_items, ksp->idtype, &icon);
@@ -2208,25 +2208,25 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
char name_final[96];
const char *enum_name;
PropertyRNA *prop = RNA_struct_find_property(itemptr, "surface_type");
- DynamicPaintSurface *surface= (DynamicPaintSurface*)itemptr->data;
+ DynamicPaintSurface *surface = (DynamicPaintSurface *)itemptr->data;
RNA_property_enum_name(C, itemptr, prop, RNA_property_enum_get(itemptr, prop), &enum_name);
- BLI_snprintf(name_final, sizeof(name_final), "%s (%s)",name,enum_name);
+ BLI_snprintf(name_final, sizeof(name_final), "%s (%s)", name, enum_name);
uiItemL(sub, name_final, icon);
if (dynamicPaint_surfaceHasColorPreview(surface)) {
uiBlockSetEmboss(block, UI_EMBOSSN);
uiDefIconButR(block, OPTION, 0, (surface->flags & MOD_DPAINT_PREVIEW) ? ICON_RESTRICT_VIEW_OFF : ICON_RESTRICT_VIEW_ON,
- 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "show_preview", 0, 0, 0, 0, 0, NULL);
+ 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "show_preview", 0, 0, 0, 0, 0, NULL);
uiBlockSetEmboss(block, UI_EMBOSS);
}
uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "is_active", i, 0, 0, 0, 0, NULL);
}
else if (itemptr->type == &RNA_MovieTrackingObject) {
- MovieTrackingObject *tracking_object= (MovieTrackingObject*)itemptr->data;
+ MovieTrackingObject *tracking_object = (MovieTrackingObject *)itemptr->data;
- split= uiLayoutSplit(sub, 0.75f, 0);
- if (tracking_object->flag&TRACKING_OBJECT_CAMERA) {
+ split = uiLayoutSplit(sub, 0.75f, 0);
+ if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
uiItemL(split, name, ICON_CAMERA_DATA);
}
else {
@@ -2263,19 +2263,19 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
* which would obviously produce a sigsev... */
if (itemptr->type) {
/* If the special property is set for the item, and it is a collection... */
- PropertyRNA *prop_list= RNA_struct_find_property(itemptr, prop_list_id);
+ PropertyRNA *prop_list = RNA_struct_find_property(itemptr, prop_list_id);
if (prop_list && RNA_property_type(prop_list) == PROP_STRING) {
int prop_names_len;
char *prop_names = RNA_property_string_get_alloc(itemptr, prop_list, NULL, 0, &prop_names_len);
- char *prop_names_end= prop_names + prop_names_len;
- char *id= prop_names;
+ char *prop_names_end = prop_names + prop_names_len;
+ char *id = prop_names;
char *id_next;
while (id < prop_names_end) {
- if ((id_next= strchr(id, ':'))) *id_next++= '\0';
- else id_next= prop_names_end;
+ if ((id_next = strchr(id, ':'))) *id_next++ = '\0';
+ else id_next = prop_names_end;
uiItemR(row, itemptr, id, 0, NULL, 0);
- id= id_next;
+ id = id_next;
}
MEM_freeN(prop_names);
}
@@ -2283,7 +2283,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
}
else
- uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */
+ uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */
/* free name */
if (namebuf) {
@@ -2294,7 +2294,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe
void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *activeptr, const char *activepropname, const char *prop_list, int rows, int maxrows, int listtype)
{
//Scene *scene= CTX_data_scene(C);
- PropertyRNA *prop= NULL, *activeprop;
+ PropertyRNA *prop = NULL, *activeprop;
PropertyType type, activetype;
StructRNA *ptype;
uiLayout *box, *row, *col;
@@ -2303,11 +2303,11 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
Panel *pa;
const char *name;
char numstr[32];
- int rnaicon=0, icon=0, i= 0, activei= 0, len= 0, items, found, min, max;
+ int rnaicon = 0, icon = 0, i = 0, activei = 0, len = 0, items, found, min, max;
/* validate arguments */
- block= uiLayoutGetBlock(layout);
- pa= block->panel;
+ block = uiLayoutGetBlock(layout);
+ pa = block->panel;
if (!pa) {
RNA_warning("Only works inside a panel");
@@ -2318,28 +2318,28 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
return;
if (ptr->data) {
- prop= RNA_struct_find_property(ptr, propname);
+ prop = RNA_struct_find_property(ptr, propname);
if (!prop) {
RNA_warning("Property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
}
- activeprop= RNA_struct_find_property(activeptr, activepropname);
+ activeprop = RNA_struct_find_property(activeptr, activepropname);
if (!activeprop) {
RNA_warning("Property not found: %s.%s", RNA_struct_identifier(ptr->type), activepropname);
return;
}
if (prop) {
- type= RNA_property_type(prop);
+ type = RNA_property_type(prop);
if (type != PROP_COLLECTION) {
RNA_warning("uiExpected collection property");
return;
}
}
- activetype= RNA_property_type(activeprop);
+ activetype = RNA_property_type(activeprop);
if (activetype != PROP_INT) {
RNA_warning("Expected integer property");
return;
@@ -2347,27 +2347,27 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
/* get icon */
if (ptr->data && prop) {
- ptype= RNA_property_pointer_type(ptr, prop);
- rnaicon= RNA_struct_ui_icon(ptype);
+ ptype = RNA_property_pointer_type(ptr, prop);
+ rnaicon = RNA_struct_ui_icon(ptype);
}
/* get active data */
- activei= RNA_property_int_get(activeptr, activeprop);
+ activei = RNA_property_int_get(activeptr, activeprop);
if (listtype == 'i') {
- box= uiLayoutListBox(layout, ptr, prop, activeptr, activeprop);
- col= uiLayoutColumn(box, 1);
- row= uiLayoutRow(col, 0);
+ box = uiLayoutListBox(layout, ptr, prop, activeptr, activeprop);
+ col = uiLayoutColumn(box, 1);
+ row = uiLayoutRow(col, 0);
if (ptr->data && prop) {
/* create list items */
RNA_PROP_BEGIN(ptr, itemptr, prop) {
/* create button */
if (!(i % 9))
- row= uiLayoutRow(col, 0);
+ row = uiLayoutRow(col, 0);
- icon= list_item_icon_get(C, &itemptr, rnaicon, 1);
- but = uiDefIconButR_prop(block, LISTROW, 0, icon, 0,0,UI_UNIT_X*10,UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, "");
+ icon = list_item_icon_get(C, &itemptr, rnaicon, 1);
+ but = uiDefIconButR_prop(block, LISTROW, 0, icon, 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, activeptr, activeprop, 0, 0, i, 0, 0, "");
uiButSetFlag(but, UI_BUT_NO_TOOLTIP);
@@ -2379,18 +2379,18 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
else if (listtype == 'c') {
/* compact layout */
- row= uiLayoutRow(layout, 1);
+ row = uiLayoutRow(layout, 1);
if (ptr->data && prop) {
/* create list items */
RNA_PROP_BEGIN(ptr, itemptr, prop) {
- found= (activei == i);
+ found = (activei == i);
if (found) {
/* create button */
- name= RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL);
- icon= list_item_icon_get(C, &itemptr, rnaicon, 0);
- uiItemL(row, (name)? name: "", icon);
+ name = RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL);
+ icon = list_item_icon_get(C, &itemptr, rnaicon, 0);
+ uiItemL(row, (name) ? name : "", icon);
if (name) {
MEM_freeN((void *)name);
@@ -2408,45 +2408,45 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
/* next/prev button */
BLI_snprintf(numstr, sizeof(numstr), "%d :", i);
- but = uiDefIconTextButR_prop(block, NUM, 0, 0, numstr, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activeprop, 0, 0, 0, 0, 0, "");
+ but = uiDefIconTextButR_prop(block, NUM, 0, 0, numstr, 0, 0, UI_UNIT_X * 5, UI_UNIT_Y, activeptr, activeprop, 0, 0, 0, 0, 0, "");
if (i == 0)
uiButSetFlag(but, UI_BUT_DISABLED);
}
else {
/* default rows */
if (rows == 0)
- rows= 5;
+ rows = 5;
if (maxrows == 0)
maxrows = 5;
if (pa->list_grip_size != 0)
- rows= pa->list_grip_size;
+ rows = pa->list_grip_size;
/* layout */
- box= uiLayoutListBox(layout, ptr, prop, activeptr, activeprop);
- row= uiLayoutRow(box, 0);
+ box = uiLayoutListBox(layout, ptr, prop, activeptr, activeprop);
+ row = uiLayoutRow(box, 0);
col = uiLayoutColumn(row, 1);
/* init numbers */
RNA_property_int_range(activeptr, activeprop, &min, &max);
if (prop)
- len= RNA_property_collection_length(ptr, prop);
- items= CLAMPIS(len, rows, MAX2(rows, maxrows));
+ len = RNA_property_collection_length(ptr, prop);
+ items = CLAMPIS(len, rows, MAX2(rows, maxrows));
/* if list length changes and active is out of view, scroll to it */
if (pa->list_last_len != len)
- if ((activei < pa->list_scroll || activei >= pa->list_scroll+items))
- pa->list_scroll= activei;
+ if ((activei < pa->list_scroll || activei >= pa->list_scroll + items))
+ pa->list_scroll = activei;
- pa->list_scroll= MIN2(pa->list_scroll, len-items);
- pa->list_scroll= MAX2(pa->list_scroll, 0);
- pa->list_size= items;
- pa->list_last_len= len;
+ pa->list_scroll = MIN2(pa->list_scroll, len - items);
+ pa->list_scroll = MAX2(pa->list_scroll, 0);
+ pa->list_size = items;
+ pa->list_last_len = len;
if (ptr->data && prop) {
/* create list items */
RNA_PROP_BEGIN(ptr, itemptr, prop) {
- if (i >= pa->list_scroll && i<pa->list_scroll+items)
+ if (i >= pa->list_scroll && i < pa->list_scroll + items)
list_item_row(C, col, ptr, &itemptr, i, rnaicon, activeptr, activeprop, prop_list);
i++;
@@ -2455,7 +2455,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
}
/* add dummy buttons to fill space */
- while (i < pa->list_scroll+items) {
+ while (i < pa->list_scroll + items) {
if (i >= pa->list_scroll)
uiItemL(col, "", ICON_NONE);
i++;
@@ -2463,8 +2463,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
/* add scrollbar */
if (len > items) {
- col= uiLayoutColumn(row, 0);
- uiDefButI(block, SCROLL, 0, "", 0,0,UI_UNIT_X*0.75,UI_UNIT_Y*items, &pa->list_scroll, 0, len-items, items, 0, "");
+ col = uiLayoutColumn(row, 0);
+ uiDefButI(block, SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * items, &pa->list_scroll, 0, len - items, items, 0, "");
}
}
}
@@ -2473,7 +2473,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *
static void operator_call_cb(bContext *C, void *UNUSED(arg1), void *arg2)
{
- wmOperatorType *ot= arg2;
+ wmOperatorType *ot = arg2;
if (ot)
WM_operator_name_call(C, ot->idname, WM_OP_INVOKE_DEFAULT, NULL);
@@ -2481,29 +2481,29 @@ static void operator_call_cb(bContext *C, void *UNUSED(arg1), void *arg2)
static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items)
{
- GHashIterator *iter= WM_operatortype_iter();
+ GHashIterator *iter = WM_operatortype_iter();
- for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
- wmOperatorType *ot= BLI_ghashIterator_getValue(iter);
+ for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
+ wmOperatorType *ot = BLI_ghashIterator_getValue(iter);
if (BLI_strcasestr(ot->name, str)) {
- if (WM_operator_poll((bContext*)C, ot)) {
+ if (WM_operator_poll((bContext *)C, ot)) {
char name[256];
- int len= strlen(ot->name);
+ int len = strlen(ot->name);
/* display name for menu, can hold hotkey */
BLI_strncpy(name, ot->name, sizeof(name));
/* check for hotkey */
- if (len < sizeof(name)-6) {
+ if (len < sizeof(name) - 6) {
if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE,
- &name[len+1], sizeof(name)-len-1))
+ &name[len + 1], sizeof(name) - len - 1))
{
- name[len]= '|';
+ name[len] = '|';
}
}
- if (0==uiSearchItemAdd(items, name, ot, 0))
+ if (0 == uiSearchItemAdd(items, name, ot, 0))
break;
}
}
@@ -2515,29 +2515,29 @@ void uiTemplateOperatorSearch(uiLayout *layout)
{
uiBlock *block;
uiBut *but;
- static char search[256]= "";
+ static char search[256] = "";
- block= uiLayoutGetBlock(layout);
+ block = uiLayoutGetBlock(layout);
uiBlockSetCurLayout(block, layout);
- but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 0, 0, UI_UNIT_X*6, UI_UNIT_Y, 0, 0, "");
+ but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, 0, 0, "");
uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL);
}
/************************* Running Jobs Template **************************/
-#define B_STOPRENDER 1
-#define B_STOPCAST 2
-#define B_STOPANIM 3
-#define B_STOPCOMPO 4
-#define B_STOPSEQ 5
-#define B_STOPCLIP 6
+#define B_STOPRENDER 1
+#define B_STOPCAST 2
+#define B_STOPANIM 3
+#define B_STOPCOMPO 4
+#define B_STOPSEQ 5
+#define B_STOPCLIP 6
static void do_running_jobs(bContext *C, void *UNUSED(arg), int event)
{
- switch(event) {
+ switch (event) {
case B_STOPRENDER:
- G.afbreek= 1;
+ G.afbreek = 1;
break;
case B_STOPCAST:
WM_jobs_stop(CTX_wm_manager(C), CTX_wm_screen(C), NULL);
@@ -2559,62 +2559,62 @@ static void do_running_jobs(bContext *C, void *UNUSED(arg), int event)
void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
{
- bScreen *screen= CTX_wm_screen(C);
- wmWindowManager *wm= CTX_wm_manager(C);
- ScrArea *sa= CTX_wm_area(C);
+ bScreen *screen = CTX_wm_screen(C);
+ wmWindowManager *wm = CTX_wm_manager(C);
+ ScrArea *sa = CTX_wm_area(C);
uiBlock *block;
- void *owner= NULL;
+ void *owner = NULL;
int handle_event;
- block= uiLayoutGetBlock(layout);
+ block = uiLayoutGetBlock(layout);
uiBlockSetCurLayout(block, layout);
uiBlockSetHandleFunc(block, do_running_jobs, NULL);
- if (sa->spacetype==SPACE_NODE) {
+ if (sa->spacetype == SPACE_NODE) {
if (WM_jobs_test(wm, sa))
- owner = sa;
- handle_event= B_STOPCOMPO;
+ owner = sa;
+ handle_event = B_STOPCOMPO;
}
- else if (sa->spacetype==SPACE_SEQ) {
+ else if (sa->spacetype == SPACE_SEQ) {
if (WM_jobs_test(wm, sa))
owner = sa;
handle_event = B_STOPSEQ;
}
- else if (sa->spacetype==SPACE_CLIP) {
+ else if (sa->spacetype == SPACE_CLIP) {
if (WM_jobs_test(wm, sa))
- owner = sa;
- handle_event= B_STOPCLIP;
+ owner = sa;
+ handle_event = B_STOPCLIP;
}
else {
Scene *scene;
/* another scene can be rendering too, for example via compositor */
- for (scene= CTX_data_main(C)->scene.first; scene; scene= scene->id.next)
+ for (scene = CTX_data_main(C)->scene.first; scene; scene = scene->id.next)
if (WM_jobs_test(wm, scene))
break;
owner = scene;
- handle_event= B_STOPRENDER;
+ handle_event = B_STOPRENDER;
}
if (owner) {
uiLayout *ui_abs;
- ui_abs= uiLayoutAbsolute(layout, 0);
+ ui_abs = uiLayoutAbsolute(layout, 0);
(void)ui_abs; // UNUSED
uiDefIconBut(block, BUT, handle_event, ICON_PANEL_CLOSE,
- 0, UI_UNIT_Y*0.1, UI_UNIT_X*0.8, UI_UNIT_Y*0.8, NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop this job"));
+ 0, UI_UNIT_Y * 0.1, UI_UNIT_X * 0.8, UI_UNIT_Y * 0.8, NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop this job"));
uiDefBut(block, PROGRESSBAR, 0, WM_jobs_name(wm, owner),
- UI_UNIT_X, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, WM_jobs_progress(wm, owner), 0, TIP_("Progress"));
+ UI_UNIT_X, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, WM_jobs_progress(wm, owner), 0, TIP_("Progress"));
uiLayoutRow(layout, 0);
}
if (WM_jobs_test(wm, screen))
- uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0,0,85,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0,
- TIP_("Stop screencast"));
+ uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, 85, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0,
+ TIP_("Stop screencast"));
if (screen->animtimer)
- uiDefIconTextBut(block, BUT, B_STOPANIM, ICON_CANCEL, TIP_("Anim Player"), 0,0,100,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0,
- TIP_("Stop animation playback"));
+ uiDefIconTextBut(block, BUT, B_STOPANIM, ICON_CANCEL, TIP_("Anim Player"), 0, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0,
+ TIP_("Stop animation playback"));
}
/************************* Reports for Last Operator Template **************************/
@@ -2622,40 +2622,40 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C)
void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
{
ReportList *reports = CTX_wm_reports(C);
- Report *report= BKE_reports_last_displayable(reports);
+ Report *report = BKE_reports_last_displayable(reports);
ReportTimerInfo *rti;
uiLayout *ui_abs;
uiBlock *block;
uiBut *but;
- uiStyle *style= UI_GetStyle();
+ uiStyle *style = UI_GetStyle();
int width;
- int icon=0;
+ int icon = 0;
/* if the report display has timed out, don't show */
if (!reports->reporttimer) return;
- rti= (ReportTimerInfo *)reports->reporttimer->customdata;
+ rti = (ReportTimerInfo *)reports->reporttimer->customdata;
- if (!rti || rti->widthfac==0.0f || !report) return;
+ if (!rti || rti->widthfac == 0.0f || !report) return;
- ui_abs= uiLayoutAbsolute(layout, 0);
- block= uiLayoutGetBlock(ui_abs);
+ ui_abs = uiLayoutAbsolute(layout, 0);
+ block = uiLayoutGetBlock(ui_abs);
width = BLF_width(style->widget.uifont_id, report->message);
- width = MIN2(rti->widthfac*width, width);
+ width = MIN2(rti->widthfac * width, width);
width = MAX2(width, 10);
/* make a box around the report to make it stand out */
uiBlockBeginAlign(block);
- but = uiDefBut(block, ROUNDBOX, 0, "", 0, 0, UI_UNIT_X+10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+ but = uiDefBut(block, ROUNDBOX, 0, "", 0, 0, UI_UNIT_X + 10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
/* set the report's bg color in but->col - ROUNDBOX feature */
rgb_float_to_uchar(but->col, rti->col);
- but->col[3]= 255;
+ but->col[3] = 255;
- but = uiDefBut(block, ROUNDBOX, 0, "", UI_UNIT_X+10, 0, UI_UNIT_X+width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
- but->col[0]= but->col[1]= but->col[2]= FTOCHAR(rti->greyscale);
- but->col[3]= 255;
+ but = uiDefBut(block, ROUNDBOX, 0, "", UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+ but->col[0] = but->col[1] = but->col[2] = FTOCHAR(rti->greyscale);
+ but->col[3] = 255;
uiBlockEndAlign(block);
@@ -2680,14 +2680,14 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
uiBlockSetEmboss(block, UI_EMBOSS);
- uiDefBut(block, LABEL, 0, report->message, UI_UNIT_X+10, 0, UI_UNIT_X+width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+ uiDefBut(block, LABEL, 0, report->message, UI_UNIT_X + 10, 0, UI_UNIT_X + width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
}
/********************************* Keymap *************************************/
static void keymap_item_modified(bContext *UNUSED(C), void *kmi_p, void *UNUSED(unused))
{
- wmKeyMapItem *kmi = (wmKeyMapItem*)kmi_p;
+ wmKeyMapItem *kmi = (wmKeyMapItem *)kmi_p;
WM_keyconfig_update_tag(NULL, kmi);
}
@@ -2700,18 +2700,18 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title,
if (title)
uiItemL(layout, title, ICON_NONE);
- flow= uiLayoutColumnFlow(layout, 2, 0);
+ flow = uiLayoutColumnFlow(layout, 2, 0);
RNA_STRUCT_BEGIN(ptr, prop) {
- int flag= RNA_property_flag(prop);
+ int flag = RNA_property_flag(prop);
if (flag & PROP_HIDDEN)
continue;
/* recurse for nested properties */
if (RNA_property_type(prop) == PROP_POINTER) {
- PointerRNA propptr= RNA_property_pointer_get(ptr, prop);
- const char *name= RNA_property_ui_name(prop);
+ PointerRNA propptr = RNA_property_pointer_get(ptr, prop);
+ const char *name = RNA_property_ui_name(prop);
if (propptr.data && RNA_struct_is_a(propptr.type, &RNA_OperatorProperties)) {
template_keymap_item_properties(layout, name, &propptr);
@@ -2727,16 +2727,16 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title,
void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr)
{
- PointerRNA propptr= RNA_pointer_get(ptr, "properties");
+ PointerRNA propptr = RNA_pointer_get(ptr, "properties");
if (propptr.data) {
- uiBut *but= uiLayoutGetBlock(layout)->buttons.last;
+ uiBut *but = uiLayoutGetBlock(layout)->buttons.last;
template_keymap_item_properties(layout, NULL, &propptr);
/* attach callbacks to compensate for missing properties update,
* we don't know which keymap (item) is being modified there */
- for (; but; but=but->next)
+ for (; but; but = but->next)
uiButSetFunc(but, keymap_item_modified, ptr->data, NULL);
}
}
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 91b37896e66..2f1075bde19 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -53,12 +53,12 @@
uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2)
{
- uiBut *but=NULL;
+ uiBut *but = NULL;
- switch(RNA_property_type(prop)) {
+ switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
{
- int arraylen= RNA_property_array_length(ptr, prop);
+ int arraylen = RNA_property_array_length(ptr, prop);
if (arraylen && index == -1)
return NULL;
@@ -74,7 +74,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
case PROP_INT:
case PROP_FLOAT:
{
- int arraylen= RNA_property_array_length(ptr, prop);
+ int arraylen = RNA_property_array_length(ptr, prop);
if (arraylen && index == -1) {
if (ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA))
@@ -105,12 +105,12 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
case PROP_POINTER: {
PointerRNA pptr;
- pptr= RNA_property_pointer_get(ptr, prop);
+ pptr = RNA_property_pointer_get(ptr, prop);
if (!pptr.type)
- pptr.type= RNA_property_pointer_type(ptr, prop);
- icon= RNA_struct_ui_icon(pptr.type);
+ pptr.type = RNA_property_pointer_type(ptr, prop);
+ icon = RNA_struct_ui_icon(pptr.type);
if (icon == ICON_DOT)
- icon= 0;
+ icon = 0;
but = uiDefIconTextButR_prop(block, IDPOIN, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL);
break;
@@ -123,7 +123,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind
break;
}
default:
- but= NULL;
+ but = NULL;
break;
}
@@ -135,47 +135,47 @@ int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, int (*check_prop)(Pointe
uiLayout *split, *col;
int flag;
const char *name;
- int tot= 0;
+ int tot = 0;
assert(ELEM3(label_align, '\0', 'H', 'V'));
RNA_STRUCT_BEGIN(ptr, prop) {
- flag= RNA_property_flag(prop);
- if (flag & PROP_HIDDEN || (check_prop && check_prop(ptr, prop)==FALSE))
+ flag = RNA_property_flag(prop);
+ if (flag & PROP_HIDDEN || (check_prop && check_prop(ptr, prop) == FALSE))
continue;
if (label_align != '\0') {
PropertyType type = RNA_property_type(prop);
int is_boolean = (type == PROP_BOOLEAN && !RNA_property_array_check(prop));
- name= RNA_property_ui_name(prop);
+ name = RNA_property_ui_name(prop);
- if (label_align=='V') {
- col= uiLayoutColumn(layout, 1);
+ if (label_align == 'V') {
+ col = uiLayoutColumn(layout, 1);
if (!is_boolean)
uiItemL(col, name, ICON_NONE);
}
- else if (label_align=='H') {
+ else if (label_align == 'H') {
split = uiLayoutSplit(layout, 0.5f, 0);
- col= uiLayoutColumn(split, 0);
- uiItemL(col, (is_boolean)? "": name, ICON_NONE);
- col= uiLayoutColumn(split, 0);
+ col = uiLayoutColumn(split, 0);
+ uiItemL(col, (is_boolean) ? "" : name, ICON_NONE);
+ col = uiLayoutColumn(split, 0);
}
else {
- col= NULL;
+ col = NULL;
}
/* may meed to add more cases here.
- * don't override enum flag names */
+ * don't override enum flag names */
/* name is shown above, empty name for button below */
- name= (flag & PROP_ENUM_FLAG || is_boolean)? NULL: "";
+ name = (flag & PROP_ENUM_FLAG || is_boolean) ? NULL : "";
}
else {
- col= layout;
- name= NULL; /* no smart label alignment, show default name with button */
+ col = layout;
+ name = NULL; /* no smart label alignment, show default name with button */
}
uiItemFullR(col, ptr, prop, -1, 0, 0, name, ICON_NONE);
@@ -194,14 +194,14 @@ int uiIconFromID(ID *id)
PointerRNA ptr;
short idcode;
- if (id==NULL)
+ if (id == NULL)
return ICON_NONE;
- idcode= GS(id->name);
+ idcode = GS(id->name);
/* exception for objects */
if (idcode == ID_OB) {
- ob= (Object*)id;
+ ob = (Object *)id;
if (ob->type == OB_EMPTY)
return ICON_EMPTY_DATA;
@@ -213,5 +213,5 @@ int uiIconFromID(ID *id)
* will set the right type, also with subclassing */
RNA_id_pointer_create(id, &ptr);
- return (ptr.type)? RNA_struct_ui_icon(ptr.type) : ICON_NONE;
+ return (ptr.type) ? RNA_struct_ui_icon(ptr.type) : ICON_NONE;
}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index b7e2ba1c179..4ecd85f62e7 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -88,7 +88,7 @@ typedef struct uiWidgetTrias {
/* max as used by round_box__edges */
#define WIDGET_CURVE_RESOLU 9
-#define WIDGET_SIZE_MAX (WIDGET_CURVE_RESOLU*4)
+#define WIDGET_SIZE_MAX (WIDGET_CURVE_RESOLU * 4)
typedef struct uiWidgetBase {
@@ -127,62 +127,70 @@ typedef struct uiWidgetType {
/* *********************** draw data ************************** */
-static float cornervec[WIDGET_CURVE_RESOLU][2]= {{0.0, 0.0}, {0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169},
-{0.707, 0.293}, {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}, {1.0, 1.0}};
+static float cornervec[WIDGET_CURVE_RESOLU][2] = {{0.0, 0.0}, {0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169},
+ {0.707, 0.293}, {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}, {1.0, 1.0}};
#define WIDGET_AA_JITTER 8
-static float jit[WIDGET_AA_JITTER][2]= {
- { 0.468813 , -0.481430}, {-0.155755 , -0.352820},
- { 0.219306 , -0.238501}, {-0.393286 , -0.110949},
- {-0.024699 , 0.013908}, { 0.343805 , 0.147431},
- {-0.272855 , 0.269918}, { 0.095909 , 0.388710}};
-
-static float num_tria_vert[3][2]= {
-{-0.352077, 0.532607}, {-0.352077, -0.549313}, {0.330000, -0.008353}};
-
-static unsigned int num_tria_face[1][3]= {
-{0, 1, 2}};
-
-static float scroll_circle_vert[16][2]= {
-{0.382684, 0.923879}, {0.000001, 1.000000}, {-0.382683, 0.923880}, {-0.707107, 0.707107},
-{-0.923879, 0.382684}, {-1.000000, 0.000000}, {-0.923880, -0.382684}, {-0.707107, -0.707107},
-{-0.382683, -0.923880}, {0.000000, -1.000000}, {0.382684, -0.923880}, {0.707107, -0.707107},
-{0.923880, -0.382684}, {1.000000, -0.000000}, {0.923880, 0.382683}, {0.707107, 0.707107}};
-
-static unsigned int scroll_circle_face[14][3]= {
-{0, 1, 2}, {2, 0, 3}, {3, 0, 15}, {3, 15, 4}, {4, 15, 14}, {4, 14, 5}, {5, 14, 13}, {5, 13, 6},
-{6, 13, 12}, {6, 12, 7}, {7, 12, 11}, {7, 11, 8}, {8, 11, 10}, {8, 10, 9}};
-
-static float menu_tria_vert[6][2]= {
-{-0.41, 0.16}, {0.41, 0.16}, {0, 0.82},
-{0, -0.82}, {-0.41, -0.16}, {0.41, -0.16}};
-
-static unsigned int menu_tria_face[2][3]= {{2, 0, 1}, {3, 5, 4}};
-
-static float check_tria_vert[6][2]= {
-{-0.578579, 0.253369}, {-0.392773, 0.412794}, {-0.004241, -0.328551},
-{-0.003001, 0.034320}, {1.055313, 0.864744}, {0.866408, 1.026895}};
-
-static unsigned int check_tria_face[4][3]= {
-{3, 2, 4}, {3, 4, 5}, {1, 0, 3}, {0, 2, 3}};
-
-GLubyte 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,
+static float jit[WIDGET_AA_JITTER][2] = {
+ { 0.468813, -0.481430}, {-0.155755, -0.352820},
+ { 0.219306, -0.238501}, {-0.393286, -0.110949},
+ {-0.024699, 0.013908}, { 0.343805, 0.147431},
+ {-0.272855, 0.269918}, { 0.095909, 0.388710}
+};
+
+static float num_tria_vert[3][2] = {
+ {-0.352077, 0.532607}, {-0.352077, -0.549313}, {0.330000, -0.008353}
+};
+
+static unsigned int num_tria_face[1][3] = {
+ {0, 1, 2}
+};
+
+static float scroll_circle_vert[16][2] = {
+ {0.382684, 0.923879}, {0.000001, 1.000000}, {-0.382683, 0.923880}, {-0.707107, 0.707107},
+ {-0.923879, 0.382684}, {-1.000000, 0.000000}, {-0.923880, -0.382684}, {-0.707107, -0.707107},
+ {-0.382683, -0.923880}, {0.000000, -1.000000}, {0.382684, -0.923880}, {0.707107, -0.707107},
+ {0.923880, -0.382684}, {1.000000, -0.000000}, {0.923880, 0.382683}, {0.707107, 0.707107}
+};
+
+static unsigned int scroll_circle_face[14][3] = {
+ {0, 1, 2}, {2, 0, 3}, {3, 0, 15}, {3, 15, 4}, {4, 15, 14}, {4, 14, 5}, {5, 14, 13}, {5, 13, 6},
+ {6, 13, 12}, {6, 12, 7}, {7, 12, 11}, {7, 11, 8}, {8, 11, 10}, {8, 10, 9}
+};
+
+static float menu_tria_vert[6][2] = {
+ {-0.41, 0.16}, {0.41, 0.16}, {0, 0.82},
+ {0, -0.82}, {-0.41, -0.16}, {0.41, -0.16}
+};
+
+static unsigned int menu_tria_face[2][3] = {{2, 0, 1}, {3, 5, 4}};
+
+static float check_tria_vert[6][2] = {
+ {-0.578579, 0.253369}, {-0.392773, 0.412794}, {-0.004241, -0.328551},
+ {-0.003001, 0.034320}, {1.055313, 0.864744}, {0.866408, 1.026895}
+};
+
+static unsigned int check_tria_face[4][3] = {
+ {3, 2, 4}, {3, 4, 5}, {1, 0, 3}, {0, 2, 3}
+};
+
+GLubyte 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)
{
- float tri_arr[3][2]= {{x1, y1}, {x2, y2}, {x3, y3}};
+ float tri_arr[3][2] = {{x1, y1}, {x2, y2}, {x3, y3}};
float color[4];
int j;
@@ -215,7 +223,7 @@ void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float m
color[3] *= 0.125f;
glColor4fv(color);
- for (j = 0; j < WIDGET_AA_JITTER; j++) {
+ for (j = 0; j < WIDGET_AA_JITTER; j++) {
glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f);
uiDrawBox(mode, minx, miny, maxx, maxy, rad);
glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f);
@@ -226,14 +234,14 @@ void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float m
static void widget_init(uiWidgetBase *wtb)
{
- wtb->totvert= wtb->halfwayvert= 0;
- wtb->tria1.tot= 0;
- wtb->tria2.tot= 0;
-
- wtb->inner= 1;
- wtb->outline= 1;
- wtb->emboss= 1;
- wtb->shadedir= 1;
+ wtb->totvert = wtb->halfwayvert = 0;
+ wtb->tria1.tot = 0;
+ wtb->tria2.tot = 0;
+
+ wtb->inner = 1;
+ wtb->outline = 1;
+ wtb->emboss = 1;
+ wtb->shadedir = 1;
}
/* helper call, makes shadow rect, with 'sun' above menu, so only shadow to left/right/bottom */
@@ -242,74 +250,74 @@ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int r
{
float vec[WIDGET_CURVE_RESOLU][2];
float minx, miny, maxx, maxy;
- int a, tot= 0;
+ int a, tot = 0;
- rad+= step;
+ rad += step;
- if (2.0f*rad > rect->ymax-rect->ymin)
- rad= 0.5f*(rect->ymax-rect->ymin);
+ if (2.0f * rad > rect->ymax - rect->ymin)
+ rad = 0.5f * (rect->ymax - rect->ymin);
- minx= rect->xmin-step;
- miny= rect->ymin-step;
- maxx= rect->xmax+step;
- maxy= rect->ymax+step;
+ minx = rect->xmin - step;
+ miny = rect->ymin - step;
+ maxx = rect->xmax + step;
+ maxy = rect->ymax + step;
/* mult */
- for (a=0; a < WIDGET_CURVE_RESOLU; a++) {
- vec[a][0]= rad*cornervec[a][0];
- vec[a][1]= rad*cornervec[a][1];
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++) {
+ vec[a][0] = rad * cornervec[a][0];
+ vec[a][1] = rad * cornervec[a][1];
}
/* start with left-top, anti clockwise */
if (roundboxalign & UI_CNR_TOP_LEFT) {
- for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
- vert[tot][0]= minx+rad-vec[a][0];
- vert[tot][1]= maxy-vec[a][1];
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
+ vert[tot][0] = minx + rad - vec[a][0];
+ vert[tot][1] = maxy - vec[a][1];
}
}
else {
- for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
- vert[tot][0]= minx;
- vert[tot][1]= maxy;
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
+ vert[tot][0] = minx;
+ vert[tot][1] = maxy;
}
}
if (roundboxalign & UI_CNR_BOTTOM_LEFT) {
- for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
- vert[tot][0]= minx+vec[a][1];
- vert[tot][1]= miny+rad-vec[a][0];
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
+ vert[tot][0] = minx + vec[a][1];
+ vert[tot][1] = miny + rad - vec[a][0];
}
}
else {
- for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
- vert[tot][0]= minx;
- vert[tot][1]= miny;
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
+ vert[tot][0] = minx;
+ vert[tot][1] = miny;
}
}
if (roundboxalign & UI_CNR_BOTTOM_RIGHT) {
- for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
- vert[tot][0]= maxx-rad+vec[a][0];
- vert[tot][1]= miny+vec[a][1];
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
+ vert[tot][0] = maxx - rad + vec[a][0];
+ vert[tot][1] = miny + vec[a][1];
}
}
else {
- for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
- vert[tot][0]= maxx;
- vert[tot][1]= miny;
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
+ vert[tot][0] = maxx;
+ vert[tot][1] = miny;
}
}
if (roundboxalign & UI_CNR_TOP_RIGHT) {
- for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
- vert[tot][0]= maxx-vec[a][1];
- vert[tot][1]= maxy-rad+vec[a][0];
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
+ vert[tot][0] = maxx - vec[a][1];
+ vert[tot][1] = maxy - rad + vec[a][0];
}
}
else {
- for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
- vert[tot][0]= maxx;
- vert[tot][1]= maxy;
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
+ vert[tot][0] = maxx;
+ vert[tot][1] = maxy;
}
}
return tot;
@@ -319,58 +327,58 @@ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int r
static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, float rad, float radi)
{
float vec[WIDGET_CURVE_RESOLU][2], veci[WIDGET_CURVE_RESOLU][2];
- float minx= rect->xmin, miny= rect->ymin, maxx= rect->xmax, maxy= rect->ymax;
- float minxi= minx + 1.0f; /* boundbox inner */
- float maxxi= maxx - 1.0f;
- float minyi= miny + 1.0f;
- float maxyi= maxy - 1.0f;
- float facxi= (maxxi!=minxi) ? 1.0f/(maxxi-minxi) : 0.0f; /* for uv, can divide by zero */
- float facyi= (maxyi!=minyi) ? 1.0f/(maxyi-minyi) : 0.0f;
- int a, tot= 0, minsize;
- const int hnum= ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT))==(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT) ||
- (roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT))==(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)) ? 1 : 2;
- const int vnum= ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT))==(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) ||
- (roundboxalign & (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT))==(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) ? 1 : 2;
-
- minsize= MIN2((rect->xmax-rect->xmin)*hnum, (rect->ymax-rect->ymin)*vnum);
-
- if (2.0f*rad > minsize)
- rad= 0.5f*minsize;
-
- if (2.0f*(radi+1.0f) > minsize)
- radi= 0.5f*minsize - 1.0f;
+ float minx = rect->xmin, miny = rect->ymin, maxx = rect->xmax, maxy = rect->ymax;
+ float minxi = minx + 1.0f; /* boundbox inner */
+ float maxxi = maxx - 1.0f;
+ float minyi = miny + 1.0f;
+ float maxyi = maxy - 1.0f;
+ float facxi = (maxxi != minxi) ? 1.0f / (maxxi - minxi) : 0.0f; /* for uv, can divide by zero */
+ float facyi = (maxyi != minyi) ? 1.0f / (maxyi - minyi) : 0.0f;
+ int a, tot = 0, minsize;
+ const int hnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT)) == (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT) ||
+ (roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)) ? 1 : 2;
+ const int vnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) ||
+ (roundboxalign & (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) == (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) ? 1 : 2;
+
+ minsize = MIN2((rect->xmax - rect->xmin) * hnum, (rect->ymax - rect->ymin) * vnum);
+
+ if (2.0f * rad > minsize)
+ rad = 0.5f * minsize;
+
+ if (2.0f * (radi + 1.0f) > minsize)
+ radi = 0.5f * minsize - 1.0f;
/* mult */
- for (a=0; a < WIDGET_CURVE_RESOLU; a++) {
- veci[a][0]= radi*cornervec[a][0];
- veci[a][1]= radi*cornervec[a][1];
- vec[a][0]= rad*cornervec[a][0];
- vec[a][1]= rad*cornervec[a][1];
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++) {
+ veci[a][0] = radi * cornervec[a][0];
+ veci[a][1] = radi * cornervec[a][1];
+ vec[a][0] = rad * cornervec[a][0];
+ vec[a][1] = rad * cornervec[a][1];
}
/* corner left-bottom */
if (roundboxalign & UI_CNR_BOTTOM_LEFT) {
- for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
- wt->inner_v[tot][0]= minxi+veci[a][1];
- wt->inner_v[tot][1]= minyi+radi-veci[a][0];
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
+ wt->inner_v[tot][0] = minxi + veci[a][1];
+ wt->inner_v[tot][1] = minyi + radi - veci[a][0];
- wt->outer_v[tot][0]= minx+vec[a][1];
- wt->outer_v[tot][1]= miny+rad-vec[a][0];
+ wt->outer_v[tot][0] = minx + vec[a][1];
+ wt->outer_v[tot][1] = miny + rad - vec[a][0];
- wt->inner_uv[tot][0]= facxi*(wt->inner_v[tot][0] - minxi);
- wt->inner_uv[tot][1]= facyi*(wt->inner_v[tot][1] - minyi);
+ wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
+ wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
}
}
else {
- wt->inner_v[tot][0]= minxi;
- wt->inner_v[tot][1]= minyi;
+ wt->inner_v[tot][0] = minxi;
+ wt->inner_v[tot][1] = minyi;
- wt->outer_v[tot][0]= minx;
- wt->outer_v[tot][1]= miny;
+ wt->outer_v[tot][0] = minx;
+ wt->outer_v[tot][1] = miny;
- wt->inner_uv[tot][0]= 0.0f;
- wt->inner_uv[tot][1]= 0.0f;
+ wt->inner_uv[tot][0] = 0.0f;
+ wt->inner_uv[tot][1] = 0.0f;
tot++;
}
@@ -378,55 +386,55 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl
/* corner right-bottom */
if (roundboxalign & UI_CNR_BOTTOM_RIGHT) {
- for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
- wt->inner_v[tot][0]= maxxi-radi+veci[a][0];
- wt->inner_v[tot][1]= minyi+veci[a][1];
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
+ wt->inner_v[tot][0] = maxxi - radi + veci[a][0];
+ wt->inner_v[tot][1] = minyi + veci[a][1];
- wt->outer_v[tot][0]= maxx-rad+vec[a][0];
- wt->outer_v[tot][1]= miny+vec[a][1];
+ wt->outer_v[tot][0] = maxx - rad + vec[a][0];
+ wt->outer_v[tot][1] = miny + vec[a][1];
- wt->inner_uv[tot][0]= facxi*(wt->inner_v[tot][0] - minxi);
- wt->inner_uv[tot][1]= facyi*(wt->inner_v[tot][1] - minyi);
+ wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
+ wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
}
}
else {
- wt->inner_v[tot][0]= maxxi;
- wt->inner_v[tot][1]= minyi;
+ wt->inner_v[tot][0] = maxxi;
+ wt->inner_v[tot][1] = minyi;
- wt->outer_v[tot][0]= maxx;
- wt->outer_v[tot][1]= miny;
+ wt->outer_v[tot][0] = maxx;
+ wt->outer_v[tot][1] = miny;
- wt->inner_uv[tot][0]= 1.0f;
- wt->inner_uv[tot][1]= 0.0f;
+ wt->inner_uv[tot][0] = 1.0f;
+ wt->inner_uv[tot][1] = 0.0f;
tot++;
}
- wt->halfwayvert= tot;
+ wt->halfwayvert = tot;
/* corner right-top */
if (roundboxalign & UI_CNR_TOP_RIGHT) {
- for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
- wt->inner_v[tot][0]= maxxi-veci[a][1];
- wt->inner_v[tot][1]= maxyi-radi+veci[a][0];
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
+ wt->inner_v[tot][0] = maxxi - veci[a][1];
+ wt->inner_v[tot][1] = maxyi - radi + veci[a][0];
- wt->outer_v[tot][0]= maxx-vec[a][1];
- wt->outer_v[tot][1]= maxy-rad+vec[a][0];
+ wt->outer_v[tot][0] = maxx - vec[a][1];
+ wt->outer_v[tot][1] = maxy - rad + vec[a][0];
- wt->inner_uv[tot][0]= facxi*(wt->inner_v[tot][0] - minxi);
- wt->inner_uv[tot][1]= facyi*(wt->inner_v[tot][1] - minyi);
+ wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
+ wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
}
}
else {
- wt->inner_v[tot][0]= maxxi;
- wt->inner_v[tot][1]= maxyi;
+ wt->inner_v[tot][0] = maxxi;
+ wt->inner_v[tot][1] = maxyi;
- wt->outer_v[tot][0]= maxx;
- wt->outer_v[tot][1]= maxy;
+ wt->outer_v[tot][0] = maxx;
+ wt->outer_v[tot][1] = maxy;
- wt->inner_uv[tot][0]= 1.0f;
- wt->inner_uv[tot][1]= 1.0f;
+ wt->inner_uv[tot][0] = 1.0f;
+ wt->inner_uv[tot][1] = 1.0f;
tot++;
}
@@ -434,40 +442,40 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl
/* corner left-top */
if (roundboxalign & UI_CNR_TOP_LEFT) {
- for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
- wt->inner_v[tot][0]= minxi+radi-veci[a][0];
- wt->inner_v[tot][1]= maxyi-veci[a][1];
+ for (a = 0; a < WIDGET_CURVE_RESOLU; a++, tot++) {
+ wt->inner_v[tot][0] = minxi + radi - veci[a][0];
+ wt->inner_v[tot][1] = maxyi - veci[a][1];
- wt->outer_v[tot][0]= minx+rad-vec[a][0];
- wt->outer_v[tot][1]= maxy-vec[a][1];
+ wt->outer_v[tot][0] = minx + rad - vec[a][0];
+ wt->outer_v[tot][1] = maxy - vec[a][1];
- wt->inner_uv[tot][0]= facxi*(wt->inner_v[tot][0] - minxi);
- wt->inner_uv[tot][1]= facyi*(wt->inner_v[tot][1] - minyi);
+ wt->inner_uv[tot][0] = facxi * (wt->inner_v[tot][0] - minxi);
+ wt->inner_uv[tot][1] = facyi * (wt->inner_v[tot][1] - minyi);
}
}
else {
- wt->inner_v[tot][0]= minxi;
- wt->inner_v[tot][1]= maxyi;
+ wt->inner_v[tot][0] = minxi;
+ wt->inner_v[tot][1] = maxyi;
- wt->outer_v[tot][0]= minx;
- wt->outer_v[tot][1]= maxy;
+ wt->outer_v[tot][0] = minx;
+ wt->outer_v[tot][1] = maxy;
- wt->inner_uv[tot][0]= 0.0f;
- wt->inner_uv[tot][1]= 1.0f;
+ wt->inner_uv[tot][0] = 0.0f;
+ wt->inner_uv[tot][1] = 1.0f;
tot++;
}
BLI_assert(tot <= WIDGET_SIZE_MAX);
- wt->totvert= tot;
+ wt->totvert = tot;
}
static void round_box_edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, float rad)
{
- round_box__edges(wt, roundboxalign, rect, rad, rad-1.0f);
+ round_box__edges(wt, roundboxalign, rect, rad, rad - 1.0f);
}
@@ -475,78 +483,78 @@ static void round_box_edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, flo
static void widget_num_tria(uiWidgetTrias *tria, rcti *rect, float triasize, char where)
{
float centx, centy, sizex, sizey, minsize;
- int a, i1=0, i2=1;
+ int a, i1 = 0, i2 = 1;
- minsize= MIN2(rect->xmax-rect->xmin, rect->ymax-rect->ymin);
+ minsize = MIN2(rect->xmax - rect->xmin, rect->ymax - rect->ymin);
/* center position and size */
- centx= (float)rect->xmin + 0.5f*minsize;
- centy= (float)rect->ymin + 0.5f*minsize;
- sizex= sizey= -0.5f*triasize*minsize;
+ centx = (float)rect->xmin + 0.5f * minsize;
+ centy = (float)rect->ymin + 0.5f * minsize;
+ sizex = sizey = -0.5f * triasize * minsize;
- if (where=='r') {
- centx= (float)rect->xmax - 0.5f*minsize;
- sizex= -sizex;
+ if (where == 'r') {
+ centx = (float)rect->xmax - 0.5f * minsize;
+ sizex = -sizex;
}
- else if (where=='t') {
- centy= (float)rect->ymax - 0.5f*minsize;
- sizey= -sizey;
- i2=0; i1= 1;
+ else if (where == 't') {
+ centy = (float)rect->ymax - 0.5f * minsize;
+ sizey = -sizey;
+ i2 = 0; i1 = 1;
}
- else if (where=='b') {
- sizex= -sizex;
- i2=0; i1= 1;
+ else if (where == 'b') {
+ sizex = -sizex;
+ i2 = 0; i1 = 1;
}
- for (a=0; a<3; a++) {
- tria->vec[a][0]= sizex*num_tria_vert[a][i1] + centx;
- tria->vec[a][1]= sizey*num_tria_vert[a][i2] + centy;
+ for (a = 0; a < 3; a++) {
+ tria->vec[a][0] = sizex * num_tria_vert[a][i1] + centx;
+ tria->vec[a][1] = sizey * num_tria_vert[a][i2] + centy;
}
- tria->tot= 1;
- tria->index= num_tria_face;
+ tria->tot = 1;
+ tria->index = num_tria_face;
}
static void widget_scroll_circle(uiWidgetTrias *tria, rcti *rect, float triasize, char where)
{
float centx, centy, sizex, sizey, minsize;
- int a, i1=0, i2=1;
+ int a, i1 = 0, i2 = 1;
- minsize= MIN2(rect->xmax-rect->xmin, rect->ymax-rect->ymin);
+ minsize = MIN2(rect->xmax - rect->xmin, rect->ymax - rect->ymin);
/* center position and size */
- centx= (float)rect->xmin + 0.5f*minsize;
- centy= (float)rect->ymin + 0.5f*minsize;
- sizex= sizey= -0.5f*triasize*minsize;
+ centx = (float)rect->xmin + 0.5f * minsize;
+ centy = (float)rect->ymin + 0.5f * minsize;
+ sizex = sizey = -0.5f * triasize * minsize;
- if (where=='r') {
- centx= (float)rect->xmax - 0.5f*minsize;
- sizex= -sizex;
+ if (where == 'r') {
+ centx = (float)rect->xmax - 0.5f * minsize;
+ sizex = -sizex;
}
- else if (where=='t') {
- centy= (float)rect->ymax - 0.5f*minsize;
- sizey= -sizey;
- i2=0; i1= 1;
+ else if (where == 't') {
+ centy = (float)rect->ymax - 0.5f * minsize;
+ sizey = -sizey;
+ i2 = 0; i1 = 1;
}
- else if (where=='b') {
- sizex= -sizex;
- i2=0; i1= 1;
+ else if (where == 'b') {
+ sizex = -sizex;
+ i2 = 0; i1 = 1;
}
- for (a=0; a<16; a++) {
- tria->vec[a][0]= sizex*scroll_circle_vert[a][i1] + centx;
- tria->vec[a][1]= sizey*scroll_circle_vert[a][i2] + centy;
+ for (a = 0; a < 16; a++) {
+ tria->vec[a][0] = sizex * scroll_circle_vert[a][i1] + centx;
+ tria->vec[a][1] = sizey * scroll_circle_vert[a][i2] + centy;
}
- tria->tot= 14;
- tria->index= scroll_circle_face;
+ tria->tot = 14;
+ tria->index = scroll_circle_face;
}
static void widget_trias_draw(uiWidgetTrias *tria)
{
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, tria->vec);
- glDrawElements(GL_TRIANGLES, tria->tot*3, GL_UNSIGNED_INT, tria->index);
+ glDrawElements(GL_TRIANGLES, tria->tot * 3, GL_UNSIGNED_INT, tria->index);
glDisableClientState(GL_VERTEX_ARRAY);
}
@@ -556,22 +564,22 @@ static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect)
int a;
/* center position and size */
- centx= rect->xmax - 0.5f*(rect->ymax-rect->ymin);
- centy= rect->ymin + 0.5f*(rect->ymax-rect->ymin);
- size= 0.4f*(rect->ymax-rect->ymin);
+ centx = rect->xmax - 0.5f * (rect->ymax - rect->ymin);
+ centy = rect->ymin + 0.5f * (rect->ymax - rect->ymin);
+ size = 0.4f * (rect->ymax - rect->ymin);
/* XXX exception */
- asp= ((float)rect->xmax-rect->xmin)/((float)rect->ymax-rect->ymin);
+ asp = ((float)rect->xmax - rect->xmin) / ((float)rect->ymax - rect->ymin);
if (asp > 1.2f && asp < 2.6f)
- centx= rect->xmax - 0.3f*(rect->ymax-rect->ymin);
+ centx = rect->xmax - 0.3f * (rect->ymax - rect->ymin);
- for (a=0; a<6; a++) {
- tria->vec[a][0]= size*menu_tria_vert[a][0] + centx;
- tria->vec[a][1]= size*menu_tria_vert[a][1] + centy;
+ for (a = 0; a < 6; a++) {
+ tria->vec[a][0] = size * menu_tria_vert[a][0] + centx;
+ tria->vec[a][1] = size * menu_tria_vert[a][1] + centy;
}
- tria->tot= 2;
- tria->index= menu_tria_face;
+ tria->tot = 2;
+ tria->index = menu_tria_face;
}
static void widget_check_trias(uiWidgetTrias *tria, rcti *rect)
@@ -580,17 +588,17 @@ static void widget_check_trias(uiWidgetTrias *tria, rcti *rect)
int a;
/* center position and size */
- centx= rect->xmin + 0.5f*(rect->ymax-rect->ymin);
- centy= rect->ymin + 0.5f*(rect->ymax-rect->ymin);
- size= 0.5f*(rect->ymax-rect->ymin);
+ centx = rect->xmin + 0.5f * (rect->ymax - rect->ymin);
+ centy = rect->ymin + 0.5f * (rect->ymax - rect->ymin);
+ size = 0.5f * (rect->ymax - rect->ymin);
- for (a=0; a<6; a++) {
- tria->vec[a][0]= size*check_tria_vert[a][0] + centx;
- tria->vec[a][1]= size*check_tria_vert[a][1] + centy;
+ for (a = 0; a < 6; a++) {
+ tria->vec[a][0] = size * check_tria_vert[a][0] + centx;
+ tria->vec[a][1] = size * check_tria_vert[a][1] + centy;
}
- tria->tot= 4;
- tria->index= check_tria_face;
+ tria->tot = 4;
+ tria->index = check_tria_face;
}
@@ -598,58 +606,58 @@ static void widget_check_trias(uiWidgetTrias *tria, rcti *rect)
static void shadecolors4(char coltop[4], char *coldown, const char *color, short shadetop, short shadedown)
{
- coltop[0]= CLAMPIS(color[0]+shadetop, 0, 255);
- coltop[1]= CLAMPIS(color[1]+shadetop, 0, 255);
- coltop[2]= CLAMPIS(color[2]+shadetop, 0, 255);
- coltop[3]= color[3];
+ coltop[0] = CLAMPIS(color[0] + shadetop, 0, 255);
+ coltop[1] = CLAMPIS(color[1] + shadetop, 0, 255);
+ coltop[2] = CLAMPIS(color[2] + shadetop, 0, 255);
+ coltop[3] = color[3];
- coldown[0]= CLAMPIS(color[0]+shadedown, 0, 255);
- coldown[1]= CLAMPIS(color[1]+shadedown, 0, 255);
- coldown[2]= CLAMPIS(color[2]+shadedown, 0, 255);
- coldown[3]= color[3];
+ coldown[0] = CLAMPIS(color[0] + shadedown, 0, 255);
+ coldown[1] = CLAMPIS(color[1] + shadedown, 0, 255);
+ coldown[2] = CLAMPIS(color[2] + shadedown, 0, 255);
+ coldown[3] = color[3];
}
static void round_box_shade_col4_r(unsigned char col_r[4], const char col1[4], const char col2[4], const float fac)
{
- const int faci= FTOCHAR(fac);
- const int facm= 255-faci;
+ const int faci = FTOCHAR(fac);
+ const int facm = 255 - faci;
- col_r[0]= (faci*col1[0] + facm*col2[0])>>8;
- col_r[1]= (faci*col1[1] + facm*col2[1])>>8;
- col_r[2]= (faci*col1[2] + facm*col2[2])>>8;
- col_r[3]= (faci*col1[3] + facm*col2[3])>>8;
+ col_r[0] = (faci * col1[0] + facm * col2[0]) >> 8;
+ col_r[1] = (faci * col1[1] + facm * col2[1]) >> 8;
+ col_r[2] = (faci * col1[2] + facm * col2[2]) >> 8;
+ col_r[3] = (faci * col1[3] + facm * col2[3]) >> 8;
}
-static void widget_verts_to_quad_strip(uiWidgetBase *wtb, const int totvert, float quad_strip[WIDGET_SIZE_MAX*2+2][2])
+static void widget_verts_to_quad_strip(uiWidgetBase *wtb, const int totvert, float quad_strip[WIDGET_SIZE_MAX * 2 + 2][2])
{
int a;
- for (a=0; a<totvert; a++) {
- copy_v2_v2(quad_strip[a*2], wtb->outer_v[a]);
- copy_v2_v2(quad_strip[a*2+1], wtb->inner_v[a]);
+ for (a = 0; a < totvert; a++) {
+ copy_v2_v2(quad_strip[a * 2], wtb->outer_v[a]);
+ copy_v2_v2(quad_strip[a * 2 + 1], wtb->inner_v[a]);
}
- copy_v2_v2(quad_strip[a*2], wtb->outer_v[0]);
- copy_v2_v2(quad_strip[a*2+1], wtb->inner_v[0]);
+ copy_v2_v2(quad_strip[a * 2], wtb->outer_v[0]);
+ copy_v2_v2(quad_strip[a * 2 + 1], wtb->inner_v[0]);
}
-static void widget_verts_to_quad_strip_open(uiWidgetBase *wtb, const int totvert, float quad_strip[WIDGET_SIZE_MAX*2][2])
+static void widget_verts_to_quad_strip_open(uiWidgetBase *wtb, const int totvert, float quad_strip[WIDGET_SIZE_MAX * 2][2])
{
int a;
- for (a=0; a<totvert; a++) {
- quad_strip[a*2][0]= wtb->outer_v[a][0];
- quad_strip[a*2][1]= wtb->outer_v[a][1];
- quad_strip[a*2+1][0]= wtb->outer_v[a][0];
- quad_strip[a*2+1][1]= wtb->outer_v[a][1] - 1.0f;
+ for (a = 0; a < totvert; a++) {
+ quad_strip[a * 2][0] = wtb->outer_v[a][0];
+ quad_strip[a * 2][1] = wtb->outer_v[a][1];
+ quad_strip[a * 2 + 1][0] = wtb->outer_v[a][0];
+ quad_strip[a * 2 + 1][1] = wtb->outer_v[a][1] - 1.0f;
}
}
static void widgetbase_outline(uiWidgetBase *wtb)
{
- float quad_strip[WIDGET_SIZE_MAX*2+2][2]; /* + 2 because the last pair is wrapped */
+ float quad_strip[WIDGET_SIZE_MAX * 2 + 2][2]; /* + 2 because the last pair is wrapped */
widget_verts_to_quad_strip(wtb, wtb->totvert, quad_strip);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, quad_strip);
- glDrawArrays(GL_QUAD_STRIP, 0, wtb->totvert*2 + 2);
+ glDrawArrays(GL_QUAD_STRIP, 0, wtb->totvert * 2 + 2);
glDisableClientState(GL_VERTEX_ARRAY);
}
@@ -661,10 +669,10 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
/* backdrop non AA */
if (wtb->inner) {
- if (wcol->shaded==0) {
+ if (wcol->shaded == 0) {
if (wcol->alpha_check) {
float inner_v_half[WIDGET_SIZE_MAX][2];
- float x_mid= 0.0f; /* used for dumb clamping of values */
+ float x_mid = 0.0f; /* used for dumb clamping of values */
/* dark checkers */
glColor4ub(UI_TRANSP_DARK, UI_TRANSP_DARK, UI_TRANSP_DARK, 255);
@@ -688,10 +696,10 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
/* alpha fill */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glColor4ubv((unsigned char*)wcol->inner);
+ glColor4ubv((unsigned char *)wcol->inner);
glEnableClientState(GL_VERTEX_ARRAY);
- for (a=0; a<wtb->totvert; a++) {
+ for (a = 0; a < wtb->totvert; a++) {
x_mid += wtb->inner_v[a][0];
}
x_mid /= wtb->totvert;
@@ -703,9 +711,9 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
/* 1/2 solid color */
glColor4ub(wcol->inner[0], wcol->inner[1], wcol->inner[2], 255);
- for (a=0; a<wtb->totvert; a++) {
- inner_v_half[a][0]= MIN2(wtb->inner_v[a][0], x_mid);
- inner_v_half[a][1]= wtb->inner_v[a][1];
+ for (a = 0; a < wtb->totvert; a++) {
+ inner_v_half[a][0] = MIN2(wtb->inner_v[a][0], x_mid);
+ inner_v_half[a][1] = wtb->inner_v[a][1];
}
glEnableClientState(GL_VERTEX_ARRAY);
@@ -715,7 +723,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
}
else {
/* simple fill */
- glColor4ubv((unsigned char*)wcol->inner);
+ glColor4ubv((unsigned char *)wcol->inner);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v);
@@ -726,12 +734,12 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
else {
char col1[4], col2[4];
unsigned char col_array[WIDGET_SIZE_MAX * 4];
- unsigned char *col_pt= col_array;
+ unsigned char *col_pt = col_array;
shadecolors4(col1, col2, wcol->inner, wcol->shadetop, wcol->shadedown);
glShadeModel(GL_SMOOTH);
- for (a=0; a<wtb->totvert; a++, col_pt += 4) {
+ for (a = 0; a < wtb->totvert; a++, col_pt += 4) {
round_box_shade_col4_r(col_pt, col1, col2, wtb->inner_uv[a][wtb->shadedir]);
}
@@ -749,8 +757,8 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
/* for each AA step */
if (wtb->outline) {
- float quad_strip[WIDGET_SIZE_MAX*2+2][2]; /* + 2 because the last pair is wrapped */
- float quad_strip_emboss[WIDGET_SIZE_MAX*2][2]; /* only for emboss */
+ float quad_strip[WIDGET_SIZE_MAX * 2 + 2][2]; /* + 2 because the last pair is wrapped */
+ float quad_strip_emboss[WIDGET_SIZE_MAX * 2][2]; /* only for emboss */
const unsigned char tcol[4] = {wcol->outline[0],
wcol->outline[1],
@@ -772,14 +780,14 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
glColor4ubv(tcol);
glVertexPointer(2, GL_FLOAT, 0, quad_strip);
- glDrawArrays(GL_QUAD_STRIP, 0, wtb->totvert*2 + 2);
+ glDrawArrays(GL_QUAD_STRIP, 0, wtb->totvert * 2 + 2);
/* emboss bottom shadow */
if (wtb->emboss) {
glColor4f(1.0f, 1.0f, 1.0f, 0.02f);
glVertexPointer(2, GL_FLOAT, 0, quad_strip_emboss);
- glDrawArrays(GL_QUAD_STRIP, 0, wtb->halfwayvert*2);
+ glDrawArrays(GL_QUAD_STRIP, 0, wtb->halfwayvert * 2);
}
glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f);
@@ -817,23 +825,23 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
/* *********************** text/icon ************************************** */
-#define PREVIEW_PAD 4
+#define PREVIEW_PAD 4
static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect)
{
int w, h, size;
- if (icon==ICON_NONE)
+ if (icon == ICON_NONE)
return;
w = rect->xmax - rect->xmin;
h = rect->ymax - rect->ymin;
size = MIN2(w, h);
- size -= PREVIEW_PAD*2; /* padding */
+ size -= PREVIEW_PAD * 2; /* padding */
if (size > 0) {
- int x = rect->xmin + w/2 - size/2;
- int y = rect->ymin + h/2 - size/2;
+ int x = rect->xmin + w / 2 - size / 2;
+ int y = rect->ymin + h / 2 - size / 2;
UI_icon_draw_preview_aspect_size(x, y, icon, 1.0f, size);
}
@@ -849,7 +857,7 @@ static int ui_but_draw_menu_icon(uiBut *but)
static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect)
{
- int xs=0, ys=0;
+ int xs = 0, ys = 0;
float aspect, height;
if (but->flag & UI_ICON_PREVIEW) {
@@ -858,67 +866,67 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect
}
/* this icon doesn't need draw... */
- if (icon==ICON_BLANK1 && (but->flag & UI_ICON_SUBMENU)==0) return;
+ if (icon == ICON_BLANK1 && (but->flag & UI_ICON_SUBMENU) == 0) return;
/* we need aspect from block, for menus... these buttons are scaled in uiPositionBlock() */
- aspect= but->block->aspect;
+ aspect = but->block->aspect;
if (aspect != but->aspect) {
/* prevent scaling up icon in pupmenu */
if (aspect < 1.0f) {
- height= UI_DPI_ICON_SIZE;
+ height = UI_DPI_ICON_SIZE;
aspect = 1.0f;
}
else
- height= UI_DPI_ICON_SIZE/aspect;
+ height = UI_DPI_ICON_SIZE / aspect;
}
else
- height= UI_DPI_ICON_SIZE;
+ height = UI_DPI_ICON_SIZE;
/* calculate blend color */
if (ELEM4(but->type, TOG, ROW, TOGN, LISTROW)) {
- if (but->flag & UI_SELECT);
- else if (but->flag & UI_ACTIVE);
- else alpha= 0.5f;
+ if (but->flag & UI_SELECT) ;
+ else if (but->flag & UI_ACTIVE) ;
+ else alpha = 0.5f;
}
/* extra feature allows more alpha blending */
- if (but->type==LABEL && but->a1==1.0f) alpha *= but->a2;
+ if (but->type == LABEL && but->a1 == 1.0f) alpha *= but->a2;
glEnable(GL_BLEND);
- if (icon && icon!=ICON_BLANK1) {
+ if (icon && icon != ICON_BLANK1) {
if (but->flag & UI_ICON_LEFT) {
- if (but->type==BUT_TOGDUAL) {
+ if (but->type == BUT_TOGDUAL) {
if (but->drawstr[0]) {
- xs= rect->xmin-1;
+ xs = rect->xmin - 1;
}
else {
- xs= (rect->xmin+rect->xmax- height)/2;
+ xs = (rect->xmin + rect->xmax - height) / 2;
}
}
else if (but->block->flag & UI_BLOCK_LOOP) {
- if (but->type==SEARCH_MENU)
- xs= rect->xmin+4;
+ if (but->type == SEARCH_MENU)
+ xs = rect->xmin + 4;
else
- xs= rect->xmin+1;
+ xs = rect->xmin + 1;
}
- else if ((but->type==ICONROW) || (but->type==ICONTEXTROW)) {
- xs= rect->xmin+3;
+ else if ((but->type == ICONROW) || (but->type == ICONTEXTROW)) {
+ xs = rect->xmin + 3;
}
else {
- xs= rect->xmin+4;
+ xs = rect->xmin + 4;
}
- ys= (rect->ymin+rect->ymax- height)/2;
+ ys = (rect->ymin + rect->ymax - height) / 2;
}
else {
- xs= (rect->xmin+rect->xmax- height)/2;
- ys= (rect->ymin+rect->ymax- height)/2;
+ xs = (rect->xmin + rect->xmax - height) / 2;
+ ys = (rect->ymin + rect->ymax - height) / 2;
}
/* to indicate draggable */
if (but->dragpoin && (but->flag & UI_ACTIVE)) {
- float rgb[3]= {1.25f, 1.25f, 1.25f};
+ float rgb[3] = {1.25f, 1.25f, 1.25f};
UI_icon_draw_aspect_color(xs, ys, icon, aspect, rgb);
}
else
@@ -926,8 +934,8 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect
}
if (ui_but_draw_menu_icon(but)) {
- xs= rect->xmax-17;
- ys= (rect->ymin+rect->ymax- height)/2;
+ xs = rect->xmax - 17;
+ ys = (rect->ymin + rect->ymax - height) / 2;
UI_icon_draw_aspect(xs, ys, ICON_RIGHTARROW_THIN, aspect, alpha);
}
@@ -954,28 +962,28 @@ static void ui_text_clip_give_next_off(uiBut *but)
/* sets but->ofs to make sure text is correctly visible */
static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
{
- int border= (but->flag & UI_BUT_ALIGN_RIGHT)? 8: 10;
- int okwidth= rect->xmax-rect->xmin - border;
+ int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
+ int okwidth = rect->xmax - rect->xmin - border;
if (but->flag & UI_HAS_ICON) okwidth -= UI_DPI_ICON_SIZE;
/* need to set this first */
uiStyleFontSet(fstyle);
- if (fstyle->kerning==1) /* for BLF_width */
+ if (fstyle->kerning == 1) /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
/* if text editing we define ofs dynamically */
if (but->editstr && but->pos >= 0) {
if (but->ofs > but->pos)
- but->ofs= but->pos;
+ but->ofs = but->pos;
if (BLF_width(fstyle->uifont_id, but->drawstr) <= okwidth)
but->ofs = 0;
}
- else but->ofs= 0;
+ else but->ofs = 0;
- but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
while (but->strwidth > okwidth) {
@@ -987,54 +995,54 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
/* copy draw string */
BLI_strncpy_utf8(buf, but->drawstr, sizeof(buf));
/* string position of cursor */
- buf[but->pos]= 0;
- width= BLF_width(fstyle->uifont_id, buf+but->ofs);
+ buf[but->pos] = 0;
+ width = BLF_width(fstyle->uifont_id, buf + but->ofs);
/* if cursor is at 20 pixels of right side button we clip left */
- if (width > okwidth-20)
+ if (width > okwidth - 20)
ui_text_clip_give_next_off(but);
else {
int len, bytes;
/* shift string to the left */
if (width < 20 && but->ofs > 0)
ui_text_clip_give_prev_off(but);
- len= strlen(but->drawstr);
- bytes= BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len));
- but->drawstr[ len-bytes ]= 0;
+ len = strlen(but->drawstr);
+ bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len));
+ but->drawstr[len - bytes] = 0;
}
}
else
ui_text_clip_give_next_off(but);
- but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
if (but->strwidth < 10) break;
}
- if (fstyle->kerning==1)
+ if (fstyle->kerning == 1)
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
}
static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
{
- int border= (but->flag & UI_BUT_ALIGN_RIGHT)? 8: 10;
- int okwidth= rect->xmax-rect->xmin - border;
- char *cpoin=NULL;
+ int border = (but->flag & UI_BUT_ALIGN_RIGHT) ? 8 : 10;
+ int okwidth = rect->xmax - rect->xmin - border;
+ char *cpoin = NULL;
char *cpend = but->drawstr + strlen(but->drawstr);
/* need to set this first */
uiStyleFontSet(fstyle);
- if (fstyle->kerning==1) /* for BLF_width */
+ if (fstyle->kerning == 1) /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
- but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr);
- but->ofs= 0;
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr);
+ but->ofs = 0;
/* find the space after ':' separator */
- cpoin= strrchr(but->drawstr, ':');
+ cpoin = strrchr(but->drawstr, ':');
- if (cpoin && (cpoin < cpend-2)) {
+ if (cpoin && (cpoin < cpend - 2)) {
char *cp2 = cpoin;
/* chop off the leading text, starting from the right */
@@ -1044,10 +1052,10 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
bytes = 1;
/* shift the text after and including cp2 back by 1 char, +1 to include null terminator */
- memmove(cp2-bytes, cp2, strlen(cp2)+1);
- cp2-=bytes;
+ memmove(cp2 - bytes, cp2, strlen(cp2) + 1);
+ cp2 -= bytes;
- but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
if (but->strwidth < 10) break;
}
@@ -1056,26 +1064,26 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
while ((but->strwidth > okwidth) && (but->ofs < 2))
{
ui_text_clip_give_next_off(but);
- but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
if (but->strwidth < 10) break;
}
}
/* once the label's gone, chop off the least significant digits */
- while (but->strwidth > okwidth ) {
- int len= strlen(but->drawstr);
- int bytes= BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len));
+ while (but->strwidth > okwidth) {
+ int len = strlen(but->drawstr);
+ int bytes = BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len));
if (bytes < 0)
bytes = 1;
- but->drawstr[ len-bytes ]= 0;
+ but->drawstr[len - bytes] = 0;
- but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
+ but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
if (but->strwidth < 10) break;
}
- if (fstyle->kerning==1)
+ if (fstyle->kerning == 1)
BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
}
@@ -1091,16 +1099,16 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
uiStyleFontSet(fstyle);
if (but->editstr || (but->flag & UI_TEXT_LEFT))
- fstyle->align= UI_STYLE_TEXT_LEFT;
+ fstyle->align = UI_STYLE_TEXT_LEFT;
else
- fstyle->align= UI_STYLE_TEXT_CENTER;
+ fstyle->align = UI_STYLE_TEXT_CENTER;
- if (fstyle->kerning==1) /* for BLF_width */
+ if (fstyle->kerning == 1) /* for BLF_width */
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
/* text button selection and cursor */
if (but->editstr && but->pos != -1) {
- short t=0, pos=0, ch;
+ short t = 0, pos = 0, ch;
short selsta_tmp, selend_tmp, selsta_draw, selwidth_draw;
if ((but->selend - but->selsta) > 0) {
@@ -1108,46 +1116,46 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
selsta_tmp = but->selsta;
selend_tmp = but->selend;
- if (but->drawstr[0]!=0) {
+ if (but->drawstr[0] != 0) {
if (but->selsta >= but->ofs) {
- ch= but->drawstr[selsta_tmp];
- but->drawstr[selsta_tmp]= 0;
+ ch = but->drawstr[selsta_tmp];
+ but->drawstr[selsta_tmp] = 0;
- selsta_draw = BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
+ selsta_draw = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
- but->drawstr[selsta_tmp]= ch;
+ but->drawstr[selsta_tmp] = ch;
}
else {
selsta_draw = 0;
}
- ch= but->drawstr[selend_tmp];
- but->drawstr[selend_tmp]= 0;
+ ch = but->drawstr[selend_tmp];
+ but->drawstr[selend_tmp] = 0;
- selwidth_draw = BLF_width(fstyle->uifont_id, but->drawstr+but->ofs);
+ selwidth_draw = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
- but->drawstr[selend_tmp]= ch;
+ but->drawstr[selend_tmp] = ch;
- glColor3ubv((unsigned char*)wcol->item);
- glRects(rect->xmin+selsta_draw, rect->ymin+2, rect->xmin+selwidth_draw, rect->ymax-2);
+ glColor3ubv((unsigned char *)wcol->item);
+ glRects(rect->xmin + selsta_draw, rect->ymin + 2, rect->xmin + selwidth_draw, rect->ymax - 2);
}
}
else {
/* text cursor */
- pos= but->pos;
+ pos = but->pos;
if (pos >= but->ofs) {
- if (but->drawstr[0]!=0) {
- ch= but->drawstr[pos];
- but->drawstr[pos]= 0;
+ if (but->drawstr[0] != 0) {
+ ch = but->drawstr[pos];
+ but->drawstr[pos] = 0;
- t= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs) / but->aspect;
+ t = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs) / but->aspect;
- but->drawstr[pos]= ch;
+ but->drawstr[pos] = ch;
}
glColor3f(0.20, 0.6, 0.9);
- glRects(rect->xmin+t, rect->ymin+2, rect->xmin+t+2, rect->ymax-2);
+ glRects(rect->xmin + t, rect->ymin + 2, rect->xmin + t + 2, rect->ymax - 2);
}
}
}
@@ -1161,15 +1169,15 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
/* cut string in 2 parts - only for menu entries */
if ((but->block->flag & UI_BLOCK_LOOP)) {
- if (ELEM5(but->type, SLI, NUM, TEX, NUMSLI, NUMABS)==0) {
- cpoin= strchr(but->drawstr, '|');
- if (cpoin) *cpoin= 0;
+ if (ELEM5(but->type, SLI, NUM, TEX, NUMSLI, NUMABS) == 0) {
+ cpoin = strchr(but->drawstr, '|');
+ if (cpoin) *cpoin = 0;
}
}
- glColor3ubv((unsigned char*)wcol->text);
+ glColor3ubv((unsigned char *)wcol->text);
- uiStyleFontDrawExt(fstyle, rect, but->drawstr+but->ofs, &font_xofs, &font_yofs);
+ uiStyleFontDrawExt(fstyle, rect, but->drawstr + but->ofs, &font_xofs, &font_yofs);
if (but->menu_key != '\0') {
char fixedbuf[128];
@@ -1177,24 +1185,24 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
BLI_strncpy(fixedbuf, but->drawstr + but->ofs, sizeof(fixedbuf));
- str= strchr(fixedbuf, but->menu_key-32); /* upper case */
- if (str==NULL)
- str= strchr(fixedbuf, but->menu_key);
+ str = strchr(fixedbuf, but->menu_key - 32); /* upper case */
+ if (str == NULL)
+ str = strchr(fixedbuf, but->menu_key);
if (str) {
- int ul_index= -1;
+ int ul_index = -1;
float ul_advance;
- ul_index= (int)(str - fixedbuf);
+ ul_index = (int)(str - fixedbuf);
if (fstyle->kerning == 1) {
BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT);
}
- fixedbuf[ul_index]= '\0';
- ul_advance= BLF_width(fstyle->uifont_id, fixedbuf);
+ fixedbuf[ul_index] = '\0';
+ ul_advance = BLF_width(fstyle->uifont_id, fixedbuf);
- BLF_position(fstyle->uifont_id, rect->xmin+font_xofs + ul_advance, rect->ymin+font_yofs, 0.0f);
+ BLF_position(fstyle->uifont_id, rect->xmin + font_xofs + ul_advance, rect->ymin + font_yofs, 0.0f);
BLF_draw(fstyle->uifont_id, "_", 2);
if (fstyle->kerning == 1) {
@@ -1205,10 +1213,10 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
/* part text right aligned */
if (cpoin) {
- fstyle->align= UI_STYLE_TEXT_RIGHT;
+ fstyle->align = UI_STYLE_TEXT_RIGHT;
rect->xmax -= ui_but_draw_menu_icon(but) ? UI_DPI_ICON_SIZE : 5;
- uiStyleFontDraw(fstyle, rect, cpoin+1);
- *cpoin= '|';
+ uiStyleFontDraw(fstyle, rect, cpoin + 1);
+ *cpoin = '|';
}
}
@@ -1216,7 +1224,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect)
{
- if (but==NULL) return;
+ if (but == NULL) return;
/* clip but->drawstr to fit in available space */
if (but->editstr && but->pos >= 0) {
@@ -1231,24 +1239,24 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
else if ((but->block->flag & UI_BLOCK_LOOP) && (but->type == BUT)) {
ui_text_leftclip(fstyle, but, rect);
}
- else but->ofs= 0;
+ else but->ofs = 0;
/* check for button text label */
if (but->type == ICONTEXTROW) {
- widget_draw_icon(but, (BIFIconID) (but->icon+but->iconadd), 1.0f, rect);
+ widget_draw_icon(but, (BIFIconID) (but->icon + but->iconadd), 1.0f, rect);
}
else {
- if (but->type==BUT_TOGDUAL) {
- int dualset= 0;
- if (but->pointype==SHO)
- dualset= BTST( *(((short *)but->poin)+1), but->bitnr);
- else if (but->pointype==INT)
- dualset= BTST( *(((int *)but->poin)+1), but->bitnr);
+ if (but->type == BUT_TOGDUAL) {
+ int dualset = 0;
+ if (but->pointype == SHO)
+ dualset = BTST(*(((short *)but->poin) + 1), but->bitnr);
+ else if (but->pointype == INT)
+ dualset = BTST(*(((int *)but->poin) + 1), but->bitnr);
- widget_draw_icon(but, ICON_DOT, dualset?1.0f:0.25f, rect);
+ widget_draw_icon(but, ICON_DOT, dualset ? 1.0f : 0.25f, rect);
}
- else if (but->type==MENU && (but->flag & UI_BUT_NODE_LINK)) {
+ else if (but->type == MENU && (but->flag & UI_BUT_NODE_LINK)) {
int tmp = rect->xmin;
rect->xmin = rect->xmax - (rect->ymax - rect->ymin) - 1;
widget_draw_icon(but, ICON_LAYER_USED, 1.0f, rect);
@@ -1259,9 +1267,9 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
* and offset the text label to accommodate it */
if (but->flag & UI_HAS_ICON) {
- widget_draw_icon(but, but->icon+but->iconadd, 1.0f, rect);
+ widget_draw_icon(but, but->icon + but->iconadd, 1.0f, rect);
- rect->xmin += (int)((float)UI_icon_get_width(but->icon+but->iconadd) * UI_DPI_ICON_FAC);
+ rect->xmin += (int)((float)UI_icon_get_width(but->icon + but->iconadd) * UI_DPI_ICON_FAC);
if (but->editstr || (but->flag & UI_TEXT_LEFT))
rect->xmin += 5;
@@ -1290,7 +1298,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
* float blend;
*/
-static struct uiWidgetStateColors wcol_state_colors= {
+static struct uiWidgetStateColors wcol_state_colors = {
{115, 190, 76, 255},
{90, 166, 51, 255},
{240, 235, 100, 255},
@@ -1312,7 +1320,7 @@ static struct uiWidgetStateColors wcol_state_colors= {
* float shadetop, shadedown;
*/
-static struct uiWidgetColors wcol_num= {
+static struct uiWidgetColors wcol_num = {
{25, 25, 25, 255},
{180, 180, 180, 255},
{153, 153, 153, 255},
@@ -1325,7 +1333,7 @@ static struct uiWidgetColors wcol_num= {
-20, 0
};
-static struct uiWidgetColors wcol_numslider= {
+static struct uiWidgetColors wcol_numslider = {
{25, 25, 25, 255},
{180, 180, 180, 255},
{153, 153, 153, 255},
@@ -1338,7 +1346,7 @@ static struct uiWidgetColors wcol_numslider= {
-20, 0
};
-static struct uiWidgetColors wcol_text= {
+static struct uiWidgetColors wcol_text = {
{25, 25, 25, 255},
{153, 153, 153, 255},
{153, 153, 153, 255},
@@ -1351,7 +1359,7 @@ static struct uiWidgetColors wcol_text= {
0, 25
};
-static struct uiWidgetColors wcol_option= {
+static struct uiWidgetColors wcol_option = {
{0, 0, 0, 255},
{70, 70, 70, 255},
{70, 70, 70, 255},
@@ -1365,7 +1373,7 @@ static struct uiWidgetColors wcol_option= {
};
/* button that shows popup */
-static struct uiWidgetColors wcol_menu= {
+static struct uiWidgetColors wcol_menu = {
{0, 0, 0, 255},
{70, 70, 70, 255},
{70, 70, 70, 255},
@@ -1379,7 +1387,7 @@ static struct uiWidgetColors wcol_menu= {
};
/* button that starts pulldown */
-static struct uiWidgetColors wcol_pulldown= {
+static struct uiWidgetColors wcol_pulldown = {
{0, 0, 0, 255},
{63, 63, 63, 255},
{86, 128, 194, 255},
@@ -1393,7 +1401,7 @@ static struct uiWidgetColors wcol_pulldown= {
};
/* button inside menu */
-static struct uiWidgetColors wcol_menu_item= {
+static struct uiWidgetColors wcol_menu_item = {
{0, 0, 0, 255},
{0, 0, 0, 0},
{86, 128, 194, 255},
@@ -1407,7 +1415,7 @@ static struct uiWidgetColors wcol_menu_item= {
};
/* backdrop menu + title text color */
-static struct uiWidgetColors wcol_menu_back= {
+static struct uiWidgetColors wcol_menu_back = {
{0, 0, 0, 255},
{25, 25, 25, 230},
{45, 45, 45, 230},
@@ -1421,7 +1429,7 @@ static struct uiWidgetColors wcol_menu_back= {
};
/* tooltip colour */
-static struct uiWidgetColors wcol_tooltip= {
+static struct uiWidgetColors wcol_tooltip = {
{0, 0, 0, 255},
{25, 25, 25, 230},
{45, 45, 45, 230},
@@ -1434,7 +1442,7 @@ static struct uiWidgetColors wcol_tooltip= {
25, -20
};
-static struct uiWidgetColors wcol_radio= {
+static struct uiWidgetColors wcol_radio = {
{0, 0, 0, 255},
{70, 70, 70, 255},
{86, 128, 194, 255},
@@ -1447,7 +1455,7 @@ static struct uiWidgetColors wcol_radio= {
15, -15
};
-static struct uiWidgetColors wcol_regular= {
+static struct uiWidgetColors wcol_regular = {
{25, 25, 25, 255},
{153, 153, 153, 255},
{100, 100, 100, 255},
@@ -1460,7 +1468,7 @@ static struct uiWidgetColors wcol_regular= {
0, 0
};
-static struct uiWidgetColors wcol_tool= {
+static struct uiWidgetColors wcol_tool = {
{25, 25, 25, 255},
{153, 153, 153, 255},
{100, 100, 100, 255},
@@ -1473,7 +1481,7 @@ static struct uiWidgetColors wcol_tool= {
15, -15
};
-static struct uiWidgetColors wcol_box= {
+static struct uiWidgetColors wcol_box = {
{25, 25, 25, 255},
{128, 128, 128, 255},
{100, 100, 100, 255},
@@ -1486,7 +1494,7 @@ static struct uiWidgetColors wcol_box= {
0, 0
};
-static struct uiWidgetColors wcol_toggle= {
+static struct uiWidgetColors wcol_toggle = {
{25, 25, 25, 255},
{153, 153, 153, 255},
{100, 100, 100, 255},
@@ -1499,7 +1507,7 @@ static struct uiWidgetColors wcol_toggle= {
0, 0
};
-static struct uiWidgetColors wcol_scroll= {
+static struct uiWidgetColors wcol_scroll = {
{50, 50, 50, 180},
{80, 80, 80, 180},
{100, 100, 100, 180},
@@ -1512,7 +1520,7 @@ static struct uiWidgetColors wcol_scroll= {
5, -5
};
-static struct uiWidgetColors wcol_progress= {
+static struct uiWidgetColors wcol_progress = {
{0, 0, 0, 255},
{190, 190, 190, 255},
{100, 100, 100, 180},
@@ -1525,7 +1533,7 @@ static struct uiWidgetColors wcol_progress= {
0, 0
};
-static struct uiWidgetColors wcol_list_item= {
+static struct uiWidgetColors wcol_list_item = {
{0, 0, 0, 255},
{0, 0, 0, 0},
{86, 128, 194, 255},
@@ -1539,7 +1547,7 @@ static struct uiWidgetColors wcol_list_item= {
};
/* free wcol struct to play with */
-static struct uiWidgetColors wcol_tmp= {
+static struct uiWidgetColors wcol_tmp = {
{0, 0, 0, 255},
{128, 128, 128, 255},
{100, 100, 100, 255},
@@ -1556,25 +1564,25 @@ static struct uiWidgetColors wcol_tmp= {
/* called for theme init (new theme) and versions */
void ui_widget_color_init(ThemeUI *tui)
{
- tui->wcol_regular= wcol_regular;
- tui->wcol_tool= wcol_tool;
- tui->wcol_text= wcol_text;
- tui->wcol_radio= wcol_radio;
- tui->wcol_option= wcol_option;
- tui->wcol_toggle= wcol_toggle;
- tui->wcol_num= wcol_num;
- tui->wcol_numslider= wcol_numslider;
- tui->wcol_menu= wcol_menu;
- tui->wcol_pulldown= wcol_pulldown;
- tui->wcol_menu_back= wcol_menu_back;
+ tui->wcol_regular = wcol_regular;
+ tui->wcol_tool = wcol_tool;
+ tui->wcol_text = wcol_text;
+ tui->wcol_radio = wcol_radio;
+ tui->wcol_option = wcol_option;
+ tui->wcol_toggle = wcol_toggle;
+ tui->wcol_num = wcol_num;
+ tui->wcol_numslider = wcol_numslider;
+ tui->wcol_menu = wcol_menu;
+ tui->wcol_pulldown = wcol_pulldown;
+ tui->wcol_menu_back = wcol_menu_back;
tui->wcol_tooltip = wcol_tooltip;
- tui->wcol_menu_item= wcol_menu_item;
- tui->wcol_box= wcol_box;
- tui->wcol_scroll= wcol_scroll;
- tui->wcol_list_item= wcol_list_item;
- tui->wcol_progress= wcol_progress;
+ tui->wcol_menu_item = wcol_menu_item;
+ tui->wcol_box = wcol_box;
+ tui->wcol_scroll = wcol_scroll;
+ tui->wcol_list_item = wcol_list_item;
+ tui->wcol_progress = wcol_progress;
- tui->wcol_state= wcol_state_colors;
+ tui->wcol_state = wcol_state_colors;
}
/* ************ button callbacks, state ***************** */
@@ -1582,18 +1590,18 @@ void ui_widget_color_init(ThemeUI *tui)
static void widget_state_blend(char cp[3], const char cpstate[3], const float fac)
{
if (fac != 0.0f) {
- cp[0]= (int)((1.0f-fac)*cp[0] + fac*cpstate[0]);
- cp[1]= (int)((1.0f-fac)*cp[1] + fac*cpstate[1]);
- cp[2]= (int)((1.0f-fac)*cp[2] + fac*cpstate[2]);
+ cp[0] = (int)((1.0f - fac) * cp[0] + fac * cpstate[0]);
+ cp[1] = (int)((1.0f - fac) * cp[1] + fac * cpstate[1]);
+ cp[2] = (int)((1.0f - fac) * cp[2] + fac * cpstate[2]);
}
}
/* copy colors from theme, and set changes in it based on state */
static void widget_state(uiWidgetType *wt, int state)
{
- uiWidgetStateColors *wcol_state= wt->wcol_state;
+ uiWidgetStateColors *wcol_state = wt->wcol_state;
- wt->wcol= *(wt->wcol_theme);
+ wt->wcol = *(wt->wcol_theme);
if (state & UI_SELECT) {
copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
@@ -1619,18 +1627,18 @@ static void widget_state(uiWidgetType *wt, int state)
widget_state_blend(wt->wcol.inner, wcol_state->inner_driven, wcol_state->blend);
if (state & UI_ACTIVE) { /* mouse over? */
- wt->wcol.inner[0]= wt->wcol.inner[0]>=240? 255 : wt->wcol.inner[0]+15;
- wt->wcol.inner[1]= wt->wcol.inner[1]>=240? 255 : wt->wcol.inner[1]+15;
- wt->wcol.inner[2]= wt->wcol.inner[2]>=240? 255 : wt->wcol.inner[2]+15;
+ wt->wcol.inner[0] = wt->wcol.inner[0] >= 240 ? 255 : wt->wcol.inner[0] + 15;
+ wt->wcol.inner[1] = wt->wcol.inner[1] >= 240 ? 255 : wt->wcol.inner[1] + 15;
+ wt->wcol.inner[2] = wt->wcol.inner[2] >= 240 ? 255 : wt->wcol.inner[2] + 15;
}
}
if (state & UI_BUT_REDALERT) {
- char red[4]= {255, 0, 0};
+ char red[4] = {255, 0, 0};
widget_state_blend(wt->wcol.inner, red, 0.4f);
}
if (state & UI_BUT_NODE_ACTIVE) {
- char blue[4]= {86, 128, 194};
+ char blue[4] = {86, 128, 194};
widget_state_blend(wt->wcol.inner, blue, 0.3f);
}
}
@@ -1638,8 +1646,8 @@ static void widget_state(uiWidgetType *wt, int state)
/* sliders use special hack which sets 'item' as inner when drawing filling */
static void widget_state_numslider(uiWidgetType *wt, int state)
{
- uiWidgetStateColors *wcol_state= wt->wcol_state;
- float blend= wcol_state->blend - 0.2f; // XXX special tweak to make sure that bar will still be visible
+ uiWidgetStateColors *wcol_state = wt->wcol_state;
+ float blend = wcol_state->blend - 0.2f; // XXX special tweak to make sure that bar will still be visible
/* call this for option button */
widget_state(wt, state);
@@ -1692,7 +1700,7 @@ static void widget_state_option_menu(uiWidgetType *wt, int state)
if (state & UI_SELECT)
UI_GetThemeColor4ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text);
else {
- bTheme *btheme= UI_GetTheme(); /* XXX */
+ bTheme *btheme = UI_GetTheme(); /* XXX */
copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text);
}
@@ -1701,13 +1709,13 @@ static void widget_state_option_menu(uiWidgetType *wt, int state)
static void widget_state_nothing(uiWidgetType *wt, int UNUSED(state))
{
- wt->wcol= *(wt->wcol_theme);
+ wt->wcol = *(wt->wcol_theme);
}
/* special case, button that calls pulldown */
static void widget_state_pulldown(uiWidgetType *wt, int 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);
@@ -1719,12 +1727,12 @@ static void widget_state_pulldown(uiWidgetType *wt, int state)
/* special case, menu items */
static void widget_state_menu_item(uiWidgetType *wt, int state)
{
- wt->wcol= *(wt->wcol_theme);
+ wt->wcol = *(wt->wcol_theme);
- if (state & (UI_BUT_DISABLED|UI_BUT_INACTIVE)) {
- wt->wcol.text[0]= 0.5f*(wt->wcol.text[0]+wt->wcol.text_sel[0]);
- wt->wcol.text[1]= 0.5f*(wt->wcol.text[1]+wt->wcol.text_sel[1]);
- wt->wcol.text[2]= 0.5f*(wt->wcol.text[2]+wt->wcol.text_sel[2]);
+ if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) {
+ wt->wcol.text[0] = 0.5f * (wt->wcol.text[0] + wt->wcol.text_sel[0]);
+ wt->wcol.text[1] = 0.5f * (wt->wcol.text[1] + wt->wcol.text_sel[1]);
+ wt->wcol.text[2] = 0.5f * (wt->wcol.text[2] + wt->wcol.text_sel[2]);
}
else if (state & UI_ACTIVE) {
copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel);
@@ -1739,27 +1747,27 @@ static void widget_state_menu_item(uiWidgetType *wt, int state)
static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float radout)
{
uiWidgetBase wtb;
- rcti rect1= *rect;
+ rcti rect1 = *rect;
float alpha, alphastep;
int step, totvert;
- float quad_strip[WIDGET_SIZE_MAX*2][2];
+ float quad_strip[WIDGET_SIZE_MAX * 2][2];
/* prevent tooltips to not show round shadow */
- if ( 2.0f*radout > 0.2f*(rect1.ymax-rect1.ymin) )
- rect1.ymax -= 0.2f*(rect1.ymax-rect1.ymin);
+ if (2.0f * radout > 0.2f * (rect1.ymax - rect1.ymin) )
+ rect1.ymax -= 0.2f * (rect1.ymax - rect1.ymin);
else
- rect1.ymax -= 2.0f*radout;
+ rect1.ymax -= 2.0f * radout;
/* inner part */
- totvert= round_box_shadow_edges(wtb.inner_v, &rect1, radin, roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT), 0.0f);
+ totvert = round_box_shadow_edges(wtb.inner_v, &rect1, radin, roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT), 0.0f);
/* inverse linear shadow alpha */
- alpha= 0.15;
- alphastep= 0.67;
+ alpha = 0.15;
+ alphastep = 0.67;
glEnableClientState(GL_VERTEX_ARRAY);
- for (step= 1; step<=radout; step++, alpha*=alphastep) {
+ for (step = 1; step <= radout; step++, alpha *= alphastep) {
round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, (float)step);
glColor4f(0.0f, 0.0f, 0.0f, alpha);
@@ -1767,7 +1775,7 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float
widget_verts_to_quad_strip_open(&wtb, totvert, quad_strip);
glVertexPointer(2, GL_FLOAT, 0, quad_strip);
- glDrawArrays(GL_QUAD_STRIP, 0, totvert*2);
+ glDrawArrays(GL_QUAD_STRIP, 0, totvert * 2);
}
glDisableClientState(GL_VERTEX_ARRAY);
@@ -1776,7 +1784,7 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float
static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int direction)
{
uiWidgetBase wtb;
- int roundboxalign= UI_CNR_ALL;
+ int roundboxalign = UI_CNR_ALL;
widget_init(&wtb);
@@ -1786,11 +1794,11 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
//rect->ymax += 4.0;
}
else if (direction == UI_DOWN) {
- roundboxalign= (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
+ roundboxalign = (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT);
rect->ymin -= 4.0;
}
else if (direction == UI_TOP) {
- roundboxalign= UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT;
+ roundboxalign = UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT;
rect->ymax += 4.0;
}
@@ -1798,7 +1806,7 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir
widget_softshadow(rect, roundboxalign, 5.0f, 8.0f);
round_box_edges(&wtb, roundboxalign, rect, 5.0f);
- wtb.emboss= 0;
+ wtb.emboss = 0;
widgetbase_draw(&wtb, wcol);
glDisable(GL_BLEND);
@@ -1812,14 +1820,14 @@ static void ui_hsv_cursor(float x, float y)
glTranslatef(x, y, 0.0f);
glColor3f(1.0f, 1.0f, 1.0f);
- glutil_draw_filled_arc(0.0f, M_PI*2.0, 3.0f, 8);
+ glutil_draw_filled_arc(0.0f, M_PI * 2.0, 3.0f, 8);
glEnable(GL_BLEND);
- glEnable(GL_LINE_SMOOTH );
+ glEnable(GL_LINE_SMOOTH);
glColor3f(0.0f, 0.0f, 0.0f);
- glutil_draw_lined_arc(0.0f, M_PI*2.0, 3.0f, 12);
+ glutil_draw_lined_arc(0.0f, M_PI * 2.0, 3.0f, 12);
glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH );
+ glDisable(GL_LINE_SMOOTH);
glPopMatrix();
@@ -1828,51 +1836,51 @@ static void ui_hsv_cursor(float x, float y)
void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx, float my)
{
/* duplication of code... well, simple is better now */
- float centx= (float)(rect->xmin + rect->xmax)/2;
- float centy= (float)(rect->ymin + rect->ymax)/2;
+ float centx = (float)(rect->xmin + rect->xmax) / 2;
+ float centy = (float)(rect->ymin + rect->ymax) / 2;
float radius, dist;
- if ( rect->xmax-rect->xmin > rect->ymax-rect->ymin )
- radius= (float)(rect->ymax - rect->ymin)/2;
+ if (rect->xmax - rect->xmin > rect->ymax - rect->ymin)
+ radius = (float)(rect->ymax - rect->ymin) / 2;
else
- radius= (float)(rect->xmax - rect->xmin)/2;
+ radius = (float)(rect->xmax - rect->xmin) / 2;
- mx-= centx;
- my-= centy;
- dist= sqrt( mx*mx + my*my);
+ mx -= centx;
+ my -= centy;
+ dist = sqrt(mx * mx + my * my);
if (dist < radius)
- *valdist= dist/radius;
+ *valdist = dist / radius;
else
- *valdist= 1.0f;
+ *valdist = 1.0f;
- *valrad= atan2f(mx, my)/(2.0f*(float)M_PI) + 0.5f;
+ *valrad = atan2f(mx, my) / (2.0f * (float)M_PI) + 0.5f;
}
static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
{
/* gouraud triangle fan */
- float radstep, ang= 0.0f;
+ float radstep, ang = 0.0f;
float centx, centy, radius, cursor_radius;
float rgb[3], hsvo[3], hsv[3], col[3], colcent[3];
- int a, tot= 32;
+ int a, tot = 32;
int color_profile = but->block->color_profile;
if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
color_profile = BLI_PR_NONE;
- radstep= 2.0f*(float)M_PI/(float)tot;
- centx= (float)(rect->xmin + rect->xmax)/2;
- centy= (float)(rect->ymin + rect->ymax)/2;
+ radstep = 2.0f * (float)M_PI / (float)tot;
+ centx = (float)(rect->xmin + rect->xmax) / 2;
+ centy = (float)(rect->ymin + rect->ymax) / 2;
- if ( rect->xmax-rect->xmin > rect->ymax-rect->ymin )
- radius= (float)(rect->ymax - rect->ymin)/2;
+ if (rect->xmax - rect->xmin > rect->ymax - rect->ymin)
+ radius = (float)(rect->ymax - rect->ymin) / 2;
else
- radius= (float)(rect->xmax - rect->xmin)/2;
+ radius = (float)(rect->xmax - rect->xmin) / 2;
/* color */
ui_get_but_vectorf(but, rgb);
copy_v3_v3(hsv, ui_block_hsv_get(but->block));
- rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+ rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
copy_v3_v3(hsvo, hsv);
/* exception: if 'lock' is set
@@ -1883,24 +1891,24 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
else if (color_profile)
hsv[2] = linearrgb_to_srgb(hsv[2]);
- hsv_to_rgb(0.f, 0.f, hsv[2], colcent, colcent+1, colcent+2);
+ hsv_to_rgb(0.f, 0.f, hsv[2], colcent, colcent + 1, colcent + 2);
glShadeModel(GL_SMOOTH);
glBegin(GL_TRIANGLE_FAN);
glColor3fv(colcent);
- glVertex2f( centx, centy);
+ glVertex2f(centx, centy);
- for (a=0; a<=tot; a++, ang+=radstep) {
- float si= sin(ang);
- float co= cos(ang);
+ for (a = 0; a <= tot; a++, ang += radstep) {
+ float si = sin(ang);
+ float co = cos(ang);
- ui_hsvcircle_vals_from_pos(hsv, hsv+1, rect, centx + co*radius, centy + si*radius);
+ ui_hsvcircle_vals_from_pos(hsv, hsv + 1, rect, centx + co * radius, centy + si * radius);
CLAMP(hsv[2], 0.0f, 1.0f); /* for display only */
- hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2);
+ hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col + 1, col + 2);
glColor3fv(col);
- glVertex2f( centx + co*radius, centy + si*radius);
+ glVertex2f(centx + co * radius, centy + si * radius);
}
glEnd();
@@ -1910,23 +1918,23 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
glPushMatrix();
glTranslatef(centx, centy, 0.0f);
glEnable(GL_BLEND);
- glEnable(GL_LINE_SMOOTH );
- glColor3ubv((unsigned char*)wcol->outline);
- glutil_draw_lined_arc(0.0f, M_PI*2.0, radius, tot + 1);
+ glEnable(GL_LINE_SMOOTH);
+ glColor3ubv((unsigned char *)wcol->outline);
+ glutil_draw_lined_arc(0.0f, M_PI * 2.0, radius, tot + 1);
glDisable(GL_BLEND);
- glDisable(GL_LINE_SMOOTH );
+ glDisable(GL_LINE_SMOOTH);
glPopMatrix();
/* cursor */
- ang= 2.0f*(float)M_PI*hsvo[0] + 0.5f*(float)M_PI;
+ ang = 2.0f * (float)M_PI * hsvo[0] + 0.5f * (float)M_PI;
if (but->flag & UI_BUT_COLOR_CUBIC)
cursor_radius = (1.0f - powf(1.0f - hsvo[1], 3.0f));
else
cursor_radius = hsvo[1];
- radius= CLAMPIS(cursor_radius, 0.0f, 1.0f) * radius;
- ui_hsv_cursor(centx + cosf(-ang)*radius, centy + sinf(-ang)*radius);
+ radius = CLAMPIS(cursor_radius, 0.0f, 1.0f) * radius;
+ ui_hsv_cursor(centx + cosf(-ang) * radius, centy + sinf(-ang) * radius);
}
/* ************ custom buttons, old stuff ************** */
@@ -1935,15 +1943,15 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect)
void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha)
{
int a;
- float h= hsv[0], s= hsv[1], v= hsv[2];
+ float h = hsv[0], s = hsv[1], v = hsv[2];
float dx, dy, sx1, sx2, sy;
- float col0[4][3]; // left half, rect bottom to top
- float col1[4][3]; // right half, rect bottom to top
+ float col0[4][3]; // left half, rect bottom to top
+ float col1[4][3]; // right half, rect bottom to top
/* draw series of gouraud rects */
glShadeModel(GL_SMOOTH);
- switch(type) {
+ switch (type) {
case UI_GRAD_SV:
hsv_to_rgb(h, 0.0, 0.0, &col1[0][0], &col1[0][1], &col1[0][2]);
hsv_to_rgb(h, 0.333, 0.0, &col1[1][0], &col1[1][1], &col1[1][2]);
@@ -1990,7 +1998,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha)
/* old below */
- for (dx=0.0f; dx<1.0f; dx+= 0.05f) {
+ for (dx = 0.0f; dx < 1.0f; dx += 0.05f) {
// previous color
copy_v3_v3(col0[0], col1[0]);
copy_v3_v3(col0[1], col1[1]);
@@ -1998,7 +2006,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha)
copy_v3_v3(col0[3], col1[3]);
// new color
- switch(type) {
+ switch (type) {
case UI_GRAD_SV:
hsv_to_rgb(h, 0.0, dx, &col1[0][0], &col1[0][1], &col1[0][2]);
hsv_to_rgb(h, 0.333, dx, &col1[1][0], &col1[1][1], &col1[1][2]);
@@ -2038,24 +2046,24 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha)
}
// rect
- sx1= rect->xmin + dx*(rect->xmax-rect->xmin);
- sx2= rect->xmin + (dx+0.05f)*(rect->xmax-rect->xmin);
- sy= rect->ymin;
- dy= (rect->ymax-rect->ymin)/3.0;
+ sx1 = rect->xmin + dx * (rect->xmax - rect->xmin);
+ sx2 = rect->xmin + (dx + 0.05f) * (rect->xmax - rect->xmin);
+ sy = rect->ymin;
+ dy = (rect->ymax - rect->ymin) / 3.0;
glBegin(GL_QUADS);
- for (a=0; a<3; a++, sy+=dy) {
+ for (a = 0; a < 3; a++, sy += dy) {
glColor4f(col0[a][0], col0[a][1], col0[a][2], alpha);
glVertex2f(sx1, sy);
glColor4f(col1[a][0], col1[a][1], col1[a][2], alpha);
glVertex2f(sx2, sy);
- glColor4f(col1[a+1][0], col1[a+1][1], col1[a+1][2], alpha);
- glVertex2f(sx2, sy+dy);
+ glColor4f(col1[a + 1][0], col1[a + 1][1], col1[a + 1][2], alpha);
+ glVertex2f(sx2, sy + dy);
- glColor4f(col0[a+1][0], col0[a+1][1], col0[a+1][2], alpha);
- glVertex2f(sx1, sy+dy);
+ glColor4f(col0[a + 1][0], col0[a + 1][1], col0[a + 1][2], alpha);
+ glVertex2f(sx1, sy + dy);
}
glEnd();
}
@@ -2068,44 +2076,44 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha)
static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect)
{
- float rgb[3], h,s,v;
- float x=0.0f, y=0.0f;
- float *hsv= ui_block_hsv_get(but->block);
+ float rgb[3], h, s, v;
+ float x = 0.0f, y = 0.0f;
+ float *hsv = ui_block_hsv_get(but->block);
float hsvn[3];
- h= hsv[0];
- s= hsv[1];
- v= hsv[2];
+ h = hsv[0];
+ s = hsv[1];
+ v = hsv[2];
ui_get_but_vectorf(but, rgb);
rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], &h, &s, &v);
- hsvn[0]= h;
- hsvn[1]= s;
- hsvn[2]= v;
+ hsvn[0] = h;
+ hsvn[1] = s;
+ hsvn[2] = v;
ui_draw_gradient(rect, hsvn, but->a1, 1.f);
- switch((int)but->a1) {
+ switch ((int)but->a1) {
case UI_GRAD_SV:
- x= v; y= s; break;
+ x = v; y = s; break;
case UI_GRAD_HV:
- x= h; y= v; break;
+ x = h; y = v; break;
case UI_GRAD_HS:
- x= h; y= s; break;
+ x = h; y = s; break;
case UI_GRAD_H:
- x= h; y= 0.5; break;
+ x = h; y = 0.5; break;
case UI_GRAD_S:
- x= s; y= 0.5; break;
+ x = s; y = 0.5; break;
case UI_GRAD_V:
- x= v; y= 0.5; break;
+ x = v; y = 0.5; break;
}
/* cursor */
- x= rect->xmin + x*(rect->xmax-rect->xmin);
- y= rect->ymin + y*(rect->ymax-rect->ymin);
- CLAMP(x, rect->xmin+3.0f, rect->xmax-3.0f);
- CLAMP(y, rect->ymin+3.0f, rect->ymax-3.0f);
+ x = rect->xmin + x * (rect->xmax - rect->xmin);
+ y = rect->ymin + y * (rect->ymax - rect->ymin);
+ CLAMP(x, rect->xmin + 3.0f, rect->xmax - 3.0f);
+ CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
ui_hsv_cursor(x, y);
@@ -2118,7 +2126,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect)
static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
{
uiWidgetBase wtb;
- float rad= 0.5f*(rect->xmax - rect->xmin);
+ float rad = 0.5f * (rect->xmax - rect->xmin);
float x, y;
float rgb[3], hsv[3], v, range;
int color_profile = but->block->color_profile;
@@ -2127,7 +2135,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
color_profile = BLI_PR_NONE;
ui_get_but_vectorf(but, rgb);
- rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2);
+ rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
v = hsv[2];
if (color_profile)
@@ -2135,7 +2143,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
/* map v from property range to [0,1] */
range = but->softmax - but->softmin;
- v = (v - but->softmin)/range;
+ v = (v - but->softmin) / range;
widget_init(&wtb);
@@ -2143,18 +2151,18 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
/* setup temp colors */
- wcol_tmp.outline[0]= wcol_tmp.outline[1]= wcol_tmp.outline[2]= 0;
- wcol_tmp.inner[0]= wcol_tmp.inner[1]= wcol_tmp.inner[2]= 128;
- wcol_tmp.shadetop= 127;
- wcol_tmp.shadedown= -128;
- wcol_tmp.shaded= 1;
+ wcol_tmp.outline[0] = wcol_tmp.outline[1] = wcol_tmp.outline[2] = 0;
+ wcol_tmp.inner[0] = wcol_tmp.inner[1] = wcol_tmp.inner[2] = 128;
+ wcol_tmp.shadetop = 127;
+ wcol_tmp.shadedown = -128;
+ wcol_tmp.shaded = 1;
widgetbase_draw(&wtb, &wcol_tmp);
/* cursor */
- x= rect->xmin + 0.5f * (rect->xmax-rect->xmin);
- y= rect->ymin + v * (rect->ymax-rect->ymin);
- CLAMP(y, rect->ymin+3.0f, rect->ymax-3.0f);
+ x = rect->xmin + 0.5f * (rect->xmax - rect->xmin);
+ y = rect->ymin + v * (rect->ymax - rect->ymin);
+ CLAMP(y, rect->ymin + 3.0f, rect->ymax - 3.0f);
ui_hsv_cursor(x, y);
@@ -2164,7 +2172,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect)
/* ************ separator, for menus etc ***************** */
static void ui_draw_separator(rcti *rect, uiWidgetColors *wcol)
{
- int y = rect->ymin + (rect->ymax - rect->ymin)/2 - 1;
+ int y = rect->ymin + (rect->ymax - rect->ymin) / 2 - 1;
unsigned char col[4];
col[0] = wcol->text[0];
@@ -2183,8 +2191,8 @@ static void ui_draw_separator(rcti *rect, uiWidgetColors *wcol)
static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
uiWidgetBase wtb;
- float rad= 0.5f*(rect->ymax - rect->ymin);
- float textofs = rad*0.75f;
+ float rad = 0.5f * (rect->ymax - rect->ymin);
+ float textofs = rad * 0.75f;
if (state & UI_SELECT)
SWAP(short, wcol->shadetop, wcol->shadedown);
@@ -2212,29 +2220,29 @@ int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol)
{
float dist, vec[4][2];
- vec[0][0]= rect->xmin;
- vec[0][1]= rect->ymin;
- vec[3][0]= rect->xmax;
- vec[3][1]= rect->ymax;
+ vec[0][0] = rect->xmin;
+ vec[0][1] = rect->ymin;
+ vec[3][0] = rect->xmax;
+ vec[3][1] = rect->ymax;
- dist= 0.5f*ABS(vec[0][0] - vec[3][0]);
+ dist = 0.5f * ABS(vec[0][0] - vec[3][0]);
- vec[1][0]= vec[0][0]+dist;
- vec[1][1]= vec[0][1];
+ vec[1][0] = vec[0][0] + dist;
+ vec[1][1] = vec[0][1];
- vec[2][0]= vec[3][0]-dist;
- vec[2][1]= vec[3][1];
+ vec[2][0] = vec[3][0] - dist;
+ vec[2][1] = vec[3][1];
- forward_diff_bezier(vec[0][0], vec[1][0], vec[2][0], vec[3][0], coord_array[0], resol, sizeof(float)*2);
- forward_diff_bezier(vec[0][1], vec[1][1], vec[2][1], vec[3][1], coord_array[0]+1, resol, sizeof(float)*2);
+ forward_diff_bezier(vec[0][0], vec[1][0], vec[2][0], vec[3][0], coord_array[0], resol, sizeof(float) * 2);
+ forward_diff_bezier(vec[0][1], vec[1][1], vec[2][1], vec[3][1], coord_array[0] + 1, resol, sizeof(float) * 2);
return 1;
}
-#define LINK_RESOL 24
+#define LINK_RESOL 24
void ui_draw_link_bezier(rcti *rect)
{
- float coord_array[LINK_RESOL+1][2];
+ float coord_array[LINK_RESOL + 1][2];
if (ui_link_bezier_points(rect, coord_array, LINK_RESOL)) {
/* we can reuse the dist variable here to increment the GL curve eval amount*/
@@ -2260,19 +2268,19 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
uiWidgetBase wtb;
float rad;
int horizontal;
- short outline=0;
+ short outline = 0;
widget_init(&wtb);
/* determine horizontal/vertical */
- horizontal= (rect->xmax - rect->xmin > rect->ymax - rect->ymin);
+ horizontal = (rect->xmax - rect->xmin > rect->ymax - rect->ymin);
if (horizontal)
- rad= 0.5f*(rect->ymax - rect->ymin);
+ rad = 0.5f * (rect->ymax - rect->ymin);
else
- rad= 0.5f*(rect->xmax - rect->xmin);
+ rad = 0.5f * (rect->xmax - rect->xmin);
- wtb.shadedir= (horizontal)? 1: 0;
+ wtb.shadedir = (horizontal) ? 1 : 0;
/* draw back part, colors swapped and shading inverted */
if (horizontal)
@@ -2282,25 +2290,25 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
widgetbase_draw(&wtb, wcol);
/* slider */
- if (slider->xmax-slider->xmin<2 || slider->ymax-slider->ymin<2);
+ if (slider->xmax - slider->xmin < 2 || slider->ymax - slider->ymin < 2) ;
else {
SWAP(short, wcol->shadetop, wcol->shadedown);
copy_v4_v4_char(wcol->inner, wcol->item);
- if (wcol->shadetop>wcol->shadedown)
- wcol->shadetop+= 20; /* XXX violates themes... */
- else wcol->shadedown+= 20;
+ if (wcol->shadetop > wcol->shadedown)
+ wcol->shadetop += 20; /* XXX violates themes... */
+ else wcol->shadedown += 20;
if (state & UI_SCROLL_PRESSED) {
- wcol->inner[0]= wcol->inner[0]>=250? 255 : wcol->inner[0]+5;
- wcol->inner[1]= wcol->inner[1]>=250? 255 : wcol->inner[1]+5;
- wcol->inner[2]= wcol->inner[2]>=250? 255 : wcol->inner[2]+5;
+ wcol->inner[0] = wcol->inner[0] >= 250 ? 255 : wcol->inner[0] + 5;
+ wcol->inner[1] = wcol->inner[1] >= 250 ? 255 : wcol->inner[1] + 5;
+ wcol->inner[2] = wcol->inner[2] >= 250 ? 255 : wcol->inner[2] + 5;
}
/* draw */
- wtb.emboss= 0; /* only emboss once */
+ wtb.emboss = 0; /* only emboss once */
/* exception for progress bar */
if (state & UI_SCROLL_NO_OUTLINE)
@@ -2309,10 +2317,10 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat
round_box_edges(&wtb, UI_CNR_ALL, slider, rad);
if (state & UI_SCROLL_ARROWS) {
- if (wcol->item[0] > 48) wcol->item[0]-= 48;
- if (wcol->item[1] > 48) wcol->item[1]-= 48;
- if (wcol->item[2] > 48) wcol->item[2]-= 48;
- wcol->item[3]= 255;
+ if (wcol->item[0] > 48) wcol->item[0] -= 48;
+ if (wcol->item[1] > 48) wcol->item[1] -= 48;
+ if (wcol->item[2] > 48) wcol->item[2] -= 48;
+ wcol->item[3] = 255;
if (horizontal) {
widget_scroll_circle(&wtb.tria1, slider, 0.6f, 'l');
@@ -2338,24 +2346,24 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
int horizontal;
/* calculate slider part */
- value= ui_get_but_val(but);
+ value = ui_get_but_val(but);
- size= (but->softmax + but->a1 - but->softmin);
- size= MAX2(size, 2);
+ size = (but->softmax + but->a1 - but->softmin);
+ size = MAX2(size, 2);
/* position */
- rect1= *rect;
+ rect1 = *rect;
/* determine horizontal/vertical */
- horizontal= (rect->xmax - rect->xmin > rect->ymax - rect->ymin);
+ horizontal = (rect->xmax - rect->xmin > rect->ymax - rect->ymin);
if (horizontal) {
- fac= (rect->xmax - rect->xmin)/(size);
- rect1.xmin = rect1.xmin + ceilf(fac*((float)value - but->softmin));
- rect1.xmax = rect1.xmin + ceilf(fac*(but->a1 - but->softmin));
+ fac = (rect->xmax - rect->xmin) / (size);
+ rect1.xmin = rect1.xmin + ceilf(fac * ((float)value - but->softmin));
+ rect1.xmax = rect1.xmin + ceilf(fac * (but->a1 - but->softmin));
/* ensure minimium size */
- min= rect->ymax - rect->ymin;
+ min = rect->ymax - rect->ymin;
if (rect1.xmax - rect1.xmin < min) {
rect1.xmax = rect1.xmin + min;
@@ -2367,12 +2375,12 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
}
}
else {
- fac= (rect->ymax - rect->ymin)/(size);
- rect1.ymax = rect1.ymax - ceilf(fac*((float)value - but->softmin));
- rect1.ymin = rect1.ymax - ceilf(fac*(but->a1 - but->softmin));
+ fac = (rect->ymax - rect->ymin) / (size);
+ rect1.ymax = rect1.ymax - ceilf(fac * ((float)value - but->softmin));
+ rect1.ymin = rect1.ymax - ceilf(fac * (but->a1 - but->softmin));
/* ensure minimium size */
- min= rect->xmax - rect->xmin;
+ min = rect->xmax - rect->xmin;
if (rect1.ymax - rect1.ymin < min) {
rect1.ymax = rect1.ymin + min;
@@ -2385,9 +2393,9 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
}
if (state & UI_SELECT)
- state= UI_SCROLL_PRESSED;
+ state = UI_SCROLL_PRESSED;
else
- state= 0;
+ state = 0;
uiWidgetScrollDraw(wcol, rect, &rect1, state);
}
@@ -2405,7 +2413,7 @@ static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int
w = value * (rect_prog.xmax - rect_prog.xmin);
/* ensure minimium size */
- min= rect_prog.ymax - rect_prog.ymin;
+ min = rect_prog.ymax - rect_prog.ymin;
w = MAX2(w, min);
rect_bar.xmax = rect_bar.xmin + w;
@@ -2425,8 +2433,8 @@ static void widget_link(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect, in
UI_ThemeColor(TH_TEXT_HI);
- rectlink.xmin = (rect->xmin+rect->xmax)/2;
- rectlink.ymin = (rect->ymin+rect->ymax)/2;
+ rectlink.xmin = (rect->xmin + rect->xmax) / 2;
+ rectlink.ymin = (rect->ymin + rect->ymax) / 2;
rectlink.xmax = but->linkto[0];
rectlink.ymax = but->linkto[1];
@@ -2448,17 +2456,17 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
/* backdrop first */
/* fully rounded */
- offs= 0.5f*(rect->ymax - rect->ymin);
- toffs = offs*0.75f;
+ offs = 0.5f * (rect->ymax - rect->ymin);
+ toffs = offs * 0.75f;
round_box_edges(&wtb, roundboxalign, rect, offs);
- wtb.outline= 0;
+ wtb.outline = 0;
widgetbase_draw(&wtb, wcol);
/* draw left/right parts only when not in text editing */
if (!(state & UI_TEXTINPUT)) {
- /* slider part */
+ /* slider part */
copy_v3_v3_char(outline, wcol->outline);
copy_v3_v3_char(wcol->outline, wcol->item);
copy_v3_v3_char(wcol->inner, wcol->item);
@@ -2466,24 +2474,24 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
if (!(state & UI_SELECT))
SWAP(short, wcol->shadetop, wcol->shadedown);
- rect1= *rect;
+ rect1 = *rect;
- value= ui_get_but_val(but);
- fac= ((float)value-but->softmin)*(rect1.xmax - rect1.xmin - offs)/(but->softmax - but->softmin);
+ value = ui_get_but_val(but);
+ fac = ((float)value - but->softmin) * (rect1.xmax - rect1.xmin - offs) / (but->softmax - but->softmin);
/* left part of slider, always rounded */
- rect1.xmax = rect1.xmin + ceil(offs+1.0f);
+ rect1.xmax = rect1.xmin + ceil(offs + 1.0f);
round_box_edges(&wtb1, roundboxalign & ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT), &rect1, offs);
- wtb1.outline= 0;
+ wtb1.outline = 0;
widgetbase_draw(&wtb1, wcol);
/* right part of slider, interpolate roundness */
rect1.xmax = rect1.xmin + fac + offs;
- rect1.xmin+= floor(offs-1.0f);
+ rect1.xmin += floor(offs - 1.0f);
if (rect1.xmax + offs > rect->xmax)
- offs*= (rect1.xmax + offs - rect->xmax)/offs;
+ offs *= (rect1.xmax + offs - rect->xmax) / offs;
else
- offs= 0.0f;
+ offs = 0.0f;
round_box_edges(&wtb1, roundboxalign & ~(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT), &rect1, offs);
widgetbase_draw(&wtb1, wcol);
@@ -2494,8 +2502,8 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s
}
/* outline */
- wtb.outline= 1;
- wtb.inner= 0;
+ wtb.outline = 1;
+ wtb.inner = 0;
widgetbase_draw(&wtb, wcol);
/* text space */
@@ -2512,14 +2520,14 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
float col[4];
int color_profile = but->block->color_profile;
- col[3]= 1.0f;
+ col[3] = 1.0f;
if (but->rnaprop) {
if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA)
color_profile = BLI_PR_NONE;
- if (RNA_property_array_length(&but->rnapoin, but->rnaprop)==4) {
- col[3]= RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
+ if (RNA_property_array_length(&but->rnapoin, but->rnaprop) == 4) {
+ col[3] = RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3);
}
}
@@ -2530,15 +2538,15 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
ui_get_but_vectorf(but, col);
- if (state & (UI_BUT_ANIMATED|UI_BUT_ANIMATED_KEY|UI_BUT_DRIVEN|UI_BUT_REDALERT)) {
+ if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) {
// draw based on state - color for keyed etc
widgetbase_draw(&wtb, wcol);
// inset to draw swatch color
- rect->xmin+= SWATCH_KEYED_BORDER;
- rect->xmax-= SWATCH_KEYED_BORDER;
- rect->ymin+= SWATCH_KEYED_BORDER;
- rect->ymax-= SWATCH_KEYED_BORDER;
+ rect->xmin += SWATCH_KEYED_BORDER;
+ rect->xmax -= SWATCH_KEYED_BORDER;
+ rect->ymin += SWATCH_KEYED_BORDER;
+ rect->ymax -= SWATCH_KEYED_BORDER;
round_box_edges(&wtb, roundboxalign, rect, 5.0f);
}
@@ -2557,11 +2565,11 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat
static void widget_icon_has_anim(uiBut *UNUSED(but), uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign))
{
- if (state & (UI_BUT_ANIMATED|UI_BUT_ANIMATED_KEY|UI_BUT_DRIVEN|UI_BUT_REDALERT)) {
+ if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) {
uiWidgetBase wtb;
widget_init(&wtb);
- wtb.outline= 0;
+ wtb.outline = 0;
/* rounded */
round_box_edges(&wtb, UI_CNR_ALL, rect, 10.0f);
@@ -2602,7 +2610,7 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state),
widgetbase_draw(&wtb, wcol);
/* text space */
- rect->xmax -= (rect->ymax-rect->ymin);
+ rect->xmax -= (rect->ymax - rect->ymin);
}
static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
@@ -2622,7 +2630,7 @@ static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat
{
/* silly node link button hacks */
uiWidgetBase wtb;
- uiWidgetColors wcol_backup= *wcol;
+ uiWidgetColors wcol_backup = *wcol;
widget_init(&wtb);
@@ -2638,14 +2646,14 @@ static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat
/* decoration */
widgetbase_draw(&wtb, wcol);
- *wcol= wcol_backup;
+ *wcol = wcol_backup;
}
static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign))
{
if (state & UI_ACTIVE) {
uiWidgetBase wtb;
- float rad= 0.5f*(rect->ymax - rect->ymin); // 4.0f
+ float rad = 0.5f * (rect->ymax - rect->ymin); // 4.0f
widget_init(&wtb);
@@ -2663,7 +2671,7 @@ static void widget_menu_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(sta
widget_init(&wtb);
/* not rounded, no outline */
- wtb.outline= 0;
+ wtb.outline = 0;
round_box_edges(&wtb, 0, rect, 0.0f);
widgetbase_draw(&wtb, wcol);
@@ -2676,7 +2684,7 @@ static void widget_list_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(sta
widget_init(&wtb);
/* rounded, but no outline */
- wtb.outline= 0;
+ wtb.outline = 0;
round_box_edges(&wtb, UI_CNR_ALL, rect, 4.0f);
widgetbase_draw(&wtb, wcol);
@@ -2685,20 +2693,20 @@ static void widget_list_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(sta
static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign))
{
uiWidgetBase wtb;
- rcti recttemp= *rect;
+ rcti recttemp = *rect;
int delta;
widget_init(&wtb);
/* square */
- recttemp.xmax = recttemp.xmin + (recttemp.ymax-recttemp.ymin);
+ recttemp.xmax = recttemp.xmin + (recttemp.ymax - recttemp.ymin);
/* smaller */
- delta= 1 + (recttemp.ymax-recttemp.ymin)/8;
- recttemp.xmin+= delta;
- recttemp.ymin+= delta;
- recttemp.xmax-= delta;
- recttemp.ymax-= delta;
+ delta = 1 + (recttemp.ymax - recttemp.ymin) / 8;
+ recttemp.xmin += delta;
+ recttemp.ymin += delta;
+ recttemp.xmax -= delta;
+ recttemp.ymax -= delta;
/* half rounded */
round_box_edges(&wtb, UI_CNR_ALL, &recttemp, 4.0f);
@@ -2711,7 +2719,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN
widgetbase_draw(&wtb, wcol);
/* text space */
- rect->xmin += (rect->ymax-rect->ymin)*0.7 + delta;
+ rect->xmin += (rect->ymax - rect->ymin) * 0.7 + delta;
}
@@ -2752,7 +2760,7 @@ static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED(
/* store the box bg as gl clearcolor, to retrieve later when drawing semi-transparent rects
* over the top to indicate disabled buttons */
/* XXX, this doesnt work right since the color applies to buttons outside the box too. */
- glClearColor(wcol->inner[0]/255.0, wcol->inner[1]/255.0, wcol->inner[2]/255.0, 1.0);
+ glClearColor(wcol->inner[0] / 255.0, wcol->inner[1] / 255.0, wcol->inner[2] / 255.0, 1.0);
copy_v3_v3_char(wcol->inner, old_col);
}
@@ -2773,7 +2781,7 @@ static void widget_but(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int
static void widget_roundbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
{
uiWidgetBase wtb;
- float rad= 5.0f; //0.5f*(rect->ymax - rect->ymin);
+ float rad = 5.0f; //0.5f*(rect->ymax - rect->ymin);
widget_init(&wtb);
@@ -2789,7 +2797,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *
unsigned char col[4];
/* state copy! */
- wt->wcol= *(wt->wcol_theme);
+ wt->wcol = *(wt->wcol_theme);
widget_init(&wtb);
@@ -2807,8 +2815,8 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *
/* outline */
round_box_edges(&wtb, UI_CNR_ALL, rect, 5.0f);
- wtb.outline= 1;
- wtb.inner= 0;
+ wtb.outline = 1;
+ wtb.inner = 0;
widgetbase_draw(&wtb, &wt->wcol);
}
@@ -2826,61 +2834,61 @@ static void widget_disabled(rcti *rect)
/* need -1 and +1 to make it work right for aligned buttons,
* but problem may be somewhere else? */
- glRectf(rect->xmin-1, rect->ymin-1, rect->xmax, rect->ymax+1);
+ glRectf(rect->xmin - 1, rect->ymin - 1, rect->xmax, rect->ymax + 1);
glDisable(GL_BLEND);
}
static uiWidgetType *widget_type(uiWidgetTypeEnum type)
{
- bTheme *btheme= UI_GetTheme();
+ bTheme *btheme = UI_GetTheme();
static uiWidgetType wt;
/* defaults */
- wt.wcol_theme= &btheme->tui.wcol_regular;
- wt.wcol_state= &btheme->tui.wcol_state;
- wt.state= widget_state;
- wt.draw= widget_but;
- wt.custom= NULL;
- wt.text= widget_draw_text_icon;
-
- switch(type) {
+ wt.wcol_theme = &btheme->tui.wcol_regular;
+ wt.wcol_state = &btheme->tui.wcol_state;
+ wt.state = widget_state;
+ wt.draw = widget_but;
+ wt.custom = NULL;
+ wt.text = widget_draw_text_icon;
+
+ switch (type) {
case UI_WTYPE_REGULAR:
break;
case UI_WTYPE_LABEL:
- wt.draw= NULL;
- wt.state= widget_state_label;
+ wt.draw = NULL;
+ wt.state = widget_state_label;
break;
case UI_WTYPE_TOGGLE:
- wt.wcol_theme= &btheme->tui.wcol_toggle;
+ wt.wcol_theme = &btheme->tui.wcol_toggle;
break;
case UI_WTYPE_OPTION:
- wt.wcol_theme= &btheme->tui.wcol_option;
- wt.draw= widget_optionbut;
+ wt.wcol_theme = &btheme->tui.wcol_option;
+ wt.draw = widget_optionbut;
break;
case UI_WTYPE_RADIO:
- wt.wcol_theme= &btheme->tui.wcol_radio;
- wt.draw= widget_radiobut;
+ wt.wcol_theme = &btheme->tui.wcol_radio;
+ wt.draw = widget_radiobut;
break;
case UI_WTYPE_NUMBER:
- wt.wcol_theme= &btheme->tui.wcol_num;
- wt.draw= widget_numbut;
+ wt.wcol_theme = &btheme->tui.wcol_num;
+ wt.draw = widget_numbut;
break;
case UI_WTYPE_SLIDER:
- wt.wcol_theme= &btheme->tui.wcol_numslider;
- wt.custom= widget_numslider;
- wt.state= widget_state_numslider;
+ wt.wcol_theme = &btheme->tui.wcol_numslider;
+ wt.custom = widget_numslider;
+ wt.state = widget_state_numslider;
break;
case UI_WTYPE_EXEC:
- wt.wcol_theme= &btheme->tui.wcol_tool;
- wt.draw= widget_roundbut;
+ wt.wcol_theme = &btheme->tui.wcol_tool;
+ wt.draw = widget_roundbut;
break;
case UI_WTYPE_TOOLTIP:
@@ -2889,10 +2897,10 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
break;
- /* strings */
+ /* strings */
case UI_WTYPE_NAME:
- wt.wcol_theme= &btheme->tui.wcol_text;
- wt.draw= widget_textbut;
+ wt.wcol_theme = &btheme->tui.wcol_text;
+ wt.draw = widget_textbut;
break;
case UI_WTYPE_NAME_LINK:
@@ -2905,57 +2913,57 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
break;
- /* start menus */
+ /* start menus */
case UI_WTYPE_MENU_RADIO:
- wt.wcol_theme= &btheme->tui.wcol_menu;
- wt.draw= widget_menubut;
+ wt.wcol_theme = &btheme->tui.wcol_menu;
+ wt.draw = widget_menubut;
break;
case UI_WTYPE_MENU_ICON_RADIO:
- wt.wcol_theme= &btheme->tui.wcol_menu;
- wt.draw= widget_menuiconbut;
+ wt.wcol_theme = &btheme->tui.wcol_menu;
+ wt.draw = widget_menuiconbut;
break;
case UI_WTYPE_MENU_POINTER_LINK:
- wt.wcol_theme= &btheme->tui.wcol_menu;
- wt.draw= widget_menubut;
+ wt.wcol_theme = &btheme->tui.wcol_menu;
+ wt.draw = widget_menubut;
break;
case UI_WTYPE_MENU_NODE_LINK:
- wt.wcol_theme= &btheme->tui.wcol_menu;
- wt.draw= widget_menunodebut;
+ wt.wcol_theme = &btheme->tui.wcol_menu;
+ wt.draw = widget_menunodebut;
break;
case UI_WTYPE_PULLDOWN:
- wt.wcol_theme= &btheme->tui.wcol_pulldown;
- wt.draw= widget_pulldownbut;
- wt.state= widget_state_pulldown;
+ wt.wcol_theme = &btheme->tui.wcol_pulldown;
+ wt.draw = widget_pulldownbut;
+ wt.state = widget_state_pulldown;
break;
- /* in menus */
+ /* in menus */
case UI_WTYPE_MENU_ITEM:
- wt.wcol_theme= &btheme->tui.wcol_menu_item;
- wt.draw= widget_menu_itembut;
- wt.state= widget_state_menu_item;
+ wt.wcol_theme = &btheme->tui.wcol_menu_item;
+ wt.draw = widget_menu_itembut;
+ wt.state = widget_state_menu_item;
break;
case UI_WTYPE_MENU_BACK:
- wt.wcol_theme= &btheme->tui.wcol_menu_back;
- wt.draw= widget_menu_back;
+ wt.wcol_theme = &btheme->tui.wcol_menu_back;
+ wt.draw = widget_menu_back;
break;
- /* specials */
+ /* specials */
case UI_WTYPE_ICON:
- wt.custom= widget_icon_has_anim;
+ wt.custom = widget_icon_has_anim;
break;
case UI_WTYPE_SWATCH:
- wt.custom= widget_swatch;
+ wt.custom = widget_swatch;
break;
case UI_WTYPE_BOX:
- wt.custom= widget_box;
- wt.wcol_theme= &btheme->tui.wcol_box;
+ wt.custom = widget_box;
+ wt.wcol_theme = &btheme->tui.wcol_box;
break;
case UI_WTYPE_RGB_PICKER:
@@ -2965,19 +2973,19 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
break;
case UI_WTYPE_SCROLL:
- wt.wcol_theme= &btheme->tui.wcol_scroll;
- wt.state= widget_state_nothing;
- wt.custom= widget_scroll;
+ wt.wcol_theme = &btheme->tui.wcol_scroll;
+ wt.state = widget_state_nothing;
+ wt.custom = widget_scroll;
break;
case UI_WTYPE_LISTITEM:
- wt.wcol_theme= &btheme->tui.wcol_list_item;
- wt.draw= widget_list_itembut;
+ wt.wcol_theme = &btheme->tui.wcol_list_item;
+ wt.draw = widget_list_itembut;
break;
case UI_WTYPE_PROGRESSBAR:
- wt.wcol_theme= &btheme->tui.wcol_progress;
- wt.custom= widget_progressbar;
+ wt.wcol_theme = &btheme->tui.wcol_progress;
+ wt.custom = widget_progressbar;
break;
}
@@ -2991,11 +2999,11 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
if (but->flag & UI_BUT_ALIGN) {
if (but->flag & UI_BUT_ALIGN_TOP)
- rect->ymax+= 1;
+ rect->ymax += 1;
if (but->flag & UI_BUT_ALIGN_LEFT)
- rect->xmin-= 1;
+ rect->xmin -= 1;
- switch(but->flag & UI_BUT_ALIGN) {
+ switch (but->flag & UI_BUT_ALIGN) {
case UI_BUT_ALIGN_TOP:
return UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT;
case UI_BUT_ALIGN_DOWN:
@@ -3023,13 +3031,13 @@ static int widget_roundbox_set(uiBut *but, rcti *rect)
/* conversion from old to new buttons, so still messy */
void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rcti *rect)
{
- bTheme *btheme= UI_GetTheme();
- ThemeUI *tui= &btheme->tui;
- uiFontStyle *fstyle= &style->widget;
- uiWidgetType *wt= NULL;
+ bTheme *btheme = UI_GetTheme();
+ ThemeUI *tui = &btheme->tui;
+ uiFontStyle *fstyle = &style->widget;
+ uiWidgetType *wt = NULL;
/* handle menus separately */
- if (but->dt==UI_EMBOSSP) {
+ if (but->dt == UI_EMBOSSP) {
switch (but->type) {
case LABEL:
widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect);
@@ -3039,12 +3047,12 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
break;
default:
- wt= widget_type(UI_WTYPE_MENU_ITEM);
+ wt = widget_type(UI_WTYPE_MENU_ITEM);
}
}
- else if (but->dt==UI_EMBOSSN) {
+ else if (but->dt == UI_EMBOSSN) {
/* "nothing" */
- wt= widget_type(UI_WTYPE_ICON);
+ wt = widget_type(UI_WTYPE_ICON);
}
else {
@@ -3053,8 +3061,8 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
if (but->block->flag & UI_BLOCK_LOOP)
widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect);
else {
- wt= widget_type(UI_WTYPE_LABEL);
- fstyle= &style->widgetlabel;
+ wt = widget_type(UI_WTYPE_LABEL);
+ fstyle = &style->widgetlabel;
}
break;
@@ -3062,55 +3070,55 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
break;
case BUT:
- wt= widget_type(UI_WTYPE_EXEC);
+ wt = widget_type(UI_WTYPE_EXEC);
break;
case NUM:
- wt= widget_type(UI_WTYPE_NUMBER);
+ wt = widget_type(UI_WTYPE_NUMBER);
break;
case NUMSLI:
case HSVSLI:
- wt= widget_type(UI_WTYPE_SLIDER);
+ wt = widget_type(UI_WTYPE_SLIDER);
break;
case ROW:
- wt= widget_type(UI_WTYPE_RADIO);
+ wt = widget_type(UI_WTYPE_RADIO);
break;
case LISTROW:
- wt= widget_type(UI_WTYPE_LISTITEM);
+ wt = widget_type(UI_WTYPE_LISTITEM);
break;
case TEX:
- wt= widget_type(UI_WTYPE_NAME);
+ wt = widget_type(UI_WTYPE_NAME);
break;
case SEARCH_MENU:
- wt= widget_type(UI_WTYPE_NAME);
+ wt = widget_type(UI_WTYPE_NAME);
if (but->block->flag & UI_BLOCK_LOOP)
- wt->wcol_theme= &btheme->tui.wcol_menu_back;
+ wt->wcol_theme = &btheme->tui.wcol_menu_back;
break;
case TOGBUT:
case TOG:
case TOGN:
case TOG3:
- wt= widget_type(UI_WTYPE_TOGGLE);
+ wt = widget_type(UI_WTYPE_TOGGLE);
break;
case OPTION:
case OPTIONN:
if (!(but->flag & UI_HAS_ICON)) {
- wt= widget_type(UI_WTYPE_OPTION);
+ wt = widget_type(UI_WTYPE_OPTION);
but->flag |= UI_TEXT_LEFT;
}
else
- wt= widget_type(UI_WTYPE_TOGGLE);
+ wt = widget_type(UI_WTYPE_TOGGLE);
/* option buttons have strings outside, on menus use different colors */
if (but->block->flag & UI_BLOCK_LOOP)
- wt->state= widget_state_option_menu;
+ wt->state = widget_state_option_menu;
break;
@@ -3118,34 +3126,34 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
case BLOCK:
case ICONTEXTROW:
if (but->flag & UI_BUT_NODE_LINK)
- wt= widget_type(UI_WTYPE_MENU_NODE_LINK);
+ wt = widget_type(UI_WTYPE_MENU_NODE_LINK);
else if (!but->str[0] && but->icon)
- wt= widget_type(UI_WTYPE_MENU_ICON_RADIO);
+ wt = widget_type(UI_WTYPE_MENU_ICON_RADIO);
else
- wt= widget_type(UI_WTYPE_MENU_RADIO);
+ wt = widget_type(UI_WTYPE_MENU_RADIO);
break;
case PULLDOWN:
- wt= widget_type(UI_WTYPE_PULLDOWN);
+ wt = widget_type(UI_WTYPE_PULLDOWN);
break;
case BUTM:
- wt= widget_type(UI_WTYPE_MENU_ITEM);
+ wt = widget_type(UI_WTYPE_MENU_ITEM);
break;
case COL:
- wt= widget_type(UI_WTYPE_SWATCH);
+ wt = widget_type(UI_WTYPE_SWATCH);
break;
case ROUNDBOX:
case LISTBOX:
- wt= widget_type(UI_WTYPE_BOX);
+ wt = widget_type(UI_WTYPE_BOX);
break;
case LINK:
case INLINK:
- wt= widget_type(UI_WTYPE_ICON);
- wt->custom= widget_link;
+ wt = widget_type(UI_WTYPE_ICON);
+ wt->custom = widget_link;
break;
@@ -3193,12 +3201,12 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
break;
case PROGRESSBAR:
- wt= widget_type(UI_WTYPE_PROGRESSBAR);
- fstyle= &style->widgetlabel;
+ wt = widget_type(UI_WTYPE_PROGRESSBAR);
+ fstyle = &style->widgetlabel;
break;
case SCROLL:
- wt= widget_type(UI_WTYPE_SCROLL);
+ wt = widget_type(UI_WTYPE_SCROLL);
break;
case TRACKPREVIEW:
@@ -3206,17 +3214,17 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
break;
default:
- wt= widget_type(UI_WTYPE_REGULAR);
+ wt = widget_type(UI_WTYPE_REGULAR);
}
}
if (wt) {
- rcti disablerect= *rect; /* rect gets clipped smaller for text */
+ rcti disablerect = *rect; /* rect gets clipped smaller for text */
int roundboxalign, state;
- roundboxalign= widget_roundbox_set(but, rect);
+ roundboxalign = widget_roundbox_set(but, rect);
- state= but->flag;
+ state = but->flag;
if (but->editstr) state |= UI_TEXTINPUT;
wt->state(wt, state);
@@ -3226,15 +3234,15 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
wt->draw(&wt->wcol, rect, state, roundboxalign);
wt->text(fstyle, &wt->wcol, but, rect);
- if (state & (UI_BUT_DISABLED|UI_BUT_INACTIVE))
- if (but->dt!=UI_EMBOSSP)
+ if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE))
+ if (but->dt != UI_EMBOSSP)
widget_disabled(&disablerect);
}
}
void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
{
- uiWidgetType *wt= widget_type(UI_WTYPE_MENU_BACK);
+ uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK);
wt->state(wt, 0);
if (block)
@@ -3245,18 +3253,18 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
if (block) {
if (block->flag & UI_BLOCK_CLIPTOP) {
/* XXX no scaling for UI here yet */
- glColor3ubv((unsigned char*)wt->wcol.text);
- UI_DrawTriIcon((rect->xmax+rect->xmin)/2, rect->ymax-8, 't');
+ glColor3ubv((unsigned char *)wt->wcol.text);
+ UI_DrawTriIcon((rect->xmax + rect->xmin) / 2, rect->ymax - 8, 't');
}
if (block->flag & UI_BLOCK_CLIPBOTTOM) {
/* XXX no scaling for UI here yet */
- glColor3ubv((unsigned char*)wt->wcol.text);
- UI_DrawTriIcon((rect->xmax+rect->xmin)/2, rect->ymin+10, 'v');
+ glColor3ubv((unsigned char *)wt->wcol.text);
+ UI_DrawTriIcon((rect->xmax + rect->xmin) / 2, rect->ymin + 10, 'v');
}
}
}
-uiWidgetColors* ui_tooltip_get_theme(void) {
+uiWidgetColors *ui_tooltip_get_theme(void) {
uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP);
return wt->wcol_theme;
}
@@ -3271,7 +3279,7 @@ void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *UNUSED(block),
void ui_draw_search_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
{
- uiWidgetType *wt= widget_type(UI_WTYPE_BOX);
+ uiWidgetType *wt = widget_type(UI_WTYPE_BOX);
glEnable(GL_BLEND);
widget_softshadow(rect, UI_CNR_ALL, 5.0f, 8.0f);
@@ -3290,44 +3298,44 @@ void ui_draw_search_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
/* state: UI_ACTIVE or 0 */
void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int iconid, int state)
{
- uiWidgetType *wt= widget_type(UI_WTYPE_MENU_ITEM);
- rcti _rect= *rect;
+ uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
+ rcti _rect = *rect;
char *cpoin;
wt->state(wt, state);
wt->draw(&wt->wcol, rect, 0, 0);
uiStyleFontSet(fstyle);
- fstyle->align= UI_STYLE_TEXT_LEFT;
+ fstyle->align = UI_STYLE_TEXT_LEFT;
/* text location offset */
- rect->xmin+=5;
- if (iconid) rect->xmin+= UI_DPI_ICON_SIZE;
+ rect->xmin += 5;
+ if (iconid) rect->xmin += UI_DPI_ICON_SIZE;
/* cut string in 2 parts? */
- cpoin= strchr(name, '|');
+ cpoin = strchr(name, '|');
if (cpoin) {
- *cpoin= 0;
- rect->xmax -= BLF_width(fstyle->uifont_id, cpoin+1) + 10;
+ *cpoin = 0;
+ rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1) + 10;
}
- glColor3ubv((unsigned char*)wt->wcol.text);
+ glColor3ubv((unsigned char *)wt->wcol.text);
uiStyleFontDraw(fstyle, rect, name);
/* part text right aligned */
if (cpoin) {
- fstyle->align= UI_STYLE_TEXT_RIGHT;
+ fstyle->align = UI_STYLE_TEXT_RIGHT;
rect->xmax = _rect.xmax - 5;
- uiStyleFontDraw(fstyle, rect, cpoin+1);
- *cpoin= '|';
+ uiStyleFontDraw(fstyle, rect, cpoin + 1);
+ *cpoin = '|';
}
/* restore rect, was messed with */
- *rect= _rect;
+ *rect = _rect;
if (iconid) {
- int xs= rect->xmin+4;
- int ys= 1 + (rect->ymin+rect->ymax- UI_DPI_ICON_SIZE)/2;
+ int xs = rect->xmin + 4;
+ int ys = 1 + (rect->ymin + rect->ymax - UI_DPI_ICON_SIZE) / 2;
glEnable(GL_BLEND);
UI_icon_draw_aspect(xs, ys, iconid, 1.2f, 0.5f); /* XXX scale weak get from fstyle? */
glDisable(GL_BLEND);
@@ -3338,7 +3346,7 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int
{
rcti trect = *rect, bg_rect;
float font_dims[2] = {0.0f, 0.0f};
- uiWidgetType *wt= widget_type(UI_WTYPE_MENU_ITEM);
+ uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
unsigned char bg_col[3];
wt->state(wt, state);
@@ -3366,15 +3374,15 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int
bg_rect.xmax = rect->xmax - PREVIEW_PAD;
UI_GetThemeColor3ubv(TH_BUTBACK, bg_col);
- glColor4ubv((unsigned char*)wt->wcol.item);
+ glColor4ubv((unsigned char *)wt->wcol.item);
glEnable(GL_BLEND);
glRecti(bg_rect.xmin, bg_rect.ymin, bg_rect.xmax, bg_rect.ymax);
glDisable(GL_BLEND);
if (state == UI_ACTIVE)
- glColor3ubv((unsigned char*)wt->wcol.text);
+ glColor3ubv((unsigned char *)wt->wcol.text);
else
- glColor3ubv((unsigned char*)wt->wcol.text_sel);
+ glColor3ubv((unsigned char *)wt->wcol.text_sel);
uiStyleFontDraw(fstyle, &trect, name);
}
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 64061a8f76b..9f4a351c66d 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -61,9 +61,9 @@
/* global for themes */
typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha);
-static bTheme *theme_active=NULL;
-static int theme_spacetype= SPACE_VIEW3D;
-static int theme_regionid= RGN_TYPE_WINDOW;
+static bTheme *theme_active = NULL;
+static int theme_spacetype = SPACE_VIEW3D;
+static int theme_regionid = RGN_TYPE_WINDOW;
void ui_resources_init(void)
{
@@ -82,393 +82,393 @@ void ui_resources_free(void)
const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
{
- ThemeSpace *ts= NULL;
- static char error[4]={240, 0, 240, 255};
- static char alert[4]={240, 60, 60, 255};
- static char headerdesel[4]={0,0,0,255};
+ ThemeSpace *ts = NULL;
+ static char error[4] = {240, 0, 240, 255};
+ static char alert[4] = {240, 60, 60, 255};
+ static char headerdesel[4] = {0, 0, 0, 255};
- const char *cp= error;
+ const char *cp = error;
if (btheme) {
// first check for ui buttons theme
if (colorid < TH_THEMEUI) {
- switch(colorid) {
+ switch (colorid) {
- case TH_REDALERT:
- cp= alert; break;
+ case TH_REDALERT:
+ cp = alert; break;
}
}
else {
- switch(spacetype) {
- case SPACE_BUTS:
- ts= &btheme->tbuts;
- break;
- case SPACE_VIEW3D:
- ts= &btheme->tv3d;
- break;
- case SPACE_IPO:
- ts= &btheme->tipo;
- break;
- case SPACE_FILE:
- ts= &btheme->tfile;
- break;
- case SPACE_NLA:
- ts= &btheme->tnla;
- break;
- case SPACE_ACTION:
- ts= &btheme->tact;
- break;
- case SPACE_SEQ:
- ts= &btheme->tseq;
- break;
- case SPACE_IMAGE:
- ts= &btheme->tima;
- break;
- case SPACE_TEXT:
- ts= &btheme->text;
- break;
- case SPACE_OUTLINER:
- ts= &btheme->toops;
- break;
- case SPACE_INFO:
- ts= &btheme->tinfo;
- break;
- case SPACE_USERPREF:
- ts= &btheme->tuserpref;
- break;
- case SPACE_CONSOLE:
- ts= &btheme->tconsole;
- break;
- case SPACE_TIME:
- ts= &btheme->ttime;
- break;
- case SPACE_NODE:
- ts= &btheme->tnode;
- break;
- case SPACE_LOGIC:
- ts= &btheme->tlogic;
- break;
- case SPACE_CLIP:
- ts= &btheme->tclip;
- break;
- default:
- ts= &btheme->tv3d;
- break;
+ switch (spacetype) {
+ case SPACE_BUTS:
+ ts = &btheme->tbuts;
+ break;
+ case SPACE_VIEW3D:
+ ts = &btheme->tv3d;
+ break;
+ case SPACE_IPO:
+ ts = &btheme->tipo;
+ break;
+ case SPACE_FILE:
+ ts = &btheme->tfile;
+ break;
+ case SPACE_NLA:
+ ts = &btheme->tnla;
+ break;
+ case SPACE_ACTION:
+ ts = &btheme->tact;
+ break;
+ case SPACE_SEQ:
+ ts = &btheme->tseq;
+ break;
+ case SPACE_IMAGE:
+ ts = &btheme->tima;
+ break;
+ case SPACE_TEXT:
+ ts = &btheme->text;
+ break;
+ case SPACE_OUTLINER:
+ ts = &btheme->toops;
+ break;
+ case SPACE_INFO:
+ ts = &btheme->tinfo;
+ break;
+ case SPACE_USERPREF:
+ ts = &btheme->tuserpref;
+ break;
+ case SPACE_CONSOLE:
+ ts = &btheme->tconsole;
+ break;
+ case SPACE_TIME:
+ ts = &btheme->ttime;
+ break;
+ case SPACE_NODE:
+ ts = &btheme->tnode;
+ break;
+ case SPACE_LOGIC:
+ ts = &btheme->tlogic;
+ break;
+ case SPACE_CLIP:
+ ts = &btheme->tclip;
+ break;
+ default:
+ ts = &btheme->tv3d;
+ break;
}
-
- switch(colorid) {
- case TH_BACK:
- if (theme_regionid==RGN_TYPE_WINDOW)
- cp= ts->back;
- else if (theme_regionid==RGN_TYPE_CHANNELS)
- cp= ts->list;
- else if (theme_regionid==RGN_TYPE_HEADER)
- cp= ts->header;
- else
- cp= ts->button;
- break;
- case TH_TEXT:
- if (theme_regionid==RGN_TYPE_WINDOW)
- cp= ts->text;
- else if (theme_regionid==RGN_TYPE_CHANNELS)
- cp= ts->list_text;
- else if (theme_regionid==RGN_TYPE_HEADER)
- cp= ts->header_text;
- else
- cp= ts->button_text;
- break;
- case TH_TEXT_HI:
- if (theme_regionid==RGN_TYPE_WINDOW)
- cp= ts->text_hi;
- else if (theme_regionid==RGN_TYPE_CHANNELS)
- cp= ts->list_text_hi;
- else if (theme_regionid==RGN_TYPE_HEADER)
- cp= ts->header_text_hi;
- else
- cp= ts->button_text_hi;
- break;
- case TH_TITLE:
- if (theme_regionid==RGN_TYPE_WINDOW)
- cp= ts->title;
- else if (theme_regionid==RGN_TYPE_CHANNELS)
- cp= ts->list_title;
- else if (theme_regionid==RGN_TYPE_HEADER)
- cp= ts->header_title;
- else
- cp= ts->button_title;
- break;
-
- case TH_HEADER:
- cp= ts->header; break;
- case TH_HEADERDESEL:
- /* we calculate a dynamic builtin header deselect color, also for pulldowns... */
- cp= ts->header;
- headerdesel[0]= cp[0]>10?cp[0]-10:0;
- headerdesel[1]= cp[1]>10?cp[1]-10:0;
- headerdesel[2]= cp[2]>10?cp[2]-10:0;
- cp= headerdesel;
- break;
- case TH_HEADER_TEXT:
- cp= ts->header_text; break;
- case TH_HEADER_TEXT_HI:
- cp= ts->header_text_hi; break;
-
- case TH_PANEL:
- cp= ts->panel; break;
- case TH_PANEL_TEXT:
- cp= ts->panel_text; break;
- case TH_PANEL_TEXT_HI:
- cp= ts->panel_text_hi; break;
-
- case TH_BUTBACK:
- cp= ts->button; break;
- case TH_BUTBACK_TEXT:
- cp= ts->button_text; break;
- case TH_BUTBACK_TEXT_HI:
- cp= ts->button_text_hi; break;
-
- case TH_SHADE1:
- cp= ts->shade1; break;
- case TH_SHADE2:
- cp= ts->shade2; break;
- case TH_HILITE:
- cp= ts->hilite; break;
-
- case TH_GRID:
- cp= ts->grid; break;
- case TH_WIRE:
- cp= ts->wire; break;
- case TH_LAMP:
- cp= ts->lamp; break;
- case TH_SPEAKER:
- cp= ts->speaker; break;
- case TH_CAMERA:
- cp= ts->camera; break;
- case TH_EMPTY:
- cp= ts->empty; break;
- case TH_SELECT:
- cp= ts->select; break;
- case TH_ACTIVE:
- cp= ts->active; break;
- case TH_GROUP:
- cp= ts->group; break;
- case TH_GROUP_ACTIVE:
- cp= ts->group_active; break;
- case TH_TRANSFORM:
- cp= ts->transform; break;
- case TH_VERTEX:
- cp= ts->vertex; break;
- case TH_VERTEX_SELECT:
- cp= ts->vertex_select; break;
- case TH_VERTEX_SIZE:
- cp= &ts->vertex_size; break;
- case TH_OUTLINE_WIDTH:
- cp= &ts->outline_width; break;
- case TH_EDGE:
- cp= ts->edge; break;
- case TH_EDGE_SELECT:
- cp= ts->edge_select; break;
- case TH_EDGE_SEAM:
- cp= ts->edge_seam; break;
- case TH_EDGE_SHARP:
- cp= ts->edge_sharp; break;
- case TH_EDGE_CREASE:
- cp= ts->edge_crease; break;
- case TH_EDITMESH_ACTIVE:
- cp= ts->editmesh_active; break;
- case TH_EDGE_FACESEL:
- cp= ts->edge_facesel; break;
- case TH_FACE:
- cp= ts->face; break;
- case TH_FACE_SELECT:
- cp= ts->face_select; break;
- case TH_FACE_DOT:
- cp= ts->face_dot; break;
- case TH_FACEDOT_SIZE:
- cp= &ts->facedot_size; break;
- case TH_DRAWEXTRA_EDGELEN:
- cp= ts->extra_edge_len; break;
- case TH_DRAWEXTRA_FACEAREA:
- cp= ts->extra_face_area; break;
- case TH_DRAWEXTRA_FACEANG:
- cp= ts->extra_face_angle; break;
- case TH_NORMAL:
- cp= ts->normal; break;
- case TH_VNORMAL:
- cp= ts->vertex_normal; break;
- case TH_BONE_SOLID:
- cp= ts->bone_solid; break;
- case TH_BONE_POSE:
- cp= ts->bone_pose; break;
- case TH_STRIP:
- cp= ts->strip; break;
- case TH_STRIP_SELECT:
- cp= ts->strip_select; break;
- case TH_CFRAME:
- cp= ts->cframe; break;
- case TH_NURB_ULINE:
- cp= ts->nurb_uline; break;
- case TH_NURB_VLINE:
- cp= ts->nurb_vline; break;
- case TH_NURB_SEL_ULINE:
- cp= ts->nurb_sel_uline; break;
- case TH_NURB_SEL_VLINE:
- cp= ts->nurb_sel_vline; break;
- case TH_ACTIVE_SPLINE:
- cp= ts->act_spline; break;
- case TH_LASTSEL_POINT:
- cp= ts->lastsel_point; break;
- case TH_HANDLE_FREE:
- cp= ts->handle_free; break;
- case TH_HANDLE_AUTO:
- cp= ts->handle_auto; break;
- case TH_HANDLE_AUTOCLAMP:
- cp= ts->handle_auto_clamped; break;
- case TH_HANDLE_VECT:
- cp= ts->handle_vect; break;
- case TH_HANDLE_ALIGN:
- cp= ts->handle_align; break;
- case TH_HANDLE_SEL_FREE:
- cp= ts->handle_sel_free; break;
- case TH_HANDLE_SEL_AUTO:
- cp= ts->handle_sel_auto; break;
- case TH_HANDLE_SEL_AUTOCLAMP:
- cp= ts->handle_sel_auto_clamped; break;
- case TH_HANDLE_SEL_VECT:
- cp= ts->handle_sel_vect; break;
- case TH_HANDLE_SEL_ALIGN:
- cp= ts->handle_sel_align; break;
-
- case TH_SYNTAX_B:
- cp= ts->syntaxb; break;
- case TH_SYNTAX_V:
- cp= ts->syntaxv; break;
- case TH_SYNTAX_C:
- cp= ts->syntaxc; break;
- case TH_SYNTAX_L:
- cp= ts->syntaxl; break;
- case TH_SYNTAX_N:
- cp= ts->syntaxn; break;
-
- case TH_NODE:
- cp= ts->syntaxl; break;
- case TH_NODE_IN_OUT:
- cp= ts->syntaxn; break;
- case TH_NODE_OPERATOR:
- cp= ts->syntaxb; break;
- case TH_NODE_CONVERTOR:
- cp= ts->syntaxv; break;
- case TH_NODE_GROUP:
- cp= ts->syntaxc; break;
- case TH_NODE_CURVING:
- cp= &ts->noodle_curving; break;
-
- case TH_SEQ_MOVIE:
- cp= ts->movie; break;
- case TH_SEQ_MOVIECLIP:
- cp= ts->movieclip; break;
- case TH_SEQ_IMAGE:
- cp= ts->image; break;
- case TH_SEQ_SCENE:
- cp= ts->scene; break;
- case TH_SEQ_AUDIO:
- cp= ts->audio; break;
- case TH_SEQ_EFFECT:
- cp= ts->effect; break;
- case TH_SEQ_PLUGIN:
- cp= ts->plugin; break;
- case TH_SEQ_TRANSITION:
- cp= ts->transition; break;
- case TH_SEQ_META:
- cp= ts->meta; break;
- case TH_SEQ_PREVIEW:
- cp= ts->preview_back; break;
-
- case TH_CONSOLE_OUTPUT:
- cp= ts->console_output; break;
- case TH_CONSOLE_INPUT:
- cp= ts-> console_input; break;
- case TH_CONSOLE_INFO:
- cp= ts->console_info; break;
- case TH_CONSOLE_ERROR:
- cp= ts->console_error; break;
- case TH_CONSOLE_CURSOR:
- cp= ts->console_cursor; break;
-
- case TH_HANDLE_VERTEX:
- cp= ts->handle_vertex;
- break;
- case TH_HANDLE_VERTEX_SELECT:
- cp= ts->handle_vertex_select;
- break;
- case TH_HANDLE_VERTEX_SIZE:
- cp= &ts->handle_vertex_size;
- break;
-
- case TH_DOPESHEET_CHANNELOB:
- cp= ts->ds_channel;
- break;
- case TH_DOPESHEET_CHANNELSUBOB:
- cp= ts->ds_subchannel;
- break;
-
- case TH_PREVIEW_BACK:
- cp= ts->preview_back;
- break;
-
- case TH_STITCH_PREVIEW_FACE:
- cp = ts->preview_stitch_face;
- break;
-
- case TH_STITCH_PREVIEW_EDGE:
- cp = ts->preview_stitch_edge;
- break;
-
- case TH_STITCH_PREVIEW_VERT:
- cp = ts->preview_stitch_vert;
- break;
-
- case TH_STITCH_PREVIEW_STITCHABLE:
- cp = ts->preview_stitch_stitchable;
- break;
-
- case TH_STITCH_PREVIEW_UNSTITCHABLE:
- cp = ts->preview_stitch_unstitchable;
- break;
- case TH_STITCH_PREVIEW_ACTIVE:
- cp = ts->preview_stitch_active;
- break;
- case TH_MARKER_OUTLINE:
- cp= ts->marker_outline; break;
- case TH_MARKER:
- cp= ts->marker; break;
- case TH_ACT_MARKER:
- cp= ts->act_marker; break;
- case TH_SEL_MARKER:
- cp= ts->sel_marker; break;
- case TH_BUNDLE_SOLID:
- cp= ts->bundle_solid; break;
- case TH_DIS_MARKER:
- cp= ts->dis_marker; break;
- case TH_PATH_BEFORE:
- cp= ts->path_before; break;
- case TH_PATH_AFTER:
- cp= ts->path_after; break;
- case TH_CAMERA_PATH:
- cp= ts->camera_path; break;
- case TH_LOCK_MARKER:
- cp= ts->lock_marker; break;
-
- case TH_MATCH:
- cp= ts->match;
- break;
-
- case TH_SELECT_HIGHLIGHT:
- cp= ts->selected_highlight;
- break;
+
+ switch (colorid) {
+ case TH_BACK:
+ if (theme_regionid == RGN_TYPE_WINDOW)
+ cp = ts->back;
+ else if (theme_regionid == RGN_TYPE_CHANNELS)
+ cp = ts->list;
+ else if (theme_regionid == RGN_TYPE_HEADER)
+ cp = ts->header;
+ else
+ cp = ts->button;
+ break;
+ case TH_TEXT:
+ if (theme_regionid == RGN_TYPE_WINDOW)
+ cp = ts->text;
+ else if (theme_regionid == RGN_TYPE_CHANNELS)
+ cp = ts->list_text;
+ else if (theme_regionid == RGN_TYPE_HEADER)
+ cp = ts->header_text;
+ else
+ cp = ts->button_text;
+ break;
+ case TH_TEXT_HI:
+ if (theme_regionid == RGN_TYPE_WINDOW)
+ cp = ts->text_hi;
+ else if (theme_regionid == RGN_TYPE_CHANNELS)
+ cp = ts->list_text_hi;
+ else if (theme_regionid == RGN_TYPE_HEADER)
+ cp = ts->header_text_hi;
+ else
+ cp = ts->button_text_hi;
+ break;
+ case TH_TITLE:
+ if (theme_regionid == RGN_TYPE_WINDOW)
+ cp = ts->title;
+ else if (theme_regionid == RGN_TYPE_CHANNELS)
+ cp = ts->list_title;
+ else if (theme_regionid == RGN_TYPE_HEADER)
+ cp = ts->header_title;
+ else
+ cp = ts->button_title;
+ break;
+
+ case TH_HEADER:
+ cp = ts->header; break;
+ case TH_HEADERDESEL:
+ /* we calculate a dynamic builtin header deselect color, also for pulldowns... */
+ cp = ts->header;
+ headerdesel[0] = cp[0] > 10 ? cp[0] - 10 : 0;
+ headerdesel[1] = cp[1] > 10 ? cp[1] - 10 : 0;
+ headerdesel[2] = cp[2] > 10 ? cp[2] - 10 : 0;
+ cp = headerdesel;
+ break;
+ case TH_HEADER_TEXT:
+ cp = ts->header_text; break;
+ case TH_HEADER_TEXT_HI:
+ cp = ts->header_text_hi; break;
+
+ case TH_PANEL:
+ cp = ts->panel; break;
+ case TH_PANEL_TEXT:
+ cp = ts->panel_text; break;
+ case TH_PANEL_TEXT_HI:
+ cp = ts->panel_text_hi; break;
+
+ case TH_BUTBACK:
+ cp = ts->button; break;
+ case TH_BUTBACK_TEXT:
+ cp = ts->button_text; break;
+ case TH_BUTBACK_TEXT_HI:
+ cp = ts->button_text_hi; break;
+
+ case TH_SHADE1:
+ cp = ts->shade1; break;
+ case TH_SHADE2:
+ cp = ts->shade2; break;
+ case TH_HILITE:
+ cp = ts->hilite; break;
+
+ case TH_GRID:
+ cp = ts->grid; break;
+ case TH_WIRE:
+ cp = ts->wire; break;
+ case TH_LAMP:
+ cp = ts->lamp; break;
+ case TH_SPEAKER:
+ cp = ts->speaker; break;
+ case TH_CAMERA:
+ cp = ts->camera; break;
+ case TH_EMPTY:
+ cp = ts->empty; break;
+ case TH_SELECT:
+ cp = ts->select; break;
+ case TH_ACTIVE:
+ cp = ts->active; break;
+ case TH_GROUP:
+ cp = ts->group; break;
+ case TH_GROUP_ACTIVE:
+ cp = ts->group_active; break;
+ case TH_TRANSFORM:
+ cp = ts->transform; break;
+ case TH_VERTEX:
+ cp = ts->vertex; break;
+ case TH_VERTEX_SELECT:
+ cp = ts->vertex_select; break;
+ case TH_VERTEX_SIZE:
+ cp = &ts->vertex_size; break;
+ case TH_OUTLINE_WIDTH:
+ cp = &ts->outline_width; break;
+ case TH_EDGE:
+ cp = ts->edge; break;
+ case TH_EDGE_SELECT:
+ cp = ts->edge_select; break;
+ case TH_EDGE_SEAM:
+ cp = ts->edge_seam; break;
+ case TH_EDGE_SHARP:
+ cp = ts->edge_sharp; break;
+ case TH_EDGE_CREASE:
+ cp = ts->edge_crease; break;
+ case TH_EDITMESH_ACTIVE:
+ cp = ts->editmesh_active; break;
+ case TH_EDGE_FACESEL:
+ cp = ts->edge_facesel; break;
+ case TH_FACE:
+ cp = ts->face; break;
+ case TH_FACE_SELECT:
+ cp = ts->face_select; break;
+ case TH_FACE_DOT:
+ cp = ts->face_dot; break;
+ case TH_FACEDOT_SIZE:
+ cp = &ts->facedot_size; break;
+ case TH_DRAWEXTRA_EDGELEN:
+ cp = ts->extra_edge_len; break;
+ case TH_DRAWEXTRA_FACEAREA:
+ cp = ts->extra_face_area; break;
+ case TH_DRAWEXTRA_FACEANG:
+ cp = ts->extra_face_angle; break;
+ case TH_NORMAL:
+ cp = ts->normal; break;
+ case TH_VNORMAL:
+ cp = ts->vertex_normal; break;
+ case TH_BONE_SOLID:
+ cp = ts->bone_solid; break;
+ case TH_BONE_POSE:
+ cp = ts->bone_pose; break;
+ case TH_STRIP:
+ cp = ts->strip; break;
+ case TH_STRIP_SELECT:
+ cp = ts->strip_select; break;
+ case TH_CFRAME:
+ cp = ts->cframe; break;
+ case TH_NURB_ULINE:
+ cp = ts->nurb_uline; break;
+ case TH_NURB_VLINE:
+ cp = ts->nurb_vline; break;
+ case TH_NURB_SEL_ULINE:
+ cp = ts->nurb_sel_uline; break;
+ case TH_NURB_SEL_VLINE:
+ cp = ts->nurb_sel_vline; break;
+ case TH_ACTIVE_SPLINE:
+ cp = ts->act_spline; break;
+ case TH_LASTSEL_POINT:
+ cp = ts->lastsel_point; break;
+ case TH_HANDLE_FREE:
+ cp = ts->handle_free; break;
+ case TH_HANDLE_AUTO:
+ cp = ts->handle_auto; break;
+ case TH_HANDLE_AUTOCLAMP:
+ cp = ts->handle_auto_clamped; break;
+ case TH_HANDLE_VECT:
+ cp = ts->handle_vect; break;
+ case TH_HANDLE_ALIGN:
+ cp = ts->handle_align; break;
+ case TH_HANDLE_SEL_FREE:
+ cp = ts->handle_sel_free; break;
+ case TH_HANDLE_SEL_AUTO:
+ cp = ts->handle_sel_auto; break;
+ case TH_HANDLE_SEL_AUTOCLAMP:
+ cp = ts->handle_sel_auto_clamped; break;
+ case TH_HANDLE_SEL_VECT:
+ cp = ts->handle_sel_vect; break;
+ case TH_HANDLE_SEL_ALIGN:
+ cp = ts->handle_sel_align; break;
+
+ case TH_SYNTAX_B:
+ cp = ts->syntaxb; break;
+ case TH_SYNTAX_V:
+ cp = ts->syntaxv; break;
+ case TH_SYNTAX_C:
+ cp = ts->syntaxc; break;
+ case TH_SYNTAX_L:
+ cp = ts->syntaxl; break;
+ case TH_SYNTAX_N:
+ cp = ts->syntaxn; break;
+
+ case TH_NODE:
+ cp = ts->syntaxl; break;
+ case TH_NODE_IN_OUT:
+ cp = ts->syntaxn; break;
+ case TH_NODE_OPERATOR:
+ cp = ts->syntaxb; break;
+ case TH_NODE_CONVERTOR:
+ cp = ts->syntaxv; break;
+ case TH_NODE_GROUP:
+ cp = ts->syntaxc; break;
+ case TH_NODE_CURVING:
+ cp = &ts->noodle_curving; break;
+
+ case TH_SEQ_MOVIE:
+ cp = ts->movie; break;
+ case TH_SEQ_MOVIECLIP:
+ cp = ts->movieclip; break;
+ case TH_SEQ_IMAGE:
+ cp = ts->image; break;
+ case TH_SEQ_SCENE:
+ cp = ts->scene; break;
+ case TH_SEQ_AUDIO:
+ cp = ts->audio; break;
+ case TH_SEQ_EFFECT:
+ cp = ts->effect; break;
+ case TH_SEQ_PLUGIN:
+ cp = ts->plugin; break;
+ case TH_SEQ_TRANSITION:
+ cp = ts->transition; break;
+ case TH_SEQ_META:
+ cp = ts->meta; break;
+ case TH_SEQ_PREVIEW:
+ cp = ts->preview_back; break;
+
+ case TH_CONSOLE_OUTPUT:
+ cp = ts->console_output; break;
+ case TH_CONSOLE_INPUT:
+ cp = ts->console_input; break;
+ case TH_CONSOLE_INFO:
+ cp = ts->console_info; break;
+ case TH_CONSOLE_ERROR:
+ cp = ts->console_error; break;
+ case TH_CONSOLE_CURSOR:
+ cp = ts->console_cursor; break;
+
+ case TH_HANDLE_VERTEX:
+ cp = ts->handle_vertex;
+ break;
+ case TH_HANDLE_VERTEX_SELECT:
+ cp = ts->handle_vertex_select;
+ break;
+ case TH_HANDLE_VERTEX_SIZE:
+ cp = &ts->handle_vertex_size;
+ break;
+
+ case TH_DOPESHEET_CHANNELOB:
+ cp = ts->ds_channel;
+ break;
+ case TH_DOPESHEET_CHANNELSUBOB:
+ cp = ts->ds_subchannel;
+ break;
+
+ case TH_PREVIEW_BACK:
+ cp = ts->preview_back;
+ break;
+
+ case TH_STITCH_PREVIEW_FACE:
+ cp = ts->preview_stitch_face;
+ break;
+
+ case TH_STITCH_PREVIEW_EDGE:
+ cp = ts->preview_stitch_edge;
+ break;
+
+ case TH_STITCH_PREVIEW_VERT:
+ cp = ts->preview_stitch_vert;
+ break;
+
+ case TH_STITCH_PREVIEW_STITCHABLE:
+ cp = ts->preview_stitch_stitchable;
+ break;
+
+ case TH_STITCH_PREVIEW_UNSTITCHABLE:
+ cp = ts->preview_stitch_unstitchable;
+ break;
+ case TH_STITCH_PREVIEW_ACTIVE:
+ cp = ts->preview_stitch_active;
+ break;
+ case TH_MARKER_OUTLINE:
+ cp = ts->marker_outline; break;
+ case TH_MARKER:
+ cp = ts->marker; break;
+ case TH_ACT_MARKER:
+ cp = ts->act_marker; break;
+ case TH_SEL_MARKER:
+ cp = ts->sel_marker; break;
+ case TH_BUNDLE_SOLID:
+ cp = ts->bundle_solid; break;
+ case TH_DIS_MARKER:
+ cp = ts->dis_marker; break;
+ case TH_PATH_BEFORE:
+ cp = ts->path_before; break;
+ case TH_PATH_AFTER:
+ cp = ts->path_after; break;
+ case TH_CAMERA_PATH:
+ cp = ts->camera_path; break;
+ case TH_LOCK_MARKER:
+ cp = ts->lock_marker; break;
+
+ case TH_MATCH:
+ cp = ts->match;
+ break;
+
+ case TH_SELECT_HIGHLIGHT:
+ cp = ts->selected_highlight;
+ break;
}
}
}
@@ -482,63 +482,63 @@ static void ui_theme_init_boneColorSets(bTheme *btheme)
int i;
/* define default color sets - currently we only define 15 of these, though that should be ample */
- /* set 1 */
+ /* set 1 */
rgba_char_args_set(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255);
rgba_char_args_set(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255);
rgba_char_args_set(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255);
- /* set 2 */
+ /* set 2 */
rgba_char_args_set(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255);
rgba_char_args_set(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255);
rgba_char_args_set(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255);
- /* set 3 */
+ /* set 3 */
rgba_char_args_set(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255);
rgba_char_args_set(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255);
rgba_char_args_set(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255);
- /* set 4 */
+ /* set 4 */
rgba_char_args_set(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255);
rgba_char_args_set(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255);
rgba_char_args_set(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255);
- /* set 5 */
+ /* set 5 */
rgba_char_args_set(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255);
rgba_char_args_set(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255);
rgba_char_args_set(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255);
- /* set 6 */
+ /* set 6 */
rgba_char_args_set(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255);
rgba_char_args_set(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255);
rgba_char_args_set(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255);
- /* set 7 */
+ /* set 7 */
rgba_char_args_set(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255);
rgba_char_args_set(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255);
rgba_char_args_set(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255);
- /* set 8 */
+ /* set 8 */
rgba_char_args_set(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255);
rgba_char_args_set(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255);
rgba_char_args_set(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255);
- /* set 9 */
+ /* set 9 */
rgba_char_args_set(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255);
rgba_char_args_set(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255);
rgba_char_args_set(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255);
- /* set 10 */
+ /* set 10 */
rgba_char_args_set(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255);
rgba_char_args_set(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255);
rgba_char_args_set(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255);
- /* set 11 */
+ /* set 11 */
rgba_char_args_set(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255);
rgba_char_args_set(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255);
rgba_char_args_set(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255);
- /* set 12 */
+ /* set 12 */
rgba_char_args_set(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255);
rgba_char_args_set(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255);
rgba_char_args_set(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255);
- /* set 13 */
+ /* set 13 */
rgba_char_args_set(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255);
rgba_char_args_set(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255);
rgba_char_args_set(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255);
- /* set 14 */
+ /* set 14 */
rgba_char_args_set(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255);
rgba_char_args_set(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255);
rgba_char_args_set(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255);
- /* set 15 */
+ /* set 15 */
rgba_char_args_set(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255);
rgba_char_args_set(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255);
rgba_char_args_set(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255);
@@ -551,23 +551,23 @@ static void ui_theme_init_boneColorSets(bTheme *btheme)
/* use this call to init new variables in themespace, if they're same for all */
static void ui_theme_init_new_do(ThemeSpace *ts)
{
- rgba_char_args_test_set(ts->header_text, 0, 0, 0, 255);
- rgba_char_args_test_set(ts->header_title, 0, 0, 0, 255);
- rgba_char_args_test_set(ts->header_text_hi, 255, 255, 255, 255);
-
- rgba_char_args_test_set(ts->panel_text, 0, 0, 0, 255);
- rgba_char_args_test_set(ts->panel_title, 0, 0, 0, 255);
- rgba_char_args_test_set(ts->panel_text_hi, 255, 255, 255, 255);
-
- rgba_char_args_test_set(ts->button, 145, 145, 145, 245);
- rgba_char_args_test_set(ts->button_title, 0, 0, 0, 255);
- rgba_char_args_test_set(ts->button_text, 0, 0, 0, 255);
- rgba_char_args_test_set(ts->button_text_hi, 255, 255, 255, 255);
-
- rgba_char_args_test_set(ts->list, 165, 165, 165, 255);
- rgba_char_args_test_set(ts->list_title, 0, 0, 0, 255);
- rgba_char_args_test_set(ts->list_text, 0, 0, 0, 255);
- rgba_char_args_test_set(ts->list_text_hi, 255, 255, 255, 255);
+ rgba_char_args_test_set(ts->header_text, 0, 0, 0, 255);
+ rgba_char_args_test_set(ts->header_title, 0, 0, 0, 255);
+ rgba_char_args_test_set(ts->header_text_hi, 255, 255, 255, 255);
+
+ rgba_char_args_test_set(ts->panel_text, 0, 0, 0, 255);
+ rgba_char_args_test_set(ts->panel_title, 0, 0, 0, 255);
+ rgba_char_args_test_set(ts->panel_text_hi, 255, 255, 255, 255);
+
+ rgba_char_args_test_set(ts->button, 145, 145, 145, 245);
+ rgba_char_args_test_set(ts->button_title, 0, 0, 0, 255);
+ rgba_char_args_test_set(ts->button_text, 0, 0, 0, 255);
+ rgba_char_args_test_set(ts->button_text_hi, 255, 255, 255, 255);
+
+ rgba_char_args_test_set(ts->list, 165, 165, 165, 255);
+ rgba_char_args_test_set(ts->list_title, 0, 0, 0, 255);
+ rgba_char_args_test_set(ts->list_text, 0, 0, 0, 255);
+ rgba_char_args_test_set(ts->list_text_hi, 255, 255, 255, 255);
}
static void ui_theme_init_new(bTheme *btheme)
@@ -602,21 +602,21 @@ void ui_theme_init_default(void)
bTheme *btheme;
/* we search for the theme with name Default */
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
- if (strcmp("Default", btheme->name)==0) break;
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
+ if (strcmp("Default", btheme->name) == 0) break;
}
- if (btheme==NULL) {
- btheme= MEM_callocN(sizeof(bTheme), "theme");
+ if (btheme == NULL) {
+ btheme = MEM_callocN(sizeof(bTheme), "theme");
BLI_addtail(&U.themes, btheme);
strcpy(btheme->name, "Default");
}
- UI_SetTheme(0, 0); // make sure the global used in this file is set
+ UI_SetTheme(0, 0); // make sure the global used in this file is set
/* UI buttons */
ui_widget_color_init(&btheme->tui);
- btheme->tui.iconfile[0]= 0;
+ btheme->tui.iconfile[0] = 0;
btheme->tui.panel.show_header = FALSE;
rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25);
@@ -631,8 +631,8 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tv3d.text, 0, 0, 0, 255);
rgba_char_args_set(btheme->tv3d.text_hi, 255, 255, 255, 255);
- rgba_char_args_set_fl(btheme->tv3d.header, 0.45, 0.45, 0.45, 1.0);
- rgba_char_args_set_fl(btheme->tv3d.button, 0.45, 0.45, 0.45, 1.0);
+ rgba_char_args_set_fl(btheme->tv3d.header, 0.45, 0.45, 0.45, 1.0);
+ rgba_char_args_set_fl(btheme->tv3d.button, 0.45, 0.45, 0.45, 1.0);
rgba_char_args_set(btheme->tv3d.panel, 165, 165, 165, 127);
rgba_char_args_set(btheme->tv3d.shade1, 160, 160, 160, 100);
@@ -651,8 +651,8 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tv3d.transform, 0xff, 0xff, 0xff, 255);
rgba_char_args_set(btheme->tv3d.vertex, 0, 0, 0, 255);
rgba_char_args_set(btheme->tv3d.vertex_select, 255, 133, 0, 255);
- btheme->tv3d.vertex_size= 3;
- btheme->tv3d.outline_width= 1;
+ btheme->tv3d.vertex_size = 3;
+ btheme->tv3d.outline_width = 1;
rgba_char_args_set(btheme->tv3d.edge, 0x0, 0x0, 0x0, 255);
rgba_char_args_set(btheme->tv3d.edge_select, 255, 160, 0, 255);
rgba_char_args_set(btheme->tv3d.edge_seam, 219, 37, 18, 255);
@@ -672,13 +672,13 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tv3d.button_title, 0, 0, 0, 255);
rgba_char_args_set(btheme->tv3d.title, 0, 0, 0, 255);
- btheme->tv3d.facedot_size= 4;
+ btheme->tv3d.facedot_size = 4;
rgba_char_args_set(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
rgba_char_args_set(btheme->tv3d.extra_face_area, 0, 32, 0, 255);
rgba_char_args_set(btheme->tv3d.extra_face_angle, 0, 0, 128, 255);
- rgba_char_args_set(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
+ rgba_char_args_set(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
rgba_char_args_set(btheme->tv3d.nurb_uline, 0x90, 0x90, 0x00, 255);
rgba_char_args_set(btheme->tv3d.nurb_vline, 0x80, 0x30, 0x60, 255);
@@ -705,86 +705,86 @@ void ui_theme_init_default(void)
/* space buttons */
/* to have something initialized */
- btheme->tbuts= btheme->tv3d;
+ btheme->tbuts = btheme->tv3d;
- rgba_char_args_set_fl(btheme->tbuts.back, 0.45, 0.45, 0.45, 1.0);
+ rgba_char_args_set_fl(btheme->tbuts.back, 0.45, 0.45, 0.45, 1.0);
rgba_char_args_set(btheme->tbuts.panel, 0x82, 0x82, 0x82, 255);
/* graph editor */
- btheme->tipo= btheme->tv3d;
- rgba_char_args_set_fl(btheme->tipo.back, 0.42, 0.42, 0.42, 1.0);
- rgba_char_args_set_fl(btheme->tipo.list, 0.4, 0.4, 0.4, 1.0);
- rgba_char_args_set(btheme->tipo.grid, 94, 94, 94, 255);
+ btheme->tipo = btheme->tv3d;
+ rgba_char_args_set_fl(btheme->tipo.back, 0.42, 0.42, 0.42, 1.0);
+ rgba_char_args_set_fl(btheme->tipo.list, 0.4, 0.4, 0.4, 1.0);
+ rgba_char_args_set(btheme->tipo.grid, 94, 94, 94, 255);
rgba_char_args_set(btheme->tipo.panel, 255, 255, 255, 150);
- rgba_char_args_set(btheme->tipo.shade1, 150, 150, 150, 100); /* scrollbars */
- rgba_char_args_set(btheme->tipo.shade2, 0x70, 0x70, 0x70, 100);
- rgba_char_args_set(btheme->tipo.vertex, 0, 0, 0, 255);
+ rgba_char_args_set(btheme->tipo.shade1, 150, 150, 150, 100); /* scrollbars */
+ rgba_char_args_set(btheme->tipo.shade2, 0x70, 0x70, 0x70, 100);
+ rgba_char_args_set(btheme->tipo.vertex, 0, 0, 0, 255);
rgba_char_args_set(btheme->tipo.vertex_select, 255, 133, 0, 255);
rgba_char_args_set(btheme->tipo.hilite, 0x60, 0xc0, 0x40, 255);
- btheme->tipo.vertex_size= 3;
+ btheme->tipo.vertex_size = 3;
- rgba_char_args_set(btheme->tipo.handle_vertex, 0, 0, 0, 255);
+ rgba_char_args_set(btheme->tipo.handle_vertex, 0, 0, 0, 255);
rgba_char_args_set(btheme->tipo.handle_vertex_select, 255, 133, 0, 255);
rgba_char_args_set(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255);
rgba_char_args_set(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255);
- btheme->tipo.handle_vertex_size= 4;
+ btheme->tipo.handle_vertex_size = 4;
- rgba_char_args_set(btheme->tipo.ds_channel, 82, 96, 110, 255);
- rgba_char_args_set(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
+ rgba_char_args_set(btheme->tipo.ds_channel, 82, 96, 110, 255);
+ rgba_char_args_set(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
rgba_char_args_set(btheme->tipo.group, 79, 101, 73, 255);
rgba_char_args_set(btheme->tipo.group_active, 135, 177, 125, 255);
/* dopesheet */
- btheme->tact= btheme->tipo;
- rgba_char_args_set(btheme->tact.strip, 12, 10, 10, 128);
- rgba_char_args_set(btheme->tact.strip_select, 255, 140, 0, 255);
+ btheme->tact = btheme->tipo;
+ rgba_char_args_set(btheme->tact.strip, 12, 10, 10, 128);
+ rgba_char_args_set(btheme->tact.strip_select, 255, 140, 0, 255);
/* space nla */
- btheme->tnla= btheme->tact;
+ btheme->tnla = btheme->tact;
/* space file */
/* to have something initialized */
- btheme->tfile= btheme->tv3d;
+ btheme->tfile = btheme->tv3d;
rgba_char_args_set_fl(btheme->tfile.back, 0.3, 0.3, 0.3, 1);
rgba_char_args_set_fl(btheme->tfile.panel, 0.3, 0.3, 0.3, 1);
rgba_char_args_set_fl(btheme->tfile.list, 0.4, 0.4, 0.4, 1);
- rgba_char_args_set(btheme->tfile.text, 250, 250, 250, 255);
+ rgba_char_args_set(btheme->tfile.text, 250, 250, 250, 255);
rgba_char_args_set(btheme->tfile.text_hi, 15, 15, 15, 255);
- rgba_char_args_set(btheme->tfile.panel, 145, 145, 145, 255); // bookmark/ui regions
+ rgba_char_args_set(btheme->tfile.panel, 145, 145, 145, 255); // bookmark/ui regions
rgba_char_args_set(btheme->tfile.active, 130, 130, 130, 255); // selected files
rgba_char_args_set(btheme->tfile.hilite, 255, 140, 25, 255); // selected files
- rgba_char_args_set(btheme->tfile.grid, 250, 250, 250, 255);
- rgba_char_args_set(btheme->tfile.image, 250, 250, 250, 255);
- rgba_char_args_set(btheme->tfile.movie, 250, 250, 250, 255);
- rgba_char_args_set(btheme->tfile.scene, 250, 250, 250, 255);
+ rgba_char_args_set(btheme->tfile.grid, 250, 250, 250, 255);
+ rgba_char_args_set(btheme->tfile.image, 250, 250, 250, 255);
+ rgba_char_args_set(btheme->tfile.movie, 250, 250, 250, 255);
+ rgba_char_args_set(btheme->tfile.scene, 250, 250, 250, 255);
/* space seq */
- btheme->tseq= btheme->tv3d;
- rgba_char_args_set(btheme->tseq.back, 116, 116, 116, 255);
- rgba_char_args_set(btheme->tseq.movie, 81, 105, 135, 255);
+ btheme->tseq = btheme->tv3d;
+ rgba_char_args_set(btheme->tseq.back, 116, 116, 116, 255);
+ rgba_char_args_set(btheme->tseq.movie, 81, 105, 135, 255);
rgba_char_args_set(btheme->tseq.movieclip, 32, 32, 143, 255);
- rgba_char_args_set(btheme->tseq.image, 109, 88, 129, 255);
- rgba_char_args_set(btheme->tseq.scene, 78, 152, 62, 255);
- rgba_char_args_set(btheme->tseq.audio, 46, 143, 143, 255);
- rgba_char_args_set(btheme->tseq.effect, 169, 84, 124, 255);
- rgba_char_args_set(btheme->tseq.plugin, 126, 126, 80, 255);
+ rgba_char_args_set(btheme->tseq.image, 109, 88, 129, 255);
+ rgba_char_args_set(btheme->tseq.scene, 78, 152, 62, 255);
+ rgba_char_args_set(btheme->tseq.audio, 46, 143, 143, 255);
+ rgba_char_args_set(btheme->tseq.effect, 169, 84, 124, 255);
+ rgba_char_args_set(btheme->tseq.plugin, 126, 126, 80, 255);
rgba_char_args_set(btheme->tseq.transition, 162, 95, 111, 255);
- rgba_char_args_set(btheme->tseq.meta, 109, 145, 131, 255);
- rgba_char_args_set(btheme->tseq.preview_back, 0, 0, 0, 255);
+ rgba_char_args_set(btheme->tseq.meta, 109, 145, 131, 255);
+ rgba_char_args_set(btheme->tseq.preview_back, 0, 0, 0, 255);
/* space image */
- btheme->tima= btheme->tv3d;
- rgba_char_args_set(btheme->tima.back, 53, 53, 53, 255);
+ btheme->tima = btheme->tv3d;
+ rgba_char_args_set(btheme->tima.back, 53, 53, 53, 255);
rgba_char_args_set(btheme->tima.vertex, 0, 0, 0, 255);
rgba_char_args_set(btheme->tima.vertex_select, 255, 133, 0, 255);
- btheme->tima.vertex_size= 3;
- btheme->tima.facedot_size= 3;
+ btheme->tima.vertex_size = 3;
+ btheme->tima.facedot_size = 3;
rgba_char_args_set(btheme->tima.face, 255, 255, 255, 10);
rgba_char_args_set(btheme->tima.face_select, 255, 133, 0, 60);
rgba_char_args_set(btheme->tima.editmesh_active, 255, 255, 255, 128);
- rgba_char_args_set_fl(btheme->tima.preview_back, 0.45, 0.45, 0.45, 1.0);
+ rgba_char_args_set_fl(btheme->tima.preview_back, 0.45, 0.45, 0.45, 1.0);
rgba_char_args_set_fl(btheme->tima.preview_stitch_face, 0.5, 0.5, 0.0, 0.2);
rgba_char_args_set_fl(btheme->tima.preview_stitch_edge, 1.0, 0.0, 1.0, 0.2);
rgba_char_args_set_fl(btheme->tima.preview_stitch_vert, 0.0, 0.0, 1.0, 0.2);
@@ -792,36 +792,36 @@ void ui_theme_init_default(void)
rgba_char_args_set_fl(btheme->tima.preview_stitch_unstitchable, 1.0, 0.0, 0.0, 1.0);
/* space text */
- btheme->text= btheme->tv3d;
- rgba_char_args_set(btheme->text.back, 153, 153, 153, 255);
- rgba_char_args_set(btheme->text.shade1, 143, 143, 143, 255);
- rgba_char_args_set(btheme->text.shade2, 0xc6, 0x77, 0x77, 255);
- rgba_char_args_set(btheme->text.hilite, 255, 0, 0, 255);
+ btheme->text = btheme->tv3d;
+ rgba_char_args_set(btheme->text.back, 153, 153, 153, 255);
+ rgba_char_args_set(btheme->text.shade1, 143, 143, 143, 255);
+ rgba_char_args_set(btheme->text.shade2, 0xc6, 0x77, 0x77, 255);
+ rgba_char_args_set(btheme->text.hilite, 255, 0, 0, 255);
/* syntax highlighting */
- rgba_char_args_set(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/
- rgba_char_args_set(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */
- rgba_char_args_set(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */
- rgba_char_args_set(btheme->text.syntaxv, 95, 95, 0, 255); /* Special */
- rgba_char_args_set(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin, red-purple */
+ rgba_char_args_set(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/
+ rgba_char_args_set(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */
+ rgba_char_args_set(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */
+ rgba_char_args_set(btheme->text.syntaxv, 95, 95, 0, 255); /* Special */
+ rgba_char_args_set(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin, red-purple */
/* space oops */
- btheme->toops= btheme->tv3d;
- rgba_char_args_set_fl(btheme->toops.back, 0.45, 0.45, 0.45, 1.0);
+ btheme->toops = btheme->tv3d;
+ rgba_char_args_set_fl(btheme->toops.back, 0.45, 0.45, 0.45, 1.0);
- rgba_char_args_set_fl(btheme->toops.match, 0.2, 0.5, 0.2, 0.3); /* highlighting search match - soft green*/
+ rgba_char_args_set_fl(btheme->toops.match, 0.2, 0.5, 0.2, 0.3); /* highlighting search match - soft green*/
rgba_char_args_set_fl(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3);
/* space info */
- btheme->tinfo= btheme->tv3d;
- rgba_char_args_set_fl(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
+ btheme->tinfo = btheme->tv3d;
+ rgba_char_args_set_fl(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
/* space user preferences */
- btheme->tuserpref= btheme->tv3d;
+ btheme->tuserpref = btheme->tv3d;
rgba_char_args_set_fl(btheme->tuserpref.back, 0.45, 0.45, 0.45, 1.0);
/* space console */
- btheme->tconsole= btheme->tv3d;
+ btheme->tconsole = btheme->tv3d;
rgba_char_args_set(btheme->tconsole.back, 0, 0, 0, 255);
rgba_char_args_set(btheme->tconsole.console_output, 96, 128, 255, 255);
rgba_char_args_set(btheme->tconsole.console_input, 255, 255, 255, 255);
@@ -830,27 +830,27 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tconsole.console_cursor, 220, 96, 96, 255);
/* space time */
- btheme->ttime= btheme->tv3d;
- rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0);
- rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0);
- rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); // sliders
+ btheme->ttime = btheme->tv3d;
+ rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0);
+ rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0);
+ rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); // sliders
/* space node, re-uses syntax color storage */
- btheme->tnode= btheme->tv3d;
+ btheme->tnode = btheme->tv3d;
rgba_char_args_set(btheme->tnode.edge_select, 255, 255, 255, 255);
- rgba_char_args_set(btheme->tnode.syntaxl, 155, 155, 155, 160); /* TH_NODE, backdrop */
- rgba_char_args_set(btheme->tnode.syntaxn, 100, 100, 100, 255); /* in/output */
- rgba_char_args_set(btheme->tnode.syntaxb, 108, 105, 111, 255); /* operator */
- rgba_char_args_set(btheme->tnode.syntaxv, 104, 106, 117, 255); /* generator */
- rgba_char_args_set(btheme->tnode.syntaxc, 105, 117, 110, 255); /* group */
+ rgba_char_args_set(btheme->tnode.syntaxl, 155, 155, 155, 160); /* TH_NODE, backdrop */
+ rgba_char_args_set(btheme->tnode.syntaxn, 100, 100, 100, 255); /* in/output */
+ rgba_char_args_set(btheme->tnode.syntaxb, 108, 105, 111, 255); /* operator */
+ rgba_char_args_set(btheme->tnode.syntaxv, 104, 106, 117, 255); /* generator */
+ rgba_char_args_set(btheme->tnode.syntaxc, 105, 117, 110, 255); /* group */
btheme->tnode.noodle_curving = 5;
/* space logic */
- btheme->tlogic= btheme->tv3d;
+ btheme->tlogic = btheme->tv3d;
rgba_char_args_set(btheme->tlogic.back, 100, 100, 100, 255);
/* space clip */
- btheme->tclip= btheme->tv3d;
+ btheme->tclip = btheme->tv3d;
rgba_char_args_set(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
rgba_char_args_set(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
@@ -864,22 +864,22 @@ void ui_theme_init_default(void)
rgba_char_args_set(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
rgba_char_args_set(btheme->tclip.handle_vertex, 0x00, 0x00, 0x00, 0xff);
rgba_char_args_set(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
- btheme->tclip.handle_vertex_size= 4;
+ btheme->tclip.handle_vertex_size = 4;
}
void UI_SetTheme(int spacetype, int regionid)
{
- if (spacetype==0) { // called for safety, when delete themes
- theme_active= U.themes.first;
- theme_spacetype= SPACE_VIEW3D;
- theme_regionid= RGN_TYPE_WINDOW;
+ if (spacetype == 0) { // called for safety, when delete themes
+ theme_active = U.themes.first;
+ theme_spacetype = SPACE_VIEW3D;
+ theme_regionid = RGN_TYPE_WINDOW;
}
else {
// later on, a local theme can be found too
- theme_active= U.themes.first;
- theme_spacetype= spacetype;
- theme_regionid= regionid;
+ theme_active = U.themes.first;
+ theme_spacetype = spacetype;
+ theme_regionid = regionid;
}
}
@@ -893,7 +893,7 @@ void UI_ThemeColor(int colorid)
{
const unsigned char *cp;
- cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
glColor3ubv(cp);
}
@@ -903,7 +903,7 @@ void UI_ThemeColor4(int colorid)
{
const unsigned char *cp;
- cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
glColor4ubv(cp);
}
@@ -914,12 +914,12 @@ void UI_ThemeColorShade(int colorid, int offset)
int r, g, b;
const unsigned char *cp;
- cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
- r= offset + (int) cp[0];
+ cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ r = offset + (int) cp[0];
CLAMP(r, 0, 255);
- g= offset + (int) cp[1];
+ g = offset + (int) cp[1];
CLAMP(g, 0, 255);
- b= offset + (int) cp[2];
+ b = offset + (int) cp[2];
CLAMP(b, 0, 255);
//glColor3ub(r, g, b);
glColor4ub(r, g, b, cp[3]);
@@ -929,14 +929,14 @@ void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset)
int r, g, b, a;
const unsigned char *cp;
- cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
- r= coloffset + (int) cp[0];
+ cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ r = coloffset + (int) cp[0];
CLAMP(r, 0, 255);
- g= coloffset + (int) cp[1];
+ g = coloffset + (int) cp[1];
CLAMP(g, 0, 255);
- b= coloffset + (int) cp[2];
+ b = coloffset + (int) cp[2];
CLAMP(b, 0, 255);
- a= alphaoffset + (int) cp[3];
+ a = alphaoffset + (int) cp[3];
CLAMP(a, 0, 255);
glColor4ub(r, g, b, a);
}
@@ -947,13 +947,13 @@ void UI_ThemeColorBlend(int colorid1, int colorid2, float fac)
int r, g, b;
const unsigned char *cp1, *cp2;
- cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
- cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
+ cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
+ cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
CLAMP(fac, 0.0f, 1.0f);
- r= floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
- g= floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
- b= floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
+ r = floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
+ g = floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
+ b = floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
glColor3ub(r, g, b);
}
@@ -964,13 +964,13 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset)
int r, g, b;
const unsigned char *cp1, *cp2;
- cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
- cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
+ cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
+ cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
CLAMP(fac, 0.0f, 1.0f);
- r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
- g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
- b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
+ r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
+ g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
+ b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
CLAMP(r, 0, 255);
CLAMP(g, 0, 255);
@@ -985,14 +985,14 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off
int r, g, b, a;
const unsigned char *cp1, *cp2;
- cp1= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
- cp2= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
+ cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1);
+ cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2);
CLAMP(fac, 0.0f, 1.0f);
- r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
- g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
- b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
- a= alphaoffset + floorf((1.0f-fac)*cp1[3] + fac*cp2[3]);
+ r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
+ g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
+ b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
+ a = alphaoffset + floorf((1.0f - fac) * cp1[3] + fac * cp2[3]);
CLAMP(r, 0, 255);
CLAMP(g, 0, 255);
@@ -1008,7 +1008,7 @@ float UI_GetThemeValuef(int colorid)
{
const unsigned char *cp;
- cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
return ((float)cp[0]);
}
@@ -1018,7 +1018,7 @@ int UI_GetThemeValue(int colorid)
{
const unsigned char *cp;
- cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
return ((int) cp[0]);
}
@@ -1029,10 +1029,10 @@ void UI_GetThemeColor3fv(int colorid, float *col)
{
const unsigned char *cp;
- cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
- col[0]= ((float)cp[0])/255.0f;
- col[1]= ((float)cp[1])/255.0f;
- col[2]= ((float)cp[2])/255.0f;
+ cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ col[0] = ((float)cp[0]) / 255.0f;
+ col[1] = ((float)cp[1]) / 255.0f;
+ col[2] = ((float)cp[2]) / 255.0f;
}
// get the color, range 0.0-1.0, complete with shading offset
@@ -1041,18 +1041,18 @@ void UI_GetThemeColorShade3fv(int colorid, int offset, float *col)
int r, g, b;
const unsigned char *cp;
- cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
- r= offset + (int) cp[0];
+ r = offset + (int) cp[0];
CLAMP(r, 0, 255);
- g= offset + (int) cp[1];
+ g = offset + (int) cp[1];
CLAMP(g, 0, 255);
- b= offset + (int) cp[2];
+ b = offset + (int) cp[2];
CLAMP(b, 0, 255);
- col[0]= ((float)r)/255.0f;
- col[1]= ((float)g)/255.0f;
- col[2]= ((float)b)/255.0f;
+ col[0] = ((float)r) / 255.0f;
+ col[1] = ((float)g) / 255.0f;
+ col[2] = ((float)b) / 255.0f;
}
// get the color, in char pointer
@@ -1060,10 +1060,10 @@ void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
{
const unsigned char *cp;
- cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
- col[0]= cp[0];
- col[1]= cp[1];
- col[2]= cp[2];
+ cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ col[0] = cp[0];
+ col[1] = cp[1];
+ col[2] = cp[2];
}
// get the color, in char pointer
@@ -1071,22 +1071,22 @@ void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
{
const unsigned char *cp;
- cp= UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
- col[0]= cp[0];
- col[1]= cp[1];
- col[2]= cp[2];
- col[3]= cp[3];
+ cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid);
+ col[0] = cp[0];
+ col[1] = cp[1];
+ col[2] = cp[2];
+ col[3] = cp[3];
}
void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4])
{
const unsigned char *cp;
- cp= UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
- col[0]= cp[0];
- col[1]= cp[1];
- col[2]= cp[2];
- col[3]= cp[3];
+ cp = UI_ThemeGetColorPtr(theme_active, spacetype, colorid);
+ col[0] = cp[0];
+ col[1] = cp[1];
+ col[2] = cp[2];
+ col[3] = cp[3];
}
// blends and shades between two char color pointers
@@ -1094,13 +1094,13 @@ void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char c
{
int r, g, b;
CLAMP(fac, 0.0f, 1.0f);
- r= offset+floorf((1.0f-fac)*cp1[0] + fac*cp2[0]);
- g= offset+floorf((1.0f-fac)*cp1[1] + fac*cp2[1]);
- b= offset+floorf((1.0f-fac)*cp1[2] + fac*cp2[2]);
-
- r= r<0?0:(r>255?255:r);
- g= g<0?0:(g>255?255:g);
- b= b<0?0:(b>255?255:b);
+ r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]);
+ g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]);
+ b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]);
+
+ r = r < 0 ? 0 : (r > 255 ? 255 : r);
+ g = g < 0 ? 0 : (g > 255 ? 255 : g);
+ b = b < 0 ? 0 : (b > 255 ? 255 : b);
glColor3ub(r, g, b);
}
@@ -1109,9 +1109,9 @@ void UI_GetColorPtrShade3ubv(const unsigned char cp[3], unsigned char col[3], in
{
int r, g, b;
- r= offset+(int)cp[0];
- g= offset+(int)cp[1];
- b= offset+(int)cp[2];
+ r = offset + (int)cp[0];
+ g = offset + (int)cp[1];
+ b = offset + (int)cp[2];
CLAMP(r, 0, 255);
CLAMP(g, 0, 255);
@@ -1128,9 +1128,9 @@ void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned cha
int r, g, b;
CLAMP(fac, 0.0f, 1.0f);
- r= offset+floor((1.0f-fac)*cp1[0] + fac*cp2[0]);
- g= offset+floor((1.0f-fac)*cp1[1] + fac*cp2[1]);
- b= offset+floor((1.0f-fac)*cp1[2] + fac*cp2[2]);
+ r = offset + floor((1.0f - fac) * cp1[0] + fac * cp2[0]);
+ g = offset + floor((1.0f - fac) * cp1[1] + fac * cp2[1]);
+ b = offset + floor((1.0f - fac) * cp1[2] + fac * cp2[2]);
CLAMP(r, 0, 255);
CLAMP(g, 0, 255);
@@ -1151,22 +1151,22 @@ void UI_ThemeClearColor(int colorid)
void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
{
- switch(axis)
+ switch (axis)
{
case 'X':
- dst_col[0]= src_col[0]>219?255:src_col[0]+36;
- dst_col[1]= src_col[1]<26?0:src_col[1]-26;
- dst_col[2]= src_col[2]<26?0:src_col[2]-26;
+ dst_col[0] = src_col[0] > 219 ? 255 : src_col[0] + 36;
+ dst_col[1] = src_col[1] < 26 ? 0 : src_col[1] - 26;
+ dst_col[2] = src_col[2] < 26 ? 0 : src_col[2] - 26;
break;
case 'Y':
- dst_col[0]= src_col[0]<46?0:src_col[0]-36;
- dst_col[1]= src_col[1]>189?255:src_col[1]+66;
- dst_col[2]= src_col[2]<46?0:src_col[2]-36;
+ dst_col[0] = src_col[0] < 46 ? 0 : src_col[0] - 36;
+ dst_col[1] = src_col[1] > 189 ? 255 : src_col[1] + 66;
+ dst_col[2] = src_col[2] < 46 ? 0 : src_col[2] - 36;
break;
case 'Z':
- dst_col[0]= src_col[0]<26?0:src_col[0]-26;
- dst_col[1]= src_col[1]<26?0:src_col[1]-26;
- dst_col[2]= src_col[2]>209?255:src_col[2]+46;
+ dst_col[0] = src_col[0] < 26 ? 0 : src_col[0] - 26;
+ dst_col[1] = src_col[1] < 26 ? 0 : src_col[1] - 26;
+ dst_col[2] = src_col[2] > 209 ? 255 : src_col[2] + 46;
break;
default:
BLI_assert(!"invalid axis arg");
@@ -1178,20 +1178,20 @@ void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3]
/* patching UserDef struct and Themes */
void init_userdef_do_versions(void)
{
- Main *bmain= G.main;
+ Main *bmain = G.main;
// countall();
/* the UserDef struct is not corrected with do_versions() .... ugh! */
if (U.wheellinescroll == 0) U.wheellinescroll = 3;
- if (U.menuthreshold1==0) {
- U.menuthreshold1= 5;
- U.menuthreshold2= 2;
+ if (U.menuthreshold1 == 0) {
+ U.menuthreshold1 = 5;
+ U.menuthreshold2 = 2;
}
- if (U.tb_leftmouse==0) {
- U.tb_leftmouse= 5;
- U.tb_rightmouse= 5;
+ if (U.tb_leftmouse == 0) {
+ U.tb_leftmouse = 5;
+ U.tb_rightmouse = 5;
}
- if (U.mixbufsize==0) U.mixbufsize= 2048;
+ if (U.mixbufsize == 0) U.mixbufsize = 2048;
if (strcmp(U.tempdir, "/") == 0) {
BLI_system_temporary_dir(U.tempdir);
}
@@ -1204,13 +1204,13 @@ void init_userdef_do_versions(void)
// XXX error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n");
}
/* transform widget settings */
- if (U.tw_hotspot==0) {
- U.tw_hotspot= 14;
- U.tw_size= 20; // percentage of window size
- U.tw_handlesize= 16; // percentage of widget radius
+ if (U.tw_hotspot == 0) {
+ U.tw_hotspot = 14;
+ U.tw_size = 20; // percentage of window size
+ U.tw_handlesize = 16; // percentage of widget radius
}
- if (U.pad_rot_angle==0)
- U.pad_rot_angle= 15;
+ if (U.pad_rot_angle == 0)
+ U.pad_rot_angle = 15;
/* graph editor - unselected F-Curve visibility */
if (U.fcu_inactive_alpha == 0) {
U.fcu_inactive_alpha = 0.25f;
@@ -1218,7 +1218,7 @@ void init_userdef_do_versions(void)
/* signal for derivedmesh to use colorband */
/* run in case this was on and is now off in the user prefs [#28096] */
- vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight):NULL);
+ vDM_ColorBand_store((U.flag & USER_CUSTOM_RANGE) ? (&U.coba_weight) : NULL);
if (bmain->versionfile <= 191) {
BLI_strncpy(U.plugtexdir, U.textudir, sizeof(U.plugtexdir));
@@ -1235,22 +1235,22 @@ void init_userdef_do_versions(void)
bTheme *btheme;
U.uiflag |= USER_GLOBALUNDO;
- if (U.undosteps==0) U.undosteps=32;
+ if (U.undosteps == 0) U.undosteps = 32;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* check for alpha==0 is safe, then color was never set */
- if (btheme->tv3d.edge_seam[3]==0) {
+ if (btheme->tv3d.edge_seam[3] == 0) {
rgba_char_args_set(btheme->tv3d.edge_seam, 230, 150, 50, 255);
}
- if (btheme->tv3d.normal[3]==0) {
+ if (btheme->tv3d.normal[3] == 0) {
rgba_char_args_set(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255);
}
- if (btheme->tv3d.vertex_normal[3]==0) {
+ if (btheme->tv3d.vertex_normal[3] == 0) {
rgba_char_args_set(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255);
}
- if (btheme->tv3d.face_dot[3]==0) {
+ if (btheme->tv3d.face_dot[3] == 0) {
rgba_char_args_set(btheme->tv3d.face_dot, 255, 138, 48, 255);
- btheme->tv3d.facedot_size= 4;
+ btheme->tv3d.facedot_size = 4;
}
}
}
@@ -1262,30 +1262,30 @@ void init_userdef_do_versions(void)
if (bmain->versionfile <= 236) {
bTheme *btheme;
/* new space type */
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* check for alpha==0 is safe, then color was never set */
- if (btheme->ttime.back[3]==0) {
+ if (btheme->ttime.back[3] == 0) {
// copied from ui_theme_init_default
- btheme->ttime= btheme->tv3d;
- rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0);
- rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0);
- rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); // sliders
+ btheme->ttime = btheme->tv3d;
+ rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0);
+ rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0);
+ rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); // sliders
}
- if (btheme->text.syntaxn[3]==0) {
- rgba_char_args_set(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/
- rgba_char_args_set(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */
- rgba_char_args_set(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */
- rgba_char_args_set(btheme->text.syntaxv, 95, 95, 0, 255); /* Special */
- rgba_char_args_set(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin, red-purple */
+ if (btheme->text.syntaxn[3] == 0) {
+ rgba_char_args_set(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/
+ rgba_char_args_set(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */
+ rgba_char_args_set(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */
+ rgba_char_args_set(btheme->text.syntaxv, 95, 95, 0, 255); /* Special */
+ rgba_char_args_set(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin, red-purple */
}
}
}
if (bmain->versionfile <= 237) {
bTheme *btheme;
/* bone colors */
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* check for alpha==0 is safe, then color was never set */
- if (btheme->tv3d.bone_solid[3]==0) {
+ if (btheme->tv3d.bone_solid[3] == 0) {
rgba_char_args_set(btheme->tv3d.bone_solid, 200, 200, 200, 255);
rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80);
}
@@ -1294,10 +1294,10 @@ void init_userdef_do_versions(void)
if (bmain->versionfile <= 238) {
bTheme *btheme;
/* bone colors */
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* check for alpha==0 is safe, then color was never set */
- if (btheme->tnla.strip[3]==0) {
- rgba_char_args_set(btheme->tnla.strip_select, 0xff, 0xff, 0xaa, 255);
+ if (btheme->tnla.strip[3] == 0) {
+ rgba_char_args_set(btheme->tnla.strip_select, 0xff, 0xff, 0xaa, 255);
rgba_char_args_set(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255);
}
}
@@ -1305,46 +1305,46 @@ void init_userdef_do_versions(void)
if (bmain->versionfile <= 239) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* Lamp theme, check for alpha==0 is safe, then color was never set */
- if (btheme->tv3d.lamp[3]==0) {
- rgba_char_args_set(btheme->tv3d.lamp, 0, 0, 0, 40);
+ if (btheme->tv3d.lamp[3] == 0) {
+ rgba_char_args_set(btheme->tv3d.lamp, 0, 0, 0, 40);
/* TEMPORAL, remove me! (ton) */
U.uiflag |= USER_PLAINMENUS;
}
}
- if (U.obcenter_dia==0) U.obcenter_dia= 6;
+ if (U.obcenter_dia == 0) U.obcenter_dia = 6;
}
if (bmain->versionfile <= 241) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* Node editor theme, check for alpha==0 is safe, then color was never set */
- if (btheme->tnode.syntaxn[3]==0) {
+ if (btheme->tnode.syntaxn[3] == 0) {
/* re-uses syntax color storage */
- btheme->tnode= btheme->tv3d;
+ btheme->tnode = btheme->tv3d;
rgba_char_args_set(btheme->tnode.edge_select, 255, 255, 255, 255);
- rgba_char_args_set(btheme->tnode.syntaxl, 150, 150, 150, 255); /* TH_NODE, backdrop */
- rgba_char_args_set(btheme->tnode.syntaxn, 129, 131, 144, 255); /* in/output */
- rgba_char_args_set(btheme->tnode.syntaxb, 127,127,127, 255); /* operator */
- rgba_char_args_set(btheme->tnode.syntaxv, 142, 138, 145, 255); /* generator */
- rgba_char_args_set(btheme->tnode.syntaxc, 120, 145, 120, 255); /* group */
+ rgba_char_args_set(btheme->tnode.syntaxl, 150, 150, 150, 255); /* TH_NODE, backdrop */
+ rgba_char_args_set(btheme->tnode.syntaxn, 129, 131, 144, 255); /* in/output */
+ rgba_char_args_set(btheme->tnode.syntaxb, 127, 127, 127, 255); /* operator */
+ rgba_char_args_set(btheme->tnode.syntaxv, 142, 138, 145, 255); /* generator */
+ rgba_char_args_set(btheme->tnode.syntaxc, 120, 145, 120, 255); /* group */
}
/* Group theme colors */
- if (btheme->tv3d.group[3]==0) {
+ if (btheme->tv3d.group[3] == 0) {
rgba_char_args_set(btheme->tv3d.group, 0x0C, 0x30, 0x0C, 255);
rgba_char_args_set(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255);
}
/* Sequence editor theme*/
- if (btheme->tseq.movie[3]==0) {
- rgba_char_args_set(btheme->tseq.movie, 81, 105, 135, 255);
- rgba_char_args_set(btheme->tseq.image, 109, 88, 129, 255);
- rgba_char_args_set(btheme->tseq.scene, 78, 152, 62, 255);
- rgba_char_args_set(btheme->tseq.audio, 46, 143, 143, 255);
- rgba_char_args_set(btheme->tseq.effect, 169, 84, 124, 255);
- rgba_char_args_set(btheme->tseq.plugin, 126, 126, 80, 255);
+ if (btheme->tseq.movie[3] == 0) {
+ rgba_char_args_set(btheme->tseq.movie, 81, 105, 135, 255);
+ rgba_char_args_set(btheme->tseq.image, 109, 88, 129, 255);
+ rgba_char_args_set(btheme->tseq.scene, 78, 152, 62, 255);
+ rgba_char_args_set(btheme->tseq.audio, 46, 143, 143, 255);
+ rgba_char_args_set(btheme->tseq.effect, 169, 84, 124, 255);
+ rgba_char_args_set(btheme->tseq.plugin, 126, 126, 80, 255);
rgba_char_args_set(btheme->tseq.transition, 162, 95, 111, 255);
- rgba_char_args_set(btheme->tseq.meta, 109, 145, 131, 255);
+ rgba_char_args_set(btheme->tseq.meta, 109, 145, 131, 255);
}
}
@@ -1360,18 +1360,18 @@ void init_userdef_do_versions(void)
if (bmain->versionfile <= 242) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* long keyframe color */
/* check for alpha==0 is safe, then color was never set */
- if (btheme->tact.strip[3]==0) {
+ if (btheme->tact.strip[3] == 0) {
rgba_char_args_set(btheme->tv3d.edge_sharp, 255, 32, 32, 255);
- rgba_char_args_set(btheme->tact.strip_select, 0xff, 0xff, 0xaa, 204);
+ rgba_char_args_set(btheme->tact.strip_select, 0xff, 0xff, 0xaa, 204);
rgba_char_args_set(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204);
}
/* IPO-Editor - Vertex Size*/
if (btheme->tipo.vertex_size == 0) {
- btheme->tipo.vertex_size= 3;
+ btheme->tipo.vertex_size = 3;
}
}
}
@@ -1381,15 +1381,15 @@ void init_userdef_do_versions(void)
}
if (bmain->versionfile < 245 || (bmain->versionfile == 245 && bmain->subversionfile < 3)) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
rgba_char_args_set(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
}
- if (U.coba_weight.tot==0)
+ if (U.coba_weight.tot == 0)
init_colorband(&U.coba_weight, 1);
}
if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* these should all use the same color */
rgba_char_args_set(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
rgba_char_args_set(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255);
@@ -1402,7 +1402,7 @@ void init_userdef_do_versions(void)
}
if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 13)) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* action channel groups (recolor anyway) */
rgba_char_args_set(btheme->tact.group, 0x39, 0x7d, 0x1b, 255);
rgba_char_args_set(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255);
@@ -1413,13 +1413,13 @@ void init_userdef_do_versions(void)
}
}
if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 16)) {
- U.flag |= USER_ADD_VIEWALIGNED|USER_ADD_EDITMODE;
+ U.flag |= USER_ADD_VIEWALIGNED | USER_ADD_EDITMODE;
}
if ((bmain->versionfile < 247) || (bmain->versionfile == 247 && bmain->subversionfile <= 2)) {
bTheme *btheme;
/* adjust themes */
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
char *col;
/* IPO Editor: Handles/Vertices */
@@ -1427,7 +1427,7 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tipo.handle_vertex, col[0], col[1], col[2], 255);
col = btheme->tipo.vertex_select;
rgba_char_args_set(btheme->tipo.handle_vertex_select, col[0], col[1], col[2], 255);
- btheme->tipo.handle_vertex_size= btheme->tipo.vertex_size;
+ btheme->tipo.handle_vertex_size = btheme->tipo.vertex_size;
/* Sequence/Image Editor: colors for GPencil text */
col = btheme->tv3d.bone_pose;
@@ -1440,59 +1440,59 @@ void init_userdef_do_versions(void)
if (bmain->versionfile < 250) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* this was not properly initialized in 2.45 */
- if (btheme->tima.face_dot[3]==0) {
+ if (btheme->tima.face_dot[3] == 0) {
rgba_char_args_set(btheme->tima.editmesh_active, 255, 255, 255, 128);
rgba_char_args_set(btheme->tima.face_dot, 255, 133, 0, 255);
- btheme->tima.facedot_size= 2;
+ btheme->tima.facedot_size = 2;
}
/* DopeSheet - (Object) Channel color */
- rgba_char_args_set(btheme->tact.ds_channel, 82, 96, 110, 255);
- rgba_char_args_set(btheme->tact.ds_subchannel, 124, 137, 150, 255);
+ rgba_char_args_set(btheme->tact.ds_channel, 82, 96, 110, 255);
+ rgba_char_args_set(btheme->tact.ds_subchannel, 124, 137, 150, 255);
/* DopeSheet - Group Channel color (saner version) */
rgba_char_args_set(btheme->tact.group, 79, 101, 73, 255);
rgba_char_args_set(btheme->tact.group_active, 135, 177, 125, 255);
/* Graph Editor - (Object) Channel color */
- rgba_char_args_set(btheme->tipo.ds_channel, 82, 96, 110, 255);
- rgba_char_args_set(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
+ rgba_char_args_set(btheme->tipo.ds_channel, 82, 96, 110, 255);
+ rgba_char_args_set(btheme->tipo.ds_subchannel, 124, 137, 150, 255);
/* Graph Editor - Group Channel color */
rgba_char_args_set(btheme->tipo.group, 79, 101, 73, 255);
rgba_char_args_set(btheme->tipo.group_active, 135, 177, 125, 255);
/* Nla Editor - (Object) Channel color */
- rgba_char_args_set(btheme->tnla.ds_channel, 82, 96, 110, 255);
- rgba_char_args_set(btheme->tnla.ds_subchannel, 124, 137, 150, 255);
+ rgba_char_args_set(btheme->tnla.ds_channel, 82, 96, 110, 255);
+ rgba_char_args_set(btheme->tnla.ds_subchannel, 124, 137, 150, 255);
/* NLA Editor - New Strip colors */
- rgba_char_args_set(btheme->tnla.strip, 12, 10, 10, 128);
- rgba_char_args_set(btheme->tnla.strip_select, 255, 140, 0, 255);
+ rgba_char_args_set(btheme->tnla.strip, 12, 10, 10, 128);
+ rgba_char_args_set(btheme->tnla.strip_select, 255, 140, 0, 255);
}
/* adjust grease-pencil distances */
- U.gp_manhattendist= 1;
- U.gp_euclideandist= 2;
+ U.gp_manhattendist = 1;
+ U.gp_euclideandist = 2;
/* adjust default interpolation for new IPO-curves */
- U.ipo_new= BEZT_IPO_BEZ;
+ U.ipo_new = BEZT_IPO_BEZ;
}
if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* common (new) variables, it checks for alpha==0 */
ui_theme_init_new(btheme);
- if (btheme->tui.wcol_num.outline[3]==0)
+ if (btheme->tui.wcol_num.outline[3] == 0)
ui_widget_color_init(&btheme->tui);
/* Logic editor theme, check for alpha==0 is safe, then color was never set */
- if (btheme->tlogic.syntaxn[3]==0) {
+ if (btheme->tlogic.syntaxn[3] == 0) {
/* re-uses syntax color storage */
- btheme->tlogic= btheme->tv3d;
+ btheme->tlogic = btheme->tv3d;
rgba_char_args_set(btheme->tlogic.back, 100, 100, 100, 255);
}
@@ -1525,40 +1525,40 @@ void init_userdef_do_versions(void)
if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) {
wmKeyMap *km;
- for (km=U.user_keymaps.first; km; km=km->next) {
- if (strcmp(km->idname, "Armature_Sketch")==0)
+ for (km = U.user_keymaps.first; km; km = km->next) {
+ if (strcmp(km->idname, "Armature_Sketch") == 0)
strcpy(km->idname, "Armature Sketch");
- else if (strcmp(km->idname, "View3D")==0)
+ else if (strcmp(km->idname, "View3D") == 0)
strcpy(km->idname, "3D View");
- else if (strcmp(km->idname, "View3D Generic")==0)
+ else if (strcmp(km->idname, "View3D Generic") == 0)
strcpy(km->idname, "3D View Generic");
- else if (strcmp(km->idname, "EditMesh")==0)
+ else if (strcmp(km->idname, "EditMesh") == 0)
strcpy(km->idname, "Mesh");
- else if (strcmp(km->idname, "TimeLine")==0)
+ else if (strcmp(km->idname, "TimeLine") == 0)
strcpy(km->idname, "Timeline");
- else if (strcmp(km->idname, "UVEdit")==0)
+ else if (strcmp(km->idname, "UVEdit") == 0)
strcpy(km->idname, "UV Editor");
- else if (strcmp(km->idname, "Animation_Channels")==0)
+ else if (strcmp(km->idname, "Animation_Channels") == 0)
strcpy(km->idname, "Animation Channels");
- else if (strcmp(km->idname, "GraphEdit Keys")==0)
+ else if (strcmp(km->idname, "GraphEdit Keys") == 0)
strcpy(km->idname, "Graph Editor");
- else if (strcmp(km->idname, "GraphEdit Generic")==0)
+ else if (strcmp(km->idname, "GraphEdit Generic") == 0)
strcpy(km->idname, "Graph Editor Generic");
- else if (strcmp(km->idname, "Action_Keys")==0)
+ else if (strcmp(km->idname, "Action_Keys") == 0)
strcpy(km->idname, "Dopesheet");
- else if (strcmp(km->idname, "NLA Data")==0)
+ else if (strcmp(km->idname, "NLA Data") == 0)
strcpy(km->idname, "NLA Editor");
- else if (strcmp(km->idname, "Node Generic")==0)
+ else if (strcmp(km->idname, "Node Generic") == 0)
strcpy(km->idname, "Node Editor");
- else if (strcmp(km->idname, "Logic Generic")==0)
+ else if (strcmp(km->idname, "Logic Generic") == 0)
strcpy(km->idname, "Logic Editor");
- else if (strcmp(km->idname, "File")==0)
+ else if (strcmp(km->idname, "File") == 0)
strcpy(km->idname, "File Browser");
- else if (strcmp(km->idname, "FileMain")==0)
+ else if (strcmp(km->idname, "FileMain") == 0)
strcpy(km->idname, "File Browser Main");
- else if (strcmp(km->idname, "FileButtons")==0)
+ else if (strcmp(km->idname, "FileButtons") == 0)
strcpy(km->idname, "File Browser Buttons");
- else if (strcmp(km->idname, "Buttons Generic")==0)
+ else if (strcmp(km->idname, "Buttons Generic") == 0)
strcpy(km->idname, "Property Editor");
}
}
@@ -1578,7 +1578,7 @@ void init_userdef_do_versions(void)
U.keyhandles_new = HD_AUTO;
/* init new curve colors */
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* init colors used for handles in 3D-View */
rgba_char_args_set(btheme->tv3d.handle_free, 0, 0, 0, 255);
rgba_char_args_set(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
@@ -1608,7 +1608,7 @@ void init_userdef_do_versions(void)
bTheme *btheme;
/* init new curve colors */
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
if (btheme->tv3d.lastsel_point[3] == 0)
rgba_char_args_set(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
}
@@ -1617,7 +1617,7 @@ void init_userdef_do_versions(void)
bTheme *btheme;
/* interface_widgets.c */
- struct uiWidgetColors wcol_progress= {
+ struct uiWidgetColors wcol_progress = {
{0, 0, 0, 255},
{190, 190, 190, 255},
{100, 100, 100, 180},
@@ -1630,15 +1630,15 @@ void init_userdef_do_versions(void)
5, -5
};
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
/* init progress bar theme */
- btheme->tui.wcol_progress= wcol_progress;
+ btheme->tui.wcol_progress = wcol_progress;
}
}
if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 2)) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
rgba_char_args_set(btheme->tv3d.extra_edge_len, 32, 0, 0, 255);
rgba_char_args_set(btheme->tv3d.extra_face_angle, 0, 32, 0, 255);
rgba_char_args_set(btheme->tv3d.extra_face_area, 0, 0, 128, 255);
@@ -1647,8 +1647,8 @@ void init_userdef_do_versions(void)
if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 4)) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
- if ((btheme->tv3d.outline_width) == 0) btheme->tv3d.outline_width= 1;
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
+ if ((btheme->tv3d.outline_width) == 0) btheme->tv3d.outline_width = 1;
}
}
@@ -1659,7 +1659,7 @@ void init_userdef_do_versions(void)
if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 2)) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
btheme->tnode.noodle_curving = 5;
}
}
@@ -1667,7 +1667,7 @@ void init_userdef_do_versions(void)
if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
btheme->tv3d.speaker[3] = 255;
}
}
@@ -1681,7 +1681,7 @@ void init_userdef_do_versions(void)
if (U.keyhandles_new == HD_AUTO)
U.keyhandles_new = HD_AUTO_ANIM;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
if (btheme->tv3d.bundle_solid[3] == 0)
rgba_char_args_set(btheme->tv3d.bundle_solid, 200, 200, 200, 255);
@@ -1689,7 +1689,7 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255);
if ((btheme->tclip.back[3]) == 0) {
- btheme->tclip= btheme->tv3d;
+ btheme->tclip = btheme->tv3d;
rgba_char_args_set(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255);
rgba_char_args_set(btheme->tclip.marker, 0x7f, 0x7f, 0x00, 255);
@@ -1703,7 +1703,7 @@ void init_userdef_do_versions(void)
rgba_char_args_set(btheme->tclip.cframe, 0x60, 0xc0, 0x40, 255);
rgba_char_args_set(btheme->tclip.handle_vertex, 0x00, 0x00, 0x00, 0xff);
rgba_char_args_set(btheme->tclip.handle_vertex_select, 0xff, 0xff, 0, 0xff);
- btheme->tclip.handle_vertex_size= 4;
+ btheme->tclip.handle_vertex_size = 4;
}
/* auto-clamped handles -> based on auto */
@@ -1715,7 +1715,7 @@ void init_userdef_do_versions(void)
/* enable (Cycles) addon by default */
if (!BLI_findstring(&U.addons, "cycles", offsetof(bAddon, module))) {
- bAddon *baddon= MEM_callocN(sizeof(bAddon), "bAddon");
+ bAddon *baddon = MEM_callocN(sizeof(bAddon), "bAddon");
BLI_strncpy(baddon->module, "cycles", sizeof(baddon->module));
BLI_addtail(&U.addons, baddon);
}
@@ -1724,15 +1724,15 @@ void init_userdef_do_versions(void)
if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 5)) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25);
- btheme->tui.icon_alpha= 1.0;
+ btheme->tui.icon_alpha = 1.0;
}
}
if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 4)) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
rgba_char_args_set_fl(btheme->tima.preview_stitch_face, 0.071, 0.259, 0.694, 0.150);
rgba_char_args_set_fl(btheme->tima.preview_stitch_edge, 1.0, 0.522, 0.0, 0.7);
rgba_char_args_set_fl(btheme->tima.preview_stitch_vert, 1.0, 0.522, 0.0, 0.5);
@@ -1749,7 +1749,7 @@ void init_userdef_do_versions(void)
if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 2)) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
if (btheme->tui.wcol_menu_item.item[3] == 255)
rgba_char_args_set(btheme->tui.wcol_menu_item.item, 172, 172, 172, 128);
}
@@ -1757,7 +1757,7 @@ void init_userdef_do_versions(void)
if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 3)) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
if (btheme->tui.wcol_tooltip.inner[3] == 0) {
btheme->tui.wcol_tooltip = btheme->tui.wcol_menu_back;
}
@@ -1769,7 +1769,7 @@ void init_userdef_do_versions(void)
if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 4)) {
bTheme *btheme;
- for (btheme= U.themes.first; btheme; btheme= btheme->next) {
+ for (btheme = U.themes.first; btheme; btheme = btheme->next) {
if (btheme->tseq.movieclip[0] == 0) {
rgba_char_args_set(btheme->tseq.movieclip, 32, 32, 143, 255);
}
@@ -1798,22 +1798,22 @@ void init_userdef_do_versions(void)
U.scrcastwait = 50;
}
if (U.v2d_min_gridsize == 0) {
- U.v2d_min_gridsize= 35;
+ U.v2d_min_gridsize = 35;
}
- if (U.dragthreshold == 0 )
- U.dragthreshold= 5;
- if (U.widget_unit==0)
- U.widget_unit= (U.dpi * 20 + 36)/72;
+ if (U.dragthreshold == 0)
+ U.dragthreshold = 5;
+ if (U.widget_unit == 0)
+ U.widget_unit = (U.dpi * 20 + 36) / 72;
if (U.anisotropic_filter <= 0)
U.anisotropic_filter = 1;
if (U.ndof_sensitivity == 0.0f) {
U.ndof_sensitivity = 1.0f;
U.ndof_flag = NDOF_LOCK_HORIZON |
- NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE;
+ NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE;
}
- if (U.tweak_threshold == 0 )
- U.tweak_threshold= 10;
+ if (U.tweak_threshold == 0)
+ U.tweak_threshold = 10;
/* funny name, but it is GE stuff, moves userdef stuff to engine */
// XXX space_set_commmandline_options();
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 792ea88baa7..5c05e9d2ba1 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -66,7 +66,7 @@
/* XXX there's V2D_SCROLL_HORIZONTAL_HIDE and V2D_SCROLL_HORIZONTAL_FULLR ... */
/* helper to allow scrollbars to dynamically hide
- * - returns a copy of the scrollbar settings with the flags to display
+ * - returns a copy of the scrollbar settings with the flags to display
* horizontal/vertical scrollbars removed
* - input scroll value is the v2d->scroll var
* - hide flags are set per region at drawtime
@@ -87,23 +87,23 @@ static void view2d_masks(View2D *v2d)
/* mask - view frame */
v2d->mask.xmin = v2d->mask.ymin = 0;
- v2d->mask.xmax = v2d->winx - 1; /* -1 yes! masks are pixels */
+ v2d->mask.xmax = v2d->winx - 1; /* -1 yes! masks are pixels */
v2d->mask.ymax = v2d->winy - 1;
#if 0
// XXX see above
- v2d->scroll &= ~(V2D_SCROLL_HORIZONTAL_HIDE|V2D_SCROLL_VERTICAL_HIDE);
+ v2d->scroll &= ~(V2D_SCROLL_HORIZONTAL_HIDE | V2D_SCROLL_VERTICAL_HIDE);
/* check size if: */
if (v2d->scroll & V2D_SCROLL_HORIZONTAL)
if (!(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL))
- if (v2d->tot.xmax-v2d->tot.xmin <= v2d->cur.xmax-v2d->cur.xmin)
+ if (v2d->tot.xmax - v2d->tot.xmin <= v2d->cur.xmax - v2d->cur.xmin)
v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE;
if (v2d->scroll & V2D_SCROLL_VERTICAL)
if (!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL))
- if (v2d->tot.ymax-v2d->tot.ymin <= v2d->cur.ymax-v2d->cur.ymin)
+ if (v2d->tot.ymax - v2d->tot.ymin <= v2d->cur.ymax - v2d->cur.ymin)
v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE;
#endif
- scroll= view2d_scroll_mapped(v2d->scroll);
+ scroll = view2d_scroll_mapped(v2d->scroll);
/* scrollers shrink mask area, but should be based off regionsize
* - they can only be on one to two edges of the region they define
@@ -113,28 +113,28 @@ static void view2d_masks(View2D *v2d)
/* vertical scroller */
if (scroll & V2D_SCROLL_LEFT) {
/* on left-hand edge of region */
- v2d->vert= v2d->mask;
+ v2d->vert = v2d->mask;
v2d->vert.xmax = V2D_SCROLL_WIDTH;
v2d->mask.xmin = v2d->vert.xmax + 1;
}
else if (scroll & V2D_SCROLL_RIGHT) {
/* on right-hand edge of region */
- v2d->vert= v2d->mask;
+ v2d->vert = v2d->mask;
v2d->vert.xmax++; /* one pixel extra... was leaving a minor gap... */
v2d->vert.xmin = v2d->vert.xmax - V2D_SCROLL_WIDTH;
v2d->mask.xmax = v2d->vert.xmin - 1;
}
/* horizontal scroller */
- if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
+ if (scroll & (V2D_SCROLL_BOTTOM | V2D_SCROLL_BOTTOM_O)) {
/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
- v2d->hor= v2d->mask;
+ v2d->hor = v2d->mask;
v2d->hor.ymax = V2D_SCROLL_HEIGHT;
v2d->mask.ymin = v2d->hor.ymax + 1;
}
else if (scroll & V2D_SCROLL_TOP) {
/* on upper edge of region */
- v2d->hor= v2d->mask;
+ v2d->hor = v2d->mask;
v2d->hor.ymin = v2d->hor.ymax - V2D_SCROLL_HEIGHT;
v2d->mask.ymax = v2d->hor.ymin - 1;
}
@@ -142,7 +142,7 @@ static void view2d_masks(View2D *v2d)
/* adjust vertical scroller if there's a horizontal scroller, to leave corner free */
if (scroll & V2D_SCROLL_VERTICAL) {
/* just set y min/max for vertical scroller to y min/max of mask as appropriate */
- if (scroll & (V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O)) {
+ if (scroll & (V2D_SCROLL_BOTTOM | V2D_SCROLL_BOTTOM_O)) {
/* on bottom edge of region (V2D_SCROLL_BOTTOM_O is outliner, the other is for standard) */
v2d->vert.ymin = v2d->mask.ymin;
}
@@ -159,125 +159,125 @@ static void view2d_masks(View2D *v2d)
/* Initialize all relevant View2D data (including view rects if first time) and/or refresh mask sizes after view resize
* - for some of these presets, it is expected that the region will have defined some
- * additional settings necessary for the customisation of the 2D viewport to its requirements
+ * additional settings necessary for the customisation of the 2D viewport to its requirements
* - this function should only be called from region init() callbacks, where it is expected that
* this is called before UI_view2d_size_update(), as this one checks that the rects are properly initialized.
*/
void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
{
- short tot_changed= 0, init= 0;
- uiStyle *style= UI_GetStyle();
+ short tot_changed = 0, init = 0;
+ uiStyle *style = UI_GetStyle();
/* initialize data if there is a need for such */
if ((v2d->flag & V2D_IS_INITIALISED) == 0) {
/* set initialized flag so that View2D doesn't get reinitialised next time again */
v2d->flag |= V2D_IS_INITIALISED;
- init= 1;
+ init = 1;
/* see eView2D_CommonViewTypes in UI_view2d.h for available view presets */
switch (type) {
/* 'standard view' - optimum setup for 'standard' view behavior,
* that should be used new views as basis for their
- * own unique View2D settings, which should be used instead of this in most cases...
+ * own unique View2D settings, which should be used instead of this in most cases...
*/
case V2D_COMMONVIEW_STANDARD:
{
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
- v2d->keepzoom= (V2D_KEEPASPECT|V2D_LIMITZOOM);
- v2d->minzoom= 0.01f;
- v2d->maxzoom= 1000.0f;
+ v2d->keepzoom = (V2D_KEEPASPECT | V2D_LIMITZOOM);
+ v2d->minzoom = 0.01f;
+ v2d->maxzoom = 1000.0f;
/* tot rect and cur should be same size, and aligned using 'standard' OpenGL coordinates for now
* - region can resize 'tot' later to fit other data
* - keeptot is only within bounds, as strict locking is not that critical
* - view is aligned for (0,0) -> (winx-1, winy-1) setup
*/
- v2d->align= (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y);
- v2d->keeptot= V2D_KEEPTOT_BOUNDS;
+ v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y);
+ v2d->keeptot = V2D_KEEPTOT_BOUNDS;
v2d->tot.xmin = v2d->tot.ymin = 0.0f;
v2d->tot.xmax = (float)(winx - 1);
v2d->tot.ymax = (float)(winy - 1);
- v2d->cur= v2d->tot;
+ v2d->cur = v2d->tot;
/* scrollers - should we have these by default? */
// XXX for now, we don't override this, or set it either!
}
- break;
+ break;
/* 'list/channel view' - zoom, aspect ratio, and alignment restrictions are set here */
case V2D_COMMONVIEW_LIST:
{
/* zoom + aspect ratio are locked */
- v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
- v2d->minzoom= v2d->maxzoom= 1.0f;
+ v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
+ v2d->minzoom = v2d->maxzoom = 1.0f;
/* tot rect has strictly regulated placement, and must only occur in +/- quadrant */
- v2d->align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
+ v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
v2d->keeptot = V2D_KEEPTOT_STRICT;
- tot_changed= 1;
+ tot_changed = 1;
/* scroller settings are currently not set here... that is left for regions... */
}
- break;
+ break;
/* 'stack view' - practically the same as list/channel view, except is located in the pos y half instead.
- * zoom, aspect ratio, and alignment restrictions are set here */
+ * zoom, aspect ratio, and alignment restrictions are set here */
case V2D_COMMONVIEW_STACK:
{
/* zoom + aspect ratio are locked */
- v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
- v2d->minzoom= v2d->maxzoom= 1.0f;
+ v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
+ v2d->minzoom = v2d->maxzoom = 1.0f;
/* tot rect has strictly regulated placement, and must only occur in +/+ quadrant */
- v2d->align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y);
+ v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y);
v2d->keeptot = V2D_KEEPTOT_STRICT;
- tot_changed= 1;
+ tot_changed = 1;
/* scroller settings are currently not set here... that is left for regions... */
}
- break;
+ break;
/* 'header' regions - zoom, aspect ratio, alignment, and panning restrictions are set here */
case V2D_COMMONVIEW_HEADER:
{
/* zoom + aspect ratio are locked */
- v2d->keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
- v2d->minzoom= v2d->maxzoom= 1.0f;
- v2d->min[0]= v2d->max[0]= (float)(winx-1);
- v2d->min[1]= v2d->max[1]= (float)(winy-1);
+ v2d->keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
+ v2d->minzoom = v2d->maxzoom = 1.0f;
+ v2d->min[0] = v2d->max[0] = (float)(winx - 1);
+ v2d->min[1] = v2d->max[1] = (float)(winy - 1);
/* tot rect has strictly regulated placement, and must only occur in +/+ quadrant */
- v2d->align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y);
+ v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y);
v2d->keeptot = V2D_KEEPTOT_STRICT;
- tot_changed= 1;
+ tot_changed = 1;
/* panning in y-axis is prohibited */
- v2d->keepofs= V2D_LOCKOFS_Y;
+ v2d->keepofs = V2D_LOCKOFS_Y;
/* absolutely no scrollers allowed */
- v2d->scroll= 0;
+ v2d->scroll = 0;
}
- break;
+ break;
/* panels view, with horizontal/vertical align */
case V2D_COMMONVIEW_PANELS_UI:
{
- float panelzoom= (style) ? style->panelzoom : 1.0f;
+ float panelzoom = (style) ? style->panelzoom : 1.0f;
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
- v2d->keepzoom= (V2D_KEEPASPECT|V2D_LIMITZOOM|V2D_KEEPZOOM);
- v2d->minzoom= 0.5f;
- v2d->maxzoom= 2.0f;
+ v2d->keepzoom = (V2D_KEEPASPECT | V2D_LIMITZOOM | V2D_KEEPZOOM);
+ v2d->minzoom = 0.5f;
+ v2d->maxzoom = 2.0f;
//tot_changed= 1;
- v2d->align= (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
- v2d->keeptot= V2D_KEEPTOT_BOUNDS;
+ v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y);
+ v2d->keeptot = V2D_KEEPTOT_BOUNDS;
- v2d->scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
+ v2d->scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE;
v2d->scroll &= ~V2D_SCROLL_VERTICAL_HIDE;
@@ -289,14 +289,14 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
v2d->cur.xmin = 0.0f;
/* bad workaround for keeping zoom level with scrollers */
- v2d->cur.xmax = (winx - V2D_SCROLL_WIDTH)*panelzoom;
+ v2d->cur.xmax = (winx - V2D_SCROLL_WIDTH) * panelzoom;
v2d->cur.ymax = 0.0f;
- v2d->cur.ymin = (-winy)*panelzoom;
+ v2d->cur.ymin = (-winy) * panelzoom;
}
- break;
+ break;
- /* other view types are completely defined using their own settings already */
+ /* other view types are completely defined using their own settings already */
default:
/* we don't do anything here, as settings should be fine, but just make sure that rect */
break;
@@ -304,8 +304,8 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
}
/* store view size */
- v2d->winx= winx;
- v2d->winy= winy;
+ v2d->winx = winx;
+ v2d->winy = winy;
/* set masks */
view2d_masks(v2d);
@@ -328,12 +328,12 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
rctf *cur, *tot;
/* use mask as size of region that View2D resides in, as it takes into account scrollbars already */
- winx= (float)(v2d->mask.xmax - v2d->mask.xmin + 1);
- winy= (float)(v2d->mask.ymax - v2d->mask.ymin + 1);
+ winx = (float)(v2d->mask.xmax - v2d->mask.xmin + 1);
+ winy = (float)(v2d->mask.ymax - v2d->mask.ymin + 1);
/* get pointers to rcts for less typing */
- cur= &v2d->cur;
- tot= &v2d->tot;
+ cur = &v2d->cur;
+ tot = &v2d->tot;
/* we must satisfy the following constraints (in decreasing order of importance):
* - alignment restrictions are respected
@@ -347,44 +347,44 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
* - firstly, we calculate the sizes of the rects
* - curwidth and curheight are saved as reference... modify width and height values here
*/
- totwidth= tot->xmax - tot->xmin;
- totheight= tot->ymax - tot->ymin;
- curwidth= width= cur->xmax - cur->xmin;
- curheight= height= cur->ymax - cur->ymin;
+ totwidth = tot->xmax - tot->xmin;
+ totheight = tot->ymax - tot->ymin;
+ curwidth = width = cur->xmax - cur->xmin;
+ curheight = height = cur->ymax - cur->ymin;
/* if zoom is locked, size on the appropriate axis is reset to mask size */
if (v2d->keepzoom & V2D_LOCKZOOM_X)
- width= winx;
+ width = winx;
if (v2d->keepzoom & V2D_LOCKZOOM_Y)
- height= winy;
+ height = winy;
/* values used to divide, so make it safe
* NOTE: width and height must use FLT_MIN instead of 1, otherwise it is impossible to
- * get enough resolution in Graph Editor for editing some curves
+ * get enough resolution in Graph Editor for editing some curves
*/
- if (width < FLT_MIN) width= 1;
- if (height < FLT_MIN) height= 1;
- if (winx < 1) winx= 1;
- if (winy < 1) winy= 1;
+ if (width < FLT_MIN) width = 1;
+ if (height < FLT_MIN) height = 1;
+ if (winx < 1) winx = 1;
+ if (winy < 1) winy = 1;
/* V2D_LIMITZOOM indicates that zoom level should be preserved when the window size changes */
if (resize && (v2d->keepzoom & V2D_KEEPZOOM)) {
float zoom, oldzoom;
- if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0) {
- zoom= winx / width;
- oldzoom= v2d->oldwinx / curwidth;
+ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
+ zoom = winx / width;
+ oldzoom = v2d->oldwinx / curwidth;
if (oldzoom != zoom)
- width *= zoom/oldzoom;
+ width *= zoom / oldzoom;
}
- if ((v2d->keepzoom & V2D_LOCKZOOM_Y)==0) {
- zoom= winy / height;
- oldzoom= v2d->oldwiny / curheight;
+ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
+ zoom = winy / height;
+ oldzoom = v2d->oldwiny / curheight;
if (oldzoom != zoom)
- height *= zoom/oldzoom;
+ height *= zoom / oldzoom;
}
}
/* keepzoom (V2D_LIMITZOOM set), indicates that zoom level on each axis must not exceed limits
@@ -394,19 +394,19 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
float zoom, fac;
/* check if excessive zoom on x-axis */
- if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0) {
- zoom= winx / width;
+ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
+ zoom = winx / width;
if ((zoom < v2d->minzoom) || (zoom > v2d->maxzoom)) {
- fac= (zoom < v2d->minzoom) ? (zoom / v2d->minzoom) : (zoom / v2d->maxzoom);
+ fac = (zoom < v2d->minzoom) ? (zoom / v2d->minzoom) : (zoom / v2d->maxzoom);
width *= fac;
}
}
/* check if excessive zoom on y-axis */
- if ((v2d->keepzoom & V2D_LOCKZOOM_Y)==0) {
- zoom= winy / height;
+ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
+ zoom = winy / height;
if ((zoom < v2d->minzoom) || (zoom > v2d->maxzoom)) {
- fac= (zoom < v2d->minzoom) ? (zoom / v2d->minzoom) : (zoom / v2d->maxzoom);
+ fac = (zoom < v2d->minzoom) ? (zoom / v2d->minzoom) : (zoom / v2d->maxzoom);
height *= fac;
}
}
@@ -419,35 +419,35 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
/* check if we should restore aspect ratio (if view size changed) */
if (v2d->keepzoom & V2D_KEEPASPECT) {
- short do_x=0, do_y=0, do_cur /* , do_win */ /* UNUSED */;
+ short do_x = 0, do_y = 0, do_cur /* , do_win */ /* UNUSED */;
float /* curRatio, */ /* UNUSED */ winRatio;
/* when a window edge changes, the aspect ratio can't be used to
* find which is the best new 'cur' rect. thats why it stores 'old'
*/
- if (winx != v2d->oldwinx) do_x= 1;
- if (winy != v2d->oldwiny) do_y= 1;
+ if (winx != v2d->oldwinx) do_x = 1;
+ if (winy != v2d->oldwiny) do_y = 1;
/* curRatio= height / width; */ /* UNUSED */
- winRatio= winy / winx;
+ winRatio = winy / winx;
/* both sizes change (area/region maximised) */
if (do_x == do_y) {
if (do_x && do_y) {
/* here is 1,1 case, so all others must be 0,0 */
- if (ABS(winx - v2d->oldwinx) > ABS(winy - v2d->oldwiny)) do_y= 0;
- else do_x= 0;
+ if (ABS(winx - v2d->oldwinx) > ABS(winy - v2d->oldwiny)) do_y = 0;
+ else do_x = 0;
}
- else if (winRatio > 1.0f) do_x= 0;
- else do_x= 1;
+ else if (winRatio > 1.0f) do_x = 0;
+ else do_x = 1;
}
- do_cur= do_x;
+ do_cur = do_x;
/* do_win= do_y; */ /* UNUSED */
if (do_cur) {
if ((v2d->keeptot == V2D_KEEPTOT_STRICT) && (winx != v2d->oldwinx)) {
/* special exception for Outliner (and later channel-lists):
- * - The view may be moved left to avoid contents being pushed out of view when view shrinks.
+ * - The view may be moved left to avoid contents being pushed out of view when view shrinks.
* - The keeptot code will make sure cur->xmin will not be less than tot->xmin (which cannot be allowed)
* - width is not adjusted for changed ratios here...
*/
@@ -464,7 +464,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
}
else {
/* portrait window: correct for x */
- width= height / winRatio;
+ width = height / winRatio;
}
}
else {
@@ -488,8 +488,8 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
}
/* store region size for next time */
- v2d->oldwinx= (short)winx;
- v2d->oldwiny= (short)winy;
+ v2d->oldwinx = (short)winx;
+ v2d->oldwiny = (short)winy;
}
/* Step 2: apply new sizes to cur rect, but need to take into account alignment settings here... */
@@ -508,8 +508,8 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
cur->xmax += width - (cur->xmax - cur->xmin);
}
else {
- temp= (cur->xmax + cur->xmin) * 0.5f;
- dh= width * 0.5f;
+ temp = (cur->xmax + cur->xmin) * 0.5f;
+ dh = width * 0.5f;
cur->xmin = temp - dh;
cur->xmax = temp + dh;
@@ -526,8 +526,8 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
cur->ymax += height - (cur->ymax - cur->ymin);
}
else {
- temp= (cur->ymax + cur->ymin) * 0.5f;
- dh= height * 0.5f;
+ temp = (cur->ymax + cur->ymin) * 0.5f;
+ dh = height * 0.5f;
cur->ymin = temp - dh;
cur->ymax = temp + dh;
@@ -540,11 +540,11 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
float temp, diff;
/* recalculate extents of cur */
- curwidth= cur->xmax - cur->xmin;
- curheight= cur->ymax - cur->ymin;
+ curwidth = cur->xmax - cur->xmin;
+ curheight = cur->ymax - cur->ymin;
/* width */
- if ( (curwidth > totwidth) && !(v2d->keepzoom & (V2D_KEEPZOOM|V2D_LOCKZOOM_X|V2D_LIMITZOOM)) ) {
+ if ( (curwidth > totwidth) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_X | V2D_LIMITZOOM)) ) {
/* if zoom doesn't have to be maintained, just clamp edges */
if (cur->xmin < tot->xmin) cur->xmin = tot->xmin;
if (cur->xmax > tot->xmax) cur->xmax = tot->xmax;
@@ -556,21 +556,21 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
*/
if (cur->xmin < tot->xmin) {
/* move cur across so that it sits at minimum of tot */
- temp= tot->xmin - cur->xmin;
+ temp = tot->xmin - cur->xmin;
cur->xmin += temp;
cur->xmax += temp;
}
else if (cur->xmax > tot->xmax) {
/* - only offset by difference of cur-xmax and tot-xmax if that would not move
- * cur-xmin to lie past tot-xmin
+ * cur-xmin to lie past tot-xmin
* - otherwise, simply shift to tot-xmin???
*/
- temp= cur->xmax - tot->xmax;
+ temp = cur->xmax - tot->xmax;
if ((cur->xmin - temp) < tot->xmin) {
/* only offset by difference from cur-min and tot-min */
- temp= cur->xmin - tot->xmin;
+ temp = cur->xmin - tot->xmin;
cur->xmin -= temp;
cur->xmax -= temp;
@@ -583,7 +583,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
}
else {
/* This here occurs when:
- * - width too big, but maintaining zoom (i.e. widths cannot be changed)
+ * - width too big, but maintaining zoom (i.e. widths cannot be changed)
* - width is OK, but need to check if outside of boundaries
*
* So, resolution is to just shift view by the gap between the extremities.
@@ -592,29 +592,29 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
*/
if ((cur->xmin < tot->xmin) && (cur->xmax > tot->xmax)) {
/* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */
- temp= (tot->xmax + tot->xmin) * 0.5f;
- diff= curheight * 0.5f;
+ temp = (tot->xmax + tot->xmin) * 0.5f;
+ diff = curheight * 0.5f;
cur->xmin = temp - diff;
cur->xmax = temp + diff;
}
else if (cur->xmin < tot->xmin) {
/* move cur across so that it sits at minimum of tot */
- temp= tot->xmin - cur->xmin;
+ temp = tot->xmin - cur->xmin;
cur->xmin += temp;
cur->xmax += temp;
}
else if (cur->xmax > tot->xmax) {
/* - only offset by difference of cur-xmax and tot-xmax if that would not move
- * cur-xmin to lie past tot-xmin
+ * cur-xmin to lie past tot-xmin
* - otherwise, simply shift to tot-xmin???
*/
- temp= cur->xmax - tot->xmax;
+ temp = cur->xmax - tot->xmax;
if ((cur->xmin - temp) < tot->xmin) {
/* only offset by difference from cur-min and tot-min */
- temp= cur->xmin - tot->xmin;
+ temp = cur->xmin - tot->xmin;
cur->xmin -= temp;
cur->xmax -= temp;
@@ -627,14 +627,14 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
}
/* height */
- if ( (curheight > totheight) && !(v2d->keepzoom & (V2D_KEEPZOOM|V2D_LOCKZOOM_Y|V2D_LIMITZOOM)) ) {
+ if ( (curheight > totheight) && !(v2d->keepzoom & (V2D_KEEPZOOM | V2D_LOCKZOOM_Y | V2D_LIMITZOOM)) ) {
/* if zoom doesn't have to be maintained, just clamp edges */
if (cur->ymin < tot->ymin) cur->ymin = tot->ymin;
if (cur->ymax > tot->ymax) cur->ymax = tot->ymax;
}
else {
/* This here occurs when:
- * - height too big, but maintaining zoom (i.e. heights cannot be changed)
+ * - height too big, but maintaining zoom (i.e. heights cannot be changed)
* - height is OK, but need to check if outside of boundaries
*
* So, resolution is to just shift view by the gap between the extremities.
@@ -642,22 +642,22 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize)
*/
if ((cur->ymin < tot->ymin) && (cur->ymax > tot->ymax)) {
/* outside boundaries on both sides, so take middle-point of tot, and place in balanced way */
- temp= (tot->ymax + tot->ymin) * 0.5f;
- diff= curheight * 0.5f;
+ temp = (tot->ymax + tot->ymin) * 0.5f;
+ diff = curheight * 0.5f;
cur->ymin = temp - diff;
cur->ymax = temp + diff;
}
else if (cur->ymin < tot->ymin) {
/* there's still space remaining, so shift up */
- temp= tot->ymin - cur->ymin;
+ temp = tot->ymin - cur->ymin;
cur->ymin += temp;
cur->ymax += temp;
}
else if (cur->ymax > tot->ymax) {
/* there's still space remaining, so shift down */
- temp= cur->ymax - tot->ymax;
+ temp = cur->ymax - tot->ymax;
cur->ymin -= temp;
cur->ymax -= temp;
@@ -726,12 +726,12 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
ARegion *ar;
/* don't continue if no view syncing to be done */
- if ((v2dcur->flag & (V2D_VIEWSYNC_SCREEN_TIME|V2D_VIEWSYNC_AREA_VERTICAL)) == 0)
+ if ((v2dcur->flag & (V2D_VIEWSYNC_SCREEN_TIME | V2D_VIEWSYNC_AREA_VERTICAL)) == 0)
return;
/* check if doing within area syncing (i.e. channels/vertical) */
if ((v2dcur->flag & V2D_VIEWSYNC_AREA_VERTICAL) && (area)) {
- for (ar= area->regionbase.first; ar; ar= ar->next) {
+ for (ar = area->regionbase.first; ar; ar = ar->next) {
/* don't operate on self */
if (v2dcur != &ar->v2d) {
/* only if view has vertical locks enabled */
@@ -742,7 +742,7 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
ar->v2d.cur.ymax = v2dcur->cur.ymax;
}
else { /* V2D_LOCK_SET */
- /* active must copy others */
+ /* active must copy others */
v2dcur->cur.ymin = ar->v2d.cur.ymin;
v2dcur->cur.ymax = ar->v2d.cur.ymax;
}
@@ -756,8 +756,8 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
/* check if doing whole screen syncing (i.e. time/horizontal) */
if ((v2dcur->flag & V2D_VIEWSYNC_SCREEN_TIME) && (screen)) {
- for (sa= screen->areabase.first; sa; sa= sa->next) {
- for (ar= sa->regionbase.first; ar; ar= ar->next) {
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
+ for (ar = sa->regionbase.first; ar; ar = ar->next) {
/* don't operate on self */
if (v2dcur != &ar->v2d) {
/* only if view has horizontal locks enabled */
@@ -768,7 +768,7 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
ar->v2d.cur.xmax = v2dcur->cur.xmax;
}
else { /* V2D_LOCK_SET */
- /* active must copy others */
+ /* active must copy others */
v2dcur->cur.xmin = ar->v2d.cur.xmin;
v2dcur->cur.xmax = ar->v2d.cur.xmax;
}
@@ -786,13 +786,13 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
/* Restore 'cur' rect to standard orientation (i.e. optimal maximum view of tot)
* This does not take into account if zooming the view on an axis will improve the view (if allowed)
*/
-void UI_view2d_curRect_reset (View2D *v2d)
+void UI_view2d_curRect_reset(View2D *v2d)
{
float width, height;
/* assume width and height of 'cur' rect by default, should be same size as mask */
- width= (float)(v2d->mask.xmax - v2d->mask.xmin + 1);
- height= (float)(v2d->mask.ymax - v2d->mask.ymin + 1);
+ width = (float)(v2d->mask.xmax - v2d->mask.xmin + 1);
+ height = (float)(v2d->mask.ymax - v2d->mask.ymin + 1);
/* handle width - posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
@@ -807,7 +807,7 @@ void UI_view2d_curRect_reset (View2D *v2d)
}
else {
/* width is centered around x==0 */
- const float dx= (float)width / 2.0f;
+ const float dx = (float)width / 2.0f;
v2d->cur.xmin = -dx;
v2d->cur.xmax = dx;
@@ -826,7 +826,7 @@ void UI_view2d_curRect_reset (View2D *v2d)
}
else {
/* height is centered around y==0 */
- const float dy= (float)height / 2.0f;
+ const float dy = (float)height / 2.0f;
v2d->cur.ymin = -dy;
v2d->cur.ymax = dy;
@@ -836,13 +836,13 @@ void UI_view2d_curRect_reset (View2D *v2d)
/* ------------------ */
/* Change the size of the maximum viewable area (i.e. 'tot' rect) */
-void UI_view2d_totRect_set_resize (View2D *v2d, int width, int height, int resize)
+void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, int resize)
{
- int scroll= view2d_scroll_mapped(v2d->scroll);
+ int scroll = view2d_scroll_mapped(v2d->scroll);
/* don't do anything if either value is 0 */
- width= abs(width);
- height= abs(height);
+ width = abs(width);
+ height = abs(height);
/* hrumf! */
/* XXX: there are work arounds for this in the panel and file browse code. */
@@ -853,7 +853,7 @@ void UI_view2d_totRect_set_resize (View2D *v2d, int width, int height, int resiz
if (ELEM3(0, v2d, width, height)) {
if (G.f & G_DEBUG)
- printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d \n", (void *)v2d, width, height); // XXX temp debug info
+ printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d \n", (void *)v2d, width, height); // XXX temp debug info
return;
}
@@ -870,7 +870,7 @@ void UI_view2d_totRect_set_resize (View2D *v2d, int width, int height, int resiz
}
else {
/* width is centered around x==0 */
- const float dx= (float)width / 2.0f;
+ const float dx = (float)width / 2.0f;
v2d->tot.xmin = -dx;
v2d->tot.xmax = dx;
@@ -889,7 +889,7 @@ void UI_view2d_totRect_set_resize (View2D *v2d, int width, int height, int resiz
}
else {
/* height is centered around y==0 */
- const float dy= (float)height / 2.0f;
+ const float dy = (float)height / 2.0f;
v2d->tot.ymin = -dy;
v2d->tot.ymax = dy;
@@ -906,16 +906,16 @@ void UI_view2d_totRect_set(View2D *v2d, int width, int height)
int UI_view2d_tab_set(View2D *v2d, int tab)
{
- float default_offset[2]= {0.0f, 0.0f};
+ float default_offset[2] = {0.0f, 0.0f};
float *offset, *new_offset;
- int changed= 0;
+ int changed = 0;
/* if tab changed, change offset */
if (tab != v2d->tab_cur && v2d->tab_offset) {
if (tab < v2d->tab_num)
- offset= &v2d->tab_offset[tab*2];
+ offset = &v2d->tab_offset[tab * 2];
else
- offset= default_offset;
+ offset = default_offset;
v2d->cur.xmax += offset[0] - v2d->cur.xmin;
v2d->cur.xmin = offset[0];
@@ -925,26 +925,26 @@ int UI_view2d_tab_set(View2D *v2d, int tab)
/* validation should happen in subsequent totRect_set */
- changed= 1;
+ changed = 1;
}
/* resize array if needed */
if (tab >= v2d->tab_num) {
- new_offset= MEM_callocN(sizeof(float)*(tab+1)*2, "view2d tab offset");
+ new_offset = MEM_callocN(sizeof(float) * (tab + 1) * 2, "view2d tab offset");
if (v2d->tab_offset) {
- memcpy(new_offset, v2d->tab_offset, sizeof(float)*v2d->tab_num*2);
+ memcpy(new_offset, v2d->tab_offset, sizeof(float) * v2d->tab_num * 2);
MEM_freeN(v2d->tab_offset);
}
- v2d->tab_offset= new_offset;
- v2d->tab_num= tab+1;
+ v2d->tab_offset = new_offset;
+ v2d->tab_num = tab + 1;
}
/* set current tab and offset */
- v2d->tab_cur= tab;
- v2d->tab_offset[2*tab+0]= v2d->cur.xmin;
- v2d->tab_offset[2*tab+1]= v2d->cur.ymax;
+ v2d->tab_cur = tab;
+ v2d->tab_offset[2 * tab + 0] = v2d->cur.xmin;
+ v2d->tab_offset[2 * tab + 1] = v2d->cur.ymax;
return changed;
}
@@ -955,21 +955,21 @@ int UI_view2d_tab_set(View2D *v2d, int tab)
/* mapping function to ensure 'cur' draws extended over the area where sliders are */
static void view2d_map_cur_using_mask(View2D *v2d, rctf *curmasked)
{
- *curmasked= v2d->cur;
+ *curmasked = v2d->cur;
if (view2d_scroll_mapped(v2d->scroll)) {
- float dx= (v2d->cur.xmax-v2d->cur.xmin)/((float)(v2d->mask.xmax-v2d->mask.xmin+1));
- float dy= (v2d->cur.ymax-v2d->cur.ymin)/((float)(v2d->mask.ymax-v2d->mask.ymin+1));
+ float dx = (v2d->cur.xmax - v2d->cur.xmin) / ((float)(v2d->mask.xmax - v2d->mask.xmin + 1));
+ float dy = (v2d->cur.ymax - v2d->cur.ymin) / ((float)(v2d->mask.ymax - v2d->mask.ymin + 1));
if (v2d->mask.xmin != 0)
- curmasked->xmin -= dx*(float)v2d->mask.xmin;
- if (v2d->mask.xmax+1 != v2d->winx)
- curmasked->xmax += dx*(float)(v2d->winx - v2d->mask.xmax-1);
+ curmasked->xmin -= dx * (float)v2d->mask.xmin;
+ if (v2d->mask.xmax + 1 != v2d->winx)
+ curmasked->xmax += dx * (float)(v2d->winx - v2d->mask.xmax - 1);
if (v2d->mask.ymin != 0)
- curmasked->ymin -= dy*(float)v2d->mask.ymin;
- if (v2d->mask.ymax+1 != v2d->winy)
- curmasked->ymax += dy*(float)(v2d->winy - v2d->mask.ymax-1);
+ curmasked->ymin -= dy * (float)v2d->mask.ymin;
+ if (v2d->mask.ymax + 1 != v2d->winy)
+ curmasked->ymax += dy * (float)(v2d->winy - v2d->mask.ymax - 1);
}
}
@@ -985,14 +985,14 @@ void UI_view2d_view_ortho(View2D *v2d)
*/
/* XXX brecht: instead of zero at least use a tiny offset, otherwise
* pixel rounding is effectively random due to float inaccuracy */
- xofs= 0.001f*(v2d->cur.xmax - v2d->cur.xmin)/(v2d->mask.xmax - v2d->mask.xmin);
- yofs= 0.001f*(v2d->cur.ymax - v2d->cur.ymin)/(v2d->mask.ymax - v2d->mask.ymin);
+ xofs = 0.001f * (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin);
+ yofs = 0.001f * (v2d->cur.ymax - v2d->cur.ymin) / (v2d->mask.ymax - v2d->mask.ymin);
/* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
view2d_map_cur_using_mask(v2d, &curmasked);
- curmasked.xmin-= xofs; curmasked.xmax-=xofs;
- curmasked.ymin-= yofs; curmasked.ymax-=yofs;
+ curmasked.xmin -= xofs; curmasked.xmax -= xofs;
+ curmasked.ymin -= yofs; curmasked.ymax -= yofs;
/* XXX ton: this flag set by outliner, for icons */
if (v2d->flag & V2D_PIXELOFS_X) {
@@ -1005,14 +1005,14 @@ void UI_view2d_view_ortho(View2D *v2d)
}
/* set matrix on all appropriate axes */
- wmOrtho2(curmasked.xmin-xofs, curmasked.xmax-xofs, curmasked.ymin-yofs, curmasked.ymax-yofs);
+ wmOrtho2(curmasked.xmin - xofs, curmasked.xmax - xofs, curmasked.ymin - yofs, curmasked.ymax - yofs);
/* XXX is this necessary? */
glLoadIdentity();
}
/* Set view matrices to only use one axis of 'cur' only
- * - xaxis = if non-zero, only use cur x-axis, otherwise use cur-yaxis (mostly this will be used for x)
+ * - xaxis = if non-zero, only use cur x-axis, otherwise use cur-yaxis (mostly this will be used for x)
*/
void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, short xaxis)
{
@@ -1023,17 +1023,17 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, short xaxis)
* but only applied where requested
*/
/* XXX temp (ton) */
- xofs= 0.0f; // (v2d->flag & V2D_PIXELOFS_X) ? 0.375f : 0.0f;
- yofs= 0.0f; // (v2d->flag & V2D_PIXELOFS_Y) ? 0.375f : 0.0f;
+ xofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_X) ? 0.375f : 0.0f;
+ yofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_Y) ? 0.375f : 0.0f;
/* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
view2d_map_cur_using_mask(v2d, &curmasked);
/* only set matrix with 'cur' coordinates on relevant axes */
if (xaxis)
- wmOrtho2(curmasked.xmin-xofs, curmasked.xmax-xofs, -yofs, ar->winy-yofs);
+ wmOrtho2(curmasked.xmin - xofs, curmasked.xmax - xofs, -yofs, ar->winy - yofs);
else
- wmOrtho2(-xofs, ar->winx-xofs, curmasked.ymin-yofs, curmasked.ymax-yofs);
+ wmOrtho2(-xofs, ar->winx - xofs, curmasked.ymin - yofs, curmasked.ymax - yofs);
/* XXX is this necessary? */
glLoadIdentity();
@@ -1043,9 +1043,9 @@ void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, short xaxis)
/* Restore view matrices after drawing */
void UI_view2d_view_restore(const bContext *C)
{
- ARegion *ar= CTX_wm_region(C);
- int width= ar->winrct.xmax-ar->winrct.xmin+1;
- int height= ar->winrct.ymax-ar->winrct.ymin+1;
+ ARegion *ar = CTX_wm_region(C);
+ int width = ar->winrct.xmax - ar->winrct.xmin + 1;
+ int height = ar->winrct.ymax - ar->winrct.ymin + 1;
wmOrtho2(0.0f, (float)width, 0.0f, (float)height);
glLoadIdentity();
@@ -1058,9 +1058,9 @@ void UI_view2d_view_restore(const bContext *C)
/* View2DGrid is typedef'd in UI_view2d.h */
struct View2DGrid {
- float dx, dy; /* stepsize (in pixels) between gridlines */
- float startx, starty; /* initial coordinates to start drawing grid from */
- int powerx, powery; /* step as power of 10 */
+ float dx, dy; /* stepsize (in pixels) between gridlines */
+ float startx, starty; /* initial coordinates to start drawing grid from */
+ int powerx, powery; /* step as power of 10 */
};
/* --------------- */
@@ -1068,20 +1068,20 @@ struct View2DGrid {
/* try to write step as a power of 10 */
static void step_to_grid(float *step, int *power, int unit)
{
- const float loga= (float)log10(*step);
+ const float loga = (float)log10(*step);
float rem;
- *power= (int)(loga);
+ *power = (int)(loga);
- rem= loga - (*power);
- rem= (float)pow(10.0, rem);
+ rem = loga - (*power);
+ rem = (float)pow(10.0, rem);
if (loga < 0.0f) {
- if (rem < 0.2f) rem= 0.2f;
- else if (rem < 0.5f) rem= 0.5f;
- else rem= 1.0f;
+ if (rem < 0.2f) rem = 0.2f;
+ else if (rem < 0.5f) rem = 0.5f;
+ else rem = 1.0f;
- *step= rem * (float)pow(10.0, (*power));
+ *step = rem * (float)pow(10.0, (*power));
/* for frames, we want 1.0 frame intervals only */
if (unit == V2D_UNIT_FRAMES) {
@@ -1093,11 +1093,11 @@ static void step_to_grid(float *step, int *power, int unit)
if (rem == 1.0f) (*power)++;
}
else {
- if (rem < 2.0f) rem= 2.0f;
- else if (rem < 5.0f) rem= 5.0f;
- else rem= 10.0f;
+ if (rem < 2.0f) rem = 2.0f;
+ else if (rem < 5.0f) rem = 5.0f;
+ else rem = 10.0f;
- *step= rem * (float)pow(10.0, (*power));
+ *step = rem * (float)pow(10.0, (*power));
(*power)++;
/* prevents printing 1.0, 2.0, 3.0, etc. */
@@ -1128,62 +1128,62 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x
return NULL;
/* grid here is allocated... */
- grid= MEM_callocN(sizeof(View2DGrid), "View2DGrid");
+ grid = MEM_callocN(sizeof(View2DGrid), "View2DGrid");
/* rule: gridstep is minimal GRIDSTEP pixels */
if (xunits == V2D_UNIT_SECONDS) {
- seconddiv= (float)(0.01 * FPS);
+ seconddiv = (float)(0.01 * FPS);
}
else {
- seconddiv= 1.0f;
+ seconddiv = 1.0f;
}
/* calculate x-axis grid scale (only if both args are valid) */
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
- space= v2d->cur.xmax - v2d->cur.xmin;
- pixels= (float)(v2d->mask.xmax - v2d->mask.xmin);
+ space = v2d->cur.xmax - v2d->cur.xmin;
+ pixels = (float)(v2d->mask.xmax - v2d->mask.xmin);
- if (pixels!=0.0f) {
- grid->dx= (U.v2d_min_gridsize * space) / (seconddiv * pixels);
+ if (pixels != 0.0f) {
+ grid->dx = (U.v2d_min_gridsize * space) / (seconddiv * pixels);
step_to_grid(&grid->dx, &grid->powerx, xunits);
grid->dx *= seconddiv;
}
if (xclamp == V2D_GRID_CLAMP) {
- if (grid->dx < 0.1f) grid->dx= 0.1f;
- grid->powerx-= 2;
- if (grid->powerx < -2) grid->powerx= -2;
+ if (grid->dx < 0.1f) grid->dx = 0.1f;
+ grid->powerx -= 2;
+ if (grid->powerx < -2) grid->powerx = -2;
}
}
/* calculate y-axis grid scale (only if both args are valid) */
if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
- space= v2d->cur.ymax - v2d->cur.ymin;
- pixels= (float)winy;
+ space = v2d->cur.ymax - v2d->cur.ymin;
+ pixels = (float)winy;
- grid->dy= U.v2d_min_gridsize * space / pixels;
+ grid->dy = U.v2d_min_gridsize * space / pixels;
step_to_grid(&grid->dy, &grid->powery, yunits);
if (yclamp == V2D_GRID_CLAMP) {
- if (grid->dy < 1.0f) grid->dy= 1.0f;
- if (grid->powery < 1) grid->powery= 1;
+ if (grid->dy < 1.0f) grid->dy = 1.0f;
+ if (grid->powery < 1) grid->powery = 1;
}
}
/* calculate start position */
if (ELEM(V2D_ARG_DUMMY, xunits, xclamp) == 0) {
- grid->startx= seconddiv*(v2d->cur.xmin/seconddiv - (float)fmod(v2d->cur.xmin/seconddiv, grid->dx/seconddiv));
- if (v2d->cur.xmin < 0.0f) grid->startx-= grid->dx;
+ grid->startx = seconddiv * (v2d->cur.xmin / seconddiv - (float)fmod(v2d->cur.xmin / seconddiv, grid->dx / seconddiv));
+ if (v2d->cur.xmin < 0.0f) grid->startx -= grid->dx;
}
else
- grid->startx= v2d->cur.xmin;
+ grid->startx = v2d->cur.xmin;
if (ELEM(V2D_ARG_DUMMY, yunits, yclamp) == 0) {
- grid->starty= (v2d->cur.ymin - (float)fmod(v2d->cur.ymin, grid->dy));
- if (v2d->cur.ymin < 0.0f) grid->starty-= grid->dy;
+ grid->starty = (v2d->cur.ymin - (float)fmod(v2d->cur.ymin, grid->dy));
+ if (v2d->cur.ymin < 0.0f) grid->starty -= grid->dy;
}
else
- grid->starty= v2d->cur.ymin;
+ grid->starty = v2d->cur.ymin;
return grid;
}
@@ -1201,70 +1201,70 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
/* vertical lines */
if (flag & V2D_VERTICAL_LINES) {
/* initialize initial settings */
- vec1[0]= vec2[0]= grid->startx;
- vec1[1]= grid->starty;
- vec2[1]= v2d->cur.ymax;
+ vec1[0] = vec2[0] = grid->startx;
+ vec1[1] = grid->starty;
+ vec2[1] = v2d->cur.ymax;
/* minor gridlines */
- step= (v2d->mask.xmax - v2d->mask.xmin + 1) / U.v2d_min_gridsize;
+ step = (v2d->mask.xmax - v2d->mask.xmin + 1) / U.v2d_min_gridsize;
UI_ThemeColor(TH_GRID);
- for (a=0; a<step; a++) {
+ for (a = 0; a < step; a++) {
glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
+ glVertex2fv(vec1);
+ glVertex2fv(vec2);
glEnd();
- vec2[0]= vec1[0]+= grid->dx;
+ vec2[0] = vec1[0] += grid->dx;
}
/* major gridlines */
- vec2[0]= vec1[0]-= 0.5f*grid->dx;
+ vec2[0] = vec1[0] -= 0.5f * grid->dx;
UI_ThemeColorShade(TH_GRID, 16);
step++;
- for (a=0; a<=step; a++) {
+ for (a = 0; a <= step; a++) {
glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
+ glVertex2fv(vec1);
+ glVertex2fv(vec2);
glEnd();
- vec2[0]= vec1[0]-= grid->dx;
+ vec2[0] = vec1[0] -= grid->dx;
}
}
/* horizontal lines */
if (flag & V2D_HORIZONTAL_LINES) {
/* only major gridlines */
- vec1[1]= vec2[1]= grid->starty;
- vec1[0]= grid->startx;
- vec2[0]= v2d->cur.xmax;
+ vec1[1] = vec2[1] = grid->starty;
+ vec1[0] = grid->startx;
+ vec2[0] = v2d->cur.xmax;
- step= (v2d->mask.ymax - v2d->mask.ymin + 1) / U.v2d_min_gridsize;
+ step = (v2d->mask.ymax - v2d->mask.ymin + 1) / U.v2d_min_gridsize;
UI_ThemeColor(TH_GRID);
- for (a=0; a<=step; a++) {
+ for (a = 0; a <= step; a++) {
glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
+ glVertex2fv(vec1);
+ glVertex2fv(vec2);
glEnd();
- vec2[1]= vec1[1]+= grid->dy;
+ vec2[1] = vec1[1] += grid->dy;
}
/* fine grid lines */
- vec2[1]= vec1[1]-= 0.5f*grid->dy;
+ vec2[1] = vec1[1] -= 0.5f * grid->dy;
step++;
if (flag & V2D_HORIZONTAL_FINELINES) {
UI_ThemeColorShade(TH_GRID, 16);
- for (a=0; a<step; a++) {
+ for (a = 0; a < step; a++) {
glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
+ glVertex2fv(vec1);
+ glVertex2fv(vec2);
glEnd();
- vec2[1]= vec1[1]-= grid->dy;
+ vec2[1] = vec1[1] -= grid->dy;
}
}
}
@@ -1274,25 +1274,25 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
/* horizontal axis */
if (flag & V2D_HORIZONTAL_AXIS) {
- vec1[0]= v2d->cur.xmin;
- vec2[0]= v2d->cur.xmax;
- vec1[1]= vec2[1]= 0.0f;
+ vec1[0] = v2d->cur.xmin;
+ vec2[0] = v2d->cur.xmax;
+ vec1[1] = vec2[1] = 0.0f;
glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
+ glVertex2fv(vec1);
+ glVertex2fv(vec2);
glEnd();
}
/* vertical axis */
if (flag & V2D_VERTICAL_AXIS) {
- vec1[1]= v2d->cur.ymin;
- vec2[1]= v2d->cur.ymax;
- vec1[0]= vec2[0]= 0.0f;
+ vec1[1] = v2d->cur.ymin;
+ vec2[1] = v2d->cur.ymax;
+ vec1[0] = vec2[0] = 0.0f;
glBegin(GL_LINE_STRIP);
- glVertex2fv(vec1);
- glVertex2fv(vec2);
+ glVertex2fv(vec1);
+ glVertex2fv(vec2);
glEnd();
}
}
@@ -1300,20 +1300,20 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag)
/* Draw a constant grid in given 2d-region */
void UI_view2d_constant_grid_draw(View2D *v2d)
{
- float start, step= 25.0f;
+ float start, step = 25.0f;
UI_ThemeColorShade(TH_BACK, -10);
- start= v2d->cur.xmin - (float)fmod(v2d->cur.xmin, step);
+ start = v2d->cur.xmin - (float)fmod(v2d->cur.xmin, step);
glBegin(GL_LINES);
- for (; start<v2d->cur.xmax; start+=step) {
+ for (; start < v2d->cur.xmax; start += step) {
glVertex2f(start, v2d->cur.ymin);
glVertex2f(start, v2d->cur.ymax);
}
- start= v2d->cur.ymin - (float)fmod(v2d->cur.ymin, step);
- for (; start<v2d->cur.ymax; start+=step) {
+ start = v2d->cur.ymin - (float)fmod(v2d->cur.ymin, step);
+ for (; start < v2d->cur.ymax; start += step) {
glVertex2f(v2d->cur.xmin, start);
glVertex2f(v2d->cur.xmax, start);
}
@@ -1331,8 +1331,8 @@ void UI_view2d_constant_grid_draw(View2D *v2d)
/* the price we pay for not exposting structs :( */
void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy)
{
- *r_dx= grid->dx;
- *r_dy= grid->dy;
+ *r_dx = grid->dx;
+ *r_dy = grid->dy;
}
/* free temporary memory used for drawing grid */
@@ -1349,20 +1349,20 @@ void UI_view2d_grid_free(View2DGrid *grid)
/* View2DScrollers is typedef'd in UI_view2d.h
* WARNING: the start of this struct must not change, as view2d_ops.c uses this too.
- * For now, we don't need to have a separate (internal) header for structs like this...
+ * For now, we don't need to have a separate (internal) header for structs like this...
*/
struct View2DScrollers {
- /* focus bubbles */
- int vert_min, vert_max; /* vertical scrollbar */
- int hor_min, hor_max; /* horizontal scrollbar */
+ /* focus bubbles */
+ int vert_min, vert_max; /* vertical scrollbar */
+ int hor_min, hor_max; /* horizontal scrollbar */
- rcti hor, vert; /* exact size of slider backdrop */
- int horfull, vertfull; /* set if sliders are full, we don't draw them */
+ rcti hor, vert; /* exact size of slider backdrop */
+ int horfull, vertfull; /* set if sliders are full, we don't draw them */
/* scales */
- View2DGrid *grid; /* grid for coordinate drawing */
- short xunits, xclamp; /* units and clamping options for x-axis */
- short yunits, yclamp; /* units and clamping options for y-axis */
+ View2DGrid *grid; /* grid for coordinate drawing */
+ short xunits, xclamp; /* units and clamping options for x-axis */
+ short yunits, yclamp; /* units and clamping options for y-axis */
};
/* Calculate relevant scroller properties */
@@ -1371,35 +1371,35 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
View2DScrollers *scrollers;
rcti vert, hor;
float fac1, fac2, totsize, scrollsize;
- int scroll= view2d_scroll_mapped(v2d->scroll);
+ int scroll = view2d_scroll_mapped(v2d->scroll);
/* scrollers is allocated here... */
- scrollers= MEM_callocN(sizeof(View2DScrollers), "View2DScrollers");
+ scrollers = MEM_callocN(sizeof(View2DScrollers), "View2DScrollers");
- vert= v2d->vert;
- hor= v2d->hor;
+ vert = v2d->vert;
+ hor = v2d->hor;
/* slider rects need to be smaller than region */
- hor.xmin+=4;
- hor.xmax-=4;
+ hor.xmin += 4;
+ hor.xmax -= 4;
if (scroll & V2D_SCROLL_BOTTOM)
- hor.ymin+=4;
+ hor.ymin += 4;
else
- hor.ymax-=4;
+ hor.ymax -= 4;
if (scroll & V2D_SCROLL_LEFT)
- vert.xmin+=4;
+ vert.xmin += 4;
else
- vert.xmax-=4;
- vert.ymin+=4;
- vert.ymax-=4;
+ vert.xmax -= 4;
+ vert.ymin += 4;
+ vert.ymax -= 4;
- CLAMP(vert.ymin, vert.ymin, vert.ymax-V2D_SCROLLER_HANDLE_SIZE);
- CLAMP(hor.xmin, hor.xmin, hor.xmax-V2D_SCROLLER_HANDLE_SIZE);
+ CLAMP(vert.ymin, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE);
+ CLAMP(hor.xmin, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE);
/* store in scrollers, used for drawing */
- scrollers->vert= vert;
- scrollers->hor= hor;
+ scrollers->vert = vert;
+ scrollers->hor = hor;
/* scroller 'buttons':
* - These should always remain within the visible region of the scrollbar
@@ -1409,38 +1409,38 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
/* horizontal scrollers */
if (scroll & V2D_SCROLL_HORIZONTAL) {
/* scroller 'button' extents */
- totsize= v2d->tot.xmax - v2d->tot.xmin;
- scrollsize= (float)(hor.xmax - hor.xmin);
- if (totsize==0.0f) totsize = 1.0f; /* avoid divide by zero */
-
- fac1= (v2d->cur.xmin - v2d->tot.xmin) / totsize;
- if (fac1<=0.0f)
- scrollers->hor_min= hor.xmin;
+ totsize = v2d->tot.xmax - v2d->tot.xmin;
+ scrollsize = (float)(hor.xmax - hor.xmin);
+ if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */
+
+ fac1 = (v2d->cur.xmin - v2d->tot.xmin) / totsize;
+ if (fac1 <= 0.0f)
+ scrollers->hor_min = hor.xmin;
else
- scrollers->hor_min= (int)(hor.xmin + (fac1 * scrollsize));
+ scrollers->hor_min = (int)(hor.xmin + (fac1 * scrollsize));
- fac2= (v2d->cur.xmax - v2d->tot.xmin) / totsize;
- if (fac2>=1.0f)
- scrollers->hor_max= hor.xmax;
+ fac2 = (v2d->cur.xmax - v2d->tot.xmin) / totsize;
+ if (fac2 >= 1.0f)
+ scrollers->hor_max = hor.xmax;
else
- scrollers->hor_max= (int)(hor.xmin + (fac2 * scrollsize));
+ scrollers->hor_max = (int)(hor.xmin + (fac2 * scrollsize));
/* prevent inverted sliders */
if (scrollers->hor_min > scrollers->hor_max)
- scrollers->hor_min= scrollers->hor_max;
+ scrollers->hor_min = scrollers->hor_max;
/* prevent sliders from being too small, and disappearing */
if ((scrollers->hor_max - scrollers->hor_min) < V2D_SCROLLER_HANDLE_SIZE) {
- scrollers->hor_max= scrollers->hor_min + V2D_SCROLLER_HANDLE_SIZE;
+ scrollers->hor_max = scrollers->hor_min + V2D_SCROLLER_HANDLE_SIZE;
- CLAMP(scrollers->hor_max, hor.xmin+V2D_SCROLLER_HANDLE_SIZE, hor.xmax);
- CLAMP(scrollers->hor_min, hor.xmin, hor.xmax-V2D_SCROLLER_HANDLE_SIZE);
+ CLAMP(scrollers->hor_max, hor.xmin + V2D_SCROLLER_HANDLE_SIZE, hor.xmax);
+ CLAMP(scrollers->hor_min, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE);
}
/* check whether sliders can disappear due to the full-range being used */
if (v2d->keeptot) {
if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) {
v2d->scroll |= V2D_SCROLL_HORIZONTAL_FULLR;
- scrollers->horfull= 1;
+ scrollers->horfull = 1;
}
else
v2d->scroll &= ~V2D_SCROLL_HORIZONTAL_FULLR;
@@ -1450,39 +1450,39 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
/* vertical scrollers */
if (scroll & V2D_SCROLL_VERTICAL) {
/* scroller 'button' extents */
- totsize= v2d->tot.ymax - v2d->tot.ymin;
- scrollsize= (float)(vert.ymax - vert.ymin);
- if (totsize==0.0f) totsize = 1.0f; /* avoid divide by zero */
-
- fac1= (v2d->cur.ymin- v2d->tot.ymin) / totsize;
- if (fac1<=0.0f)
- scrollers->vert_min= vert.ymin;
+ totsize = v2d->tot.ymax - v2d->tot.ymin;
+ scrollsize = (float)(vert.ymax - vert.ymin);
+ if (totsize == 0.0f) totsize = 1.0f; /* avoid divide by zero */
+
+ fac1 = (v2d->cur.ymin - v2d->tot.ymin) / totsize;
+ if (fac1 <= 0.0f)
+ scrollers->vert_min = vert.ymin;
else
- scrollers->vert_min= (int)(vert.ymin + (fac1 * scrollsize));
+ scrollers->vert_min = (int)(vert.ymin + (fac1 * scrollsize));
- fac2= (v2d->cur.ymax - v2d->tot.ymin) / totsize;
- if (fac2>=1.0f)
- scrollers->vert_max= vert.ymax;
+ fac2 = (v2d->cur.ymax - v2d->tot.ymin) / totsize;
+ if (fac2 >= 1.0f)
+ scrollers->vert_max = vert.ymax;
else
- scrollers->vert_max= (int)(vert.ymin + (fac2 * scrollsize));
+ scrollers->vert_max = (int)(vert.ymin + (fac2 * scrollsize));
/* prevent inverted sliders */
if (scrollers->vert_min > scrollers->vert_max)
- scrollers->vert_min= scrollers->vert_max;
+ scrollers->vert_min = scrollers->vert_max;
/* prevent sliders from being too small, and disappearing */
if ((scrollers->vert_max - scrollers->vert_min) < V2D_SCROLLER_HANDLE_SIZE) {
- scrollers->vert_max= scrollers->vert_min + V2D_SCROLLER_HANDLE_SIZE;
+ scrollers->vert_max = scrollers->vert_min + V2D_SCROLLER_HANDLE_SIZE;
- CLAMP(scrollers->vert_max, vert.ymin+V2D_SCROLLER_HANDLE_SIZE, vert.ymax);
- CLAMP(scrollers->vert_min, vert.ymin, vert.ymax-V2D_SCROLLER_HANDLE_SIZE);
+ CLAMP(scrollers->vert_max, vert.ymin + V2D_SCROLLER_HANDLE_SIZE, vert.ymax);
+ CLAMP(scrollers->vert_min, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE);
}
/* check whether sliders can disappear due to the full-range being used */
if (v2d->keeptot) {
if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) {
v2d->scroll |= V2D_SCROLL_VERTICAL_FULLR;
- scrollers->vertfull= 1;
+ scrollers->vertfull = 1;
}
else
v2d->scroll &= ~V2D_SCROLL_VERTICAL_FULLR;
@@ -1490,14 +1490,14 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short
}
/* grid markings on scrollbars */
- if (scroll & (V2D_SCROLL_SCALE_HORIZONTAL|V2D_SCROLL_SCALE_VERTICAL)) {
+ if (scroll & (V2D_SCROLL_SCALE_HORIZONTAL | V2D_SCROLL_SCALE_VERTICAL)) {
/* store clamping */
- scrollers->xclamp= xclamp;
- scrollers->xunits= xunits;
- scrollers->yclamp= yclamp;
- scrollers->yunits= yunits;
+ scrollers->xclamp = xclamp;
+ scrollers->xunits = xunits;
+ scrollers->yclamp = yclamp;
+ scrollers->yunits = yunits;
- scrollers->grid= UI_view2d_grid_calc(CTX_data_scene(C), v2d, xunits, xclamp, yunits, yclamp, (hor.xmax - hor.xmin), (vert.ymax - vert.ymin));
+ scrollers->grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, xunits, xclamp, yunits, yclamp, (hor.xmax - hor.xmin), (vert.ymax - vert.ymin));
}
/* return scrollers */
@@ -1526,19 +1526,19 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
ANIM_timecode_string_from_frame(timecode_str, scene, power, (unit == V2D_UNIT_SECONDS), val);
/* get length of string, and adjust printing location to fit it into the horizontal scrollbar */
- len= strlen(timecode_str);
+ len = strlen(timecode_str);
if (dir == 'h') {
/* seconds/timecode display has slightly longer strings... */
if (unit == V2D_UNIT_SECONDS)
- x-= 3*len;
+ x -= 3 * len;
else
- x-= 4*len;
+ x -= 4 * len;
}
/* Add degree sympbol to end of string for vertical scrollbar? */
if ((dir == 'v') && (unit == V2D_UNIT_DEGREES)) {
- timecode_str[len]= 186;
- timecode_str[len+1]= 0;
+ timecode_str[len] = 186;
+ timecode_str[len + 1] = 0;
}
/* draw it */
@@ -1548,20 +1548,20 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
/* Draw scrollbars in the given 2d-region */
void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *vs)
{
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
rcti vert, hor;
- int scroll= view2d_scroll_mapped(v2d->scroll);
+ int scroll = view2d_scroll_mapped(v2d->scroll);
/* make copies of rects for less typing */
- vert= vs->vert;
- hor= vs->hor;
+ vert = vs->vert;
+ hor = vs->hor;
/* horizontal scrollbar */
if (scroll & V2D_SCROLL_HORIZONTAL) {
/* only draw scrollbar when it doesn't fill the entire space */
- if (vs->horfull==0) {
- bTheme *btheme= UI_GetTheme();
- uiWidgetColors wcol= btheme->tui.wcol_scroll;
+ if (vs->horfull == 0) {
+ bTheme *btheme = UI_GetTheme();
+ uiWidgetColors wcol = btheme->tui.wcol_scroll;
rcti slider;
int state;
@@ -1570,7 +1570,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
slider.ymin = hor.ymin;
slider.ymax = hor.ymax;
- state= (v2d->scroll_ui & V2D_SCROLL_H_ACTIVE)?UI_SCROLL_PRESSED:0;
+ state = (v2d->scroll_ui & V2D_SCROLL_H_ACTIVE) ? UI_SCROLL_PRESSED : 0;
/* show zoom handles if:
* - zooming on x-axis is allowed (no scroll otherwise)
@@ -1579,9 +1579,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
* (workaround to make sure that button windows don't show these,
* and only the time-grids with their zoomability can do so)
*/
- if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0 &&
- (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) &&
- (slider.xmax - slider.xmin > V2D_SCROLLER_HANDLE_SIZE))
+ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 &&
+ (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) &&
+ (slider.xmax - slider.xmin > V2D_SCROLLER_HANDLE_SIZE))
{
state |= UI_SCROLL_ARROWS;
}
@@ -1594,22 +1594,22 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* scale indicators */
if ((scroll & V2D_SCROLL_SCALE_HORIZONTAL) && (vs->grid)) {
- View2DGrid *grid= vs->grid;
+ View2DGrid *grid = vs->grid;
float fac, dfac, fac2, val;
/* the numbers: convert grid->startx and -dx to scroll coordinates
* - fac is x-coordinate to draw to
* - dfac is gap between scale markings
*/
- fac= (grid->startx - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
- fac= (float)hor.xmin + fac*(hor.xmax - hor.xmin);
+ fac = (grid->startx - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
+ fac = (float)hor.xmin + fac * (hor.xmax - hor.xmin);
- dfac= (grid->dx) / (v2d->cur.xmax - v2d->cur.xmin);
- dfac= dfac * (hor.xmax - hor.xmin);
+ dfac = (grid->dx) / (v2d->cur.xmax - v2d->cur.xmin);
+ dfac = dfac * (hor.xmax - hor.xmin);
/* set starting value, and text color */
UI_ThemeColor(TH_TEXT);
- val= grid->startx;
+ val = grid->startx;
/* if we're clamping to whole numbers only, make sure entries won't be repeated */
if (vs->xclamp == V2D_GRID_CLAMP) {
@@ -1619,45 +1619,45 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
}
}
if (vs->xunits == V2D_UNIT_FRAMES)
- grid->powerx= 1;
+ grid->powerx = 1;
/* draw numbers in the appropriate range */
if (dfac > 0.0f) {
- float h= 2.0f+(float)(hor.ymin);
+ float h = 2.0f + (float)(hor.ymin);
- for (; fac < hor.xmax-10; fac+=dfac, val+=grid->dx) {
+ for (; fac < hor.xmax - 10; fac += dfac, val += grid->dx) {
/* make prints look nicer for scrollers */
- if (fac < hor.xmin+10)
+ if (fac < hor.xmin + 10)
continue;
switch (vs->xunits) {
- case V2D_UNIT_FRAMES: /* frames (as whole numbers)*/
+ case V2D_UNIT_FRAMES: /* frames (as whole numbers)*/
scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMES, 'h');
break;
- case V2D_UNIT_FRAMESCALE: /* frames (not always as whole numbers) */
+ case V2D_UNIT_FRAMESCALE: /* frames (not always as whole numbers) */
scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMESCALE, 'h');
break;
- case V2D_UNIT_SECONDS: /* seconds */
- fac2= val/(float)FPS;
+ case V2D_UNIT_SECONDS: /* seconds */
+ fac2 = val / (float)FPS;
scroll_printstr(scene, fac, h, fac2, grid->powerx, V2D_UNIT_SECONDS, 'h');
break;
- case V2D_UNIT_SECONDSSEQ: /* seconds with special calculations (only used for sequencer only) */
+ case V2D_UNIT_SECONDSSEQ: /* seconds with special calculations (only used for sequencer only) */
{
float time;
- fac2= val/(float)FPS;
- time= (float)floor(fac2);
- fac2= fac2-time;
+ fac2 = val / (float)FPS;
+ time = (float)floor(fac2);
+ fac2 = fac2 - time;
- scroll_printstr(scene, fac, h, time+(float)FPS*fac2/100.0f, grid->powerx, V2D_UNIT_SECONDSSEQ, 'h');
+ scroll_printstr(scene, fac, h, time + (float)FPS * fac2 / 100.0f, grid->powerx, V2D_UNIT_SECONDSSEQ, 'h');
}
- break;
+ break;
- case V2D_UNIT_DEGREES: /* Graph Editor for rotation Drivers */
+ case V2D_UNIT_DEGREES: /* Graph Editor for rotation Drivers */
/* HACK: although we're drawing horizontal, we make this draw as 'vertical', just to get degree signs */
scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_DEGREES, 'v');
break;
@@ -1670,9 +1670,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* vertical scrollbar */
if (scroll & V2D_SCROLL_VERTICAL) {
/* only draw scrollbar when it doesn't fill the entire space */
- if (vs->vertfull==0) {
- bTheme *btheme= UI_GetTheme();
- uiWidgetColors wcol= btheme->tui.wcol_scroll;
+ if (vs->vertfull == 0) {
+ bTheme *btheme = UI_GetTheme();
+ uiWidgetColors wcol = btheme->tui.wcol_scroll;
rcti slider;
int state;
@@ -1681,7 +1681,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
slider.ymin = vs->vert_min;
slider.ymax = vs->vert_max;
- state= (v2d->scroll_ui & V2D_SCROLL_V_ACTIVE)?UI_SCROLL_PRESSED:0;
+ state = (v2d->scroll_ui & V2D_SCROLL_V_ACTIVE) ? UI_SCROLL_PRESSED : 0;
/* show zoom handles if:
* - zooming on y-axis is allowed (no scroll otherwise)
@@ -1690,9 +1690,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
* (workaround to make sure that button windows don't show these,
* and only the time-grids with their zoomability can do so)
*/
- if ((v2d->keepzoom & V2D_LOCKZOOM_Y)==0 &&
- (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) &&
- (slider.ymax - slider.ymin > V2D_SCROLLER_HANDLE_SIZE))
+ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 &&
+ (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) &&
+ (slider.ymax - slider.ymin > V2D_SCROLLER_HANDLE_SIZE))
{
state |= UI_SCROLL_ARROWS;
}
@@ -1706,7 +1706,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
/* scale indiators */
if ((scroll & V2D_SCROLL_SCALE_VERTICAL) && (vs->grid)) {
- View2DGrid *grid= vs->grid;
+ View2DGrid *grid = vs->grid;
float fac, dfac, val;
/* the numbers: convert grid->starty and dy to scroll coordinates
@@ -1715,15 +1715,15 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
* - these involve a correction for horizontal scrollbar
* NOTE: it's assumed that that scrollbar is there if this is involved!
*/
- fac= (grid->starty- v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
- fac= vert.ymin + fac*(vert.ymax - vert.ymin);
+ fac = (grid->starty - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
+ fac = vert.ymin + fac * (vert.ymax - vert.ymin);
- dfac= (grid->dy) / (v2d->cur.ymax - v2d->cur.ymin);
- dfac= dfac * (vert.ymax - vert.ymin);
+ dfac = (grid->dy) / (v2d->cur.ymax - v2d->cur.ymin);
+ dfac = dfac * (vert.ymax - vert.ymin);
/* set starting value, and text color */
UI_ThemeColor(TH_TEXT);
- val= grid->starty;
+ val = grid->starty;
/* if vertical clamping (to whole numbers) is used (i.e. in Sequencer), apply correction */
if (vs->yclamp == V2D_GRID_CLAMP)
@@ -1735,13 +1735,13 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
BLF_rotation_default(90.0f);
BLF_enable_default(BLF_ROTATION);
- for (; fac < vert.ymax-10; fac+= dfac, val += grid->dy) {
+ for (; fac < vert.ymax - 10; fac += dfac, val += grid->dy) {
/* make prints look nicer for scrollers */
- if (fac < vert.ymin+10)
+ if (fac < vert.ymin + 10)
continue;
- scroll_printstr(scene, (float)(vert.xmax)-2.0f, fac, val, grid->powery, vs->yunits, 'v');
+ scroll_printstr(scene, (float)(vert.xmax) - 2.0f, fac, val, grid->powery, vs->yunits, 'v');
}
BLF_disable_default(BLF_ROTATION);
@@ -1817,31 +1817,31 @@ void UI_view2d_listview_cell_to_view(View2D *v2d, short columnwidth, short rowhe
* - column, row = the 'coordinates' of the relevant 'cell'
*/
void UI_view2d_listview_view_to_cell(View2D *v2d, short columnwidth, short rowheight, float startx, float starty,
- float viewx, float viewy, int *column, int *row)
+ float viewx, float viewy, int *column, int *row)
{
/* adjust view coordinates to be all positive ints, corrected for the start offset */
- const int x= (int)(floorf(fabsf(viewx) + 0.5f) - startx);
- const int y= (int)(floorf(fabsf(viewy) + 0.5f) - starty);
+ const int x = (int)(floorf(fabsf(viewx) + 0.5f) - startx);
+ const int y = (int)(floorf(fabsf(viewy) + 0.5f) - starty);
/* sizes must not be negative */
if ( (v2d == NULL) || ((columnwidth <= 0) && (rowheight <= 0)) ) {
- if (column) *column= 0;
- if (row) *row= 0;
+ if (column) *column = 0;
+ if (row) *row = 0;
return;
}
/* get column */
if ((column) && (columnwidth > 0))
- *column= x / columnwidth;
+ *column = x / columnwidth;
else if (column)
- *column= 0;
+ *column = 0;
/* get row */
if ((row) && (rowheight > 0))
- *row= y / rowheight;
+ *row = y / rowheight;
else if (row)
- *row= 0;
+ *row = 0;
}
/* Get the 'extreme' (min/max) column and row indices which are visible within the 'cur' rect
@@ -1850,17 +1850,17 @@ void UI_view2d_listview_view_to_cell(View2D *v2d, short columnwidth, short rowhe
* - column/row_min/max = the starting and ending column/row indices
*/
void UI_view2d_listview_visible_cells(View2D *v2d, short columnwidth, short rowheight, float startx, float starty,
- int *column_min, int *column_max, int *row_min, int *row_max)
+ int *column_min, int *column_max, int *row_min, int *row_max)
{
/* using 'cur' rect coordinates, call the cell-getting function to get the cells for this */
if (v2d) {
/* min */
UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
- v2d->cur.xmin, v2d->cur.ymin, column_min, row_min);
+ v2d->cur.xmin, v2d->cur.ymin, column_min, row_min);
/* max*/
UI_view2d_listview_view_to_cell(v2d, columnwidth, rowheight, startx, starty,
- v2d->cur.xmax, v2d->cur.ymax, column_max, row_max);
+ v2d->cur.xmax, v2d->cur.ymax, column_max, row_max);
}
}
@@ -1869,7 +1869,7 @@ void UI_view2d_listview_visible_cells(View2D *v2d, short columnwidth, short rowh
/* Convert from screen/region space to 2d-View space
*
- * - x,y = coordinates to convert
+ * - x,y = coordinates to convert
* - viewx,viewy = resultant coordinates
*/
void UI_view2d_region_to_view(View2D *v2d, int x, int y, float *r_viewx, float *r_viewy)
@@ -1877,73 +1877,73 @@ void UI_view2d_region_to_view(View2D *v2d, int x, int y, float *r_viewx, float *
float div, ofs;
if (r_viewx) {
- div= (float)(v2d->mask.xmax - v2d->mask.xmin);
- ofs= (float)v2d->mask.xmin;
+ div = (float)(v2d->mask.xmax - v2d->mask.xmin);
+ ofs = (float)v2d->mask.xmin;
- *r_viewx= v2d->cur.xmin + (v2d->cur.xmax-v2d->cur.xmin) * ((float)x - ofs) / div;
+ *r_viewx = v2d->cur.xmin + (v2d->cur.xmax - v2d->cur.xmin) * ((float)x - ofs) / div;
}
if (r_viewy) {
- div= (float)(v2d->mask.ymax - v2d->mask.ymin);
- ofs= (float)v2d->mask.ymin;
+ div = (float)(v2d->mask.ymax - v2d->mask.ymin);
+ ofs = (float)v2d->mask.ymin;
- *r_viewy= v2d->cur.ymin + (v2d->cur.ymax - v2d->cur.ymin) * ((float)y - ofs) / div;
+ *r_viewy = v2d->cur.ymin + (v2d->cur.ymax - v2d->cur.ymin) * ((float)y - ofs) / div;
}
}
/* Convert from 2d-View space to screen/region space
* - Coordinates are clamped to lie within bounds of region
*
- * - x,y = coordinates to convert
- * - regionx,regiony = resultant coordinates
+ * - x,y = coordinates to convert
+ * - regionx,regiony = resultant coordinates
*/
void UI_view2d_view_to_region(View2D *v2d, float x, float y, int *regionx, int *regiony)
{
/* set initial value in case coordinate lies outside of bounds */
if (regionx)
- *regionx= V2D_IS_CLIPPED;
+ *regionx = V2D_IS_CLIPPED;
if (regiony)
- *regiony= V2D_IS_CLIPPED;
+ *regiony = V2D_IS_CLIPPED;
/* express given coordinates as proportional values */
- x= (x - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
- y= (y - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
+ x = (x - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
+ y = (y - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
/* check if values are within bounds */
- if ((x>=0.0f) && (x<=1.0f) && (y>=0.0f) && (y<=1.0f)) {
+ if ((x >= 0.0f) && (x <= 1.0f) && (y >= 0.0f) && (y <= 1.0f)) {
if (regionx)
- *regionx= (int)(v2d->mask.xmin + x*(v2d->mask.xmax-v2d->mask.xmin));
+ *regionx = (int)(v2d->mask.xmin + x * (v2d->mask.xmax - v2d->mask.xmin));
if (regiony)
- *regiony= (int)(v2d->mask.ymin + y*(v2d->mask.ymax-v2d->mask.ymin));
+ *regiony = (int)(v2d->mask.ymin + y * (v2d->mask.ymax - v2d->mask.ymin));
}
}
/* Convert from 2d-view space to screen/region space
* - Coordinates are NOT clamped to lie within bounds of region
*
- * - x,y = coordinates to convert
- * - regionx,regiony = resultant coordinates
+ * - x,y = coordinates to convert
+ * - regionx,regiony = resultant coordinates
*/
void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, int *regionx, int *regiony)
{
/* step 1: express given coordinates as proportional values */
- x= (x - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
- y= (y - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
+ x = (x - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
+ y = (y - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
/* step 2: convert proportional distances to screen coordinates */
- x= v2d->mask.xmin + x*(v2d->mask.xmax - v2d->mask.xmin);
- y= v2d->mask.ymin + y*(v2d->mask.ymax - v2d->mask.ymin);
+ x = v2d->mask.xmin + x * (v2d->mask.xmax - v2d->mask.xmin);
+ y = v2d->mask.ymin + y * (v2d->mask.ymax - v2d->mask.ymin);
/* although we don't clamp to lie within region bounds, we must avoid exceeding size of ints */
if (regionx) {
- if (x < INT_MIN) *regionx= INT_MIN;
- else if (x > INT_MAX) *regionx= INT_MAX;
- else *regionx= (int)x;
+ if (x < INT_MIN) *regionx = INT_MIN;
+ else if (x > INT_MAX) *regionx = INT_MAX;
+ else *regionx = (int)x;
}
if (regiony) {
- if (y < INT_MIN) *regiony= INT_MIN;
- else if (y > INT_MAX) *regiony= INT_MAX;
- else *regiony= (int)y;
+ if (y < INT_MIN) *regiony = INT_MIN;
+ else if (y > INT_MAX) *regiony = INT_MAX;
+ else *regiony = (int)y;
}
}
@@ -1953,8 +1953,8 @@ void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, int *regionx, in
/* View2D data by default resides in region, so get from region stored in context */
View2D *UI_view2d_fromcontext(const bContext *C)
{
- ScrArea *area= CTX_wm_area(C);
- ARegion *region= CTX_wm_region(C);
+ ScrArea *area = CTX_wm_area(C);
+ ARegion *region = CTX_wm_region(C);
if (area == NULL) return NULL;
if (region == NULL) return NULL;
@@ -1964,13 +1964,13 @@ View2D *UI_view2d_fromcontext(const bContext *C)
/* same as above, but it returns regionwindow. Utility for pulldowns or buttons */
View2D *UI_view2d_fromcontext_rwin(const bContext *C)
{
- ScrArea *sa= CTX_wm_area(C);
- ARegion *region= CTX_wm_region(C);
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *region = CTX_wm_region(C);
if (sa == NULL) return NULL;
if (region == NULL) return NULL;
- if (region->regiontype!=RGN_TYPE_WINDOW) {
- ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+ if (region->regiontype != RGN_TYPE_WINDOW) {
+ ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
return ar ? &(ar->v2d) : NULL;
}
return &(region->v2d);
@@ -1997,15 +1997,15 @@ void UI_view2d_getscale(View2D *v2d, float *x, float *y)
*
* - x,y = mouse coordinates in screen (not region) space
*/
-short UI_view2d_mouse_in_scrollers (const bContext *C, View2D *v2d, int x, int y)
+short UI_view2d_mouse_in_scrollers(const bContext *C, View2D *v2d, int x, int y)
{
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
int co[2];
- int scroll= view2d_scroll_mapped(v2d->scroll);
+ int scroll = view2d_scroll_mapped(v2d->scroll);
/* clamp x,y to region-coordinates first */
- co[0]= x - ar->winrct.xmin;
- co[1]= y - ar->winrct.ymin;
+ co[0] = x - ar->winrct.xmin;
+ co[1] = y - ar->winrct.ymin;
/* check if within scrollbars */
if (scroll & V2D_SCROLL_HORIZONTAL) {
@@ -2022,7 +2022,7 @@ short UI_view2d_mouse_in_scrollers (const bContext *C, View2D *v2d, int x, int y
/* ******************* view2d text drawing cache ******************** */
/* assumes caches are used correctly, so for time being no local storage in v2d */
-static ListBase strings= {NULL, NULL};
+static ListBase strings = {NULL, NULL};
typedef struct View2DString {
struct View2DString *next, *prev;
@@ -2039,36 +2039,36 @@ void UI_view2d_text_cache_add(View2D *v2d, float x, float y, const char *str, co
{
int mval[2];
- UI_view2d_view_to_region(v2d, x, y, mval, mval+1);
+ UI_view2d_view_to_region(v2d, x, y, mval, mval + 1);
- if (mval[0]!=V2D_IS_CLIPPED && mval[1]!=V2D_IS_CLIPPED) {
- int len= strlen(str)+1;
+ if (mval[0] != V2D_IS_CLIPPED && mval[1] != V2D_IS_CLIPPED) {
+ int len = strlen(str) + 1;
/* use calloc, rect has to be zeroe'd */
- View2DString *v2s= MEM_callocN(sizeof(View2DString)+len, "View2DString");
- char *v2s_str= (char *)(v2s+1);
+ View2DString *v2s = MEM_callocN(sizeof(View2DString) + len, "View2DString");
+ char *v2s_str = (char *)(v2s + 1);
memcpy(v2s_str, str, len);
BLI_addtail(&strings, v2s);
- v2s->col.pack= *((int *)col);
- v2s->mval[0]= mval[0];
- v2s->mval[1]= mval[1];
+ v2s->col.pack = *((int *)col);
+ v2s->mval[0] = mval[0];
+ v2s->mval[1] = mval[1];
}
}
/* no clip (yet) */
void UI_view2d_text_cache_rectf(View2D *v2d, rctf *rect, const char *str, const char col[4])
{
- int len= strlen(str)+1;
- View2DString *v2s= MEM_callocN(sizeof(View2DString)+len, "View2DString");
- char *v2s_str= (char *)(v2s+1);
+ int len = strlen(str) + 1;
+ View2DString *v2s = MEM_callocN(sizeof(View2DString) + len, "View2DString");
+ char *v2s_str = (char *)(v2s + 1);
memcpy(v2s_str, str, len);
UI_view2d_to_region_no_clip(v2d, rect->xmin, rect->ymin, &v2s->rect.xmin, &v2s->rect.ymin);
UI_view2d_to_region_no_clip(v2d, rect->xmax, rect->ymax, &v2s->rect.xmax, &v2s->rect.ymax);
- v2s->col.pack= *((int *)col);
- v2s->mval[0]= v2s->rect.xmin;
- v2s->mval[1]= v2s->rect.ymin;
+ v2s->col.pack = *((int *)col);
+ v2s->mval[0] = v2s->rect.xmin;
+ v2s->mval[1] = v2s->rect.ymin;
BLI_addtail(&strings, v2s);
}
@@ -2077,7 +2077,7 @@ void UI_view2d_text_cache_rectf(View2D *v2d, rctf *rect, const char *str, const
void UI_view2d_text_cache_draw(ARegion *ar)
{
View2DString *v2s;
- int col_pack_prev= 0;
+ int col_pack_prev = 0;
// glMatrixMode(GL_PROJECTION);
// glPushMatrix();
@@ -2085,24 +2085,24 @@ void UI_view2d_text_cache_draw(ARegion *ar)
// glPushMatrix();
ED_region_pixelspace(ar);
- for (v2s= strings.first; v2s; v2s= v2s->next) {
- const char *str= (const char *)(v2s+1);
- int xofs=0, yofs;
+ for (v2s = strings.first; v2s; v2s = v2s->next) {
+ const char *str = (const char *)(v2s + 1);
+ int xofs = 0, yofs;
- yofs= ceil( 0.5f*(v2s->rect.ymax - v2s->rect.ymin - BLF_height_default("28")));
- if (yofs<1) yofs= 1;
+ yofs = ceil(0.5f * (v2s->rect.ymax - v2s->rect.ymin - BLF_height_default("28")));
+ if (yofs < 1) yofs = 1;
if (col_pack_prev != v2s->col.pack) {
glColor3ubv(v2s->col.ub);
- col_pack_prev= v2s->col.pack;
+ col_pack_prev = v2s->col.pack;
}
if (v2s->rect.xmin >= v2s->rect.xmax)
- BLF_draw_default((float)v2s->mval[0]+xofs, (float)v2s->mval[1]+yofs, 0.0, str, BLF_DRAW_STR_DUMMY_MAX);
+ BLF_draw_default((float)v2s->mval[0] + xofs, (float)v2s->mval[1] + yofs, 0.0, str, BLF_DRAW_STR_DUMMY_MAX);
else {
- BLF_clipping_default(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4);
+ BLF_clipping_default(v2s->rect.xmin - 4, v2s->rect.ymin - 4, v2s->rect.xmax + 4, v2s->rect.ymax + 4);
BLF_enable_default(BLF_CLIPPING);
- BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, str, BLF_DRAW_STR_DUMMY_MAX);
+ BLF_draw_default(v2s->rect.xmin + xofs, v2s->rect.ymin + yofs, 0.0f, str, BLF_DRAW_STR_DUMMY_MAX);
BLF_disable_default(BLF_CLIPPING);
}
}
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index c729e944c62..129a47c7063 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -55,7 +55,7 @@
static int view2d_poll(bContext *C)
{
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
return (ar != NULL) && (ar->v2d.flag & V2D_IS_INITIALISED);
}
@@ -63,37 +63,37 @@ static int view2d_poll(bContext *C)
/* ********************************************************* */
/* VIEW PANNING OPERATOR */
-/* This group of operators come in several forms:
+/* This group of operators come in several forms:
* 1) Modal 'dragging' with MMB - where movement of mouse dictates amount to pan view by
* 2) Scrollwheel 'steps' - rolling mousewheel by one step moves view by predefined amount
*
* In order to make sure this works, each operator must define the following RNA-Operator Props:
- * deltax, deltay - define how much to move view by (relative to zoom-correction factor)
+ * deltax, deltay - define how much to move view by (relative to zoom-correction factor)
*/
/* ------------------ Shared 'core' stuff ---------------------- */
/* temp customdata for operator */
typedef struct v2dViewPanData {
- bScreen *sc; /* screen where view pan was initiated */
- ScrArea *sa; /* area where view pan was initiated */
- ARegion *ar; /* region where view pan was initiated */
- View2D *v2d; /* view2d we're operating in */
-
- float facx, facy; /* amount to move view relative to zoom */
-
- /* options for version 1 */
- int startx, starty; /* mouse x/y values in window when operator was initiated */
- int lastx, lasty; /* previous x/y values of mouse in window */
- int invoke_event; /* event starting pan, for modal exit */
+ bScreen *sc; /* screen where view pan was initiated */
+ ScrArea *sa; /* area where view pan was initiated */
+ ARegion *ar; /* region where view pan was initiated */
+ View2D *v2d; /* view2d we're operating in */
+
+ float facx, facy; /* amount to move view relative to zoom */
+
+ /* options for version 1 */
+ int startx, starty; /* mouse x/y values in window when operator was initiated */
+ int lastx, lasty; /* previous x/y values of mouse in window */
+ int invoke_event; /* event starting pan, for modal exit */
- short in_scroller; /* for MMB in scrollers (old feature in past, but now not that useful) */
+ short in_scroller; /* for MMB in scrollers (old feature in past, but now not that useful) */
} v2dViewPanData;
/* initialize panning customdata */
static int view_pan_init(bContext *C, wmOperator *op)
{
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
v2dViewPanData *vpd;
View2D *v2d;
float winx, winy;
@@ -103,25 +103,25 @@ static int view_pan_init(bContext *C, wmOperator *op)
return 0;
/* check if panning is allowed at all */
- v2d= &ar->v2d;
+ v2d = &ar->v2d;
if ((v2d->keepofs & V2D_LOCKOFS_X) && (v2d->keepofs & V2D_LOCKOFS_Y))
return 0;
/* set custom-data for operator */
- vpd= MEM_callocN(sizeof(v2dViewPanData), "v2dViewPanData");
- op->customdata= vpd;
+ vpd = MEM_callocN(sizeof(v2dViewPanData), "v2dViewPanData");
+ op->customdata = vpd;
/* set pointers to owners */
- vpd->sc= CTX_wm_screen(C);
- vpd->sa= CTX_wm_area(C);
- vpd->v2d= v2d;
+ vpd->sc = CTX_wm_screen(C);
+ vpd->sa = CTX_wm_area(C);
+ vpd->v2d = v2d;
vpd->ar = ar;
/* calculate translation factor - based on size of view */
- winx= (float)(ar->winrct.xmax - ar->winrct.xmin + 1);
- winy= (float)(ar->winrct.ymax - ar->winrct.ymin + 1);
- vpd->facx= (v2d->cur.xmax - v2d->cur.xmin) / winx;
- vpd->facy= (v2d->cur.ymax - v2d->cur.ymin) / winy;
+ winx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1);
+ winy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1);
+ vpd->facx = (v2d->cur.xmax - v2d->cur.xmin) / winx;
+ vpd->facy = (v2d->cur.ymax - v2d->cur.ymin) / winy;
return 1;
}
@@ -129,20 +129,20 @@ static int view_pan_init(bContext *C, wmOperator *op)
/* apply transform to view (i.e. adjust 'cur' rect) */
static void view_pan_apply(wmOperator *op)
{
- v2dViewPanData *vpd= op->customdata;
- View2D *v2d= vpd->v2d;
+ v2dViewPanData *vpd = op->customdata;
+ View2D *v2d = vpd->v2d;
float dx, dy;
/* calculate amount to move view by */
- dx= vpd->facx * (float)RNA_int_get(op->ptr, "deltax");
- dy= vpd->facy * (float)RNA_int_get(op->ptr, "deltay");
+ dx = vpd->facx * (float)RNA_int_get(op->ptr, "deltax");
+ dy = vpd->facy * (float)RNA_int_get(op->ptr, "deltay");
/* only move view on an axis if change is allowed */
- if ((v2d->keepofs & V2D_LOCKOFS_X)==0) {
+ if ((v2d->keepofs & V2D_LOCKOFS_X) == 0) {
v2d->cur.xmin += dx;
v2d->cur.xmax += dx;
}
- if ((v2d->keepofs & V2D_LOCKOFS_Y)==0) {
+ if ((v2d->keepofs & V2D_LOCKOFS_Y) == 0) {
v2d->cur.ymin += dy;
v2d->cur.ymax += dy;
}
@@ -156,9 +156,9 @@ static void view_pan_apply(wmOperator *op)
UI_view2d_sync(vpd->sc, vpd->sa, v2d, V2D_LOCK_COPY);
/* exceptions */
- if (vpd->sa->spacetype==SPACE_OUTLINER) {
+ if (vpd->sa->spacetype == SPACE_OUTLINER) {
/* don't rebuild full tree, since we're just changing our view */
- SpaceOops *soops= vpd->sa->spacedata.first;
+ SpaceOops *soops = vpd->sa->spacedata.first;
soops->storeflag |= SO_TREESTORE_REDRAW;
}
}
@@ -168,7 +168,7 @@ static void view_pan_exit(wmOperator *op)
{
if (op->customdata) {
MEM_freeN(op->customdata);
- op->customdata= NULL;
+ op->customdata = NULL;
}
}
@@ -188,7 +188,7 @@ static int view_pan_exec(bContext *C, wmOperator *op)
/* set up modal operator and relevant settings */
static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- wmWindow *window= CTX_wm_window(C);
+ wmWindow *window = CTX_wm_window(C);
v2dViewPanData *vpd;
View2D *v2d;
@@ -196,13 +196,13 @@ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event)
if (!view_pan_init(C, op))
return OPERATOR_PASS_THROUGH;
- vpd= op->customdata;
- v2d= vpd->v2d;
+ vpd = op->customdata;
+ v2d = vpd->v2d;
/* set initial settings */
- vpd->startx= vpd->lastx= event->x;
- vpd->starty= vpd->lasty= event->y;
- vpd->invoke_event= event->type;
+ vpd->startx = vpd->lastx = event->x;
+ vpd->starty = vpd->lasty = event->y;
+ vpd->invoke_event = event->type;
if (event->type == MOUSEPAN) {
RNA_int_set(op->ptr, "deltax", event->prevx - event->x);
@@ -232,7 +232,7 @@ static int view_pan_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* handle user input - calculations of mouse-movement need to be done here, not in the apply callback! */
static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
{
- v2dViewPanData *vpd= op->customdata;
+ v2dViewPanData *vpd = op->customdata;
/* execute the events */
switch (event->type) {
@@ -242,18 +242,18 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
RNA_int_set(op->ptr, "deltax", (vpd->lastx - event->x));
RNA_int_set(op->ptr, "deltay", (vpd->lasty - event->y));
- vpd->lastx= event->x;
- vpd->lasty= event->y;
+ vpd->lastx = event->x;
+ vpd->lasty = event->y;
view_pan_apply(op);
}
- break;
- /* XXX - Mode switching isn't implemented. See comments in 36818.
- * switch to zoom */
+ break;
+ /* XXX - Mode switching isn't implemented. See comments in 36818.
+ * switch to zoom */
#if 0
case LEFTMOUSE:
- if (event->val==KM_PRESS) {
- * calculate overall delta mouse-movement for redo *
+ if (event->val == KM_PRESS) {
+ /* calculate overall delta mouse-movement for redo */
RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx));
RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty));
@@ -264,8 +264,8 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
}
#endif
default:
- if (event->type == vpd->invoke_event || event->type==ESCKEY) {
- if (event->val==KM_RELEASE) {
+ if (event->type == vpd->invoke_event || event->type == ESCKEY) {
+ if (event->val == KM_RELEASE) {
/* calculate overall delta mouse-movement for redo */
RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx));
RNA_int_set(op->ptr, "deltay", (vpd->starty - vpd->lasty));
@@ -302,7 +302,7 @@ static void VIEW2D_OT_pan(wmOperatorType *ot)
ot->cancel = view_pan_cancel;
/* operator is modal */
- ot->flag = OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER;
+ ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER;
/* rna - must keep these in sync with the other operators */
RNA_def_int(ot->srna, "deltax", 0, INT_MIN, INT_MAX, "Delta X", "", INT_MIN, INT_MAX);
@@ -321,7 +321,7 @@ static int view_scrollright_exec(bContext *C, wmOperator *op)
return OPERATOR_PASS_THROUGH;
/* also, check if can pan in horizontal axis */
- vpd= op->customdata;
+ vpd = op->customdata;
if (vpd->v2d->keepofs & V2D_LOCKOFS_X) {
view_pan_exit(op);
return OPERATOR_PASS_THROUGH;
@@ -365,7 +365,7 @@ static int view_scrollleft_exec(bContext *C, wmOperator *op)
return OPERATOR_PASS_THROUGH;
/* also, check if can pan in horizontal axis */
- vpd= op->customdata;
+ vpd = op->customdata;
if (vpd->v2d->keepofs & V2D_LOCKOFS_X) {
view_pan_exit(op);
return OPERATOR_PASS_THROUGH;
@@ -408,7 +408,7 @@ static int view_scrolldown_exec(bContext *C, wmOperator *op)
return OPERATOR_PASS_THROUGH;
/* also, check if can pan in vertical axis */
- vpd= op->customdata;
+ vpd = op->customdata;
if (vpd->v2d->keepofs & V2D_LOCKOFS_Y) {
view_pan_exit(op);
return OPERATOR_PASS_THROUGH;
@@ -419,7 +419,7 @@ static int view_scrolldown_exec(bContext *C, wmOperator *op)
RNA_int_set(op->ptr, "deltay", -40);
if (RNA_boolean_get(op->ptr, "page")) {
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
RNA_int_set(op->ptr, "deltay", ar->v2d.mask.ymin - ar->v2d.mask.ymax);
}
@@ -458,7 +458,7 @@ static int view_scrollup_exec(bContext *C, wmOperator *op)
return OPERATOR_PASS_THROUGH;
/* also, check if can pan in vertical axis */
- vpd= op->customdata;
+ vpd = op->customdata;
if (vpd->v2d->keepofs & V2D_LOCKOFS_Y) {
view_pan_exit(op);
return OPERATOR_PASS_THROUGH;
@@ -469,7 +469,7 @@ static int view_scrollup_exec(bContext *C, wmOperator *op)
RNA_int_set(op->ptr, "deltay", 40);
if (RNA_boolean_get(op->ptr, "page")) {
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
RNA_int_set(op->ptr, "deltay", ar->v2d.mask.ymax - ar->v2d.mask.ymin);
}
@@ -499,7 +499,7 @@ static void VIEW2D_OT_scroll_up(wmOperatorType *ot)
/* ********************************************************* */
/* SINGLE-STEP VIEW ZOOMING OPERATOR */
-/* This group of operators come in several forms:
+/* This group of operators come in several forms:
* 1) Scrollwheel 'steps' - rolling mousewheel by one step zooms view by predefined amount
* 2) Scrollwheel 'steps' + alt + ctrl/shift - zooms view on one axis only (ctrl=x, shift=y) // XXX this could be implemented...
* 3) Pad +/- Keys - pressing each key moves the zooms the view by a predefined amount
@@ -514,42 +514,42 @@ static void VIEW2D_OT_scroll_up(wmOperatorType *ot)
/* temp customdata for operator */
typedef struct v2dViewZoomData {
- View2D *v2d; /* view2d we're operating in */
+ View2D *v2d; /* view2d we're operating in */
ARegion *ar;
/* needed for continuous zoom */
wmTimer *timer;
double timer_lastdraw;
- int lastx, lasty; /* previous x/y values of mouse in window */
- int invoke_event; /* event type that invoked, for modal exits */
- float dx, dy; /* running tally of previous delta values (for obtaining final zoom) */
- float mx_2d, my_2d; /* initial mouse location in v2d coords */
+ int lastx, lasty; /* previous x/y values of mouse in window */
+ int invoke_event; /* event type that invoked, for modal exits */
+ float dx, dy; /* running tally of previous delta values (for obtaining final zoom) */
+ float mx_2d, my_2d; /* initial mouse location in v2d coords */
} v2dViewZoomData;
/* initialize panning customdata */
static int view_zoomdrag_init(bContext *C, wmOperator *op)
{
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
v2dViewZoomData *vzd;
View2D *v2d;
/* regions now have v2d-data by default, so check for region */
if (ar == NULL)
return 0;
- v2d= &ar->v2d;
+ v2d = &ar->v2d;
/* check that 2d-view is zoomable */
if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y))
return 0;
/* set custom-data for operator */
- vzd= MEM_callocN(sizeof(v2dViewZoomData), "v2dViewZoomData");
- op->customdata= vzd;
+ vzd = MEM_callocN(sizeof(v2dViewZoomData), "v2dViewZoomData");
+ op->customdata = vzd;
/* set pointers to owners */
- vzd->v2d= v2d;
+ vzd->v2d = v2d;
vzd->ar = ar;
return 1;
@@ -558,13 +558,13 @@ static int view_zoomdrag_init(bContext *C, wmOperator *op)
/* check if step-zoom can be applied */
static int view_zoom_poll(bContext *C)
{
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
View2D *v2d;
/* check if there's a region in context to work with */
if (ar == NULL)
return 0;
- v2d= &ar->v2d;
+ v2d = &ar->v2d;
/* check that 2d-view is zoomable */
if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y))
@@ -577,42 +577,42 @@ static int view_zoom_poll(bContext *C)
/* apply transform to view (i.e. adjust 'cur' rect) */
static void view_zoomstep_apply(bContext *C, wmOperator *op)
{
- v2dViewZoomData *vzd= op->customdata;
- ARegion *ar= CTX_wm_region(C);
- View2D *v2d= &ar->v2d;
+ v2dViewZoomData *vzd = op->customdata;
+ ARegion *ar = CTX_wm_region(C);
+ View2D *v2d = &ar->v2d;
float dx, dy, facx, facy;
/* calculate amount to move view by, ensuring symmetry so the
* old zoom level is restored after zooming back the same amount
*/
- facx= RNA_float_get(op->ptr, "zoomfacx");
- facy= RNA_float_get(op->ptr, "zoomfacy");
+ facx = RNA_float_get(op->ptr, "zoomfacx");
+ facy = RNA_float_get(op->ptr, "zoomfacy");
if (facx >= 0.0f) {
- dx= (v2d->cur.xmax - v2d->cur.xmin) * facx;
- dy= (v2d->cur.ymax - v2d->cur.ymin) * facy;
+ dx = (v2d->cur.xmax - v2d->cur.xmin) * facx;
+ dy = (v2d->cur.ymax - v2d->cur.ymin) * facy;
}
else {
- dx= ((v2d->cur.xmax - v2d->cur.xmin)/(1.0f + 2.0f*facx)) * facx;
- dy= ((v2d->cur.ymax - v2d->cur.ymin)/(1.0f + 2.0f*facy)) * facy;
+ dx = ((v2d->cur.xmax - v2d->cur.xmin) / (1.0f + 2.0f * facx)) * facx;
+ dy = ((v2d->cur.ymax - v2d->cur.ymin) / (1.0f + 2.0f * facy)) * facy;
}
/* only resize view on an axis if change is allowed */
- if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0) {
+ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
if (v2d->keepofs & V2D_LOCKOFS_X) {
- v2d->cur.xmax -= 2*dx;
+ v2d->cur.xmax -= 2 * dx;
}
else if (v2d->keepofs & V2D_KEEPOFS_X) {
if (v2d->align & V2D_ALIGN_NO_POS_X)
- v2d->cur.xmin += 2*dx;
+ v2d->cur.xmin += 2 * dx;
else
- v2d->cur.xmax -= 2*dx;
+ v2d->cur.xmax -= 2 * dx;
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax-v2d->cur.xmin);
+ float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
float mval_faci = 1.0f - mval_fac;
- float ofs= (mval_fac * dx) - (mval_faci * dx);
+ float ofs = (mval_fac * dx) - (mval_faci * dx);
v2d->cur.xmin += ofs + dx;
v2d->cur.xmax += ofs - dx;
@@ -623,21 +623,21 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
}
}
}
- if ((v2d->keepzoom & V2D_LOCKZOOM_Y)==0) {
+ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
if (v2d->keepofs & V2D_LOCKOFS_Y) {
- v2d->cur.ymax -= 2*dy;
+ v2d->cur.ymax -= 2 * dy;
}
else if (v2d->keepofs & V2D_KEEPOFS_Y) {
if (v2d->align & V2D_ALIGN_NO_POS_Y)
- v2d->cur.ymin += 2*dy;
+ v2d->cur.ymin += 2 * dy;
else
- v2d->cur.ymax -= 2*dy;
+ v2d->cur.ymax -= 2 * dy;
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax-v2d->cur.ymin);
+ float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
float mval_faci = 1.0f - mval_fac;
- float ofs= (mval_fac * dy) - (mval_faci * dy);
+ float ofs = (mval_fac * dy) - (mval_faci * dy);
v2d->cur.ymin += ofs + dy;
v2d->cur.ymax += ofs - dy;
@@ -664,7 +664,7 @@ static void view_zoomstep_exit(wmOperator *op)
{
if (op->customdata) {
MEM_freeN(op->customdata);
- op->customdata= NULL;
+ op->customdata = NULL;
}
}
@@ -694,15 +694,15 @@ static int view_zoomin_invoke(bContext *C, wmOperator *op, wmEvent *event)
if (!view_zoomdrag_init(C, op))
return OPERATOR_PASS_THROUGH;
- vzd= op->customdata;
+ vzd = op->customdata;
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
/* store initial mouse position (in view space) */
UI_view2d_region_to_view(&ar->v2d,
- event->mval[0], event->mval[1],
- &vzd->mx_2d, &vzd->my_2d);
+ event->mval[0], event->mval[1],
+ &vzd->mx_2d, &vzd->my_2d);
}
return view_zoomin_exec(C, op);
@@ -751,15 +751,15 @@ static int view_zoomout_invoke(bContext *C, wmOperator *op, wmEvent *event)
if (!view_zoomdrag_init(C, op))
return OPERATOR_PASS_THROUGH;
- vzd= op->customdata;
+ vzd = op->customdata;
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
/* store initial mouse position (in view space) */
UI_view2d_region_to_view(&ar->v2d,
- event->mval[0], event->mval[1],
- &vzd->mx_2d, &vzd->my_2d);
+ event->mval[0], event->mval[1],
+ &vzd->mx_2d, &vzd->my_2d);
}
return view_zoomout_exec(C, op);
@@ -785,7 +785,7 @@ static void VIEW2D_OT_zoom_out(wmOperatorType *ot)
/* ********************************************************* */
/* DRAG-ZOOM OPERATOR */
-/* MMB Drag - allows non-uniform scaling by dragging mouse
+/* MMB Drag - allows non-uniform scaling by dragging mouse
*
* In order to make sure this works, each operator must define the following RNA-Operator Props:
* deltax, deltay - amounts to add to each side of the 'cur' rect
@@ -794,35 +794,35 @@ static void VIEW2D_OT_zoom_out(wmOperatorType *ot)
/* apply transform to view (i.e. adjust 'cur' rect) */
static void view_zoomdrag_apply(bContext *C, wmOperator *op)
{
- v2dViewZoomData *vzd= op->customdata;
- View2D *v2d= vzd->v2d;
+ v2dViewZoomData *vzd = op->customdata;
+ View2D *v2d = vzd->v2d;
float dx, dy;
/* get amount to move view by */
- dx= RNA_float_get(op->ptr, "deltax");
- dy= RNA_float_get(op->ptr, "deltay");
+ dx = RNA_float_get(op->ptr, "deltax");
+ dy = RNA_float_get(op->ptr, "deltay");
/* continuous zoom shouldn't move that fast... */
if (U.viewzoom == USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
- double time= PIL_check_seconds_timer();
- float time_step= (float)(time - vzd->timer_lastdraw);
+ double time = PIL_check_seconds_timer();
+ float time_step = (float)(time - vzd->timer_lastdraw);
dx *= time_step * 0.5f;
dy *= time_step * 0.5f;
- vzd->timer_lastdraw= time;
+ vzd->timer_lastdraw = time;
}
/* only move view on an axis if change is allowed */
- if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0) {
+ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
if (v2d->keepofs & V2D_LOCKOFS_X) {
- v2d->cur.xmax -= 2*dx;
+ v2d->cur.xmax -= 2 * dx;
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax-v2d->cur.xmin);
+ float mval_fac = (vzd->mx_2d - v2d->cur.xmin) / (v2d->cur.xmax - v2d->cur.xmin);
float mval_faci = 1.0f - mval_fac;
- float ofs= (mval_fac * dx) - (mval_faci * dx);
+ float ofs = (mval_fac * dx) - (mval_faci * dx);
v2d->cur.xmin += ofs + dx;
v2d->cur.xmax += ofs - dx;
@@ -833,15 +833,15 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
}
}
}
- if ((v2d->keepzoom & V2D_LOCKZOOM_Y)==0) {
+ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
if (v2d->keepofs & V2D_LOCKOFS_Y) {
- v2d->cur.ymax -= 2*dy;
+ v2d->cur.ymax -= 2 * dy;
}
else {
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax-v2d->cur.ymin);
+ float mval_fac = (vzd->my_2d - v2d->cur.ymin) / (v2d->cur.ymax - v2d->cur.ymin);
float mval_faci = 1.0f - mval_fac;
- float ofs= (mval_fac * dy) - (mval_faci * dy);
+ float ofs = (mval_fac * dy) - (mval_faci * dy);
v2d->cur.ymin += ofs + dy;
v2d->cur.ymax += ofs - dy;
@@ -865,13 +865,13 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
static void view_zoomdrag_exit(bContext *C, wmOperator *op)
{
if (op->customdata) {
- v2dViewZoomData *vzd= op->customdata;
+ v2dViewZoomData *vzd = op->customdata;
if (vzd->timer)
WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), vzd->timer);
MEM_freeN(op->customdata);
- op->customdata= NULL;
+ op->customdata = NULL;
}
}
@@ -896,7 +896,7 @@ static int view_zoomdrag_exec(bContext *C, wmOperator *op)
/* set up modal operator and relevant settings */
static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- wmWindow *window= CTX_wm_window(C);
+ wmWindow *window = CTX_wm_window(C);
v2dViewZoomData *vzd;
View2D *v2d;
@@ -904,21 +904,21 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
if (!view_zoomdrag_init(C, op))
return OPERATOR_PASS_THROUGH;
- vzd= op->customdata;
- v2d= vzd->v2d;
+ vzd = op->customdata;
+ v2d = vzd->v2d;
if (event->type == MOUSEZOOM) {
float dx, dy, fac;
- vzd->lastx= event->prevx;
- vzd->lasty= event->prevy;
+ vzd->lastx = event->prevx;
+ vzd->lasty = event->prevy;
/* As we have only 1D information (magnify value), feed both axes
* with magnify information that is stored in x axis
*/
- fac= 0.01f * (event->x - event->prevx);
- dx= fac * (v2d->cur.xmax - v2d->cur.xmin) / 10.0f;
- dy= fac * (v2d->cur.ymax - v2d->cur.ymin) / 10.0f;
+ fac = 0.01f * (event->x - event->prevx);
+ dx = fac * (v2d->cur.xmax - v2d->cur.xmin) / 10.0f;
+ dy = fac * (v2d->cur.ymax - v2d->cur.ymin) / 10.0f;
RNA_float_set(op->ptr, "deltax", dx);
RNA_float_set(op->ptr, "deltay", dy);
@@ -929,21 +929,21 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
/* set initial settings */
- vzd->lastx= event->x;
- vzd->lasty= event->y;
+ vzd->lastx = event->x;
+ vzd->lasty = event->y;
RNA_float_set(op->ptr, "deltax", 0);
RNA_float_set(op->ptr, "deltay", 0);
/* for modal exit test */
- vzd->invoke_event= event->type;
+ vzd->invoke_event = event->type;
if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
- ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
/* store initial mouse position (in view space) */
UI_view2d_region_to_view(&ar->v2d,
- event->mval[0], event->mval[1],
- &vzd->mx_2d, &vzd->my_2d);
+ event->mval[0], event->mval[1],
+ &vzd->mx_2d, &vzd->my_2d);
}
if (v2d->keepofs & V2D_LOCKOFS_X)
@@ -958,8 +958,8 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
if (U.viewzoom == USER_ZOOM_CONT) {
/* needs a timer to continue redrawing */
- vzd->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);
- vzd->timer_lastdraw= PIL_check_seconds_timer();
+ vzd->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);
+ vzd->timer_lastdraw = PIL_check_seconds_timer();
}
return OPERATOR_RUNNING_MODAL;
@@ -968,8 +968,8 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* handle user input - calculations of mouse-movement need to be done here, not in the apply callback! */
static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
{
- v2dViewZoomData *vzd= op->customdata;
- View2D *v2d= vzd->v2d;
+ v2dViewZoomData *vzd = op->customdata;
+ View2D *v2d = vzd->v2d;
/* execute the events */
if (event->type == TIMER && event->customdata == vzd->timer) {
@@ -985,35 +985,35 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
/* x-axis transform */
dist = (v2d->mask.xmax - v2d->mask.xmin) / 2.0f;
- dx= 1.0f - (fabsf(vzd->lastx - dist) + 2.0f) / (fabsf(event->x - dist) + 2.0f);
- dx*= 0.5f * (v2d->cur.xmax - v2d->cur.xmin);
+ dx = 1.0f - (fabsf(vzd->lastx - dist) + 2.0f) / (fabsf(event->x - dist) + 2.0f);
+ dx *= 0.5f * (v2d->cur.xmax - v2d->cur.xmin);
/* y-axis transform */
dist = (v2d->mask.ymax - v2d->mask.ymin) / 2.0f;
- dy= 1.0f - (fabsf(vzd->lasty - dist) + 2.0f) / (fabsf(event->y - dist) + 2.0f);
- dy*= 0.5f * (v2d->cur.ymax - v2d->cur.ymin);
+ dy = 1.0f - (fabsf(vzd->lasty - dist) + 2.0f) / (fabsf(event->y - dist) + 2.0f);
+ dy *= 0.5f * (v2d->cur.ymax - v2d->cur.ymin);
}
else {
/* 'continuous' or 'dolly' */
float fac;
/* x-axis transform */
- fac= 0.01f * (event->x - vzd->lastx);
- dx= fac * (v2d->cur.xmax - v2d->cur.xmin);
+ fac = 0.01f * (event->x - vzd->lastx);
+ dx = fac * (v2d->cur.xmax - v2d->cur.xmin);
/* y-axis transform */
- fac= 0.01f * (event->y - vzd->lasty);
- dy= fac * (v2d->cur.ymax - v2d->cur.ymin);
+ fac = 0.01f * (event->y - vzd->lasty);
+ dy = fac * (v2d->cur.ymax - v2d->cur.ymin);
#if 0
/* continuous zoom shouldn't move that fast... */
if (U.viewzoom == USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
- double time= PIL_check_seconds_timer();
- float time_step= (float)(time - vzd->timer_lastdraw);
+ double time = PIL_check_seconds_timer();
+ float time_step = (float)(time - vzd->timer_lastdraw);
dx /= (0.1f / time_step);
dy /= (0.1f / time_step);
- vzd->timer_lastdraw= time;
+ vzd->timer_lastdraw = time;
}
#endif
}
@@ -1028,23 +1028,23 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event)
* - continuous zoom only depends on distance of mouse to starting point to determine rate of change
*/
if (U.viewzoom != USER_ZOOM_CONT) { // XXX store this setting as RNA prop?
- vzd->lastx= event->x;
- vzd->lasty= event->y;
+ vzd->lastx = event->x;
+ vzd->lasty = event->y;
}
/* apply zooming */
view_zoomdrag_apply(C, op);
}
- else if (event->type == vzd->invoke_event || event->type==ESCKEY) {
+ else if (event->type == vzd->invoke_event || event->type == ESCKEY) {
if (event->val == KM_RELEASE) {
/* for redo, store the overall deltas - need to respect zoom-locks here... */
- if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0)
+ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0)
RNA_float_set(op->ptr, "deltax", vzd->dx);
else
RNA_float_set(op->ptr, "deltax", 0);
- if ((v2d->keepzoom & V2D_LOCKZOOM_Y)==0)
+ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0)
RNA_float_set(op->ptr, "deltay", vzd->dy);
else
RNA_float_set(op->ptr, "deltay", 0);
@@ -1097,8 +1097,8 @@ static void VIEW2D_OT_zoom(wmOperatorType *ot)
static int view_borderzoom_exec(bContext *C, wmOperator *op)
{
- ARegion *ar= CTX_wm_region(C);
- View2D *v2d= &ar->v2d;
+ ARegion *ar = CTX_wm_region(C);
+ View2D *v2d = &ar->v2d;
rctf rect;
int gesture_mode;
@@ -1107,7 +1107,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmax"), RNA_int_get(op->ptr, "ymax"), &rect.xmax, &rect.ymax);
/* check if zooming in/out view */
- gesture_mode= RNA_int_get(op->ptr, "gesture_mode");
+ gesture_mode = RNA_int_get(op->ptr, "gesture_mode");
if (gesture_mode == GESTURE_MODAL_IN) {
/* zoom in:
@@ -1115,16 +1115,17 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
* - just set the 'cur' rect to have the same coordinates as the border region
* if zoom is allowed to be changed
*/
- if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0) {
+ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
v2d->cur.xmin = rect.xmin;
v2d->cur.xmax = rect.xmax;
}
- if ((v2d->keepzoom & V2D_LOCKZOOM_Y)==0) {
+ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
v2d->cur.ymin = rect.ymin;
v2d->cur.ymax = rect.ymax;
}
}
- else /* if (gesture_mode == GESTURE_MODAL_OUT) */ {
+ else { /* if (gesture_mode == GESTURE_MODAL_OUT) */
+
/* zoom out:
* - the current 'cur' rect coordinates are going to end up where the 'rect' ones are,
* but the 'cur' rect coordinates will need to be adjusted to take in more of the view
@@ -1133,18 +1134,18 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
float zoom, center, size;
// TODO: is this zoom factor calculation valid? It seems to produce same results everytime...
- if ((v2d->keepzoom & V2D_LOCKZOOM_X)==0) {
- size= (v2d->cur.xmax - v2d->cur.xmin);
- zoom= size / (rect.xmax - rect.xmin);
- center= (v2d->cur.xmax + v2d->cur.xmin) * 0.5f;
+ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
+ size = (v2d->cur.xmax - v2d->cur.xmin);
+ zoom = size / (rect.xmax - rect.xmin);
+ center = (v2d->cur.xmax + v2d->cur.xmin) * 0.5f;
v2d->cur.xmin = center - (size * zoom);
v2d->cur.xmax = center + (size * zoom);
}
- if ((v2d->keepzoom & V2D_LOCKZOOM_Y)==0) {
- size= (v2d->cur.ymax - v2d->cur.ymin);
- zoom= size / (rect.ymax - rect.ymin);
- center= (v2d->cur.ymax + v2d->cur.ymin) * 0.5f;
+ if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
+ size = (v2d->cur.ymax - v2d->cur.ymin);
+ zoom = size / (rect.ymax - rect.ymin);
+ center = (v2d->cur.ymax + v2d->cur.ymin) * 0.5f;
v2d->cur.ymin = center - (size * zoom);
v2d->cur.ymax = center + (size * zoom);
@@ -1187,47 +1188,47 @@ static void VIEW2D_OT_zoom_border(wmOperatorType *ot)
/* ********************************************************* */
/* SCROLLERS */
-/* Scrollers should behave in the following ways, when clicked on with LMB (and dragged):
+/* Scrollers should behave in the following ways, when clicked on with LMB (and dragged):
* 1) 'Handles' on end of 'bubble' - when the axis that the scroller represents is zoomable,
* enlarge 'cur' rect on the relevant side
* 2) 'Bubble'/'bar' - just drag, and bar should move with mouse (view pans opposite)
*
* In order to make sure this works, each operator must define the following RNA-Operator Props:
- * deltax, deltay - define how much to move view by (relative to zoom-correction factor)
+ * deltax, deltay - define how much to move view by (relative to zoom-correction factor)
*/
/* customdata for scroller-invoke data */
typedef struct v2dScrollerMove {
- View2D *v2d; /* View2D data that this operation affects */
- ARegion *ar; /* region that the scroller is in */
+ View2D *v2d; /* View2D data that this operation affects */
+ ARegion *ar; /* region that the scroller is in */
- short scroller; /* scroller that mouse is in ('h' or 'v') */
- short zone; /* -1 is min zoomer, 0 is bar, 1 is max zoomer */ // XXX find some way to provide visual feedback of this (active color?)
+ short scroller; /* scroller that mouse is in ('h' or 'v') */
+ short zone; /* -1 is min zoomer, 0 is bar, 1 is max zoomer */ // XXX find some way to provide visual feedback of this (active color?)
- float fac; /* view adjustment factor, based on size of region */
- float delta; /* amount moved by mouse on axis of interest */
+ float fac; /* view adjustment factor, based on size of region */
+ float delta; /* amount moved by mouse on axis of interest */
- float scrollbarwidth; /* width of the scrollbar itself, used for page up/down clicks */
+ float scrollbarwidth; /* width of the scrollbar itself, used for page up/down clicks */
int scrollbar_orig; /* initial location of scrollbar x/y, mouse relative */
- int lastx, lasty; /* previous mouse coordinates (in screen coordinates) for determining movement */
+ int lastx, lasty; /* previous mouse coordinates (in screen coordinates) for determining movement */
} v2dScrollerMove;
/* View2DScrollers is typedef'd in UI_view2d.h
* This is a CUT DOWN VERSION of the 'real' version, which is defined in view2d.c, as we only need focus bubble info
* WARNING: the start of this struct must not change, so that it stays in sync with the 'real' version
- * For now, we don't need to have a separate (internal) header for structs like this...
+ * For now, we don't need to have a separate (internal) header for structs like this...
*/
struct View2DScrollers {
- /* focus bubbles */
- int vert_min, vert_max; /* vertical scrollbar */
- int hor_min, hor_max; /* horizontal scrollbar */
+ /* focus bubbles */
+ int vert_min, vert_max; /* vertical scrollbar */
+ int hor_min, hor_max; /* horizontal scrollbar */
};
/* quick enum for vsm->zone (scroller handles) */
enum {
- SCROLLHANDLE_MIN= -1,
+ SCROLLHANDLE_MIN = -1,
SCROLLHANDLE_BAR,
SCROLLHANDLE_MAX,
SCROLLHANDLE_MIN_OUTSIDE,
@@ -1237,26 +1238,26 @@ enum {
/* ------------------------ */
/* check if mouse is within scroller handle
- * - mouse = relevant mouse coordinate in region space
- * - sc_min, sc_max = extents of scroller 'groove' (potential available space for scroller)
- * - sh_min, sh_max = positions of scrollbar handles
+ * - mouse = relevant mouse coordinate in region space
+ * - sc_min, sc_max = extents of scroller 'groove' (potential available space for scroller)
+ * - sh_min, sh_max = positions of scrollbar handles
*/
static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_min, int sh_max)
{
- short in_min, in_max, in_bar, out_min, out_max, in_view=1;
+ short in_min, in_max, in_bar, out_min, out_max, in_view = 1;
/* firstly, check if
* - 'bubble' fills entire scroller
* - 'bubble' completely out of view on either side
*/
- if ((sh_min <= sc_min) && (sh_max >= sc_max)) in_view= 0;
+ if ((sh_min <= sc_min) && (sh_max >= sc_max)) in_view = 0;
if (sh_min == sh_max) {
- if (sh_min <= sc_min) in_view= 0;
- if (sh_max >= sc_max) in_view= 0;
+ if (sh_min <= sc_min) in_view = 0;
+ if (sh_max >= sc_max) in_view = 0;
}
else {
- if (sh_max <= sc_min) in_view= 0;
- if (sh_min >= sc_max) in_view= 0;
+ if (sh_max <= sc_min) in_view = 0;
+ if (sh_min >= sc_max) in_view = 0;
}
@@ -1266,11 +1267,11 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
/* check if mouse is in or past either handle */
// TODO: check if these extents are still valid or not
- in_max= ( (mouse >= (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse <= (sh_max + V2D_SCROLLER_HANDLE_SIZE)) );
- in_min= ( (mouse <= (sh_min + V2D_SCROLLER_HANDLE_SIZE)) && (mouse >= (sh_min - V2D_SCROLLER_HANDLE_SIZE)) );
- in_bar= ( (mouse < (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse > (sh_min + V2D_SCROLLER_HANDLE_SIZE)) );
- out_min= mouse < (sh_min - V2D_SCROLLER_HANDLE_SIZE);
- out_max= mouse > (sh_max + V2D_SCROLLER_HANDLE_SIZE);
+ in_max = ( (mouse >= (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse <= (sh_max + V2D_SCROLLER_HANDLE_SIZE)) );
+ in_min = ( (mouse <= (sh_min + V2D_SCROLLER_HANDLE_SIZE)) && (mouse >= (sh_min - V2D_SCROLLER_HANDLE_SIZE)) );
+ in_bar = ( (mouse < (sh_max - V2D_SCROLLER_HANDLE_SIZE)) && (mouse > (sh_min + V2D_SCROLLER_HANDLE_SIZE)) );
+ out_min = mouse < (sh_min - V2D_SCROLLER_HANDLE_SIZE);
+ out_max = mouse > (sh_max + V2D_SCROLLER_HANDLE_SIZE);
if (in_bar)
return SCROLLHANDLE_BAR;
@@ -1292,18 +1293,18 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
{
v2dScrollerMove *vsm;
View2DScrollers *scrollers;
- ARegion *ar= CTX_wm_region(C);
- View2D *v2d= &ar->v2d;
+ ARegion *ar = CTX_wm_region(C);
+ View2D *v2d = &ar->v2d;
float mask_size;
/* set custom-data for operator */
- vsm= MEM_callocN(sizeof(v2dScrollerMove), "v2dScrollerMove");
- op->customdata= vsm;
+ vsm = MEM_callocN(sizeof(v2dScrollerMove), "v2dScrollerMove");
+ op->customdata = vsm;
/* set general data */
- vsm->v2d= v2d;
- vsm->ar= ar;
- vsm->scroller= in_scroller;
+ vsm->v2d = v2d;
+ vsm->ar = ar;
+ vsm->scroller = in_scroller;
/* store mouse-coordinates, and convert mouse/screen coordinates to region coordinates */
vsm->lastx = event->x;
@@ -1311,20 +1312,20 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
/* 'zone' depends on where mouse is relative to bubble
* - zooming must be allowed on this axis, otherwise, default to pan
*/
- scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
+ scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
if (in_scroller == 'h') {
/* horizontal scroller - calculate adjustment factor first */
- mask_size= (float)(v2d->hor.xmax - v2d->hor.xmin);
- vsm->fac= (v2d->tot.xmax - v2d->tot.xmin) / mask_size;
+ mask_size = (float)(v2d->hor.xmax - v2d->hor.xmin);
+ vsm->fac = (v2d->tot.xmax - v2d->tot.xmin) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */
- vsm->zone= mouse_in_scroller_handle(event->mval[0], v2d->hor.xmin, v2d->hor.xmax, scrollers->hor_min, scrollers->hor_max);
+ vsm->zone = mouse_in_scroller_handle(event->mval[0], v2d->hor.xmin, v2d->hor.xmax, scrollers->hor_min, scrollers->hor_max);
if ((v2d->keepzoom & V2D_LOCKZOOM_X) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) {
/* default to scroll, as handles not usable */
- vsm->zone= SCROLLHANDLE_BAR;
+ vsm->zone = SCROLLHANDLE_BAR;
}
vsm->scrollbarwidth = scrollers->hor_max - scrollers->hor_min;
@@ -1332,19 +1333,19 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
}
else {
/* vertical scroller - calculate adjustment factor first */
- mask_size= (float)(v2d->vert.ymax - v2d->vert.ymin);
- vsm->fac= (v2d->tot.ymax - v2d->tot.ymin) / mask_size;
+ mask_size = (float)(v2d->vert.ymax - v2d->vert.ymin);
+ vsm->fac = (v2d->tot.ymax - v2d->tot.ymin) / mask_size;
/* get 'zone' (i.e. which part of scroller is activated) */
- vsm->zone= mouse_in_scroller_handle(event->mval[1], v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max);
+ vsm->zone = mouse_in_scroller_handle(event->mval[1], v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max);
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) {
/* default to scroll, as handles not usable */
- vsm->zone= SCROLLHANDLE_BAR;
+ vsm->zone = SCROLLHANDLE_BAR;
}
vsm->scrollbarwidth = scrollers->vert_max - scrollers->vert_min;
- vsm->scrollbar_orig = ((scrollers->vert_max + scrollers->vert_min) / 2) + + ar->winrct.ymin;
+ vsm->scrollbar_orig = ((scrollers->vert_max + scrollers->vert_min) / 2) + +ar->winrct.ymin;
}
UI_view2d_scrollers_free(scrollers);
@@ -1355,12 +1356,12 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
static void scroller_activate_exit(bContext *C, wmOperator *op)
{
if (op->customdata) {
- v2dScrollerMove *vsm= op->customdata;
+ v2dScrollerMove *vsm = op->customdata;
- vsm->v2d->scroll_ui &= ~(V2D_SCROLL_H_ACTIVE|V2D_SCROLL_V_ACTIVE);
+ vsm->v2d->scroll_ui &= ~(V2D_SCROLL_H_ACTIVE | V2D_SCROLL_V_ACTIVE);
MEM_freeN(op->customdata);
- op->customdata= NULL;
+ op->customdata = NULL;
ED_region_tag_redraw(CTX_wm_region(C));
}
@@ -1376,12 +1377,12 @@ static int scroller_activate_cancel(bContext *C, wmOperator *op)
/* apply transform to view (i.e. adjust 'cur' rect) */
static void scroller_activate_apply(bContext *C, wmOperator *op)
{
- v2dScrollerMove *vsm= op->customdata;
- View2D *v2d= vsm->v2d;
+ v2dScrollerMove *vsm = op->customdata;
+ View2D *v2d = vsm->v2d;
float temp;
/* calculate amount to move view by */
- temp= vsm->fac * vsm->delta;
+ temp = vsm->fac * vsm->delta;
/* type of movement */
switch (vsm->zone) {
@@ -1430,7 +1431,7 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
/* handle user input for scrollers - calculations of mouse-movement need to be done here, not in the apply callback! */
static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event)
{
- v2dScrollerMove *vsm= op->customdata;
+ v2dScrollerMove *vsm = op->customdata;
/* execute the events */
switch (event->type) {
@@ -1441,10 +1442,10 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event)
/* if using bar (i.e. 'panning') or 'max' zoom widget */
switch (vsm->scroller) {
case 'h': /* horizontal scroller - so only horizontal movement ('cur' moves opposite to mouse) */
- vsm->delta= (float)(event->x - vsm->lastx);
+ vsm->delta = (float)(event->x - vsm->lastx);
break;
case 'v': /* vertical scroller - so only vertical movement ('cur' moves opposite to mouse) */
- vsm->delta= (float)(event->y - vsm->lasty);
+ vsm->delta = (float)(event->y - vsm->lasty);
break;
}
}
@@ -1452,25 +1453,25 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event)
/* using 'min' zoom widget */
switch (vsm->scroller) {
case 'h': /* horizontal scroller - so only horizontal movement ('cur' moves with mouse) */
- vsm->delta= (float)(vsm->lastx - event->x);
+ vsm->delta = (float)(vsm->lastx - event->x);
break;
case 'v': /* vertical scroller - so only vertical movement ('cur' moves with to mouse) */
- vsm->delta= (float)(vsm->lasty - event->y);
+ vsm->delta = (float)(vsm->lasty - event->y);
break;
}
}
/* store previous coordinates */
- vsm->lastx= event->x;
- vsm->lasty= event->y;
+ vsm->lastx = event->x;
+ vsm->lasty = event->y;
scroller_activate_apply(C, op);
}
- break;
+ break;
case LEFTMOUSE:
case MIDDLEMOUSE:
- if (event->val==KM_RELEASE) {
+ if (event->val == KM_RELEASE) {
/* single-click was in empty space outside bubble, so scroll by 1 'page' */
if (ELEM(vsm->zone, SCROLLHANDLE_MIN_OUTSIDE, SCROLLHANDLE_MAX_OUTSIDE)) {
if (vsm->zone == SCROLLHANDLE_MIN_OUTSIDE)
@@ -1500,12 +1501,12 @@ static int scroller_activate_modal(bContext *C, wmOperator *op, wmEvent *event)
/* a click (or click drag in progress) should have occurred, so check if it happened in scrollbar */
static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- ARegion *ar= CTX_wm_region(C);
- View2D *v2d= &ar->v2d;
- short in_scroller= 0;
+ ARegion *ar = CTX_wm_region(C);
+ View2D *v2d = &ar->v2d;
+ short in_scroller = 0;
/* check if mouse in scrollbars, if they're enabled */
- in_scroller= UI_view2d_mouse_in_scrollers(C, v2d, event->x, event->y);
+ in_scroller = UI_view2d_mouse_in_scrollers(C, v2d, event->x, event->y);
/* if in a scroller, init customdata then set modal handler which will catch mousedown to start doing useful stuff */
if (in_scroller) {
@@ -1513,39 +1514,39 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* initialize customdata */
scroller_activate_init(C, op, event, in_scroller);
- vsm= (v2dScrollerMove *)op->customdata;
+ vsm = (v2dScrollerMove *)op->customdata;
/* support for quick jump to location - gtk and qt do this on linux */
if (event->type == MIDDLEMOUSE) {
switch (vsm->scroller) {
case 'h': /* horizontal scroller - so only horizontal movement ('cur' moves opposite to mouse) */
- vsm->delta= (float)(event->x - vsm->scrollbar_orig);
+ vsm->delta = (float)(event->x - vsm->scrollbar_orig);
break;
case 'v': /* vertical scroller - so only vertical movement ('cur' moves opposite to mouse) */
- vsm->delta= (float)(event->y - vsm->scrollbar_orig);
+ vsm->delta = (float)(event->y - vsm->scrollbar_orig);
break;
}
scroller_activate_apply(C, op);
- vsm->zone= SCROLLHANDLE_BAR;
+ vsm->zone = SCROLLHANDLE_BAR;
}
/* check if zoom zones are inappropriate (i.e. zoom widgets not shown), so cannot continue
* NOTE: see view2d.c for latest conditions, and keep this in sync with that
*/
if (ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) {
- if ( ((vsm->scroller=='h') && (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL)==0) ||
- ((vsm->scroller=='v') && (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL)==0) )
+ if ( ((vsm->scroller == 'h') && (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL) == 0) ||
+ ((vsm->scroller == 'v') && (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL) == 0) )
{
/* switch to bar (i.e. no scaling gets handled) */
- vsm->zone= SCROLLHANDLE_BAR;
+ vsm->zone = SCROLLHANDLE_BAR;
}
}
/* check if zone is inappropriate (i.e. 'bar' but panning is banned), so cannot continue */
if (vsm->zone == SCROLLHANDLE_BAR) {
- if ( ((vsm->scroller=='h') && (v2d->keepofs & V2D_LOCKOFS_X)) ||
- ((vsm->scroller=='v') && (v2d->keepofs & V2D_LOCKOFS_Y)) )
+ if ( ((vsm->scroller == 'h') && (v2d->keepofs & V2D_LOCKOFS_X)) ||
+ ((vsm->scroller == 'v') && (v2d->keepofs & V2D_LOCKOFS_Y)) )
{
/* free customdata initialized */
scroller_activate_exit(C, op);
@@ -1556,8 +1557,8 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
/* zone is also inappropriate if scroller is not visible... */
- if ( ((vsm->scroller=='h') && (v2d->scroll & (V2D_SCROLL_HORIZONTAL_HIDE|V2D_SCROLL_HORIZONTAL_FULLR))) ||
- ((vsm->scroller=='v') && (v2d->scroll & (V2D_SCROLL_VERTICAL_HIDE|V2D_SCROLL_VERTICAL_FULLR))) )
+ if ( ((vsm->scroller == 'h') && (v2d->scroll & (V2D_SCROLL_HORIZONTAL_HIDE | V2D_SCROLL_HORIZONTAL_FULLR))) ||
+ ((vsm->scroller == 'v') && (v2d->scroll & (V2D_SCROLL_VERTICAL_HIDE | V2D_SCROLL_VERTICAL_FULLR))) )
{
/* free customdata initialized */
scroller_activate_exit(C, op);
@@ -1568,7 +1569,7 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
/* activate the scroller */
- if (vsm->scroller=='h')
+ if (vsm->scroller == 'h')
v2d->scroll_ui |= V2D_SCROLL_H_ACTIVE;
else
v2d->scroll_ui |= V2D_SCROLL_V_ACTIVE;
@@ -1607,14 +1608,14 @@ static void VIEW2D_OT_scroller_activate(wmOperatorType *ot)
static int reset_exec(bContext *C, wmOperator *UNUSED(op))
{
- uiStyle *style= UI_GetStyle();
- ARegion *ar= CTX_wm_region(C);
- View2D *v2d= &ar->v2d;
+ uiStyle *style = UI_GetStyle();
+ ARegion *ar = CTX_wm_region(C);
+ View2D *v2d = &ar->v2d;
int winx, winy;
/* zoom 1.0 */
- winx= (float)(v2d->mask.xmax - v2d->mask.xmin + 1);
- winy= (float)(v2d->mask.ymax - v2d->mask.ymin + 1);
+ winx = (float)(v2d->mask.xmax - v2d->mask.xmin + 1);
+ winy = (float)(v2d->mask.ymax - v2d->mask.ymin + 1);
v2d->cur.xmax = v2d->cur.xmin + winx;
v2d->cur.ymax = v2d->cur.ymin + winy;
@@ -1624,20 +1625,20 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op))
/* posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
v2d->cur.xmax = 0.0f;
- v2d->cur.xmin = -winx*style->panelzoom;
+ v2d->cur.xmin = -winx * style->panelzoom;
}
else if ((v2d->align & V2D_ALIGN_NO_NEG_X) && !(v2d->align & V2D_ALIGN_NO_POS_X)) {
- v2d->cur.xmax = winx*style->panelzoom;
+ v2d->cur.xmax = winx * style->panelzoom;
v2d->cur.xmin = 0.0f;
}
/* - posx and negx flags are mutually exclusive, so watch out */
if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
v2d->cur.ymax = 0.0f;
- v2d->cur.ymin = -winy*style->panelzoom;
+ v2d->cur.ymin = -winy * style->panelzoom;
}
else if ((v2d->align & V2D_ALIGN_NO_NEG_Y) && !(v2d->align & V2D_ALIGN_NO_POS_Y)) {
- v2d->cur.ymax = winy*style->panelzoom;
+ v2d->cur.ymax = winy * style->panelzoom;
v2d->cur.ymin = 0.0f;
}
}
@@ -1715,21 +1716,21 @@ void UI_view2d_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_in", PADPLUSKEY, KM_PRESS, 0, 0);
/* scroll up/down - no modifiers, only when zoom fails */
- /* these may fail if zoom is disallowed, in which case they should pass on event */
+ /* these may fail if zoom is disallowed, in which case they should pass on event */
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", WHEELDOWNMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", WHEELUPMOUSE, KM_PRESS, 0, 0);
- /* these may be necessary if vertical scroll is disallowed */
+ /* these may be necessary if vertical scroll is disallowed */
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_right", WHEELDOWNMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_left", WHEELUPMOUSE, KM_PRESS, 0, 0);
/* alternatives for page up/down to scroll */
#if 0 // XXX disabled, since this causes conflicts with hotkeys in animation editors
- /* scroll up/down may fall through to left/right */
+ /* scroll up/down may fall through to left/right */
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", PAGEDOWNKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_up", PAGEUPKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_right", PAGEDOWNKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_left", PAGEUPKEY, KM_PRESS, 0, 0);
- /* shift for moving view left/right with page up/down */
+ /* shift for moving view left/right with page up/down */
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_right", PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_left", PAGEUPKEY, KM_PRESS, KM_SHIFT, 0);
#endif