-
Notifications
You must be signed in to change notification settings - Fork 0
/
Components.ewu
4508 lines (3808 loc) · 139 KB
/
Components.ewu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
$version 12.00
// Components
note group Note1
{
attr Bounds = <10,0,450,370>;
}
// This class implements a 'push button' widget. When the user presses the button, \
// a signal is sent to the slot method stored in its @OnActivate property.
$rect <20,50,220,90>
$output false
class ButtonBase70x90 : Templates::PushButton
{
$rect <0,110,200,150>
inherited property Bounds = <0,0,70,90>;
$rect <20,370,220,410>
inherited method UpdateViewState()
{
// Always invoke the inherited method.
super( aState );
// Determine the new state of the push button.
//
// isEnabled --> the button can react to user inputs.
// isSelected --> the button can receive keyboard events.
// isPressed --> the button should appear pressed.
//
var bool isEnabled = aState.contains( Core::ViewState[ Enabled ]);
var bool isSelected = aState.contains( Core::ViewState[ Selected ]);
var bool isPressed = ( TouchHandler.Down && TouchHandler.Inside ) ||
FlashTimer.Enabled;
Background.Bitmap = Backgound;
// Update the parameters of the text view (label)
if ( InitialsTxt != null )
{
InitialsTxt.Font = IconFont;
InitialsTxt.String = Icon;
InitialsTxt.Color = IconColor;
}
// Update the parameters of the text view (label)
if ( DescripTxt != null )
{
DescripTxt.Font = DescriptFont;
DescripTxt.String = Descript;
DescripTxt.Color = DescriptColor;
}
if ( !isEnabled )
{
Background.Color = BackgroundColorEnabled;
DescripTxt.Color = DescriptColorEnabled;
InitialsTxt.Color = IconColorEnabled;
//Border.Color = #CCCCCCFF;
//Border.Width = 1;
}
else if ( isPressed )
{
Background.Color = BackgoundColorPressed;
DescripTxt.Color = DescriptColorPressed;
InitialsTxt.Color = IconColorPressed;
//Border.Color = #000000FF;
// Border.Width = 3;
}
else if ( isSelected )
{
Background.Color =BackgoundColor;
// Border.Color = #444444FF;
// Border.Width = 3;
}
// Enabled but not pressed nor selected.
else
{
Background.Color = BackgoundColor;
// Border.Color = #444444FF;
// Border.Width = 1;
}
// Remember the current state. Next time when the UpdateViewState() is called
// you can compare the 'old' state with the 'new' state and perform more
// sophisticated update, e.g. you can start an animation effect for the
// pressed <<-->> not pressed transition.
enabled = isEnabled;
selected = isSelected;
pressed = isPressed;
}
// State management
note group Note4
{
attr Bounds = <10,330,230,600>;
}
// Feedback flash effect
note group Note3
{
attr Bounds = <240,470,460,600>;
}
// Keyboard events
note group Note2
{
attr Bounds = <240,330,460,460>;
}
// Touch screen events
note group Note1
{
attr Bounds = <10,150,230,320>;
}
// This variable stores the current state of the button.
$rect <20,490,220,530>
var bool pressed;
// This variable stores the current state of the button.
$rect <20,450,220,490>
var bool selected;
// This variable stores the current state of the button.
$rect <20,410,220,450>
var bool enabled;
// This timer object is used to flash the button when the user has tapped it very \
// quickly or the button has been activated with the keyboard. This is just a visual \
// feedback effect.
$rect <250,510,450,550>
object Core::Timer FlashTimer
{
preset OnTrigger = onFlashTimer;
preset Period = 0;
preset Begin = 50;
}
// This key handler reacts to key press events. When the user presses the key specified \
// in the property 'Filter' of the key handler, the handler is activated and the \
// method '@onPressKey' is called.
$rect <250,370,450,410>
object Core::KeyPressHandler KeyHandler
{
preset OnPress = onPressKey;
preset Filter = Core::KeyCode.Enter;
}
// This internal slot method is called when the '@FlashTimer' is expired. It ends \
// the short flash feedback effect.
$rect <250,550,450,590>
slot onFlashTimer
{
// The feedback flash timer is finished. Request the button to update its
// appearance. The update will occur in the UpdateViewState() method.
InvalidateViewState();
// With the end of the feedback flash effect the button is activated.
postsignal OnActivate;
}
// This internal slot method is called when the '@KeyHandler' is activated (when \
// the user has pressed the key specified in the property 'Filter' of the key handler).
$rect <250,410,450,450>
slot onPressKey
{
// Ignore keyboard events when the user is interacting with the button via the
// touch screen.
if ( TouchHandler.Down )
return;
// Ignore repetitions of key events (e.g. when the user holds the key pressed)
if ( KeyHandler.Repetition )
return;
// Pressing the key flashes the button for a short period. This is a kind of
// feedback effect. Request the button to update its appearance accordingly.
// The update will occur in the UpdateViewState() method.
InvalidateViewState();
// The button is still performing the feedback flash effect from the preceding
// tap/key event. This can occur when the user taps the button or presses the
// key in a very rapid succession. Thus complete this preceding tap (simulate
// the timer expiration) before starting a new button interaction.
if ( FlashTimer.Enabled )
{
postsignal OnActivate;
FlashTimer.Enabled = false;
}
// Start the feedback flash effect.
FlashTimer.Enabled = true;
}
// This internal slot method is called when the user drags the finger while pressing \
// the button. This only updates the button to appear pressed or released.
$rect <20,270,220,310>
slot onEnterLeaveTouch
{
// Every time the user touches the button or drags the finger inside/outside
// the button's area request the button update its appearance. The update will
// occur in the UpdateViewState() method.
InvalidateViewState();
}
// This internal slot method is called when the user releases the touch screen \
// after touching the button's area. This activates the button.
$rect <20,230,220,270>
slot onReleaseTouch
{
// Did the user moved the finger outside the button's area? In such case
// the button is not activated.
if ( !TouchHandler.Inside )
return;
// The user interaction has been passed over to the another touch handler
if ( TouchHandler.AutoDeflected )
return;
// The user has pressed and held the button for longer time. This was enough
// long to give a visual 'press' feedback to the user. The button can be
// activated immediately.
if ( TouchHandler.HoldPeriod >= FlashTimer.Begin )
postsignal OnActivate;
// The user has tapped the button very quickly. Defer the button activation
// to give the user first a short visual feedback that the button has been
// pressed.
else
FlashTimer.Enabled = true;
}
// This internal slot method is called when the user touches the button's area.
$rect <20,190,220,230>
slot onPressTouch
{
// The button is still performing the feedback flash effect from the preceding
// tap. This can occur when the user taps the button in a very rapid succession.
// Thus complete this preceding tap (simulate the timer expiration) before
// starting a new button interaction.
if ( FlashTimer.Enabled )
{
postsignal OnActivate;
FlashTimer.Enabled = false;
}
}
$rect <450,50,650,90>
onset Icon
{
// The value doesn't change - nothing to do.
if ( pure Icon == value )
return;
// Remember the property's new value.
pure Icon = value;
// ... and trigger the component to update its actual state.
InvalidateViewState();
}
// The property 'Label' specifies the text to display as label in this push button \
// widget. The desired font as well as the colors for all individual button states \
// have to be specified in the configuration object assigned to the property @Appearance. \
// If there is no configuration object associated to this push button widget (the \
// property @Appearance is 'null'), no label is displayed.
// Per default, the label is displayed centered within the push button area. You \
// can modify the alignment of the label as well as its margins by specifying them \
// in the configuration object.
$rect <450,10,650,50>
property string Icon = "";
// The property 'OnActivate' can refer to a slot method, which will receive a signal \
// as soon as the user has activated the button. Thereupon the method's logic will \
// be executed.
$rect <250,10,450,50>
property slot OnActivate = null;
$rect <20,530,220,570>
var Views::Text textView;
$rect <660,10,860,50>
property string Descript = "";
$rect <660,50,860,90>
onset Descript
{
// The value doesn't change - nothing to do.
if ( pure Descript == value )
return;
// Remember the property's new value.
pure Descript = value;
// ... and trigger the component to update its actual state.
InvalidateViewState();
}
$rect <660,90,860,130>
property color DescriptColor = Res::Blue;
$rect <660,130,860,170>
onset DescriptColor
{
// The value doesn't change - nothing to do.
if ( pure DescriptColor == value )
return;
// Remember the property's new value.
pure DescriptColor = value;
// ... and trigger the component to update its actual state.
InvalidateViewState();
}
$rect <450,90,650,130>
property color IconColor = Res::WhiteComponents;
$rect <450,130,650,170>
onset IconColor
{
// The value doesn't change - nothing to do.
if ( pure IconColor == value )
return;
// Remember the property's new value.
pure IconColor = value;
// ... and trigger the component to update its actual state.
InvalidateViewState();
}
$rect <870,90,1070,130>
property color BackgoundColor = Res::Grey;
$rect <870,130,1070,170>
onset BackgoundColor
{
// The value doesn't change - nothing to do.
if ( pure BackgoundColor == value )
return;
// Remember the property's new value.
pure BackgoundColor = value;
InvalidateViewState();
}
$rect <870,170,1070,210>
property color BackgoundColorPressed = Res::GreyLight;
$rect <870,210,1070,250>
onset BackgoundColorPressed
{
// The value doesn't change - nothing to do.
if ( pure BackgoundColorPressed == value )
return;
// Remember the property's new value.
pure BackgoundColorPressed = value;
InvalidateViewState();
}
$rect <660,170,860,210>
property Resources::Font DescriptFont = Res::ContactFont12;
$rect <660,210,860,250>
onset DescriptFont
{
// The value doesn't change - nothing to do.
if ( pure DescriptFont == value )
return;
// Remember the property's new value.
pure DescriptFont = value;
InvalidateViewState();
}
$rect <450,170,650,210>
property Resources::Font IconFont = Res::TitileFont25;
$rect <450,210,650,250>
onset IconFont
{
// The value doesn't change - nothing to do.
if ( pure IconFont == value )
return;
// Remember the property's new value.
pure IconFont = value;
InvalidateViewState();
}
$rect <870,10,1070,50>
property Resources::Bitmap Backgound = Res::ButtonRoundBig;
$rect <870,50,1070,90>
onset Backgound
{
// The value doesn't change - nothing to do.
if ( pure Backgound == value )
return;
// Remember the property's new value.
pure Backgound = value;
InvalidateViewState();
}
$rect <870,250,1070,290>
property color BackgroundColorEnabled = Res::Grey;
$rect <870,290,1070,330>
onset BackgroundColorEnabled
{
// The value doesn't change - nothing to do.
if ( pure BackgroundColorEnabled == value )
return;
// Remember the property's new value.
pure BackgroundColorEnabled = value;
InvalidateViewState();
}
$rect <660,250,860,290>
property color DescriptColorEnabled = Res::Grey;
$rect <660,290,860,330>
onset DescriptColorEnabled
{
// The value doesn't change - nothing to do.
if ( pure DescriptColorEnabled == value )
return;
// Remember the property's new value.
pure DescriptColorEnabled = value;
InvalidateViewState();
}
$rect <450,250,650,290>
property color IconColorEnabled = Res::Grey;
$rect <450,290,650,330>
onset IconColorEnabled
{
// The value doesn't change - nothing to do.
if ( pure IconColorEnabled == value )
return;
// Remember the property's new value.
pure IconColorEnabled = value;
InvalidateViewState();
}
$rect <660,330,860,370>
property color DescriptColorPressed = Res::GreyLight;
$rect <660,370,860,410>
onset DescriptColorPressed
{
// The value doesn't change - nothing to do.
if ( pure DescriptColorPressed == value )
return;
// Remember the property's new value.
pure DescriptColorPressed = value;
// ... and trigger the component to update its actual state.
InvalidateViewState();
}
$rect <450,330,650,370>
property color IconColorPressed = Res::BlueLight;
$rect <450,370,650,410>
onset IconColorPressed
{
// The value doesn't change - nothing to do.
if ( pure IconColorPressed == value )
return;
// Remember the property's new value.
pure IconColorPressed = value;
// ... and trigger the component to update its actual state.
InvalidateViewState();
}
$rect <20,20,160,60>
object Views::Image Background
{
preset Layout = Core::Layout[AlignToBottom, AlignToLeft, AlignToRight, AlignToTop, ResizeHorz, ResizeVert];
preset Bounds = <0,0,70,70>;
preset Color = Res::WhiteComponents;
}
$rect <20,20,160,60>
object Core::SimpleTouchHandler TouchHandler
{
preset Layout = Core::Layout[AlignToBottom, AlignToLeft, AlignToRight, AlignToTop, ResizeHorz, ResizeVert];
preset Point4 = <0,91>;
preset Point3 = <70,91>;
preset Point2 = <70,0>;
preset Point1 = <0,0>;
preset OnLeave = onEnterLeaveTouch;
preset OnEnter = onEnterLeaveTouch;
preset OnRelease = onReleaseTouch;
preset OnPress = onPressTouch;
preset RetargetCondition = Core::RetargetReason[WipeDown, WipeLeft, WipeRight, WipeUp];
preset MaxStrikeCount = 100;
}
$rect <20,20,160,60>
object Views::Text InitialsTxt
{
preset Bounds = <0,0,70,70>;
preset AutoSize = true;
preset String = "";
preset Font = Res::IconsFont30;
preset Color = #FFFFFFFF;
}
$rect <20,20,160,60>
object Views::Text DescripTxt
{
preset Bounds = <0,70,70,91>;
preset AutoSize = true;
preset WrapText = true;
preset Alignment = Views::TextAlignment[AlignHorzCenter, AlignVertCenter];
preset String = "";
preset Font = Res::ContactFontBold15;
}
}
// This class implements a 'push button' widget. When the user presses the button, \
// a signal is sent to the slot method stored in its @OnActivate property.
$rect <240,90,440,130>
$output false
class Button265x470 : Templates::PushButton
{
$rect <480,310,680,350>
inherited property Bounds = <6,436,265,470>;
$rect <710,190,910,230>
inherited method UpdateViewState()
{
// Always invoke the inherited method.
super( aState );
// Determine the new state of the push button.
//
// isEnabled --> the button can react to user inputs.
// isSelected --> the button can receive keyboard events.
// isPressed --> the button should appear pressed.
//
var bool isEnabled = aState.contains( Core::ViewState[ Enabled ]);
var bool isSelected = aState.contains( Core::ViewState[ Selected ]);
var bool isPressed = ( TouchHandler.Down && TouchHandler.Inside ) ||
FlashTimer.Enabled;
/*
TO DO:
Depending on your button design, you have surely added some new views
to your button. In the below code you should update the properties of
these views. For example, when your button has two images to appear
exclusively for released and pressed button state, following can be
done:
imagePressed.Visible = isPressed;
imageReleased.Visible = !isPressed;
Depending on the state of the button, you can alternate any property
of your views. You can change their visibility, colors, opacity,
bitmaps shown in image views, fonts used to render text, the position
and the size the view, ...
HINT:
Instead of instantly alternate the views properties you can here also
start effects to do this with an animation. Important: To decide when
to start an effect you should compare the current state of the button
(e.g. 'isPressed') with its preceding state (e.g. variable 'pressed').
Assuming you have already added to your button component a new effect
member, named it 'pressedEffect' and configured it to animate e.g. the
opacity of an image within the button. Then following is sufficient to
trigger the animation:
if ( isPressed && !pressed )
{
pressedEffect.Reversed = false;
pressedEffect.Enabled = true;
}
else if ( !isPressed && pressed )
{
pressedEffect.Reversed = true;
pressedEffect.Enabled = true;
}
*/
// Update the parameters of the text view (label)
if ( Text != null )
{
var color clr = Res::Red;
Text.Font = Res::ContactFont15;
Text.String = String;
Text.Color = clr;
}
if ( !isEnabled )
{
Background.Color = Res::WhiteTransparent;
Text.Color = Res::Grey;
}
else if ( isPressed )
{
Background.Color = Res::PressColor;
Text.Color = Res::RedLight;
}
else if ( isSelected )
{
Background.Color = Res::WhiteTransparent;
}
// Enabled but not pressed nor selected.
else
{
Background.Color = Res::WhiteTransparent;
}
// Remember the current state. Next time when the UpdateViewState() is called
// you can compare the 'old' state with the 'new' state and perform more
// sophisticated update, e.g. you can start an animation effect for the
// pressed <<-->> not pressed transition.
enabled = isEnabled;
selected = isSelected;
pressed = isPressed;
}
// State management
note group Note4
{
attr Bounds = <700,150,920,400>;
}
// Feedback flash effect
note group Note3
{
attr Bounds = <470,150,690,280>;
}
// Keyboard events
note group Note2
{
attr Bounds = <240,150,460,280>;
}
// Touch screen events
note group Note1
{
attr Bounds = <10,150,230,320>;
}
// This variable stores the current state of the button.
$rect <710,310,910,350>
var bool pressed;
// This variable stores the current state of the button.
$rect <710,270,910,310>
var bool selected;
// This variable stores the current state of the button.
$rect <710,230,910,270>
var bool enabled;
// This timer object is used to flash the button when the user has tapped it very \
// quickly or the button has been activated with the keyboard. This is just a visual \
// feedback effect.
$rect <480,190,680,230>
object Core::Timer FlashTimer
{
preset OnTrigger = onFlashTimer;
preset Period = 0;
preset Begin = 50;
}
// This key handler reacts to key press events. When the user presses the key specified \
// in the property 'Filter' of the key handler, the handler is activated and the \
// method '@onPressKey' is called.
$rect <250,190,450,230>
object Core::KeyPressHandler KeyHandler
{
preset OnPress = onPressKey;
preset Filter = Core::KeyCode.Enter;
}
// This internal slot method is called when the '@FlashTimer' is expired. It ends \
// the short flash feedback effect.
$rect <480,230,680,270>
slot onFlashTimer
{
// The feedback flash timer is finished. Request the button to update its
// appearance. The update will occur in the UpdateViewState() method.
InvalidateViewState();
// With the end of the feedback flash effect the button is activated.
postsignal OnActivate;
}
// This internal slot method is called when the '@KeyHandler' is activated (when \
// the user has pressed the key specified in the property 'Filter' of the key handler).
$rect <250,230,450,270>
slot onPressKey
{
// Ignore keyboard events when the user is interacting with the button via the
// touch screen.
if ( TouchHandler.Down )
return;
// Ignore repetitions of key events (e.g. when the user holds the key pressed)
if ( KeyHandler.Repetition )
return;
// Pressing the key flashes the button for a short period. This is a kind of
// feedback effect. Request the button to update its appearance accordingly.
// The update will occur in the UpdateViewState() method.
InvalidateViewState();
// The button is still performing the feedback flash effect from the preceding
// tap/key event. This can occur when the user taps the button or presses the
// key in a very rapid succession. Thus complete this preceding tap (simulate
// the timer expiration) before starting a new button interaction.
if ( FlashTimer.Enabled )
{
postsignal OnActivate;
FlashTimer.Enabled = false;
}
// Start the feedback flash effect.
FlashTimer.Enabled = true;
}
// This internal slot method is called when the user drags the finger while pressing \
// the button. This only updates the button to appear pressed or released.
$rect <20,270,220,310>
slot onEnterLeaveTouch
{
// Every time the user touches the button or drags the finger inside/outside
// the button's area request the button update its appearance. The update will
// occur in the UpdateViewState() method.
InvalidateViewState();
}
// This internal slot method is called when the user releases the touch screen \
// after touching the button's area. This activates the button.
$rect <20,230,220,270>
slot onReleaseTouch
{
// Did the user moved the finger outside the button's area? In such case
// the button is not activated.
if ( !TouchHandler.Inside )
return;
// The user interaction has been passed over to the another touch handler
if ( TouchHandler.AutoDeflected )
return;
// The user has pressed and held the button for longer time. This was enough
// long to give a visual 'press' feedback to the user. The button can be
// activated immediately.
if ( TouchHandler.HoldPeriod >= FlashTimer.Begin )
postsignal OnActivate;
// The user has tapped the button very quickly. Defer the button activation
// to give the user first a short visual feedback that the button has been
// pressed.
else
FlashTimer.Enabled = true;
}
// This internal slot method is called when the user touches the button's area.
$rect <20,190,220,230>
slot onPressTouch
{
// The button is still performing the feedback flash effect from the preceding
// tap. This can occur when the user taps the button in a very rapid succession.
// Thus complete this preceding tap (simulate the timer expiration) before
// starting a new button interaction.
if ( FlashTimer.Enabled )
{
postsignal OnActivate;
FlashTimer.Enabled = false;
}
}
$rect <20,20,160,60>
object Views::Rectangle Background
{
preset Layout = Core::Layout[AlignToBottom, AlignToLeft, AlignToRight, AlignToTop, ResizeHorz, ResizeVert];
preset Bounds = <0,0,258,33>;
preset Color = Res::WhiteComponents;
}
$rect <20,20,160,60>
object Core::SimpleTouchHandler TouchHandler
{
preset Layout = Core::Layout[AlignToBottom, AlignToLeft, AlignToRight, AlignToTop, ResizeHorz, ResizeVert];
preset Point4 = <0,33>;
preset Point3 = <258,33>;
preset Point2 = <258,0>;
preset Point1 = <0,0>;
preset OnLeave = onEnterLeaveTouch;
preset OnEnter = onEnterLeaveTouch;
preset OnRelease = onReleaseTouch;
preset OnPress = onPressTouch;
preset RetargetCondition = Core::RetargetReason[WipeDown, WipeLeft, WipeRight, WipeUp];
preset MaxStrikeCount = 100;
}
// The property 'OnActivate' can refer to a slot method, which will receive a signal \
// as soon as the user has activated the button. Thereupon the method's logic will \
// be executed.
$rect <260,10,450,50>
property slot OnActivate = null;
$rect <450,50,650,90>
onset String
{
// The value doesn't change - nothing to do.
if ( pure String == value )
return;
// Remember the property's new value.
pure String = value;
// ... and trigger the component to update its actual state.
InvalidateViewState();
}
// The property 'Label' specifies the text to display as label in this push button \
// widget. The desired font as well as the colors for all individual button states \
// have to be specified in the configuration object assigned to the property @Appearance. \
// If there is no configuration object associated to this push button widget (the \
// property @Appearance is 'null'), no label is displayed.
// Per default, the label is displayed centered within the push button area. You \
// can modify the alignment of the label as well as its margins by specifying them \
// in the configuration object.
$rect <450,10,650,50>
property string String = "";
$rect <710,350,910,390>
var Views::Text textView;
$rect <20,20,160,60>
object Views::Text Text
{
preset Layout = Core::Layout[AlignToLeft, AlignToTop];
preset Bounds = <12,0,258,33>;
preset Alignment = Views::TextAlignment[AlignHorzLeft, AlignVertCenter];
preset String = "Delete contact";
preset Font = Resources::FontSmall;
preset Color = #FF295BFF;
}
}
// This class implements a 'push button' widget. When the user presses the button, \
// a signal is sent to the slot method stored in its @OnActivate property.
$rect <240,130,440,170>
$output false
class TextButton : Templates::PushButton
{
$rect <480,310,680,350>
inherited property Bounds = <0,0,66,25>;
$rect <930,190,1130,230>
inherited method UpdateLayout()
{
super(aSize);
Background.Bounds = Bounds.orect;
TextTxt.Bounds = Bounds.orect;
}
$rect <710,190,910,230>
inherited method UpdateViewState()
{
super( aState );
var bool isEnabled = aState.contains( Core::ViewState[ Enabled ]);
var bool isSelected = aState.contains( Core::ViewState[ Selected ]);
var bool isPressed = ( TouchHandler.Down && TouchHandler.Inside ) ||
FlashTimer.Enabled;
if ( TextTxt != null )
{
var color clr = TextColor;
TextTxt.Font = Res::ContactFont15;
TextTxt.String = Text;
TextTxt.Color = clr;
}
if ( !isEnabled )
{
Background.Color = BackgoundColor;
TextTxt.Color = Res::Grey;
}
else if ( isPressed )
{
Background.Color = BackgoundColor;
TextTxt.Color = TextColorPress;
}
else if ( isSelected )
{
Background.Color = BackgoundColor;
}
else
{
Background.Color = BackgoundColor;
}
enabled = isEnabled;
selected = isSelected;
pressed = isPressed;
}
// State management
note group Note4
{
attr Bounds = <700,150,920,400>;
}
// Feedback flash effect
note group Note3
{
attr Bounds = <470,150,690,280>;
}
// Keyboard events
note group Note2
{
attr Bounds = <240,150,460,280>;
}
// Touch screen events
note group Note1
{
attr Bounds = <10,150,230,320>;
}
// This variable stores the current state of the button.
$rect <710,310,910,350>
var bool pressed;
// This variable stores the current state of the button.
$rect <710,270,910,310>
var bool selected;
// This variable stores the current state of the button.
$rect <710,230,910,270>
var bool enabled;
// This timer object is used to flash the button when the user has tapped it very \
// quickly or the button has been activated with the keyboard. This is just a visual \
// feedback effect.
$rect <480,190,680,230>
object Core::Timer FlashTimer
{
preset OnTrigger = onFlashTimer;
preset Period = 0;