|
1 | | -namespace microgui { |
2 | | - const app = new microgui.App(); |
3 | | - |
4 | | - // const simpleTextComponent = new TextBox({ |
5 | | - // alignment: GUIComponentAlignment.TOP, |
6 | | - // isActive: false, |
7 | | - // title: "Title Text :)", |
8 | | - // text: ["Hello there,", "I hope you are well.", "Isn't this neat?"], |
9 | | - // colour: 6, |
10 | | - // xScaling: 1.7, |
11 | | - // }) |
12 | | - |
13 | | - // const simpleBtnComponent = new ButtonCollection({ |
14 | | - // alignment: GUIComponentAlignment.BOT_RIGHT, |
15 | | - // btns: [[new Button({ icon: "accelerometer", onClick: () => basic.showNumber(0)})]], |
16 | | - // isActive: true, |
17 | | - // }) |
18 | | - |
19 | | - // const window = new Window({ app, components: [simpleTextComponent]}) |
20 | | - // app.pushScene(window) |
21 | | - |
22 | | - |
23 | | - |
24 | | - // const comp1 = new ButtonCollection({ |
25 | | - // alignment: GUIComponentAlignment.TOP, |
26 | | - // btns: [ |
27 | | - // [new Button({ icon: "pin_0", ariaId: "0", x: 0, y: 0, onClick: () => basic.showNumber(0) }), |
28 | | - // new Button({ icon: "pin_1", ariaId: "1", x: 20, y: 0, onClick: () => basic.showNumber(1) })], |
29 | | - // [new Button({ icon: "green_tick", ariaId: "Done", x: 20, y: 20, onClick: () => Window.makeComponentActive(1, false) })] |
30 | | - // ], |
31 | | - // isActive: true, |
32 | | - // }) |
33 | | - |
34 | | - // const comp2 = new ButtonCollection({ |
35 | | - // alignment: GUIComponentAlignment.LEFT, |
36 | | - // btns: [ |
37 | | - // [new Button({ icon: "thermometer", ariaId: "", x: 10, y: 0, onClick: () => basic.showNumber(0) })], |
38 | | - // [new Button({ icon: "green_tick", ariaId: "", x: 10, y: 20, onClick: () => Window.makeComponentActive(2, true) })] |
39 | | - // ], |
40 | | - // isActive: false, |
41 | | - // isHidden: true, |
42 | | - // colour: 2, |
43 | | - // }) |
44 | | - |
45 | | - // /** |
46 | | - // * Grid of buttons in the centre of the screen, |
47 | | - // * Press done to go somewhere else. |
48 | | - // */ |
49 | | - // const comp3 = new ButtonCollection({ |
50 | | - // alignment: GUIComponentAlignment.CENTRE, |
51 | | - // btns: [ |
52 | | - // [ // Row 1: |
53 | | - // new Button({ icon: "thermometer", ariaId: "0", x: 5, y: 5, onClick: () => basic.showNumber(0) }), |
54 | | - // new Button({ icon: "thermometer", ariaId: "1", x: 25, y: 5, onClick: () => basic.showNumber(1) }), |
55 | | - // new Button({ icon: "thermometer", ariaId: "2", x: 45, y: 5, onClick: () => basic.showNumber(2) }), |
56 | | - // new Button({ icon: "thermometer", ariaId: "3", x: 65, y: 5, onClick: () => basic.showNumber(3) }), |
57 | | - // ], |
58 | | - // [ // Row 2: |
59 | | - // new Button({ icon: "thermometer", ariaId: "4", x: 5, y: 30, onClick: () => basic.showNumber(4) }), |
60 | | - // new Button({ icon: "thermometer", ariaId: "5", x: 25, y: 30, onClick: () => basic.showNumber(5) }), |
61 | | - // new Button({ icon: "thermometer", ariaId: "6", x: 45, y: 30, onClick: () => basic.showNumber(6) }), |
62 | | - // new Button({ icon: "green_tick", ariaId: "", x: 65, y: 30, onClick: () => Window.makeComponentActive(0, true) }) |
63 | | - // ], |
64 | | - // ], |
65 | | - // isActive: false, |
66 | | - // isHidden: true, |
67 | | - // xScaling: 1.1, |
68 | | - // colour: 6, |
69 | | - // }) |
70 | | - |
71 | | - // const window = new Window({app, components: [comp1, comp2, comp3] }) |
72 | | - // app.pushScene(window) |
73 | | - |
74 | | - |
75 | | - |
76 | | - |
77 | | - // let count = 0; |
78 | | - // const comp1 = new ButtonCollection({ |
79 | | - // alignment: GUIComponentAlignment.TOP, |
80 | | - // btns: [ |
81 | | - // [new Button({ |
82 | | - // icon: "pin_0", ariaId: "+1", x: 10, y: 10, onClick: () => { |
83 | | - // count += 1; |
84 | | - // } |
85 | | - // })], |
86 | | - // ], |
87 | | - // isActive: true, |
88 | | - // colour: 2, |
89 | | - // xScaling: 0.5, |
90 | | - // yScaling: 0.7, |
91 | | - // xOffset: -10 |
92 | | - // }) |
93 | | - |
94 | | - // const comp2 = new GUIGraph({ |
95 | | - // alignment: GUIComponentAlignment.BOT, |
96 | | - // graphableFns: [new GraphableFunction((_) => count)], |
97 | | - // isActive: false, |
98 | | - // }) |
99 | | - |
100 | | - // const window = new Window({ app, components: [comp1, comp2] }) |
101 | | - // app.pushScene(window) |
102 | | - |
103 | | - |
104 | | - |
105 | | - const txtBtnComp = new TextButtonCollection({ |
106 | | - alignment: GUIComponentAlignment.CENTRE, |
107 | | - isActive: true, |
108 | | - textBtns: [ |
109 | | - new TextButton({ text: "Text Btn 1", callback: () => basic.showString("hi") }), |
110 | | - new TextButton({ text: "Text Btn 2", callback: () => basic.showString("yo") }) |
111 | | - ], |
112 | | - xOffset: 10, |
113 | | - title: "Title :)" |
114 | | - }) |
115 | | - const window = new Window({ app, components: [txtBtnComp] }) |
116 | | - app.pushScene(window) |
117 | | -} |
| 1 | +// namespace microgui { |
| 2 | +// import AppInterface = user_interface_base.AppInterface |
| 3 | +// import Scene = user_interface_base.Scene |
| 4 | + |
| 5 | +// const app = new microgui.App(); |
| 6 | + |
| 7 | +// // const simpleTextComponent = new TextBox({ |
| 8 | +// // alignment: GUIComponentAlignment.TOP, |
| 9 | +// // isActive: false, |
| 10 | +// // title: "Title Text :)", |
| 11 | +// // text: ["Hello there,", "I hope you are well.", "Isn't this neat?"], |
| 12 | +// // colour: 6, |
| 13 | +// // xScaling: 1.7, |
| 14 | +// // }) |
| 15 | + |
| 16 | +// // const simpleBtnComponent = new ButtonCollection({ |
| 17 | +// // alignment: GUIComponentAlignment.BOT_RIGHT, |
| 18 | +// // btns: [[new Button({ icon: "accelerometer", onClick: () => basic.showNumber(0)})]], |
| 19 | +// // isActive: true, |
| 20 | +// // }) |
| 21 | + |
| 22 | +// // const window = new Window({ app, components: [simpleTextComponent]}) |
| 23 | +// // app.pushScene(window) |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +// // const comp1 = new ButtonCollection({ |
| 28 | +// // alignment: GUIComponentAlignment.TOP, |
| 29 | +// // btns: [ |
| 30 | +// // [new Button({ icon: "pin_0", ariaId: "0", x: 0, y: 0, onClick: () => basic.showNumber(0) }), |
| 31 | +// // new Button({ icon: "pin_1", ariaId: "1", x: 20, y: 0, onClick: () => basic.showNumber(1) })], |
| 32 | +// // [new Button({ icon: "green_tick", ariaId: "Done", x: 20, y: 20, onClick: () => Window.makeComponentActive(1, false) })] |
| 33 | +// // ], |
| 34 | +// // isActive: true, |
| 35 | +// // }) |
| 36 | + |
| 37 | +// // const comp2 = new ButtonCollection({ |
| 38 | +// // alignment: GUIComponentAlignment.LEFT, |
| 39 | +// // btns: [ |
| 40 | +// // [new Button({ icon: "thermometer", ariaId: "", x: 10, y: 0, onClick: () => basic.showNumber(0) })], |
| 41 | +// // [new Button({ icon: "green_tick", ariaId: "", x: 10, y: 20, onClick: () => Window.makeComponentActive(2, true) })] |
| 42 | +// // ], |
| 43 | +// // isActive: false, |
| 44 | +// // isHidden: true, |
| 45 | +// // colour: 2, |
| 46 | +// // }) |
| 47 | + |
| 48 | +// // /** |
| 49 | +// // * Grid of buttons in the centre of the screen, |
| 50 | +// // * Press done to go somewhere else. |
| 51 | +// // */ |
| 52 | +// // const comp3 = new ButtonCollection({ |
| 53 | +// // alignment: GUIComponentAlignment.CENTRE, |
| 54 | +// // btns: [ |
| 55 | +// // [ // Row 1: |
| 56 | +// // new Button({ icon: "thermometer", ariaId: "0", x: 5, y: 5, onClick: () => basic.showNumber(0) }), |
| 57 | +// // new Button({ icon: "thermometer", ariaId: "1", x: 25, y: 5, onClick: () => basic.showNumber(1) }), |
| 58 | +// // new Button({ icon: "thermometer", ariaId: "2", x: 45, y: 5, onClick: () => basic.showNumber(2) }), |
| 59 | +// // new Button({ icon: "thermometer", ariaId: "3", x: 65, y: 5, onClick: () => basic.showNumber(3) }), |
| 60 | +// // ], |
| 61 | +// // [ // Row 2: |
| 62 | +// // new Button({ icon: "thermometer", ariaId: "4", x: 5, y: 30, onClick: () => basic.showNumber(4) }), |
| 63 | +// // new Button({ icon: "thermometer", ariaId: "5", x: 25, y: 30, onClick: () => basic.showNumber(5) }), |
| 64 | +// // new Button({ icon: "thermometer", ariaId: "6", x: 45, y: 30, onClick: () => basic.showNumber(6) }), |
| 65 | +// // new Button({ icon: "green_tick", ariaId: "", x: 65, y: 30, onClick: () => Window.makeComponentActive(0, true) }) |
| 66 | +// // ], |
| 67 | +// // ], |
| 68 | +// // isActive: false, |
| 69 | +// // isHidden: true, |
| 70 | +// // xScaling: 1.1, |
| 71 | +// // colour: 6, |
| 72 | +// // }) |
| 73 | + |
| 74 | +// // const window = new Window({app, components: [comp1, comp2, comp3] }) |
| 75 | +// // app.pushScene(window) |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +// // let count = 0; |
| 81 | +// // const comp1 = new ButtonCollection({ |
| 82 | +// // alignment: GUIComponentAlignment.TOP, |
| 83 | +// // btns: [ |
| 84 | +// // [new Button({ |
| 85 | +// // icon: "pin_0", ariaId: "+1", x: 10, y: 10, onClick: () => { |
| 86 | +// // count += 1; |
| 87 | +// // } |
| 88 | +// // })], |
| 89 | +// // ], |
| 90 | +// // isActive: true, |
| 91 | +// // colour: 2, |
| 92 | +// // xScaling: 0.5, |
| 93 | +// // yScaling: 0.7, |
| 94 | +// // xOffset: -10 |
| 95 | +// // }) |
| 96 | + |
| 97 | +// // const comp2 = new GUIGraph({ |
| 98 | +// // alignment: GUIComponentAlignment.BOT, |
| 99 | +// // graphableFns: [new GraphableFunction((_) => count)], |
| 100 | +// // isActive: false, |
| 101 | +// // }) |
| 102 | + |
| 103 | +// // const window = new Window({ app, components: [comp1, comp2] }) |
| 104 | +// // app.pushScene(window) |
| 105 | + |
| 106 | +// class Test extends Scene { |
| 107 | +// private components: GUIComponentAbstract[]; |
| 108 | +// private currentComponentID: number; |
| 109 | + |
| 110 | +// constructor(app: AppInterface, components: GUIComponentAbstract[]) { |
| 111 | +// super() |
| 112 | +// this.components = components |
| 113 | +// this.currentComponentID = 0; |
| 114 | + |
| 115 | +// if (this.components != null) |
| 116 | +// this.focus(true) |
| 117 | +// } |
| 118 | + |
| 119 | +// public makeComponentActive(componentID: number, hideOthers: boolean) { |
| 120 | +// this.currentComponentID = componentID; |
| 121 | +// this.focus(hideOthers); |
| 122 | +// } |
| 123 | + |
| 124 | +// public updateComponentsContext(componentID: number, context: any[]) { |
| 125 | +// this.components[componentID].addContext(context) |
| 126 | +// } |
| 127 | + |
| 128 | +// /* override */ startup() { |
| 129 | +// super.startup() |
| 130 | +// } |
| 131 | + |
| 132 | +// private focus(hideOthers: boolean) { |
| 133 | +// if (hideOthers) |
| 134 | +// this.components.forEach(component => { component.hide() }) |
| 135 | +// this.components.forEach(component => { component.unmakeActive() }) |
| 136 | + |
| 137 | +// this.components[this.currentComponentID].unHide() |
| 138 | +// this.components[this.currentComponentID].makeActive() |
| 139 | +// } |
| 140 | + |
| 141 | +// draw() { |
| 142 | +// screen().fillRect( |
| 143 | +// 0, |
| 144 | +// 0, |
| 145 | +// screen().width, |
| 146 | +// screen().height, |
| 147 | +// this.backgroundColor |
| 148 | +// ) |
| 149 | + |
| 150 | +// if (this.components != null) { |
| 151 | +// this.components.forEach(component => { |
| 152 | +// if (!component.hidden && !component.active) |
| 153 | +// component.draw() |
| 154 | +// }) |
| 155 | +// } |
| 156 | + |
| 157 | +// // Always draw active ontop |
| 158 | +// this.components[this.currentComponentID].draw() |
| 159 | +// } |
| 160 | +// } |
| 161 | + |
| 162 | + |
| 163 | +// const txtBtnComp = new TextButtonCollection({ |
| 164 | +// alignment: GUIComponentAlignment.CENTRE, |
| 165 | +// isActive: true, |
| 166 | +// textBtns: [ |
| 167 | +// new TextButton({ text: "Text Btn 1", callback: () => basic.showString("hi") }), |
| 168 | +// new TextButton({ text: "Text Btn 2", callback: () => basic.showString("yo") }) |
| 169 | +// ], |
| 170 | +// xOffset: 10, |
| 171 | +// title: "Title :)" |
| 172 | +// }) |
| 173 | + |
| 174 | +// const txtBtnComp2 = new TextButtonCollection({ |
| 175 | +// alignment: GUIComponentAlignment.TOP, |
| 176 | +// isActive: false, |
| 177 | +// textBtns: [ |
| 178 | +// new TextButton({ text: "Text Btn 3", callback: () => basic.showString("A") }), |
| 179 | +// new TextButton({ text: "Text Btn 4", callback: () => basic.showString("b") }) |
| 180 | +// ], |
| 181 | +// xOffset: 10, |
| 182 | +// title: "Title :(" |
| 183 | +// }) |
| 184 | + |
| 185 | +// const window = new Test(app, [txtBtnComp]) |
| 186 | +// app.pushScene(window) |
| 187 | + |
| 188 | +// input.onButtonPressed(Button.A, function() { |
| 189 | +// const window2 = new Test(app, [txtBtnComp2]) |
| 190 | + |
| 191 | +// app.popScene() |
| 192 | +// app.pushScene(window2) |
| 193 | +// }) |
| 194 | +// } |
0 commit comments