class

Opal::UI::TargetSelector2D

Inherits Opal::UI::Control < Opal::UI::InputHookable < Opal::UI::Element < Opal::UI::Themable < Reference < Object

Interactive 2D continuous target/coordinate selector. Supports custom X/Y continuous domains, procedural background shader blocks, static buffer backgrounds, custom reticle glyphs, mouse dragging, and arrow-key stepping.

Constructors

new(x_range : Range(Float64, Float64) = 0.0..1.0, y_range : Range(Float64, Float64) = 0.0..1.0, initial_x : Float64 | Nil = nil, initial_y : Float64 | Nil = nil, reticle_char : Char = '⌖', show_coordinates : Bool = true, border : Bool = true, width : Int32 | Nil = 24, height : Int32 | Nil = 10, background_shader : Proc(Float64, Float64, Color) | Nil = nil)
Source
new(x_range : Range(Float64, Float64) = 0.0..1.0, y_range : Range(Float64, Float64) = 0.0..1.0, initial_x : Float64 | Nil = nil, initial_y : Float64 | Nil = nil, reticle_char : Char = '⌖', show_coordinates : Bool = true, border : Bool = true, width : Int32 | Nil = 24, height : Int32 | Nil = 10, &block : Float64, Float64 -> Color)
Source

Instance methods

background_buffer

Optional pre-rendered background buffer

Source
background_buffer=(background_buffer : Buffer | Nil)

Optional pre-rendered background buffer

Source
background_color
Source
background_color=(background_color : Color)
Source
background_shader

Optional procedural background generator: receives normalized (u, v) in [0.0..1.0] and returns a Color

Source
background_shader=(background_shader : Proc(Float64, Float64, Color) | Nil)

Optional procedural background generator: receives normalized (u, v) in [0.0..1.0] and returns a Color

Source
border=(border : Bool)
Source
border?
Source
border_color
Source
border_color=(border_color : Color)
Source
confirmed?
Source
handle_key(key : Terminal::KeyEvent) : Bool

Default key event handler. Override in subclasses if not using @default_input_proc.

Source
handle_mouse(event : Terminal::MouseEvent) : Bool

Default mouse event handler. Override in subclasses if not using @default_input_proc.

Source
height
Source
height=(height : Int32)
Source
last_h
Source
last_h=(last_h : Int32)
Source
last_w
Source
last_w=(last_w : Int32)
Source
last_x
Source
last_x=(last_x : Int32)
Source
last_y
Source
last_y=(last_y : Int32)
Source
normalized_coords

Returns normalized (u, v) in [0.0..1.0]

Source
on_change

Callbacks

Source
on_change=(on_change : Proc(Float64, Float64, Nil) | Nil)

Callbacks

Source
on_confirm
Source
on_confirm=(on_confirm : Proc(Float64, Float64, Nil) | Nil)
Source
preferred_size(available_w : Int32, available_h : Int32) : Tuple(Int32, Int32)
Source
render(buffer : Buffer, x : Int32, y : Int32, width : Int32, height : Int32) : Nil
Source
render(buffer : Buffer) : Nil
Source
reticle_char
Source
reticle_char=(reticle_char : Char)
Source
reticle_color
Source
reticle_color=(reticle_color : Color)
Source
set_from_normalized(u : Float64, v : Float64) : Nil

Sets coordinates from normalized (u, v) in [0.0..1.0]

Source
set_values(x : Float64, y : Float64) : Nil

Sets current coordinate values and triggers on_change if changed

Source
show_coordinates
Source
show_coordinates=(show_coordinates : Bool)
Source
step_x
Source
step_x=(step_x : Float64)
Source
step_y
Source
step_y=(step_y : Float64)
Source
width
Source
width=(width : Int32)
Source
x_max
Source
x_max=(x_max : Float64)
Source
x_min
Source
x_min=(x_min : Float64)
Source
x_val
Source
x_val=(x_val : Float64)
Source
y_max
Source
y_max=(y_max : Float64)
Source
y_min
Source
y_min=(y_min : Float64)
Source
y_val
Source
y_val=(y_val : Float64)
Source