pub struct UiTextureBuilder<'a> { /* private fields */ }Expand description
Builder for UiTexture.
Implementations§
Source§impl<'a> UiTextureBuilder<'a>
impl<'a> UiTextureBuilder<'a>
Sourcepub fn position(self, value: (f32, f32)) -> Self
pub fn position(self, value: (f32, f32)) -> Self
Examples found in repository?
examples/hello.rs (line 51)
15fn main() {
16 let display = glutin::WindowBuilder::new()
17 .with_dimensions(640, 640)
18 .with_vsync()
19 .build_glium()
20 .unwrap();
21
22 let mut ui = Ui::new(&display);
23
24 let font =
25 FontTexture::new(&display, FONT_RAW, 50, FontTexture::ascii_character_list()).unwrap();
26
27 let text_display = ui.build_text_display(&font, "hello");
28
29 let mut text = UiTextBuilder::default()
30 .position((0.1, 0.1))
31 .size((0.15, 0.1))
32 .text(text_display)
33 .color((0.1, 0.1, 0.1, 1.0))
34 .build()
35 .unwrap();
36
37 let mut button1 = UiButtonBuilder::default()
38 .position((0.1, 0.1))
39 .size((0.15, 0.1))
40 .build()
41 .unwrap();
42
43 let mut button2 = UiButtonBuilder::default()
44 .position((0.5, 0.5))
45 .size((0.3, 0.3))
46 .build()
47 .unwrap();
48
49 let texture = SimpleTexture::from(&KNOB_BASE_WHITE_RAW, ImageFormat::PNG, &display).unwrap();
50 let knob_base = UiTextureBuilder::default()
51 .position((0.5, 0.5))
52 .size((0.3, 0.3))
53 .rotation(0.0)
54 .texture(&texture)
55 .build()
56 .unwrap();
57
58 let texture = SimpleTexture::from(&KNOB_LIGHT_RAW, ImageFormat::PNG, &display).unwrap();
59 let mut knob_light = UiTextureBuilder::default()
60 .position((0.5, 0.5))
61 .size((0.3, 0.3))
62 .rotation(0.0)
63 .texture(&texture)
64 .build()
65 .unwrap();
66
67 loop {
68 ui.update(|target, mouse, system| {
69 button1.update(&mouse);
70 button2.update(&mouse);
71
72 target.clear_color(0.4, 0.4, 0.4, 1.0);
73
74 match *button1.left() {
75 ButtonState::Pressed(_x, _y) => {
76 text.set_text("world");
77 text.color.0 += mouse.delta_position().0 * 2.55;
78 text.color.1 += mouse.delta_position().1 * 2.55;
79 }
80 _ => {
81 text.set_text("hello");
82 }
83 }
84 match *button1.right() {
85 ButtonState::Pressed(_x, _y) => {
86 text.set_text("MOVE!");
87 text.position.0 += mouse.delta_position().0 * 5.0;
88 text.position.1 += mouse.delta_position().1 * 5.0;
89 button1.position.0 += mouse.delta_position().0 * 5.0;
90 button1.position.1 += mouse.delta_position().1 * 5.0;
91 }
92 _ => {
93 text.set_text("hello");
94 }
95 }
96
97 match *button2.left() {
98 ButtonState::Pressed(_x, _y) => {
99 knob_light.rotation += mouse.delta_position().1 * 360.0;
100 }
101 _ => (),
102 }
103 match *button2.right() {
104 ButtonState::Pressed(_x, _y) => {
105 knob_light.rotation += mouse.delta_position().1 * 360.0 * 2.0;
106 }
107 _ => (),
108 }
109
110 text.draw(target, system);
111 knob_base.draw(target, system);
112 knob_light.draw(target, system);
113 });
114 }
115}Sourcepub fn size(self, value: (f32, f32)) -> Self
pub fn size(self, value: (f32, f32)) -> Self
Examples found in repository?
examples/hello.rs (line 52)
15fn main() {
16 let display = glutin::WindowBuilder::new()
17 .with_dimensions(640, 640)
18 .with_vsync()
19 .build_glium()
20 .unwrap();
21
22 let mut ui = Ui::new(&display);
23
24 let font =
25 FontTexture::new(&display, FONT_RAW, 50, FontTexture::ascii_character_list()).unwrap();
26
27 let text_display = ui.build_text_display(&font, "hello");
28
29 let mut text = UiTextBuilder::default()
30 .position((0.1, 0.1))
31 .size((0.15, 0.1))
32 .text(text_display)
33 .color((0.1, 0.1, 0.1, 1.0))
34 .build()
35 .unwrap();
36
37 let mut button1 = UiButtonBuilder::default()
38 .position((0.1, 0.1))
39 .size((0.15, 0.1))
40 .build()
41 .unwrap();
42
43 let mut button2 = UiButtonBuilder::default()
44 .position((0.5, 0.5))
45 .size((0.3, 0.3))
46 .build()
47 .unwrap();
48
49 let texture = SimpleTexture::from(&KNOB_BASE_WHITE_RAW, ImageFormat::PNG, &display).unwrap();
50 let knob_base = UiTextureBuilder::default()
51 .position((0.5, 0.5))
52 .size((0.3, 0.3))
53 .rotation(0.0)
54 .texture(&texture)
55 .build()
56 .unwrap();
57
58 let texture = SimpleTexture::from(&KNOB_LIGHT_RAW, ImageFormat::PNG, &display).unwrap();
59 let mut knob_light = UiTextureBuilder::default()
60 .position((0.5, 0.5))
61 .size((0.3, 0.3))
62 .rotation(0.0)
63 .texture(&texture)
64 .build()
65 .unwrap();
66
67 loop {
68 ui.update(|target, mouse, system| {
69 button1.update(&mouse);
70 button2.update(&mouse);
71
72 target.clear_color(0.4, 0.4, 0.4, 1.0);
73
74 match *button1.left() {
75 ButtonState::Pressed(_x, _y) => {
76 text.set_text("world");
77 text.color.0 += mouse.delta_position().0 * 2.55;
78 text.color.1 += mouse.delta_position().1 * 2.55;
79 }
80 _ => {
81 text.set_text("hello");
82 }
83 }
84 match *button1.right() {
85 ButtonState::Pressed(_x, _y) => {
86 text.set_text("MOVE!");
87 text.position.0 += mouse.delta_position().0 * 5.0;
88 text.position.1 += mouse.delta_position().1 * 5.0;
89 button1.position.0 += mouse.delta_position().0 * 5.0;
90 button1.position.1 += mouse.delta_position().1 * 5.0;
91 }
92 _ => {
93 text.set_text("hello");
94 }
95 }
96
97 match *button2.left() {
98 ButtonState::Pressed(_x, _y) => {
99 knob_light.rotation += mouse.delta_position().1 * 360.0;
100 }
101 _ => (),
102 }
103 match *button2.right() {
104 ButtonState::Pressed(_x, _y) => {
105 knob_light.rotation += mouse.delta_position().1 * 360.0 * 2.0;
106 }
107 _ => (),
108 }
109
110 text.draw(target, system);
111 knob_base.draw(target, system);
112 knob_light.draw(target, system);
113 });
114 }
115}Sourcepub fn rotation(self, value: f32) -> Self
pub fn rotation(self, value: f32) -> Self
Examples found in repository?
examples/hello.rs (line 53)
15fn main() {
16 let display = glutin::WindowBuilder::new()
17 .with_dimensions(640, 640)
18 .with_vsync()
19 .build_glium()
20 .unwrap();
21
22 let mut ui = Ui::new(&display);
23
24 let font =
25 FontTexture::new(&display, FONT_RAW, 50, FontTexture::ascii_character_list()).unwrap();
26
27 let text_display = ui.build_text_display(&font, "hello");
28
29 let mut text = UiTextBuilder::default()
30 .position((0.1, 0.1))
31 .size((0.15, 0.1))
32 .text(text_display)
33 .color((0.1, 0.1, 0.1, 1.0))
34 .build()
35 .unwrap();
36
37 let mut button1 = UiButtonBuilder::default()
38 .position((0.1, 0.1))
39 .size((0.15, 0.1))
40 .build()
41 .unwrap();
42
43 let mut button2 = UiButtonBuilder::default()
44 .position((0.5, 0.5))
45 .size((0.3, 0.3))
46 .build()
47 .unwrap();
48
49 let texture = SimpleTexture::from(&KNOB_BASE_WHITE_RAW, ImageFormat::PNG, &display).unwrap();
50 let knob_base = UiTextureBuilder::default()
51 .position((0.5, 0.5))
52 .size((0.3, 0.3))
53 .rotation(0.0)
54 .texture(&texture)
55 .build()
56 .unwrap();
57
58 let texture = SimpleTexture::from(&KNOB_LIGHT_RAW, ImageFormat::PNG, &display).unwrap();
59 let mut knob_light = UiTextureBuilder::default()
60 .position((0.5, 0.5))
61 .size((0.3, 0.3))
62 .rotation(0.0)
63 .texture(&texture)
64 .build()
65 .unwrap();
66
67 loop {
68 ui.update(|target, mouse, system| {
69 button1.update(&mouse);
70 button2.update(&mouse);
71
72 target.clear_color(0.4, 0.4, 0.4, 1.0);
73
74 match *button1.left() {
75 ButtonState::Pressed(_x, _y) => {
76 text.set_text("world");
77 text.color.0 += mouse.delta_position().0 * 2.55;
78 text.color.1 += mouse.delta_position().1 * 2.55;
79 }
80 _ => {
81 text.set_text("hello");
82 }
83 }
84 match *button1.right() {
85 ButtonState::Pressed(_x, _y) => {
86 text.set_text("MOVE!");
87 text.position.0 += mouse.delta_position().0 * 5.0;
88 text.position.1 += mouse.delta_position().1 * 5.0;
89 button1.position.0 += mouse.delta_position().0 * 5.0;
90 button1.position.1 += mouse.delta_position().1 * 5.0;
91 }
92 _ => {
93 text.set_text("hello");
94 }
95 }
96
97 match *button2.left() {
98 ButtonState::Pressed(_x, _y) => {
99 knob_light.rotation += mouse.delta_position().1 * 360.0;
100 }
101 _ => (),
102 }
103 match *button2.right() {
104 ButtonState::Pressed(_x, _y) => {
105 knob_light.rotation += mouse.delta_position().1 * 360.0 * 2.0;
106 }
107 _ => (),
108 }
109
110 text.draw(target, system);
111 knob_base.draw(target, system);
112 knob_light.draw(target, system);
113 });
114 }
115}Sourcepub fn texture(self, value: &'a SimpleTexture) -> Self
pub fn texture(self, value: &'a SimpleTexture) -> Self
Examples found in repository?
examples/hello.rs (line 54)
15fn main() {
16 let display = glutin::WindowBuilder::new()
17 .with_dimensions(640, 640)
18 .with_vsync()
19 .build_glium()
20 .unwrap();
21
22 let mut ui = Ui::new(&display);
23
24 let font =
25 FontTexture::new(&display, FONT_RAW, 50, FontTexture::ascii_character_list()).unwrap();
26
27 let text_display = ui.build_text_display(&font, "hello");
28
29 let mut text = UiTextBuilder::default()
30 .position((0.1, 0.1))
31 .size((0.15, 0.1))
32 .text(text_display)
33 .color((0.1, 0.1, 0.1, 1.0))
34 .build()
35 .unwrap();
36
37 let mut button1 = UiButtonBuilder::default()
38 .position((0.1, 0.1))
39 .size((0.15, 0.1))
40 .build()
41 .unwrap();
42
43 let mut button2 = UiButtonBuilder::default()
44 .position((0.5, 0.5))
45 .size((0.3, 0.3))
46 .build()
47 .unwrap();
48
49 let texture = SimpleTexture::from(&KNOB_BASE_WHITE_RAW, ImageFormat::PNG, &display).unwrap();
50 let knob_base = UiTextureBuilder::default()
51 .position((0.5, 0.5))
52 .size((0.3, 0.3))
53 .rotation(0.0)
54 .texture(&texture)
55 .build()
56 .unwrap();
57
58 let texture = SimpleTexture::from(&KNOB_LIGHT_RAW, ImageFormat::PNG, &display).unwrap();
59 let mut knob_light = UiTextureBuilder::default()
60 .position((0.5, 0.5))
61 .size((0.3, 0.3))
62 .rotation(0.0)
63 .texture(&texture)
64 .build()
65 .unwrap();
66
67 loop {
68 ui.update(|target, mouse, system| {
69 button1.update(&mouse);
70 button2.update(&mouse);
71
72 target.clear_color(0.4, 0.4, 0.4, 1.0);
73
74 match *button1.left() {
75 ButtonState::Pressed(_x, _y) => {
76 text.set_text("world");
77 text.color.0 += mouse.delta_position().0 * 2.55;
78 text.color.1 += mouse.delta_position().1 * 2.55;
79 }
80 _ => {
81 text.set_text("hello");
82 }
83 }
84 match *button1.right() {
85 ButtonState::Pressed(_x, _y) => {
86 text.set_text("MOVE!");
87 text.position.0 += mouse.delta_position().0 * 5.0;
88 text.position.1 += mouse.delta_position().1 * 5.0;
89 button1.position.0 += mouse.delta_position().0 * 5.0;
90 button1.position.1 += mouse.delta_position().1 * 5.0;
91 }
92 _ => {
93 text.set_text("hello");
94 }
95 }
96
97 match *button2.left() {
98 ButtonState::Pressed(_x, _y) => {
99 knob_light.rotation += mouse.delta_position().1 * 360.0;
100 }
101 _ => (),
102 }
103 match *button2.right() {
104 ButtonState::Pressed(_x, _y) => {
105 knob_light.rotation += mouse.delta_position().1 * 360.0 * 2.0;
106 }
107 _ => (),
108 }
109
110 text.draw(target, system);
111 knob_base.draw(target, system);
112 knob_light.draw(target, system);
113 });
114 }
115}Sourcepub fn build(self) -> Result<UiTexture<'a>, String>
pub fn build(self) -> Result<UiTexture<'a>, String>
Examples found in repository?
examples/hello.rs (line 55)
15fn main() {
16 let display = glutin::WindowBuilder::new()
17 .with_dimensions(640, 640)
18 .with_vsync()
19 .build_glium()
20 .unwrap();
21
22 let mut ui = Ui::new(&display);
23
24 let font =
25 FontTexture::new(&display, FONT_RAW, 50, FontTexture::ascii_character_list()).unwrap();
26
27 let text_display = ui.build_text_display(&font, "hello");
28
29 let mut text = UiTextBuilder::default()
30 .position((0.1, 0.1))
31 .size((0.15, 0.1))
32 .text(text_display)
33 .color((0.1, 0.1, 0.1, 1.0))
34 .build()
35 .unwrap();
36
37 let mut button1 = UiButtonBuilder::default()
38 .position((0.1, 0.1))
39 .size((0.15, 0.1))
40 .build()
41 .unwrap();
42
43 let mut button2 = UiButtonBuilder::default()
44 .position((0.5, 0.5))
45 .size((0.3, 0.3))
46 .build()
47 .unwrap();
48
49 let texture = SimpleTexture::from(&KNOB_BASE_WHITE_RAW, ImageFormat::PNG, &display).unwrap();
50 let knob_base = UiTextureBuilder::default()
51 .position((0.5, 0.5))
52 .size((0.3, 0.3))
53 .rotation(0.0)
54 .texture(&texture)
55 .build()
56 .unwrap();
57
58 let texture = SimpleTexture::from(&KNOB_LIGHT_RAW, ImageFormat::PNG, &display).unwrap();
59 let mut knob_light = UiTextureBuilder::default()
60 .position((0.5, 0.5))
61 .size((0.3, 0.3))
62 .rotation(0.0)
63 .texture(&texture)
64 .build()
65 .unwrap();
66
67 loop {
68 ui.update(|target, mouse, system| {
69 button1.update(&mouse);
70 button2.update(&mouse);
71
72 target.clear_color(0.4, 0.4, 0.4, 1.0);
73
74 match *button1.left() {
75 ButtonState::Pressed(_x, _y) => {
76 text.set_text("world");
77 text.color.0 += mouse.delta_position().0 * 2.55;
78 text.color.1 += mouse.delta_position().1 * 2.55;
79 }
80 _ => {
81 text.set_text("hello");
82 }
83 }
84 match *button1.right() {
85 ButtonState::Pressed(_x, _y) => {
86 text.set_text("MOVE!");
87 text.position.0 += mouse.delta_position().0 * 5.0;
88 text.position.1 += mouse.delta_position().1 * 5.0;
89 button1.position.0 += mouse.delta_position().0 * 5.0;
90 button1.position.1 += mouse.delta_position().1 * 5.0;
91 }
92 _ => {
93 text.set_text("hello");
94 }
95 }
96
97 match *button2.left() {
98 ButtonState::Pressed(_x, _y) => {
99 knob_light.rotation += mouse.delta_position().1 * 360.0;
100 }
101 _ => (),
102 }
103 match *button2.right() {
104 ButtonState::Pressed(_x, _y) => {
105 knob_light.rotation += mouse.delta_position().1 * 360.0 * 2.0;
106 }
107 _ => (),
108 }
109
110 text.draw(target, system);
111 knob_base.draw(target, system);
112 knob_light.draw(target, system);
113 });
114 }
115}Trait Implementations§
Source§impl<'a> Default for UiTextureBuilder<'a>
impl<'a> Default for UiTextureBuilder<'a>
Source§fn default() -> UiTextureBuilder<'a>
fn default() -> UiTextureBuilder<'a>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<'a> Freeze for UiTextureBuilder<'a>
impl<'a> !RefUnwindSafe for UiTextureBuilder<'a>
impl<'a> !Send for UiTextureBuilder<'a>
impl<'a> !Sync for UiTextureBuilder<'a>
impl<'a> Unpin for UiTextureBuilder<'a>
impl<'a> !UnwindSafe for UiTextureBuilder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> SetParameter for T
impl<T> SetParameter for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.