When choosing "render engine" in Scene Buttons, the newly added or removed
Panels didn't invoke a re-alignment event yet.
Also added code that inserts new panels as good as possible on their
previous locations. This works reliable for 1 new panel, not for more, this
because a Panel only stores its old location, not the locations of all
Panels in a given configuration. Consider that minor issue...
This commit is contained in:
Ton Roosendaal
2004-12-01 12:39:14 +00:00
parent 10e64fe4b4
commit d7c8ff725a
5 changed files with 26 additions and 2 deletions

View File

@@ -2885,6 +2885,7 @@ static void direct_link_screen(FileData *fd, bScreen *sc)
for(pa= sa->panels.first; pa; pa=pa->next) {
pa->paneltab= newdataadr(fd, pa->paneltab);
pa->active= 0;
pa->sortcounter= 0;
}
for (sl= sa->spacedata.first; sl; sl= sl->next) {

View File

@@ -272,6 +272,7 @@ void test_idbutton_cb(void *namev, void *arg2_unused);
#define B_FILETYPEMENU 1638
#define B_SELECTCODEC 1639
#define B_RTCHANGED 1640
#define B_SWITCHRENDER 1641
#ifdef __NLA
/* *********************** */

View File

@@ -87,7 +87,7 @@ typedef struct Panel { /* the part from uiBlock that needs saved in file */
short flag, active; /* active= used currently by a uiBlock */
short control, pad;
short old_ofsx, old_ofsy; /* for stow */
int pad2;
int sortcounter; /* when sorting panels, it uses this to put new ones in right place */
struct Panel *paneltab; /* this panel is tabbed in *paneltab */
} Panel;

View File

@@ -492,6 +492,11 @@ void do_render_panels(unsigned short event)
case B_RTCHANGED:
allqueue(REDRAWALL, 0);
break;
case B_SWITCHRENDER:
/* new panels added, so... */
G.buts->re_align= 1;
allqueue(REDRAWBUTSSCENE, 0);
break;
case B_PLAYANIM:
#ifdef WITH_QUICKTIME
if(G.scene->r.imtype == R_QUICKTIME)
@@ -1080,7 +1085,7 @@ static void render_panel_render(void)
uiBlockBeginAlign(block);
uiDefBut(block, BUT,B_DORENDER,"RENDER", 369, 164, 191,37, 0, 0, 0, 0, 0, "Start the rendering");
/* yafray: on request, render engine menu is back again, and moved to Render panel */
uiDefButS(block, MENU, B_REDR, "Rendering Engine %t|Blender Internal %x0|YafRay %x1",
uiDefButS(block, MENU, B_SWITCHRENDER, "Rendering Engine %t|Blender Internal %x0|YafRay %x1",
369, 142, 191, 20, &G.scene->r.renderer, 0, 0, 0, 0, "Choose rendering engine");
uiBlockBeginAlign(block);

View File

@@ -1169,12 +1169,20 @@ typedef struct PanelSort {
Panel *pa, *orig;
} PanelSort;
/* note about sorting;
the sortcounter has a lower value for new panels being added.
however, that only works to insert a single panel, when more new panels get
added the coordinates of existing panels and the previously stored to-be-insterted
panels do not match for sorting */
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->sortcounter > ps2->pa->sortcounter) return 1;
else if( ps1->pa->sortcounter < ps2->pa->sortcounter) return -1;
return 0;
}
@@ -1186,6 +1194,8 @@ static int find_highest_panel(const void *a1, const void *a2)
if( ps1->pa->ofsy < ps2->pa->ofsy) return 1;
else if( ps1->pa->ofsy > ps2->pa->ofsy) return -1;
else if( ps1->pa->sortcounter > ps2->pa->sortcounter) return 1;
else if( ps1->pa->sortcounter < ps2->pa->sortcounter) return -1;
return 0;
}
@@ -1197,6 +1207,7 @@ int uiAlignPanelStep(ScrArea *sa, float fac)
SpaceButs *sbuts= sa->spacedata.first;
Panel *pa;
PanelSort *ps, *panelsort, *psnext;
static int sortcounter= 0;
int a, tot=0, done;
if(sa->spacetype!=SPACE_BUTS) {
@@ -1278,6 +1289,12 @@ int uiAlignPanelStep(ScrArea *sa, float fac)
}
}
/* set counter, used for sorting with newly added panels */
sortcounter++;
for(pa= sa->panels.first; pa; pa= pa->next) {
if(pa->active) pa->sortcounter= sortcounter;
}
/* free panelsort array */
ps= panelsort;
for(a=0; a<tot; a++, ps++) {