1 /* This is a small demo of the high-performance GUIX graphics framework. */
2 
3 #include <stdio.h>
4 #include "tx_api.h"
5 #include "gx_api.h"
6 #include "gx_validation_utility.h"
7 #include "gx_menu.h"
8 #include "gx_system.h"
9 
10 TEST_PARAM test_parameter = {
11     "guix_animation_complete", /* Test name */
12     117, 100, 526, 151  /* Define the coordinates of the capture area.
13                          In this test, we only need to capture the line
14                          drawing area.  */
15 };
16 
17 static VOID      control_thread_entry(ULONG);
main(int argc,char ** argv)18 int main(int argc, char ** argv)
19 {
20     /* Parse the command line argument. */
21     gx_validation_setup(argc, argv);
22 
23     /* Start ThreadX system */
24     tx_kernel_enter();
25     return(0);
26 }
27 
tx_application_define(void * first_unused_memory)28 VOID tx_application_define(void *first_unused_memory)
29 {
30 
31     /* Create a dedicated thread to perform various operations
32        on the line drawing example. These operations simulate
33        user input. */
34     gx_validation_control_thread_create(control_thread_entry);
35 
36     /* Termiante the test if it runs for more than 100 ticks */
37     /* This function is not implemented yet. */
38     gx_validation_watchdog_create(100);
39 
40     /* Call the actual line example routine. */
41     gx_validation_application_define(first_unused_memory);
42 
43 }
44 
45 
46 /* Replace the default graphics driver with the validation driver. */
47 #ifdef win32_graphics_driver_setup_565rgb
48 #undef win32_graphics_driver_setup_565rgb
49 #endif
50 #define win32_graphics_driver_setup_565rgb  gx_validation_graphics_driver_setup_565rgb
51 
52 
53 #ifdef WIN32
54 #undef WIN32
55 #endif
56 
57 #include "gx_validation_wrapper.h"
58 #include "demo_guix_all_widgets_16bpp.c"
59 
60 char *test_comment[1];
61 
control_thread_entry(ULONG input)62 static VOID control_thread_entry(ULONG input)
63 {
64 INT                frame_id=1;
65 GX_ANIMATION_INFO  info;
66 GX_ANIMATION       animation;
67 GX_BUTTON          button;
68 GX_RECTANGLE       size;
69 
70     gx_utility_rectangle_define(&size, 0, 0, 100, 50);
71 
72     /* Create a button for animation. */
73     memset(&button, 0, sizeof(GX_BUTTON));
74     gx_button_create(&button, "button", GX_NULL, GX_STYLE_ENABLED, 1000, &size);
75 
76     gx_widget_detach((GX_WIDGET *)&NestedWindow);
77 
78     test_comment[0] = (char *)malloc(256);
79 
80     memset(&info, 0, sizeof(GX_ANIMATION_INFO));
81     memset(&animation, 0, sizeof(GX_ANIMATION));
82     info.gx_animation_target = (GX_WIDGET *)&button;
83     info.gx_animation_style = GX_ANIMATION_SINE_EASE_OUT | GX_ANIMATION_DETACH;
84     info.gx_animation_start_alpha = 255;
85     info.gx_animation_end_alpha = 255;
86     info.gx_animation_start_position.gx_point_x = 100;
87     info.gx_animation_start_position.gx_point_y = 107;
88     info.gx_animation_end_position.gx_point_x = 400;
89     info.gx_animation_end_position.gx_point_y = 107;
90     info.gx_animation_steps = 10;
91     info.gx_animation_start_delay = 0;
92     info.gx_animation_frame_interval = 1;
93     info.gx_animation_id = 1;
94     info.gx_animation_parent = (GX_WIDGET *)&button_screen;
95 
96 GX_ENTER_CRITICAL
97     gx_animation_create(&animation);
98     gx_canvas_create(&animation_canvas, GX_NULL,
99         all_widgets_16bpp_display_table[0].display,
100         GX_CANVAS_MANAGED_VISIBLE,
101         NESTED_WINDOW_WIDTH, NESTED_WINDOW_HEIGHT,
102         animation_canvas_memory, NESTED_WINDOW_WIDTH * NESTED_WINDOW_HEIGHT * sizeof(GX_COLOR));
103 
104     gx_animation_canvas_define(&animation, &animation_canvas);
105     tx_thread_sleep(1);
106     gx_animation_start(&animation, &info);
107 
108     sprintf(test_comment[0], "Canvas animation");
109 
110     /* start_id, expected_frames, comments, num_comments, max_time. */
111     gx_validation_capture_frames(frame_id, 10, (char **)test_comment, 1, 20);
112 GX_EXIT_CRITICAL
113 
114     gx_validation_capture_frames_wait();
115 
116     gx_widget_status_add((GX_WIDGET *)&button, GX_STATUS_STUDIO_CREATED);
117     sprintf(test_comment[0], "Add GX_STATUS_STUDIO_CREATED status, start canvas animation");
118     tx_thread_sleep(1);
119     gx_animation_start(&animation, &info);
120     gx_validation_current_frame_id_get(&frame_id);
121     frame_id++;
122     gx_validation_capture_frames(frame_id, 10, (char **)test_comment, 1, 20);
123     gx_validation_capture_frames_wait();
124 
125     gx_validation_set_frame_comment("Start animation and detach animation target from its parent");
126 GX_ENTER_CRITICAL
127     info.gx_animation_steps = 2;
128     info.gx_animation_target = (GX_WIDGET *)&NestedWindow;
129     gx_animation_start(&animation, &info);
130     gx_widget_detach((GX_WIDGET *)&NestedWindow);
131 GX_EXIT_CRITICAL
132 
133     tx_thread_sleep(10);
134 
135     gx_validation_current_frame_id_get(&frame_id);
136     frame_id++;
137     gx_validation_set_frame_id(frame_id);
138     gx_validation_set_frame_comment("Sleep to wait animation complete");
139     gx_validation_screen_refresh();
140 
141     free(test_comment[0]);
142     gx_validation_end();
143 
144     exit(0);
145 }
146 
147