Page Menu
Home
Search
Configure Global Search
Log In
Files
F11467
panel_solo.diff
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
sneg negr (sneg)
Nov 13 2013, 2:24 PM
Size
17 KB
Subscribers
None
panel_solo.diff
View Options
Index: source/blender/editors/interface/interface_panel.c
===================================================================
--- source/blender/editors/interface/interface_panel.c (revision 28545)
+++ source/blender/editors/interface/interface_panel.c (working copy)
@@ -26,7 +26,7 @@
*/
/* a full doc with API notes can be found in bf-blender/blender/doc/interface_API.txt */
-
+
#include <math.h>
#include <stdlib.h>
#include <string.h>
@@ -64,6 +64,7 @@
#define PNL_LAST_ADDED 1
#define PNL_ACTIVE 2
+#define PNL_SOLO 3
#define PNL_WAS_ACTIVE 4
#define PNL_ANIM_ALIGN 8
#define PNL_NEW_ADDED 16
@@ -106,10 +107,10 @@
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)
- return BUT_VERTICAL;
+ return BUT_VERTICAL;
else if(ELEM3(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS))
return BUT_VERTICAL;
-
+
return 0;
}
@@ -152,7 +153,7 @@
return 1;
}
}
-
+
return 0;
}
@@ -176,13 +177,13 @@
char *hookname= NULL;
int newpanel;
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)
break;
-
+
newpanel= (pa == NULL);
if(!newpanel) {
@@ -201,7 +202,7 @@
else
pa->flag |= PNL_CLOSEDX;
}
-
+
pa->ofsx= 0;
pa->ofsy= style->panelouter;
pa->sizex= 0;
@@ -209,7 +210,7 @@
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) {
@@ -222,7 +223,7 @@
}
}
}
- }
+ }
}
}
@@ -234,7 +235,7 @@
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;
@@ -256,7 +257,7 @@
if(pa->flag & PNL_CLOSED) return pa;
*open= 1;
-
+
return pa;
}
@@ -295,13 +296,13 @@
mx= CTX_wm_window(C)->eventstate->x;
my= CTX_wm_window(C)->eventstate->y;
-
+
pa->ofsx= mx-pa->sizex/2;
pa->ofsy= my-pa->sizey/2;
-
+
if(pa->flag & PNL_CLOSED) pa->flag &= ~PNL_CLOSED;
}
-
+
if(pa->control & UI_PNL_UNSTOW) {
if(pa->flag & PNL_CLOSEDY) {
pa->flag &= ~PNL_CLOSED;
@@ -337,7 +338,7 @@
/* extern used by previewrender */
void uiPanelPush(uiBlock *block)
{
- glPushMatrix();
+ glPushMatrix();
if(block->panel)
glTranslatef((float)block->panel->ofsx, (float)block->panel->ofsy, 0.0);
@@ -355,7 +356,7 @@
ui_draw_anti_tria(x-1, y, x-1, y+11.0, x+9, y+6.25);
}
else {
- ui_draw_anti_tria(x-3, y+10, x+8-1, y+10, x+4.25-2, y);
+ ui_draw_anti_tria(x-3, y+10, x+8-1, y+10, x+4.25-2, y);
}
}
@@ -380,15 +381,15 @@
glEnable(GL_BLEND);
glLineWidth(2.0);
-
+
fdrawline(x1, y1, x2, y2);
fdrawline(x1, y2, x2, y1);
-
+
glLineWidth(1.0);
-
+
glDisable(GL_LINE_SMOOTH);
glDisable(GL_BLEND);
-
+
}
/* x 'icon' for panel header */
@@ -405,20 +406,20 @@
{
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;
-
+
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);
-
+
glColor4ub(0, 0, 0, 50);
fdrawline(xmin, ymin+1, xmax, ymax+1);
fdrawline(xmin+dx, ymin+1, xmax, ymax-dy+1);
@@ -429,21 +430,21 @@
{
float xmin, xmax, dx;
float ymin, ymax, dy;
-
+
xmin= rect->xmin;
xmax= rect->xmax;
ymin= rect->ymin;
ymax= rect->ymax;
-
+
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);
-
+
glColor4ub(0, 0, 0, 50);
fdrawline(xmin, ymax+1, xmax, ymin+1);
fdrawline(xmin+dx, ymax+1, xmax, ymin+dy+1);
@@ -458,22 +459,22 @@
rcti hrect;
int pnl_icons;
char *activename= 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;
-
+
/* active tab */
/* draw text label */
UI_ThemeColor(TH_TITLE);
-
+
hrect= *rect;
if(dir == 'h') {
hrect.xmin= rect->xmin+pnl_icons;
uiStyleFontDraw(&style->paneltitle, &hrect, activename);
}
else {
- /* ignore 'pnl_icons', otherwise the text gets offset horizontally
+ /* 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;
@@ -487,7 +488,7 @@
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;
rect->ymin= centy - sizey;
@@ -501,7 +502,7 @@
rcti headrect;
rctf itemrect;
int ofsx;
-
+
if(panel->paneltab) return;
if(panel->type && (panel->type->flag & PNL_NO_HEADER)) return;
@@ -510,12 +511,12 @@
headrect= *rect;
headrect.ymin= headrect.ymax;
headrect.ymax= headrect.ymin + floor(PNL_HEADER/block->aspect + 0.001f);
-
+
if(!(panel->runtime_flag & PNL_FIRST)) {
float minx= rect->xmin+5.0f/block->aspect;
float maxx= rect->xmax-5.0f/block->aspect;
float y= headrect.ymax;
-
+
glEnable(GL_BLEND);
glColor4f(0.0f, 0.0f, 0.0f, 0.5f);
fdrawline(minx, y+1, maxx, y+1);
@@ -523,12 +524,12 @@
fdrawline(minx, y, maxx, y);
glDisable(GL_BLEND);
}
-
+
/* horizontal title */
if(!(panel->flag & PNL_CLOSEDX)) {
ui_draw_aligned_panel_header(ar, style, block, &headrect, 'h');
-
- /* itemrect smaller */
+
+ /* itemrect smaller */
itemrect.xmax= headrect.xmax - 5.0f/block->aspect;
itemrect.xmin= itemrect.xmax - (headrect.ymax-headrect.ymin);
itemrect.ymin= headrect.ymin;
@@ -536,12 +537,12 @@
rectf_scale(&itemrect, 0.8f);
ui_draw_panel_dragwidget(&itemrect);
}
-
+
/* if the panel is minimized vertically:
* (------)
*/
if(panel->flag & PNL_CLOSEDY) {
-
+
}
else if(panel->flag & PNL_CLOSEDX) {
/* draw vertical title */
@@ -549,49 +550,49 @@
}
/* an open panel */
else {
-
+
/* in some occasions, draw a border */
if(panel->flag & PNL_SELECT) {
if(panel->control & UI_PNL_SOLID) uiSetRoundBox(15);
else uiSetRoundBox(3);
-
+
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)
ui_draw_panel_scalewidget(rect);
}
-
+
/* draw optional close icon */
-
+
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;
}
-
+
/* draw collapse icon */
UI_ThemeColor(TH_TEXT);
-
- /* itemrect smaller */
+
+ /* itemrect smaller */
itemrect.xmin= headrect.xmin + 5.0f/block->aspect;
itemrect.xmax= itemrect.xmin + (headrect.ymax-headrect.ymin);
itemrect.ymin= headrect.ymin;
itemrect.ymax= headrect.ymax;
-
+
rectf_scale(&itemrect, 0.5f);
-
+
if(panel->flag & PNL_CLOSEDY)
ui_draw_tria_rect(&itemrect, 'h');
else if(panel->flag & PNL_CLOSEDX)
ui_draw_tria_rect(&itemrect, 'h');
else
ui_draw_tria_rect(&itemrect, 'v');
-
-
+
+
}
/************************** panel alignment *************************/
@@ -642,7 +643,7 @@
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;
@@ -655,22 +656,22 @@
static int find_highest_panel(const void *a1, const void *a2)
{
const PanelSort *ps1=a1, *ps2=a2;
-
+
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;
}
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;
-
+
return 0;
}
@@ -683,7 +684,7 @@
PanelSort *ps, *panelsort, *psnext;
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)
@@ -703,7 +704,7 @@
/* sort panels */
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) {
@@ -712,10 +713,10 @@
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);
@@ -726,7 +727,7 @@
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;
@@ -734,7 +735,7 @@
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(style, psnext->pa);
@@ -744,7 +745,7 @@
psnext->pa->ofsy= ps->pa->ofsy + get_panel_size_y(style, ps->pa) - get_panel_size_y(style, psnext->pa);
}
}
-
+
/* we interpolate */
done= 0;
ps= panelsort;
@@ -767,7 +768,7 @@
for(ps= panelsort, a=0; a<tot; a++, ps++)
MEM_freeN(ps->pa);
MEM_freeN(panelsort);
-
+
return done;
}
@@ -798,7 +799,7 @@
void uiBeginPanels(const bContext *C, ARegion *ar)
{
Panel *pa;
-
+
/* 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) {
@@ -815,7 +816,7 @@
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)
if(block->active && block->panel)
@@ -843,7 +844,7 @@
panew->paneltab= NULL;
ED_region_tag_redraw(ar); // the buttons panew were not made
}
- }
+ }
}
/* re-align, possibly with animation */
@@ -860,12 +861,12 @@
if(block->active && block->panel)
if(!firstpa || block->panel->sortorder < firstpa->sortorder)
firstpa= block->panel;
-
+
if(firstpa)
firstpa->runtime_flag |= PNL_FIRST;
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)) {
@@ -887,18 +888,18 @@
Panel *pa;
/* also called with panel==NULL for clear */
-
+
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->ofsx > panel->ofsx- safex*panel->sizex)
if(pa->ofsx+pa->sizex < panel->ofsx+ (1.0+safex)*panel->sizex)
if(pa->ofsy > panel->ofsy- safey*panel->sizey)
@@ -917,7 +918,7 @@
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;
@@ -927,10 +928,10 @@
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);
-
+
if(data->startsizey-dy < UI_PANEL_MINY)
dy= -UI_PANEL_MINY+data->startsizey;
@@ -940,11 +941,11 @@
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;
check_panel_overlap(ar, panel);
-
+
if(align) uiAlignPanelStep(sa, ar, 0.2, 1);
}
@@ -964,11 +965,16 @@
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)
+ if(event == EVT_TWEAK_A){
+ if(block->panel->runtime_flag != PNL_SOLO){
+ if(mx <= block->minx+10+PNL_ICON-2) button = 3;
+ }
+ }
+ else if(event==RETKEY)
button= 1;
else if(event==AKEY)
button= 1;
@@ -982,16 +988,27 @@
else if(mx <= block->minx+10+PNL_ICON+2) {
button= 1;
}
-
- if(button) {
- if(button==2) { // close
+
+ if(button){
+ if(button==3){ // solo
+ for(pa= ar->panels.first; pa; pa= pa->next) {
+ if(pa != block->panel) {
+ pa->flag= (align==BUT_HORIZONTAL)? PNL_CLOSEDX: PNL_CLOSEDY;
+ block->panel->runtime_flag = PNL_CLOSED;
+ } else {
+ pa->flag &= ~PNL_CLOSED;
+ block->panel->runtime_flag = PNL_SOLO;
+ }
+ }
+ }
+ else if(button==2) { // close
ED_region_tag_redraw(ar);
}
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)
+ if (block->panel->snap & PNL_SNAP_BOTTOM)
block->panel->ofsy= 0;
}
else if(align==BUT_HORIZONTAL) {
@@ -1000,10 +1017,10 @@
else {
/* snap down to bottom screen edge*/
block->panel->flag |= PNL_CLOSEDY;
- if (block->panel->snap & PNL_SNAP_BOTTOM)
+ if (block->panel->snap & PNL_SNAP_BOTTOM)
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;
@@ -1053,29 +1070,29 @@
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) {
-
+
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
ui_handle_panel_header(C, block, mx, my, event->type);
-
+
continue;
}
}
-
+
/* on active button, do not handle panels */
if(ui_button_is_active(ar))
continue;
-
+
if(inside) {
/* clicked at panel header? */
if(pa->flag & PNL_CLOSEDX) {
- if(block->minx <= mx && block->minx+PNL_HEADER >= mx)
+ if(block->minx <= mx && block->minx+PNL_HEADER >= mx)
inside_header= 1;
}
else if((block->maxy <= my) && (block->maxy+PNL_HEADER >= my)) {
@@ -1095,9 +1112,13 @@
break;
}
}
- else if(event->type == LEFTMOUSE) {
+ else if(event->type==LEFTMOUSE) {
if(inside_header) {
- ui_handle_panel_header(C, block, mx, my, 0);
+ if(event->ctrl) {
+ ui_handle_panel_header(C, block, mx, my, EVT_TWEAK_A);
+ } else {
+ ui_handle_panel_header(C, block, mx, my, 0);
+ }
break;
}
else if(inside_scale && !(pa->flag & PNL_CLOSED)) {
@@ -1114,7 +1135,7 @@
}
else if(event->type==PADPLUSKEY || event->type==PADMINUS) {
int zoom=0;
-
+
/* if panel is closed, only zoom if mouse is over the header */
if (pa->flag & (PNL_CLOSEDX|PNL_CLOSEDY)) {
if (inside_header)
@@ -1136,7 +1157,7 @@
ED_region_tag_redraw(ar);
retval= WM_UI_HANDLER_BREAK;
- }
+ }
}
}
#endif
@@ -1198,7 +1219,7 @@
uiHandlePanelData *data= pa->activedata;
wmWindow *win= CTX_wm_window(C);
ARegion *ar= CTX_wm_region(C);
-
+
if(data && data->state == state)
return;
@@ -1255,7 +1276,7 @@
/* XXX exception handling, 3d window preview panel */
/* if(block->drawextra==BIF_view3d_previewdraw)
BIF_view3d_previewrender_clear(curarea);*/
-
+
/* XXX exception handling, 3d window preview panel */
/* if(block->drawextra==BIF_view3d_previewdraw)
BIF_view3d_previewrender_signal(curarea, PR_DISPRECT);
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
5f/b6/b348577b3e673e044cb7817b909f
Event Timeline
Log In to Comment