[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20295] branches/blender2.5/blender: UI: added support for enable buttons in the panel header.

Brecht Van Lommel brecht at blender.org
Wed May 20 16:46:50 CEST 2009


Revision: 20295
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20295
Author:   blendix
Date:     2009-05-20 16:46:49 +0200 (Wed, 20 May 2009)

Log Message:
-----------
UI: added support for enable buttons in the panel header.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_material.py
    branches/blender2.5/blender/release/ui/buttons_scene.py
    branches/blender2.5/blender/release/ui/buttons_world.py
    branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c
    branches/blender2.5/blender/source/blender/editors/screen/area.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_screen_types.h

Modified: branches/blender2.5/blender/release/ui/buttons_material.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_material.py	2009-05-20 14:32:15 UTC (rev 20294)
+++ branches/blender2.5/blender/release/ui/buttons_material.py	2009-05-20 14:46:49 UTC (rev 20295)
@@ -36,16 +36,17 @@
 	def poll(self, context):
 		ob = context.active_object
 		return (ob and ob.active_material and ob.active_material.type == "SURFACE")
+
+	def draw_header(self, context):
+		sss = context.active_object.active_material.subsurface_scattering
+
+		layout = self.layout
+		layout.itemR(sss, "enabled", text="")
 	
 	def draw(self, context):
 		layout = self.layout
 		sss = context.active_object.active_material.subsurface_scattering
 		
-		if not sss:
-			return
-		
-		layout.itemR(sss, "enabled", text="Enable")
-		
 		flow = layout.column_flow()
 		flow.itemR(sss, "error_tolerance")
 		flow.itemR(sss, "ior")
@@ -73,7 +74,7 @@
 		raym = context.active_object.active_material.raytrace_mirror
 
 		layout = self.layout
-		layout.itemR(raym, "enabled", text=self.__label__)
+		layout.itemR(raym, "enabled", text="")
 	
 	def draw(self, context):
 		layout = self.layout
@@ -105,11 +106,15 @@
 		ob = context.active_object
 		return (ob and ob.active_material and ob.active_material.type == "SURFACE")
 
+	def draw_header(self, context):
+		rayt = context.active_object.active_material.raytrace_transparency
+
+		layout = self.layout
+		layout.itemR(rayt, "enabled", text="")
+
 	def draw(self, context):
 		layout = self.layout
 		rayt = context.active_object.active_material.raytrace_transparency
-
-		layout.itemR(rayt, "enabled", text="Enable")
 		
 		split = layout.split()
 		

Modified: branches/blender2.5/blender/release/ui/buttons_scene.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_scene.py	2009-05-20 14:32:15 UTC (rev 20294)
+++ branches/blender2.5/blender/release/ui/buttons_scene.py	2009-05-20 14:46:49 UTC (rev 20295)
@@ -70,28 +70,30 @@
 class RENDER_PT_antialiasing(RenderButtonsPanel):
 	__label__ = "Anti-Aliasing"
 
+	def draw_header(self, context):
+		rd = context.scene.render_data
+
+		layout = self.layout
+		layout.itemR(rd, "antialiasing", text="")
+
 	def draw(self, context):
 		scene = context.scene
 		layout = self.layout
 
 		rd = scene.render_data
 
-		row = layout.row()
-		row.itemR(rd, "antialiasing", text="Enable")
+		split = layout.split()
+		
+		sub = split.column()
+		sub.itemL(text="Samples:")
+		sub.row().itemR(rd, "antialiasing_samples", expand=True)
 
-		if rd.antialiasing:
-			split = layout.split()
-			
-			sub = split.column()
-			sub.itemL(text="Samples:")
-			sub.row().itemR(rd, "antialiasing_samples", expand=True)
-	
-			sub = split.column()
-			sub.itemR(rd, "pixel_filter")
-			sub.itemR(rd, "filter_size", text="Size")
-			sub.itemR(rd, "save_buffers")
-			if rd.save_buffers:
-				sub.itemR(rd, "full_sample")
+		sub = split.column()
+		sub.itemR(rd, "pixel_filter")
+		sub.itemR(rd, "filter_size", text="Size")
+		sub.itemR(rd, "save_buffers")
+		if rd.save_buffers:
+			sub.itemR(rd, "full_sample")
 
 class RENDER_PT_render(RenderButtonsPanel):
 	__label__ = "Render"
@@ -172,4 +174,4 @@
 bpy.types.register(RENDER_PT_dimensions)
 bpy.types.register(RENDER_PT_antialiasing)
 bpy.types.register(RENDER_PT_shading)
-bpy.types.register(RENDER_PT_output)
\ No newline at end of file
+bpy.types.register(RENDER_PT_output)

Modified: branches/blender2.5/blender/release/ui/buttons_world.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_world.py	2009-05-20 14:32:15 UTC (rev 20294)
+++ branches/blender2.5/blender/release/ui/buttons_world.py	2009-05-20 14:46:49 UTC (rev 20295)
@@ -40,13 +40,16 @@
 class WORLD_PT_mist(WorldButtonsPanel):
 	__label__ = "Mist"
 
+	def draw_header(self, context):
+		world = context.scene.world
+
+		layout = self.layout
+		layout.itemR(world.mist, "enabled", text="")
+
 	def draw(self, context):
 		world = context.scene.world
 		layout = self.layout
 
-		row = layout.row()
-		row.itemR(world.mist, "enabled", text="Enable")
-
 		flow = layout.column_flow()
 		flow.itemR(world.mist, "start")
 		flow.itemR(world.mist, "depth")
@@ -59,13 +62,16 @@
 class WORLD_PT_stars(WorldButtonsPanel):
 	__label__ = "Stars"
 
+	def draw_header(self, context):
+		world = context.scene.world
+
+		layout = self.layout
+		layout.itemR(world.stars, "enabled", text="")
+
 	def draw(self, context):
 		world = context.scene.world
 		layout = self.layout
 
-		row = layout.row()
-		row.itemR(world.stars, "enabled", text="Enable")
-
 		flow = layout.column_flow()
 		flow.itemR(world.stars, "size")
 		flow.itemR(world.stars, "min_distance", text="Min. Dist")
@@ -75,6 +81,12 @@
 class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
 	__label__ = "Ambient Occlusion"
 
+	def draw_header(self, context):
+		world = context.scene.world
+
+		layout = self.layout
+		layout.itemR(world.ambient_occlusion, "enabled", text="")
+
 	def draw(self, context):
 		world = context.scene.world
 		layout = self.layout
@@ -82,8 +94,6 @@
 		ao = world.ambient_occlusion
 		
 		row = layout.row()
-		row.itemR(ao, "enabled", text="Enable")
-		row = layout.row()
 		row.itemR(ao, "gather_method", expand=True)
 		
 		if ao.gather_method == 'RAYTRACE':

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c	2009-05-20 14:32:15 UTC (rev 20294)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_panel.c	2009-05-20 14:46:49 UTC (rev 20295)
@@ -297,16 +297,16 @@
 {
 	uiStyle *style= U.uistyles.first;
 	uiBut *but;
-	int space= style->panelspace;
+	int ofsy;
 
-	/* buttons min/max centered, offset calculated */
+	/* compute bounds and offset */
 	ui_bounds_block(block);
 
+	ofsy= block->panel->sizey - style->panelspace;
+
 	for(but= block->buttons.first; but; but=but->next) {
-		but->x1= space + (but->x1-block->minx);
-		but->y1= space + (but->y1-block->miny);
-		but->x2= space + (but->x2-block->minx);
-		but->y2= space + (but->y2-block->miny);
+		but->y1 += ofsy;
+		but->y2 += ofsy;
 	}
 
 	block->maxx= block->panel->sizex;
@@ -453,6 +453,8 @@
 	/* + 0.001f to avoid flirting with float inaccuracy */
 	if(panel->control & UI_PNL_CLOSE) pnl_icons=(2*PNL_ICON+5)/block->aspect + 0.001f;
 	else pnl_icons= (PNL_ICON+5)/block->aspect + 0.001f;
+
+	pnl_icons += panel->labelofs;
 	
 	if(nr==1) {
 		
@@ -831,7 +833,7 @@
 	uiBlock *block;
 	Panel *panot, *panew, *patest, *pa;
 	
-	/* scaling contents */
+	/* offset contents */
 	for(block= ar->uiblocks.first; block; block= block->next)
 		if(block->active && block->panel)
 			ui_offset_panel_block(block);

Modified: branches/blender2.5/blender/source/blender/editors/screen/area.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/area.c	2009-05-20 14:32:15 UTC (rev 20294)
+++ branches/blender2.5/blender/source/blender/editors/screen/area.c	2009-05-20 14:46:49 UTC (rev 20295)
@@ -968,7 +968,7 @@
 	Panel *panel;
 	View2D *v2d= &ar->v2d;
 	float col[3];
-	int xco, yco, x, y, miny=0, w, em, header, open;
+	int xco, yco, x, y, miny=0, w, em, header, triangle, open;
 
 	if(vertical) {
 		w= v2d->cur.xmax - v2d->cur.xmin;
@@ -980,6 +980,7 @@
 	}
 
 	header= 20; // XXX
+	triangle= 22;
 	x= 0;
 	y= -style->panelouter;
 
@@ -1003,18 +1004,17 @@
 			if(vertical)
 				y -= header;
 
-			/* XXX enable buttons test */
-#if 0
-			panel->layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER,
-				header+style->panelspace, header+style->panelspace, header, 1, style);
+			if(pt->draw_header) {
+				/* for enabled buttons */
+				panel->layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER,
+					triangle, header+style->panelspace, header, 1, style);
 
-			if(pt->draw_header)
 				pt->draw_header(C, panel);
-			else
-				uiItemL(panel->layout, pt->label, 0);
 
-			panel->layout= NULL;
-#endif
+				uiBlockLayoutResolve(C, block, &xco, &yco);
+				panel->labelofs= xco - triangle;
+				panel->layout= NULL;
+			}
 
 			if(open) {
 				panel->type= pt;
@@ -1143,6 +1143,5 @@
 void ED_region_header_init(ARegion *ar)
 {
 	UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
-	ar->v2d.flag &= ~(V2D_PIXELOFS_X|V2D_PIXELOFS_Y); // XXX temporary
 }
 

Modified: branches/blender2.5/blender/source/blender/makesdna/DNA_screen_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesdna/DNA_screen_types.h	2009-05-20 14:32:15 UTC (rev 20294)
+++ branches/blender2.5/blender/source/blender/makesdna/DNA_screen_types.h	2009-05-20 14:46:49 UTC (rev 20295)
@@ -97,10 +97,11 @@
 	char panelname[64], tabname[64];	/* defined as UI_MAX_NAME_STR */
 	char drawname[64];					/* panelname is identifier for restoring location */
 	short ofsx, ofsy, sizex, sizey;
+	short labelofs, pad;
 	short flag, runtime_flag;
 	short control;
 	short snap;
-	int sortorder, pad;			/* panels are aligned according to increasing sortorder */
+	int sortorder;			/* panels are aligned according to increasing sortorder */
 	struct Panel *paneltab;		/* this panel is tabbed in *paneltab */
 	void *activedata;			/* runtime for panel manipulation */
 } Panel;





More information about the Bf-blender-cvs mailing list