ltk/widget/
factory.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-License-Identifier: LGPL-2.1-only
// Copyright (C) 2026 Liberux Labs, S. L. <info@liberux.net>

use std::sync::Arc;

use super::button::Button;
use super::container::Container;
use super::element::Element;
use super::external::{ External, ExternalSource };
use super::image::Image;
use super::text::Text;
use super::text_edit::TextEdit;

pub fn button<Msg: Clone>( label: impl Into<String> ) -> Button<Msg>
{
	Button::new( label.into() )
}

pub fn icon_button<Msg: Clone>( rgba: Arc<Vec<u8>>, img_w: u32, img_h: u32 ) -> Button<Msg>
{
	Button::new_icon( rgba, img_w, img_h )
}

pub fn text_edit<Msg: Clone>(
	placeholder: impl Into<String>,
	value: impl Into<String>,
) -> TextEdit<Msg>
{
	TextEdit::new( placeholder.into(), value.into() )
}

pub fn image( rgba: Arc<Vec<u8>>, width: u32, height: u32 ) -> Image
{
	Image::new( rgba, width, height )
}

pub fn text( content: impl Into<String> ) -> Text
{
	Text::new( content )
}

pub fn container<Msg: Clone>( child: impl Into<Element<Msg>> ) -> Container<Msg>
{
	Container::new( child )
}

/// Build an [`External`] widget that hosts content rendered by
/// a caller-managed GL texture producer.
pub fn external( width: f32, height: f32, source: ExternalSource ) -> External
{
	External::new( width, height, source )
}