2026-07-11 18:13:03 +03:00
|
|
|
//! Text editor panel — font, size, color, alignment, effects.
|
|
|
|
|
|
|
|
|
|
use crate::app::Message;
|
|
|
|
|
use iced::widget::{button, column, container, horizontal_rule, row, slider, text};
|
|
|
|
|
use iced::{Element, Length};
|
|
|
|
|
|
|
|
|
|
/// Build the text editor panel.
|
2026-07-12 02:05:31 +03:00
|
|
|
#[allow(dead_code)]
|
2026-07-11 18:13:03 +03:00
|
|
|
pub fn view(
|
|
|
|
|
font_size: f32,
|
|
|
|
|
font_color: [u8; 4],
|
|
|
|
|
_alignment: &str,
|
|
|
|
|
orientation: &str,
|
|
|
|
|
) -> Element<'static, Message> {
|
|
|
|
|
let size_slider = slider(8.0..=200.0, font_size, |v| Message::TextSizeChanged(v))
|
|
|
|
|
.step(1.0)
|
|
|
|
|
.width(Length::Fill);
|
|
|
|
|
|
|
|
|
|
let r = font_color[0];
|
|
|
|
|
let g = font_color[1];
|
|
|
|
|
let b = font_color[2];
|
|
|
|
|
|
2026-07-16 18:41:05 +03:00
|
|
|
let color_r = slider(0..=255, r, move |v| {
|
|
|
|
|
Message::TextColorChanged([v, g, b, 255])
|
|
|
|
|
});
|
|
|
|
|
let color_g = slider(0..=255, g, move |v| {
|
|
|
|
|
Message::TextColorChanged([r, v, b, 255])
|
|
|
|
|
});
|
|
|
|
|
let color_b = slider(0..=255, b, move |v| {
|
|
|
|
|
Message::TextColorChanged([r, g, v, 255])
|
|
|
|
|
});
|
2026-07-11 18:13:03 +03:00
|
|
|
|
|
|
|
|
let align_left = button(text("Left").size(10))
|
|
|
|
|
.on_press(Message::TextAlignChanged("Left".to_string()))
|
|
|
|
|
.padding([4, 8]);
|
|
|
|
|
let align_center = button(text("Center").size(10))
|
|
|
|
|
.on_press(Message::TextAlignChanged("Center".to_string()))
|
|
|
|
|
.padding([4, 8]);
|
|
|
|
|
let align_right = button(text("Right").size(10))
|
|
|
|
|
.on_press(Message::TextAlignChanged("Right".to_string()))
|
|
|
|
|
.padding([4, 8]);
|
|
|
|
|
|
|
|
|
|
let accept_btn = button(text("Accept").size(11))
|
|
|
|
|
.on_press(Message::TextAccept)
|
|
|
|
|
.padding([6, 12]);
|
|
|
|
|
let cancel_btn = button(text("Cancel").size(11))
|
|
|
|
|
.on_press(Message::TextCancel)
|
|
|
|
|
.padding([6, 12]);
|
|
|
|
|
|
|
|
|
|
let orient = orientation.to_string();
|
|
|
|
|
|
|
|
|
|
let panel = column![
|
2026-07-14 14:14:10 +03:00
|
|
|
text("Text").size(13),
|
2026-07-11 18:13:03 +03:00
|
|
|
horizontal_rule(1),
|
|
|
|
|
text(format!("Size: {:.0}", font_size)).size(10),
|
|
|
|
|
size_slider,
|
|
|
|
|
text("Color").size(10),
|
|
|
|
|
row![text("R").size(10), color_r].spacing(4),
|
|
|
|
|
row![text("G").size(10), color_g].spacing(4),
|
|
|
|
|
row![text("B").size(10), color_b].spacing(4),
|
|
|
|
|
row![align_left, align_center, align_right].spacing(4),
|
|
|
|
|
text(format!("Orientation: {}", orient)).size(10),
|
|
|
|
|
horizontal_rule(1),
|
|
|
|
|
row![accept_btn, cancel_btn].spacing(8),
|
|
|
|
|
]
|
|
|
|
|
.spacing(4)
|
|
|
|
|
.padding(8);
|
|
|
|
|
|
|
|
|
|
container(panel)
|
|
|
|
|
.width(Length::Fill)
|
|
|
|
|
.height(Length::Fill)
|
|
|
|
|
.style(move |_theme| iced::widget::container::Style {
|
2026-07-16 18:41:05 +03:00
|
|
|
background: Some(iced::Background::Color(iced::Color::from_rgb(
|
|
|
|
|
0.18, 0.18, 0.18,
|
|
|
|
|
))),
|
|
|
|
|
border: iced::Border::default()
|
|
|
|
|
.color(iced::Color::from_rgb(0.3, 0.3, 0.3))
|
|
|
|
|
.width(1),
|
2026-07-11 18:13:03 +03:00
|
|
|
..Default::default()
|
|
|
|
|
})
|
|
|
|
|
.into()
|
|
|
|
|
}
|