diff options
author | Ton Roosendaal <ton@blender.org> | 2004-12-01 15:39:14 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2004-12-01 15:39:14 +0300 |
commit | d7c8ff725afa8748b2443e18ff2aba359afe022f (patch) | |
tree | 7f604506c391d3989ab21ec8306c7848c8776e8e /source | |
parent | 10e64fe4b4ad42209d6a01155b0d3ad2d6e5dda3 (diff) |
Bug #1909
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...
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 1 | ||||
-rw-r--r-- | source/blender/include/butspace.h | 1 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_screen_types.h | 2 | ||||
-rw-r--r-- | source/blender/src/buttons_scene.c | 7 | ||||
-rw-r--r-- | source/blender/src/interface_panel.c | 17 |
5 files changed, 26 insertions, 2 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 97e7828a91c..18c70b0586b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -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) { diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h index 9cbff1fb8af..eedebeda96c 100644 --- a/source/blender/include/butspace.h +++ b/source/blender/include/butspace.h @@ -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 /* *********************** */ diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index f11374dff99..dc5a0b20b17 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -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; diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index f2a4e20ced1..cb9f184bf1e 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -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); diff --git a/source/blender/src/interface_panel.c b/source/blender/src/interface_panel.c index 2d486aac7fa..d16b3bcef18 100644 --- a/source/blender/src/interface_panel.c +++ b/source/blender/src/interface_panel.c @@ -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++) { |