Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Sat, 29 Apr 2017 06:32:25 +0000 (16:32 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 29 Apr 2017 06:32:30 +0000 (16:32 +1000)
1  2 
source/blender/editors/interface/interface_handlers.c
source/blender/editors/render/render_opengl.c

index ccf1c7305a9377d183bc73fb4dc753344a9ad498,b50789ff89736bd3b7e0198ed2012b957310ce71..59e0961f0db039c163942fe1b5a4ade8e6f2b050
@@@ -186,6 -186,7 +186,6 @@@ typedef struct uiSelectContextStore 
        uiSelectContextElem *elems;
        int elems_len;
        bool do_free;
 -      bool is_enabled;
        /* When set, simply copy values (don't apply difference).
         * Rules are:
         * - dragging numbers uses delta.
@@@ -201,9 -202,7 +201,9 @@@ static void ui_selectcontext_apply
          bContext *C, uiBut *but, struct uiSelectContextStore *selctx_data,
          const double value, const double value_orig);
  
 +#if 0
  #define IS_ALLSELECT_EVENT(event) ((event)->alt != 0)
 +#endif
  
  /** just show a tinted color so users know its activated */
  #define UI_BUT_IS_SELECT_CONTEXT UI_BUT_NODE_ACTIVE
@@@ -1180,11 -1179,14 +1180,11 @@@ static void ui_multibut_states_apply(bC
                                ui_but_execute_begin(C, ar, but, &active_back);
  
  #ifdef USE_ALLSELECT
 -                              if (data->select_others.is_enabled) {
 -                                      /* init once! */
 -                                      if (mbut_state->select_others.elems_len == 0) {
 -                                              ui_selectcontext_begin(C, but, &mbut_state->select_others);
 -                                      }
 -                                      if (mbut_state->select_others.elems_len == 0) {
 -                                              mbut_state->select_others.elems_len = -1;
 -                                      }
 +                              if (mbut_state->select_others.elems_len == 0) {
 +                                      ui_selectcontext_begin(C, but, &mbut_state->select_others);
 +                              }
 +                              if (mbut_state->select_others.elems_len == 0) {
 +                                      mbut_state->select_others.elems_len = -1;
                                }
  
                                /* needed so we apply the right deltas */
@@@ -2072,7 -2074,12 +2072,7 @@@ static void ui_apply_but(bContext *C, u
                else
  #  endif
                if (data->select_others.elems_len == 0) {
 -                      wmWindow *win = CTX_wm_window(C);
 -                      /* may have been enabled before activating */
 -                      if (data->select_others.is_enabled || IS_ALLSELECT_EVENT(win->eventstate)) {
 -                              ui_selectcontext_begin(C, but, &data->select_others);
 -                              data->select_others.is_enabled = true;
 -                      }
 +                      ui_selectcontext_begin(C, but, &data->select_others);
                }
                if (data->select_others.elems_len == 0) {
                        /* dont check again */
                        break;
                case UI_BTYPE_ROW:
                case UI_BTYPE_LISTROW:
 +              case UI_BTYPE_TAB:
                        ui_apply_but_ROW(C, block, but, data);
                        break;
                case UI_BTYPE_SCROLL:
@@@ -3074,7 -3080,11 +3074,7 @@@ static void ui_textedit_begin(bContext 
  
  #ifdef USE_ALLSELECT
        if (is_num_but) {
 -              if (IS_ALLSELECT_EVENT(win->eventstate)) {
 -                      data->select_others.is_enabled = true;
 -                      data->select_others.is_copy = true;
 -
 -              }
 +              data->select_others.is_copy = true;
        }
  #endif
  
@@@ -3674,6 -3684,15 +3674,6 @@@ static void ui_block_open_begin(bContex
                        data->menu->popup = but->block->handle->popup;
        }
  
 -#ifdef USE_ALLSELECT
 -      {
 -              wmWindow *win = CTX_wm_window(C);
 -              if (IS_ALLSELECT_EVENT(win->eventstate)) {
 -                      data->select_others.is_enabled = true;
 -              }
 -      }
 -#endif
 -
        /* this makes adjacent blocks auto open from now on */
        //if (but->block->auto_open == 0) but->block->auto_open = 1;
  }
@@@ -3855,18 -3874,6 +3855,18 @@@ static int ui_do_but_KEYEVT
        return WM_UI_HANDLER_CONTINUE;
  }
  
 +static int ui_do_but_TAB(bContext *C, uiBut *but, uiHandleButtonData *data, const wmEvent *event)
 +{
 +      if (data->state == BUTTON_STATE_HIGHLIGHT) {
 +              if (ELEM(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val == KM_RELEASE) {
 +                      button_activate_state(C, but, BUTTON_STATE_EXIT);
 +                      return WM_UI_HANDLER_CONTINUE;
 +              }
 +      }
 +
 +      return WM_UI_HANDLER_CONTINUE;
 +}
 +
  static bool ui_but_is_mouse_over_icon_extra(const ARegion *region, uiBut *but, const int mouse_xy[2])
  {
        int x = mouse_xy[0], y = mouse_xy[1];
@@@ -5211,8 -5218,7 +5211,8 @@@ static int ui_do_but_COLOR
                                if (!event->ctrl) {
                                        float color[3];
                                        Scene *scene = CTX_data_scene(C);
 -                                      Paint *paint = BKE_paint_get_active(scene);
 +                                      SceneLayer *sl = CTX_data_scene_layer(C);
 +                                      Paint *paint = BKE_paint_get_active(scene, sl);
                                        Brush *brush = BKE_paint_brush(paint);
  
                                        if (brush->flag & BRUSH_USE_GRADIENT) {
@@@ -6120,7 -6126,6 +6120,7 @@@ static int ui_do_but_CURVE
        int mx, my, a;
        bool changed = false;
        Scene *scene = CTX_data_scene(C);
 +      SceneLayer *sl = CTX_data_scene_layer(C);
  
        mx = event->x;
        my = event->y;
                                }
                                else {
                                        curvemapping_changed(cumap, true);  /* remove doubles */
 -                                      BKE_paint_invalidate_cursor_overlay(scene, cumap);
 +                                      BKE_paint_invalidate_cursor_overlay(scene, sl, cumap);
                                }
                        }
  
@@@ -6752,6 -6757,7 +6752,7 @@@ static bool ui_but_menu(bContext *C, ui
  {
        uiPopupMenu *pup;
        uiLayout *layout;
+       MenuType *mt = WM_menutype_find("WM_MT_button_context", true);
        bool is_array, is_array_component;
        uiStringInfo label = {BUT_GET_LABEL, NULL};
  
                /*bool is_idprop = RNA_property_is_idprop(prop);*/ /* XXX does not work as expected, not strictly needed */
                bool is_set = RNA_property_is_set(ptr, prop);
  
+               /* set the prop and pointer data for python access to the hovered ui element; TODO, index could be supported as well*/
+               PointerRNA temp_ptr;
+               RNA_pointer_create(NULL, &RNA_Property, but->rnaprop, &temp_ptr);
+               uiLayoutSetContextPointer(layout,"button_prop", &temp_ptr);
+               uiLayoutSetContextPointer(layout,"button_pointer", ptr);
                /* second slower test, saved people finding keyframe items in menus when its not possible */
                if (is_anim)
                        is_anim = RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop);
                                                0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
                        UI_but_func_set(but2, popup_add_shortcut_func, but, NULL);
                }
-               
+               /* Set the operator pointer for python access */
+               uiLayoutSetContextPointer(layout,"button_operator", but->opptr);
                uiItemS(layout);
        }
  
        }
        uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0);
  
+       mt = WM_menutype_find("WM_MT_button_context", false);
+       if (mt) {
+               Menu menu = {NULL};
+               menu.layout = uiLayoutColumn(layout, false);
+               menu.type = mt;
+               mt->draw(C, &menu);
+       }
        UI_popup_menu_end(C, pup);
  
        return true;
@@@ -7109,9 -7132,6 +7127,9 @@@ static int ui_do_button(bContext *C, ui
                case UI_BTYPE_HOTKEY_EVENT:
                        retval = ui_do_but_HOTKEYEVT(C, but, data, event);
                        break;
 +              case UI_BTYPE_TAB:
 +                      retval = ui_do_but_TAB(C, but, data, event);
 +                      break;
                case UI_BTYPE_BUT_TOGGLE:
                case UI_BTYPE_TOGGLE:
                case UI_BTYPE_ICON_TOGGLE:
index 8ac223b13898798227ea9a5bd8413e087df8b597,c7ee57240cfab0a8c131f5364f23e689827c4274..a8f3d1739bdb46e3482b97f7a849905d0eae26e0
@@@ -38,7 -38,6 +38,6 @@@
  #include "BLI_math_color_blend.h"
  #include "BLI_blenlib.h"
  #include "BLI_utildefines.h"
- #include "BLI_jitter.h"
  #include "BLI_threads.h"
  #include "BLI_task.h"
  
@@@ -71,9 -70,9 +70,9 @@@
  #include "RNA_access.h"
  #include "RNA_define.h"
  
 -#include "GPU_glew.h"
  #include "GPU_compositing.h"
  #include "GPU_framebuffer.h"
 +#include "GPU_matrix.h"
  
  #include "render_intern.h"
  
@@@ -92,7 -91,6 +91,7 @@@ typedef struct OGLRender 
        Main *bmain;
        Render *re;
        Scene *scene;
 +      SceneLayer *scene_layer;
  
        View3D *v3d;
        RegionView3D *rv3d;
  #endif
  } OGLRender;
  
 -/* added because v3d is not always valid */
 -static unsigned int screen_opengl_layers(OGLRender *oglrender)
 -{
 -      if (oglrender->v3d) {
 -              return oglrender->scene->lay | oglrender->v3d->lay;
 -      }
 -      else {
 -              return oglrender->scene->lay;
 -      }
 -}
 -
  static bool screen_opengl_is_multiview(OGLRender *oglrender)
  {
        View3D *v3d = oglrender->v3d;
@@@ -265,7 -274,6 +264,7 @@@ static void screen_opengl_views_setup(O
  static void screen_opengl_render_doit(OGLRender *oglrender, RenderResult *rr)
  {
        Scene *scene = oglrender->scene;
 +      SceneLayer *sl = oglrender->scene_layer;
        ARegion *ar = oglrender->ar;
        View3D *v3d = oglrender->v3d;
        RegionView3D *rv3d = oglrender->rv3d;
                        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
                        wmOrtho2(0, sizex, 0, sizey);
 -                      glTranslatef(sizex / 2, sizey / 2, 0.0f);
 +                      gpuTranslate2f(sizex / 2, sizey / 2);
  
                        G.f |= G_RENDER_OGL;
                        ED_gpencil_draw_ex(scene, gpd, sizex, sizey, scene->r.cfra, SPACE_SEQ);
  
                if (view_context) {
                        ibuf_view = ED_view3d_draw_offscreen_imbuf(
 -                             scene, v3d, ar, sizex, sizey,
 +                             scene, sl, v3d, ar, sizex, sizey,
                               IB_rect, draw_bgpic,
                               alpha_mode, oglrender->ofs_samples, oglrender->ofs_full_samples, viewname,
                               oglrender->fx, oglrender->ofs, err_out);
                }
                else {
                        ibuf_view = ED_view3d_draw_offscreen_imbuf_simple(
 -                              scene, scene->camera, oglrender->sizex, oglrender->sizey,
 +                              scene, sl, scene->camera, oglrender->sizex, oglrender->sizey,
                                IB_rect, OB_SOLID, false, true, true,
                                alpha_mode, oglrender->ofs_samples, oglrender->ofs_full_samples, viewname,
                                oglrender->fx, oglrender->ofs, err_out);
@@@ -639,7 -647,6 +638,7 @@@ static bool screen_opengl_render_init(b
        oglrender->sizey = sizey;
        oglrender->bmain = CTX_data_main(C);
        oglrender->scene = scene;
 +      oglrender->scene_layer = CTX_data_scene_layer(C);
        oglrender->cfrao = scene->r.cfra;
  
        oglrender->write_still = is_write_still && !is_animation;
@@@ -783,7 -790,7 +782,7 @@@ static void screen_opengl_render_end(bC
  
        if (oglrender->timer) { /* exec will not have a timer */
                scene->r.cfra = oglrender->cfrao;
 -              BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, screen_opengl_layers(oglrender));
 +              BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene);
  
                WM_event_remove_timer(oglrender->wm, oglrender->win, oglrender->timer);
        }
@@@ -993,7 -1000,12 +992,7 @@@ static bool screen_opengl_render_anim_s
        if (CFRA < oglrender->nfra)
                CFRA++;
        while (CFRA < oglrender->nfra) {
 -              unsigned int lay = screen_opengl_layers(oglrender);
 -
 -              if (lay & 0xFF000000)
 -                      lay &= 0xFF000000;
 -
 -              BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, lay);
 +              BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene);
                CFRA++;
        }
  
  
        WM_cursor_time(oglrender->win, scene->r.cfra);
  
 -      BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene, screen_opengl_layers(oglrender));
 +      BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, scene);
  
        if (view_context) {
                if (oglrender->rv3d->persp == RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) {