merge stable version #2

Merged
doryan merged 97 commits from experimental into main 2024-08-28 18:54:00 +03:00
Showing only changes of commit 2c331c4ed7 - Show all commits

View File

@ -5,10 +5,12 @@ use gtk::{prelude::*, *};
pub type InputLabel = String; pub type InputLabel = String;
#[derive(Clone)] #[derive(Clone, Debug)]
pub struct Input { pub struct Input {
component: Box, component: Box,
input: TextView, input: TextView,
input_label: Label,
input_frame: Frame,
} }
pub struct InputBuilder { pub struct InputBuilder {
@ -35,25 +37,33 @@ impl Product<InputBuilder, Box> for Input {
} }
impl Input { impl Input {
pub fn get_input(self) -> TextView { pub fn get_input(&self) -> &TextView {
self.input &self.input
}
pub fn get_frame(&self) -> &Frame {
&self.input_frame
}
pub fn get_label(&self) -> &Label {
&self.input_label
} }
} }
impl InputBuilder { impl InputBuilder {
pub fn set_label(mut self, label: &str) -> Self { pub fn label(mut self, label: &str) -> Self {
self.label = String::from(label); self.label = label.into();
self self
} }
pub fn set_align(mut self, align: Alignment) -> Self { pub fn align(mut self, align: Alignment) -> Self {
self.align = align; self.align = align;
self self
} }
pub fn set_margins(mut self, margin: MarginData) -> Self { pub fn margins(mut self, margin: MarginData) -> Self {
self.margins = margin; self.margins = margin;
self self
@ -62,7 +72,7 @@ impl InputBuilder {
pub fn build(self, monospace: bool, wrap_mode: WrapMode, input_height: i32) -> Input { pub fn build(self, monospace: bool, wrap_mode: WrapMode, input_height: i32) -> Input {
let input_component = Box::new(Orientation::Vertical, 0); let input_component = Box::new(Orientation::Vertical, 0);
let input_label = Label::builder() let text_view_label = Label::builder()
.halign(self.align.horizontal) .halign(self.align.horizontal)
.valign(self.align.vertical) .valign(self.align.vertical)
.set_margin(self.margins) .set_margin(self.margins)
@ -81,12 +91,14 @@ impl InputBuilder {
.set_margin(MarginData::MultipleMargin((0, 5, 0, 5))) .set_margin(MarginData::MultipleMargin((0, 5, 0, 5)))
.build(); .build();
input_component.append(&input_label); input_component.append(&text_view_label);
input_component.append(&text_view_input_frame); input_component.append(&text_view_input_frame);
Input { Input {
component: input_component, component: input_component,
input: text_view_input, input: text_view_input.clone(),
input_frame: text_view_input_frame.clone(),
input_label: text_view_label.clone(),
} }
} }
} }