Skip to content

Commit

Permalink
Add go back button
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfoodK committed Jul 14, 2024
1 parent 194c8a9 commit 8647dae
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion jigcle/src/playground.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::{
};
use file::bundle;
use namui::*;
use namui_prebuilt::button;
use skia::load_image_from_resource_location;
use std::ops::Deref;

Expand Down Expand Up @@ -57,7 +58,7 @@ playground를 줄이니까 꽤 괜찮음.
*/
impl Component for Playground {
fn render(self, ctx: &RenderCtx) {
let (playing_level, _set_playing_level) = ctx.atom(&PLAYING_LEVEL_ATOM);
let (playing_level, set_playing_level) = ctx.atom(&PLAYING_LEVEL_ATOM);
let (_bgm, set_bgm) = ctx.state(|| None);
let (image, set_image) = ctx.state(|| None);

Expand Down Expand Up @@ -100,6 +101,28 @@ impl Component for Playground {
load_image.abort();
})
});

ctx.add(button::TextButton {
rect: Rect::Xywh {
x: 16.px(),
y: 16.px(),
width: 256.px(),
height: 64.px(),
},
text: "Back",
text_color: Color::WHITE,
stroke_color: Color::WHITE,
stroke_width: 2.px(),
fill_color: Color::grayscale_alpha_f01(0.0, 0.25),
mouse_buttons: vec![MouseButton::Left],
on_mouse_up_in: &|event| {
if !event.is_local_xy_in() {
return;
}
set_playing_level.set(None);
},
});

let Some(sfx7) = sfx7.as_ref() else { return };
let Some(sfx8) = sfx8.as_ref() else { return };

Expand Down

0 comments on commit 8647dae

Please sign in to comment.