[beryl-commits] r2286 - branches/beryl-plugins/group-tabbed

maniac at server.beryl-project.org maniac at server.beryl-project.org
Tue Jan 2 18:54:41 CET 2007


Author: maniac
Date: 2007-01-02 17:54:39 +0000 (Tue, 02 Jan 2007)
New Revision: 2286

Modified:
   branches/beryl-plugins/group-tabbed/group.c
   branches/beryl-plugins/group-tabbed/group.h
   branches/beryl-plugins/group-tabbed/option.c
   branches/beryl-plugins/group-tabbed/paint.c
   branches/beryl-plugins/group-tabbed/tab.c
Log:
group-tab-branch:
- use change tab animation time instead of steps
- use states for change tab animation
- thus rename TabBarState to PaintState
- roico, please fix the first part of animation ;-)


Modified: branches/beryl-plugins/group-tabbed/group.c
===================================================================
--- branches/beryl-plugins/group-tabbed/group.c	2007-01-02 16:47:35 UTC (rev 2285)
+++ branches/beryl-plugins/group-tabbed/group.c	2007-01-02 17:54:39 UTC (rev 2286)
@@ -252,7 +252,8 @@
 		g->topTab = NULL;
 		g->prevTopTab = NULL;
 		g->nextTopTab = NULL;
-		g->changeAnimationSteps = 0;
+		g->changeAnimationTime = 0.0f;
+		g->state = PaintOff;
 		g->animationSteps = 0;
 		g->ungroup = FALSE;
 		g->changeTab = FALSE;
@@ -552,8 +553,8 @@
 			if(!gw->slot || !gw->group || !gw->group->tabBar)
 				break;
 
-			if(gw->group->tabBar->state != TabBarOn &&
-				gw->group->tabBar->state != TabBarPermanentOn)
+			if(gw->group->tabBar->state != PaintOn &&
+				gw->group->tabBar->state != PaintPermanentOn)
 				break;
 
 			if(!XPointInRegion(gw->group->tabBar->region, d->pointerX, d->pointerY))
@@ -573,8 +574,8 @@
 			if(!gw->slot || !gw->group || !gw->group->tabBar)
 				break;
 
-			if(gw->group->tabBar->state != TabBarOn &&
-				gw->group->tabBar->state != TabBarPermanentOn)
+			if(gw->group->tabBar->state != PaintOn &&
+				gw->group->tabBar->state != PaintPermanentOn)
 				break;
 
 			if(!XPointInRegion(gw->group->tabBar->region, d->pointerX, d->pointerY))

Modified: branches/beryl-plugins/group-tabbed/group.h
===================================================================
--- branches/beryl-plugins/group-tabbed/group.h	2007-01-02 16:47:35 UTC (rev 2285)
+++ branches/beryl-plugins/group-tabbed/group.h	2007-01-02 17:54:39 UTC (rev 2286)
@@ -88,7 +88,7 @@
 #define GROUP_SCREEN_OPTION_TABBAR_FONTSIZE		25
 #define GROUP_SCREEN_OPTION_TABBAR_FONTCOLOR		26
 #define GROUP_SCREEN_OPTION_TAB_CREATE_MIPMAPS		27
-#define GROUP_SCREEN_OPTION_CHANGE_ANIMATION_STEPS	28
+#define GROUP_SCREEN_OPTION_CHANGE_ANIMATION_TIME	28
 #define GROUP_SCREEN_OPTION_NUM				29
 
 /*
@@ -230,12 +230,12 @@
  */
 
 typedef enum {
-	TabBarOff = 0,
-	TabBarFadeIn,
-	TabBarFadeOut,
-	TabBarOn,
-	TabBarPermanentOn
-} TabBarState;
+	PaintOff = 0,
+	PaintFadeIn,
+	PaintFadeOut,
+	PaintOn,
+	PaintPermanentOn
+} PaintState;
 
 typedef struct _GroupTabBar {
 	GroupTabBarSlot		*slots;
@@ -248,7 +248,7 @@
 	GroupCairoContext *cc;
 
 	Bool			mouseOver;
-	TabBarState		state;
+	PaintState		state;
 	int				timeoutHandle;
 	int				animationTime;
 	Region			region;
@@ -291,10 +291,12 @@
 					//If the tab was changed again during animation,
 					//Another animation should be started again, switching for this window.
 
-	int changeAnimationSteps;
+	int changeAnimationTime;
 
 	GroupTabBar *tabBar;
+
 	int animationSteps;
+	PaintState state;
 
 	Bool	ungroup;
 	Bool	changeTab;

Modified: branches/beryl-plugins/group-tabbed/option.c
===================================================================
--- branches/beryl-plugins/group-tabbed/option.c	2007-01-02 16:47:35 UTC (rev 2285)
+++ branches/beryl-plugins/group-tabbed/option.c	2007-01-02 17:54:39 UTC (rev 2286)
@@ -80,10 +80,6 @@
 #define GROUP_TABBAR_FONTSIZE_MIN	6
 #define GROUP_TABBAR_FONTSIZE_MAX	24
 
-#define GROUP_CHANGE_ANIMATION_STEPS_DEFAULT	20
-#define GROUP_CHANGE_ANIMATION_STEPS_MIN	1
-#define GROUP_CHANGE_ANIMATION_STEPS_MAX	500
-
 #define GROUP_MOVE_DEFAULT			TRUE
 #define GROUP_RESIZE_DEFAULT			TRUE
 #define GROUP_RAISE_DEFAULT			TRUE
@@ -126,6 +122,11 @@
 #define GROUP_FADE_TIME_PRECISION	0.1f
 #define GROUP_FADE_TIME_DEFAULT		0.5f
 
+#define GROUP_CHANGE_ANIMATION_TIME_DEFAULT	1.0f
+#define GROUP_CHANGE_ANIMATION_TIME_MIN		0.0f
+#define GROUP_CHANGE_ANIMATION_TIME_MAX		5.0f
+#define GROUP_CHANGE_ANIMATION_TIME_PRECISION	0.1f
+
 #define GROUP_VISIBILITY_TIME_MIN		0.0f
 #define GROUP_VISIBILITY_TIME_MAX		10.0f
 #define GROUP_VISIBILITY_TIME_PRECISION		0.1f
@@ -527,19 +528,20 @@
 	o->type = CompOptionTypeBool;
 	o->value.b = GROUP_UNTAB_ON_CLOSE_DEFAULT;
 	
-	o = &gs->opt[GROUP_SCREEN_OPTION_CHANGE_ANIMATION_STEPS];
-	o->name = "change_animation_steps";
+	o = &gs->opt[GROUP_SCREEN_OPTION_CHANGE_ANIMATION_TIME];
+	o->name = "change_animation_time";
 	o->group = N_("Tabbing");
 	o->subGroup = N_("Options");
 	o->displayHints = "";
 	o->advanced = False;
-	o->shortDesc = N_("Change Tab Animation Steps");
+	o->shortDesc = N_("Change Tab Animation Duration");
 	o->longDesc =
-	    N_("The animation steps that are needed for the animation that happens when changing tabs.");
-	o->type = CompOptionTypeInt;
-	o->value.i = GROUP_CHANGE_ANIMATION_STEPS_DEFAULT;
-	o->rest.i.min = GROUP_CHANGE_ANIMATION_STEPS_MIN;
-	o->rest.i.max = GROUP_CHANGE_ANIMATION_STEPS_MAX;
+	    N_("The duration (in s) of the animation that happens when changing tabs.");
+	o->type = CompOptionTypeFloat;
+	o->value.f = GROUP_CHANGE_ANIMATION_TIME_DEFAULT;
+	o->rest.f.min = GROUP_CHANGE_ANIMATION_TIME_MIN;
+	o->rest.f.max = GROUP_CHANGE_ANIMATION_TIME_MAX;
+	o->rest.f.precision = GROUP_CHANGE_ANIMATION_TIME_PRECISION;
 }
 
 /*
@@ -643,7 +645,6 @@
 	case GROUP_SCREEN_OPTION_THUMB_SIZE:
 	case GROUP_SCREEN_OPTION_BORDER_WIDTH:
 	case GROUP_SCREEN_OPTION_BORDER_RADIUS:
-	case GROUP_SCREEN_OPTION_CHANGE_ANIMATION_STEPS:
 		if (compSetIntOption(o, value)) {
 			return TRUE;
 		}
@@ -661,6 +662,7 @@
 
 	case GROUP_SCREEN_OPTION_FADE_TIME:
 	case GROUP_SCREEN_OPTION_VISIBILITY_TIME:
+	case GROUP_SCREEN_OPTION_CHANGE_ANIMATION_TIME:
 		if (compSetFloatOption(o, value)) {
 			return TRUE;
 		}

Modified: branches/beryl-plugins/group-tabbed/paint.c
===================================================================
--- branches/beryl-plugins/group-tabbed/paint.c	2007-01-02 16:47:35 UTC (rev 2285)
+++ branches/beryl-plugins/group-tabbed/paint.c	2007-01-02 17:54:39 UTC (rev 2286)
@@ -65,10 +65,10 @@
 	WindowPaintAttrib sAttrib = w->lastPaint;
 
 	// animate fade
-	if (group->tabBar->state == TabBarFadeIn)
+	if (group->tabBar->state == PaintFadeIn)
 		sAttrib.opacity -= sAttrib.opacity * group->tabBar->animationTime / 
 				   (gs->opt[GROUP_SCREEN_OPTION_FADE_TIME].value.f * 1000);
-	else if (group->tabBar->state == TabBarFadeOut)
+	else if (group->tabBar->state == PaintFadeOut)
 		sAttrib.opacity = sAttrib.opacity * group->tabBar->animationTime / 
 				  (gs->opt[GROUP_SCREEN_OPTION_FADE_TIME].value.f * 1000);
 
@@ -216,7 +216,7 @@
  */
 void groupPaintTabBar(GroupSelection * group)
 {
-	if (!group->topTab || (group->tabBar->state == TabBarOff))
+	if (!group->topTab || (group->tabBar->state == PaintOff))
 		return;
 
 	CompWindow *topTab = TOP_TAB(group);
@@ -239,7 +239,7 @@
 	int alpha_line = gs->opt[GROUP_SCREEN_OPTION_TAB_BORDER_COLOR].value.c[3];
 	int alpha_line_selection = group->color[3];
 	
-	if (group->tabBar->state == TabBarFadeIn) {
+	if (group->tabBar->state == PaintFadeIn) {
 		alpha_fill -= alpha_fill * group->tabBar->animationTime / 
 			      (gs->opt[GROUP_SCREEN_OPTION_FADE_TIME].value.f * 1000);
 		alpha_fill_selection -= alpha_fill_selection * group->tabBar->animationTime / 
@@ -248,7 +248,7 @@
 			      (gs->opt[GROUP_SCREEN_OPTION_FADE_TIME].value.f * 1000);
 		alpha_line_selection -= alpha_line_selection * group->tabBar->animationTime / 
 			      (gs->opt[GROUP_SCREEN_OPTION_FADE_TIME].value.f * 1000);
-	} else if (group->tabBar->state == TabBarFadeOut) {
+	} else if (group->tabBar->state == PaintFadeOut) {
 		alpha_fill  = alpha_fill * group->tabBar->animationTime / 
 			      (gs->opt[GROUP_SCREEN_OPTION_FADE_TIME].value.f * 1000);
 		alpha_fill_selection  = alpha_fill_selection * group->tabBar->animationTime / 
@@ -429,21 +429,27 @@
 
 	for(group = gd->groups; group; group = group->next)
 	{
+		if (group->state != PaintOff) {
+			group->changeAnimationTime -= msSinceLastPaint;
+			if (group->changeAnimationTime < 0)
+				group->changeAnimationTime = 0;
+		}
+
 		if(!group->tabBar || !group->topTab)
 			continue;
 
-		if (((group->tabBar->state == TabBarFadeIn) || 
-		     (group->tabBar->state == TabBarFadeOut)) &&
+		if (((group->tabBar->state == PaintFadeIn) || 
+		     (group->tabBar->state == PaintFadeOut)) &&
 		    group->tabBar->animationTime > 0) {
 			group->tabBar->animationTime -= msSinceLastPaint;
 			if (group->tabBar->animationTime < 0)
 				group->tabBar->animationTime = 0;
 
 			if (group->tabBar->animationTime == 0) {
-				if (group->tabBar->state == TabBarFadeIn)
-					group->tabBar->state = TabBarOn;
-				else if (group->tabBar->state == TabBarFadeOut)
-					group->tabBar->state = TabBarOff;
+				if (group->tabBar->state == PaintFadeIn)
+					group->tabBar->state = PaintOn;
+				else if (group->tabBar->state == PaintFadeOut)
+					group->tabBar->state = PaintOff;
 			}
 		}
 	}
@@ -537,7 +543,7 @@
 		if(!group->tabBar || !group->topTab)
 			continue;
 
-		if (group->tabBar->state != TabBarOff) {
+		if (group->tabBar->state != PaintOff) {
 			damageScreenRegion(s, group->tabBar->region);
 		}
 	}
@@ -777,14 +783,10 @@
 
 	status = (*w->screen->drawWindow) (w, attrib, region, mask);
 
-	if ((gw->group && gw->group->tabBar && gw->group->topTab &&	//Sorry for the longest if ever.
-	   TOP_TAB(gw->group)->id == w->id &&
-	   (gw->group->changeAnimationSteps == 0 || 
-	   gw->group->changeAnimationSteps < gs->opt[GROUP_SCREEN_OPTION_CHANGE_ANIMATION_STEPS].value.i / 2))
-	   ||
+	if ((gw->group && gw->group->tabBar && gw->group->topTab && (TOP_TAB(gw->group)->id == w->id) && 
+	   ((gw->group->state == PaintOff) || (gw->group->state == PaintFadeOut))) ||
 	   (gw->group && gw->group->tabBar && gw->group->prevTopTab &&
-	   PREV_TOP_TAB(gw->group)->id == w->id &&
-	   gw->group->changeAnimationSteps > gs->opt[GROUP_SCREEN_OPTION_CHANGE_ANIMATION_STEPS].value.i / 2))
+	   PREV_TOP_TAB(gw->group)->id == w->id && (gw->group->state == PaintFadeIn)))
 	    	groupPaintTabBar(gw->group);
 
 	WRAP(gs, w->screen, drawWindow, groupDrawWindow);
@@ -808,10 +810,8 @@
 	WindowPaintAttrib gAttrib = *attrib;
 
 	if (gw->group && gw->group->tabBar && gw->group->topTab &&
-		!gw->group->animationSteps &&
-		TOP_TAB(gw->group)->id != w->id && 
-		!(gw->group->changeAnimationSteps &&
-		  	PREV_TOP_TAB(gw->group)->id == w->id) ) {
+		!gw->group->animationSteps && TOP_TAB(gw->group)->id != w->id && 
+		!(gw->group->state != PaintOff && PREV_TOP_TAB(gw->group)->id == w->id) ) {
 
 		return TRUE;
 	}
@@ -830,24 +830,27 @@
 		gAttrib.brightness = brightness;
 	}
 	
-	if(gw->group && gw->group->changeAnimationSteps &&
+	if(gw->group && (gw->group->state != PaintOff) &&
 	    (w->id == TOP_TAB(gw->group)->id || w->id == PREV_TOP_TAB(gw->group)->id))
 	{
+		float rotateAngle;
+
+		rotateAngle = gw->group->changeAnimationTime * 180.0f / (gs->opt[GROUP_SCREEN_OPTION_CHANGE_ANIMATION_TIME].value.f * 1000.0f);
 		glPushMatrix();
 		
 		glScalef(1.0f, 1.0f, 1.0f / w->screen->width);
 		
-		if(w->id == TOP_TAB(gw->group)->id)
+		if (w->id == TOP_TAB(gw->group)->id)
 		{
 			glTranslatef(WIN_X(TOP_TAB(gw->group)) + WIN_WIDTH(TOP_TAB(gw->group))/2.0f, 0.0f, 0.0f);
-			glRotatef(gw->group->changeAnimationSteps * 180.0f / gs->opt[GROUP_SCREEN_OPTION_CHANGE_ANIMATION_STEPS].value.i, 0.0f, 1.0f, 0.0f);
+			glRotatef(rotateAngle, 0.0f, 1.0f, 0.0f);
 			glTranslatef(-WIN_X(TOP_TAB(gw->group)) - WIN_WIDTH(TOP_TAB(gw->group))/2.0f, 0.0f, 0.0f);
 		}
 		
 		else
 		{
 			glTranslatef(WIN_X(PREV_TOP_TAB(gw->group)) + WIN_WIDTH(PREV_TOP_TAB(gw->group))/2, 0.0f, 0.0f);
-			glRotatef(180.0f + gw->group->changeAnimationSteps * 180.0f / gs->opt[GROUP_SCREEN_OPTION_CHANGE_ANIMATION_STEPS].value.i, 0.0f, 1.0f, 0.0f);
+			glRotatef(180.0f + rotateAngle, 0.0f, 1.0f, 0.0f);
 			glTranslatef(-WIN_X(PREV_TOP_TAB(gw->group)) - WIN_WIDTH(PREV_TOP_TAB(gw->group))/2.0f, 0.0f, 0.0f);
 		}
 	}
@@ -856,7 +859,7 @@
 	status = (*w->screen->paintWindow) (w, &gAttrib, region, mask);
 	WRAP(gs, w->screen, paintWindow, groupPaintWindow);
 	
-	if(gw->group && gw->group->changeAnimationSteps &&
+	if(gw->group && (gw->group->state != PaintOff) &&
 	    (w->id == TOP_TAB(gw->group)->id || w->id == PREV_TOP_TAB(gw->group)->id))
 	{
 		addWindowDamage(w);

Modified: branches/beryl-plugins/group-tabbed/tab.c
===================================================================
--- branches/beryl-plugins/group-tabbed/tab.c	2007-01-02 16:47:35 UTC (rev 2285)
+++ branches/beryl-plugins/group-tabbed/tab.c	2007-01-02 17:54:39 UTC (rev 2286)
@@ -76,9 +76,9 @@
 	GroupSelection *group = (GroupSelection *)data;
 
 	if (group->tabBar->mouseOver) {
-		group->tabBar->state = TabBarOn;
+		group->tabBar->state = PaintOn;
 	} else {
-		group->tabBar->state = TabBarFadeOut;
+		group->tabBar->state = PaintFadeOut;
 		
 		if(group->inputPrevention.id)
 			groupSwitchTopTabInput(group, TRUE);
@@ -98,16 +98,16 @@
 {
 	GroupTabBar *bar = group->tabBar;
 	GROUP_SCREEN(group->windows[0]->screen);
-	TabBarState oldState;
+	PaintState oldState;
 	
 	if(!bar)
 		return;
 
-	if (bar->state == TabBarPermanentOn)
+	if (bar->state == PaintPermanentOn)
 		return;
 
 	if (mask & KEEP_BAR_VISIBILITY_MASK) {
-		bar->state = TabBarPermanentOn;
+		bar->state = PaintPermanentOn;
 		bar->animationTime = gs->opt[GROUP_SCREEN_OPTION_FADE_TIME].value.f * 1000;
 		
 		if (bar->timeoutHandle)
@@ -124,17 +124,17 @@
 	
 	oldState = bar->state;
 
-	if (visible) {
-		if (bar->state == TabBarOff)
-			bar->state = TabBarFadeIn;	
-		else if (bar->state == TabBarFadeOut)
-			bar->state = TabBarFadeIn;
-	} else {
-		if (bar->state == TabBarOn)
-			bar->state = TabBarFadeOut;
-		else if (bar->state == TabBarFadeIn)
-			bar->state = TabBarFadeOut;
-	}
+ 	if (visible) {
+		if (bar->state == PaintOff)
+			bar->state = PaintFadeIn;	
+		else if (bar->state == PaintFadeOut)
+			bar->state = PaintFadeIn;
+ 	} else {
+		if (bar->state == PaintOn)
+			bar->state = PaintFadeOut;
+		else if (bar->state == PaintFadeIn)
+			bar->state = PaintFadeOut;
+ 	}
 
 	if (bar->state != oldState)
 		bar->animationTime = (gs->opt[GROUP_SCREEN_OPTION_FADE_TIME].value.f * 1000) - 
@@ -202,7 +202,8 @@
 				groupDeleteTabBar(group);
 				groupDestroyInputPreventionWindow(group);
 				
-				group->changeAnimationSteps = 0;
+				group->changeAnimationTime = 0;
+				group->state = PaintOff;
 				group->nextTopTab = NULL;
 
 				group->changeTab = FALSE;
@@ -264,20 +265,20 @@
 
 				activateWindow (topTab);
 				
-				if(group->prevTopTab)
-					group->changeAnimationSteps = gs->opt[GROUP_SCREEN_OPTION_CHANGE_ANIMATION_STEPS].value.i;
-				
-				else	//No window to do animation with.
+				if(group->prevTopTab) {
+					//we use only the half time here - the second half will be PaintFadeOut
+					group->changeAnimationTime = gs->opt[GROUP_SCREEN_OPTION_CHANGE_ANIMATION_TIME].value.f * 500;
+					printf("set animation time to %d\n", group->changeAnimationTime);
+					group->state = PaintFadeIn;
+				} else	//No window to do animation with.
 					group->prevTopTab = group->topTab;
 				
 				group->changeTab = FALSE;
 			}
 			
-			if(group->changeAnimationSteps)
+			if(group->state != PaintOff)
 			{
-				group->changeAnimationSteps--;
-				
-				if(group->changeAnimationSteps == 0)
+				if(group->state == PaintFadeOut && !group->changeAnimationTime)
 				{				
 					if(group->prevTopTab)
 					{
@@ -296,9 +297,10 @@
 						groupChangeTab(group->nextTopTab);
 						group->nextTopTab = NULL;
 					}
+
+					group->state = PaintOff;
 				}
-				
-				else if(group->changeAnimationSteps == gs->opt[GROUP_SCREEN_OPTION_CHANGE_ANIMATION_STEPS].value.i / 2)
+				else if(group->state == PaintFadeIn && !group->changeAnimationTime)
 				{
 					// recalc here is needed (for y value)!
 					groupRecalcTabBarPos(group, (group->tabBar->region->extents.x1 + group->tabBar->region->extents.x2) / 2,
@@ -309,9 +311,11 @@
 						groupTabSetVisibility (group, TRUE, 
 							SHOW_BAR_INSTANTLY_MASK | KEEP_BAR_VISIBILITY_MASK);
 					}
-					
 					else
 						groupUpdateInputPreventionWindow(group);
+
+					group->state = PaintFadeOut;
+					group->changeAnimationTime = gs->opt[GROUP_SCREEN_OPTION_CHANGE_ANIMATION_TIME].value.f * 500;
 				}
 				
 				addWindowDamage(TOP_TAB(group));
@@ -404,10 +408,10 @@
 
 		bar->mouseOver = XPointInRegion(&reg, mouseX, mouseY);
 		
-		if (bar->state != TabBarOff)
+		if (bar->state != PaintOff)
 			bar->mouseOver |= XPointInRegion(bar->region, mouseX, mouseY);
 		
-		if(bar->state == TabBarOff && bar->mouseOver) {
+		if(bar->state == PaintOff && bar->mouseOver) {
 			groupRecalcTabBarPos(group, mouseX, WIN_REAL_X(topTab), 
 				WIN_REAL_X(topTab) + WIN_REAL_WIDTH(topTab));
 			addWindowDamage(topTab);
@@ -573,7 +577,7 @@
 		gw->group->oldTopTabCenterY = WIN_Y(PREV_TOP_TAB(gw->group)) + WIN_HEIGHT(PREV_TOP_TAB(gw->group))/2;
 	}
 	
-	if(gw->group->changeAnimationSteps)
+	if(gw->group->state != PaintOff)
 		gw->group->nextTopTab = topTab;
 	
 	else
@@ -965,7 +969,7 @@
 	bar->slots = NULL;
 	bar->nSlots = 0;
 	bar->draggedSlot = NULL;
-	bar->state = TabBarOff;
+	bar->state = PaintOff;
 	bar->mouseOver = FALSE;
 	bar->animationTime = 0;
 	bar->timeoutHandle = 0;




More information about the commits mailing list