[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17906] branches/blender2.5/blender/source /blender: 2.5

Ton Roosendaal ton at blender.org
Wed Dec 17 16:38:41 CET 2008


Revision: 17906
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17906
Author:   ton
Date:     2008-12-17 16:38:40 +0100 (Wed, 17 Dec 2008)

Log Message:
-----------
2.5

- Made a nice generic 'OK confirm' implementation for operators.
  Just use in operator type definition this line:

  ot->invoke= WM_operator_confirm;

  It will autmatically use operator name for asking OK. It will
  also use properties (if set before).

  Note for Brecht: the test okee_operator() you coded could better not
  be used in operators themselves.

  In future we can also add menus that get automatically generated
  based on operator properties. Like 'add constraint' showing the
  constraint types.

- Added this confirm call for most of the keys you'd expect it for.
  (user settings, delete marker, rip area, split region, etc).

- Cleanup: moved ed_markers.c to the util/ directory, it doesnt belong
  in space_time. Also made separate function for the marker keymap
  definition.

- removed ancient redraw notifier from ghost event level (every key
  press gave full screen draw)

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

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/util/ed_markers.c

Removed Paths:
-------------
    branches/blender2.5/blender/source/blender/editors/space_time/ed_markers.c

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_markers.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_markers.h	2008-12-17 10:25:02 UTC (rev 17905)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_markers.h	2008-12-17 15:38:40 UTC (rev 17906)
@@ -34,13 +34,14 @@
 	DRAW_MARKERS_LOCAL	= (1<<1)
 };
 
+struct wmWindowManager;
 
-
 void draw_markers_time(const bContext *C, int flag);
 
-/* register operators, called in ED_operatortypes_screen() */
+/* called in screen_ops.c:ED_operatortypes_screen() */
 void ED_marker_operatortypes(void); 
+/* called in screen_ops.c:ED_keymap_screen() */
+void ED_marker_keymap(struct wmWindowManager *wm);
 
-
 #endif /* ED_MARKERS_H */
 

Modified: branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c	2008-12-17 10:25:02 UTC (rev 17905)
+++ branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c	2008-12-17 15:38:40 UTC (rev 17906)
@@ -271,7 +271,7 @@
 	ot->name= "Rip Area into New Window";
 	ot->idname= "ED_SCR_OT_area_rip";
 	
-	ot->invoke= NULL; //WM_operator_confirm;
+	ot->invoke= WM_operator_confirm;
 	ot->exec= screen_area_rip_op;
 	ot->poll= ED_operator_areaactive;
 }
@@ -1124,6 +1124,7 @@
 	ot->idname= "ED_SCR_OT_repeat_last";
 	
 	/* api callbacks */
+	ot->invoke= WM_operator_confirm;	
 	ot->exec= repeat_last_exec;
 	
 	ot->poll= ED_operator_screenactive;
@@ -1161,6 +1162,7 @@
 	ot->idname= "ED_SCR_OT_region_split";
 	
 	/* api callbacks */
+	ot->invoke= WM_operator_confirm;
 	ot->exec= region_split_exec;
 	ot->poll= ED_operator_areaactive;
 	
@@ -1196,6 +1198,7 @@
 	ot->idname= "ED_SCR_OT_region_flip";
 	
 	/* api callbacks */
+	ot->invoke= WM_operator_confirm;
 	ot->exec= region_flip_exec;
 	
 	ot->poll= ED_operator_areaactive;
@@ -1299,5 +1302,8 @@
 	RNA_enum_set(WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "dir", 'v');
 	WM_keymap_add_item(keymap, "ED_SCR_OT_region_flip", F5KEY, KM_PRESS, 0, 0);
 	WM_keymap_verify_item(keymap, "ED_SCR_OT_repeat_last", F4KEY, KM_PRESS, 0, 0);
+	
+	/* screen level global keymaps */
+	ED_marker_keymap(wm);
 }
 

Deleted: branches/blender2.5/blender/source/blender/editors/space_time/ed_markers.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_time/ed_markers.c	2008-12-17 10:25:02 UTC (rev 17905)
+++ branches/blender2.5/blender/source/blender/editors/space_time/ed_markers.c	2008-12-17 15:38:40 UTC (rev 17906)
@@ -1,847 +0,0 @@
-/**
- * $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 <math.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_userdef_types.h"
-#include "DNA_windowmanager_types.h"
-
-#include "RNA_access.h"
-#include "RNA_define.h"
-
-#include "BLI_blenlib.h"
-
-#include "BKE_global.h"
-#include "BKE_utildefines.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "BIF_gl.h"
-#include "BIF_glutil.h"
-
-#include "UI_interface.h"
-#include "UI_interface_icons.h"
-#include "UI_view2d.h"
-#include "UI_resources.h"
-#include "UI_text.h"
-
-#include "ED_markers.h"
-#include "ED_screen.h"
-#include "ED_types.h"
-#include "ED_util.h"
-
-/* ************* Marker API **************** */
-
-static ListBase *context_get_markers(const bContext *C)
-{
-	
-#if 0
-	/* XXX get them from pose */
-	if ((slink->spacetype == SPACE_ACTION) && (saction->flag & SACTION_POSEMARKERS_MOVE)) {
-		if (saction->action)
-			markers= &saction->action->markers;
-		else
-			markers= NULL;
-	}
-	else
-#endif
-	
-	return &C->scene->markers;
-}
-
-/* ************* 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, 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;
-	}
-	
-	UI_icon_draw(xpos*xscale-5.0, 16.0, icon_id);
-	
-	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) {
-			UI_ThemeColor(TH_TEXT_HI);
-			ui_rasterpos_safe(xpos*xscale+4.0, (ypixels<=39.0)?(ypixels-10.0):29.0, 1.0);
-		}
-		else {
-			UI_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);
-		}
-		UI_DrawString(G.font, marker->name, 0);
-	}
-	glScalef(xscale, 1.0, 1.0);
-}
-
-/* Draw Scene-Markers in time window */
-void draw_markers_time(const bContext *C, int flag)
-{
-	ListBase *markers= context_get_markers(C);
-	View2D *v2d= UI_view2d_fromcontext(C);
-	TimeMarker *marker;
-	
-	/* unselected markers are drawn at the first time */
-	for (marker= 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= markers->first; marker; marker= marker->next) {
-		if (marker->flag & SELECT) draw_marker(v2d, marker, C->scene->r.cfra, flag);
-	}
-}
-
-
-
-/* ************************** add markers *************************** */
-
-/* add TimeMarker at curent frame */
-static int ed_marker_add(bContext *C, wmOperator *op)
-{
-	ListBase *markers= context_get_markers(C);
-	TimeMarker *marker;
-	int frame= C->scene->r.cfra;
-	
-	/* two markers can't be at the same place */
-	for(marker= markers->first; marker; marker= marker->next)
-		if(marker->frame == frame) 
-			return OPERATOR_CANCELLED;
-	
-	/* deselect all */
-	for(marker= markers->first; marker; marker= marker->next)
-		marker->flag &= ~SELECT;
-	
-	marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
-	marker->flag= SELECT;
-	marker->frame= frame;
-	sprintf(marker->name, "Frame %d", frame); // XXX - temp code only
-	BLI_addtail(markers, marker);
-	
-	//BIF_undo_push("Add Marker");
-	
-	return OPERATOR_FINISHED;
-}
-
-static 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;
-	ot->poll= ED_operator_areaactive;
-	
-}
-
-/* ************************** transform markers *************************** */
-
-
-/* operator state vars used:  
-	frs: delta movement
-
-functions:
-
-	init()   check selection, add customdata with old values and some lookups
-
-	apply()  do the actual movement
-
-	exit()	cleanup, send notifier
-
-    cancel() to escpae from modal
-
-callbacks:
-
-	exec()	calls init, apply, exit 
-
-	invoke() calls init, adds modal handler
-
-	modal()	accept modal events while doing it, ends with apply and exit, or cancel
-
-*/
-
-typedef struct MarkerMove {
-	SpaceLink *slink;
-	ListBase *markers;
-	int event_type;		/* store invoke-event, to verify */
-	int *oldframe, evtx, firstx;
-} MarkerMove;
-
-/* copy selection to temp buffer */
-/* return 0 if not OK */
-static int ed_marker_move_init(bContext *C, wmOperator *op)
-{
-	ListBase *markers= context_get_markers(C);
-	MarkerMove *mm;
-	TimeMarker *marker;
-	int totmark=0;
-	int a;
-	
-	for (marker= markers->first; marker; marker= marker->next)
-		if (marker->flag & SELECT) totmark++;
-	
-	if (totmark==0) return 0;
-	
-	op->customdata= mm= MEM_callocN(sizeof(MarkerMove), "Markermove");
-	mm->slink= C->area->spacedata.first;
-	mm->markers= markers;
-	mm->oldframe= MEM_callocN(totmark*sizeof(int), "MarkerMove oldframe");
-	
-	for (a=0, marker= markers->first; marker; marker= marker->next) {
-		if (marker->flag & SELECT) {
-			mm->oldframe[a]= marker->frame;
-			a++;
-		}
-	}
-	
-	return 1;
-}
-
-/* free stuff */
-static void ed_marker_move_exit(bContext *C, wmOperator *op)
-{
-	MarkerMove *mm= op->customdata;
-	
-	MEM_freeN(mm->oldframe);
-	MEM_freeN(op->customdata);
-	op->customdata= NULL;
-}
-
-static int ed_marker_move_invoke(bContext *C, wmOperator *op, wmEvent *evt)
-{
-	if(ed_marker_move_init(C, op)) {
-		MarkerMove *mm= op->customdata;
-		
-		mm->evtx= evt->x;
-		mm->firstx= evt->x;
-		mm->event_type= evt->type;
-		
-		/* add temp handler */
-		WM_event_add_modal_handler(C, &C->window->handlers, op);
-		
-		/* reset frs delta */
-		RNA_int_set(op->ptr, "frs", 0);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list