Module: RbSDL2::Window::State

Included in:
RbSDL2::Window
Defined in:
lib/rb_sdl2/window/state.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.to_flags(allow_high_dpi: false, always_on_top: false, borderless: false, foreign: false, fullscreen: false, fullscreen_desktop: false, hidden: false, input_focus: false, input_grabbed: false, keyboard_grabbed: false, maximized: false, metal: false, minimized: false, mouse_capture: false, mouse_focus: false, mouse_grabbed: false, opengl: false, popup_menu: false, resizable: false, shown: false, skip_taskbar: false, tooltip: false, utility: false, vulkan: false) ⇒ Object



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
# File 'lib/rb_sdl2/window/state.rb', line 31

def to_flags(allow_high_dpi: false, always_on_top: false, borderless: false, foreign: false,
             fullscreen: false, fullscreen_desktop: false, hidden: false, input_focus: false,
             input_grabbed: false, keyboard_grabbed: false, maximized: false, metal: false,
             minimized: false, mouse_capture: false, mouse_focus: false, mouse_grabbed: false,
             opengl: false, popup_menu: false, resizable: false, shown: false,
             skip_taskbar: false, tooltip: false, utility: false, vulkan: false)
  0 |
    (allow_high_dpi ? SDL_WINDOW_ALLOW_HIGHDPI : 0) |
    (always_on_top ? SDL_WINDOW_ALWAYS_ON_TOP : 0) |
    (borderless ? SDL_WINDOW_BORDERLESS : 0) |
    (foreign ? SDL_WINDOW_FOREIGN : 0) |
    (fullscreen ? SDL_WINDOW_FULLSCREEN : 0) |
    (fullscreen_desktop ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0) |
    (hidden ? SDL_WINDOW_HIDDEN : 0) |
    (input_focus ? SDL_WINDOW_INPUT_FOCUS : 0) |
    (input_grabbed ? SDL_WINDOW_INPUT_GRABBED : 0) |
    (keyboard_grabbed ? SDL_WINDOW_KEYBOARD_GRABBED : 0) |
    (maximized ? SDL_WINDOW_MAXIMIZED : 0) |
    (metal ? SDL_WINDOW_METAL : 0) |
    (minimized ? SDL_WINDOW_MINIMIZED : 0) |
    (mouse_capture ? SDL_WINDOW_MOUSE_CAPTURE : 0) |
    (mouse_focus ? SDL_WINDOW_MOUSE_FOCUS : 0) |
    (mouse_grabbed ? SDL_WINDOW_MOUSE_GRABBED : 0) |
    (opengl ? SDL_WINDOW_OPENGL : 0)  |
    (popup_menu ? SDL_WINDOW_POPUP_MENU : 0) |
    (resizable ? SDL_WINDOW_RESIZABLE : 0) |
    (shown ? SDL_WINDOW_SHOWN : 0) |
    (skip_taskbar ? SDL_WINDOW_SKIP_TASKBAR : 0) |
    (tooltip ? SDL_WINDOW_TOOLTIP : 0) |
    (utility ? SDL_WINDOW_UTILITY : 0) |
    (vulkan ? SDL_WINDOW_VULKAN : 0)
end

Instance Method Details

#allow_high_dpi?Boolean

Returns:

  • (Boolean)


65
# File 'lib/rb_sdl2/window/state.rb', line 65

def allow_high_dpi? = flags?(SDL_WINDOW_ALLOW_HIGHDPI)

#always_on_top=(bool) ⇒ Object



67
68
69
# File 'lib/rb_sdl2/window/state.rb', line 67

def always_on_top=(bool)
  ::SDL.SetWindowAlwaysOnTop(self, bool ? ::SDL::TRUE : ::SDL::FALSE)
end

#always_on_top?Boolean

Returns:

  • (Boolean)


71
# File 'lib/rb_sdl2/window/state.rb', line 71

def always_on_top? = flags?(SDL_WINDOW_ALWAYS_ON_TOP)

#bordered=(bool) ⇒ Object



73
74
75
# File 'lib/rb_sdl2/window/state.rb', line 73

def bordered=(bool)
  ::SDL.SetWindowBordered(self, bool ? ::SDL::TRUE : ::SDL::FALSE)
end

#borderless?Boolean

Returns:

  • (Boolean)


77
# File 'lib/rb_sdl2/window/state.rb', line 77

def borderless? = flags?(SDL_WINDOW_BORDERLESS)

#current!Object



79
# File 'lib/rb_sdl2/window/state.rb', line 79

def current! = ::SDL.RaiseWindow(self);

#flagsObject



81
# File 'lib/rb_sdl2/window/state.rb', line 81

def flags = ::SDL.GetWindowFlags(self)

#flags?(num) ⇒ Boolean

Returns:

  • (Boolean)


83
# File 'lib/rb_sdl2/window/state.rb', line 83

def flags?(num) = flags & num != 0

#foreign?Boolean

Returns:

  • (Boolean)


85
# File 'lib/rb_sdl2/window/state.rb', line 85

def foreign? = flags?(SDL_WINDOW_FOREIGN)

#fullscreenObject

Raises:



87
88
89
90
91
# File 'lib/rb_sdl2/window/state.rb', line 87

def fullscreen
  err = ::SDL.SetWindowFullscreen(self, ::SDL::WINDOW_FULLSCREEN)
  raise RbSDL2Error if err < 0
  self
end

#fullscreen?Boolean

Returns:

  • (Boolean)


93
# File 'lib/rb_sdl2/window/state.rb', line 93

def fullscreen? = flags?(SDL_WINDOW_FULLSCREEN)

#fullscreen_desktopObject

Raises:



95
96
97
98
99
# File 'lib/rb_sdl2/window/state.rb', line 95

def fullscreen_desktop
  err = ::SDL.SetWindowFullscreen(self, ::SDL::WINDOW_FULLSCREEN_DESKTOP)
  raise RbSDL2Error if err < 0
  self
end

#fullscreen_desktop?Boolean

Returns:

  • (Boolean)


101
# File 'lib/rb_sdl2/window/state.rb', line 101

def fullscreen_desktop? = flags?(SDL_WINDOW_FULLSCREEN_DESKTOP)

#grab=(bool) ⇒ Object



103
104
105
# File 'lib/rb_sdl2/window/state.rb', line 103

def grab=(bool)
  ::SDL.SetWindowGrab(self, bool ? ::SDL::TRUE : ::SDL::FALSE)
end

#grabbed?Boolean

Returns:

  • (Boolean)


107
# File 'lib/rb_sdl2/window/state.rb', line 107

def grabbed? = ::SDL.GetWindowGrab(self) == ::SDL::TRUE

#grabbed_keyboard?Boolean

Returns:

  • (Boolean)


109
# File 'lib/rb_sdl2/window/state.rb', line 109

def grabbed_keyboard? = ::SDL.GetWindowKeyboardGrab(self) == ::SDL::TRUE

#grabbed_mouse?Boolean

Returns:

  • (Boolean)


111
# File 'lib/rb_sdl2/window/state.rb', line 111

def grabbed_mouse? = ::SDL.GetWindowMouseGrab(self) == ::SDL::TRUE

#hidden?Boolean

Returns:

  • (Boolean)


115
# File 'lib/rb_sdl2/window/state.rb', line 115

def hidden? = flags?(SDL_WINDOW_HIDDEN)

#hideObject



113
# File 'lib/rb_sdl2/window/state.rb', line 113

def hide = ::SDL.HideWindow(self);

#input_focused?Boolean

Returns:

  • (Boolean)


117
# File 'lib/rb_sdl2/window/state.rb', line 117

def input_focused? = flags?(SDL_WINDOW_INPUT_FOCUS)

#input_grabbed?Boolean

Returns:

  • (Boolean)


119
# File 'lib/rb_sdl2/window/state.rb', line 119

def input_grabbed? = flags?(SDL_WINDOW_INPUT_GRABBED)

#keyboard_grab=(bool) ⇒ Object



121
122
123
# File 'lib/rb_sdl2/window/state.rb', line 121

def keyboard_grab=(bool)
  ::SDL.SetWindowKeyboardGrab(self, bool ? ::SDL::TRUE : ::SDL::FALSE)
end

#keyboard_grabbed?Boolean

Returns:

  • (Boolean)


125
# File 'lib/rb_sdl2/window/state.rb', line 125

def keyboard_grabbed? = flags?(SDL_WINDOW_KEYBOARD_GRABBED)

#maximizeObject



127
# File 'lib/rb_sdl2/window/state.rb', line 127

def maximize = ::SDL.MaximizeWindow(self);

#maximized?Boolean

Returns:

  • (Boolean)


129
# File 'lib/rb_sdl2/window/state.rb', line 129

def maximized? = flags?(SDL_WINDOW_MAXIMIZED)

#metal?Boolean

Returns:

  • (Boolean)


131
# File 'lib/rb_sdl2/window/state.rb', line 131

def metal? = flags?(SDL_WINDOW_METAL)

#minimizeObject



133
# File 'lib/rb_sdl2/window/state.rb', line 133

def minimize = ::SDL.MinimizeWindow(self);

#minimized?Boolean

Returns:

  • (Boolean)


135
# File 'lib/rb_sdl2/window/state.rb', line 135

def minimized? = flags?(SDL_WINDOW_MINIMIZED)

#mouse_captured?Boolean

Returns:

  • (Boolean)


137
# File 'lib/rb_sdl2/window/state.rb', line 137

def mouse_captured? = flags?(SDL_WINDOW_MOUSE_CAPTURE)

#mouse_focused?Boolean

Returns:

  • (Boolean)


139
# File 'lib/rb_sdl2/window/state.rb', line 139

def mouse_focused? = flags?(SDL_WINDOW_MOUSE_FOCUS)

#mouse_grab=(bool) ⇒ Object



141
142
143
# File 'lib/rb_sdl2/window/state.rb', line 141

def mouse_grab=(bool)
  ::SDL.SetWindowMouseGrab(self, bool ? ::SDL::TRUE : ::SDL::FALSE)
end

#mouse_grabbed?Boolean

Returns:

  • (Boolean)


145
# File 'lib/rb_sdl2/window/state.rb', line 145

def mouse_grabbed? = flags?(SDL_WINDOW_MOUSE_GRABBED)

#opengl?Boolean

Returns:

  • (Boolean)


147
# File 'lib/rb_sdl2/window/state.rb', line 147

def opengl? = flags?(SDL_WINDOW_OPENGL)

Returns:

  • (Boolean)


149
# File 'lib/rb_sdl2/window/state.rb', line 149

def popup_menu? = flags?(SDL_WINDOW_POPUP_MENU)

#resizable=(bool) ⇒ Object



151
152
153
# File 'lib/rb_sdl2/window/state.rb', line 151

def resizable=(bool)
  ::SDL.SetWindowResizable(self, bool ? ::SDL::TRUE : ::SDL::FALSE)
end

#resizable?Boolean

Returns:

  • (Boolean)


155
# File 'lib/rb_sdl2/window/state.rb', line 155

def resizable? = flags?(SDL_WINDOW_RESIZABLE)

#restoreObject



157
# File 'lib/rb_sdl2/window/state.rb', line 157

def restore = ::SDL.RestoreWindow(self);

#showObject



159
# File 'lib/rb_sdl2/window/state.rb', line 159

def show = ::SDL.ShowWindow(self);

#shown?Boolean

Returns:

  • (Boolean)


161
# File 'lib/rb_sdl2/window/state.rb', line 161

def shown? = flags?(SDL_WINDOW_SHOWN)

#skip_taskbar?Boolean

Returns:

  • (Boolean)


163
# File 'lib/rb_sdl2/window/state.rb', line 163

def skip_taskbar? = flags?(SDL_WINDOW_SKIP_TASKBAR)

#tooltip?Boolean

Returns:

  • (Boolean)


165
# File 'lib/rb_sdl2/window/state.rb', line 165

def tooltip? = flags?(SDL_WINDOW_TOOLTIP)

#utility?Boolean

Returns:

  • (Boolean)


167
# File 'lib/rb_sdl2/window/state.rb', line 167

def utility? = flags?(SDL_WINDOW_UTILITY)

#vulkan?Boolean

Returns:

  • (Boolean)


169
# File 'lib/rb_sdl2/window/state.rb', line 169

def vulkan? = flags?(SDL_WINDOW_VULKAN)

#windowedObject

Raises:



171
172
173
174
175
# File 'lib/rb_sdl2/window/state.rb', line 171

def windowed
  err = ::SDL.SetWindowFullscreen(self, 0)
  raise RbSDL2Error if err < 0
  self
end