Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add type parameters to some structs #55

Merged
merged 8 commits into from
Aug 5, 2022
26 changes: 13 additions & 13 deletions src/input.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
struct InputButton
struct InputButton{I}
ended_down::Bool
num_transitions::Int
num_transitions::I
end

abstract type AbstractUserInputState end

mutable struct UserInputState <: AbstractUserInputState
cursor::SD.Point
key_escape::InputButton
key_up::InputButton
key_down::InputButton
key_left::InputButton
key_right::InputButton
mouse_left::InputButton
mouse_right::InputButton
mouse_middle::InputButton
mutable struct UserInputState{I1, I2} <: AbstractUserInputState
cursor::SD.Point{I1}
key_escape::InputButton{I2}
key_up::InputButton{I2}
key_down::InputButton{I2}
key_left::InputButton{I2}
key_right::InputButton{I2}
mouse_left::InputButton{I2}
mouse_right::InputButton{I2}
mouse_middle::InputButton{I2}
characters::Vector{Char}
end

Expand All @@ -28,7 +28,7 @@ press(input_button) = InputButton(true, input_button.num_transitions + one(input
release(input_button) = InputButton(false, input_button.num_transitions + one(input_button.num_transitions))
reset(input_button) = InputButton(input_button.ended_down, zero(input_button.num_transitions))

function reset!(user_input_state::UserInputState)
function reset!(user_input_state)
user_input_state.key_escape = reset(user_input_state.key_escape)
user_input_state.key_up = reset(user_input_state.key_up)
user_input_state.key_down = reset(user_input_state.key_down)
Expand Down
4 changes: 2 additions & 2 deletions src/layout.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
abstract type AbstractLayout end

mutable struct BoxLayout <: AbstractLayout
reference_bounding_box::SD.Rectangle{Int}
mutable struct BoxLayout{I} <: AbstractLayout
reference_bounding_box::SD.Rectangle{I}
end

@enum Alignment begin
Expand Down
16 changes: 8 additions & 8 deletions src/user_interaction.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
abstract type AbstractWidgetID end

struct WidgetID <: AbstractWidgetID
file::String
line::Int
instance::Int
struct WidgetID{S, I} <: AbstractWidgetID
file::S
line::I
instance::I
end

abstract type AbstractUserInteractionState end

mutable struct UserInteractionState <: AbstractUserInteractionState
hot_widget::WidgetID
active_widget::WidgetID
null_widget::WidgetID
mutable struct UserInteractionState{S, I} <: AbstractUserInteractionState
hot_widget::WidgetID{S, I}
active_widget::WidgetID{S, I}
null_widget::WidgetID{S, I}
end

const NULL_WIDGET_ID = WidgetID("", 0, 0)