Add visual radio
This commit is contained in:
parent
804ce7dcff
commit
3e11ddd30f
@ -4,8 +4,8 @@ require 'prawn/blank'
|
|||||||
module Fourmi::Prawn::Utils
|
module Fourmi::Prawn::Utils
|
||||||
module Extensions
|
module Extensions
|
||||||
module VisualForm
|
module VisualForm
|
||||||
def visual_checkbox(name, checked = false, size: 8, white: false, form: false)
|
def visual_checkbox(name, checked = false, size: 8, white: false, form: false, at: [0, cursor])
|
||||||
bounding_box([0, cursor], width: bounds.width) do
|
bounding_box(at, width: bounds.width) do
|
||||||
float do
|
float do
|
||||||
bounding_box([0, cursor], width: size, height: size) do
|
bounding_box([0, cursor], width: size, height: size) do
|
||||||
if form
|
if form
|
||||||
@ -24,6 +24,30 @@ module Fourmi::Prawn::Utils
|
|||||||
end if block_given?
|
end if block_given?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def visual_radio(parent, value:, checked: false, size: 8, white: false, form: false, at: [0, cursor])
|
||||||
|
bounding_box(at, width: bounds.width) do
|
||||||
|
float do
|
||||||
|
bounding_box([0, cursor], width: size, height: size) do
|
||||||
|
center_coordinates = [bounds.right / 2.0, bounds.top / 2.0]
|
||||||
|
radius = size / 2.0
|
||||||
|
|
||||||
|
if form
|
||||||
|
radio parent: parent, at: [0, bounds.top], value: value, width: bounds.width, height: bounds.height
|
||||||
|
else
|
||||||
|
with_fill_color 'FFFFFF' do
|
||||||
|
fill_circle center_coordinates, radius if white
|
||||||
|
end
|
||||||
|
fill_circle center_coordinates, radius - 2 if checked
|
||||||
|
end
|
||||||
|
stroke_circle center_coordinates, bounds.width / 2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
indent(size + 7) do
|
||||||
|
yield
|
||||||
|
end if block_given?
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user