Common Source Code Project for Qt (a.k.a for FM-7).
Revision | d2f8d2bf84c5864a7b5a2bcd3076d98e0ed96fad (tree) |
---|---|
Zeit | 2017-08-11 13:39:56 |
Autor | K.Ohta <whatisthis.sowhat@gmai...> |
Commiter | K.Ohta |
[Qt][Draw][GL] Fix screen aspect problem(s).
@@ -1,5 +1,5 @@ | ||
1 | 1 | message("* qt/osd") |
2 | -SET(THIS_LIB_VERSION 2.9.8) | |
2 | +SET(THIS_LIB_VERSION 2.9.9) | |
3 | 3 | |
4 | 4 | set(s_qt_osd_headers |
5 | 5 | osd_base.h |
@@ -104,7 +104,12 @@ USING_FLAGS_EXT::USING_FLAGS_EXT(config_t *cfg) : USING_FLAGS(cfg) | ||
104 | 104 | #else |
105 | 105 | screen_height = SCREEN_HEIGHT; |
106 | 106 | #endif |
107 | - | |
107 | +#if defined(SCREEN_X_ZOOM) | |
108 | + screen_x_zoom = SCREEN_X_ZOOM; | |
109 | +#endif | |
110 | +#if defined(SCREEN_Y_ZOOM) | |
111 | + screen_y_zoom = SCREEN_Y_ZOOM; | |
112 | +#endif | |
108 | 113 | screen_width_aspect = WINDOW_WIDTH_ASPECT; |
109 | 114 | screen_height_aspect = WINDOW_HEIGHT_ASPECT; |
110 | 115 | max_button = 0; |
@@ -1,6 +1,6 @@ | ||
1 | 1 | message("* qt/gui") |
2 | 2 | |
3 | -set(THIS_LIB_VERSION 2.10.2) | |
3 | +set(THIS_LIB_VERSION 2.10.3) | |
4 | 4 | set(s_qt_gui_headers |
5 | 5 | csp_logger.h |
6 | 6 |
@@ -162,26 +162,41 @@ void Ui_MainWindowBase::set_screen_aspect(int num) | ||
162 | 162 | |
163 | 163 | if(using_flags->get_emu()) { |
164 | 164 | int w, h, n; |
165 | - double nd, ww, hh; | |
165 | + float nd, ww, hh; | |
166 | + float xzoom = using_flags->get_screen_x_zoom(); | |
167 | + float yzoom = using_flags->get_screen_y_zoom(); | |
166 | 168 | n = using_flags->get_config_ptr()->window_mode; |
167 | 169 | if(n < 0) n = 1; |
168 | 170 | nd = actionScreenSize[n]->binds->getDoubleValue(); |
169 | - ww = nd * (double)using_flags->get_screen_width(); | |
170 | - hh = nd * (double)using_flags->get_screen_height(); | |
171 | + ww = (float)using_flags->get_screen_width(); | |
172 | + hh = (float)using_flags->get_screen_height(); | |
171 | 173 | |
172 | 174 | if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) || |
173 | 175 | (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) { |
174 | - double par_w = (double)using_flags->get_screen_width_aspect() / (double)using_flags->get_screen_width(); | |
175 | - double par_h = (double)using_flags->get_screen_height_aspect() / (double)using_flags->get_screen_height(); | |
176 | + float par_w = (float)using_flags->get_screen_width_aspect() / ww; | |
177 | + float par_h = (float)using_flags->get_screen_height_aspect() / hh; | |
176 | 178 | //double par = par_h / par_w; |
177 | - if(using_flags->get_config_ptr()->window_stretch_type == 1) { // refer to X, scale Y. | |
178 | - hh = hh * par_h; | |
179 | - } else if(using_flags->get_config_ptr()->window_stretch_type == 2) { // refer to Y, scale X only | |
180 | - ww = ww / par_h; | |
181 | - } else if(using_flags->get_config_ptr()->window_stretch_type == 3) { // Scale both X, Y | |
182 | - ww = ww * par_w; | |
183 | - hh = hh * par_h; | |
179 | + switch(using_flags->get_config_ptr()->window_stretch_type) { | |
180 | + case 0: // refer to X and Y. | |
181 | + ww = ww * nd * xzoom; | |
182 | + hh = hh * nd * yzoom; | |
183 | + break; | |
184 | + case 1: // refer to X, scale Y only | |
185 | + ww = ww * nd * xzoom; | |
186 | + hh = hh * nd * par_h; | |
187 | + break; | |
188 | + case 2: // refer to Y, scale X only | |
189 | + ww = (ww * nd) / par_h * yzoom; | |
190 | + hh = hh * nd * yzoom; | |
191 | + break; | |
192 | + case 3: | |
193 | + ww = ((ww * nd) / par_h) * yzoom; | |
194 | + hh = ((hh * nd) / par_w) * xzoom; | |
195 | + break; | |
184 | 196 | } |
197 | + } else { | |
198 | + ww = ww * nd * xzoom; | |
199 | + hh = hh * nd * yzoom; | |
185 | 200 | } |
186 | 201 | w = (int)ww; |
187 | 202 | h = (int)hh; |
@@ -137,6 +137,9 @@ protected: | ||
137 | 137 | |
138 | 138 | int real_screen_width; |
139 | 139 | int real_screen_height; |
140 | + | |
141 | + float screen_x_zoom; | |
142 | + float screen_y_zoom; | |
140 | 143 | |
141 | 144 | int screen_width_aspect; |
142 | 145 | int screen_height_aspect; |
@@ -277,6 +280,8 @@ public: | ||
277 | 280 | int get_screen_height_aspect() { return screen_height_aspect; } |
278 | 281 | int get_real_screen_width() { return real_screen_width; } |
279 | 282 | int get_real_screen_height() { return real_screen_height; } |
283 | + float get_screen_x_zoom() { return screen_x_zoom; } | |
284 | + float get_screen_y_zoom() { return screen_y_zoom; } | |
280 | 285 | |
281 | 286 | int get_screen_mode_num() { return screen_mode_num; } |
282 | 287 | int get_max_button() { return max_button; } |
@@ -84,7 +84,9 @@ USING_FLAGS::USING_FLAGS(config_t *cfg) | ||
84 | 84 | |
85 | 85 | screen_width = SCREEN_WIDTH; |
86 | 86 | screen_height = SCREEN_HEIGHT; |
87 | - | |
87 | + | |
88 | + screen_x_zoom = 1.0f; | |
89 | + screen_y_zoom = 1.0f; | |
88 | 90 | screen_width_aspect = WINDOW_WIDTH_ASPECT; |
89 | 91 | screen_height_aspect = WINDOW_HEIGHT_ASPECT; |
90 | 92 | max_button = 0; |
@@ -30,24 +30,39 @@ void Object_Menu_Control::set_screen_aspect(void) { | ||
30 | 30 | |
31 | 31 | void Object_Menu_Control::set_screen_size(void) { |
32 | 32 | int w, h; |
33 | - double nd, ww, hh; | |
33 | + float nd, ww, hh; | |
34 | + float xzoom = using_flags->get_screen_x_zoom(); | |
35 | + float yzoom = using_flags->get_screen_y_zoom(); | |
34 | 36 | using_flags->get_config_ptr()->window_mode = getNumber(); |
35 | 37 | nd = getDoubleValue(); |
36 | - ww = nd * (double)using_flags->get_screen_width(); | |
37 | - hh = nd * (double)using_flags->get_screen_height(); | |
38 | + ww = (float)using_flags->get_screen_width(); | |
39 | + hh = (float)using_flags->get_screen_height(); | |
38 | 40 | if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) || |
39 | 41 | (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) { |
40 | - double par_w = (double)using_flags->get_screen_width_aspect() / (double)using_flags->get_screen_width(); | |
41 | - double par_h = (double)using_flags->get_screen_height_aspect() / (double)using_flags->get_screen_height(); | |
42 | - //double par = par_h / par_w; | |
43 | - if(using_flags->get_config_ptr()->window_stretch_type == 1) { // refer to X, scale Y. | |
44 | - hh = hh * par_h; | |
45 | - } else if(using_flags->get_config_ptr()->window_stretch_type == 2) { // refer to Y, scale X only | |
46 | - ww = ww / par_h; | |
47 | - } else if(using_flags->get_config_ptr()->window_stretch_type == 3) { // Scale both X, Y | |
48 | - ww = ww * par_w; | |
49 | - hh = hh * par_h; | |
42 | + float par_w = (float)using_flags->get_screen_width_aspect() / ww; | |
43 | + float par_h = (float)using_flags->get_screen_height_aspect() / hh; | |
44 | + //float par = par_h / par_w; | |
45 | + switch(using_flags->get_config_ptr()->window_stretch_type) { | |
46 | + case 0: // refer to X and Y. | |
47 | + ww = ww * nd * xzoom; | |
48 | + hh = hh * nd * yzoom; | |
49 | + break; | |
50 | + case 1: // refer to X, scale Y only | |
51 | + ww = ww * nd * xzoom; | |
52 | + hh = hh * nd * par_h; | |
53 | + break; | |
54 | + case 2: // refer to Y, scale X only | |
55 | + ww = (ww * nd) / par_h * yzoom; | |
56 | + hh = hh * nd * yzoom; | |
57 | + break; | |
58 | + case 3: | |
59 | + ww = ((ww * nd) / par_h) * yzoom; | |
60 | + hh = ((hh * nd) / par_w) * xzoom; | |
61 | + break; | |
50 | 62 | } |
63 | + } else { | |
64 | + ww = ww * nd * xzoom; | |
65 | + hh = hh * nd * yzoom; | |
51 | 66 | } |
52 | 67 | w = (int)ww; |
53 | 68 | h = (int)hh; |