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:
Diffstat (limited to 'source/blender/editors/interface/interface_panel.c')
-rw-r--r--source/blender/editors/interface/interface_panel.c410
1 files changed, 205 insertions, 205 deletions
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index ffb8b0acf37..08c96aaf0fb 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -103,17 +103,17 @@ 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) {
+ 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))
+ else if (ELEM3(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS))
return BUT_VERTICAL;
return 0;
@@ -126,34 +126,34 @@ static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa)
*r_pa= NULL;
- if(sa->spacetype==SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) {
+ 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->align)
+ 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) {
- if((pa->runtime_flag & PNL_WAS_ACTIVE) && !(pa->runtime_flag & PNL_ACTIVE))
+ 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))
+ if (!(pa->runtime_flag & PNL_WAS_ACTIVE) && (pa->runtime_flag & PNL_ACTIVE))
return 1;
- if(pa->activedata)
+ if (pa->activedata)
active= 1;
}
/* in case we need to do an animation (size changes) */
- for(pa=ar->panels.first; pa; pa=pa->next) {
- if(pa->runtime_flag & PNL_ANIM_ALIGN) {
- if(!active)
+ for (pa=ar->panels.first; pa; pa=pa->next) {
+ if (pa->runtime_flag & PNL_ANIM_ALIGN) {
+ if (!active)
*r_pa= pa;
return 1;
}
@@ -183,14 +183,14 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int
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);
- if(!newpanel) {
+ if (!newpanel) {
pa->type= pt;
}
else {
@@ -200,8 +200,8 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int
BLI_strncpy(pa->panelname, idname, UI_MAX_NAME_STR);
BLI_strncpy(pa->tabname, tabname, UI_MAX_NAME_STR);
- if(pt->flag & PNL_DEFAULT_CLOSED) {
- if(align == BUT_VERTICAL)
+ if (pt->flag & PNL_DEFAULT_CLOSED) {
+ if (align == BUT_VERTICAL)
pa->flag |= PNL_CLOSEDY;
else
pa->flag |= PNL_CLOSEDX;
@@ -216,11 +216,11 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int
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) {
+ 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;
ui_panel_copy_offset(pa, patab);
break;
@@ -236,19 +236,19 @@ 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)
- if(palast->runtime_flag & PNL_LAST_ADDED)
+ for (palast=ar->panels.first; palast; palast=palast->next)
+ if (palast->runtime_flag & PNL_LAST_ADDED)
break;
- if(newpanel) {
+ if (newpanel) {
pa->sortorder= (palast)? palast->sortorder+1: 0;
- for(panext=ar->panels.first; panext; panext=panext->next)
- if(panext != pa && panext->sortorder >= pa->sortorder)
+ for (panext=ar->panels.first; panext; panext=panext->next)
+ if (panext != pa && panext->sortorder >= pa->sortorder)
panext->sortorder++;
}
- if(palast)
+ if (palast)
palast->runtime_flag &= ~PNL_LAST_ADDED;
/* assign to block */
@@ -257,8 +257,8 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int
*open= 0;
- if(pa->paneltab) return pa;
- if(pa->flag & PNL_CLOSED) return pa;
+ if (pa->paneltab) return pa;
+ if (pa->flag & PNL_CLOSED) return pa;
*open= 1;
@@ -269,23 +269,23 @@ void uiEndPanel(uiBlock *block, int width, int height)
{
Panel *pa= block->panel;
- if(pa->runtime_flag & PNL_NEW_ADDED) {
+ if (pa->runtime_flag & PNL_NEW_ADDED) {
pa->runtime_flag &= ~PNL_NEW_ADDED;
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)) {
+ if (!ELEM(width, 0, pa->sizex) || !ELEM(height, 0, pa->sizey)) {
pa->runtime_flag |= PNL_ANIM_ALIGN;
- if(height != 0)
+ if (height != 0)
pa->ofsy += pa->sizey-height;
}
/* update width/height if non-zero */
- if(width != 0)
+ if (width != 0)
pa->sizex= width;
- if(height != 0)
+ if (height != 0)
pa->sizey= height;
}
}
@@ -301,7 +301,7 @@ static void ui_offset_panel_block(uiBlock *block)
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;
}
@@ -319,7 +319,7 @@ static void uiPanelPush(uiBlock *block)
{
glPushMatrix();
- if(block->panel)
+ if (block->panel)
glTranslatef((float)block->panel->ofsx, (float)block->panel->ofsy, 0.0);
}
@@ -332,10 +332,10 @@ static void uiPanelPop(uiBlock *UNUSED(block))
/* triangle 'icon' for panel header */
void UI_DrawTriIcon(float x, float y, char dir)
{
- if(dir=='h') {
+ if (dir=='h') {
ui_draw_anti_tria( x-3, y-5, x-3, y+5, x+7,y );
}
- else if(dir=='t') {
+ else if (dir=='t') {
ui_draw_anti_tria( x-5, y-7, x+5, y-7, x, y+3);
}
else { /* 'v' = vertical, down */
@@ -346,7 +346,7 @@ void UI_DrawTriIcon(float x, float y, char dir)
/* triangle 'icon' inside rect */
static void ui_draw_tria_rect(rctf *rect, char dir)
{
- if(dir=='h') {
+ 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);
}
@@ -444,7 +444,7 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, rcti *r
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;
+ 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 */
@@ -452,7 +452,7 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, rcti *r
UI_ThemeColor(TH_TITLE);
hrect= *rect;
- if(dir == 'h') {
+ if (dir == 'h') {
hrect.xmin = rect->xmin+pnl_icons;
hrect.ymin += 2.0f/block->aspect;
uiStyleFontDraw(&style->paneltitle, &hrect, activename);
@@ -488,8 +488,8 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
rctf itemrect;
int ofsx;
- if(panel->paneltab) return;
- if(panel->type && (panel->type->flag & PNL_NO_HEADER)) return;
+ if (panel->paneltab) return;
+ if (panel->type && (panel->type->flag & PNL_NO_HEADER)) return;
/* calculate header rect */
/* + 0.001f to prevent flicker due to float inaccuracy */
@@ -504,7 +504,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
glEnable(GL_BLEND);
- if(btheme->tui.panel.show_header) {
+ if (btheme->tui.panel.show_header) {
/* draw with background color */
glEnable(GL_BLEND);
glColor4ubv((unsigned char*)btheme->tui.panel.header);
@@ -513,7 +513,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
fdrawline(minx, y, maxx, y);
fdrawline(minx, y, maxx, y);
}
- else if(!(panel->runtime_flag & PNL_FIRST)) {
+ else if (!(panel->runtime_flag & PNL_FIRST)) {
/* draw embossed separator */
minx += 5.0f/block->aspect;
maxx -= 5.0f/block->aspect;
@@ -529,7 +529,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
}
/* horizontal title */
- if(!(panel->flag & PNL_CLOSEDX)) {
+ if (!(panel->flag & PNL_CLOSEDX)) {
ui_draw_aligned_panel_header(style, block, &headrect, 'h');
/* itemrect smaller */
@@ -545,10 +545,10 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
/* if the panel is minimized vertically:
* (------)
*/
- if(panel->flag & PNL_CLOSEDY) {
+ if (panel->flag & PNL_CLOSEDY) {
}
- else if(panel->flag & PNL_CLOSEDX) {
+ else if (panel->flag & PNL_CLOSEDX) {
/* draw vertical title */
ui_draw_aligned_panel_header(style, block, &headrect, 'v');
}
@@ -556,22 +556,22 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
else {
/* in some occasions, draw a border */
- if(panel->flag & PNL_SELECT) {
- if(panel->control & UI_PNL_SOLID) uiSetRoundBox(UI_CNR_ALL);
+ if (panel->flag & PNL_SELECT) {
+ if (panel->control & UI_PNL_SOLID) uiSetRoundBox(UI_CNR_ALL);
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);
}
- if(panel->control & UI_PNL_SCALE)
+ if (panel->control & UI_PNL_SCALE)
ui_draw_panel_scalewidget(rect);
}
/* draw optional close icon */
ofsx= 6;
- if(panel->control & UI_PNL_CLOSE) {
+ if (panel->control & UI_PNL_CLOSE) {
UI_ThemeColor(TH_TEXT);
ui_draw_x_icon(rect->xmin+2+ofsx, rect->ymax+2);
@@ -589,9 +589,9 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
rectf_scale(&itemrect, 0.35f);
- if(panel->flag & PNL_CLOSEDY)
+ if (panel->flag & PNL_CLOSEDY)
ui_draw_tria_rect(&itemrect, 'h');
- else if(panel->flag & PNL_CLOSEDX)
+ else if (panel->flag & PNL_CLOSEDX)
ui_draw_tria_rect(&itemrect, 'h');
else
ui_draw_tria_rect(&itemrect, 'v');
@@ -603,7 +603,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect)
static int get_panel_header(Panel *pa)
{
- if(pa->type && (pa->type->flag & PNL_NO_HEADER))
+ if (pa->type && (pa->type->flag & PNL_NO_HEADER))
return 0;
return PNL_HEADER;
@@ -611,7 +611,7 @@ static int get_panel_header(Panel *pa)
static int get_panel_size_y(Panel *pa)
{
- if(pa->type && (pa->type->flag & PNL_NO_HEADER))
+ if (pa->type && (pa->type->flag & PNL_NO_HEADER))
return pa->sizey;
return PNL_HEADER + pa->sizey;
@@ -621,16 +621,16 @@ 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;
- else if(pa->paneltab) return pa->paneltab->ofsy;
+ 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);
+ 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;
}
@@ -648,10 +648,10 @@ static int find_leftmost_panel(const void *a1, const void *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;
- else if(ps1->pa->sortorder > ps2->pa->sortorder) return 1;
- else if(ps1->pa->sortorder < ps2->pa->sortorder) return -1;
+ if (ps1->pa->ofsx > ps2->pa->ofsx) return 1;
+ else if (ps1->pa->ofsx < ps2->pa->ofsx) return -1;
+ else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
+ else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
return 0;
}
@@ -665,10 +665,10 @@ static int find_highest_panel(const void *a1, const void *a2)
* 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;
- else if(ps1->pa->sortorder > ps2->pa->sortorder) return 1;
- else if(ps1->pa->sortorder < ps2->pa->sortorder) 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;
return 0;
}
@@ -677,8 +677,8 @@ static int compare_panel(const void *a1, const void *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;
+ if (ps1->pa->sortorder > ps2->pa->sortorder) return 1;
+ else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1;
return 0;
}
@@ -693,18 +693,18 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag)
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;
}
}
@@ -713,22 +713,22 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag)
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) {
+ 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) {
+ 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++)
+ for (ps=panelsort, a=0; a<tot; a++, ps++)
ps->orig->sortorder= a;
}
else
@@ -740,10 +740,10 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag)
ps->pa->ofsx= 0;
ps->pa->ofsy= -get_panel_size_y(ps->pa);
- for(a=0; a<tot-1; a++, ps++) {
+ for (a=0; a<tot-1; a++, ps++) {
psnext= ps+1;
- if(align==BUT_VERTICAL) {
+ 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);
}
@@ -756,9 +756,9 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag)
/* we interpolate */
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)) {
+ 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;
@@ -767,8 +767,8 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag)
}
/* copy locations to tabs */
- for(pa= ar->panels.first; pa; pa= pa->next)
- if(pa->paneltab && (pa->runtime_flag & PNL_ACTIVE))
+ for (pa= ar->panels.first; pa; pa= pa->next)
+ if (pa->paneltab && (pa->runtime_flag & PNL_ACTIVE))
ui_panel_copy_offset(pa, pa->paneltab);
/* free panelsort array */
@@ -788,11 +788,11 @@ static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y)
int sizey = UI_PANEL_WIDTH;
/* compute size taken up by panels, for setting in view2d */
- for(pa= ar->panels.first; pa; pa= pa->next) {
- if(pa->runtime_flag & PNL_ACTIVE) {
+ for (pa= ar->panels.first; pa; pa= pa->next) {
+ if (pa->runtime_flag & PNL_ACTIVE) {
int pa_sizex, pa_sizey;
- if(align==BUT_VERTICAL) {
+ if (align==BUT_VERTICAL) {
pa_sizex= pa->ofsx + pa->sizex;
pa_sizey= get_panel_real_ofsy(pa);
}
@@ -822,12 +822,12 @@ static void ui_do_animate(const bContext *C, Panel *panel)
fac= MIN2(fac, 1.0f);
/* for max 1 second, interpolate positions */
- if(uiAlignPanelStep(sa, ar, fac, 0))
+ if (uiAlignPanelStep(sa, ar, fac, 0))
ED_region_tag_redraw(ar);
else
fac= 1.0f;
- if(fac >= 1.0f) {
+ if (fac >= 1.0f) {
panel_activate_state(C, panel, PANEL_STATE_EXIT);
return;
}
@@ -839,8 +839,8 @@ 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) {
- if(pa->runtime_flag & PNL_ACTIVE)
+ for (pa=ar->panels.first; pa; pa=pa->next) {
+ if (pa->runtime_flag & PNL_ACTIVE)
pa->runtime_flag= PNL_WAS_ACTIVE;
else
pa->runtime_flag= 0;
@@ -855,25 +855,25 @@ void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y)
Panel *panot, *panew, *patest, *pa, *firstpa;
/* offset contents */
- for(block= ar->uiblocks.first; block; block= block->next)
- if(block->active && block->panel)
+ 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) {
- if((panew->runtime_flag & PNL_ACTIVE)) {
- if(panew->paneltab==panot) { // panew is tab in notmade pa
+ 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
break;
}
}
}
/* now panew can become the new parent, check all other tabs */
- if(panew) {
- for(patest= ar->panels.first; patest; patest= patest->next) {
- if(patest->paneltab == panot) {
+ if (panew) {
+ for (patest= ar->panels.first; patest; patest= patest->next) {
+ if (patest->paneltab == panot) {
patest->paneltab= panew;
}
}
@@ -885,8 +885,8 @@ void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y)
}
/* re-align, possibly with animation */
- if(panels_re_align(sa, ar, &pa)) {
- if(pa)
+ if (panels_re_align(sa, ar, &pa)) {
+ if (pa)
panel_activate_state(C, pa, PANEL_STATE_ANIMATION);
else
uiAlignPanelStep(sa, ar, 1.0, 0);
@@ -894,12 +894,12 @@ 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)
- if(block->active && block->panel)
- if(!firstpa || block->panel->sortorder < firstpa->sortorder)
+ for (block= ar->uiblocks.first; block; block=block->next)
+ if (block->active && block->panel)
+ if (!firstpa || block->panel->sortorder < firstpa->sortorder)
firstpa= block->panel;
- if(firstpa)
+ if (firstpa)
firstpa->runtime_flag |= PNL_FIRST;
/* compute size taken up by panel */
@@ -913,14 +913,14 @@ 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) {
- if(block->active && block->panel && !(block->panel->flag & PNL_SELECT)) {
+ 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) {
- if(block->active && block->panel && (block->panel->flag & PNL_SELECT)) {
+ for (block= ar->uiblocks.first; block; block=block->next) {
+ if (block->active && block->panel && (block->panel->flag & PNL_SELECT)) {
uiDrawBlock(C, block);
}
}
@@ -934,21 +934,21 @@ 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)) {
+ 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->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)
+ 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;
}
}
@@ -965,7 +965,7 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel)
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))
+ if (!BLI_in_rcti(&ar->winrct, event->x, event->y))
return;
dx= (event->x-data->startx) & ~(PNL_GRID-1);
@@ -974,10 +974,10 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel)
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) {
+ if (data->state == PANEL_STATE_DRAG_SCALE) {
panel->sizex = MAX2(data->startsizex+dx, UI_PANEL_MINX);
- if(data->startsizey-dy < UI_PANEL_MINY)
+ if (data->startsizey-dy < UI_PANEL_MINY)
dy= -UI_PANEL_MINY+data->startsizey;
panel->sizey= data->startsizey-dy;
@@ -991,7 +991,7 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel)
panel->ofsy = data->startofsy+dy;
check_panel_overlap(ar, panel);
- if(align) uiAlignPanelStep(sa, ar, 0.2, 1);
+ if (align) uiAlignPanelStep(sa, ar, 0.2, 1);
}
ED_region_tag_redraw(ar);
@@ -1014,34 +1014,34 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
/* XXX weak code, currently it assumes layout style for location of widgets */
/* check open/collapsed button */
- if(event==RETKEY)
+ if (event==RETKEY)
button= 1;
- else if(event==AKEY)
+ else if (event==AKEY)
button= 1;
- else if(block->panel->flag & PNL_CLOSEDX) {
- if(my >= block->maxy) button= 1;
+ else if (block->panel->flag & PNL_CLOSEDX) {
+ if (my >= block->maxy) button= 1;
}
- else if(block->panel->control & UI_PNL_CLOSE) {
+ 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;
- //else if(mx <= block->minx+10+2*PNL_ICON+2) button= 1;
+ 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) {
+ else if (mx <= block->maxx-PNL_ICON-12) {
button= 1;
}
- if(button) {
- if(button==2) { // close
+ if (button) {
+ if (button==2) { // close
ED_region_tag_redraw(ar);
}
else { // collapse
- if(block->panel->flag & PNL_CLOSED) {
+ 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;
}
- else if(align==BUT_HORIZONTAL) {
+ else if (align==BUT_HORIZONTAL) {
block->panel->flag |= PNL_CLOSEDX;
}
else {
@@ -1051,20 +1051,20 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
block->panel->ofsy= -block->panel->sizey;
}
- for(pa= ar->panels.first; pa; pa= pa->next) {
- if(pa->paneltab==block->panel) {
- if(block->panel->flag & PNL_CLOSED) pa->flag |= PNL_CLOSED;
+ 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;
}
}
}
- if(align)
+ if (align)
panel_activate_state(C, block->panel, PANEL_STATE_ANIMATION);
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);
}
}
@@ -1080,7 +1080,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
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) {
+ for (block=ar->uiblocks.last; block; block=block->prev) {
mx= event->x;
my= event->y;
ui_window_to_block(ar, block, &mx, &my);
@@ -1089,20 +1089,20 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
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.
+ 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)
+ if (block->minx <= mx && block->maxx >= mx)
+ if (block->miny <= my && block->maxy+PNL_HEADER >= my)
inside= 1;
- if(inside && event->val==KM_PRESS) {
- if(event->type == AKEY && !ELEM4(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift, event->alt)) {
+ 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 (pa->flag & PNL_CLOSEDY) {
+ if ((block->maxy <= my) && (block->maxy+PNL_HEADER >= my))
ui_handle_panel_header(C, block, mx, my, event->type);
}
else
@@ -1113,53 +1113,53 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
}
/* on active button, do not handle panels */
- if(ui_button_is_active(ar))
+ if (ui_button_is_active(ar))
continue;
- if(inside) {
+ if (inside) {
/* clicked at panel header? */
- if(pa->flag & PNL_CLOSEDX) {
- if(block->minx <= mx && block->minx+PNL_HEADER >= mx)
+ if (pa->flag & PNL_CLOSEDX) {
+ if (block->minx <= mx && block->minx+PNL_HEADER >= mx)
inside_header= 1;
}
- else if((block->maxy <= my) && (block->maxy+PNL_HEADER >= my)) {
+ 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)
+ else if (pa->control & UI_PNL_SCALE) {
+ 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) {
+ if (ELEM(event->type, RETKEY, PADENTER)) {
+ if (inside_header) {
ui_handle_panel_header(C, block, mx, my, RETKEY);
break;
}
}
- else if(event->type == LEFTMOUSE) {
- if(inside_header) {
+ else if (event->type == LEFTMOUSE) {
+ if (inside_header) {
ui_handle_panel_header(C, block, mx, my, 0);
break;
}
- else if(inside_scale && !(pa->flag & PNL_CLOSED)) {
+ else if (inside_scale && !(pa->flag & PNL_CLOSED)) {
panel_activate_state(C, pa, PANEL_STATE_DRAG_SCALE);
break;
}
}
- else if(event->type == ESCKEY) {
+ else if (event->type == ESCKEY) {
/*XXX 2.50*/
#if 0
- if(block->handler) {
+ if (block->handler) {
rem_blockhandler(sa, block->handler);
ED_region_tag_redraw(ar);
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;
@@ -1171,13 +1171,13 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
else
zoom=1;
- if(zoom) {
+ if (zoom) {
ScrArea *sa= CTX_wm_area(C);
SpaceLink *sl= sa->spacedata.first;
- if(sa->spacetype!=SPACE_BUTS) {
- if(!(pa->control & UI_PNL_SCALE)) {
- if(event->type==PADPLUSKEY) sl->blockscale+= 0.1;
+ if (sa->spacetype!=SPACE_BUTS) {
+ if (!(pa->control & UI_PNL_SCALE)) {
+ if (event->type==PADPLUSKEY) sl->blockscale+= 0.1;
else sl->blockscale-= 0.1;
CLAMP(sl->blockscale, 0.6, 1.0);
@@ -1204,30 +1204,30 @@ static int ui_handler_panel(bContext *C, wmEvent *event, void *userdata)
uiHandlePanelData *data= panel->activedata;
/* verify if we can stop */
- if(event->type == LEFTMOUSE && event->val!=KM_PRESS) {
+ 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)
+ if (align)
panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
else
panel_activate_state(C, panel, PANEL_STATE_EXIT);
}
- else if(event->type == MOUSEMOVE) {
- if(data->state == PANEL_STATE_DRAG)
+ else if (event->type == MOUSEMOVE) {
+ if (data->state == PANEL_STATE_DRAG)
ui_do_drag(C, event, panel);
}
- else if(event->type == TIMER && event->customdata == data->animtimer) {
- if(data->state == PANEL_STATE_ANIMATION)
+ else if (event->type == TIMER && event->customdata == data->animtimer) {
+ if (data->state == PANEL_STATE_ANIMATION)
ui_do_animate(C, panel);
- else if(data->state == PANEL_STATE_DRAG)
+ else if (data->state == PANEL_STATE_DRAG)
ui_do_drag(C, event, panel);
}
data= panel->activedata;
- if(data && data->state == PANEL_STATE_ANIMATION)
+ if (data && data->state == PANEL_STATE_ANIMATION)
return WM_UI_HANDLER_CONTINUE;
else
return WM_UI_HANDLER_BREAK;
@@ -1246,11 +1246,11 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
wmWindow *win= CTX_wm_window(C);
ARegion *ar= CTX_wm_region(C);
- if(data && data->state == state)
+ if (data && data->state == state)
return;
- if(state == PANEL_STATE_EXIT || state == PANEL_STATE_ANIMATION) {
- if(data && data->state != PANEL_STATE_ANIMATION) {
+ if (state == PANEL_STATE_EXIT || state == PANEL_STATE_ANIMATION) {
+ if (data && data->state != PANEL_STATE_ANIMATION) {
/* XXX:
* - the panel tabbing function call below (test_add_new_tabs()) has been commented out
* "It is too easy to do by accident when reordering panels, is very hard to control and use, and has no real benefit." - BillRey
@@ -1265,26 +1265,26 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
else
pa->flag |= PNL_SELECT;
- if(data && data->animtimer) {
+ if (data && data->animtimer) {
WM_event_remove_timer(CTX_wm_manager(C), win, data->animtimer);
data->animtimer= NULL;
}
- if(state == PANEL_STATE_EXIT) {
+ if (state == PANEL_STATE_EXIT) {
MEM_freeN(data);
pa->activedata= NULL;
WM_event_remove_ui_handler(&win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, 0);
}
else {
- if(!data) {
+ if (!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))
+ 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;
@@ -1301,15 +1301,15 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat
/* 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
}