Merging r46062 through r46073 from trunk into soc-2011-tomato
[blender.git] / source / blender / editors / space_clip / clip_editor.c
index 099c3c7532c555f691b89552e27d2ceb91e54aa5..69a8b0f4c92423efee63f99ff2e9f3a7b1648340 100644 (file)
@@ -37,6 +37,7 @@
 #include "BKE_movieclip.h"
 #include "BKE_context.h"
 #include "BKE_tracking.h"
+
 #include "DNA_object_types.h"  /* SELECT */
 
 #include "BLI_utildefines.h"
@@ -60,6 +61,8 @@
 
 #include "clip_intern.h"       // own include
 
+/* ******** operactor poll functions ******** */
+
 int ED_space_clip_poll(bContext *C)
 {
        SpaceClip *sc = CTX_wm_space_clip(C);
@@ -70,6 +73,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, bScreen *screen, SpaceClip *sc, MovieClip *clip)
 {
        MovieClip *old_clip;
@@ -508,3 +556,12 @@ void ED_space_clip_free_texture_buffer(SpaceClip *sc)
                MEM_freeN(context);
        }
 }
+
+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;
+}