forked from bartvdbraak/blender
Various changes to screen-related code, aiming to fix a few problems and usability issues with 'temp' screen layouts.
Now, temp screens are hidden from being accessed directly, with a new 'Back to Previous' button appearing in place of the screen menu when (for example) fullscreen render image areas are present. Window type menus also get disabled here too, to prevent things from getting too mixed up.
This commit is contained in:
parent
f4fa39a551
commit
81a69bb00f
Binary file not shown.
Before Width: | Height: | Size: 204 KiB After Width: | Height: | Size: 204 KiB |
@ -29,6 +29,7 @@ class INFO_HT_header(bpy.types.Header):
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
window = context.window
|
||||
scene = context.scene
|
||||
rd = scene.render_data
|
||||
|
||||
@ -45,7 +46,12 @@ class INFO_HT_header(bpy.types.Header):
|
||||
sub.menu("INFO_MT_render")
|
||||
sub.menu("INFO_MT_help")
|
||||
|
||||
layout.template_ID(context.window, "screen", new="screen.new", unlink="screen.delete")
|
||||
if window.screen.fullscreen:
|
||||
layout.operator("screen.back_to_previous", icon="ICON_SCREEN_BACK", text="Back to Previous")
|
||||
layout.separator()
|
||||
else:
|
||||
layout.template_ID(context.window, "screen", new="screen.new", unlink="screen.delete")
|
||||
|
||||
layout.template_ID(context.screen, "scene", new="scene.new", unlink="scene.delete")
|
||||
|
||||
layout.separator()
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -81,7 +81,7 @@ void ED_area_tag_refresh(ScrArea *sa);
|
||||
void ED_area_do_refresh(struct bContext *C, ScrArea *sa);
|
||||
void ED_area_headerprint(ScrArea *sa, const char *str);
|
||||
void ED_area_newspace(struct bContext *C, ScrArea *sa, int type);
|
||||
void ED_area_prevspace(struct bContext *C);
|
||||
void ED_area_prevspace(struct bContext *C, ScrArea *sa);
|
||||
void ED_area_swapspace(struct bContext *C, ScrArea *sa1, ScrArea *sa2);
|
||||
|
||||
/* screens */
|
||||
@ -100,7 +100,8 @@ void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen
|
||||
void ED_screen_animation_timer(struct bContext *C, int redraws, int sync, int enable);
|
||||
void ED_screen_animation_timer_update(struct bContext *C, int redraws);
|
||||
int ED_screen_full_newspace(struct bContext *C, ScrArea *sa, int type);
|
||||
void ED_screen_full_prevspace(struct bContext *C);
|
||||
void ED_screen_full_prevspace(struct bContext *C, ScrArea *sa);
|
||||
void ED_screen_full_restore(struct bContext *C, ScrArea *sa);
|
||||
|
||||
void ED_screen_new_window(struct bContext *C, struct rcti *position, int type);
|
||||
|
||||
|
@ -76,7 +76,7 @@ DEF_ICON(ICON_UNLOCKED)
|
||||
DEF_ICON(ICON_LOCKED)
|
||||
DEF_ICON(ICON_UNPINNED)
|
||||
DEF_ICON(ICON_PINNED)
|
||||
DEF_ICON(ICON_BLANK015)
|
||||
DEF_ICON(ICON_SCREEN_BACK)
|
||||
DEF_ICON(ICON_RIGHTARROW)
|
||||
DEF_ICON(ICON_DOWNARROW_HLT)
|
||||
DEF_ICON(ICON_DOTSUP)
|
||||
|
@ -1089,30 +1089,11 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type)
|
||||
}
|
||||
}
|
||||
|
||||
void ED_area_prevspace(bContext *C)
|
||||
void ED_area_prevspace(bContext *C, ScrArea *sa)
|
||||
{
|
||||
SpaceLink *sl= CTX_wm_space_data(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
|
||||
/* cleanup */
|
||||
#if 0 // XXX needs to be space type specific
|
||||
if(sfile->spacetype==SPACE_FILE) {
|
||||
if(sfile->pupmenu) {
|
||||
MEM_freeN(sfile->pupmenu);
|
||||
sfile->pupmenu= NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
SpaceLink *sl = (sa) ? sa->spacedata.first : CTX_wm_space_data(C);
|
||||
|
||||
if(sl->next) {
|
||||
|
||||
#if 0 // XXX check whether this is still needed
|
||||
if (sfile->spacetype == SPACE_SCRIPT) {
|
||||
SpaceScript *sc = (SpaceScript *)sfile;
|
||||
if (sc->script) sc->script->flags &=~SCRIPT_FILESEL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* workaround for case of double prevspace, render window
|
||||
with a file browser on top of it */
|
||||
if(sl->next->spacetype == SPACE_FILE && sl->next->next)
|
||||
@ -1193,7 +1174,8 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco)
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
int xco= 8;
|
||||
|
||||
xco= ED_area_header_switchbutton(C, block, yco);
|
||||
if (!sa->full)
|
||||
xco= ED_area_header_switchbutton(C, block, yco);
|
||||
|
||||
uiBlockSetEmboss(block, UI_EMBOSSN);
|
||||
|
||||
|
@ -1312,7 +1312,13 @@ void ED_screen_delete(bContext *C, bScreen *sc)
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
bScreen *newsc;
|
||||
int delete= 1;
|
||||
|
||||
|
||||
/* don't allow deleting temp fullscreens for now */
|
||||
if (sc->full == SCREENFULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* screen can only be in use by one window at a time, so as
|
||||
long as we are able to find a screen that is unused, we
|
||||
can safely assume ours is not in use anywhere an delete it */
|
||||
@ -1536,17 +1542,42 @@ int ED_screen_full_newspace(bContext *C, ScrArea *sa, int type)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ED_screen_full_prevspace(bContext *C)
|
||||
void ED_screen_full_prevspace(bContext *C, ScrArea *sa)
|
||||
{
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
|
||||
ED_area_prevspace(C);
|
||||
|
||||
ED_area_prevspace(C, sa);
|
||||
|
||||
if(sa->full)
|
||||
ed_screen_fullarea(C, win, sa);
|
||||
}
|
||||
|
||||
/* restore a screen / area back to default operation, after temp fullscreen modes */
|
||||
void ED_screen_full_restore(bContext *C, ScrArea *sa)
|
||||
{
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
SpaceLink *sl = sa->spacedata.first;
|
||||
|
||||
/* if fullscreen area has a secondary space (such as as file browser or fullscreen render
|
||||
* overlaid on top of a existing setup) then return to the previous space */
|
||||
|
||||
if (sl->next) {
|
||||
/* specific checks for space types */
|
||||
if (sl->spacetype == SPACE_IMAGE) {
|
||||
SpaceImage *sima= sa->spacedata.first;
|
||||
if (sima->flag & SI_PREVSPACE)
|
||||
sima->flag &= ~SI_PREVSPACE;
|
||||
if (sima->flag & SI_FULLWINDOW)
|
||||
sima->flag &= ~SI_FULLWINDOW;
|
||||
}
|
||||
ED_screen_full_prevspace(C, sa);
|
||||
}
|
||||
/* otherwise just tile the area again */
|
||||
else {
|
||||
ed_screen_fullarea(C, win, sa);
|
||||
}
|
||||
}
|
||||
|
||||
/* redraws: uses defines from stime->redraws
|
||||
* enable: 1 - forward on, -1 - backwards on, 0 - off
|
||||
*/
|
||||
|
@ -1544,10 +1544,10 @@ static int screen_set_exec(bContext *C, wmOperator *op)
|
||||
int tot= BLI_countlist(&CTX_data_main(C)->screen);
|
||||
int delta= RNA_int_get(op->ptr, "delta");
|
||||
|
||||
/* this screen is 'fake', solve later XXX */
|
||||
/* return to previous state before switching screens */
|
||||
if(sa && sa->full)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
ED_screen_full_restore(C, sa);
|
||||
|
||||
if(delta==1) {
|
||||
while(tot--) {
|
||||
screen= screen->id.next;
|
||||
@ -3412,10 +3412,10 @@ static int render_view_cancel_exec(bContext *C, wmOperator *unused)
|
||||
|
||||
if(sima->flag & SI_FULLWINDOW) {
|
||||
sima->flag &= ~SI_FULLWINDOW;
|
||||
ED_screen_full_prevspace(C);
|
||||
ED_screen_full_prevspace(C, sa);
|
||||
}
|
||||
else
|
||||
ED_area_prevspace(C);
|
||||
ED_area_prevspace(C, sa);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@ -3459,7 +3459,7 @@ static int render_view_show_invoke(bContext *C, wmOperator *unused, wmEvent *eve
|
||||
|
||||
if(sima->flag & SI_FULLWINDOW) {
|
||||
sima->flag &= ~SI_FULLWINDOW;
|
||||
ED_screen_full_prevspace(C);
|
||||
ED_screen_full_prevspace(C, sa);
|
||||
}
|
||||
else if(sima->next) {
|
||||
ED_area_newspace(C, sa, sima->next->spacetype);
|
||||
@ -3486,6 +3486,40 @@ static void SCREEN_OT_render_view_show(struct wmOperatorType *ot)
|
||||
ot->poll= ED_operator_screenactive;
|
||||
}
|
||||
|
||||
/* *********************** generic fullscreen 'back' button *************** */
|
||||
|
||||
|
||||
static int fullscreen_back_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bScreen *screen = CTX_wm_screen(C);
|
||||
ScrArea *sa=NULL;
|
||||
|
||||
/* search current screen for 'fullscreen' areas */
|
||||
for (sa=screen->areabase.first; sa; sa=sa->next) {
|
||||
if (sa->full) break;
|
||||
}
|
||||
if (!sa) {
|
||||
BKE_report(op->reports, RPT_ERROR, "No fullscreen areas were found.");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
ED_screen_full_restore(C, sa);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static void SCREEN_OT_back_to_previous(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Back to Previous Screen";
|
||||
ot->description= "Revert back to the original screen layout, before fullscreen area overlay.";
|
||||
ot->idname= "SCREEN_OT_back_to_previous";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= fullscreen_back_exec;
|
||||
ot->poll= ED_operator_screenactive;
|
||||
}
|
||||
|
||||
/* *********** show user pref window ****** */
|
||||
|
||||
static int userpref_show_invoke(bContext *C, wmOperator *unused, wmEvent *event)
|
||||
@ -3672,6 +3706,7 @@ void ED_operatortypes_screen(void)
|
||||
WM_operatortype_append(SCREEN_OT_header_toolbox);
|
||||
WM_operatortype_append(SCREEN_OT_screen_set);
|
||||
WM_operatortype_append(SCREEN_OT_screen_full_area);
|
||||
WM_operatortype_append(SCREEN_OT_back_to_previous);
|
||||
WM_operatortype_append(SCREEN_OT_screenshot);
|
||||
WM_operatortype_append(SCREEN_OT_screencast);
|
||||
WM_operatortype_append(SCREEN_OT_userpref_show);
|
||||
|
@ -78,6 +78,12 @@ static int rna_Screen_animation_playing_get(PointerRNA *ptr)
|
||||
return (sc->animtimer != NULL);
|
||||
}
|
||||
|
||||
static int rna_Screen_fullscreen_get(PointerRNA *ptr)
|
||||
{
|
||||
bScreen *sc= (bScreen*)ptr->data;
|
||||
return (sc->full == SCREENFULL);
|
||||
}
|
||||
|
||||
static void rna_Area_type_set(PointerRNA *ptr, int value)
|
||||
{
|
||||
ScrArea *sa= (ScrArea*)ptr->data;
|
||||
@ -185,6 +191,11 @@ static void rna_def_screen(BlenderRNA *brna)
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_boolean_funcs(prop, "rna_Screen_animation_playing_get", NULL);
|
||||
RNA_def_property_ui_text(prop, "Animation Playing", "Animation playback is active.");
|
||||
|
||||
prop= RNA_def_property(srna, "fullscreen", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_boolean_funcs(prop, "rna_Screen_fullscreen_get", NULL);
|
||||
RNA_def_property_ui_text(prop, "Fullscreen", "An area is maximised, filling this screen.");
|
||||
}
|
||||
|
||||
void RNA_def_screen(BlenderRNA *brna)
|
||||
|
@ -1029,9 +1029,9 @@ static int wm_handler_fileselect_call(bContext *C, ListBase *handlers, wmEventHa
|
||||
char *path= RNA_string_get_alloc(handler->op->ptr, "path", NULL, 0);
|
||||
|
||||
if(screen != handler->filescreen)
|
||||
ED_screen_full_prevspace(C);
|
||||
ED_screen_full_prevspace(C, CTX_wm_area(C));
|
||||
else
|
||||
ED_area_prevspace(C);
|
||||
ED_area_prevspace(C, CTX_wm_area(C));
|
||||
|
||||
/* remlink now, for load file case */
|
||||
BLI_remlink(handlers, handler);
|
||||
|
Loading…
Reference in New Issue
Block a user