Add reusable UI components for Phase 7 UI Polish
- Introduced `EmojiQuickGrid`, `FontPresetPicker`, and `PresetSizeToggle` classes for emoji selection, font presets, and size toggles respectively. - Implemented configuration methods for each component to handle dynamic content and theming. - Created tests for the new components to ensure functionality and integration with the existing UI. - Added a comprehensive architecture specification for Phase 7 UI Polish detailing scope, implementation, and validation strategies. - Updated existing theme handling to support new UI elements and ensure consistent styling across the application.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
class_name PresetSizeToggle
|
||||
extends HBoxContainer
|
||||
signal preset_selected(id: String, value: int)
|
||||
var _presets: Array[Dictionary] = []
|
||||
var _selected_id: String = ""
|
||||
var _group: ButtonGroup = ButtonGroup.new()
|
||||
func configure(presets: Array[Dictionary], selected_id: String, theme: Variant = null) -> void:
|
||||
for child: Node in get_children(): child.queue_free()
|
||||
_presets = presets.duplicate(true); _selected_id = selected_id
|
||||
for item: Dictionary in _presets:
|
||||
if String(item.get("id","")).is_empty(): continue
|
||||
var button := Button.new(); button.text = String(item.get("label", item["id"])); button.custom_minimum_size = Vector2(44,44); button.toggle_mode = true; button.button_group = _group
|
||||
button.pressed.connect(func() -> void: set_selected(String(item["id"]), true)); add_child(button); button.set_pressed_no_signal(String(item["id"]) == selected_id)
|
||||
if not _presets.is_empty() and _selected_id.is_empty(): _selected_id = String(_presets[0].get("id", ""))
|
||||
func set_selected(id: String, emit_signal: bool = false) -> void:
|
||||
for item: Dictionary in _presets:
|
||||
if String(item.get("id", "")) == id:
|
||||
_selected_id = id
|
||||
if emit_signal: preset_selected.emit(id, int(item.get("value", 0)))
|
||||
return
|
||||
func get_selected_id() -> String: return _selected_id
|
||||
func get_selected_value() -> int:
|
||||
for item: Dictionary in _presets:
|
||||
if String(item.get("id", "")) == _selected_id: return int(item.get("value", 0))
|
||||
return 0
|
||||
Reference in New Issue
Block a user