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

Brecht Van Lommel brecht at blender.org
Tue Nov 11 16:18:21 CET 2008


Revision: 17408
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17408
Author:   blendix
Date:     2008-11-11 16:18:21 +0100 (Tue, 11 Nov 2008)

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

Various changes made in the process of working on the UI code:

* Added functions to generate Timer events. There was some unfinished code to
  create one timer per window, this replaces that with a way to let operators
  or other handlers add/remove their own timers as needed. This is currently
  delivered as an event with the timer handle, perhaps this should be a notifier
  instead? Also includes some fixes in ghost for timer events that were not
  delivered in time, due to passing negative timeout.
* Added a Message event, which is a generic event that can be added by any
  operator. This is used in the UI code to communicate the results of opened
  blocks. Again, this may be better as a notifier.
* These two events should not be blocked as they are intended for a specific
  operator or handler, so there were exceptions added for this, which is one
  of the reasons they might work better as notifiers, but currently these
  things can't listen to notifier yet.
* Added an option to events to indicate if the customdata should be freed or
  not.

* Added a free() callback for area regions, and added a free function for
  area regions in blenkernel since it was already there for screens and areas.
* Added ED_screen/area/region_exit functions to clean up things like operators
  and handlers when they are closed.
* Added screen level regions, these will draw over areas boundaries, with the
  last created region on top. These are useful for tooltips, menus, etc, and
  are not saved to file. It's using the same ARegion struct as areas to avoid
  code duplication, but perhaps that should be renamed then. Note that redraws
  currently go correct, because only full window redraws are used, for partial
  redraws without any frontbuffer drawing, the window manager needs to get
  support for compositing subwindows.

* Minor changes in the subwindow code to retrieve the matrix, and moved
  setlinestyle to glutil.c.
* Reversed argument order in WM_event_add/remove_keymap_handler to be consistent
  with modal_handler.

* Operators can now block events but not necessarily cancel/finish.
* Modal operators are now stored in a list in the window/area/region they were
  created in. This means for example that when a transform operator is invoked
  from a region but registers a handler at the window level (since mouse motion
  across areas should work), it will still get removed when the region is closed
  while the operator is running. 

Modified Paths:
--------------
    branches/blender2.5/blender/intern/ghost/GHOST_Types.h
    branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemCarbon.cpp
    branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
    branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemX11.cpp
    branches/blender2.5/blender/source/blender/blenkernel/BKE_screen.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/screen.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/include/BIF_glutil.h
    branches/blender2.5/blender/source/blender/editors/include/ED_screen.h
    branches/blender2.5/blender/source/blender/editors/screen/area.c
    branches/blender2.5/blender/source/blender/editors/screen/glutil.c
    branches/blender2.5/blender/source/blender/editors/screen/screen_edit.c
    branches/blender2.5/blender/source/blender/editors/space_time/space_time.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/space_view3d.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_screen_types.h
    branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h
    branches/blender2.5/blender/source/blender/windowmanager/WM_api.h
    branches/blender2.5/blender/source/blender/windowmanager/WM_types.h
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_event_system.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_files.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_subwindow.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_window.c
    branches/blender2.5/blender/source/blender/windowmanager/wm_event_types.h
    branches/blender2.5/blender/source/blender/windowmanager/wm_subwindow.h

Modified: branches/blender2.5/blender/intern/ghost/GHOST_Types.h
===================================================================
--- branches/blender2.5/blender/intern/ghost/GHOST_Types.h	2008-11-11 15:03:26 UTC (rev 17407)
+++ branches/blender2.5/blender/intern/ghost/GHOST_Types.h	2008-11-11 15:18:21 UTC (rev 17408)
@@ -143,6 +143,8 @@
 	GHOST_kEventWindowSize,
 	GHOST_kEventWindowMove,
 
+	GHOST_kEventTimer,
+
 	GHOST_kNumEventTypes
 } GHOST_TEventType;
 

Modified: branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemCarbon.cpp
===================================================================
--- branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemCarbon.cpp	2008-11-11 15:03:26 UTC (rev 17407)
+++ branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemCarbon.cpp	2008-11-11 15:18:21 UTC (rev 17408)
@@ -423,17 +423,15 @@
 		GHOST_TimerManager* timerMgr = getTimerManager();
 
 		if (waitForEvent) {
-			GHOST_TUns64 curtime = getMilliSeconds();
 			GHOST_TUns64 next = timerMgr->nextFireTime();
 			double timeOut;
 			
 			if (next == GHOST_kFireTimeNever) {
 				timeOut = kEventDurationForever;
 			} else {
-				if (next<=curtime)
+				timeOut = (double)(next - getMilliSeconds())/1000.0;
+				if (timeOut < 0.0)
 					timeOut = 0.0;
-				else
-					timeOut = (double) (next - getMilliSeconds())/1000.0;
 			}
 			
 			::ReceiveNextEvent(0, NULL, timeOut, false, &event);

Modified: branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemWin32.cpp
===================================================================
--- branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemWin32.cpp	2008-11-11 15:03:26 UTC (rev 17407)
+++ branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemWin32.cpp	2008-11-11 15:18:21 UTC (rev 17408)
@@ -190,11 +190,12 @@
 			::Sleep(1);
 #else
 			GHOST_TUns64 next = timerMgr->nextFireTime();
+			GHOST_TInt64 maxSleep = next - getMilliSeconds();
 			
 			if (next == GHOST_kFireTimeNever) {
 				::WaitMessage();
-			} else {
-				::SetTimer(NULL, 0, next - getMilliSeconds(), NULL);
+			} else if(maxSleep >= 0.0) {
+				::SetTimer(NULL, 0, maxSleep, NULL);
 				::WaitMessage();
 				::KillTimer(NULL, 0);
 			}

Modified: branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemX11.cpp
===================================================================
--- branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemX11.cpp	2008-11-11 15:03:26 UTC (rev 17407)
+++ branches/blender2.5/blender/intern/ghost/intern/GHOST_SystemX11.cpp	2008-11-11 15:18:21 UTC (rev 17408)
@@ -309,7 +309,10 @@
 			if (next==GHOST_kFireTimeNever) {
 				SleepTillEvent(m_display, -1);
 			} else {
-				SleepTillEvent(m_display, next - getMilliSeconds());
+				GHOST_TInt64 maxSleep = next - getMilliSeconds();
+
+				if(maxSleep >= 0)
+					SleepTillEvent(m_display, next - getMilliSeconds());
 			}
 		}
 		

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_screen.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_screen.h	2008-11-11 15:03:26 UTC (rev 17407)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_screen.h	2008-11-11 15:18:21 UTC (rev 17408)
@@ -82,10 +82,12 @@
 	void		(*draw)(const struct bContext *, struct ARegion *);		/* draw entirely, windowsize changes should be handled here */
 	
 	void		(*listener)(struct ARegion *, struct wmNotifier *);
+	void		(*free)(struct ARegion *);
 } ARegionType;
 
 
 void BKE_screen_area_free(struct ScrArea *sa);
+void BKE_area_region_free(struct ARegion *ar);
 void free_screen(struct bScreen *sc); 
 
 struct SpaceType *BKE_spacetype_from_id(int spaceid);

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/screen.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/screen.c	2008-11-11 15:03:26 UTC (rev 17407)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/screen.c	2008-11-11 15:18:21 UTC (rev 17408)
@@ -90,11 +90,21 @@
 	}
 }
 
+/* not region itself */
+void BKE_area_region_free(ARegion *ar)
+{
+	if(ar->type && ar->type->free)
+		ar->type->free(ar);
+}
 
 /* not area itself */
 void BKE_screen_area_free(ScrArea *sa)
 {
+	ARegion *ar;
 	
+	for(ar=sa->regionbase.first; ar; ar=ar->next)
+		BKE_area_region_free(ar);
+
 	BKE_spacedata_freelist(&sa->spacedata);
 	
 	BLI_freelistN(&sa->regionbase);

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2008-11-11 15:03:26 UTC (rev 17407)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2008-11-11 15:18:21 UTC (rev 17408)
@@ -3492,6 +3492,7 @@
 		
 		win->queue.first= win->queue.last= NULL;
 		win->handlers.first= win->handlers.last= NULL;
+		win->modalops.first= win->modalops.last= NULL;
 		win->subwindows.first= win->subwindows.last= NULL;
 	}
 	
@@ -3836,7 +3837,8 @@
 	link_list(fd, &(sc->vertbase));
 	link_list(fd, &(sc->edgebase));
 	link_list(fd, &(sc->areabase));
-	
+	sc->regionbase.first= sc->regionbase.last= NULL;
+
 	sc->mainwin= sc->subwinactive= 0;	/* indices */
 	
 	/* hacky patch... but people have been saving files with the verse-blender,
@@ -3875,6 +3877,7 @@
 		link_list(fd, &(sa->regionbase));
 
 		sa->handlers.first= sa->handlers.last= NULL;
+		sa->modalops.first= sa->modalops.last= NULL;
 		sa->uiblocks.first= sa->uiblocks.last= NULL;
 		sa->type= NULL;	/* spacetype callbacks */
 		
@@ -3937,6 +3940,9 @@
 		
 		for(ar= sa->regionbase.first; ar; ar= ar->next) {
 			ar->handlers.first= ar->handlers.last= NULL;
+			ar->modalops.first= ar->modalops.last= NULL;
+			ar->uiblocks.first= ar->uiblocks.last= NULL;
+			ar->regiondata= NULL;
 			ar->swinid= 0;
 			ar->type= NULL;
 		}

Modified: branches/blender2.5/blender/source/blender/editors/include/BIF_glutil.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/BIF_glutil.h	2008-11-11 15:03:26 UTC (rev 17407)
+++ branches/blender2.5/blender/source/blender/editors/include/BIF_glutil.h	2008-11-11 15:18:21 UTC (rev 17408)
@@ -206,6 +206,7 @@
 void bglFlush(void);
 int is_a_really_crappy_intel_card(void);
 void set_inverted_drawing(int enable);
+void setlinestyle(int nr);
 
 
 /* own working polygon offset */

Modified: branches/blender2.5/blender/source/blender/editors/include/ED_screen.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_screen.h	2008-11-11 15:03:26 UTC (rev 17407)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_screen.h	2008-11-11 15:18:21 UTC (rev 17408)
@@ -38,9 +38,11 @@
 struct wmNotifier;
 
 /* regions */
+void	ED_region_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ARegion *ar);
 void	ED_region_do_listen(ARegion *ar, struct wmNotifier *note);
 void	ED_region_do_draw(struct bContext *C, ARegion *ar);
 void	ED_region_do_refresh(struct bContext *C, ARegion *ar);
+void	ED_region_exit(struct bContext *C, ARegion *ar);
 
 /* spaces */
 void	ED_spacetypes_init(void);
@@ -48,6 +50,7 @@
 
 /* areas */
 void	ED_area_initialize(struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa);
+void	ED_area_exit(struct bContext *C, ScrArea *sa);
 
 /* screens */
 void	ED_screens_initialize(struct wmWindowManager *wm);
@@ -58,6 +61,7 @@
 bScreen *ED_screen_duplicate(struct wmWindow *win, bScreen *sc);
 bScreen *ED_screen_riparea(struct wmWindow *win, bScreen *sc, struct ScrArea *sa);
 void	ED_screen_set_subwinactive(struct wmWindow *win);
+void	ED_screen_exit(struct bContext *C, struct wmWindow *window, bScreen *screen);
 
 void	ED_operatortypes_screen(void);
 void	ED_keymap_screen(struct wmWindowManager *wm);

Modified: branches/blender2.5/blender/source/blender/editors/screen/area.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/area.c	2008-11-11 15:03:26 UTC (rev 17407)
+++ branches/blender2.5/blender/source/blender/editors/screen/area.c	2008-11-11 15:18:21 UTC (rev 17408)
@@ -173,6 +173,8 @@
 	
 	/* hidden is user flag */
 	if(ar->flag & RGN_FLAG_HIDDEN);
+	/* XXX floating area region, not handled yet here */
+	else if(ar->alignment == RGN_ALIGN_FLOAT);
 	/* remainder is too small for any usage */
 	else if( rct_fits(remainder, 'v', 1)==0 || rct_fits(remainder, 'h', 1) < 0 ) {
 		ar->flag |= RGN_FLAG_TOO_SMALL;
@@ -189,7 +191,7 @@
 		}
 		else {
 			int fac= rct_fits(remainder, 'v', ar->size);
-			
+
 			if(fac < 0 )
 				ar->size += fac;
 			
@@ -352,6 +354,20 @@
 	}
 }
 
+/* used for area and screen regions */
+void ED_region_initialize(wmWindowManager *wm, wmWindow *win, ARegion *ar)
+{
+	if(ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) {
+		if(ar->swinid)
+			wm_subwindow_close(win, ar->swinid);
+		ar->swinid= 0;
+	}
+	else if(ar->swinid==0)
+		ar->swinid= wm_subwindow_open(win, &ar->winrct);
+	else 
+		wm_subwindow_position(win, ar->swinid, &ar->winrct);
+}
+
 /* called in screen_refresh, or screens_init */
 void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa)
 {
@@ -376,17 +392,8 @@
 	region_rect_recursive(sa->regionbase.first, &rect);
 	
 	/* region windows */
-	for(ar= sa->regionbase.first; ar; ar= ar->next) {
-		if(ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) {
-			if(ar->swinid)
-				wm_subwindow_close(win, ar->swinid);
-			ar->swinid= 0;
-		}
-		else if(ar->swinid==0)
-			ar->swinid= wm_subwindow_open(win, &ar->winrct);
-		else 
-			wm_subwindow_position(win, ar->swinid, &ar->winrct);
-	}
+	for(ar= sa->regionbase.first; ar; ar= ar->next)
+		ED_region_initialize(wm, win, ar);
 	
 	area_azone_initialize(sa);
 }
@@ -435,8 +442,11 @@
 	/* regions */
 	BLI_freelistN(&sa1->regionbase);
 	BLI_duplicatelist(&sa1->regionbase, &sa2->regionbase);
-	for(ar= sa1->regionbase.first; ar; ar= ar->next)
+	for(ar= sa1->regionbase.first; ar; ar= ar->next) {
+		ar->handlers.first= ar->handlers.last= NULL;
+		ar->uiblocks.first= ar->uiblocks.last= NULL;
 		ar->swinid= 0;
+	}
 		
 	/* scripts */
 	BPY_free_scriptlink(&sa1->scriptlink);

Modified: branches/blender2.5/blender/source/blender/editors/screen/glutil.c
===================================================================

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list