Changeset 74
- Timestamp:
- 07/18/08 20:02:57 (2 months ago)
- Files:
-
- trunk/pihlaja/src/dsss.conf (modified) (2 diffs)
- trunk/pihlaja/src/pihlaja/PihlajaMain.d (modified) (4 diffs)
- trunk/pihlaja/src/shiraz/Shiraz.d (modified) (2 diffs)
- trunk/pihlaja/src/shiraz/canvas/Colour.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/canvas/PlainRectangle.d (modified) (10 diffs)
- trunk/pihlaja/src/shiraz/canvas/Rectangle.d (modified) (22 diffs)
- trunk/pihlaja/src/shiraz/ui/Animator.d (modified) (5 diffs)
- trunk/pihlaja/src/shiraz/ui/Menu.d (added)
- trunk/pihlaja/src/shiraz/ui/Paned.d (modified) (1 diff)
- trunk/pihlaja/src/shiraz/ui/ProgressBar.d (modified) (3 diffs)
- trunk/pihlaja/src/shiraz/ui/SubWindow.d (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pihlaja/src/dsss.conf
r71 r74 50 50 #buildflags += -debug=GtkOpenGLCanvas 51 51 #buildflags += -debug=SubWindow 52 buildflags += -debug=Menu 52 53 #buildflags += -debug=Widget 53 54 #buildflags += -debug=Rectangle … … 58 59 #buildflags += -debug=FindLeaf #warning: very much output 59 60 #buildflags += -debug=Animator 61 buildflags += -debug=Animator2 60 62 buildflags += -debug=Image 61 63 } trunk/pihlaja/src/pihlaja/PihlajaMain.d
r73 r74 39 39 import shiraz.ui.Window; 40 40 import shiraz.ui.SubWindow; 41 import shiraz.ui.Menu; 41 42 import shiraz.ui.Paned; 42 43 import shiraz.ui.Button; … … 287 288 //add(myWindow4); 288 289 insideButton4 = new Button("ØŽÛØ±Ø§Ø²"); 289 insideButton4.signalActivate.attach(&clickHandler3); 290 insideButton4.signalActivate.attach(&funnyProgressLoopHandler); 291 //insideButton4.signalActivate.attach(&clickHandler3); 290 292 /* 291 293 insideButton4.signalMouseButtonPress.attach(&clickHandler3); … … 306 308 exportProgressBar = new ProgressBar("Exporting..."); 307 309 myWindow4.add(exportProgressBar); 308 exportProgressBar.fraction = 0.7f;310 //exportProgressBar.fraction = 0.7f; 309 311 310 312 playButton = new Button("Play"); … … 635 637 } 636 638 } 639 } 640 641 void funnyProgressLoopHandler() 642 { 643 if( exportProgressBar.fraction < 1.0f ) 644 exportProgressBar.fractionAnim(1.0f, &funnyProgressLoopHandler); 645 else exportProgressBar.fractionAnim(0.0f, &funnyProgressLoopHandler); 637 646 } 638 647 trunk/pihlaja/src/shiraz/Shiraz.d
r73 r74 528 528 529 529 my_theme.addValue( "Shiraz.Button.defaultHeight", 0.03f ); 530 my_theme.addValue( "Shiraz.WindowHeader.NORMAL.defaultHeight", 0.03f ); 531 my_theme.addValue( "Shiraz.WindowHeader.SMALL.defaultHeight", 0.02f ); 530 532 531 533 … … 603 605 604 606 my_theme.addValue( "Shiraz.Button.defaultHeight", 0.03f ); 607 my_theme.addValue( "Shiraz.WindowHeader.NORMAL.defaultHeight", 0.03f ); 608 my_theme.addValue( "Shiraz.WindowHeader.SMALL.defaultHeight", 0.02f ); 605 609 606 610 //Gradients: 607 611 608 612 Gradient gradient = new Gradient(); 609 gradient.add( 0.0f, 2 24.0f/255.0f, 224.0f/255.0f, 224.0f/255.0f, 1.0f );610 gradient.add( 0.35f, 2 24.0f/255.0f, 224.0f/255.0f, 224.0f/255.0f, 1.0f );611 gradient.add( 0.66f, 1 90.0f/255.0f, 190.0f/255.0f, 190.0f/255.0f, 1.0f );612 gradient.add( 1.0f, 1 90.0f/255.0f, 190.0f/255.0f, 190.0f/255.0f, 1.0f );613 gradient.add( 0.0f, 205.0f/255.0f, 205.0f/255.0f, 205.0f/255.0f, 1.0f ); 614 gradient.add( 0.35f, 205.0f/255.0f, 205.0f/255.0f, 205.0f/255.0f, 1.0f ); 615 gradient.add( 0.66f, 168.0f/255.0f, 168.0f/255.0f, 168.0f/255.0f, 1.0f ); 616 gradient.add( 1.0f, 168.0f/255.0f, 168.0f/255.0f, 168.0f/255.0f, 1.0f ); 613 617 my_theme.addGradient("Image.GRADIENT_2", gradient); 614 618 trunk/pihlaja/src/shiraz/canvas/Colour.d
r68 r74 21 21 { 22 22 public: 23 24 this() 25 { 26 set(1.0f, 1.0f, 1.0f, 1.0f); 27 } 23 28 24 29 this( float sr, float sg, float sb, float sa = 1.0f ) trunk/pihlaja/src/shiraz/canvas/PlainRectangle.d
r73 r74 46 46 47 47 import shiraz.canvas.Draw; 48 import shiraz.canvas.Colour; 48 49 import shiraz.canvas.ICanvasItem; 49 50 import shiraz.canvas.IShape; … … 223 224 debug(PlainRectangle) scope(exit) Trace.formatln("PlainRectangle.this(p1,p2) END."); 224 225 //super(); 226 227 mainColour = new Colour(); 228 prelightColour = new Colour(); 229 updatePrelightColour(); 225 230 226 231 if (p1 is null || p2 is null) throw new Exception("PlainRectangle.this(p1, p2) Error: Points cannot be null."); … … 766 771 debug(PlainRectangle) scope(exit) Trace.formatln("PlainRectangle.this() END."); 767 772 773 mainColour = new Colour(); 774 prelightColour = new Colour(); 775 updatePrelightColour(); 776 768 777 //This defines the default colour of all 769 778 //widgets and everything. Let it be 18% grey...? … … 781 790 debug(PlainRectangle) scope(exit) Trace.formatln("PlainRectangle.this(4) END."); 782 791 792 mainColour = new Colour(); 793 prelightColour = new Colour(); 794 updatePrelightColour(); 783 795 784 796 //These won't work as these will … … 804 816 debug(PlainRectangle) scope(exit) Trace.formatln("PlainRectangle.this(6) END."); 805 817 818 mainColour = new Colour(); 819 prelightColour = new Colour(); 820 updatePrelightColour(); 821 806 822 _xPos = set_pos_x; 807 823 _yPos = set_pos_y; … … 820 836 this( ICanvasItem setme ) 821 837 { 838 mainColour = new Colour(); 839 prelightColour = new Colour(); 840 updatePrelightColour(); 841 822 842 _xPos = setme.xPos; 823 843 _yPos = setme.yPos; … … 833 853 this( PlainRectangle setme ) 834 854 { 855 mainColour = new Colour(); 856 prelightColour = new Colour(); 857 updatePrelightColour(); 858 835 859 _xPos = setme.xPos; 836 860 _yPos = setme.yPos; … … 1610 1634 } 1611 1635 1636 Colour mainColour; 1637 Colour prelightColour; 1638 void updatePrelightColour() 1639 { 1640 if( mainColour.r > 0.8f )//If whitish...make darker. 1641 { 1642 prelightColour.set( 0.7f*mainColour.r, 0.7f*mainColour.g, 0.7f*mainColour.b, mainColour.a ); 1643 } 1644 else //otherwise make lighter. 1645 { 1646 prelightColour.set( 1.3f*mainColour.r, 1.3f*mainColour.g, 1.3f*mainColour.b, mainColour.a ); 1647 } 1648 } 1649 1612 1650 //Colour 1613 1651 float r() { return _colour_data[0]; } … … 1630 1668 void colour( float sr, float sg, float sb, float sa ) 1631 1669 { 1670 mainColour.set(sr, sg, sb, sa); 1671 updatePrelightColour(); 1632 1672 r = sr; g = sg; b = sb; a = sa; 1633 1673 } … … 1637 1677 if( set.length >= 4 ) 1638 1678 { 1679 mainColour.set(set[0], set[1], set[2], set[3]); 1680 updatePrelightColour(); 1639 1681 r = set[0]; g = set[1]; b = set[2]; a = set[3]; 1640 1682 } trunk/pihlaja/src/shiraz/canvas/Rectangle.d
r73 r74 45 45 import shiraz.canvas.Image; 46 46 import shiraz.canvas.Bezier; 47 import shiraz.canvas.Colour; 47 48 import shiraz.ui.Animator; 48 49 import shiraz.ui.InputState; … … 1882 1883 //redraw to make them run. 1883 1884 //Should this be moved to Animator? Maybe not. 1885 /* 1884 1886 if(animator.length > 0) 1885 1887 { … … 1899 1901 1900 1902 } 1901 1903 */ 1902 1904 //Trace.formatln("ok anims."); 1903 1905 … … 1909 1911 //is simpler. 1910 1912 1911 /* 1913 if(animator.length > 0) 1914 { 1915 //Trace.formatln("Animations pending."); 1916 invalidate(); 1917 } 1918 1919 1912 1920 LinkSeq!(Animator) to_remove = new LinkSeq!(Animator); 1913 1921 … … 1922 1930 anim.removeFromOwner(); 1923 1931 } 1924 */1932 1925 1933 foreach(Rectangle wid; itemList) 1926 1934 { … … 1935 1943 //Trace.formatln("Added animation."); 1936 1944 1945 bool should_we_append = true; 1946 1947 foreach( Animator anim; animator ) 1948 { 1949 if( anim.combine(set_anim) == false ) 1950 { 1951 should_we_append = false; 1952 } 1953 } 1954 1955 if( should_we_append == true ) 1956 { 1957 debug(Animator2) Trace.formatln("Added animator to {}. {}", name, set_anim.toString() ); 1958 1959 animator.append(set_anim); 1960 } 1961 else 1962 { 1963 debug(Animator2) Trace.formatln("Didn't add animator to {}.", name); 1964 } 1965 //else delete set_anim; 1966 1967 invalidate();//redraw when a new animation is added 1968 //to get it started and running. 1969 1937 1970 //Temporary limit of 5 animations: 1938 if( animator.length < 5 )1971 /*if( animator.length < 5 ) 1939 1972 { 1940 1973 animator.append( set_anim ); 1941 invalidate();//redraw when a new animation is added 1942 //to get it started and running. 1943 } 1974 }*/ 1944 1975 } 1945 1976 … … 1947 1978 { 1948 1979 animator.remove( set_anim ); 1980 debug(Animator2) Trace.formatln("Removed animator. name: {}, animators.length: {}", name, animator.length ); 1949 1981 invalidate();//just in case this does something usefull. 1950 1982 } … … 1975 2007 to_add = new Animator( this, &scale, null, null ); 1976 2008 to_add.path(to_path); 2009 add(to_add); 1977 2010 break; 1978 2011 case DefaultAnimator.LOWER: … … 1990 2023 to_add = new Animator( this, &scale, null, null ); 1991 2024 to_add.path(to_path); 2025 add(to_add); 1992 2026 break; 1993 2027 case DefaultAnimator.ROTATE_180: … … 2006 2040 to_add.speed = 2.0; 2007 2041 to_add.path(to_path); 2042 add(to_add); 2008 2043 break; 2009 2044 //This is kind of temporary until we get the … … 2024 2059 to_add.speed = 2.0; 2025 2060 to_add.path(to_path); 2061 add(to_add); 2026 2062 break; 2027 2063 case DefaultAnimator.ROTATE_360: … … 2042 2078 to_add = new Animator( this, &yRot, null, null ); 2043 2079 to_add.path(to_path); 2080 add(to_add); 2044 2081 break; 2045 2082 … … 2135 2172 m_isPrelight = true; 2136 2173 2137 colourMem( r, g, b, a ); 2138 2139 if( r > 0.8f )//If whitish...make darker. 2174 //colourMem( r, g, b, a ); 2175 2176 colourAnim( prelightColour.r, prelightColour.g, prelightColour.b, prelightColour.a ); 2177 2178 /*if( r > 0.8f )//If whitish...make darker. 2140 2179 { 2141 2180 colourAnim( 0.7f*r, 0.7f*g, 0.7f*b, a ); … … 2144 2183 { 2145 2184 colourAnim( 1.3f*r, 1.3f*g, 1.3f*b, a ); 2146 } 2185 }*/ 2147 2186 2148 2187 invalidate(); … … 2153 2192 m_isPrelight = false; 2154 2193 2155 colourAnim( rMem, gMem, bMem, aMem ); 2194 //colourAnim( rMem, gMem, bMem, aMem ); 2195 colourAnim( mainColour.r, mainColour.g, mainColour.b, mainColour.a ); 2156 2196 2157 2197 invalidate(); … … 3968 4008 Animator to_anim = new Animator(this, &r, &r, null, null, null, null, set_when_finished ); 3969 4009 to_anim.animateTo( to_set, 0.0f, 0.0f ); 4010 add(to_anim); 3970 4011 } 3971 4012 … … 3974 4015 Animator to_anim = new Animator(this, &g, &g, null, null, null, null, set_when_finished ); 3975 4016 to_anim.animateTo( to_set, 0.0f, 0.0f ); 4017 add(to_anim); 3976 4018 } 3977 4019 … … 3980 4022 Animator to_anim = new Animator(this, &b, &b, null, null, null, null, set_when_finished ); 3981 4023 to_anim.animateTo( to_set, 0.0f, 0.0f ); 4024 add(to_anim); 3982 4025 } 3983 4026 … … 3986 4029 Animator to_anim = new Animator(this, &a, &a, null, null, null, null, set_when_finished ); 3987 4030 to_anim.animateTo( to_set, 0.0f, 0.0f ); 4031 add(to_anim); 3988 4032 } 3989 4033 … … 3992 4036 Animator to_anim = new Animator(this, &r, &r, &g, &g, &b, &b, set_when_finished ); 3993 4037 to_anim.animateTo( to_r, to_g, to_b ); 4038 add(to_anim); 3994 4039 3995 4040 Animator to_anim_alpha = new Animator(this, &a, &a, null, null, null, null, set_when_finished ); 3996 4041 to_anim_alpha.animateTo( to_a, 0.0f, 0.0f ); 4042 add(to_anim_alpha); 3997 4043 } 3998 4044 … … 4029 4075 Animator to_anim = new Animator(this, &xPos, &xPos, &yPos, &yPos, &zPos, &zPos, set_when_finished ); 4030 4076 to_anim.animateTo( to_x, to_y, to_z ); 4077 add(to_anim); 4031 4078 } 4032 4079 … … 4035 4082 Animator to_anim = new Animator(this, &w, &w, &h, &h, null, null, set_when_finished ); 4036 4083 to_anim.animateTo( to_w, to_h, 0.0f ); 4084 add(to_anim); 4037 4085 } 4038 4086 trunk/pihlaja/src/shiraz/ui/Animator.d
r69 r74 53 53 void delegate() whenFinished; 54 54 55 float toX ;56 float toY ;57 float toZ ;55 float toX = 0.0f; 56 float toY = 0.0f; 57 float toZ = 0.0f; 58 58 59 59 bool xDone = false; … … 61 61 bool zDone = false; 62 62 63 ICanvasItem owner;//CHECK name this parent? 63 ICanvasItem owner( ICanvasItem set_owner ) { return m_owner = set_owner; } 64 ICanvasItem owner() { return m_owner; } 65 ICanvasItem m_owner;//CHECK name this parent? 64 66 65 67 BezierG1 m_path; … … 78 80 this( ICanvasItem set_item, float delegate(float) set_x, float delegate(float) set_y, float delegate(float) set_z, void delegate() set_when_finished = null ) 79 81 { 82 //BROKEN!? 83 80 84 animatorType = AnimatorType.ABSOLUTE_PATH; 81 85 82 owner = set_item;83 84 if( owner !is null )85 owner.add( this );86 87 86 //get = set_get; 88 87 setX = set_x; … … 91 90 92 91 whenFinished = set_when_finished; 93 } 94 92 93 owner = set_item; 94 95 //if( owner !is null ) 96 //owner.add( this ); 97 } 98 99 100 //TODO remove set_item from the ctor. 101 //It should be set in Rectangle.add( Animator ). 95 102 this( ICanvasItem set_item, float delegate(float) set_x, float delegate() get_x, float delegate(float) set_y, float delegate() get_y, float delegate(float) set_z, float delegate() get_z, void delegate() set_when_finished = null ) 96 103 { 97 104 animatorType = AnimatorType.ABSOLUTE_TO; 98 105 99 owner = set_item;100 101 if( owner !is null )102 owner.add( this );103 104 106 speed = 10.0f; 105 107 … … 120 122 if( setZ is null || getZ is null ) 121 123 zDone = true; 124 125 owner = set_item; 126 127 //if( owner !is null ) 128 //owner.add( this ); 129 } 130 131 char[] toString() 132 { 133 char[] ret = "Animator: "; 134 ret ~= "toX: "; 135 ret ~= Float.toString(toX); 136 ret ~= " toY: "; 137 ret ~= Float.toString(toY); 138 ret ~= " toZ: "; 139 ret ~= Float.toString(toZ); 140 return ret; 141 } 142 143 //Returns true if set_anim should be added to the animations in owner. 144 //If there's something left there that couldn't be combined with 145 //other animators. 146 bool combine(Animator set_anim) 147 { 148 //We presume that the owner is the same. 149 150 bool checkDelegateCombine( Animator a_anim, float delegate(float) a_dlg, Animator b_anim, float delegate(float) b_dlg ) 151 { 152 if( a_dlg !is null && a_dlg is b_dlg ) 153 { 154 return true; 155 } 156 return false; 157 } 158 159 if( animatorType == AnimatorType.ABSOLUTE_TO && set_anim.animatorType == AnimatorType.ABSOLUTE_TO ) 160 { 161 //TODO check for other combinations, like if setX is setZ 162 163 if( xDone == false && checkDelegateCombine( this, setX, set_anim, set_anim.setX ) ) 164 { 165 debug(Animator2) Trace.formatln("setX was identical. Removing it. toX: {} set_anim.toX: {}", cast(double)toX, cast(double)set_anim.toX ); 166 toX = set_anim.toX; 167 whenFinished = set_anim.whenFinished; 168 set_anim.setX = null; 169 set_anim.xDone = true; 170 debug(Animator2) Trace.formatln("after. toX: {}", cast(double)toX ); 171 } 172 if( yDone == false && checkDelegateCombine( this, setY, set_anim, set_anim.setY ) ) 173 { 174 debug(Animator2) Trace.formatln("setY was identical. Removing it. {}", cast(double)toY ); 175 toY = set_anim.toY; 176 whenFinished = set_anim.whenFinished; 177 set_anim.setY = null; 178 set_anim.yDone = true; 179 } 180 if( zDone == false && checkDelegateCombine( this, setZ, set_anim, set_anim.setZ ) ) 181 { 182 debug(Animator2) Trace.formatln("setZ was identical. Removing it. {}", cast(double)toZ ); 183 toZ = set_anim.toZ; 184 whenFinished = set_anim.whenFinished; 185 set_anim.setZ = null; 186 set_anim.zDone = true; 187 } 188 189 if( set_anim.xDone == true && set_anim.yDone == true && set_anim.zDone == true ) 190 { 191 return false;//Everything was combined. 192 } 193 //else 194 return true;//There's something left in set_anim. 195 } 122 196 } 123 197 trunk/pihlaja/src/shiraz/ui/Paned.d
r68 r74 356 356 updatePanedControllersXPosFromValue(); 357 357 return ret; 358 } 359 360 /** 361 * No effect because it would screw up the Paned system. 362 */ 363 void sendToTop( Rectangle wid ) 364 { 365 debug(Paned) Trace.formatln("Paned.sendToTop(Widget) START."); 366 debug(Paned) scope(exit) Trace.formatln("Paned.sendToTop(Widget) STOP."); 367 368 //No effect because it would screw up the Paned system. 369 } 370 371 /** 372 * Bring this widget to be the lowest widget 373 * in it's container. No effect because it would screw up the Paned system. 374 */ 375 void sendToBottom( Rectangle wid ) 376 { 377 debug(Paned) Trace.formatln("Paned.sendToBottom(Widget) START."); 378 debug(Paned) scope(exit) Trace.formatln("Paned.sendToBottom(Widget) STOP."); 379 380 //No effect because it would screw up the Paned system. 358 381 } 359 382 trunk/pihlaja/src/shiraz/ui/ProgressBar.d
r68 r74 28 28 import shiraz.Shiraz; 29 29 import shiraz.ui.InputState; 30 import shiraz.ui.Animator; 30 31 import shiraz.ui.Widget; 31 32 import shiraz.canvas.Rectangle; … … 138 139 //progressRect.x2 = progressRect.x2 - delt; 139 140 if( progressRect !is null ) 141 { 140 142 progressRect.w = (progressRect.w * fraction); 143 progressRect.xPos = -((w*0.5f) - (progressRect.w*0.5f) ); 144 } 141 145 } 142 146 … … 152 156 } 153 157 protected float m_fraction = 0.0f; 158 159 void fractionAnim( float to_set, void delegate() set_when_finished = null ) 160 { 161 Animator to_anim = new Animator(this, &fraction, &fraction, null, null, null, null, set_when_finished ); 162 to_anim.animateTo( to_set, 0.0f, 0.0f ); 163 add(to_anim); 164 } 154 165 155 166 //orientation - left to right etc. trunk/pihlaja/src/shiraz/ui/SubWindow.d
r73 r74 32 32 import shiraz.ui.Animator; 33 33 import shiraz.ui.Button; 34 import shiraz.ui.Box;//Just for class Menu35 34 import shiraz.ui.Label; 36 35 import shiraz.canvas.Rectangle; … … 391 390 if( set_type == WindowHeaderType.NORMAL ) 392 391 { 393 defaultHeight = 0.03f;394 maxHeight = 0.03f;392 defaultHeight = g_shiraz.getValueFromTheme("Shiraz.WindowHeader.NORMAL.defaultHeight"); 393 maxHeight = g_shiraz.getValueFromTheme("Shiraz.WindowHeader.NORMAL.defaultHeight"); 395 394 } 396 395 else if ( set_type == WindowHeaderType.SMALL ) 397 396 { 398 defaultHeight = 0.02f;399 maxHeight = 0.02f;397 defaultHeight = g_shiraz.getValueFromTheme("Shiraz.WindowHeader.SMALL.defaultHeight"); 398 maxHeight = g_shiraz.getValueFromTheme("Shiraz.WindowHeader.SMALL.defaultHeight"); 400 399 } 401 400 … … 860 859 controlWidget.sizeAnim( controlWidget.parent.w, controlWidget.parent.h ); 861 860 862 //The more detailed API: 861 //The more detailed API: BROKEN... needs Rectangle.add(Animator). 863 862 /* 864 863 Animator to_anim = new Animator(controlWidget, &controlWidget.xPos, &controlWidget.xPos, &controlWidget.yPos, &controlWidget.yPos, null, null ); … … 885 884 Animator to_anim = new Animator(controlWidget, &controlWidget.xPos, &controlWidget.xPos, &controlWidget.yPos, &controlWidget.yPos, null, null ); 886 885 to_anim.animateTo( xPosMem, yPosMem, 0.0f ); 886 controlWidget.add(to_anim); 887 887 888 888 Animator wh_anim = new Animator(controlWidget, &controlWidget.w, &controlWidget.w, &controlWidget.h, &controlWidget.h, null, null ); 889 889 wh_anim.animateTo( wMem, hMem, 0.0f ); 890 controlWidget.add(wh_anim); 890 891 /* 891 892 controlWidget.xPos = xPosMem; … … 1043 1044 //resizeButton.maxWidth = 0.025f; 1044 1045 //resizeButton.maxHeight = 0.025f;//Symmetrical option TODO. 1045 resizeButton.defaultSize( 0.03f, 0.03f ); 1046 //resizeButton.defaultSize( 0.03f, 0.03f ); 1047 if( set_bottom_header_type == WindowHeaderType.NORMAL ) 1048 { 1049 resizeButton.defaultHeight = g_shiraz.getValueFromTheme("Shiraz.WindowHeader.NORMAL.defaultHeight"); 1050 resizeButton.defaultWidth = g_shiraz.getValueFromTheme("Shiraz.WindowHeader.NORMAL.defaultHeight"); 1051 } 1052 else if ( set_bottom_header_type == WindowHeaderType.SMALL ) 1053 { 1054 resizeButton.defaultHeight = g_shiraz.getValueFromTheme("Shiraz.WindowHeader.SMALL.defaultHeight"); 1055 resizeButton.defaultWidth = g_shiraz.getValueFromTheme("Shiraz.WindowHeader.SMALL.defaultHeight"); 1056 } 1046 1057 resizeButton.xPackOptions = PackOptions.SHRINK; 1047 1058 resizeButton.yPackOptions = PackOptions.SHRINK; … … 1058 1069 }//if has_bottomheader 1059 1070 1060 signalEnterNotify.attach(&windowHandler);1061 signalLeaveNotify.attach(&windowHandler);1071 //signalEnterNotify.attach(&windowHandler); 1072 //signalLeaveNotify.attach(&windowHandler); 1062 1073 1063 1074 if( use_fbo_clipping ) … … 1303 1314 */ 1304 1315 1316 /* 1305 1317 void windowHandler( InputState input, Rectangle wid ) 1306 1318 { … … 1318 1330 //sendToTop(); 1319 1331 1320 / *if( hasAnimators == false )1321 {1322 addDefaultAnimator( DefaultAnimator.RAISE );1323 }*/1332 //if( hasAnimators == false ) 1333 //{ 1334 // addDefaultAnimator( DefaultAnimator.RAISE ); 1335 //} 1324 1336 break; 1325 1337 case SEventType.LEAVE_NOTIFY: … … 1333 1345 } 1334 1346 } 1347 */ 1335 1348 1336 1349 void headerHandler( InputState input, Rectangle wid ) … … 1562 1575 } 1563 1576 1564 class Menu : public HBox1565 {1566 public:1567 this()1568 {1569 Trace.formatln("Menu.this() START.");1570 scope(exit) Trace.formatln("Menu.this() END.");1571 1572 super();1573 name = "Menu";1574 1575 colour = g_shiraz.getColourFromTheme("Shiraz.Button");1576 texture = g_shiraz.getTextureFromTheme("Shiraz.Button");1577 1578 //signalMouseButtonPress.attach(&mouseHandler);1579 1580 //menuWindows = new LinkSeq!(MenuWindow);1581 }1582 1583 void addMenuItem(MenuItem add_item)1584 {1585 add_item.menu = this;1586 add_item.createMenuWindow(this);1587 super.add(add_item);1588 }1589 1590 void mouseHandler( InputState input, Rectangle wid )1591 {1592 input.isHandled = true;1593 1594 MenuItem a_item = cast(MenuItem)wid;1595 1596 switch( input.eventType )1597 {1598 default:1599 break;1600 case SEventType.ENTER_NOTIFY:1601 if( isOpened == true && currentOpenMenuItem !is a_item )1602 {1603 Trace.formatln("Enter_notify menuitem: {}", a_item.name );1604 if( currentOpenMenuItem !is null )1605 currentOpenMenuItem.hideMenuWindow();1606 currentOpenMenuItem = a_item;1607 a_item.showMenuWindow();1608 }1609 //wid.prelight();1610 //wid.sendToTop();1611 break;1612 case SEventType.LEAVE_NOTIFY:1613 Trace.formatln("Leave_notify menuitem: {}", a_item.name );1614 //wid.unprelight();1615 break;1616 case SEventType.MOUSE_BUTTON_PRESS:1617 Trace.formatln("Press menuitem: {}", a_item.name );1618 isOpened = true;1619 currentOpenMenuItem = a_item;1620 a_item.showMenuWindow();1621 //wid.grabInput();1622 //wid.sendToTop();1623 break;1624 case SEventType.MOUSE_BUTTON_RELEASE:1625 Trace.formatln("Release menuitem: {}", a_item.name );1626 //a_item.hideMenuWindow();1627 //wid.ungrabInput();1628 break;1629 }1630 1631 if( input.mouse.button[MouseButton.LEFT] == true )1632 {1633 //myWindow4.moveTo( input.mouse.x, input.mouse.y );1634 //wid.move( input.mouse.xRel, input.mouse.yRel );1635 //Trace.formatln( "xrel: {} yrel: {}", input.mouse.xRel, input.mouse.yRel );1636 }1637 }1638 1639 void close()1640 {1641 foreach(Rectangle item; itemList)1642 {1643 (cast(MenuItem)item).hideMenuWindow();1644 }1645 1646 isOpened = false;1647 }1648 1649 bool isOpened = false;//TODO make into protected property.1650 MenuItem currentOpenMenuItem;1651 1652 //LinkSeq!(MenuWindow) menuWindows;1653 }1654 1655 class MenuItem : public Button1656 {1657 public:1658 this(char[] set_name, void delegate() set_on_activate = null )1659 {1660 Trace.formatln("MenuItem.this() START.");1661 scope(exit) Trace.formatln("MenuItem.this() END.");1662 1663 super(set_name);1664 1665 isOutline = false;1666 1667 xPackOptions = PackOptions.SHRINK;1668 yPackOptions = PackOptions.SHRINK;1669 1670 inPadding = 0.015f;1671 padding = 0.0f;1672 1673 texture = null;1674 1675 colour = g_shiraz.getColourFromTheme("Shiraz.MenuItem");1676 1677 if( set_on_activate !is null )1678 signalActivate.attach(set_on_activate);1679 1680 /*1681 menuButton = new Button(set_name);1682 menuButton.texture = null;1683 menuButton.padding = 0.0f;1684 add(menuButton);1685 */1686 1687 //keyShortCutLabel = new Label("Key");1688 //add(keyShortCutLabel);1689 1690 }1691 1692 void addMenuItem(MenuItem add_item)1693 {1694 if( menu is null )1695 {1696 Trace.formatln("MenuItem.addMenuItem() ERROR: You have to add the MenuItem to a Menu before adding MenuItems to it.");1697 return;1698 }1699 add_item.menu = menu;1700 if( menuWindow is null )1701 createMenuWindow(menu);1702 //There should be some more handling of menuitems inside menuitems * 3.1703 1704 if( menuWindow !is null )1705 menuWindow.add(add_item);1706 1707 arrange();1708 invalidate();1709 menuWindow.arrange();1710 menuWindow.invalidate();1711 }1712 1713 bool isMainMenu = false;1714 Menu menu;1715 1716 void onActivate()1717 {1718 if( isMainMenu == false && menu !is null )1719 menu.close();1720 //in super.onActivate(): signalActivate.call();1721 super.onActivate();1722 }1723 1724 //internal:1725 //RENAME to initForMenu(Menu set_menu)1726 public void createMenuWindow(Menu set_menu)1727 {1728 isMainMenu = true;1729 texture = g_shiraz.getTextureFromTheme("Shiraz.Button");1730 1731 menu = set_menu;1732 1733 menuWindow = new MenuWindow();1734 menuWindow.defaultSize( 0.25f, 0.35f );1735 1736 signalMouseButtonPress.attach(&menu.mouseHandler);1737 signalMouseButtonRelease.attach(&menu.mouseHandler);1738 signalEnterNotify.attach(&menu.mouseHandler);1739 signalLeaveNotify.attach(&menu.mouseHandler);1740 1741 arrange();1742 invalidate();1743 //signalActivate.attach(&showMenuWindow);1744 //signalMouseButtonPress.attach(&showMenuWindow);1745 //signalMouseButtonRelease.attach(&hideMenuWindow);1746 }1747 1748 1749 /*1750 void renderChildren(Draw draw)1751 {1752 super.renderChildren(draw);1753 1754 if( menuWindow !is null )1755 menuWindow.render(draw);1756 }1757 */1758 1759 void arrange()1760 {1761 super.arrange();1762 1763 if( menuWindow !is null )1764 {1765 menuWindow.yPos = yPos2c + ((h*0.5f) + (menuWindow.h*0.5f));1766 menuWindow.xPos = xPos2c + (menuWindow.w*0.5f) - (w*0.5f);1767 }1768 }1769 1770 void showMenuWindowHandler( InputState input, Rectangle wid )1771 {1772 input.isHandled = true;1773 showMenuWindow();1774 }1775 1776 void showMenuWindow()1777 {1778 if( menuWindow !is null )1779 {1780 if( menuWindow.a != 1.0f )1781 menuWindow.a = 0.0f;1782 if( menuWindow.parent is null )1783 {1784 Trace.formatln("Adding menuWindow into rootWindow for the first time.");1785 rootWindow.addToCanvas( menuWindow );1786 }1787 menuWindow.show();1788 menuWindow.sendToTop();1789 if( menuWindow.a != 1.0f )1790 menuWindow.aAnim(1.0f);1791 }1792 }1793 1794 void hideMenuWindowHandler( InputState input, Rectangle wid )1795 {1796 input.isHandled = true;1797 hideMenuWindow();1798 }1799 1800 void hideMenuWindow()1801 {1802 if( menuWindow !is null )1803 {&nbs
