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:
-rw-r--r--source/blender/editors/include/ED_markers.h49
-rw-r--r--source/blender/editors/include/ED_types.h39
-rw-r--r--source/blender/editors/include/UI_view2d.h4
-rw-r--r--source/blender/editors/interface/view2d.c5
-rw-r--r--source/blender/editors/screen/screen_ops.c10
-rw-r--r--source/blender/editors/space_time/ed_markers.c242
-rw-r--r--source/blender/editors/space_time/space_time.c7
-rw-r--r--source/blender/editors/space_time/time_ops.c9
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c1
9 files changed, 361 insertions, 5 deletions
diff --git a/source/blender/editors/include/ED_markers.h b/source/blender/editors/include/ED_markers.h
new file mode 100644
index 00000000000..09346417d5a
--- /dev/null
+++ b/source/blender/editors/include/ED_markers.h
@@ -0,0 +1,49 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef ED_MARKERS_H
+#define ED_MARKERS_H
+
+/* flags for drawing markers */
+enum {
+ DRAW_MARKERS_LINES = (1<<0),
+ DRAW_MARKERS_LOCAL = (1<<1)
+};
+
+
+
+struct wmOperatorType;
+
+
+void draw_markers_time(const bContext *C, int flag);
+
+/* operators */
+void ED_MARKER_OT_add(struct wmOperatorType *ot);
+
+
+#endif /* ED_MARKERS_H */
+
diff --git a/source/blender/editors/include/ED_types.h b/source/blender/editors/include/ED_types.h
new file mode 100644
index 00000000000..7b19341fb9e
--- /dev/null
+++ b/source/blender/editors/include/ED_types.h
@@ -0,0 +1,39 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef ED_TYPES_H
+#define ED_TYPES_H
+
+/* **************** GENERAL EDITOR-WIDE TYPES AND DEFINES ************************** */
+
+/* old blender defines... should be depricated? */
+#define SELECT 1
+#define ACTIVE 2
+
+
+#endif /* ED_TYPES_H */
+
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 481d96952e9..7b5712b66de 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -65,5 +65,9 @@ void UI_view2d_region_to_view(struct View2D *v2d, short x, short y, float *viewx
void UI_view2d_view_to_region(struct View2D *v2d, float x, float y, short *regionx, short *regiony);
void UI_view2d_to_region_no_clip(struct View2D *v2d, float x, float y, short *regionx, short *region_y);
+/* utilities */
+void UI_view2d_getscale(View2D *v2d, float *x, float *y);
+
+
#endif /* UI_VIEW2D_H */
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index 075c89c9b47..322d88489bf 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -323,4 +323,9 @@ void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, short *regionx,
}
}
+void UI_view2d_getscale(View2D *v2d, float *x, float *y)
+{
+ if (x) *x = (v2d->mask.xmax-v2d->mask.xmin)/(v2d->cur.xmax-v2d->cur.xmin);
+ if (y) *y = (v2d->mask.ymax-v2d->mask.ymin)/(v2d->cur.ymax-v2d->cur.ymin);
+}
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index f129a225aa2..9e976a81c1f 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -39,6 +39,7 @@
#include "WM_types.h"
#include "ED_area.h"
+#include "ED_markers.h"
#include "ED_screen.h"
#include "ED_screen_types.h"
@@ -1275,12 +1276,16 @@ void ED_operatortypes_screen(void)
WM_operatortype_append(ED_SCR_OT_cursor_type);
WM_operatortype_append(ED_SCR_OT_actionzone);
- /* tools */
+ /* screen tools */
WM_operatortype_append(ED_SCR_OT_area_move);
WM_operatortype_append(ED_SCR_OT_area_split);
WM_operatortype_append(ED_SCR_OT_area_join);
WM_operatortype_append(ED_SCR_OT_area_rip);
+ /* tools shared by more space types */
+ WM_operatortype_append(ED_MARKER_OT_add);
+
+
/* for test only */
WM_operatortype_append(ED_SCR_OT_border_select);
}
@@ -1298,9 +1303,6 @@ void ED_keymap_screen(wmWindowManager *wm)
/* for test only */
WM_keymap_verify_item(&wm->screenkeymap, "ED_SCR_OT_border_select", BKEY, KM_PRESS, 0, 0);
- WM_keymap_verify_item(&wm->screenkeymap, "WM_OT_tweak_gesture", LEFTMOUSE, KM_PRESS, 0, 0); /* generates event */
-
- WM_keymap_add_item(&wm->screenkeymap, "ED_SCR_OT_area_split", EVT_TWEAK, EVT_GESTURE_S, 0, 0);
}
diff --git a/source/blender/editors/space_time/ed_markers.c b/source/blender/editors/space_time/ed_markers.c
new file mode 100644
index 00000000000..54e4ab6d360
--- /dev/null
+++ b/source/blender/editors/space_time/ed_markers.c
@@ -0,0 +1,242 @@
+/**
+ * $Id:
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+#include "DNA_view2d_types.h"
+#include "DNA_windowmanager_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "BLI_blenlib.h"
+
+#include "BKE_global.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
+#include "UI_interface.h"
+#include "UI_view2d.h"
+#include "UI_resources.h"
+
+#include "ED_markers.h"
+#include "ED_types.h"
+
+/* ************* Marker Drawing ************ */
+
+/* XXX */
+extern void ui_rasterpos_safe(float x, float y, float aspect);
+
+/* function to draw markers */
+static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
+{
+ float xpos, ypixels, xscale, yscale;
+ int icon_id= 0;
+
+ xpos = marker->frame;
+ /* no time correction for framelen! space is drawn with old values */
+
+ ypixels= v2d->mask.ymax-v2d->mask.ymin;
+ UI_view2d_getscale(v2d, &xscale, &yscale);
+
+ glScalef( 1.0/xscale, 1.0/yscale, 1.0);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+ /* verticle line */
+ if (flag & DRAW_MARKERS_LINES) {
+ setlinestyle(3);
+ if(marker->flag & SELECT)
+ glColor4ub(255,255,255, 96);
+ else
+ glColor4ub(0,0,0, 96);
+
+ glBegin(GL_LINES);
+ glVertex2f((xpos*xscale)+0.5, 12);
+ glVertex2f((xpos*xscale)+0.5, 34*yscale); /* a bit lazy but we know it cant be greater then 34 strips high*/
+ glEnd();
+ setlinestyle(0);
+ }
+
+ /* 5 px to offset icon to align properly, space / pixels corrects for zoom */
+ if (flag & DRAW_MARKERS_LOCAL) {
+ icon_id= (marker->flag & ACTIVE) ? ICON_PMARKER_ACT :
+ (marker->flag & SELECT) ? ICON_PMARKER_SEL :
+ ICON_PMARKER;
+ }
+ else {
+ icon_id= (marker->flag & SELECT) ? ICON_MARKER_HLT :
+ ICON_MARKER;
+ }
+
+ //BIF_icon_draw(xpos*xscale-5.0, 12.0, icon_id);
+ glColor3ub(0, 100, 0);
+ glRectf(xpos*xscale-5.0f, 12.0f, xpos*xscale, 17.0f);
+
+ glBlendFunc(GL_ONE, GL_ZERO);
+ glDisable(GL_BLEND);
+
+ /* and the marker name too, shifted slightly to the top-right */
+ if(marker->name && marker->name[0]) {
+ if(marker->flag & SELECT) {
+ //BIF_ThemeColor(TH_TEXT_HI);
+ ui_rasterpos_safe(xpos*xscale+4.0, (ypixels<=39.0)?(ypixels-10.0):29.0, 1.0);
+ }
+ else {
+ // BIF_ThemeColor(TH_TEXT);
+ if((marker->frame <= cfra) && (marker->frame+5 > cfra))
+ ui_rasterpos_safe(xpos*xscale+4.0, (ypixels<=39.0)?(ypixels-10.0):29.0, 1.0);
+ else
+ ui_rasterpos_safe(xpos*xscale+4.0, 17.0, 1.0);
+ }
+// BIF_DrawString(G.font, marker->name, 0);
+ }
+ glScalef(xscale, yscale, 1.0);
+}
+
+/* Draw Scene-Markers in time window (XXX make generic) */
+void draw_markers_time(const bContext *C, int flag)
+{
+ TimeMarker *marker;
+ SpaceTime *stime= C->area->spacedata.first;
+ View2D *v2d= &stime->v2d;
+
+ /* unselected markers are drawn at the first time */
+ for (marker= C->scene->markers.first; marker; marker= marker->next) {
+ if (!(marker->flag & SELECT)) draw_marker(v2d, marker, C->scene->r.cfra, flag);
+ }
+
+ /* selected markers are drawn later */
+ for (marker= C->scene->markers.first; marker; marker= marker->next) {
+ if (marker->flag & SELECT) draw_marker(v2d, marker, C->scene->r.cfra, flag);
+ }
+}
+
+
+
+/* ************* Marker API **************** */
+
+/* add TimeMarker at curent frame */
+static int ed_marker_add(bContext *C, wmOperator *op)
+{
+ TimeMarker *marker;
+ int frame= C->scene->r.cfra;
+
+ /* two markers can't be at the same place */
+ for(marker= C->scene->markers.first; marker; marker= marker->next)
+ if(marker->frame == frame)
+ return OPERATOR_CANCELLED;
+
+ /* deselect all */
+ for(marker= C->scene->markers.first; marker; marker= marker->next)
+ marker->flag &= ~SELECT;
+
+ marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
+ marker->flag= SELECT;
+ marker->frame= frame;
+ BLI_addtail(&(C->scene->markers), marker);
+
+ //BIF_undo_push("Add Marker");
+
+ return OPERATOR_FINISHED;
+}
+
+
+/* remove selected TimeMarkers */
+void ed_marker_remove(bContext *C)
+{
+ TimeMarker *marker, *nmarker;
+ short changed= 0;
+
+ for(marker= C->scene->markers.first; marker; marker= nmarker) {
+ nmarker= marker->next;
+ if(marker->flag & SELECT) {
+ BLI_freelinkN(&(C->scene->markers), marker);
+ changed= 1;
+ }
+ }
+
+// if (changed)
+// BIF_undo_push("Remove Marker");
+}
+
+
+/* duplicate selected TimeMarkers */
+void ed_marker_duplicate(bContext *C)
+{
+ TimeMarker *marker, *newmarker;
+
+ /* go through the list of markers, duplicate selected markers and add duplicated copies
+ * to the begining of the list (unselect original markers) */
+ for(marker= C->scene->markers.first; marker; marker= marker->next) {
+ if(marker->flag & SELECT){
+ /* unselect selected marker */
+ marker->flag &= ~SELECT;
+ /* create and set up new marker */
+ newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
+ newmarker->flag= SELECT;
+ newmarker->frame= marker->frame;
+ BLI_strncpy(newmarker->name, marker->name, sizeof(marker->name));
+ /* new marker is added to the begining of list */
+ BLI_addhead(&(C->scene->markers), newmarker);
+ }
+ }
+
+// transform_markers('g', 0);
+}
+
+void ED_MARKER_OT_add(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Add Time Marker";
+ ot->idname= "ED_MARKER_OT_add";
+
+ /* api callbacks */
+ ot->exec= ed_marker_add;
+
+}
+
+
+/* ************************** registration **********************************/
+
+void marker_operatortypes(void)
+{
+ WM_operatortype_append(ED_MARKER_OT_add);
+}
+
+
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index 9dbbf668c27..bc7c86c173e 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -51,6 +51,8 @@
#include "UI_resources.h"
#include "UI_view2d.h"
+#include "ED_markers.h"
+
#include "time_intern.h"
/* ************************ main time area region *********************** */
@@ -137,6 +139,9 @@ static void time_main_area_draw(const bContext *C, ARegion *ar)
/* current frame */
time_draw_cfra_time(C, stime);
+
+ /* markers */
+ draw_markers_time(C, 0);
}
static void time_main_area_listener(ARegion *ar, wmNotifier *wmn)
@@ -228,7 +233,7 @@ static void time_init(wmWindowManager *wm, ScrArea *sa)
ar->type= &mainart;
- /* XXX the windowmanager may not be th best place to keep these
+ /* XXX the windowmanager may not be the best place to keep these
* keymaps, and this function callback may not be the best one
* to add the keymap handler, also will need to take care of
* area type changes, etc, basically space callbacks need to
diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c
index 41a65fc20ee..33e04821d35 100644
--- a/source/blender/editors/space_time/time_ops.c
+++ b/source/blender/editors/space_time/time_ops.c
@@ -48,6 +48,8 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "ED_markers.h"
+
/* ********************** frame change operator ***************************/
static int change_frame_init(bContext *C, wmOperator *op)
@@ -184,5 +186,12 @@ void time_operatortypes(void)
void time_keymap(wmWindowManager *wm)
{
WM_keymap_verify_item(&wm->timekeymap, "ED_TIME_OT_change_frame", LEFTMOUSE, KM_PRESS, 0, 0);
+
+ WM_keymap_verify_item(&wm->timekeymap, "ED_MARKER_OT_add", MKEY, KM_PRESS, 0, 0);
+
+ WM_keymap_verify_item(&wm->timekeymap, "WM_OT_tweak_gesture", RIGHTMOUSE, KM_PRESS, 0, 0); /* generates event */
+
+ //WM_keymap_add_item(&wm->screenkeymap, "ED_SCR_OT_area_split", EVT_TWEAK, EVT_GESTURE_S, 0, 0);
+
}
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 953965fd144..260709906ba 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -65,6 +65,7 @@ wmOperatorType *WM_operatortype_find(const char *idname)
if(strncmp(ot->idname, idname, OP_MAX_TYPENAME)==0)
return ot;
}
+ printf("search for unknown operator %s\n", idname);
return NULL;
}