OSDN Git Service

[Qt][Draw][GL] Fix screen aspect problem(s).
authorK.Ohta <whatisthis.sowhat@gmail.com>
Fri, 11 Aug 2017 04:39:56 +0000 (13:39 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Fri, 11 Aug 2017 04:39:56 +0000 (13:39 +0900)
source/src/qt/CMakeLists.txt
source/src/qt/common/menu_flags.cpp
source/src/qt/gui/CMakeLists.txt
source/src/qt/gui/mainwindow_utils.cpp
source/src/qt/gui/menu_flags.h
source/src/qt/gui/menu_flags_tmpl.cpp
source/src/qt/gui/menu_screen.cpp

index c29f5a8..4fba550 100644 (file)
@@ -1,5 +1,5 @@
 message("* qt/osd")
-SET(THIS_LIB_VERSION 2.9.8
+SET(THIS_LIB_VERSION 2.9.9
 
 set(s_qt_osd_headers
        osd_base.h
index d151ed0..00fc902 100644 (file)
@@ -104,7 +104,12 @@ USING_FLAGS_EXT::USING_FLAGS_EXT(config_t *cfg) : USING_FLAGS(cfg)
 #else
        screen_height = SCREEN_HEIGHT;
 #endif
-       
+#if defined(SCREEN_X_ZOOM)
+       screen_x_zoom = SCREEN_X_ZOOM;
+#endif
+#if defined(SCREEN_Y_ZOOM)
+       screen_y_zoom = SCREEN_Y_ZOOM;
+#endif
        screen_width_aspect = WINDOW_WIDTH_ASPECT;
        screen_height_aspect = WINDOW_HEIGHT_ASPECT;
        max_button = 0;
index 3d33c21..ce429f2 100644 (file)
@@ -1,6 +1,6 @@
 message("* qt/gui")
 
-set(THIS_LIB_VERSION 2.10.2)
+set(THIS_LIB_VERSION 2.10.3)
 set(s_qt_gui_headers
          csp_logger.h
   
index 72a485e..f52ba6b 100644 (file)
@@ -162,26 +162,41 @@ void Ui_MainWindowBase::set_screen_aspect(int num)
        
        if(using_flags->get_emu()) {
                int w, h, n;
-               double nd, ww, hh;
+               float nd, ww, hh;
+               float xzoom = using_flags->get_screen_x_zoom();
+               float yzoom = using_flags->get_screen_y_zoom();
                n = using_flags->get_config_ptr()->window_mode;
                if(n < 0) n = 1;
                nd = actionScreenSize[n]->binds->getDoubleValue();
-               ww = nd * (double)using_flags->get_screen_width();
-               hh = nd * (double)using_flags->get_screen_height();
+               ww = (float)using_flags->get_screen_width();
+               hh = (float)using_flags->get_screen_height();
                
                if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
                   (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
-                       double par_w = (double)using_flags->get_screen_width_aspect() / (double)using_flags->get_screen_width();
-                       double par_h = (double)using_flags->get_screen_height_aspect() / (double)using_flags->get_screen_height();
+                       float par_w = (float)using_flags->get_screen_width_aspect() / ww;
+                       float par_h = (float)using_flags->get_screen_height_aspect() / hh;
                        //double par = par_h / par_w;
-                       if(using_flags->get_config_ptr()->window_stretch_type == 1) { // refer to X, scale Y.
-                               hh = hh * par_h;
-                       } else if(using_flags->get_config_ptr()->window_stretch_type == 2) { // refer to Y, scale X only
-                               ww = ww / par_h;
-                       } else if(using_flags->get_config_ptr()->window_stretch_type == 3) { // Scale both X, Y
-                               ww = ww * par_w;
-                               hh = hh * par_h;
+                       switch(using_flags->get_config_ptr()->window_stretch_type) {
+                       case 0: // refer to X and Y.
+                               ww = ww * nd * xzoom;
+                               hh = hh * nd * yzoom;
+                               break;
+                       case 1: // refer to X, scale Y only
+                               ww = ww * nd * xzoom;
+                               hh = hh * nd * par_h;
+                               break;
+                       case 2: // refer to Y, scale X only
+                               ww = (ww * nd) / par_h * yzoom;
+                               hh = hh * nd * yzoom;
+                               break;
+                       case 3:
+                               ww = ((ww * nd) / par_h) * yzoom;
+                               hh = ((hh * nd) / par_w) * xzoom;
+                               break;
                        }
+               } else {
+                       ww = ww * nd * xzoom;
+                       hh = hh * nd * yzoom;
                }
                w = (int)ww;
                h = (int)hh;
index 56396cf..ef2f5f5 100644 (file)
@@ -137,6 +137,9 @@ protected:
        
        int real_screen_width;
        int real_screen_height;
+
+       float screen_x_zoom;
+       float screen_y_zoom;
        
        int screen_width_aspect;
        int screen_height_aspect;
@@ -277,6 +280,8 @@ public:
        int get_screen_height_aspect() { return screen_height_aspect; }
        int get_real_screen_width() { return real_screen_width; }
        int get_real_screen_height() { return real_screen_height; }
+       float get_screen_x_zoom() { return screen_x_zoom; }
+       float get_screen_y_zoom() { return screen_y_zoom; }
        
        int get_screen_mode_num() { return screen_mode_num; }
        int get_max_button() { return max_button; }
index 6c8df7d..a45420b 100644 (file)
@@ -84,7 +84,9 @@ USING_FLAGS::USING_FLAGS(config_t *cfg)
        
        screen_width = SCREEN_WIDTH;
        screen_height = SCREEN_HEIGHT;
-       
+
+       screen_x_zoom = 1.0f;
+       screen_y_zoom = 1.0f;
        screen_width_aspect = WINDOW_WIDTH_ASPECT;
        screen_height_aspect = WINDOW_HEIGHT_ASPECT;
        max_button = 0;
index 3b66f3e..7beee1d 100644 (file)
@@ -30,24 +30,39 @@ void Object_Menu_Control::set_screen_aspect(void) {
 
 void Object_Menu_Control::set_screen_size(void) {
        int w, h;
-       double nd, ww, hh;
+       float nd, ww, hh;
+       float xzoom = using_flags->get_screen_x_zoom();
+       float yzoom = using_flags->get_screen_y_zoom();
        using_flags->get_config_ptr()->window_mode = getNumber();
        nd = getDoubleValue();
-       ww = nd * (double)using_flags->get_screen_width();
-       hh = nd * (double)using_flags->get_screen_height();
+       ww = (float)using_flags->get_screen_width();
+       hh = (float)using_flags->get_screen_height();
        if((using_flags->get_screen_height_aspect() != using_flags->get_screen_height()) ||
           (using_flags->get_screen_width_aspect() != using_flags->get_screen_width())) {
-               double par_w = (double)using_flags->get_screen_width_aspect() / (double)using_flags->get_screen_width();
-               double par_h = (double)using_flags->get_screen_height_aspect() / (double)using_flags->get_screen_height();
-               //double par = par_h / par_w;
-               if(using_flags->get_config_ptr()->window_stretch_type == 1) { // refer to X, scale Y.
-                       hh = hh * par_h;
-               } else if(using_flags->get_config_ptr()->window_stretch_type == 2) { // refer to Y, scale X only
-                       ww = ww / par_h;
-               } else if(using_flags->get_config_ptr()->window_stretch_type == 3) { // Scale both X, Y
-                       ww = ww * par_w;
-                       hh = hh * par_h;
+               float par_w = (float)using_flags->get_screen_width_aspect() / ww;
+               float par_h = (float)using_flags->get_screen_height_aspect() / hh;
+               //float par = par_h / par_w;
+               switch(using_flags->get_config_ptr()->window_stretch_type) {
+               case 0: // refer to X and Y.
+                       ww = ww * nd * xzoom;
+                       hh = hh * nd * yzoom;
+                       break;
+               case 1: // refer to X, scale Y only
+                       ww = ww * nd * xzoom;
+                       hh = hh * nd * par_h;
+                       break;
+               case 2: // refer to Y, scale X only
+                       ww = (ww * nd) / par_h * yzoom;
+                       hh = hh * nd * yzoom;
+                       break;
+               case 3:
+                       ww = ((ww * nd) / par_h) * yzoom;
+                       hh = ((hh * nd) / par_w) * xzoom;
+                       break;
                }
+       } else {
+               ww = ww * nd * xzoom;
+               hh = hh * nd * yzoom;
        }
        w = (int)ww;
        h = (int)hh;