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 06439585eb - Show all commits

View File

@ -5,6 +5,41 @@ use gtk::{prelude::*, *};
pub type InputLabel = String; pub type InputLabel = String;
macro_rules! build_for {
( $(($comp:ty,$name:ident)),* ) => {
$(
pub fn $name(self, input_height: Option<i32>) -> Input<$comp> {
let input_component = Box::new(Orientation::Vertical, 0);
let input_label = Label::builder()
.halign(self.align.horizontal)
.valign(self.align.vertical)
.set_margin(self.margins)
.label(self.label)
.build();
let mut input_builder = <$comp>::builder()
.set_margin(MarginData::EqualsMargin(6));
if let Some(height) = input_height {
input_builder = input_builder.height_request(height);
}
let input = input_builder.build();
input_component.append(&input_label);
input_component.append(&input);
Input {
component: input_component,
input: input.clone(),
input_label: input_label.clone(),
}
}
)*
};
}
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Input { pub struct Input {
component: Box, component: Box,
@ -101,4 +136,5 @@ impl InputBuilder {
input_label: text_view_label.clone(), input_label: text_view_label.clone(),
} }
} }
build_for!((TextView, build), (Entry, build_entry));
} }