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

update drawing functions names and argument order #58

Merged
merged 4 commits into from
Aug 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/drawing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function draw_text_line_with_slider_in_a_box!(image, bounding_box, slider_value,
return nothing
end

function SD.draw!(image::AbstractMatrix, bounding_box::SD.Rectangle, widget_type::AbstractWidgetType, args...; kwargs...)
function draw_widget!(image::AbstractMatrix, widget_type::AbstractWidgetType, bounding_box::SD.Rectangle, args...; kwargs...)
if SD.is_outbounds(image, bounding_box)
return nothing
end
Expand All @@ -73,12 +73,12 @@ function SD.draw!(image::AbstractMatrix, bounding_box::SD.Rectangle, widget_type

view_box_bounding_box = SD.Rectangle(SD.Point(bounding_box.position.i - i_min + one(i_min), bounding_box.position.j - j_min + one(j_min)), bounding_box.height, bounding_box.width)

draw_widget!(view_box_image, view_box_bounding_box, widget_type, args...; kwargs...)
draw_widget_unclipped!(view_box_image, widget_type, view_box_bounding_box, args...; kwargs...)

return nothing
end

function draw_widget!(image, bounding_box, widget_type::Button, user_interaction_state, this_widget, text, font, alignment, padding, background_color, border_color, text_color)
function draw_widget_unclipped!(image, widget_type::Button, bounding_box, user_interaction_state, this_widget, text, font, alignment, padding, background_color, border_color, text_color)
draw_text_line_in_a_box!(
image,
bounding_box,
Expand All @@ -92,7 +92,7 @@ function draw_widget!(image, bounding_box, widget_type::Button, user_interaction
)
end

function draw_widget!(image, bounding_box, widget_type::Slider, user_interaction_state, this_widget, slider_value, alignment, padding, text, font, background_color, border_color, text_color, bar_color)
function draw_widget_unclipped!(image, widget_type::Slider, bounding_box, user_interaction_state, this_widget, slider_value, alignment, padding, text, font, background_color, border_color, text_color, bar_color)
draw_text_line_with_slider_in_a_box!(
image,
bounding_box,
Expand All @@ -108,7 +108,7 @@ function draw_widget!(image, bounding_box, widget_type::Slider, user_interaction
)
end

function draw_widget!(image, bounding_box, widget_type::TextBox, user_interaction_state, this_widget, text, alignment, padding, font, background_color, border_color, text_color)
function draw_widget_unclipped!(image, widget_type::TextBox, bounding_box, user_interaction_state, this_widget, text, alignment, padding, font, background_color, border_color, text_color)
if get_num_printable_characters(text) * SD.get_width(font) > bounding_box.width
alignment = RIGHT_IN
end
Expand All @@ -134,9 +134,9 @@ function draw_widget!(image, bounding_box, widget_type::TextBox, user_interactio
return nothing
end

draw_widget!(image, bounding_box, widget_type::Text, user_interaction_state, this_widget, text, font, alignment, padding, background_color, border_color, text_color) = draw_widget!(image, bounding_box, BUTTON, user_interaction_state, this_widget, text, font, alignment, padding, background_color, border_color, text_color)
draw_widget_unclipped!(image, widget_type::Text, bounding_box, user_interaction_state, this_widget, text, font, alignment, padding, background_color, border_color, text_color) = draw_widget_unclipped!(image, BUTTON, bounding_box, user_interaction_state, this_widget, text, font, alignment, padding, background_color, border_color, text_color)

function draw_widget!(image, bounding_box, widget_type::CheckBox, user_interaction_state, this_widget, widget_value, alignment, padding, text, font, background_color, border_color, text_color, indicator_color)
function draw_widget_unclipped!(image, widget_type::CheckBox, bounding_box, user_interaction_state, this_widget, widget_value, alignment, padding, text, font, background_color, border_color, text_color, indicator_color)
font_width = SD.get_width(font)
box_width = oftype(font_width, 2) * font_width
x = box_width ÷ oftype(box_width, 8)
Expand All @@ -160,7 +160,7 @@ function draw_widget!(image, bounding_box, widget_type::CheckBox, user_interacti
return nothing
end

function draw_widget!(image, bounding_box, widget_type::RadioButton, user_interaction_state, this_widget, widget_value, alignment, padding, text, font, background_color, border_color, text_color, indicator_color)
function draw_widget_unclipped!(image, widget_type::RadioButton, bounding_box, user_interaction_state, this_widget, widget_value, alignment, padding, text, font, background_color, border_color, text_color, indicator_color)

font_width = SD.get_width(font)
indicator_width = oftype(font_width, 2) * font_width
Expand All @@ -185,7 +185,7 @@ function draw_widget!(image, bounding_box, widget_type::RadioButton, user_intera
return nothing
end

function draw_widget!(image, bounding_box, widget_type::DropDown, user_interaction_state, this_widget, widget_value, alignment, padding, text, font, background_color, border_color, text_color, indicator_color)
function draw_widget_unclipped!(image, widget_type::DropDown, bounding_box, user_interaction_state, this_widget, widget_value, alignment, padding, text, font, background_color, border_color, text_color, indicator_color)
font_width = SD.get_width(font)
indicator_width = oftype(font_width, 2) * font_width
x = indicator_width ÷ oftype(indicator_width, 8)
Expand Down
6 changes: 3 additions & 3 deletions src/widgets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ function do_widget!(

widget_value = do_widget!(widget_type, user_interaction_state, this_widget, cursor, input_button, widget_bounding_box)

SD.draw!(image, widget_bounding_box, widget_type, user_interaction_state, this_widget, text, font, content_alignment, content_padding, background_color, border_color, text_color)
draw_widget!(image, widget_type, widget_bounding_box, user_interaction_state, this_widget, text, font, content_alignment, content_padding, background_color, border_color, text_color)

return widget_value
end
Expand Down Expand Up @@ -339,7 +339,7 @@ function do_widget!(

widget_value = do_widget!(widget_type, user_interaction_state, this_widget, widget_value, cursor, input_button, widget_bounding_box)

SD.draw!(image, widget_bounding_box, widget_type, user_interaction_state, this_widget, widget_value, content_alignment, content_padding, text, font, background_color, border_color, text_color, indicator_color)
draw_widget!(image, widget_type, widget_bounding_box, user_interaction_state, this_widget, widget_value, content_alignment, content_padding, text, font, background_color, border_color, text_color, indicator_color)

return widget_value
end
Expand Down Expand Up @@ -371,7 +371,7 @@ function do_widget!(

widget_value = do_widget!(widget_type, user_interaction_state, this_widget, widget_value, cursor, input_button, characters, widget_bounding_box)

SD.draw!(image, widget_bounding_box, widget_type, user_interaction_state, this_widget, widget_value, content_alignment, content_padding, font, background_color, border_color, text_color)
draw_widget!(image, widget_type, widget_bounding_box, user_interaction_state, this_widget, widget_value, content_alignment, content_padding, font, background_color, border_color, text_color)

return widget_value
end