pub struct Group { /* private fields */ }
Implementations§
source§impl Group
impl Group
sourcepub fn new(id: Id, size: Vec2) -> Group
pub fn new(id: Id, size: Vec2) -> Group
Examples found in repository?
examples/events.rs (line 17)
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
async fn main() {
loop {
clear_background(WHITE);
root_ui().window(hash!(), Vec2::new(20., 20.), Vec2::new(450., 200.), |ui| {
let (mouse_x, mouse_y) = mouse_position();
ui.label(None, &format!("Mouse position: {} {}", mouse_x, mouse_y));
let (mouse_wheel_x, mouse_wheel_y) = mouse_wheel();
ui.label(None, &format!("Mouse wheel x: {}", mouse_wheel_x));
ui.label(None, &format!("Mouse wheel y: {}", mouse_wheel_y));
widgets::Group::new(hash!(), Vec2::new(200., 90.))
.position(Vec2::new(240., 0.))
.ui(ui, |ui| {
ui.label(None, "Pressed kbd keys");
if let Some(key) = get_last_key_pressed() {
ui.label(None, &format!("{:?}", key))
}
});
widgets::Group::new(hash!(), Vec2::new(200., 90.))
.position(Vec2::new(240., 92.))
.ui(ui, |ui| {
ui.label(None, "Pressed mouse keys");
if is_mouse_button_down(MouseButton::Left) {
ui.label(None, "Left");
}
if is_mouse_button_down(MouseButton::Right) {
ui.label(None, "Right");
}
if is_mouse_button_down(MouseButton::Middle) {
ui.label(None, "Middle");
}
});
});
next_frame().await;
}
}
More examples
examples/ui.rs (line 57)
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
fn slots(&mut self, ui: &mut Ui) {
let item_dragging = &mut self.item_dragging;
let fit_command = &mut self.fit_command;
for (label, slot) in self.slots.iter_mut() {
Group::new(hash!("grp", slot.id, &label), Vec2::new(210., 55.)).ui(ui, |ui| {
let drag = Group::new(slot.id, Vec2::new(50., 50.))
// slot without item is not draggable
.draggable(slot.item.is_some())
// but could be a target of drag
.hoverable(*item_dragging)
// and is highlighted with other color when some item is dragging
.highlight(*item_dragging)
.ui(ui, |ui| {
if let Some(ref item) = slot.item {
ui.label(Vec2::new(5., 10.), &item);
}
});
match drag {
// there is some item in this slot and it was dragged to another slot
Drag::Dropped(_, Some(id)) if slot.item.is_some() => {
*fit_command = Some(FittingCommand::Refit {
target_slot: id,
origin_slot: slot.id,
});
}
// there is some item in this slot and it was dragged out - unfit it
Drag::Dropped(_, None) if slot.item.is_some() => {
*fit_command = Some(FittingCommand::Unfit {
target_slot: slot.id,
});
}
// there is no item in this slot
// this is impossible - slots without items are non-draggable
Drag::Dropped(_, _) => unreachable!(),
Drag::Dragging(pos, id) => {
debug!("slots: pos: {:?}, id {:?}", pos, id);
*item_dragging = true;
}
Drag::No => {}
}
ui.label(Vec2::new(60., 20.), label);
});
}
}
fn inventory(&mut self, ui: &mut Ui) {
let item_dragging = &mut self.item_dragging;
for (n, item) in self.inventory.iter().enumerate() {
let drag = Group::new(hash!("inventory", n), Vec2::new(50., 50.))
.draggable(true)
.ui(ui, |ui| {
ui.label(Vec2::new(5., 10.), &item);
});
match drag {
Drag::Dropped(_, Some(id)) => {
self.fit_command = Some(FittingCommand::Fit {
target_slot: id,
item: item.clone(),
});
*item_dragging = false;
}
Drag::Dropped(_, _) => {
*item_dragging = false;
}
Drag::Dragging(pos, id) => {
debug!("inventory: pos: {:?}, id {:?}", pos, id);
*item_dragging = true;
}
_ => {}
}
}
}
fn set_item(&mut self, id: u64, item: Option<String>) {
if let Some(slot) = self.slots.iter_mut().find(|(_, slot)| slot.id == id) {
slot.1.item = item;
}
}
}
#[macroquad::main("UI showcase")]
async fn main() {
let mut data = Data::new();
let mut data0 = String::new();
let mut data1 = String::new();
let mut text0 = String::new();
let mut text1 = String::new();
let mut number0 = 0.;
let mut number1 = 0.;
let texture: Texture2D = load_texture("examples/ferris.png").await.unwrap();
loop {
clear_background(WHITE);
widgets::Window::new(hash!(), vec2(400., 200.), vec2(320., 400.))
.label("Shop")
.titlebar(true)
.ui(&mut *root_ui(), |ui| {
for i in 0..30 {
Group::new(hash!("shop", i), Vec2::new(300., 80.)).ui(ui, |ui| {
ui.label(Vec2::new(10., 10.), &format!("Item N {}", i));
ui.label(Vec2::new(260., 40.), "10/10");
ui.label(Vec2::new(200., 58.), &format!("{} kr", 800));
if ui.button(Vec2::new(260., 55.), "buy") {
data.inventory.push(format!("Item {}", i));
}
});
}
});
widgets::Window::new(hash!(), vec2(100., 220.), vec2(542., 430.))
.label("Fitting window")
.titlebar(true)
.ui(&mut *root_ui(), |ui| {
Group::new(hash!(), Vec2::new(230., 400.)).ui(ui, |ui| {
data.slots(ui);
});
Group::new(hash!(), Vec2::new(280., 400.)).ui(ui, |ui| {
data.inventory(ui);
});
});
widgets::Window::new(hash!(), vec2(470., 50.), vec2(300., 300.))
.label("Megaui Showcase Window")
.ui(&mut *root_ui(), |ui| {
ui.tree_node(hash!(), "input", |ui| {
ui.label(None, "Some random text");
if ui.button(None, "click me") {
println!("hi");
}
ui.separator();
ui.label(None, "Some other random text");
if ui.button(None, "other button") {
println!("hi2");
}
ui.separator();
ui.input_text(hash!(), "<- input text 1", &mut data0);
ui.input_text(hash!(), "<- input text 2", &mut data1);
ui.label(
None,
&format!("Text entered: \"{}\" and \"{}\"", data0, data1),
);
ui.separator();
});
ui.tree_node(hash!(), "buttons", |ui| {
widgets::Button::new(texture.clone())
.size(vec2(120., 70.))
.ui(ui);
ui.same_line(0.);
widgets::Button::new("Button").size(vec2(120., 70.)).ui(ui);
widgets::Button::new("Button").size(vec2(120., 70.)).ui(ui);
ui.same_line(0.);
widgets::Button::new(texture.clone())
.size(vec2(120., 70.))
.ui(ui);
});
ui.tree_node(hash!(), "sliders", |ui| {
ui.slider(hash!(), "[-10 .. 10]", -10f32..10f32, &mut number0);
ui.slider(hash!(), "[0 .. 100]", 0f32..100f32, &mut number1);
});
ui.tree_node(hash!(), "editbox 1", |ui| {
ui.label(None, "This is editbox!");
ui.editbox(hash!(), vec2(285., 165.), &mut text0);
});
ui.tree_node(hash!(), "editbox 2", |ui| {
ui.label(None, "This is editbox!");
ui.editbox(hash!(), vec2(285., 165.), &mut text1);
});
});
match data.fit_command.take() {
Some(FittingCommand::Unfit { target_slot }) => data.set_item(target_slot, None),
Some(FittingCommand::Fit { target_slot, item }) => {
data.set_item(target_slot, Some(item));
}
Some(FittingCommand::Refit {
target_slot,
origin_slot,
}) => {
let origin_item = data
.slots
.iter()
.find_map(|(_, slot)| {
if slot.id == origin_slot {
Some(slot.item.clone())
} else {
None
}
})
.flatten();
data.set_item(target_slot, origin_item);
data.set_item(origin_slot, None);
}
None => {}
};
next_frame().await;
}
}
sourcepub fn position(self, position: Vec2) -> Group
pub fn position(self, position: Vec2) -> Group
Examples found in repository?
examples/events.rs (line 18)
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
async fn main() {
loop {
clear_background(WHITE);
root_ui().window(hash!(), Vec2::new(20., 20.), Vec2::new(450., 200.), |ui| {
let (mouse_x, mouse_y) = mouse_position();
ui.label(None, &format!("Mouse position: {} {}", mouse_x, mouse_y));
let (mouse_wheel_x, mouse_wheel_y) = mouse_wheel();
ui.label(None, &format!("Mouse wheel x: {}", mouse_wheel_x));
ui.label(None, &format!("Mouse wheel y: {}", mouse_wheel_y));
widgets::Group::new(hash!(), Vec2::new(200., 90.))
.position(Vec2::new(240., 0.))
.ui(ui, |ui| {
ui.label(None, "Pressed kbd keys");
if let Some(key) = get_last_key_pressed() {
ui.label(None, &format!("{:?}", key))
}
});
widgets::Group::new(hash!(), Vec2::new(200., 90.))
.position(Vec2::new(240., 92.))
.ui(ui, |ui| {
ui.label(None, "Pressed mouse keys");
if is_mouse_button_down(MouseButton::Left) {
ui.label(None, "Left");
}
if is_mouse_button_down(MouseButton::Right) {
ui.label(None, "Right");
}
if is_mouse_button_down(MouseButton::Middle) {
ui.label(None, "Middle");
}
});
});
next_frame().await;
}
}
pub fn layout(self, layout: Layout) -> Group
sourcepub fn draggable(self, draggable: bool) -> Group
pub fn draggable(self, draggable: bool) -> Group
Examples found in repository?
examples/ui.rs (line 60)
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
fn slots(&mut self, ui: &mut Ui) {
let item_dragging = &mut self.item_dragging;
let fit_command = &mut self.fit_command;
for (label, slot) in self.slots.iter_mut() {
Group::new(hash!("grp", slot.id, &label), Vec2::new(210., 55.)).ui(ui, |ui| {
let drag = Group::new(slot.id, Vec2::new(50., 50.))
// slot without item is not draggable
.draggable(slot.item.is_some())
// but could be a target of drag
.hoverable(*item_dragging)
// and is highlighted with other color when some item is dragging
.highlight(*item_dragging)
.ui(ui, |ui| {
if let Some(ref item) = slot.item {
ui.label(Vec2::new(5., 10.), &item);
}
});
match drag {
// there is some item in this slot and it was dragged to another slot
Drag::Dropped(_, Some(id)) if slot.item.is_some() => {
*fit_command = Some(FittingCommand::Refit {
target_slot: id,
origin_slot: slot.id,
});
}
// there is some item in this slot and it was dragged out - unfit it
Drag::Dropped(_, None) if slot.item.is_some() => {
*fit_command = Some(FittingCommand::Unfit {
target_slot: slot.id,
});
}
// there is no item in this slot
// this is impossible - slots without items are non-draggable
Drag::Dropped(_, _) => unreachable!(),
Drag::Dragging(pos, id) => {
debug!("slots: pos: {:?}, id {:?}", pos, id);
*item_dragging = true;
}
Drag::No => {}
}
ui.label(Vec2::new(60., 20.), label);
});
}
}
fn inventory(&mut self, ui: &mut Ui) {
let item_dragging = &mut self.item_dragging;
for (n, item) in self.inventory.iter().enumerate() {
let drag = Group::new(hash!("inventory", n), Vec2::new(50., 50.))
.draggable(true)
.ui(ui, |ui| {
ui.label(Vec2::new(5., 10.), &item);
});
match drag {
Drag::Dropped(_, Some(id)) => {
self.fit_command = Some(FittingCommand::Fit {
target_slot: id,
item: item.clone(),
});
*item_dragging = false;
}
Drag::Dropped(_, _) => {
*item_dragging = false;
}
Drag::Dragging(pos, id) => {
debug!("inventory: pos: {:?}, id {:?}", pos, id);
*item_dragging = true;
}
_ => {}
}
}
}
sourcepub fn hoverable(self, hoverable: bool) -> Group
pub fn hoverable(self, hoverable: bool) -> Group
Examples found in repository?
examples/ui.rs (line 62)
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
fn slots(&mut self, ui: &mut Ui) {
let item_dragging = &mut self.item_dragging;
let fit_command = &mut self.fit_command;
for (label, slot) in self.slots.iter_mut() {
Group::new(hash!("grp", slot.id, &label), Vec2::new(210., 55.)).ui(ui, |ui| {
let drag = Group::new(slot.id, Vec2::new(50., 50.))
// slot without item is not draggable
.draggable(slot.item.is_some())
// but could be a target of drag
.hoverable(*item_dragging)
// and is highlighted with other color when some item is dragging
.highlight(*item_dragging)
.ui(ui, |ui| {
if let Some(ref item) = slot.item {
ui.label(Vec2::new(5., 10.), &item);
}
});
match drag {
// there is some item in this slot and it was dragged to another slot
Drag::Dropped(_, Some(id)) if slot.item.is_some() => {
*fit_command = Some(FittingCommand::Refit {
target_slot: id,
origin_slot: slot.id,
});
}
// there is some item in this slot and it was dragged out - unfit it
Drag::Dropped(_, None) if slot.item.is_some() => {
*fit_command = Some(FittingCommand::Unfit {
target_slot: slot.id,
});
}
// there is no item in this slot
// this is impossible - slots without items are non-draggable
Drag::Dropped(_, _) => unreachable!(),
Drag::Dragging(pos, id) => {
debug!("slots: pos: {:?}, id {:?}", pos, id);
*item_dragging = true;
}
Drag::No => {}
}
ui.label(Vec2::new(60., 20.), label);
});
}
}
sourcepub fn highlight(self, highlight: bool) -> Group
pub fn highlight(self, highlight: bool) -> Group
Examples found in repository?
examples/ui.rs (line 64)
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
fn slots(&mut self, ui: &mut Ui) {
let item_dragging = &mut self.item_dragging;
let fit_command = &mut self.fit_command;
for (label, slot) in self.slots.iter_mut() {
Group::new(hash!("grp", slot.id, &label), Vec2::new(210., 55.)).ui(ui, |ui| {
let drag = Group::new(slot.id, Vec2::new(50., 50.))
// slot without item is not draggable
.draggable(slot.item.is_some())
// but could be a target of drag
.hoverable(*item_dragging)
// and is highlighted with other color when some item is dragging
.highlight(*item_dragging)
.ui(ui, |ui| {
if let Some(ref item) = slot.item {
ui.label(Vec2::new(5., 10.), &item);
}
});
match drag {
// there is some item in this slot and it was dragged to another slot
Drag::Dropped(_, Some(id)) if slot.item.is_some() => {
*fit_command = Some(FittingCommand::Refit {
target_slot: id,
origin_slot: slot.id,
});
}
// there is some item in this slot and it was dragged out - unfit it
Drag::Dropped(_, None) if slot.item.is_some() => {
*fit_command = Some(FittingCommand::Unfit {
target_slot: slot.id,
});
}
// there is no item in this slot
// this is impossible - slots without items are non-draggable
Drag::Dropped(_, _) => unreachable!(),
Drag::Dragging(pos, id) => {
debug!("slots: pos: {:?}, id {:?}", pos, id);
*item_dragging = true;
}
Drag::No => {}
}
ui.label(Vec2::new(60., 20.), label);
});
}
}
sourcepub fn ui<F: FnOnce(&mut Ui)>(self, ui: &mut Ui, f: F) -> Drag
pub fn ui<F: FnOnce(&mut Ui)>(self, ui: &mut Ui, f: F) -> Drag
Examples found in repository?
examples/events.rs (lines 19-25)
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
async fn main() {
loop {
clear_background(WHITE);
root_ui().window(hash!(), Vec2::new(20., 20.), Vec2::new(450., 200.), |ui| {
let (mouse_x, mouse_y) = mouse_position();
ui.label(None, &format!("Mouse position: {} {}", mouse_x, mouse_y));
let (mouse_wheel_x, mouse_wheel_y) = mouse_wheel();
ui.label(None, &format!("Mouse wheel x: {}", mouse_wheel_x));
ui.label(None, &format!("Mouse wheel y: {}", mouse_wheel_y));
widgets::Group::new(hash!(), Vec2::new(200., 90.))
.position(Vec2::new(240., 0.))
.ui(ui, |ui| {
ui.label(None, "Pressed kbd keys");
if let Some(key) = get_last_key_pressed() {
ui.label(None, &format!("{:?}", key))
}
});
widgets::Group::new(hash!(), Vec2::new(200., 90.))
.position(Vec2::new(240., 92.))
.ui(ui, |ui| {
ui.label(None, "Pressed mouse keys");
if is_mouse_button_down(MouseButton::Left) {
ui.label(None, "Left");
}
if is_mouse_button_down(MouseButton::Right) {
ui.label(None, "Right");
}
if is_mouse_button_down(MouseButton::Middle) {
ui.label(None, "Middle");
}
});
});
next_frame().await;
}
}
More examples
examples/ui.rs (lines 57-95)
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
fn slots(&mut self, ui: &mut Ui) {
let item_dragging = &mut self.item_dragging;
let fit_command = &mut self.fit_command;
for (label, slot) in self.slots.iter_mut() {
Group::new(hash!("grp", slot.id, &label), Vec2::new(210., 55.)).ui(ui, |ui| {
let drag = Group::new(slot.id, Vec2::new(50., 50.))
// slot without item is not draggable
.draggable(slot.item.is_some())
// but could be a target of drag
.hoverable(*item_dragging)
// and is highlighted with other color when some item is dragging
.highlight(*item_dragging)
.ui(ui, |ui| {
if let Some(ref item) = slot.item {
ui.label(Vec2::new(5., 10.), &item);
}
});
match drag {
// there is some item in this slot and it was dragged to another slot
Drag::Dropped(_, Some(id)) if slot.item.is_some() => {
*fit_command = Some(FittingCommand::Refit {
target_slot: id,
origin_slot: slot.id,
});
}
// there is some item in this slot and it was dragged out - unfit it
Drag::Dropped(_, None) if slot.item.is_some() => {
*fit_command = Some(FittingCommand::Unfit {
target_slot: slot.id,
});
}
// there is no item in this slot
// this is impossible - slots without items are non-draggable
Drag::Dropped(_, _) => unreachable!(),
Drag::Dragging(pos, id) => {
debug!("slots: pos: {:?}, id {:?}", pos, id);
*item_dragging = true;
}
Drag::No => {}
}
ui.label(Vec2::new(60., 20.), label);
});
}
}
fn inventory(&mut self, ui: &mut Ui) {
let item_dragging = &mut self.item_dragging;
for (n, item) in self.inventory.iter().enumerate() {
let drag = Group::new(hash!("inventory", n), Vec2::new(50., 50.))
.draggable(true)
.ui(ui, |ui| {
ui.label(Vec2::new(5., 10.), &item);
});
match drag {
Drag::Dropped(_, Some(id)) => {
self.fit_command = Some(FittingCommand::Fit {
target_slot: id,
item: item.clone(),
});
*item_dragging = false;
}
Drag::Dropped(_, _) => {
*item_dragging = false;
}
Drag::Dragging(pos, id) => {
debug!("inventory: pos: {:?}, id {:?}", pos, id);
*item_dragging = true;
}
_ => {}
}
}
}
fn set_item(&mut self, id: u64, item: Option<String>) {
if let Some(slot) = self.slots.iter_mut().find(|(_, slot)| slot.id == id) {
slot.1.item = item;
}
}
}
#[macroquad::main("UI showcase")]
async fn main() {
let mut data = Data::new();
let mut data0 = String::new();
let mut data1 = String::new();
let mut text0 = String::new();
let mut text1 = String::new();
let mut number0 = 0.;
let mut number1 = 0.;
let texture: Texture2D = load_texture("examples/ferris.png").await.unwrap();
loop {
clear_background(WHITE);
widgets::Window::new(hash!(), vec2(400., 200.), vec2(320., 400.))
.label("Shop")
.titlebar(true)
.ui(&mut *root_ui(), |ui| {
for i in 0..30 {
Group::new(hash!("shop", i), Vec2::new(300., 80.)).ui(ui, |ui| {
ui.label(Vec2::new(10., 10.), &format!("Item N {}", i));
ui.label(Vec2::new(260., 40.), "10/10");
ui.label(Vec2::new(200., 58.), &format!("{} kr", 800));
if ui.button(Vec2::new(260., 55.), "buy") {
data.inventory.push(format!("Item {}", i));
}
});
}
});
widgets::Window::new(hash!(), vec2(100., 220.), vec2(542., 430.))
.label("Fitting window")
.titlebar(true)
.ui(&mut *root_ui(), |ui| {
Group::new(hash!(), Vec2::new(230., 400.)).ui(ui, |ui| {
data.slots(ui);
});
Group::new(hash!(), Vec2::new(280., 400.)).ui(ui, |ui| {
data.inventory(ui);
});
});
widgets::Window::new(hash!(), vec2(470., 50.), vec2(300., 300.))
.label("Megaui Showcase Window")
.ui(&mut *root_ui(), |ui| {
ui.tree_node(hash!(), "input", |ui| {
ui.label(None, "Some random text");
if ui.button(None, "click me") {
println!("hi");
}
ui.separator();
ui.label(None, "Some other random text");
if ui.button(None, "other button") {
println!("hi2");
}
ui.separator();
ui.input_text(hash!(), "<- input text 1", &mut data0);
ui.input_text(hash!(), "<- input text 2", &mut data1);
ui.label(
None,
&format!("Text entered: \"{}\" and \"{}\"", data0, data1),
);
ui.separator();
});
ui.tree_node(hash!(), "buttons", |ui| {
widgets::Button::new(texture.clone())
.size(vec2(120., 70.))
.ui(ui);
ui.same_line(0.);
widgets::Button::new("Button").size(vec2(120., 70.)).ui(ui);
widgets::Button::new("Button").size(vec2(120., 70.)).ui(ui);
ui.same_line(0.);
widgets::Button::new(texture.clone())
.size(vec2(120., 70.))
.ui(ui);
});
ui.tree_node(hash!(), "sliders", |ui| {
ui.slider(hash!(), "[-10 .. 10]", -10f32..10f32, &mut number0);
ui.slider(hash!(), "[0 .. 100]", 0f32..100f32, &mut number1);
});
ui.tree_node(hash!(), "editbox 1", |ui| {
ui.label(None, "This is editbox!");
ui.editbox(hash!(), vec2(285., 165.), &mut text0);
});
ui.tree_node(hash!(), "editbox 2", |ui| {
ui.label(None, "This is editbox!");
ui.editbox(hash!(), vec2(285., 165.), &mut text1);
});
});
match data.fit_command.take() {
Some(FittingCommand::Unfit { target_slot }) => data.set_item(target_slot, None),
Some(FittingCommand::Fit { target_slot, item }) => {
data.set_item(target_slot, Some(item));
}
Some(FittingCommand::Refit {
target_slot,
origin_slot,
}) => {
let origin_item = data
.slots
.iter()
.find_map(|(_, slot)| {
if slot.id == origin_slot {
Some(slot.item.clone())
} else {
None
}
})
.flatten();
data.set_item(target_slot, origin_item);
data.set_item(origin_slot, None);
}
None => {}
};
next_frame().await;
}
}
pub fn begin(self, ui: &mut Ui) -> GroupToken
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Group
impl Send for Group
impl Sync for Group
impl Unpin for Group
impl UnwindSafe for Group
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