gosu 1.1.0.pre2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/COPYING +1 -1
- data/ext/gosu/extconf.rb +5 -1
- data/include/Gosu/Color.hpp +48 -100
- data/include/Gosu/Font.hpp +7 -9
- data/include/Gosu/Fwd.hpp +1 -1
- data/include/Gosu/Graphics.hpp +6 -4
- data/include/Gosu/GraphicsBase.hpp +6 -6
- data/include/Gosu/Image.hpp +3 -3
- data/include/Gosu/ImageData.hpp +1 -1
- data/include/Gosu/Math.hpp +4 -16
- data/include/Gosu/Platform.hpp +1 -51
- data/include/Gosu/Text.hpp +37 -40
- data/include/Gosu/Utility.hpp +10 -8
- data/include/Gosu/Version.hpp +1 -1
- data/include/Gosu/Window.hpp +2 -0
- data/lib/gosu/compat.rb +4 -0
- data/lib/gosu/swig_patches.rb +31 -3
- data/rdoc/gosu.rb +9 -1
- data/src/Bitmap.cpp +13 -13
- data/src/Color.cpp +50 -46
- data/src/EmptyImageData.hpp +1 -1
- data/src/Font.cpp +4 -4
- data/src/GosuViewController.cpp +2 -0
- data/src/Graphics.cpp +4 -4
- data/src/Image.cpp +4 -3
- data/src/Input.cpp +1 -10
- data/src/LargeImageData.cpp +20 -20
- data/src/LargeImageData.hpp +1 -1
- data/src/Macro.cpp +100 -143
- data/src/Macro.hpp +1 -1
- data/src/RenderState.hpp +5 -5
- data/src/Resolution.cpp +107 -59
- data/src/RubyGosu.cxx +465 -496
- data/src/RubyGosu.h +3 -2
- data/src/TexChunk.cpp +1 -1
- data/src/TexChunk.hpp +1 -1
- data/src/Text.cpp +31 -32
- data/src/TrueTypeFont.cpp +1 -1
- data/src/TrueTypeFontApple.cpp +10 -3
- data/src/Utility.cpp +82 -23
- data/src/WinUtility.hpp +2 -1
- data/src/Window.cpp +9 -9
- data/src/WindowUIKit.cpp +2 -2
- metadata +5 -7
- data/src/UtilityApple.cpp +0 -16
- data/src/UtilityWin.cpp +0 -17
    
        data/include/Gosu/Window.hpp
    CHANGED
    
    | @@ -89,6 +89,8 @@ namespace Gosu | |
| 89 89 | 
             
                    //! If this function returns true, the system cursor will be visible while over the window.
         | 
| 90 90 | 
             
                    virtual bool needs_cursor() const { return true; }
         | 
| 91 91 |  | 
| 92 | 
            +
                    virtual void gain_focus() {}
         | 
| 93 | 
            +
             | 
| 92 94 | 
             
                    //! This function is called when the window loses focus on some platforms.
         | 
| 93 95 | 
             
                    //! Most importantly, it is called on the iPhone or iPad when the user locks the screen.
         | 
| 94 96 | 
             
                    virtual void lose_focus() {}
         | 
    
        data/lib/gosu/compat.rb
    CHANGED
    
    
    
        data/lib/gosu/swig_patches.rb
    CHANGED
    
    | @@ -20,7 +20,7 @@ class Gosu::Window | |
| 20 20 | 
             
              end
         | 
| 21 21 |  | 
| 22 22 | 
             
              %w(update draw needs_redraw? needs_cursor?
         | 
| 23 | 
            -
                 lose_focus button_down button_up
         | 
| 23 | 
            +
                 gain_focus lose_focus button_down button_up
         | 
| 24 24 | 
             
                 gamepad_connected gamepad_disconnected drop).each do |callback|
         | 
| 25 25 | 
             
                define_method "protected_#{callback}" do |*args|
         | 
| 26 26 | 
             
                  begin
         | 
| @@ -35,13 +35,13 @@ class Gosu::Window | |
| 35 35 | 
             
                  end
         | 
| 36 36 | 
             
                end
         | 
| 37 37 | 
             
              end
         | 
| 38 | 
            -
             | 
| 38 | 
            +
             | 
| 39 39 | 
             
              def protected_draw_2
         | 
| 40 40 | 
             
                protected_draw
         | 
| 41 41 | 
             
                $gosu_gl_blocks_2 = $gosu_gl_blocks
         | 
| 42 42 | 
             
                $gosu_gl_blocks = nil
         | 
| 43 43 | 
             
              end
         | 
| 44 | 
            -
             | 
| 44 | 
            +
             | 
| 45 45 | 
             
              alias_method :show_internal, :show
         | 
| 46 46 | 
             
              def show
         | 
| 47 47 | 
             
                show_internal
         | 
| @@ -54,6 +54,21 @@ class Gosu::Window | |
| 54 54 | 
             
                  raise @_exception
         | 
| 55 55 | 
             
                end
         | 
| 56 56 | 
             
              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              alias_method :tick_internal, :tick
         | 
| 59 | 
            +
              def tick
         | 
| 60 | 
            +
                value = tick_internal
         | 
| 61 | 
            +
                # Try to format the message nicely, without any useless patching that we are
         | 
| 62 | 
            +
                # doing here.
         | 
| 63 | 
            +
                if defined? @_exception
         | 
| 64 | 
            +
                  if @_exception.backtrace.is_a? Array and not @_exception.backtrace.frozen?
         | 
| 65 | 
            +
                    @_exception.backtrace.reject! { |line| line.include? "lib/gosu/swig_patches.rb" }
         | 
| 66 | 
            +
                  end
         | 
| 67 | 
            +
                  raise @_exception
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                value
         | 
| 71 | 
            +
              end
         | 
| 57 72 | 
             
            end
         | 
| 58 73 |  | 
| 59 74 | 
             
            module Gosu
         | 
| @@ -73,6 +88,19 @@ end | |
| 73 88 | 
             
            # SWIG somehow maps the instance method "argb" as an overload of the class
         | 
| 74 89 | 
             
            # method of the same name.
         | 
| 75 90 | 
             
            class Gosu::Color
         | 
| 91 | 
            +
              alias_method :initialize_without_argb, :initialize
         | 
| 92 | 
            +
             | 
| 93 | 
            +
              # The (a,r,g,b) constructor overload was dropped in C++ to reduce ambiguity,
         | 
| 94 | 
            +
              # adding it via %extend in gosu.i does not work, so patch it here.
         | 
| 95 | 
            +
              def initialize(*args)
         | 
| 96 | 
            +
                if args.size == 4
         | 
| 97 | 
            +
                  initialize_without_argb(args[1], args[2], args[3])
         | 
| 98 | 
            +
                  self.alpha = args[0]
         | 
| 99 | 
            +
                else
         | 
| 100 | 
            +
                  initialize_without_argb(*args)
         | 
| 101 | 
            +
                end
         | 
| 102 | 
            +
              end
         | 
| 103 | 
            +
             | 
| 76 104 | 
             
              alias_method :argb, :to_i
         | 
| 77 105 | 
             
            end
         | 
| 78 106 |  | 
    
        data/rdoc/gosu.rb
    CHANGED
    
    | @@ -481,7 +481,7 @@ module Gosu | |
| 481 481 | 
             
                # Draws the image rotated, with its rotational center at (x, y).
         | 
| 482 482 | 
             
                #
         | 
| 483 483 | 
             
                # @return [void]
         | 
| 484 | 
            -
                # @param angle [Float]
         | 
| 484 | 
            +
                # @param angle [Float] the angle to rotate, in degrees.
         | 
| 485 485 | 
             
                # @param center_x [Float] the relative horizontal rotation origin.
         | 
| 486 486 | 
             
                # @param center_y [Float] the relative vertical rotation origin.
         | 
| 487 487 | 
             
                # @param (see #draw)
         | 
| @@ -960,6 +960,14 @@ module Gosu | |
| 960 960 | 
             
                # @see Gosu.gamepad_name
         | 
| 961 961 | 
             
                def gamepad_disconnected(index); end
         | 
| 962 962 |  | 
| 963 | 
            +
                ##
         | 
| 964 | 
            +
                # Called when the window gains focus
         | 
| 965 | 
            +
                def gain_focus; end
         | 
| 966 | 
            +
             | 
| 967 | 
            +
                ##
         | 
| 968 | 
            +
                # Called when the windows loses focus
         | 
| 969 | 
            +
                def lose_focus; end
         | 
| 970 | 
            +
             | 
| 963 971 | 
             
                # @!endgroup
         | 
| 964 972 | 
             
              end
         | 
| 965 973 |  | 
    
        data/src/Bitmap.cpp
    CHANGED
    
    | @@ -31,20 +31,20 @@ void Gosu::Bitmap::resize(int width, int height, Color c) | |
| 31 31 |  | 
| 32 32 | 
             
            void Gosu::Bitmap::blend_pixel(int x, int y, Color c)
         | 
| 33 33 | 
             
            {
         | 
| 34 | 
            -
                if (c.alpha | 
| 34 | 
            +
                if (c.alpha == 0) return;
         | 
| 35 35 |  | 
| 36 36 | 
             
                Color out = get_pixel(x, y);
         | 
| 37 | 
            -
                if (out.alpha | 
| 37 | 
            +
                if (out.alpha == 0) {
         | 
| 38 38 | 
             
                    set_pixel(x, y, c);
         | 
| 39 39 | 
             
                    return;
         | 
| 40 40 | 
             
                }
         | 
| 41 41 |  | 
| 42 | 
            -
                int inv_alpha = out.alpha | 
| 42 | 
            +
                int inv_alpha = out.alpha * (255 - c.alpha) / 255;
         | 
| 43 43 |  | 
| 44 | 
            -
                out. | 
| 45 | 
            -
                out. | 
| 46 | 
            -
                out. | 
| 47 | 
            -
                out. | 
| 44 | 
            +
                out.alpha = (c.alpha + inv_alpha);
         | 
| 45 | 
            +
                out.red =   ((c.red   * c.alpha + out.red   * inv_alpha) / out.alpha);
         | 
| 46 | 
            +
                out.green = ((c.green * c.alpha + out.green * inv_alpha) / out.alpha);
         | 
| 47 | 
            +
                out.blue =  ((c.blue  * c.alpha + out.blue  * inv_alpha) / out.alpha);
         | 
| 48 48 |  | 
| 49 49 | 
             
                set_pixel(x, y, out);
         | 
| 50 50 | 
             
            }
         | 
| @@ -108,9 +108,9 @@ void Gosu::apply_color_key(Bitmap& bitmap, Color key) | |
| 108 108 | 
             
                            auto visit = [&](Color c) {
         | 
| 109 109 | 
             
                              if (c != key) {
         | 
| 110 110 | 
             
                                  neighbors += 1;
         | 
| 111 | 
            -
                                  red += c.red | 
| 112 | 
            -
                                  green += c.green | 
| 113 | 
            -
                                  blue += c.blue | 
| 111 | 
            +
                                  red += c.red;
         | 
| 112 | 
            +
                                  green += c.green;
         | 
| 113 | 
            +
                                  blue += c.blue;
         | 
| 114 114 | 
             
                              }
         | 
| 115 115 | 
             
                            };
         | 
| 116 116 |  | 
| @@ -121,9 +121,9 @@ void Gosu::apply_color_key(Bitmap& bitmap, Color key) | |
| 121 121 |  | 
| 122 122 | 
             
                            Color replacement = Color::NONE;
         | 
| 123 123 | 
             
                            if (neighbors > 0) {
         | 
| 124 | 
            -
                                replacement. | 
| 125 | 
            -
                                replacement. | 
| 126 | 
            -
                                replacement. | 
| 124 | 
            +
                                replacement.red = red / neighbors;
         | 
| 125 | 
            +
                                replacement.green = green / neighbors;
         | 
| 126 | 
            +
                                replacement.blue = blue / neighbors;
         | 
| 127 127 | 
             
                            }
         | 
| 128 128 | 
             
                            bitmap.set_pixel(x, y, replacement);
         | 
| 129 129 | 
             
                        }
         | 
    
        data/src/Color.cpp
    CHANGED
    
    | @@ -9,9 +9,9 @@ namespace | |
| 9 9 |  | 
| 10 10 | 
             
                HSV color_to_hsv(const Gosu::Color& c)
         | 
| 11 11 | 
             
                {
         | 
| 12 | 
            -
                    double r = c.red | 
| 13 | 
            -
                    double g = c.green | 
| 14 | 
            -
                    double b = c.blue | 
| 12 | 
            +
                    double r = c.red / 255.0;
         | 
| 13 | 
            +
                    double g = c.green / 255.0;
         | 
| 14 | 
            +
                    double b = c.blue / 255.0;
         | 
| 15 15 |  | 
| 16 16 | 
             
                    double min = std::min(std::min(r, g), b);
         | 
| 17 17 | 
             
                    double max = std::max(std::max(r, g), b);
         | 
| @@ -22,7 +22,7 @@ namespace | |
| 22 22 | 
             
                        return hsv;
         | 
| 23 23 | 
             
                    }
         | 
| 24 24 |  | 
| 25 | 
            -
                    HSV hsv;
         | 
| 25 | 
            +
                    HSV hsv{};
         | 
| 26 26 |  | 
| 27 27 | 
             
                    // Value.
         | 
| 28 28 | 
             
                    hsv.v = max;
         | 
| @@ -50,38 +50,33 @@ namespace | |
| 50 50 | 
             
            }
         | 
| 51 51 |  | 
| 52 52 | 
             
            Gosu::Color Gosu::Color::from_hsv(double h, double s, double v)
         | 
| 53 | 
            -
            {
         | 
| 54 | 
            -
                return from_ahsv(255, h, s, v);
         | 
| 55 | 
            -
            }
         | 
| 56 | 
            -
             | 
| 57 | 
            -
            Gosu::Color Gosu::Color::from_ahsv(Channel alpha, double h, double s, double v)
         | 
| 58 53 | 
             
            {
         | 
| 59 54 | 
             
                // Normalize hue so that is always in the [0, 360) range and wraps around.
         | 
| 60 55 | 
             
                h = normalize_angle(h);
         | 
| 61 56 | 
             
                // Clamp s and v for consistency with the Ruby/Gosu ARGB getters/setters.
         | 
| 62 | 
            -
                s = clamp(s, 0.0, 1.0);
         | 
| 63 | 
            -
                v = clamp(v, 0.0, 1.0);
         | 
| 64 | 
            -
             | 
| 57 | 
            +
                s = std::clamp(s, 0.0, 1.0);
         | 
| 58 | 
            +
                v = std::clamp(v, 0.0, 1.0);
         | 
| 59 | 
            +
             | 
| 65 60 | 
             
                int sector = static_cast<int>(h / 60);
         | 
| 66 61 | 
             
                double factorial = h / 60 - sector;
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                 | 
| 69 | 
            -
                 | 
| 70 | 
            -
                 | 
| 71 | 
            -
             | 
| 62 | 
            +
             | 
| 63 | 
            +
                Channel p = static_cast<Channel>(255 * v * (1 - s));
         | 
| 64 | 
            +
                Channel q = static_cast<Channel>(255 * v * (1 - s * factorial));
         | 
| 65 | 
            +
                Channel t = static_cast<Channel>(255 * v * (1 - s * (1 - factorial)));
         | 
| 66 | 
            +
             | 
| 72 67 | 
             
                switch (sector) {
         | 
| 73 68 | 
             
                case 0:
         | 
| 74 | 
            -
                    return Color( | 
| 69 | 
            +
                    return Color{static_cast<Channel>(255 * v), t, p};
         | 
| 75 70 | 
             
                case 1:
         | 
| 76 | 
            -
                    return Color | 
| 71 | 
            +
                    return Color{q, static_cast<Channel>(255 * v), p};
         | 
| 77 72 | 
             
                case 2:
         | 
| 78 | 
            -
                    return Color | 
| 73 | 
            +
                    return Color{p, static_cast<Channel>(255 * v), t};
         | 
| 79 74 | 
             
                case 3:
         | 
| 80 | 
            -
                    return Color | 
| 75 | 
            +
                    return Color{p, q, static_cast<Channel>(255 * v)};
         | 
| 81 76 | 
             
                case 4:
         | 
| 82 | 
            -
                    return Color | 
| 77 | 
            +
                    return Color{t, p, static_cast<Channel>(255 * v)};
         | 
| 83 78 | 
             
                default: // sector 5
         | 
| 84 | 
            -
                    return Color( | 
| 79 | 
            +
                    return Color{static_cast<Channel>(255 * v), p, q};
         | 
| 85 80 | 
             
                }
         | 
| 86 81 | 
             
            }
         | 
| 87 82 |  | 
| @@ -92,7 +87,7 @@ double Gosu::Color::hue() const | |
| 92 87 |  | 
| 93 88 | 
             
            void Gosu::Color::set_hue(double h)
         | 
| 94 89 | 
             
            {
         | 
| 95 | 
            -
                *this =  | 
| 90 | 
            +
                *this = from_hsv(h, saturation(), value()).with_alpha(alpha);
         | 
| 96 91 | 
             
            }
         | 
| 97 92 |  | 
| 98 93 | 
             
            double Gosu::Color::saturation() const
         | 
| @@ -102,7 +97,7 @@ double Gosu::Color::saturation() const | |
| 102 97 |  | 
| 103 98 | 
             
            void Gosu::Color::set_saturation(double s)
         | 
| 104 99 | 
             
            {
         | 
| 105 | 
            -
                *this =  | 
| 100 | 
            +
                *this = from_hsv(hue(), s, value()).with_alpha(alpha);
         | 
| 106 101 | 
             
            }
         | 
| 107 102 |  | 
| 108 103 | 
             
            double Gosu::Color::value() const
         | 
| @@ -112,33 +107,42 @@ double Gosu::Color::value() const | |
| 112 107 |  | 
| 113 108 | 
             
            void Gosu::Color::set_value(double v)
         | 
| 114 109 | 
             
            {
         | 
| 115 | 
            -
                *this =  | 
| 110 | 
            +
                *this = from_hsv(hue(), saturation(), v).with_alpha(alpha);
         | 
| 116 111 | 
             
            }
         | 
| 117 112 |  | 
| 118 | 
            -
            Gosu::Color Gosu:: | 
| 113 | 
            +
            Gosu::Color Gosu::lerp(Color a, Color b, double t)
         | 
| 119 114 | 
             
            {
         | 
| 120 | 
            -
                 | 
| 121 | 
            -
             | 
| 122 | 
            -
             | 
| 123 | 
            -
             | 
| 115 | 
            +
                const auto lerp_channel = [](Color::Channel a, Color::Channel b, double t) {
         | 
| 116 | 
            +
                    return static_cast<Color::Channel>(std::clamp(std::round(lerp(a, b, t)), 0.0, 255.0));
         | 
| 117 | 
            +
                };
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                Color result;
         | 
| 120 | 
            +
                result.red = lerp_channel(a.red, b.red, t);
         | 
| 121 | 
            +
                result.green = lerp_channel(a.green, b.green, t);
         | 
| 122 | 
            +
                result.blue = lerp_channel(a.blue, b.blue, t);
         | 
| 123 | 
            +
                result.alpha = lerp_channel(a.alpha, b.alpha, t);
         | 
| 124 | 
            +
                return result;
         | 
| 124 125 | 
             
            }
         | 
| 125 126 |  | 
| 126 127 | 
             
            Gosu::Color Gosu::multiply(Color a, Color b)
         | 
| 127 128 | 
             
            {
         | 
| 128 | 
            -
                 | 
| 129 | 
            -
             | 
| 130 | 
            -
             | 
| 131 | 
            -
             | 
| 129 | 
            +
                Color result;
         | 
| 130 | 
            +
                result.red = static_cast<Color::Channel>(std::round(a.red * b.red / 255.0));
         | 
| 131 | 
            +
                result.green = static_cast<Color::Channel>(std::round(a.green * b.green / 255.0));
         | 
| 132 | 
            +
                result.blue = static_cast<Color::Channel>(std::round(a.blue * b.blue / 255.0));
         | 
| 133 | 
            +
                result.alpha = static_cast<Color::Channel>(std::round(a.alpha * b.alpha / 255.0));
         | 
| 134 | 
            +
                return result;
         | 
| 132 135 | 
             
            }
         | 
| 133 136 |  | 
| 134 | 
            -
            const Gosu::Color Gosu::Color::NONE | 
| 135 | 
            -
            const Gosu::Color Gosu::Color::BLACK | 
| 136 | 
            -
            const Gosu::Color Gosu::Color::GRAY | 
| 137 | 
            -
            const Gosu::Color Gosu::Color::WHITE | 
| 138 | 
            -
             | 
| 139 | 
            -
            const Gosu::Color Gosu::Color:: | 
| 140 | 
            -
            const Gosu::Color Gosu::Color:: | 
| 141 | 
            -
            const Gosu::Color Gosu::Color:: | 
| 142 | 
            -
            const Gosu::Color Gosu::Color:: | 
| 143 | 
            -
            const Gosu::Color Gosu::Color:: | 
| 144 | 
            -
            const Gosu::Color Gosu::Color:: | 
| 137 | 
            +
            const Gosu::Color Gosu::Color::NONE{0x00'000000};
         | 
| 138 | 
            +
            const Gosu::Color Gosu::Color::BLACK{0, 0, 0};
         | 
| 139 | 
            +
            const Gosu::Color Gosu::Color::GRAY{128, 128, 128};
         | 
| 140 | 
            +
            const Gosu::Color Gosu::Color::WHITE{255, 255, 255};
         | 
| 141 | 
            +
             | 
| 142 | 
            +
            const Gosu::Color Gosu::Color::AQUA{0, 255, 255};
         | 
| 143 | 
            +
            const Gosu::Color Gosu::Color::RED{255, 0, 0};
         | 
| 144 | 
            +
            const Gosu::Color Gosu::Color::GREEN{0, 255, 0};
         | 
| 145 | 
            +
            const Gosu::Color Gosu::Color::BLUE{0, 0, 255};
         | 
| 146 | 
            +
            const Gosu::Color Gosu::Color::YELLOW{255, 255, 0};
         | 
| 147 | 
            +
            const Gosu::Color Gosu::Color::FUCHSIA{255, 0, 255};
         | 
| 148 | 
            +
            const Gosu::Color Gosu::Color::CYAN{0, 255, 255};
         | 
    
        data/src/EmptyImageData.hpp
    CHANGED
    
    
    
        data/src/Font.cpp
    CHANGED
    
    | @@ -112,13 +112,13 @@ double Gosu::Font::markup_width(const string& markup) const | |
| 112 112 | 
             
            }
         | 
| 113 113 |  | 
| 114 114 | 
             
            void Gosu::Font::draw_text(const string& text, double x, double y, ZPos z,
         | 
| 115 | 
            -
                                       double scale_x, double scale_y, Color c,  | 
| 115 | 
            +
                                       double scale_x, double scale_y, Color c, BlendMode mode) const
         | 
| 116 116 | 
             
            {
         | 
| 117 117 | 
             
                draw_markup(escape_markup(text), x, y, z, scale_x, scale_y, c, mode);
         | 
| 118 118 | 
             
            }
         | 
| 119 119 |  | 
| 120 120 | 
             
            void Gosu::Font::draw_markup(const string& markup, double x, double y, ZPos z,
         | 
| 121 | 
            -
                                         double scale_x, double scale_y, Color c,  | 
| 121 | 
            +
                                         double scale_x, double scale_y, Color c, BlendMode mode) const
         | 
| 122 122 | 
             
            {
         | 
| 123 123 | 
             
                double current_y = y;
         | 
| 124 124 |  | 
| @@ -142,7 +142,7 @@ void Gosu::Font::draw_markup(const string& markup, double x, double y, ZPos z, | |
| 142 142 |  | 
| 143 143 | 
             
            void Gosu::Font::draw_text_rel(const string& text, double x, double y, ZPos z,
         | 
| 144 144 | 
             
                                           double rel_x, double rel_y, double scale_x, double scale_y,
         | 
| 145 | 
            -
                                           Color c,  | 
| 145 | 
            +
                                           Color c, BlendMode mode) const
         | 
| 146 146 | 
             
            {
         | 
| 147 147 | 
             
                if (rel_x) x -= text_width(text) * scale_x * rel_x;
         | 
| 148 148 | 
             
                if (rel_y) y -= height() * scale_y * rel_y;
         | 
| @@ -152,7 +152,7 @@ void Gosu::Font::draw_text_rel(const string& text, double x, double y, ZPos z, | |
| 152 152 |  | 
| 153 153 | 
             
            void Gosu::Font::draw_markup_rel(const string& markup, double x, double y, ZPos z,
         | 
| 154 154 | 
             
                                             double rel_x, double rel_y, double scale_x, double scale_y,
         | 
| 155 | 
            -
                                             Color c,  | 
| 155 | 
            +
                                             Color c, BlendMode mode) const
         | 
| 156 156 | 
             
            {
         | 
| 157 157 | 
             
                if (rel_x) x -= markup_width(markup) * scale_x * rel_x;
         | 
| 158 158 | 
             
                if (rel_y) y -= height() * scale_y * rel_y;
         | 
    
        data/src/GosuViewController.cpp
    CHANGED
    
    | @@ -121,6 +121,8 @@ static void handle_audio_interruption(void* unused, UInt32 inInterruptionState) | |
| 121 121 | 
             
            - (void)applicationWillEnterForeground:(NSNotification*)notification
         | 
| 122 122 | 
             
            {
         | 
| 123 123 | 
             
                [self setupTimerOrDisplayLink];
         | 
| 124 | 
            +
                
         | 
| 125 | 
            +
                self.gosuWindowReference.gain_focus();
         | 
| 124 126 | 
             
            }
         | 
| 125 127 |  | 
| 126 128 | 
             
            - (void)applicationDidEnterBackground:(NSNotification*)notification
         | 
    
        data/src/Graphics.cpp
    CHANGED
    
    | @@ -330,7 +330,7 @@ void Gosu::Graphics::transform(const Gosu::Transform& transform, const function< | |
| 330 330 | 
             
            }
         | 
| 331 331 |  | 
| 332 332 | 
             
            void Gosu::Graphics::draw_line(double x1, double y1, Color c1,
         | 
| 333 | 
            -
                double x2, double y2, Color c2, ZPos z,  | 
| 333 | 
            +
                double x2, double y2, Color c2, ZPos z, BlendMode mode)
         | 
| 334 334 | 
             
            {
         | 
| 335 335 | 
             
                DrawOp op;
         | 
| 336 336 | 
             
                op.render_state.mode = mode;
         | 
| @@ -343,7 +343,7 @@ void Gosu::Graphics::draw_line(double x1, double y1, Color c1, | |
| 343 343 | 
             
            }
         | 
| 344 344 |  | 
| 345 345 | 
             
            void Gosu::Graphics::draw_triangle(double x1, double y1, Color c1, double x2, double y2, Color c2,
         | 
| 346 | 
            -
                double x3, double y3, Color c3, ZPos z,  | 
| 346 | 
            +
                double x3, double y3, Color c3, ZPos z, BlendMode mode)
         | 
| 347 347 | 
             
            {
         | 
| 348 348 | 
             
                DrawOp op;
         | 
| 349 349 | 
             
                op.render_state.mode = mode;
         | 
| @@ -361,7 +361,7 @@ void Gosu::Graphics::draw_triangle(double x1, double y1, Color c1, double x2, do | |
| 361 361 | 
             
            }
         | 
| 362 362 |  | 
| 363 363 | 
             
            void Gosu::Graphics::draw_quad(double x1, double y1, Color c1, double x2, double y2, Color c2,
         | 
| 364 | 
            -
                double x3, double y3, Color c3, double x4, double y4, Color c4, ZPos z,  | 
| 364 | 
            +
                double x3, double y3, Color c3, double x4, double y4, Color c4, ZPos z, BlendMode mode)
         | 
| 365 365 | 
             
            {
         | 
| 366 366 | 
             
                normalize_coordinates(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4);
         | 
| 367 367 |  | 
| @@ -384,7 +384,7 @@ void Gosu::Graphics::draw_quad(double x1, double y1, Color c1, double x2, double | |
| 384 384 | 
             
            }
         | 
| 385 385 |  | 
| 386 386 | 
             
            void Gosu::Graphics::draw_rect(double x, double y, double width, double height, Color c,
         | 
| 387 | 
            -
                                           ZPos z, Gosu:: | 
| 387 | 
            +
                                           ZPos z, Gosu::BlendMode mode)
         | 
| 388 388 | 
             
            {
         | 
| 389 389 | 
             
                draw_quad(x, y, c, x + width, y, c, x, y + height, c, x + width, y + height, c, z, mode);
         | 
| 390 390 | 
             
            }
         | 
    
        data/src/Image.cpp
    CHANGED
    
    | @@ -57,7 +57,7 @@ unsigned Gosu::Image::height() const | |
| 57 57 | 
             
            }
         | 
| 58 58 |  | 
| 59 59 | 
             
            void Gosu::Image::draw(double x, double y, ZPos z, double scale_x, double scale_y, Color c,
         | 
| 60 | 
            -
                 | 
| 60 | 
            +
                BlendMode mode) const
         | 
| 61 61 | 
             
            {
         | 
| 62 62 | 
             
                double x2 = x + width() * scale_x;
         | 
| 63 63 | 
             
                double y2 = y + height() * scale_y;
         | 
| @@ -66,7 +66,7 @@ void Gosu::Image::draw(double x, double y, ZPos z, double scale_x, double scale_ | |
| 66 66 | 
             
            }
         | 
| 67 67 |  | 
| 68 68 | 
             
            void Gosu::Image::draw_mod(double x, double y, ZPos z, double scale_x, double scale_y, Color c1,
         | 
| 69 | 
            -
                Color c2, Color c3, Color c4,  | 
| 69 | 
            +
                Color c2, Color c3, Color c4, BlendMode mode) const
         | 
| 70 70 | 
             
            {
         | 
| 71 71 | 
             
                double x2 = x + width() * scale_x;
         | 
| 72 72 | 
             
                double y2 = y + height() * scale_y;
         | 
| @@ -75,7 +75,8 @@ void Gosu::Image::draw_mod(double x, double y, ZPos z, double scale_x, double sc | |
| 75 75 | 
             
            }
         | 
| 76 76 |  | 
| 77 77 | 
             
            void Gosu::Image::draw_rot(double x, double y, ZPos z, double angle,
         | 
| 78 | 
            -
                double center_x, double center_y, double scale_x, double scale_y, Color c, | 
| 78 | 
            +
                double center_x, double center_y, double scale_x, double scale_y, Color c,
         | 
| 79 | 
            +
                                       BlendMode mode) const
         | 
| 79 80 | 
             
            {
         | 
| 80 81 | 
             
                double size_x = width() * scale_x;
         | 
| 81 82 | 
             
                double size_y = height() * scale_y;
         | 
    
        data/src/Input.cpp
    CHANGED
    
    | @@ -78,20 +78,11 @@ struct Gosu::Input::Impl | |
| 78 78 |  | 
| 79 79 | 
             
                void update_mouse_position()
         | 
| 80 80 | 
             
                {
         | 
| 81 | 
            -
                #if SDL_VERSION_ATLEAST(2, 0, 5)
         | 
| 82 | 
            -
                    // SDL_GetGlobalMouseState was added in SDL 2.0.4, but it only started using the same
         | 
| 83 | 
            -
                    // coordinate system as SDL_GetWindowPosition on X11 in 2.0.5.
         | 
| 84 81 | 
             
                    int x, y, window_x, window_y;
         | 
| 85 82 | 
             
                    SDL_GetWindowPosition(window, &window_x, &window_y);
         | 
| 86 83 | 
             
                    SDL_GetGlobalMouseState(&x, &y);
         | 
| 87 84 | 
             
                    mouse_x = x - window_x;
         | 
| 88 85 | 
             
                    mouse_y = y - window_y;
         | 
| 89 | 
            -
                #else
         | 
| 90 | 
            -
                    int x, y;
         | 
| 91 | 
            -
                    SDL_GetMouseState(&x, &y);
         | 
| 92 | 
            -
                    mouse_x = x;
         | 
| 93 | 
            -
                    mouse_y = y;
         | 
| 94 | 
            -
                #endif
         | 
| 95 86 | 
             
                }
         | 
| 96 87 |  | 
| 97 88 | 
             
                void set_mouse_position(double x, double y)
         | 
| @@ -100,7 +91,7 @@ struct Gosu::Input::Impl | |
| 100 91 | 
             
                                          static_cast<int>((x - mouse_offset_x) / mouse_scale_x),
         | 
| 101 92 | 
             
                                          static_cast<int>((y - mouse_offset_y) / mouse_scale_y));
         | 
| 102 93 |  | 
| 103 | 
            -
                #if  | 
| 94 | 
            +
                #if !defined(GOSU_IS_X)
         | 
| 104 95 | 
             
                    // On systems where we have a working GetGlobalMouseState, we can warp the mouse and
         | 
| 105 96 | 
             
                    // retrieve its position directly afterwards.
         | 
| 106 97 | 
             
                    update_mouse_position();
         | 
    
        data/src/LargeImageData.cpp
    CHANGED
    
    | @@ -69,7 +69,7 @@ void Gosu::LargeImageData::draw(double x1, double y1, Color c1, | |
| 69 69 | 
             
                                            double x2, double y2, Color c2,
         | 
| 70 70 | 
             
                                            double x3, double y3, Color c3,
         | 
| 71 71 | 
             
                                            double x4, double y4, Color c4,
         | 
| 72 | 
            -
                                            ZPos z,  | 
| 72 | 
            +
                                            ZPos z, BlendMode mode) const
         | 
| 73 73 | 
             
            {
         | 
| 74 74 | 
             
                normalize_coordinates(x1, y1, x2, y2, x3, y3, c3, x4, y4, c4);
         | 
| 75 75 |  | 
| @@ -84,25 +84,25 @@ void Gosu::LargeImageData::draw(double x1, double y1, Color c1, | |
| 84 84 | 
             
                        double rel_y_t = y / h;
         | 
| 85 85 | 
             
                        double rel_y_b = (y + tile.height()) / h;
         | 
| 86 86 |  | 
| 87 | 
            -
                    #define  | 
| 88 | 
            -
                         | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
                        double x_t_l =  | 
| 93 | 
            -
                        double x_t_r =  | 
| 94 | 
            -
                        double x_b_l =  | 
| 95 | 
            -
                        double x_b_r =  | 
| 96 | 
            -
             | 
| 97 | 
            -
                        double y_t_l =  | 
| 98 | 
            -
                        double y_t_r =  | 
| 99 | 
            -
                        double y_b_l =  | 
| 100 | 
            -
                        double y_b_r =  | 
| 101 | 
            -
             | 
| 102 | 
            -
                        Color  c_t_l =  | 
| 103 | 
            -
                        Color  c_t_r =  | 
| 104 | 
            -
                        Color  c_b_l =  | 
| 105 | 
            -
                        Color  c_b_r =  | 
| 87 | 
            +
                    #define LERP2D(what, x_weight, y_weight) \
         | 
| 88 | 
            +
                        lerp(lerp(what##1, what##3, y_weight), \
         | 
| 89 | 
            +
                        lerp(what##2, what##4, y_weight), \
         | 
| 90 | 
            +
                        x_weight);
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                        double x_t_l = LERP2D(x, rel_x_l, rel_y_t);
         | 
| 93 | 
            +
                        double x_t_r = LERP2D(x, rel_x_r, rel_y_t);
         | 
| 94 | 
            +
                        double x_b_l = LERP2D(x, rel_x_l, rel_y_b);
         | 
| 95 | 
            +
                        double x_b_r = LERP2D(x, rel_x_r, rel_y_b);
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                        double y_t_l = LERP2D(y, rel_x_l, rel_y_t);
         | 
| 98 | 
            +
                        double y_t_r = LERP2D(y, rel_x_r, rel_y_t);
         | 
| 99 | 
            +
                        double y_b_l = LERP2D(y, rel_x_l, rel_y_b);
         | 
| 100 | 
            +
                        double y_b_r = LERP2D(y, rel_x_r, rel_y_b);
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                        Color  c_t_l = LERP2D(c, rel_x_l, rel_y_t);
         | 
| 103 | 
            +
                        Color  c_t_r = LERP2D(c, rel_x_r, rel_y_t);
         | 
| 104 | 
            +
                        Color  c_b_l = LERP2D(c, rel_x_l, rel_y_b);
         | 
| 105 | 
            +
                        Color  c_b_r = LERP2D(c, rel_x_r, rel_y_b);
         | 
| 106 106 |  | 
| 107 107 | 
             
                        tile.draw(x_t_l, y_t_l, c_t_l,
         | 
| 108 108 | 
             
                                  x_t_r, y_t_r, c_t_r,
         | 
    
        data/src/LargeImageData.hpp
    CHANGED
    
    | @@ -25,7 +25,7 @@ public: | |
| 25 25 | 
             
                          double x2, double y2, Color c2,
         | 
| 26 26 | 
             
                          double x3, double y3, Color c3,
         | 
| 27 27 | 
             
                          double x4, double y4, Color c4,
         | 
| 28 | 
            -
                          ZPos z,  | 
| 28 | 
            +
                          ZPos z, BlendMode mode) const override;
         | 
| 29 29 |  | 
| 30 30 | 
             
                const GLTexInfo* gl_tex_info() const override { return nullptr; }
         | 
| 31 31 |  |