Keymap: Special keymap for clip editor scrubbing area
authorJacques Lucke <mail@jlucke.com>
Wed, 8 May 2019 12:10:09 +0000 (14:10 +0200)
committerJacques Lucke <mail@jlucke.com>
Wed, 8 May 2019 12:10:09 +0000 (14:10 +0200)
Reviewers: sergey

Differential Revision: https://developer.blender.org/D4825

release/scripts/presets/keyconfig/keymap_data/blender_default.py
source/blender/editors/animation/anim_scrubbing.c
source/blender/editors/include/ED_scrubbing.h
source/blender/editors/screen/area.c
source/blender/editors/space_clip/space_clip.c

index 793f1c7..a708be1 100644 (file)
@@ -1322,6 +1322,20 @@ def km_scrubbing(params):
 
     return keymap
 
+def km_scrubbing_clip(params):
+    items = []
+    keymap = (
+        "Clip Scrubbing",
+        {"space_type": 'CLIP_EDITOR', "region_type": 'PREVIEW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("clip.change_frame", {"type": "LEFTMOUSE", "value": 'PRESS'}, None),
+    ])
+
+    return keymap
+
 
 def km_graph_editor_generic(_params):
     items = []
@@ -6165,6 +6179,7 @@ def generate_keymaps(params=None):
         km_mask_editing(params),
         km_markers(params),
         km_scrubbing(params),
+        km_scrubbing_clip(params),
         km_graph_editor_generic(params),
         km_graph_editor(params),
         km_image_generic(params),
index a22d1b4..507d48c 100644 (file)
@@ -155,6 +155,13 @@ void ED_scrubbing_draw(const ARegion *ar,
   GPU_matrix_pop_projection();
 }
 
+bool ED_event_in_scrubbing_region(const ARegion *ar, const wmEvent *event)
+{
+  rcti rect = ar->winrct;
+  rect.ymin = rect.ymax - UI_SCRUBBING_MARGIN_Y;
+  return BLI_rcti_isect_pt(&rect, event->x, event->y);
+}
+
 void ED_channel_search_draw(const bContext *C, ARegion *ar, bDopeSheet *dopesheet)
 {
   GPU_matrix_push_projection();
index cc22572..26d9f3d 100644 (file)
 struct bContext;
 struct View2DGrid;
 struct bDopeSheet;
+struct wmEvent;
 
 void ED_scrubbing_draw(const struct ARegion *ar,
                        const struct Scene *scene,
                        bool display_seconds,
                        bool discrete_frames);
 
+bool ED_event_in_scrubbing_region(const struct ARegion *ar, const struct wmEvent *event);
+
 void ED_channel_search_draw(const struct bContext *C,
                             struct ARegion *ar,
                             struct bDopeSheet *dopesheet);
index 6fe2b5e..fe70957 100644 (file)
@@ -50,6 +50,7 @@
 #include "ED_screen.h"
 #include "ED_screen_types.h"
 #include "ED_space_api.h"
+#include "ED_scrubbing.h"
 
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
@@ -1566,13 +1567,6 @@ static bool event_in_markers_region(const ARegion *ar, const wmEvent *event)
   return BLI_rcti_isect_pt(&rect, event->x, event->y);
 }
 
-static bool event_in_scrubbing_region(const ARegion *ar, const wmEvent *event)
-{
-  rcti rect = ar->winrct;
-  rect.ymin = rect.ymax - UI_SCRUBBING_MARGIN_Y;
-  return BLI_rcti_isect_pt(&rect, event->x, event->y);
-}
-
 /**
  * \param ar: Region, may be NULL when adding handlers for \a sa.
  */
@@ -1620,7 +1614,7 @@ static void ed_default_handlers(
 
     /* time-scrubbing */
     keymap = WM_keymap_ensure(wm->defaultconf, "Scrubbing", 0, 0);
-    WM_event_add_keymap_handler_poll(handlers, keymap, event_in_scrubbing_region);
+    WM_event_add_keymap_handler_poll(handlers, keymap, ED_event_in_scrubbing_region);
 
     /* frame changing and timeline operators (for time spaces) */
     keymap = WM_keymap_ensure(wm->defaultconf, "Animation", 0, 0);
index 3397c52..6ebecbf 100644 (file)
@@ -1002,9 +1002,13 @@ static void clip_preview_region_init(wmWindowManager *wm, ARegion *ar)
   UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
 
   /* own keymap */
+
   keymap = WM_keymap_ensure(wm->defaultconf, "Clip", SPACE_CLIP, 0);
   WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);
 
+  keymap = WM_keymap_ensure(wm->defaultconf, "Clip Scrubbing", SPACE_CLIP, RGN_TYPE_PREVIEW);
+  WM_event_add_keymap_handler_poll(&ar->handlers, keymap, ED_event_in_scrubbing_region);
+
   keymap = WM_keymap_ensure(wm->defaultconf, "Clip Graph Editor", SPACE_CLIP, 0);
   WM_event_add_keymap_handler_v2d_mask(&ar->handlers, keymap);