[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17560] branches/blender2.5/blender/source /blender: More testing with new system:

Ton Roosendaal ton at blender.org
Mon Nov 24 19:59:59 CET 2008


Revision: 17560
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17560
Author:   ton
Date:     2008-11-24 19:59:59 +0100 (Mon, 24 Nov 2008)

Log Message:
-----------
More testing with new system:

- Added markers (partially) back, ed_markers.c (temporary in spacetime,
  where to put general stuff like this?), and added ED_markers.h for api.

- Mkey in timewindow shows marker (no icon, doesnt work yet).
  (Adding operators gets easy :)

- Noted some conflict for operator storage... with markers being used all
  over, added it to the screen level.

- More todos: view2d is stored in space, for time, etc. With regions we
  could move this over, but better todo as post 2.5 project. Multiple 2d
  views in area would be cool though.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
    branches/blender2.5/blender/source/blender/editors/interface/view2d.c
    branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
    branches/blender2.5/blender/source/blender/editors/space_time/space_time.c
    branches/blender2.5/blender/source/blender/editors/space_time/time_ops.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/include/ED_markers.h
    branches/blender2.5/blender/source/blender/editors/include/ED_types.h
    branches/blender2.5/blender/source/blender/editors/space_time/ed_markers.c

Added: branches/blender2.5/blender/source/blender/editors/include/ED_markers.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_markers.h	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_markers.h	2008-11-24 18:59:59 UTC (rev 17560)
@@ -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 */
+

Added: branches/blender2.5/blender/source/blender/editors/include/ED_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_types.h	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_types.h	2008-11-24 18:59:59 UTC (rev 17560)
@@ -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 */
+

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h	2008-11-24 17:48:40 UTC (rev 17559)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_view2d.h	2008-11-24 18:59:59 UTC (rev 17560)
@@ -65,5 +65,9 @@
 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 */
 

Modified: branches/blender2.5/blender/source/blender/editors/interface/view2d.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2008-11-24 17:48:40 UTC (rev 17559)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d.c	2008-11-24 18:59:59 UTC (rev 17560)
@@ -323,4 +323,9 @@
 	}
 }
 
+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);
+}
 

Modified: branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c	2008-11-24 17:48:40 UTC (rev 17559)
+++ branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c	2008-11-24 18:59:59 UTC (rev 17560)
@@ -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 @@
 	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 @@
 
 	/* 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);
-
 }
 

Added: branches/blender2.5/blender/source/blender/editors/space_time/ed_markers.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_time/ed_markers.c	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/space_time/ed_markers.c	2008-11-24 18:59:59 UTC (rev 17560)
@@ -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);
+	}
+	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list