class

Opal::UI::Palette

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

Interactive Palette UI control supporting Named and Indexed modes, color reordering via [ and ], min/max constraints, inline renaming, and seamless embedded ColorPicker integration.

Constructors

indexed(colors : Array(Color), min_colors : Int32 | Nil = nil, max_colors : Int32 | Nil = nil, allow_add : Bool = true, allow_remove : Bool = true, allow_reorder : Bool = true, picker_mode : ColorMode = ColorMode::RGB, picker_layout : ColorPickerLayout = ColorPickerLayout::Sliders, show_picker_alpha : Bool = false, show_picker_harmonies : Bool = true, title : String = "Indexed Palette", width : Int32 | Nil = 54, height : Int32 | Nil = 16) : Palette

Convenience constructor for indexed mode from Array(Color)

Source
named(entries : Hash(String, Color), allow_add : Bool = true, allow_rename : Bool = true, allow_remove : Bool = true, picker_mode : ColorMode = ColorMode::RGB, picker_layout : ColorPickerLayout = ColorPickerLayout::Sliders, show_picker_alpha : Bool = false, show_picker_harmonies : Bool = true, title : String = "Named Palette", width : Int32 | Nil = 54, height : Int32 | Nil = 16) : Palette

Convenience constructor for named mode from Hash(String, Color)

Source
new(model : PaletteModel = PaletteModel.new, picker_mode : ColorMode = ColorMode::RGB, picker_layout : ColorPickerLayout = ColorPickerLayout::Sliders, show_picker_alpha : Bool = false, show_picker_harmonies : Bool = true, title : String = "Color Palette", width : Int32 | Nil = 54, height : Int32 | Nil = 16)
Source

Instance methods

active_border_color
Source
active_border_color=(active_border_color : Color)
Source
add_entry

Adds a new color or entry

Source
border_color
Source
border_color=(border_color : Color)
Source
cancel_color_edit

Cancels color editing without saving

Source
cancel_rename
Source
color_picker

Embedded ColorPicker state

Source
confirm_color_edit(color : Color) : Nil

Confirms the edited color from ColorPicker back to the Palette

Source
confirm_rename
Source
confirmed=(confirmed : Bool)
Source
confirmed?
Source
cursor
Source
cursor=(cursor : Int32)
Source
delete_selected

Removes selected entry

Source
editing_color=(editing_color : Bool)
Source
editing_color?
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
model
Source
model=(model : PaletteModel)
Source
move_cursor(delta : Int32) : Nil

Moves cursor with bounds checking and triggers selection callback

Source
on_change

Callbacks

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

Callbacks

Source
on_confirm
Source
on_confirm=(on_confirm : Proc(PaletteModel, Nil) | Nil)
Source
on_select
Source
on_select=(on_select : Proc(Int32, Color, String | Nil, Nil) | Nil)
Source
open_color_picker

Begins editing the currently selected color with the ColorPicker

Source
picker_layout
Source
picker_layout=(picker_layout : ColorPickerLayout)
Source
picker_mode
Source
picker_mode=(picker_mode : ColorMode)
Source
preferred_size(available_w : Int32, available_h : Int32) : Tuple(Int32, Int32)
Source
rename_buffer
Source
rename_buffer=(rename_buffer : String)
Source
renaming=(renaming : Bool)

Inline renaming state (Named mode)

Source
renaming?

Inline renaming state (Named mode)

Source
render(buffer : Buffer, x : Int32, y : Int32, width : Int32, height : Int32) : Nil
Source
render(buffer : Buffer) : Nil
Source
set_cursor(idx : Int32) : Nil
Source
show_border=(show_border : Bool)
Source
show_border?
Source
show_picker_alpha=(show_picker_alpha : Bool)
Source
show_picker_alpha?
Source
show_picker_harmonies=(show_picker_harmonies : Bool)
Source
show_picker_harmonies?
Source
start_rename

Starts inline renaming

Source
swap_left

Swap selected color left/earlier (via [ key)

Source
swap_right

Swap selected color right/later (via ] key)

Source
title

Visual styling

Source
title=(title : String)

Visual styling

Source
width

Geometry cache

Source
width=(width : Int32)

Geometry cache

Source