@@ -56,16 +56,13 @@ var Pointer = function (ui, x, y, key, frame) {
56
56
57
57
this . lbl = this . ui . add . label ( x + 20 , y + 20 , "" ) . setFontStyle ( PathBuilder . UI . fonts [ "Label" ] ) ;
58
58
59
- //TODO: implement container
60
- this . linebutton = this . ui . add . text ( x , y , "Line" , null , null , null , this . switchdrawmode , [ "Line" ] , this ) . setFontStyle ( PathBuilder . UI . fonts [ "Button" ] ) ;
61
- this . quadbutton = this . ui . add . text ( x , y , "Quadratic" , null , null , null , this . switchdrawmode , [ "QuadraticBezier" ] , this ) . setFontStyle ( PathBuilder . UI . fonts [ "Button" ] ) ;
62
- this . cubicbutton = this . ui . add . text ( x , y , "Cubic" , null , null , null , this . switchdrawmode , [ "CubicBezier" ] , this ) . setFontStyle ( PathBuilder . UI . fonts [ "Button" ] ) ;
63
- this . splinebutton = this . ui . add . text ( x , y , "Spline" , null , null , null , this . switchdrawmode , [ "Spline" ] , this ) . setFontStyle ( PathBuilder . UI . fonts [ "Button" ] ) ;
64
- this . ellipsebutton = this . ui . add . text ( x , y , "Ellipse" , null , null , null , this . switchdrawmode , [ "Ellipse" ] , this ) . setFontStyle ( PathBuilder . UI . fonts [ "Button" ] ) ;
59
+ this . menu = this . ui . add . menu ( x , y ) ;
65
60
66
- this . menu = [ this . linebutton , this . quadbutton , this . cubicbutton , this . splinebutton , this . ellipsebutton ] ;
67
-
68
- this . menu . forEach ( function ( element ) { element . setVisible ( false ) } ) ;
61
+ this . menu . add ( - 50 , - 50 , "Line" , this . switchdrawmode , [ "Line" ] , this ) ;
62
+ this . menu . add ( 0 , - 50 , "Quadratic" , this . switchdrawmode , [ "Quadratic" ] , this ) ;
63
+ this . menu . add ( 50 , - 50 , "Cubic" , this . switchdrawmode , [ "Cubic" ] , this ) ;
64
+ this . menu . add ( - 50 , 50 , "Spline" , this . switchdrawmode , [ "Spline" ] , this ) ;
65
+ this . menu . add ( 0 , 50 , "Ellipse" , this . switchdrawmode , [ "Ellipse" ] , this ) ;
69
66
70
67
this . scene . events . on ( 'switchmode' , this . switchmode , this ) ;
71
68
@@ -85,22 +82,21 @@ Pointer.prototype.switchmode = function (mode) {
85
82
86
83
this . setVisible ( true ) ;
87
84
this . lbl . setVisible ( true ) ;
88
- this . menu . forEach ( function ( element ) { element . setVisible ( false ) } ) ;
85
+ this . menu . hide ( ) ;
86
+
89
87
}
90
88
if ( mode == "normal" ) {
91
89
92
90
this . setVisible ( false ) ;
93
- this . menu . forEach ( function ( element ) { element . setVisible ( false ) } ) ;
91
+ this . menu . hide ( ) ;
92
+
94
93
}
95
94
if ( mode == "select" ) {
96
95
this . setVisible ( false ) ;
97
- this . menu . forEach ( function ( element ) { element . setVisible ( true ) } ) ;
98
-
99
- this . linebutton . setPosition ( this . x - 50 , this . y - 50 ) ;
100
- this . quadbutton . setPosition ( this . x , this . y - 50 ) ;
101
- this . cubicbutton . setPosition ( this . x + 50 , this . y - 50 ) ;
102
- this . splinebutton . setPosition ( this . x - 50 , this . y + 50 ) ;
103
- this . ellipsebutton . setPosition ( this . x , this . y + 50 ) ;
96
+
97
+ this . menu . setPosition ( this . x , this . y ) ;
98
+ this . menu . show ( ) ;
99
+
104
100
}
105
101
if ( mode == "hand" ) {
106
102
game . canvas . style . cursor = "grab" ;
@@ -117,7 +113,7 @@ Pointer.prototype.switchCursor = function(){
117
113
Pointer . prototype . switchdrawmode = function ( mode ) {
118
114
this . scene . drawmode = mode ;
119
115
this . scene . drawmodelabel . setText ( "curve: " + mode ) ;
120
- this . menu . forEach ( function ( element ) { element . setVisible ( false ) } ) ;
116
+ this . menu . hide ( ) ;
121
117
this . scene . switchmode ( "draw" ) ;
122
118
}
123
119
0 commit comments