Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Mon, 17 Jul 2017 03:21:05 +0000 (13:21 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 17 Jul 2017 03:21:05 +0000 (13:21 +1000)
1  2 
doc/python_api/sphinx_doc_gen.py
source/blender/editors/screen/screen_ops.c
source/blender/python/intern/bpy_interface.c

index b3aebcf618828cd3f1d1bda2773ec7c69596bb55,098e2736ed1bc51b8ef9274e6ede83da130122ae..af1c2be434a615033d1fa2786ab6b97ac32af188
@@@ -332,9 -332,6 +332,9 @@@ except ImportError
  # to avoid having to match Blender's source tree.
  EXTRA_SOURCE_FILES = (
      "../../../release/scripts/templates_py/bmesh_simple.py",
 +    "../../../release/scripts/templates_py/manipulator_operator.py",
 +    "../../../release/scripts/templates_py/manipulator_operator_target.py",
 +    "../../../release/scripts/templates_py/manipulator_simple.py",
      "../../../release/scripts/templates_py/operator_simple.py",
      "../../../release/scripts/templates_py/ui_panel_simple.py",
      "../../../release/scripts/templates_py/ui_previews_custom_icon.py",
@@@ -1027,7 -1024,6 +1027,7 @@@ context_type_map = 
      "brush": ("Brush", False),
      "camera": ("Camera", False),
      "cloth": ("ClothModifier", False),
 +    "collection": ("LayerCollection", False),
      "collision": ("CollisionModifier", False),
      "curve": ("Curve", False),
      "dynamic_paint": ("DynamicPaintModifier", False),
      "image_paint_object": ("Object", False),
      "lamp": ("Lamp", False),
      "lattice": ("Lattice", False),
 +    "lightprobe": ("LightProbe", False),
      "line_style": ("FreestyleLineStyle", False),
      "material": ("Material", False),
      "material_slot": ("MaterialSlot", False),
      "particle_system": ("ParticleSystem", False),
      "particle_system_editable": ("ParticleSystem", False),
      "pose_bone": ("PoseBone", False),
 +    "render_layer": ("SceneLayer", False),
      "scene": ("Scene", False),
      "sculpt_object": ("Object", False),
      "selectable_bases": ("ObjectBase", True),
@@@ -1645,6 -1639,11 +1645,11 @@@ def write_sphinx_conf_py(basepath)
      fw("version = '%s - API'\n" % BLENDER_VERSION_DOTS)
      fw("release = '%s - API'\n" % BLENDER_VERSION_DOTS)
  
+     # Quiet file not in table-of-contents warnings.
+     fw("exclude_patterns = [\n")
+     fw("    'include__bmesh.rst',\n")
+     fw("]\n\n")
      if ARGS.sphinx_theme != 'default':
          fw("html_theme = '%s'\n" % ARGS.sphinx_theme)
  
      fw("}\n\n")
  
      fw("latex_documents = [ ('contents', 'contents.tex', 'Blender Index', 'Blender Foundation', 'manual'), ]\n")
+     # Workaround for useless links leading to compile errors
+     # See https://github.com/sphinx-doc/sphinx/issues/3866
+     fw(r"""
+ from sphinx.domains.python import PythonDomain
+ class PatchedPythonDomain(PythonDomain):
+     def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
+         if 'refspecific' in node:
+             del node['refspecific']
+         return super(PatchedPythonDomain, self).resolve_xref(
+             env, fromdocname, builder, typ, target, node, contnode)
+ def setup(sphinx):
+     sphinx.override_domain(PatchedPythonDomain)
+ """)
+     # end workaround
      file.close()
  
  
index b8fa16117a992a38d6111c95bcb9bfd9ee6857e4,27e19ca1fc330310837b6d6ab94d127d5a4f24ac..326421cf166fc45e9051109dd1b6a9f0111c93ca
  #include "DNA_meta_types.h"
  #include "DNA_mask_types.h"
  #include "DNA_node_types.h"
 +#include "DNA_workspace_types.h"
  #include "DNA_userdef_types.h"
  
  #include "BKE_context.h"
  #include "BKE_customdata.h"
  #include "BKE_global.h"
 +#include "BKE_icons.h"
  #include "BKE_main.h"
  #include "BKE_object.h"
  #include "BKE_report.h"
@@@ -63,7 -61,6 +63,7 @@@
  #include "BKE_editmesh.h"
  #include "BKE_sound.h"
  #include "BKE_mask.h"
 +#include "BKE_workspace.h"
  
  #include "WM_api.h"
  #include "WM_types.h"
@@@ -574,8 -571,8 +574,8 @@@ int ED_operator_mask(bContext *C
                        case SPACE_IMAGE:
                        {
                                SpaceImage *sima = sa->spacedata.first;
 -                              Scene *scene = CTX_data_scene(C);
 -                              return ED_space_image_check_show_maskedit(scene, sima);
 +                              SceneLayer *sl = CTX_data_scene_layer(C);
 +                              return ED_space_image_check_show_maskedit(sl, sima);
                        }
                }
        }
@@@ -980,17 -977,13 +980,17 @@@ static void SCREEN_OT_area_swap(wmOpera
  /* operator callback */
  static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event)
  {
 -      wmWindow *newwin, *win;
 -      bScreen *newsc, *sc;
 +      wmWindow *newwin, *win = CTX_wm_window(C);
 +      Scene *scene;
 +      WorkSpace *workspace = WM_window_get_active_workspace(win);
 +      WorkSpaceLayout *layout_old = WM_window_get_active_layout(win);
 +      WorkSpaceLayout *layout_new;
 +      bScreen *newsc;
        ScrArea *sa;
        rcti rect;
        
        win = CTX_wm_window(C);
 -      sc = CTX_wm_screen(C);
 +      scene = CTX_data_scene(C);
        sa = CTX_wm_area(C);
        
        /* XXX hrmf! */
        }
  
        *newwin->stereo3d_format = *win->stereo3d_format;
 -      
 +
 +      newwin->scene = scene;
 +
 +      WM_window_set_active_workspace(newwin, workspace);
        /* allocs new screen and adds to newly created window, using window size */
 -      newsc = ED_screen_add(newwin, CTX_data_scene(C), sc->id.name + 2);
 -      newwin->screen = newsc;
 -      
 +      layout_new = ED_workspace_layout_add(workspace, newwin, BKE_workspace_layout_name_get(layout_old));
 +      newsc = BKE_workspace_layout_screen_get(layout_new);
 +      WM_window_set_active_layout(newwin, workspace, layout_new);
 +
        /* copy area to new screen */
        ED_area_data_copy((ScrArea *)newsc->areabase.first, sa, true);
  
@@@ -1231,8 -1220,6 +1231,8 @@@ static void area_move_apply_do(bContex
                }
  
                WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* redraw everything */
 +              /* Update preview thumbnail */
 +              BKE_icon_changed(sc->id.icon_id);
        }
  }
  
@@@ -1521,9 -1508,7 +1521,9 @@@ static int area_split_apply(bContext *C
                ED_area_tag_redraw(sd->narea);
  
                WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
 -              
 +              /* Update preview thumbnail */
 +              BKE_icon_changed(sc->id.icon_id);
 +
                return 1;
        }
        
@@@ -1724,7 -1709,7 +1724,7 @@@ static int area_split_modal(bContext *C
                                        }
                                }
                                
 -                              CTX_wm_window(C)->screen->do_draw = true;
 +                              CTX_wm_screen(C)->do_draw = true;
  
                        }
                        
@@@ -2094,11 -2079,12 +2094,11 @@@ static void areas_do_frame_follow(bCont
        bScreen *scr = CTX_wm_screen(C);
        Scene *scene = CTX_data_scene(C);
        wmWindowManager *wm = CTX_wm_manager(C);
 -      wmWindow *window;
 -      for (window = wm->windows.first; window; window = window->next) {
 -              ScrArea *sa;
 -              for (sa = window->screen->areabase.first; sa; sa = sa->next) {
 -                      ARegion *ar;
 -                      for (ar = sa->regionbase.first; ar; ar = ar->next) {
 +      for (wmWindow *window = wm->windows.first; window; window = window->next) {
 +              const bScreen *screen = WM_window_get_active_screen(window);
 +
 +              for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
 +                      for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) {
                                /* do follow here if editor type supports it */
                                if ((scr->redraws_flag & TIME_FOLLOW)) {
                                        if ((ar->regiontype == RGN_TYPE_WINDOW &&
@@@ -2274,25 -2260,28 +2274,28 @@@ static int keyframe_jump_exec(bContext 
        BLI_dlrbTree_linkedlist_sync(&keys);
        
        /* find matching keyframe in the right direction */
-       do {
-               if (next)
-                       ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
-               else
-                       ak = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra);
-               
-               if (ak) {
-                       if (CFRA != (int)ak->cfra) {
-                               /* this changes the frame, so set the frame and we're done */
-                               CFRA = (int)ak->cfra;
-                               done = true;
+       if (next)
+               ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra);
+       else
+               ak = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra);
+       
+       while ((ak != NULL) && (done == false)) {
+               if (CFRA != (int)ak->cfra) {
+                       /* this changes the frame, so set the frame and we're done */
+                       CFRA = (int)ak->cfra;
+                       done = true;
+               }
+               else {
+                       /* take another step... */
+                       if (next) {
+                               ak = ak->next;
                        }
                        else {
-                               /* make this the new starting point for the search */
-                               cfra = ak->cfra;
+                               ak = ak->prev;
                        }
                }
-       } while ((ak != NULL) && (done == false));
+       }
+       
        /* free temp stuff */
        BLI_dlrbTree_free(&keys);
  
@@@ -2394,16 -2383,64 +2397,16 @@@ static void SCREEN_OT_marker_jump(wmOpe
  
  /* ************** switch screen operator ***************************** */
  
 -static bool screen_set_is_ok(bScreen *screen, bScreen *screen_prev)
 -{
 -      return ((screen->winid == 0) &&
 -              /* in typical usage these should have a nonzero winid
 -               * (all temp screens should be used, or closed & freed). */
 -              (screen->temp == false) &&
 -              (screen->state == SCREENNORMAL) &&
 -              (screen != screen_prev) &&
 -              (screen->id.name[2] != '.' || !(U.uiflag & USER_HIDE_DOT)));
 -}
 -
  /* function to be called outside UI context, or for redo */
  static int screen_set_exec(bContext *C, wmOperator *op)
  {
 -      Main *bmain = CTX_data_main(C);
 -      bScreen *screen = CTX_wm_screen(C);
 -      bScreen *screen_prev = screen;
 -      
 -      ScrArea *sa = CTX_wm_area(C);
 -      int tot = BLI_listbase_count(&bmain->screen);
 +      WorkSpace *workspace = CTX_wm_workspace(C);
        int delta = RNA_int_get(op->ptr, "delta");
 -      
 -      /* temp screens are for userpref or render display */
 -      if (screen->temp || (sa && sa->full && sa->full->temp)) {
 -              return OPERATOR_CANCELLED;
 -      }
 -      
 -      if (delta == 1) {
 -              while (tot--) {
 -                      screen = screen->id.next;
 -                      if (screen == NULL) screen = bmain->screen.first;
 -                      if (screen_set_is_ok(screen, screen_prev)) {
 -                              break;
 -                      }
 -              }
 -      }
 -      else if (delta == -1) {
 -              while (tot--) {
 -                      screen = screen->id.prev;
 -                      if (screen == NULL) screen = bmain->screen.last;
 -                      if (screen_set_is_ok(screen, screen_prev)) {
 -                              break;
 -                      }
 -              }
 -      }
 -      else {
 -              screen = NULL;
 -      }
 -      
 -      if (screen && screen_prev != screen) {
 -              /* return to previous state before switching screens */
 -              if (sa && sa->full) {
 -                      ED_screen_full_restore(C, sa); /* may free 'screen_prev' */
 -              }
 -              
 -              ED_screen_set(C, screen);
 +
 +      if (ED_workspace_layout_cycle(workspace, delta, C)) {
                return OPERATOR_FINISHED;
        }
 +
        return OPERATOR_CANCELLED;
  }
  
@@@ -3258,7 -3295,7 +3261,7 @@@ static int header_toggle_menus_exec(bCo
        sa->flag = sa->flag ^ HEADER_NO_PULLDOWN;
  
        ED_area_tag_redraw(sa);
 -      WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);  
 +      WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL);
  
        return OPERATOR_FINISHED;
  }
@@@ -3555,9 -3592,7 +3558,9 @@@ static int screen_animation_step(bConte
                ED_update_for_newframe(bmain, scene, 1);
  
                for (window = wm->windows.first; window; window = window->next) {
 -                      for (sa = window->screen->areabase.first; sa; sa = sa->next) {
 +                      const bScreen *win_screen = WM_window_get_active_screen(window);
 +
 +                      for (sa = win_screen->areabase.first; sa; sa = sa->next) {
                                ARegion *ar;
                                for (ar = sa->regionbase.first; ar; ar = ar->next) {
                                        bool redraw = false;
@@@ -3631,11 -3666,11 +3634,11 @@@ static void SCREEN_OT_animation_step(wm
  /* find window that owns the animation timer */
  bScreen *ED_screen_animation_playing(const wmWindowManager *wm)
  {
 -      wmWindow *win;
 +      for (wmWindow *win = wm->windows.first; win; win = win->next) {
 +              bScreen *screen = WM_window_get_active_screen(win);
  
 -      for (win = wm->windows.first; win; win = win->next) {
 -              if (win->screen->animtimer || win->screen->scrubbing) {
 -                      return win->screen;
 +              if (screen->animtimer || screen->scrubbing) {
 +                      return screen;
                }
        }
  
  
  bScreen *ED_screen_animation_no_scrub(const wmWindowManager *wm)
  {
 -      wmWindow *win;
 +      for (wmWindow *win = wm->windows.first; win; win = win->next) {
 +              bScreen *screen = WM_window_get_active_screen(win);
  
 -      for (win = wm->windows.first; win; win = win->next) {
 -              if (win->screen->animtimer) {
 -                      return win->screen;
 +              if (screen->animtimer) {
 +                      return screen;
                }
        }
  
@@@ -3882,13 -3917,11 +3885,13 @@@ static void SCREEN_OT_userpref_show(str
  static int screen_new_exec(bContext *C, wmOperator *UNUSED(op))
  {
        wmWindow *win = CTX_wm_window(C);
 -      bScreen *sc = CTX_wm_screen(C);
 -      
 -      sc = ED_screen_duplicate(win, sc);
 -      WM_event_add_notifier(C, NC_SCREEN | ND_SCREENBROWSE, sc);
 -      
 +      WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
 +      WorkSpaceLayout *layout_old = BKE_workspace_active_layout_get(win->workspace_hook);
 +      WorkSpaceLayout *layout_new;
 +
 +      layout_new = ED_workspace_layout_duplicate(workspace, layout_old, win);
 +      WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTBROWSE, layout_new);
 +
        return OPERATOR_FINISHED;
  }
  
@@@ -3909,11 -3942,9 +3912,11 @@@ static void SCREEN_OT_new(wmOperatorTyp
  static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op))
  {
        bScreen *sc = CTX_wm_screen(C);
 -      
 -      WM_event_add_notifier(C, NC_SCREEN | ND_SCREENDELETE, sc);
 -      
 +      WorkSpace *workspace = CTX_wm_workspace(C);
 +      WorkSpaceLayout *layout = BKE_workspace_layout_find(workspace, sc);
 +
 +      WM_event_add_notifier(C, NC_SCREEN | ND_LAYOUTDELETE, layout);
 +
        return OPERATOR_FINISHED;
  }
  
@@@ -3928,6 -3959,95 +3931,6 @@@ static void SCREEN_OT_delete(wmOperator
        ot->exec = screen_delete_exec;
  }
  
 -/********************* new scene operator *********************/
 -
 -static int scene_new_exec(bContext *C, wmOperator *op)
 -{
 -      Scene *newscene, *scene = CTX_data_scene(C);
 -      Main *bmain = CTX_data_main(C);
 -      int type = RNA_enum_get(op->ptr, "type");
 -
 -      if (type == SCE_COPY_NEW) {
 -              newscene = BKE_scene_add(bmain, DATA_("Scene"));
 -      }
 -      else { /* different kinds of copying */
 -              newscene = BKE_scene_copy(bmain, scene, type);
 -
 -              /* these can't be handled in blenkernel currently, so do them here */
 -              if (type == SCE_COPY_LINK_DATA) {
 -                      ED_object_single_users(bmain, newscene, false, true);
 -              }
 -              else if (type == SCE_COPY_FULL) {
 -                      ED_editors_flush_edits(C, false);
 -                      ED_object_single_users(bmain, newscene, true, true);
 -              }
 -      }
 -      
 -      ED_screen_set_scene(C, CTX_wm_screen(C), newscene);
 -      
 -      WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, newscene);
 -      
 -      return OPERATOR_FINISHED;
 -}
 -
 -static void SCENE_OT_new(wmOperatorType *ot)
 -{
 -      static EnumPropertyItem type_items[] = {
 -              {SCE_COPY_NEW, "NEW", 0, "New", "Add new scene"},
 -              {SCE_COPY_EMPTY, "EMPTY", 0, "Copy Settings", "Make a copy without any objects"},
 -              {SCE_COPY_LINK_OB, "LINK_OBJECTS", 0, "Link Objects", "Link to the objects from the current scene"},
 -              {SCE_COPY_LINK_DATA, "LINK_OBJECT_DATA", 0, "Link Object Data", "Copy objects linked to data from the current scene"},
 -              {SCE_COPY_FULL, "FULL_COPY", 0, "Full Copy", "Make a full copy of the current scene"},
 -              {0, NULL, 0, NULL, NULL}};
 -      
 -      /* identifiers */
 -      ot->name = "New Scene";
 -      ot->description = "Add new scene by type";
 -      ot->idname = "SCENE_OT_new";
 -      
 -      /* api callbacks */
 -      ot->exec = scene_new_exec;
 -      ot->invoke = WM_menu_invoke;
 -      
 -      /* flags */
 -      ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 -      
 -      /* properties */
 -      ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "");
 -}
 -
 -/********************* delete scene operator *********************/
 -
 -static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op))
 -{
 -      Scene *scene = CTX_data_scene(C);
 -
 -      if (ED_screen_delete_scene(C, scene) == false) {
 -              return OPERATOR_CANCELLED;
 -      }
 -
 -      if (G.debug & G_DEBUG)
 -              printf("scene delete %p\n", scene);
 -
 -      WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, scene);
 -
 -      return OPERATOR_FINISHED;
 -}
 -
 -static void SCENE_OT_delete(wmOperatorType *ot)
 -{
 -      /* identifiers */
 -      ot->name = "Delete Scene";
 -      ot->description = "Delete active scene";
 -      ot->idname = "SCENE_OT_delete";
 -      
 -      /* api callbacks */
 -      ot->exec = scene_delete_exec;
 -      
 -      /* flags */
 -      ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 -}
 -
  /* ***************** region alpha blending ***************** */
  
  /* implementation note: a disappearing region needs at least 1 last draw with 100% backbuffer
@@@ -4199,11 -4319,13 +4202,11 @@@ void ED_operatortypes_screen(void
        WM_operatortype_append(SCREEN_OT_animation_step);
        WM_operatortype_append(SCREEN_OT_animation_play);
        WM_operatortype_append(SCREEN_OT_animation_cancel);
 -      
 +
        /* new/delete */
        WM_operatortype_append(SCREEN_OT_new);
        WM_operatortype_append(SCREEN_OT_delete);
 -      WM_operatortype_append(SCENE_OT_new);
 -      WM_operatortype_append(SCENE_OT_delete);
 -      
 +
        /* tools shared by more space types */
        WM_operatortype_append(ED_OT_undo);
        WM_operatortype_append(ED_OT_undo_push);
index cd4d2f7a1c2dfd5bda80aba972bf77182c2b0f00,20cfd364a0cf1014063acfbb95aa45d11398c154..c6337f2ac28b1685a142a6da84e6b493785e9793
@@@ -530,8 -530,7 +530,8 @@@ static bool python_script_exec
  
        if (py_dict) {
  #ifdef PYMODULE_CLEAR_WORKAROUND
 -              PyModuleObject *mmod = (PyModuleObject *)PyDict_GetItemString(PyThreadState_GET()->interp->modules, "__main__");
 +              PyModuleObject *mmod = (PyModuleObject *)PyDict_GetItem(
 +                      PyThreadState_GET()->interp->modules, bpy_intern_str___main__);
                PyObject *dict_back = mmod->md_dict;
                /* freeing the module will clear the namespace,
                 * gives problems running classes defined in this namespace being used later. */
@@@ -870,6 -869,7 +870,7 @@@ static void bpy_module_delay_init(PyObj
  
        BLI_strncpy(filename_abs, filename_rel, sizeof(filename_abs));
        BLI_path_cwd(filename_abs, sizeof(filename_abs));
+       Py_DECREF(filename_obj);
  
        argv[0] = filename_abs;
        argv[1] = NULL;