Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
farmaazon committed Jul 12, 2021
1 parent 9507553 commit 4c40f96
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 18 deletions.
6 changes: 5 additions & 1 deletion src/rust/ensogl/lib/theme/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,12 @@ define_themes! { [light:0, dark:1]
width = 202.0 , 202.0;
padding = 16.0, 16.0;
height = 421.0, 421.0;
background = application::file_browser::background , application::file_browser::background;
background = Rgba(0.992,0.996,1.0,1.0), Rgba(0.182,0.188,0.196,1.0);
text = widget::list_view::text, widget::list_view::text;
text {
size = 12.0, 12.0;
padding = 6.0 , 6.0 ;
}
bar {
height = 45.0, 45.0;
border_size = 1.0, 1.0;
Expand Down
2 changes: 1 addition & 1 deletion src/rust/ide/src/ide/integration/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl Integration {

let file_browser = &model.view.open_dialog().file_browser;
let project_list = &model.view.open_dialog().project_list;
frp::extend! { network
frp::extend! { TRACE_ALL network
let chosen_project = project_list.chosen_entry.clone_ref();
let file_chosen = file_browser.entry_chosen.clone_ref();
project_chosen <- chosen_project.filter_map(|p| *p);
Expand Down
4 changes: 2 additions & 2 deletions src/rust/ide/view/src/open_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ impl OpenDialog {
width <- all_with3(&project_list_width,&gap_between_panels,&init,
|pw,g,()| *pw + *g + file_browser::WIDTH
);
project_list_x <- all_with(&width,&project_list_width,|w,pw| *w / 2.0 + *pw / 2.0);
project_list_x <- all_with(&width,&project_list_width,|w,pw| - *w / 2.0 + *pw / 2.0);
file_browser_x <- width.map(|w| w / 2.0 - file_browser::WIDTH / 2.0);

eval project_list_x ((x) project_list.set_position_x(*x));
eval file_browser_x ((x) file_browser.set_position_x(*x));
}

init.emit(());
Self {logger,network,project_list,file_browser,display_object,style_watch}
}
}
Expand Down
45 changes: 31 additions & 14 deletions src/rust/ide/view/src/open_dialog/project_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,41 @@ use ensogl_theme::application::project_list as theme;
/// The project entry widget for the [`list_view::ListView`] inside [`ProjectList`].
#[derive(Clone,CloneRef,Debug)]
pub struct Entry {
network : frp::Network,
style_watch : StyleWatchFrp,
label : ensogl_text::Area,
display_object : display::object::Instance,
network : frp::Network,
style_watch : StyleWatchFrp,
label : ensogl_text::Area,
}

impl Entry {
/// Create entry for a project with given name.
pub fn new(app:&Application, name:impl Str) -> Self {
let network = frp::Network::new("ProjectEntry");
let label = app.new_view::<ensogl_text::Area>();
let style_watch = StyleWatchFrp::new(&app.display.scene().style_sheet);
let text_color = style_watch.get_color(theme::text);
let logger = Logger::new("project_list::Entry");
let display_object = display::object::Instance::new(logger);
let network = frp::Network::new("project_list::Entry");
let label = app.new_view::<ensogl_text::Area>();
let style_watch = StyleWatchFrp::new(&app.display.scene().style_sheet);
let text_color = style_watch.get_color(theme::text);
let text_size = style_watch.get_number(theme::text::size);
let text_padding = style_watch.get_number(theme::text::padding);
display_object.add_child(&label);
label.set_default_color(text_color.value());
label.set_position_xy(Vector2(6.0,6.0)); // TODO[ao] Hmmm...
label.set_default_text_size(text::Size(text_size.value()));
label.set_position_xy(Vector2(text_padding.value(), text_size.value() / 2.0));
label.set_content(name.as_ref());
label.remove_from_scene_layer(&app.display.scene().layers.main);
label.add_to_scene_layer(&app.display.scene().layers.panel_text);
frp::extend! { network
eval text_color ((color) label.set_default_color(color));
eval text_color ((color) label.set_default_color(color));
eval text_size ((size) label.set_default_text_size(text::Size(*size)));
eval text_padding ((padding) label.set_position_x(*padding));
}
Self {network,style_watch,label}
Self {display_object,network,style_watch,label}
}
}

impl display::Object for Entry {
fn display_object(&self) -> &display::object::Instance { self.label.display_object() }
fn display_object(&self) -> &display::object::Instance { &self.display_object }
}

impl list_view::entry::Entry for Entry {
Expand Down Expand Up @@ -132,22 +141,29 @@ impl ProjectList {
caption.remove_from_scene_layer(&app.display.scene().layers.main);
caption.add_to_scene_layer(&app.display.scene().layers.panel_text);

ensogl::shapes_order_dependencies! {
app.display.scene() => {
background -> list_view::io_rect;
background -> list_view::selection;
}
}

let style_watch = StyleWatchFrp::new(&app.display.scene().style_sheet);
let width = style_watch.get_number(theme::width);
let height = style_watch.get_number(theme::height);
let bar_height = style_watch.get_number(theme::bar::height);
let padding = style_watch.get_number(theme::padding);
let color = style_watch.get_color(theme::bar::label::color);
let label_size = style_watch.get_number(theme::bar::label::color);
let label_size = style_watch.get_number(theme::bar::label::size);

frp::extend! { network
frp::extend! { TRACE_ALL network
init <- source::<()>();
size <- all_with3(&width,&height,&init,|w,h,()|
Vector2(w + background::SHADOW_PX * 2.0,h + background::SHADOW_PX * 2.0)
);
list_size <- all_with4(&width,&height,&bar_height,&init,|w,h,bh,()|
Vector2(*w,*h - *bh));
list_y <- bar_height.map(|bh| -*bh / 2.0);
list_y <- all_with(&bar_height,&init, |bh,()| -*bh / 2.0);
caption_xy <- all_with4(&width,&height,&padding,&init,
|w,h,p,()| Vector2(-*w / 2.0 + *p, *h / 2.0 - p)
);
Expand All @@ -161,6 +177,7 @@ impl ProjectList {
eval color ((color) caption.set_default_color(color));
eval label_size ((size) caption.set_default_text_size(text::Size(*size)));
};
init.emit(());

Self {logger,network,display_object,background,caption,list,style_watch}
}
Expand Down

0 comments on commit 4c40f96

Please sign in to comment.