turns out trying to access the position of a closed window results in an x error
who could've known
This commit is contained in:
parent
7fcf926426
commit
49ce6885ea
|
@ -40,9 +40,11 @@ class Funfriend::ChatterContext < Funfriend::WindowContext
|
||||||
def update_position
|
def update_position
|
||||||
if parent
|
if parent
|
||||||
p = parent.not_nil!
|
p = parent.not_nil!
|
||||||
|
if !p.closed
|
||||||
window.position = (Vec2.new(p.window.position) + Vec2.new(p.window.size) / 2 + parent_relative_pos - window_size / 2).xy_i
|
window.position = (Vec2.new(p.window.position) + Vec2.new(p.window.size) / 2 + parent_relative_pos - window_size / 2).xy_i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def render(dt : Float64)
|
def render(dt : Float64)
|
||||||
# let OpenGL draw to it
|
# let OpenGL draw to it
|
||||||
|
|
|
@ -5,6 +5,7 @@ GLFW_FOCUS_ON_SHOW = 0x0002000C
|
||||||
|
|
||||||
class Funfriend::WindowContext
|
class Funfriend::WindowContext
|
||||||
getter window : CrystGLFW::Window
|
getter window : CrystGLFW::Window
|
||||||
|
property closed : Bool = false
|
||||||
|
|
||||||
DEFAULT_HINTS = {
|
DEFAULT_HINTS = {
|
||||||
# supposedly required on MacOS
|
# supposedly required on MacOS
|
||||||
|
@ -43,6 +44,7 @@ class Funfriend::WindowContext
|
||||||
|
|
||||||
def close
|
def close
|
||||||
window.destroy
|
window.destroy
|
||||||
|
@closed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_up
|
def clean_up
|
||||||
|
|
Loading…
Reference in New Issue