Changeset 66
- Timestamp:
- 06/29/08 12:32:16 (2 months ago)
- Files:
-
- trunk/pihlaja/src/shiraz/Shiraz.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/canvas/Draw.d (modified) (3 diffs)
- trunk/pihlaja/src/shiraz/canvas/Image.d (modified) (3 diffs)
- trunk/pihlaja/src/shiraz/canvas/Rectangle.d (modified) (6 diffs)
- trunk/pihlaja/src/shiraz/ui/Button.d (modified) (2 diffs)
- trunk/pihlaja/src/shiraz/ui/Label.d (modified) (3 diffs)
- trunk/pihlaja/src/shiraz/ui/Paned.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/ui/SubWindow.d (modified) (4 diffs)
- trunk/pihlaja/src/shiraz/ui/Window.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pihlaja/src/shiraz/Shiraz.d
r64 r66 59 59 float tempparam1 = 53.1f; 60 60 61 61 //The height of one pixel in Height coordinates. 62 //to convert pixels to Height coordinates: 63 // inPixels * pixel() 64 //to convert Height coordinates to pixels: 65 // inHCoord / pixel() 62 66 float pixel() { return 1.0f/screenHeightP; } 63 67 //This returns and accepts Height coordinates trunk/pihlaja/src/shiraz/canvas/Draw.d
r62 r66 385 385 } 386 386 387 static void showText( char[] set_text, GLubyte[] image, uint wid, uint hei, uint chan, float[4] set_colour )387 static void showText( char[] set_text, GLubyte[] image, uint wid, uint hei, uint chan, float[4] set_colour, out float get_text_width, out float get_text_height ) 388 388 { 389 389 cairo_format_t form = cairo_format_t.ARGB32; … … 416 416 */ 417 417 418 font_options.setHintStyle(cairo_hint_style_t.DEFAULT);419 //font_options.setHintStyle(cairo_hint_style_t.NONE);418 //font_options.setHintStyle(cairo_hint_style_t.DEFAULT); 419 font_options.setHintStyle(cairo_hint_style_t.NONE); 420 420 //font_options.setHintStyle(cairo_hint_style_t.SLIGHT); 421 421 //font_options.setHintStyle(cairo_hint_style_t.MEDIUM); 422 422 //font_options.setHintStyle(cairo_hint_style_t.FULL); 423 423 424 font_options.setHintMetrics(cairo_hint_metrics_t.DEFAULT);425 //font_options.setHintMetrics(cairo_hint_metrics_t.OFF);424 //font_options.setHintMetrics(cairo_hint_metrics_t.DEFAULT); 425 font_options.setHintMetrics(cairo_hint_metrics_t.OFF); 426 426 //font_options.setHintMetrics(cairo_hint_metrics_t.ON); 427 427 428 font_options.setAntialias(cairo_antialias_t.DEFAULT);429 //font_options.setAntialias(cairo_antialias_t.GRAY);428 //font_options.setAntialias(cairo_antialias_t.DEFAULT); 429 font_options.setAntialias(cairo_antialias_t.GRAY); 430 430 //font_options.setAntialias(cairo_antialias_t.NONE); 431 431 //font_options.setAntialias(cairo_antialias_t.SUBPIXEL); … … 464 464 //double x = wid-((extents.width/2.0) + extents.xBearing); 465 465 //double y = hei-((extents.height/2.0) + extents.yBearing); 466 467 //TODO What about + or - xBearing here?? 468 get_text_width = extents.width; 469 get_text_height = extents.height; 466 470 467 471 double x = (wid/2.0)-((extents.width/2.0) + extents.xBearing); trunk/pihlaja/src/shiraz/canvas/Image.d
r63 r66 675 675 } 676 676 677 static Image createFromText( char[] set_text, float[4] set_colour )677 static Image createFromText( char[] set_text, float[4] set_colour, out float get_text_width, out float get_text_height ) 678 678 { 679 679 Image img = new Image(); … … 681 681 //img.magFilter = GL_NEAREST; 682 682 //img.minFilter = GL_NEAREST; 683 img.showText(set_text, set_colour );683 img.showText(set_text, set_colour, get_text_width, get_text_height ); 684 684 685 685 return img; 686 686 } 687 687 688 void showText( char[] set_text, float[4] set_colour )688 void showText( char[] set_text, float[4] set_colour, out float get_text_width, out float get_text_height ) 689 689 { 690 690 width = 128; … … 692 692 channels = 4; 693 693 scope GLubyte[] image = new GLubyte[(width*height)*channels]; 694 Draw.showText( set_text, image, width, height, channels, set_colour );694 Draw.showText( set_text, image, width, height, channels, set_colour, get_text_width, get_text_height ); 695 695 createTextureFromData( image, width, height, channels ); 696 696 } trunk/pihlaja/src/shiraz/canvas/Rectangle.d
r65 r66 2774 2774 //float border = 0.002f; 2775 2775 //float padding = 0.005f; 2776 2777 //TODO use: 2778 float inPadding = 0.0f; 2779 //float outPadding = 0.0f; 2776 2780 float padding = 0.0f; 2777 2781 2782 //TODO: Anchor NOT USED AT THE MOMENT: 2783 /* 2778 2784 public void anchor() { return m_anchor; } 2779 2785 public void anchor(Anchor set) { return m_anchor = set; } 2780 2786 protected Anchor m_anchor = Anchor.TOP_LEFT; 2787 */ 2781 2788 2782 2789 /* … … 2813 2820 public ArrangeType arrangeType(ArrangeType set) { return m_arrangeType = set; } 2814 2821 protected ArrangeType m_arrangeType = ArrangeType.VBOX; 2822 2823 bool followsChildWidth = false; 2824 bool followsChildHeight = false; 2815 2825 2816 2826 /* … … 2971 2981 if( result == 0.0f ) 2972 2982 return minWidth;//This propably makes no sense, but 2983 //currently it should work. As minHeight is set for 2984 //all Widgets. 2985 2986 return result; 2987 } 2988 2989 float childrenDefaultHeight() 2990 { 2991 float result = 0.0f; 2992 2993 switch( arrangeType ) 2994 { 2995 default: 2996 case ArrangeType.FREE: 2997 2998 break; 2999 case ArrangeType.LAYER: 3000 3001 break; 3002 case ArrangeType.HBOX: 3003 foreach( Rectangle wid; itemList ) 3004 { 3005 //debug(arrange) Trace.formatln("wid.name: {} height: {}", wid.name, cast(double) wid.h ); 3006 if( result < (wid.ifDefaultHeight + wid.padding*2.0f) ) 3007 result = (wid.ifDefaultHeight + wid.padding*2.0f); 3008 } 3009 break; 3010 case ArrangeType.VBOX: 3011 foreach( Rectangle wid; itemList ) 3012 { 3013 result = result + (wid.ifDefaultHeight + wid.padding*2.0f); 3014 } 3015 break; 3016 } 3017 3018 if( result == 0.0f ) 3019 return ifDefaultHeight;//This propably makes no sense, but 3020 //currently it should work. As minHeight is set for 3021 //all Widgets. 3022 3023 return result; 3024 } 3025 3026 float childrenDefaultWidth() 3027 { 3028 float result = 0.0f; 3029 3030 switch( arrangeType ) 3031 { 3032 default: 3033 case ArrangeType.FREE: 3034 3035 break; 3036 case ArrangeType.LAYER: 3037 3038 break; 3039 case ArrangeType.HBOX: 3040 foreach( Rectangle wid; itemList ) 3041 { 3042 result = result + (wid.ifDefaultWidth + wid.padding*2.0f); 3043 } 3044 break; 3045 case ArrangeType.VBOX: 3046 foreach( Rectangle wid; itemList ) 3047 { 3048 //Trace.formatln("wid.name: {} height: {}", wid.name, cast(double) wid.h ); 3049 if( result < (wid.ifDefaultWidth + wid.padding*2.0f) ) 3050 result = (wid.ifDefaultWidth + wid.padding*2.0f); 3051 } 3052 break; 3053 } 3054 3055 if( result == 0.0f ) 3056 return ifDefaultWidth;//This propably makes no sense, but 2973 3057 //currently it should work. As minHeight is set for 2974 3058 //all Widgets. … … 3489 3573 } 3490 3574 3491 3575 if( followsChildWidth == true ) 3576 { 3577 defaultWidthN = childrenDefaultWidth() + (inPadding*2.0f); 3578 } 3579 3580 if( followsChildHeight == true ) 3581 { 3582 defaultHeightN = childrenDefaultHeight() + (inPadding*2.0f); 3583 } 3492 3584 3493 3585 … … 3704 3796 return m_defaultWidth; 3705 3797 } 3798 public float defaultWidthN(float set) 3799 { 3800 hasDefaultWidth = true; 3801 m_defaultWidth = set; 3802 if( m_minWidth > m_defaultWidth ) 3803 m_minWidth = m_defaultWidth; 3804 if( m_maxWidth < m_defaultWidth ) 3805 m_maxWidth = m_defaultWidth; 3806 3807 wN(defaultWidth);//was wc() 3808 3809 //arrange(); 3810 return m_defaultWidth; 3811 } 3706 3812 protected float m_defaultWidth = 1.0f; 3707 3813 … … 3743 3849 return m_defaultHeight; 3744 3850 } 3851 public float defaultHeightN(float set) 3852 { 3853 hasDefaultHeight = true; 3854 m_defaultHeight = set; 3855 if( m_minHeight > m_defaultHeight ) 3856 m_minHeight = m_defaultHeight; 3857 if( m_maxHeight < m_defaultHeight ) 3858 m_maxHeight = m_defaultHeight; 3859 3860 hN(defaultHeight);//was hc() 3861 3862 //arrange(); 3863 return m_defaultHeight; 3864 } 3745 3865 protected float m_defaultHeight = 1.0f; 3746 3866 trunk/pihlaja/src/shiraz/ui/Button.d
r61 r66 74 74 //set( 0.0f, 0.0f, 0.6f, 0.2f ); 75 75 76 inPadding = 0.015f; 76 77 padding = 0.005f; 77 //xPackOptions = PackOptions.SHRINK;78 xPackOptions = PackOptions.SHRINK; 78 79 yPackOptions = PackOptions.SHRINK; 79 80 defaultHeight = 0.04; … … 85 86 label.colour(1.0, 1.0, 1.0, 1.0);//White 86 87 label.xPackOptions = PackOptions.EXPAND; 88 89 //Now that we have the label set up, it knows it's 90 //width, and we can use it to set our defaultWidth. 91 //using padding here is just funny. We should really have 92 //a system with inPadding and outPadding. 93 defaultWidth = label.textWidth + (padding * 6.0f); 94 followsChildWidth = true; 95 87 96 add(label); 88 97 89 98 signalMouseButtonPress.attach(&buttonHandler); 90 99 signalMouseButtonRelease.attach(&buttonHandler); trunk/pihlaja/src/shiraz/ui/Label.d
r52 r66 59 59 //set( 0.0f, 0.0f, 0.6f, 0.2f ); 60 60 61 texture = Image.createFromText( name, m_textColourData ); 61 texture = Image.createFromText( name, m_textColourData, textWidth, textHeight ); 62 //Image gives the text size in pixels, we'll have to convert them to 63 //Height Coordinates. 64 textWidth = textWidth * pixel; 65 textHeight = textHeight * pixel; 66 67 defaultWidth = textWidth; 68 defaultHeight = textHeight; 69 70 Trace.formatln("textWidth: {}", cast(double) textWidth ); 71 Trace.formatln("textHeight: {}", cast(double) textHeight ); 62 72 63 73 padding = 0.0f; … … 71 81 72 82 } 83 84 float textWidth = 0.0f; 85 float textHeight = 0.0f; 73 86 74 87 /+public Widget root(Widget set)///Don't use this yourself. … … 216 229 r = sr; g = sg; b = sb; a = sa; 217 230 if( texture !is null ) 218 texture.showText( name, m_textColourData ); 231 { 232 texture.showText( name, m_textColourData, textWidth, textHeight ); 233 //Image gives the text size in pixels, we'll have to convert them to 234 //Height Coordinates. 235 textWidth = textWidth * pixel; 236 textHeight = textHeight * pixel; 237 } 219 238 } 220 239 trunk/pihlaja/src/shiraz/ui/Paned.d
r65 r66 75 75 76 76 //rectangle. 77 colour(0.92f, 0.12f, 0.12f, 1.0f); 77 colour(0.12f, 0.12f, 0.12f, 1.0f); 78 isOutline = false; 78 79 //rectangle. 79 80 //set( 0.0f, 0.0f, 0.6f, 0.2f ); 80 81 81 texture = g_shiraz.getTextureFromTheme("Shiraz.Button");82 //texture = g_shiraz.getTextureFromTheme("Shiraz.Button"); 82 83 83 84 padding = 0.000f; trunk/pihlaja/src/shiraz/ui/SubWindow.d
r64 r66 1569 1569 isOutline = false; 1570 1570 1571 xPackOptions = PackOptions.SHRINK; 1572 yPackOptions = PackOptions.SHRINK; 1573 1574 inPadding = 0.015f; 1571 1575 padding = 0.0f; 1572 1576 1573 1577 texture = null; 1578 1579 /* 1580 menuButton = new Button(set_name); 1581 menuButton.texture = null; 1582 menuButton.padding = 0.0f; 1583 add(menuButton); 1584 */ 1585 1586 //keyShortCutLabel = new Label("Key"); 1587 //add(keyShortCutLabel); 1574 1588 1575 1589 } … … 1599 1613 void arrange() 1600 1614 { 1615 super.arrange(); 1616 1601 1617 if( menuWindow !is null ) 1602 1618 { 1603 menuWindow.yPos = yPos2c + ((h*0.5 ) + (menuWindow.h*0.5));1604 menuWindow.xPos = xPos2c ;1619 menuWindow.yPos = yPos2c + ((h*0.5f) + (menuWindow.h*0.5f)); 1620 menuWindow.xPos = xPos2c + (menuWindow.w*0.5f) - (w*0.5f); 1605 1621 } 1606 1622 } … … 1635 1651 } 1636 1652 1653 //Button menuButton; 1654 Label keyShortCutLabel; 1637 1655 MenuWindow menuWindow; 1638 1656 } … … 1647 1665 1648 1666 super("MenuWindow", WindowHeaderType.NONE, WindowHeaderType.NONE ); 1667 1668 followsChildWidth = true; 1669 followsChildHeight = true; 1649 1670 1650 1671 trunk/pihlaja/src/shiraz/ui/Window.d
r64 r66 1059 1059 1060 1060 gtkWindow.setSizeRequest( cast(int)set_width, cast(int)set_height ); 1061 //Doesn't work?: 1062 //gtkWindow.setDefaultSize( cast(int)set_width, cast(int)set_height ); 1061 1063 } 1062 1064
