Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-04-29 16:32:26 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-04-29 16:32:26 +0400
commitc27c87dde4f627565df7cb000b7eba45c2604ce4 (patch)
treeb08cecd61310a99d013e4bbbcabb70f92685b648 /source/blender/editors/space_clip
parent16d4c49c464ba4c56d96120003456e92688432f1 (diff)
Camera tracking: backport refactoring made in local branches with masking and dopesheet view into trunk
Mostly related on changes in poll functions for tracking operators and some changes to how interface is initializing for different view types.
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r--source/blender/editors/space_clip/clip_buttons.c8
-rw-r--r--source/blender/editors/space_clip/clip_editor.c57
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c58
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c8
-rw-r--r--source/blender/editors/space_clip/clip_intern.h5
-rw-r--r--source/blender/editors/space_clip/clip_toolbar.c8
-rw-r--r--source/blender/editors/space_clip/clip_utils.c60
-rw-r--r--source/blender/editors/space_clip/space_clip.c207
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c99
9 files changed, 336 insertions, 174 deletions
diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c
index eabd64bdc4f..6bf7c4e3dc8 100644
--- a/source/blender/editors/space_clip/clip_buttons.c
+++ b/source/blender/editors/space_clip/clip_buttons.c
@@ -63,6 +63,13 @@
/* Panels */
+static int clip_grease_pencil_panel_poll(const bContext *C, PanelType *UNUSED(pt))
+{
+ SpaceClip *sc = CTX_wm_space_clip(C);
+
+ return TRUE;
+}
+
void ED_clip_buttons_register(ARegionType *art)
{
PanelType *pt;
@@ -72,6 +79,7 @@ void ED_clip_buttons_register(ARegionType *art)
strcpy(pt->label, "Grease Pencil");
pt->draw = gpencil_panel_standard;
pt->flag |= PNL_DEFAULT_CLOSED;
+ pt->poll = clip_grease_pencil_panel_poll;
BLI_addtail(&art->paneltypes, pt);
}
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 3946d4cc36d..885357a100d 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -35,6 +35,7 @@
#include "BKE_movieclip.h"
#include "BKE_context.h"
#include "BKE_tracking.h"
+
#include "DNA_object_types.h" /* SELECT */
#include "BLI_utildefines.h"
@@ -55,6 +56,8 @@
#include "clip_intern.h" // own include
+/* ******** operactor poll functions ******** */
+
int ED_space_clip_poll(bContext *C)
{
SpaceClip *sc = CTX_wm_space_clip(C);
@@ -65,6 +68,51 @@ int ED_space_clip_poll(bContext *C)
return FALSE;
}
+int ED_space_clip_tracking_poll(bContext *C)
+{
+ SpaceClip *sc= CTX_wm_space_clip(C);
+
+ if (sc && sc->clip)
+ return ED_space_clip_show_trackedit(sc);
+
+ return FALSE;
+}
+
+int ED_space_clip_tracking_size_poll(bContext *C)
+{
+ if (ED_space_clip_tracking_poll(C)) {
+ MovieClip *clip = CTX_data_edit_movieclip(C);
+
+ if (clip) {
+ SpaceClip *sc = CTX_wm_space_clip(C);
+ int width, height;
+
+ BKE_movieclip_get_size(clip, &sc->user, &width, &height);
+
+ return width > 0 && height > 0;
+ }
+ }
+
+ return FALSE;
+}
+
+int ED_space_clip_tracking_frame_poll(bContext *C)
+{
+ if (ED_space_clip_tracking_poll(C)) {
+ MovieClip *clip = CTX_data_edit_movieclip(C);
+
+ if (clip) {
+ SpaceClip *sc = CTX_wm_space_clip(C);
+
+ return BKE_movieclip_has_frame(clip, &sc->user);
+ }
+ }
+
+ return FALSE;
+}
+
+/* ******** editing functions ******** */
+
void ED_space_clip_set(bContext *C, SpaceClip *sc, MovieClip *clip)
{
sc->clip = clip;
@@ -314,3 +362,12 @@ void ED_clip_mouse_pos(bContext *C, wmEvent *event, float co[2])
{
ED_clip_point_stable_pos(C, event->mval[0], event->mval[1], &co[0], &co[1]);
}
+
+int ED_space_clip_show_trackedit(SpaceClip *sc)
+{
+ if (sc) {
+ return ELEM3(sc->mode, SC_MODE_TRACKING, SC_MODE_RECONSTRUCTION, SC_MODE_DISTORTION);
+ }
+
+ return FALSE;
+}
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index df14491c9c9..4825403fb4a 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -87,60 +87,6 @@ static void draw_curve_knot(float x, float y, float xscale, float yscale, float
glPopMatrix();
}
-static void draw_graph_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
-{
- View2D *v2d = &ar->v2d;
- float xscale, yscale;
- float vec[2];
-
- /* Draw a light green line to indicate current frame */
- vec[0] = (float)(sc->user.framenr * scene->r.framelen);
-
- UI_ThemeColor(TH_CFRAME);
- glLineWidth(2.0);
-
- glBegin(GL_LINE_STRIP);
- vec[1] = v2d->cur.ymin;
- glVertex2fv(vec);
-
- vec[1] = v2d->cur.ymax;
- glVertex2fv(vec);
- glEnd();
-
- glLineWidth(1.0);
-
- UI_view2d_view_orthoSpecial(ar, v2d, 1);
-
- /* because the frame number text is subject to the same scaling as the contents of the view */
- UI_view2d_getscale(v2d, &xscale, &yscale);
- glScalef(1.0f/xscale, 1.0f, 1.0f);
-
- clip_draw_curfra_label(sc, (float)sc->user.framenr * xscale, 18);
-
- /* restore view transform */
- glScalef(xscale, 1.0, 1.0);
-}
-
-static void draw_graph_sfra_efra(Scene *scene, View2D *v2d)
-{
- UI_view2d_view_ortho(v2d);
-
- /* currently clip editor supposes that editing clip length is equal to scene frame range */
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
-
- glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
- glRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
- glDisable(GL_BLEND);
-
- UI_ThemeColorShade(TH_BACK, -60);
-
- /* thin lines where the actual frames are */
- fdrawline((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
- fdrawline((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax);
-}
-
static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack *UNUSED(track),
MovieTrackingMarker *marker, int UNUSED(coord), float val)
{
@@ -280,8 +226,8 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
}
/* frame range */
- draw_graph_sfra_efra(scene, v2d);
+ clip_draw_sfra_efra(v2d, scene);
/* current frame */
- draw_graph_cfra(sc, ar, scene);
+ clip_draw_cfra(sc, ar, scene);
}
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index b569469d304..7916a96f98c 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -63,15 +63,13 @@
static int ED_space_clip_graph_poll(bContext *C)
{
- SpaceClip *sc = CTX_wm_space_clip(C);
-
- if (sc && sc->clip) {
+ if (ED_space_clip_tracking_poll(C)) {
ARegion *ar = CTX_wm_region(C);
return ar->regiontype == RGN_TYPE_PREVIEW;
}
- return 0;
+ return FALSE;
}
typedef struct {
@@ -486,7 +484,7 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot)
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = delete_curve_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h
index 425a1da9ec5..0b63ae5b12f 100644
--- a/source/blender/editors/space_clip/clip_intern.h
+++ b/source/blender/editors/space_clip/clip_intern.h
@@ -38,6 +38,7 @@ struct MovieClip;
struct MovieTrackingMarker;
struct MovieTrackingTrack;
struct Scene;
+struct ScrArea;
struct SpaceClip;
struct wmOperatorType;
@@ -81,6 +82,7 @@ void CLIP_OT_rebuild_proxy(struct wmOperatorType *ot);
void CLIP_OT_mode_set(struct wmOperatorType *ot);
/* clip_toolbar.c */
+struct ARegion *ED_clip_has_properties_region(struct ScrArea *sa);
void CLIP_OT_tools(struct wmOperatorType *ot);
void CLIP_OT_properties(struct wmOperatorType *ot);
void ED_clip_tool_props_register(struct ARegionType *art);
@@ -104,6 +106,9 @@ void clip_delete_marker(struct bContext *C, struct MovieClip *clip, struct ListB
void clip_view_center_to_point(struct SpaceClip *sc, float x, float y);
+void clip_draw_cfra(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene);
+void clip_draw_sfra_efra(struct View2D *v2d, struct Scene *scene);
+
/* tracking_ops.c */
void CLIP_OT_select(struct wmOperatorType *ot);
void CLIP_OT_select_all(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c
index b80deb8260a..da8bf8fedd9 100644
--- a/source/blender/editors/space_clip/clip_toolbar.c
+++ b/source/blender/editors/space_clip/clip_toolbar.c
@@ -56,7 +56,7 @@
/************************** properties ******************************/
-static ARegion *clip_has_properties_region(ScrArea *sa)
+ARegion *ED_clip_has_properties_region(ScrArea *sa)
{
ARegion *ar, *arnew;
@@ -90,9 +90,9 @@ static int properties_poll(bContext *C)
static int properties_exec(bContext *C, wmOperator *UNUSED(op))
{
ScrArea *sa = CTX_wm_area(C);
- ARegion *ar = clip_has_properties_region(sa);
+ ARegion *ar = ED_clip_has_properties_region(sa);
- if (ar)
+ if (ar && ar->alignment != RGN_ALIGN_NONE)
ED_region_toggle_hidden(C, ar);
return OPERATOR_FINISHED;
@@ -167,7 +167,7 @@ static int tools_exec(bContext *C, wmOperator *UNUSED(op))
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = clip_has_tools_region(sa);
- if (ar)
+ if (ar && ar->alignment != RGN_ALIGN_NONE)
ED_region_toggle_hidden(C, ar);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index 443a1d0cdd3..c8ba8be7eae 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -29,6 +29,7 @@
* \ingroup spclip
*/
+#include "DNA_scene_types.h"
#include "DNA_object_types.h" /* SELECT */
#include "MEM_guardedalloc.h"
@@ -42,6 +43,9 @@
#include "BKE_tracking.h"
#include "BKE_depsgraph.h"
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -53,6 +57,8 @@
#include "RNA_access.h"
#include "RNA_define.h"
+#include "UI_interface.h"
+#include "UI_resources.h"
#include "UI_view2d.h"
#include "clip_intern.h" // own include
@@ -220,3 +226,57 @@ void clip_view_center_to_point(SpaceClip *sc, float x, float y)
sc->xof = (x - 0.5f) * width * aspx;
sc->yof = (y - 0.5f) * height * aspy;
}
+
+void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
+{
+ View2D *v2d = &ar->v2d;
+ float xscale, yscale;
+ float vec[2];
+
+ /* Draw a light green line to indicate current frame */
+ vec[0] = (float)(sc->user.framenr * scene->r.framelen);
+
+ UI_ThemeColor(TH_CFRAME);
+ glLineWidth(2.0);
+
+ glBegin(GL_LINE_STRIP);
+ vec[1] = v2d->cur.ymin;
+ glVertex2fv(vec);
+
+ vec[1] = v2d->cur.ymax;
+ glVertex2fv(vec);
+ glEnd();
+
+ glLineWidth(1.0);
+
+ UI_view2d_view_orthoSpecial(ar, v2d, 1);
+
+ /* because the frame number text is subject to the same scaling as the contents of the view */
+ UI_view2d_getscale(v2d, &xscale, &yscale);
+ glScalef(1.0f/xscale, 1.0f, 1.0f);
+
+ clip_draw_curfra_label(sc, (float)sc->user.framenr * xscale, 18);
+
+ /* restore view transform */
+ glScalef(xscale, 1.0, 1.0);
+}
+
+void clip_draw_sfra_efra(View2D *v2d, Scene *scene)
+{
+ UI_view2d_view_ortho(v2d);
+
+ /* currently clip editor supposes that editing clip length is equal to scene frame range */
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+ glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
+
+ glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
+ glRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
+ glDisable(GL_BLEND);
+
+ UI_ThemeColorShade(TH_BACK, -60);
+
+ /* thin lines where the actual frames are */
+ fdrawline((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax);
+ fdrawline((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax);
+}
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 4de790bc00c..58582df7a3f 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -96,7 +96,7 @@ static void init_preview_region(const bContext *C, ARegion *ar)
ar->v2d.keeptot = 0;
}
-static ARegion *clip_has_preview_region(const bContext *C, ScrArea *sa)
+static ARegion *ED_clip_has_preview_region(const bContext *C, ScrArea *sa)
{
ARegion *ar, *arnew;
@@ -619,10 +619,13 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul
if (CTX_data_dir(member)) {
CTX_data_dir_set(result, clip_context_dir);
+
return TRUE;
}
else if (CTX_data_equals(member, "edit_movieclip")) {
- CTX_data_id_pointer_set(result, &sc->clip->id);
+ if (sc->clip)
+ CTX_data_id_pointer_set(result, &sc->clip->id);
+
return TRUE;
}
@@ -636,54 +639,163 @@ static void clip_refresh(const bContext *C, ScrArea *sa)
Scene *scene = CTX_data_scene(C);
SpaceClip *sc = (SpaceClip *)sa->spacedata.first;
ARegion *ar_main = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
- ARegion *ar_preview = clip_has_preview_region(C, sa);
+ ARegion *ar_tools = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
+ ARegion *ar_tool_props = BKE_area_find_region_type(sa, RGN_TYPE_TOOL_PROPS);
+ ARegion *ar_preview = ED_clip_has_preview_region(C, sa);
+ ARegion *ar_properties = ED_clip_has_properties_region(sa);
+ int main_visible = FALSE, preview_visible = FALSE, tools_visible = FALSE;
+ int tool_props_visible = FALSE, properties_visible = FALSE;
int view_changed = FALSE;
switch (sc->view) {
case SC_VIEW_CLIP:
- if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) {
- ar_preview->flag |= RGN_FLAG_HIDDEN;
- ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
- WM_event_remove_handlers((bContext*)C, &ar_preview->handlers);
- view_changed = TRUE;
- }
- if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
- ar_main->alignment = RGN_ALIGN_NONE;
- view_changed = TRUE;
- }
- if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) {
- /* store graph region align */
- if (ar_preview->alignment == RGN_ALIGN_TOP)
- sc->runtime_flag &= ~SC_GRAPH_BOTTOM;
- else
- sc->runtime_flag |= SC_GRAPH_BOTTOM;
-
- ar_preview->alignment = RGN_ALIGN_NONE;
- view_changed = TRUE;
- }
+ main_visible = TRUE;
+ preview_visible = FALSE;
+ tools_visible = TRUE;
+ tool_props_visible = TRUE;
+ properties_visible = TRUE;
break;
case SC_VIEW_GRAPH:
- if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) {
- ar_preview->flag &= ~RGN_FLAG_HIDDEN;
- ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
- ar_preview->v2d.cur = ar_preview->v2d.tot;
- view_changed = TRUE;
- }
- if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
- ar_main->alignment = RGN_ALIGN_NONE;
- view_changed = TRUE;
- }
- if (ar_preview && !ELEM(ar_preview->alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) {
- if (sc->runtime_flag & SC_GRAPH_BOTTOM)
- ar_preview->alignment = RGN_ALIGN_BOTTOM;
- else
- ar_preview->alignment = RGN_ALIGN_TOP;
-
- view_changed = TRUE;
- }
+ main_visible = TRUE;
+ preview_visible = TRUE;
+ tools_visible = TRUE;
+ tool_props_visible = TRUE;
+ properties_visible = TRUE;
break;
}
+ if (main_visible) {
+ if (ar_main && (ar_main->flag & RGN_FLAG_HIDDEN)) {
+ ar_main->flag &= ~RGN_FLAG_HIDDEN;
+ ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ view_changed = TRUE;
+ }
+
+ if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
+ ar_main->alignment = RGN_ALIGN_NONE;
+ view_changed = TRUE;
+ }
+ }
+ else {
+ if (ar_main && !(ar_main->flag & RGN_FLAG_HIDDEN)) {
+ ar_main->flag |= RGN_FLAG_HIDDEN;
+ ar_main->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &ar_main->handlers);
+ view_changed = TRUE;
+ }
+ if (ar_main && ar_main->alignment != RGN_ALIGN_NONE) {
+ ar_main->alignment = RGN_ALIGN_NONE;
+ view_changed = TRUE;
+ }
+ }
+
+ if (properties_visible) {
+ if (ar_properties && (ar_properties->flag & RGN_FLAG_HIDDEN)) {
+ ar_properties->flag &= ~RGN_FLAG_HIDDEN;
+ ar_properties->v2d.flag &= ~V2D_IS_INITIALISED;
+ view_changed = TRUE;
+ }
+ if (ar_properties && ar_properties->alignment != RGN_ALIGN_RIGHT) {
+ ar_properties->alignment = RGN_ALIGN_RIGHT;
+ view_changed = TRUE;
+ }
+ }
+ else {
+ if (ar_properties && !(ar_properties->flag & RGN_FLAG_HIDDEN)) {
+ ar_properties->flag |= RGN_FLAG_HIDDEN;
+ ar_properties->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &ar_properties->handlers);
+ view_changed = TRUE;
+ }
+ if (ar_properties && ar_properties->alignment != RGN_ALIGN_NONE) {
+ ar_properties->alignment = RGN_ALIGN_NONE;
+ view_changed = TRUE;
+ }
+ }
+
+ if (tools_visible) {
+ if (ar_tools && (ar_tools->flag & RGN_FLAG_HIDDEN)) {
+ ar_tools->flag &= ~RGN_FLAG_HIDDEN;
+ ar_tools->v2d.flag &= ~V2D_IS_INITIALISED;
+ view_changed = TRUE;
+ }
+ if (ar_tools && ar_tools->alignment != RGN_ALIGN_LEFT) {
+ ar_tools->alignment = RGN_ALIGN_LEFT;
+ view_changed = TRUE;
+ }
+ }
+ else {
+ if (ar_tools && !(ar_tools->flag & RGN_FLAG_HIDDEN)) {
+ ar_tools->flag |= RGN_FLAG_HIDDEN;
+ ar_tools->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &ar_tools->handlers);
+ view_changed = TRUE;
+ }
+ if (ar_tools && ar_tools->alignment != RGN_ALIGN_NONE) {
+ ar_tools->alignment = RGN_ALIGN_NONE;
+ view_changed = TRUE;
+ }
+ }
+
+ if (tool_props_visible) {
+ if (ar_tool_props && (ar_tool_props->flag & RGN_FLAG_HIDDEN)) {
+ ar_tool_props->flag &= ~RGN_FLAG_HIDDEN;
+ ar_tool_props->v2d.flag &= ~V2D_IS_INITIALISED;
+ view_changed = TRUE;
+ }
+ if (ar_tool_props && (ar_tool_props->alignment != (RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV))) {
+ ar_tool_props->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV;
+ view_changed = TRUE;
+ }
+ }
+ else {
+ if (ar_tool_props && !(ar_tool_props->flag & RGN_FLAG_HIDDEN)) {
+ ar_tool_props->flag |= RGN_FLAG_HIDDEN;
+ ar_tool_props->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &ar_tool_props->handlers);
+ view_changed = TRUE;
+ }
+ if (ar_tool_props && ar_tool_props->alignment != RGN_ALIGN_NONE) {
+ ar_tool_props->alignment = RGN_ALIGN_NONE;
+ view_changed = TRUE;
+ }
+ }
+
+ if (preview_visible) {
+ if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) {
+ ar_preview->flag &= ~RGN_FLAG_HIDDEN;
+ ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ ar_preview->v2d.cur = ar_preview->v2d.tot;
+ view_changed = TRUE;
+ }
+ if (ar_preview && !ELEM(ar_preview->alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) {
+ if (sc->runtime_flag & SC_GRAPH_BOTTOM)
+ ar_preview->alignment = RGN_ALIGN_BOTTOM;
+ else
+ ar_preview->alignment = RGN_ALIGN_TOP;
+
+ view_changed = TRUE;
+ }
+ }
+ else {
+ /* store graph region align */
+ if (ar_preview->alignment == RGN_ALIGN_TOP)
+ sc->runtime_flag &= ~SC_GRAPH_BOTTOM;
+ else if (ar_preview->alignment == RGN_ALIGN_BOTTOM)
+ sc->runtime_flag |= SC_GRAPH_BOTTOM;
+
+ if (ar_preview && !(ar_preview->flag & RGN_FLAG_HIDDEN)) {
+ ar_preview->flag |= RGN_FLAG_HIDDEN;
+ ar_preview->v2d.flag &= ~V2D_IS_INITIALISED;
+ WM_event_remove_handlers((bContext *)C, &ar_preview->handlers);
+ view_changed = TRUE;
+ }
+ if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) {
+ ar_preview->alignment = RGN_ALIGN_NONE;
+ view_changed = TRUE;
+ }
+ }
+
if (view_changed) {
ED_area_initialize(wm, window, sa);
ED_area_tag_redraw(sa);
@@ -832,13 +944,13 @@ static void clip_preview_area_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
-static void clip_preview_area_draw(const bContext *C, ARegion *ar)
+static void graph_area_draw(const bContext *C, ARegion *ar)
{
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
SpaceClip *sc = CTX_wm_space_clip(C);
Scene *scene = CTX_data_scene(C);
- short unitx = V2D_UNIT_FRAMESCALE, unity = V2D_UNIT_VALUES;
+ short unitx, unity;
if (sc->flag & SC_LOCK_TIMECURSOR)
ED_clip_graph_center_current_frame(scene, ar);
@@ -856,11 +968,20 @@ static void clip_preview_area_draw(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* scrollers */
+ unitx = (sc->flag & SC_SHOW_SECONDS)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES;
+ unity = V2D_UNIT_VALUES;
scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
UI_view2d_scrollers_draw(C, v2d, scrollers);
UI_view2d_scrollers_free(scrollers);
}
+static void clip_preview_area_draw(const bContext *C, ARegion *ar)
+{
+ SpaceClip *sc = CTX_wm_space_clip(C);
+
+ graph_area_draw(C, ar);
+}
+
static void clip_preview_area_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn))
{
}
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index f4454394ca3..b3bb7464761 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -78,39 +78,6 @@
#include "clip_intern.h" // own include
-static int space_clip_frame_poll(bContext *C)
-{
- SpaceClip *sc = CTX_wm_space_clip(C);
-
- if (sc) {
- MovieClip *clip = ED_space_clip(sc);
-
- if (clip)
- return BKE_movieclip_has_frame(clip, &sc->user);
- }
-
- return FALSE;
-}
-
-static int space_clip_size_poll(bContext *C)
-{
- SpaceClip *sc = CTX_wm_space_clip(C);
-
- if (sc) {
- MovieClip *clip = ED_space_clip(sc);
-
- if (clip) {
- int width, height;
-
- BKE_movieclip_get_size(clip, &sc->user, &width, &height);
-
- return width > 0 && height > 0;
- }
- }
-
- return FALSE;
-}
-
/********************** add marker operator *********************/
static void add_marker(SpaceClip *sc, float x, float y)
@@ -175,7 +142,7 @@ void CLIP_OT_add_marker(wmOperatorType *ot)
/* api callbacks */
ot->invoke = add_marker_invoke;
ot->exec = add_marker_exec;
- ot->poll = space_clip_size_poll;
+ ot->poll = ED_space_clip_tracking_size_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -220,7 +187,7 @@ void CLIP_OT_delete_track(wmOperatorType *ot)
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = delete_track_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -271,7 +238,7 @@ void CLIP_OT_delete_marker(wmOperatorType *ot)
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = delete_marker_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -662,7 +629,7 @@ void CLIP_OT_slide_marker(wmOperatorType *ot)
ot->idname = "CLIP_OT_slide_marker";
/* api callbacks */
- ot->poll = space_clip_size_poll;
+ ot->poll = ED_space_clip_tracking_size_poll;
ot->invoke = slide_marker_invoke;
ot->modal = slide_marker_modal;
@@ -876,7 +843,7 @@ void CLIP_OT_select(wmOperatorType *ot)
/* api callbacks */
ot->exec = select_exec;
ot->invoke = select_invoke;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_UNDO;
@@ -953,7 +920,7 @@ void CLIP_OT_select_border(wmOperatorType *ot)
ot->invoke = WM_border_select_invoke;
ot->exec = border_select_exec;
ot->modal = WM_border_select_modal;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_UNDO;
@@ -1037,7 +1004,7 @@ void CLIP_OT_select_circle(wmOperatorType *ot)
ot->invoke = WM_gesture_circle_invoke;
ot->modal = WM_gesture_circle_modal;
ot->exec = circle_select_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1128,7 +1095,7 @@ void CLIP_OT_select_all(wmOperatorType *ot)
/* api callbacks */
ot->exec = select_all_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1219,7 +1186,7 @@ void CLIP_OT_select_grouped(wmOperatorType *ot)
/* api callbacks */
ot->exec = select_groped_exec;
- ot->poll = space_clip_size_poll;
+ ot->poll = ED_space_clip_tracking_size_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1596,7 +1563,7 @@ void CLIP_OT_track_markers(wmOperatorType *ot)
/* api callbacks */
ot->exec = track_markers_exec;
ot->invoke = track_markers_invoke;
- ot->poll = space_clip_frame_poll;
+ ot->poll = ED_space_clip_tracking_frame_poll;
ot->modal = track_markers_modal;
/* flags */
@@ -1819,7 +1786,7 @@ void CLIP_OT_solve_camera(wmOperatorType *ot)
ot->exec = solve_camera_exec;
ot->invoke = solve_camera_invoke;
ot->modal = solve_camera_modal;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1867,7 +1834,7 @@ void CLIP_OT_clear_solution(wmOperatorType *ot)
/* api callbacks */
ot->exec = clear_solution_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1919,7 +1886,7 @@ void CLIP_OT_clear_track_path(wmOperatorType *ot)
/* api callbacks */
ot->exec = clear_track_path_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1977,7 +1944,7 @@ void CLIP_OT_disable_markers(wmOperatorType *ot)
/* api callbacks */
ot->exec = disable_markers_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2035,7 +2002,7 @@ static Object *get_orientation_object(bContext *C)
static int set_orientation_poll(bContext *C)
{
- if (space_clip_size_poll(C)) {
+ if (ED_space_clip_tracking_size_poll(C)) {
Scene *scene = CTX_data_scene(C);
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
@@ -2645,7 +2612,7 @@ void CLIP_OT_set_scale(wmOperatorType *ot)
static int set_solution_scale_poll(bContext *C)
{
- if (space_clip_size_poll(C)) {
+ if (ED_space_clip_tracking_size_poll(C)) {
SpaceClip *sc = CTX_wm_space_clip(C);
MovieClip *clip = ED_space_clip(sc);
MovieTracking *tracking = &clip->tracking;
@@ -2723,7 +2690,7 @@ void CLIP_OT_set_center_principal(wmOperatorType *ot)
/* api callbacks */
ot->exec = set_center_principal_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2777,7 +2744,7 @@ void CLIP_OT_hide_tracks(wmOperatorType *ot)
/* api callbacks */
ot->exec = hide_tracks_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2816,7 +2783,7 @@ void CLIP_OT_hide_tracks_clear(wmOperatorType *ot)
/* api callbacks */
ot->exec = hide_tracks_clear_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2898,7 +2865,7 @@ void CLIP_OT_detect_features(wmOperatorType *ot)
/* api callbacks */
ot->exec = detect_features_exec;
- ot->poll = space_clip_frame_poll;
+ ot->poll = ED_space_clip_tracking_frame_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -2993,7 +2960,7 @@ void CLIP_OT_frame_jump(wmOperatorType *ot)
/* api callbacks */
ot->exec = frame_jump_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3050,7 +3017,7 @@ void CLIP_OT_join_tracks(wmOperatorType *ot)
/* api callbacks */
ot->exec = join_tracks_exec;
- ot->poll = space_clip_size_poll;
+ ot->poll = ED_space_clip_tracking_size_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3100,7 +3067,7 @@ void CLIP_OT_lock_tracks(wmOperatorType *ot)
/* api callbacks */
ot->exec = lock_tracks_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3150,7 +3117,7 @@ void CLIP_OT_track_copy_color(wmOperatorType *ot)
/* api callbacks */
ot->exec = track_copy_color_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3199,7 +3166,7 @@ void CLIP_OT_stabilize_2d_add(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_add_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3259,7 +3226,7 @@ void CLIP_OT_stabilize_2d_remove(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_remove_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3302,7 +3269,7 @@ void CLIP_OT_stabilize_2d_select(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_select_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3339,7 +3306,7 @@ void CLIP_OT_stabilize_2d_set_rotation(wmOperatorType *ot)
/* api callbacks */
ot->exec = stabilize_2d_set_rotation_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3530,7 +3497,7 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot)
/* api callbacks */
ot->exec = clean_tracks_exec;
ot->invoke = clean_tracks_invoke;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3567,7 +3534,7 @@ void CLIP_OT_tracking_object_new(wmOperatorType *ot)
/* api callbacks */
ot->exec = tracking_object_new_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3605,7 +3572,7 @@ void CLIP_OT_tracking_object_remove(wmOperatorType *ot)
/* api callbacks */
ot->exec = tracking_object_remove_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -3636,7 +3603,7 @@ void CLIP_OT_copy_tracks(wmOperatorType *ot)
/* api callbacks */
ot->exec = copy_tracks_exec;
- ot->poll = ED_space_clip_poll;
+ ot->poll = ED_space_clip_tracking_poll;
/* flags */
ot->flag = OPTYPE_REGISTER;
@@ -3646,7 +3613,7 @@ void CLIP_OT_copy_tracks(wmOperatorType *ot)
static int paste_tracks_poll(bContext *C)
{
- if (ED_space_clip_poll(C)) {
+ if (ED_space_clip_tracking_poll(C)) {
return BKE_tracking_clipboard_has_tracks();
}