Changeset 78
- Timestamp:
- 08/01/08 22:37:15 (4 months ago)
- Files:
-
- trunk/pihlaja/src/dsss.conf (modified) (2 diffs)
- trunk/pihlaja/src/pihlaja/PihlajaMain.d (modified) (3 diffs)
- trunk/pihlaja/src/shiraz/canvas/Image.d (modified) (5 diffs)
- trunk/pihlaja/src/shiraz/canvas/PlainRectangle.d (modified) (8 diffs)
- trunk/pihlaja/src/shiraz/canvas/Rectangle.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/canvas/ShapeShadow.d (added)
- trunk/pihlaja/src/shiraz/core/Theme.d (modified) (7 diffs)
- trunk/pihlaja/src/shiraz/ui/Button.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/ui/SubWindow.d (modified) (3 diffs)
- trunk/pihlaja/src/shiraz/ui/Window.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pihlaja/src/dsss.conf
r76 r78 45 45 #buildflags += -debug=FBO 46 46 #buildflags += -debug=Shiraz 47 buildflags += -debug=Theme47 #buildflags += -debug=Theme 48 48 #buildflags += -debug=ProjectWindow 49 49 #buildflags += -debug=Window 50 50 #buildflags += -debug=GtkOpenGLCanvas 51 51 #buildflags += -debug=SubWindow 52 buildflags += -debug=Menu52 #buildflags += -debug=Menu 53 53 #buildflags += -debug=Widget 54 54 #buildflags += -debug=Rectangle … … 59 59 #buildflags += -debug=FindLeaf #warning: very much output 60 60 #buildflags += -debug=Animator 61 buildflags += -debug=Animator262 buildflags += -debug=Image61 #buildflags += -debug=Animator2 62 #buildflags += -debug=Image 63 63 } 64 64 version(Windows) { trunk/pihlaja/src/pihlaja/PihlajaMain.d
r77 r78 134 134 135 135 videoViewerWindow = new SubWindow("Viewer", WindowHeaderType.SMALL, WindowHeaderType.SMALL); 136 videoViewerWindow.shadowType = ShadowType.NONE; 136 137 //videoViewerWindow.isClipByParent = false; 137 138 … … 275 276 276 277 myWindow4 = new SubWindow("Timeline", WindowHeaderType.SMALL, WindowHeaderType.SMALL); 278 myWindow4.shadowType = ShadowType.NONE; 277 279 //myWindow4.isClipByParent = false; 278 280 myWindow4.moveTo( -0.3f, 0.4f ); … … 366 368 367 369 SubWindow awin28 = new SubWindow("Timeline", WindowHeaderType.SMALL, WindowHeaderType.SMALL); 370 awin28.shadowType = ShadowType.NONE; 368 371 //awin28.isClipByParent = false; 369 372 awin28.defaultSize( 0.4f, 0.4f ); trunk/pihlaja/src/shiraz/canvas/Image.d
r77 r78 15 15 * along with Shiraz; if not, write to the Free Software 16 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * 18 * The functions boxBlur() and fastBlur() were taken from librsvg-2.15.90 19 * rsvg-filter.c and are Copyright (C) 2004 Caleb Moore. 20 * Author: Caleb Moore <c.moore@student.unsw.edu.au> 21 * They are licenced as LGPL. 17 22 */ 18 23 19 24 module shiraz.canvas.Image; 20 25 … … 984 989 void blur(float blur_amount) 985 990 { 986 fast _blur(this, this, blur_amount, blur_amount );991 fastBlur(this, this, blur_amount, blur_amount ); 987 992 } 988 993 … … 1108 1113 */ 1109 1114 1110 //The following two functions were taken from librsvg-2.15.90.1111 //And modified to fit this class.1112 //Here's the licence:1113 1114 /*1115 rsvg-filter.c: Provides filters1116 1117 Copyright (C) 2004 Caleb Moore1118 1119 This program is free software; you can redistribute it and/or1120 modify it under the terms of the GNU Library General Public License as1121 published by the Free Software Foundation; either version 2 of the1122 License, or (at your option) any later version.1123 1124 This program is distributed in the hope that it will be useful,1125 but WITHOUT ANY WARRANTY; without even the implied warranty of1126 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU1127 Library General Public License for more details.1128 1129 You should have received a copy of the GNU Library General Public1130 License along with this program; if not, write to the1131 Free Software Foundation, Inc., 59 Temple Place - Suite 330,1132 Boston, MA 02111-1307, USA.1133 1134 Author: Caleb Moore <c.moore@student.unsw.edu.au>1135 */1136 1137 1115 1138 1116 static void 1139 box _blur (Image input, Image output, GLubyte[] intermediate, int kw,1117 boxBlur (Image input, Image output, GLubyte[] intermediate, int kw, 1140 1118 int kh )//, RsvgIRect boundarys, RsvgFilterPrimitiveOutput op) 1141 1119 { … … 1285 1263 } 1286 1264 1287 static void fast _blur(Image input, Image output, float blur_amount_x,1265 static void fastBlur(Image input, Image output, float blur_amount_x, 1288 1266 float blur_amount_y )//, RsvgIRect boundarys, RsvgFilterPrimitiveOutput op) 1289 1267 { … … 1298 1276 scope GLubyte[] intermediate = new GLubyte[max(kx, ky)]; 1299 1277 1300 box _blur (input, output, intermediate, kx,1278 boxBlur (input, output, intermediate, kx, 1301 1279 ky );//, boundarys, op); 1302 box _blur (output, output, intermediate, kx,1280 boxBlur (output, output, intermediate, kx, 1303 1281 ky );//, boundarys, op); 1304 box _blur (output, output, intermediate, kx,1282 boxBlur (output, output, intermediate, kx, 1305 1283 ky );//, boundarys, op); 1306 1284 trunk/pihlaja/src/shiraz/canvas/PlainRectangle.d
r76 r78 50 50 import shiraz.canvas.IShape; 51 51 import shiraz.canvas.ShapeRectangle; 52 import shiraz.canvas.ShapeShadow; 52 53 import shiraz.canvas.Image; 53 54 import shiraz.canvas.Gradient; … … 60 61 import shiraz.canvas.rtree.Node; 61 62 import shiraz.canvas.rtree.Index; 63 64 public enum ShadowType 65 { 66 NONE, 67 SQUARE, 68 ROUND 69 } 62 70 63 71 /* … … 1068 1076 protected IShape shape; 1069 1077 1078 //Shadows: 1079 public ShadowType shadowType(ShadowType set) 1080 { 1081 if( set == m_shadowType ) 1082 { 1083 return m_shadowType; 1084 } 1085 1086 m_shadowType = set; 1087 1088 if( set == ShadowType.NONE ) 1089 { 1090 if( shapeShadow !is null ) 1091 delete shapeShadow; 1092 } 1093 else 1094 { 1095 if( shapeShadow is null ) 1096 shapeShadow = new ShapeShadow(ix1, iy1, ix2, iy2); 1097 updateShadowTexture(); 1098 } 1099 return m_shadowType; 1100 } 1101 public ShadowType shadowType() { return m_shadowType; } 1102 protected ShadowType m_shadowType = ShadowType.NONE; 1103 //protected Shadow shadow; 1104 protected IShape shapeShadow; 1105 1106 protected void updateShadowTexture() 1107 { 1108 if( shapeShadow is null ) 1109 return; 1110 1111 if( shadowType == ShadowType.SQUARE ) 1112 { 1113 shapeShadow.texture = g_shiraz.getTextureFromTheme("Shiraz.ShapeShadow.square"); 1114 } 1115 else if( shadowType == ShadowType.ROUND ) 1116 { 1117 shapeShadow.texture = g_shiraz.getTextureFromTheme("Shiraz.ShapeShadow.round"); 1118 } 1119 else Trace.formatln("PlainRectangle.updateShadowTexture() strange parameter for a shadow: ShadowType.NONE."); 1120 } 1121 1070 1122 /* 1071 1123 TODO interface IShape … … 1135 1187 //draw.colour(); 1136 1188 //draw.gradient( gradient ); 1189 1190 renderShadow(draw); 1137 1191 1138 1192 //TODO … … 1166 1220 1167 1221 1222 } 1223 1224 void renderShadow( Draw draw ) 1225 { 1226 if( shadowType != ShadowType.NONE ) 1227 { 1228 glColor4f(1.0f, 1.0f, 1.0f, a); 1229 1230 //HARDCODED PIXEL SIZE! 1231 float hard_tex_width = (w / g_shiraz.pixel)+102.0f;//102.0f; 1232 float hard_tex_height = (h / g_shiraz.pixel)+102.0f;//102.0f; 1233 1234 shapeShadow.bounds( 1235 //roundToPixels( 1236 icx - (pixel*hard_tex_width*0.5f), 1237 //roundToPixels( 1238 icy + 0.005f - (pixel*hard_tex_height*0.5f), 1239 //roundToPixels( 1240 icx + (pixel*hard_tex_width*0.5f), 1241 //roundToPixels( 1242 icy + 0.005f + (pixel*hard_tex_height*0.5f), 1243 iz); 1244 1245 draw.fill( shapeShadow ); 1246 } 1168 1247 } 1169 1248 … … 1298 1377 void renderPixelPerPixel( Draw draw, float hard_tex_width, float hard_tex_height ) 1299 1378 { 1300 debug(clipping) Trace.formatln("PlainRectangle.render () START. name: {}", fullName() );1379 debug(clipping) Trace.formatln("PlainRectangle.renderPixelPerPixel() START. name: {}", fullName() ); 1301 1380 1302 1381 beginRender(draw); 1303 1382 1304 draw.pushTexture( texture );1383 //draw.pushTexture( texture ); 1305 1384 //These should be handled by the Shape: 1306 1385 //draw.colour(); … … 1329 1408 1330 1409 draw.fill( shape ); 1331 draw.popTexture();1410 //draw.popTexture(); 1332 1411 1333 1412 /*if(isOutline) … … 1354 1433 void renderPixelPerPixelHeight( Draw draw, float hard_tex_height ) 1355 1434 { 1356 debug(clipping) Trace.formatln("PlainRectangle.render () START. name: {}", fullName() );1435 debug(clipping) Trace.formatln("PlainRectangle.renderPixelPerPixelHeight() START. name: {}", fullName() ); 1357 1436 1358 1437 beginRender(draw); trunk/pihlaja/src/shiraz/canvas/Rectangle.d
r77 r78 39 39 40 40 41 import shiraz.canvas.ICanvasItem;42 import shiraz.canvas.PlainRectangle;41 public import shiraz.canvas.ICanvasItem; 42 public import shiraz.canvas.PlainRectangle; 43 43 import shiraz.canvas.IRootWindow; 44 44 import shiraz.canvas.Draw; trunk/pihlaja/src/shiraz/core/Theme.d
r77 r78 112 112 createTopWindowHeaderImage(); 113 113 createBottomWindowHeaderImage(); 114 createWindowShadowImage(); 114 115 } 115 116 … … 122 123 addImage( "Shiraz.Menu", my_image ); 123 124 } 125 126 void createWindowShadowImage() 127 { 128 Image my_image = new Image(256, 256, 4); 129 my_image.name = "Shiraz.ShapeShadow.round"; 130 drawWindowShadow(my_image, true); 131 my_image.blur(6.0f); 132 my_image.writeToPng("/home/joonaz/testi/WindowShadow.png"); 133 my_image.createTexture(); 134 addImage( "Shiraz.ShapeShadow.round", my_image ); 135 136 Image my_image2 = new Image(256, 256, 4); 137 my_image2.name = "Shiraz.ShapeShadow.square"; 138 drawWindowShadow(my_image2, false); 139 my_image2.blur(6.0f); 140 my_image2.writeToPng("/home/joonaz/testi/WindowShadowSquare.png"); 141 my_image2.createTexture(); 142 addImage( "Shiraz.ShapeShadow.square", my_image2 ); 143 } 144 145 void drawWindowShadow( Image an_image, bool is_rounded = true ) 146 { 147 cairo_format_t form = cairo_format_t.ARGB32; 148 149 if( an_image.channels == 4 ) 150 form = cairo_format_t.ARGB32; 151 else if( an_image.channels == 3 ) 152 form = cairo_format_t.RGB24; 153 else if( an_image.channels == 1 ) 154 form = cairo_format_t.A8; 155 //TODO other cairo_format_t. 156 157 ImageSurface imageSurface = ImageSurface.createForData(an_image.imageData.ptr, form, an_image.width, an_image.height, an_image.width * an_image.channels); 158 scope(exit) delete imageSurface; 159 auto cr = Context.create(imageSurface); 160 scope(exit) delete cr; 161 162 //TODO theme the SMALL and NORMAL window sizes... 163 float hei = g_shiraz.getValueFromTheme("Shiraz.WindowHeader.SMALL.defaultHeight") / g_shiraz.pixel; 164 165 cr.save(); 166 cr.setLineWidth(1.0); 167 float xRender = an_image.width/5; 168 float yRender = an_image.height/5;//32.0f;//(an_image.height - hei) * 0.5f;//an_image.height/3; 169 float x2Render = an_image.width - xRender; 170 float y2Render = an_image.height - yRender;//(an_image.height - yRender) + hei; 171 double curve_size = hei * 0.5f;//(y2Render - yRender) * 0.5f; 172 173 174 //Clipping: 175 176 //cr.rectangle( xRender, yRender, x2Render, y2Render ); 177 //cr.clip(); 178 179 /* 180 Gradient gradient; 181 //gradient = g_shiraz.getGradientFromTheme("Shiraz.Button"); 182 gradient = getGradient("Shiraz.WindowHeader.Top"); 183 184 scope Pattern linear = Pattern.createLinear( xRender, yRender, xRender, yRender + hei );//(0.0, 0.0, 0.0, 20.0) ); 185 ColourStop last_colourstop; 186 foreach( ColourStop colstop; gradient ) 187 { 188 //We store the last colourstop: 189 last_colourstop = colstop; 190 191 //BGRA 192 //I checked, and with the current settings the cairo images 193 //are BGRA and not RGBA. That's why I found it easiest to just 194 //swap the order here, in the drawing phase: 195 196 //linear.addColorStopRgba( colstop.position, colstop.colour.r, colstop.colour.g, colstop.colour.b, colstop.colour.a ); 197 linear.addColorStopRgba( colstop.position, colstop.colour.b, colstop.colour.g, colstop.colour.r, colstop.colour.a ); 198 } 199 200 if( is_top == true ) 201 { 202 cr.setSource( linear ); 203 } 204 else 205 { 206 cr.setSourceRgba(last_colourstop.colour.b, last_colourstop.colour.g, last_colourstop.colour.r, last_colourstop.colour.a); 207 cr.translate(0.0f, -hei); 208 } 209 */ 210 211 cr.setSourceRgba(0.0f, 0.0f, 0.0f, 0.5f); 212 213 if( is_rounded == true ) 214 { 215 cr.moveTo(xRender, yRender + curve_size);//up-left, lowerpoint 216 cr.curveTo(xRender, yRender + curve_size, xRender, yRender, xRender + curve_size, yRender);//up-left, upperpoint 217 cr.lineTo(x2Render - curve_size, yRender);//up-right, upperpoint 218 cr.curveTo(x2Render - curve_size, yRender, x2Render, yRender, x2Render, yRender + curve_size);//up-right, lowerpoint 219 cr.lineTo(x2Render, y2Render - curve_size);//down-right, upperpoint 220 cr.curveTo(x2Render, y2Render - curve_size, x2Render, y2Render, x2Render - curve_size, y2Render);//down-right, lowerpoint 221 cr.lineTo(xRender + curve_size, y2Render);//down-left, lowerpoint 222 cr.curveTo(xRender + curve_size, y2Render, xRender, y2Render, xRender, y2Render - curve_size);//down-left, upperpoint 223 cr.lineTo(xRender, yRender + curve_size);//up-left, lowerpoint 224 } 225 else 226 { 227 cr.rectangle( xRender, yRender, x2Render-xRender, y2Render-yRender ); 228 } 229 230 cr.fill;//Preserve(); 231 //cr.setSourceRgba(0.0, 0.0, 0.0, 1.0); 232 //cr.setSourceRgba( outlineColour.r, outlineColour.g, outlineColour.b, outlineColour.a ); 233 //cr.stroke(); 234 235 cr.restore(); 236 237 cr.destroy(); 238 imageSurface.destroy(); 239 } 240 124 241 125 242 void createButtonImage() … … 177 294 //cr.setSourceRgba(set_colour[0], set_colour[1], set_colour[2], set_colour[3]); 178 295 179 float xRender = an_image.width/ 8;296 float xRender = an_image.width/5; 180 297 float yRender = an_image.height/3; 181 298 float x2Render = an_image.width - xRender; … … 209 326 { 210 327 cr.setSourceRgba(0.0f, 0.0f, 0.0f, 0.5f); 211 cr.translate( 1.0f, 3.5f);328 cr.translate(0.0f, 3.5f); 212 329 } 213 330 … … 292 409 cr.save(); 293 410 cr.setLineWidth(1.0); 294 float xRender = an_image.width/ 8;411 float xRender = an_image.width/5; 295 412 float yRender = (an_image.height - hei) * 0.5f;//an_image.height/3; 296 413 float x2Render = an_image.width - xRender; … … 300 417 //Clipping: 301 418 302 cr.rectangle( xRender, yRender, x2Render, y2Render ); 419 //cr.rectangle( xRender, yRender, x2Render, y2Render ); 420 cr.rectangle( xRender, yRender, x2Render-xRender, y2Render-yRender ); 303 421 cr.clip(); 304 422 … … 352 470 cr.restore(); 353 471 354 imageSurface.writeToPng("/home/joonaz/testi/TopWindowHeader.png");472 //imageSurface.writeToPng("/home/joonaz/testi/TopWindowHeader.png"); 355 473 356 474 cr.destroy(); trunk/pihlaja/src/shiraz/ui/Button.d
r76 r78 190 190 //TODO Naturally we'd want to get rid of these hardcoded sizes... 191 191 //renderPixelPerPixel( draw, 128.0f, 64.0f ); 192 renderPixelPerPixel( draw, (w / g_shiraz.pixel)+64.0f, 64.0f ); 192 //a = 0.5f; 193 194 //102.0f is from (256.0f / 5) * 2.0f = 102.4f ~ in pixels 102.0f. 195 //So (256 / 5) is the size of the button texture's left and right side. 196 renderPixelPerPixel( draw, (w / g_shiraz.pixel)+102.0f, 64.0f ); 197 //super.render(draw); 193 198 //renderPixelPerPixelHeight( draw, 64.0f ); 194 199 } trunk/pihlaja/src/shiraz/ui/SubWindow.d
r76 r78 935 935 isFrontSide = set_is_frontside; 936 936 937 if( set_bottom_header_type == WindowHeaderType.NONE )//&& set_top_header_type == WindowHeaderType.NONE ) 938 { 939 //We only evaluate bottomheader for the shadow roundness, for now. 940 //Because we only have round or square from both ends shadows. 941 //And because the bottom is where the shadow is shown most. 942 shadowType = ShadowType.SQUARE; 943 } 944 else 945 { 946 shadowType = ShadowType.ROUND; 947 } 948 949 937 950 //g_shiraz.registerWindow(this); 938 951 … … 1247 1260 1248 1261 beginRender( draw ); 1262 1263 renderShadow(draw); 1249 1264 1250 1265 draw.pushTexture( framebufferObject ); … … 1797 1812 } 1798 1813 1799 1814 public ShadowType shadowType(ShadowType set) 1815 { 1816 side2.shadowType = set; 1817 return side1.shadowType = set; 1818 } 1819 public ShadowType shadowType() { return side1.shadowType; } 1800 1820 1801 1821 PlainWindow side1; trunk/pihlaja/src/shiraz/ui/Window.d
r76 r78 694 694 plainWindow = new PlainWindow(set_name, WindowHeaderType.NONE, WindowHeaderType.NONE, true, false );//isfrontside=true, use_fbo_clipping=false 695 695 addToCanvas(plainWindow); 696 plainWindow.shadowType = shiraz.canvas.PlainRectangle.ShadowType.NONE;//Remove the shadow from here as it isn't even shown. 696 697 697 698 Trace.formatln("After Window.super().");
