-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
952 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
luda-editor/new-client/src/episode_editor/properties_panel.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
use super::scene_sprite_editor::SceneSpriteEditor; | ||
use luda_rpc::{AssetDoc, EpisodeEditAction, Scene}; | ||
use namui::*; | ||
use namui_prebuilt::{button, table::*}; | ||
use std::collections::HashMap; | ||
|
||
static PROPERTIES_PANEL_TAB_ATOM: Atom<PropertiesPanelTab> = Atom::uninitialized(); | ||
|
||
pub struct PropertiesPanel<'a> { | ||
pub wh: Wh<Px>, | ||
pub scene: &'a Scene, | ||
pub edit_episode: &'a dyn Fn(EpisodeEditAction), | ||
pub asset_docs: Sig<'a, HashMap<String, AssetDoc>>, | ||
} | ||
impl Component for PropertiesPanel<'_> { | ||
fn render(self, ctx: &RenderCtx) { | ||
let Self { | ||
wh, | ||
scene, | ||
asset_docs, | ||
edit_episode, | ||
} = self; | ||
|
||
let (properties_panel_tab, set_properties_panel_tab) = | ||
ctx.init_atom(&PROPERTIES_PANEL_TAB_ATOM, || PropertiesPanelTab::Standing); | ||
|
||
let update_scene = &|scene: Scene| { | ||
edit_episode(EpisodeEditAction::UpdateScene { scene }); | ||
}; | ||
|
||
ctx.compose(|ctx| { | ||
vertical([ | ||
fixed( | ||
48.px(), | ||
horizontal([ | ||
render_tab_button( | ||
"스탠딩", | ||
matches!(*properties_panel_tab, PropertiesPanelTab::Standing), | ||
|| { | ||
set_properties_panel_tab.set(PropertiesPanelTab::Standing); | ||
}, | ||
), | ||
render_tab_button( | ||
"배경", | ||
matches!(*properties_panel_tab, PropertiesPanelTab::Background), | ||
|| { | ||
set_properties_panel_tab.set(PropertiesPanelTab::Background); | ||
}, | ||
), | ||
render_tab_button( | ||
"오디오", | ||
matches!(*properties_panel_tab, PropertiesPanelTab::Audio), | ||
|| { | ||
set_properties_panel_tab.set(PropertiesPanelTab::Audio); | ||
}, | ||
), | ||
]), | ||
), | ||
ratio(1, |wh, ctx| match properties_panel_tab.as_ref() { | ||
PropertiesPanelTab::Standing => { | ||
ctx.add(SceneSpriteEditor { | ||
wh, | ||
scene, | ||
update_scene, | ||
asset_docs, | ||
}); | ||
} | ||
PropertiesPanelTab::Background => {} | ||
PropertiesPanelTab::Audio => {} | ||
}), | ||
])(wh, ctx); | ||
}); | ||
} | ||
} | ||
|
||
pub enum PropertiesPanelTab { | ||
Standing, | ||
Background, | ||
Audio, | ||
} | ||
|
||
fn render_tab_button<'a>( | ||
text: &'a str, | ||
selected: bool, | ||
on_click: impl 'a + FnOnce(), | ||
) -> TableCell<'a> { | ||
TableCell::Some { | ||
unit: Unit::Ratio(1.0), | ||
render: Box::new(move |_direction, wh, ctx| { | ||
let (text_color, fill_color) = match selected { | ||
true => (Color::WHITE, Color::BLUE), | ||
false => (Color::BLUE, Color::TRANSPARENT), | ||
}; | ||
|
||
ctx.add(button::TextButton { | ||
rect: wh.to_rect(), | ||
text: text.to_string(), | ||
text_color, | ||
stroke_color: Color::BLUE, | ||
stroke_width: 1.px(), | ||
fill_color, | ||
mouse_buttons: vec![MouseButton::Left], | ||
on_mouse_up_in: move |_| { | ||
on_click(); | ||
}, | ||
}); | ||
}), | ||
need_clip: true, | ||
} | ||
} |
Oops, something went wrong.