-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Component Group View with static header and without icons #3373
Merged
Merged
Changes from 163 commits
Commits
Show all changes
165 commits
Select commit
Hold shift + click to select a range
60ce484
WIP component_group debug scene w/scroll-area
akavel 9e7ff75
remove scroll_area
akavel 91fb726
WIP start adding files for CGV in lib/rust/ensogl/
akavel eb8606d
WIP plugging CGV into example scene
akavel b1d5ef9
use simple Label entries in the example
akavel 6baab5e
compiles but does not show in the example
akavel 06f1ec7
connect set_entries & resize
akavel 2d9daef
style: no spaces in FRP of ListView
akavel d680f66
add ListView::frp::background_visible(bool)
akavel 3977a59
WIP trying to disable ListView background for CGV
akavel 5a2db45
WIP unexpectedly, effect seems reversed
akavel 3785ab8
fix background visibility setting
akavel 9dbd3bc
s/background_visibility/show_background/
akavel 4fead21
s//show_background_shadow/
akavel b6e36db
parametrize listview bg corners radius
akavel 66b0069
WIP starting to impl custom color for ListView bg
akavel caecd7b
set_background_color in LV
akavel a9382bd
make LV setters private
akavel e79a3de
use set_background_color in LV.init
akavel 9373fa8
add empty TextArea to CGV
akavel c3ef542
allow setting the header text; currently badly positioned
akavel 8b0475e
comments tweaks
akavel 5a42e8a
const HEADER_HEIGHT
akavel 349fd8b
CGV::resize() impl.
akavel d475a92
improve doc comment in shapes_order_dependencies!
akavel 338d1eb
WIP adding header_background; bad z-order
akavel 08cd066
CLEANUP some comment
akavel fb23962
TRY shapes_order_dependencies!; did not help
akavel 49b8442
show header text above header_background
akavel ed123bb
shorter group name for now
akavel 8e3ecd6
small tweaks
akavel c6a2cce
DEBUG mcdbg::View
akavel 18fd311
fix LV position
akavel a7ca8c2
HEADER_LEFT_PADDING
akavel b7324f2
HACK lv_padding
akavel 8f5c4b4
tweak FRP init variable location
akavel df31d31
CLEANUP mcdbg
akavel 24d277f
fix vertical position of group name
akavel fe27711
WIP adding set_font function in text::Area
akavel aeca296
first TA.set_font working attempt
akavel 61971f8
WIP start working on TA::clip_line_to_width
akavel 6eb7476
WIP quick & dirty PoC of ellipse truncating
akavel cc87551
pass String to clip_line_to_width
akavel 8e60d5f
use unicode ellipsis
akavel 381249d
s/clip/clip_at/
akavel 2db798d
real width of ellipsis
akavel f4294ea
use find_map and ignore width of ellipsis for now
akavel cb07cee
rename func
akavel 28416d4
account for width of ellipsis
akavel cf06630
set_truncation_width FRP
akavel bb13896
use short header text for now
akavel 5162f67
add CGV::set_background_color FRP input
akavel 0acd66a
CLEANUP debug color setting
akavel 17bba18
tweak header text vertical alignment
akavel 8a2faed
delete unused import of "shadow"
akavel 8b8260a
some cleanups
akavel 78b6a75
more cleanups
akavel a61ebe5
cargo fmt
akavel 0cd89e9
glyph_system_borrowed
akavel b9fb33a
Revert "glyph_system_borrowed"
akavel 544c3ad
cleanup around truncation_width
akavel 0e5f89d
add & use DejaVuSans-Bold for CGV header
akavel f02de48
start adding theme for CGV
akavel 16fc80c
draft stylesheet for CGV
akavel 2ad4c2a
del obsolete dependency
akavel 22eed46
start using init source in LV FRP for defaults
akavel 1a2ce68
LV: use init source for default_background_color
akavel edaf6ee
WIP set_style_path
akavel be3afdf
DEBUG set_style_path etc.
akavel 678b180
update_entries_style_prefix
akavel 4bbe73d
style_path -> style_prefix & some cleanups & updates
akavel fb41ef1
fix init source in CGV FRP
akavel f75c082
use proper styles path in CGV
akavel 8a516cc
del obsolete TODO
akavel ee0739f
HeaderGeometry
akavel 7e03d97
WIP start adding support for Text styles
akavel b6d3fe4
WIP style Data: TryFrom->FromStr
akavel 5ecddba
added Text() variant in styles
akavel 64d68d1
set CGV header font from styles
akavel 540de0a
load font for ListView entries from styles
akavel 7d73016
improve theme name
akavel ce840c9
cargo fmt
akavel 68d05aa
cargo clippy fixes
akavel 64db7c5
comment & resize->set_size
akavel 4209782
more comments + fix vertical positioning calculations
akavel f87fe82
tweak CGV::new body
akavel 2bced50
add comment
akavel 15a0a3e
del unused import from LV entry
akavel 9bbb9b4
LV: show_shadow->shadow_alpha, drop some funcs
akavel 4001a37
set_custom_bg_color -> set_bg_color
akavel e5ea02f
simplify & reformat LV Frp::set_style_prefix handling
akavel ab1f6bb
trunc w/ellipsis naming tweak
akavel 65dd4fc
trunc w/ellipsis naming tweak
akavel 1413ced
trunc w/ellipsis naming tweak
akavel 048cfd8
trunc w/ellipsis naming tweak
akavel aa892f6
trunc w/ellipsis naming tweak
akavel 9c374f5
more trunc_w_ellipsis tweaks
akavel 1ede1fa
trunc. tweaks
akavel 6a683d0
cargo fmt
akavel 60622a1
comment tweaks
akavel f3c2409
example w/texts
akavel b4d1508
example text tweak
akavel be4f01f
sample texts
akavel ab2b98d
truncate overwidth list_view entries
akavel 2cb584b
tweak
akavel 2e90072
add parser for Data::Text from_str
akavel fc20bcf
Merge remote-tracking branch 'origin/develop' into wip/akavel/cgv-sta…
akavel e859e5c
pragmas cleanup
akavel 9c485ab
fix for CI
akavel 68fb971
changelog
akavel 51c722c
fix clippy
akavel a622ed4
cargo fmt
akavel 5c2cb86
remove unused fonts
akavel ad33d98
lower the WASM binary size limit
akavel 9a4a203
cargo fmt
akavel 3eb469e
tweak whitespace
akavel 1786520
more whitespace tweaks
akavel ea2f9f0
tweak module docs
akavel 0a963b7
edit module doc again
akavel 3e2ea92
restore comment
akavel 32e80ec
Merge branch 'develop' into wip/akavel/cgv-static-181724889
akavel 8775396
pull back support for Text values in styles
akavel 35744df
pull back support for custom styles for ListView entries
akavel 2c6a604
cargo fmt
akavel e1d3ac0
del spurious empty line
akavel 7b5fe8f
change truncation_width from refcell to just cell
akavel a26d544
move CGV to app/gui/view/component-browser/
akavel 5ce05c6
cargo fmt
akavel 1054e3f
fix visual glitch
akavel 4760977
WIP; LV trims too much, Searcher too slow
akavel 39def4b
WIP fix LV debug scene
akavel 363eaa9
fix perf. regression
akavel ef406c1
review: use color from Design Doc in debug scene
akavel 017fdb1
review: move HeaderGeometry above FRP
akavel 4b135af
review: put font name in constant
akavel aa043dc
review: Entry::resize(width)->set_max_width(max_width)
akavel 6df9b78
cleanup some commented lines
akavel 74c94d0
review: drop import of ensogl_list_view::entry
akavel 284466e
drop more imports
akavel dd8c60c
review: rename CGV to drop "View" suffix
akavel 2f7e90e
review: del recursion_limit
akavel 1efcf7f
review: use and improve entry_point attribute for debug scn
akavel d3465c9
review: tweaks
akavel 4469aeb
review: improve formatting to better match rustfmt
akavel 57d0830
refactor entry_width calc
akavel 5c04403
Merge remote-tracking branch 'origin/develop' into wip/akavel/cgv-sta…
akavel 4f386d2
Merge remote-tracking branch 'origin/develop' into wip/akavel/cgv-sta…
akavel cd3490c
review: revert recursion_limit increase
akavel 766c16b
review: set_header_text -> set_header
akavel bf2f9ea
review: rustfmt-like formatting in macro
akavel bd0f655
update_header_with instead of full resize() in CGV
akavel 7d706d7
fix clippy
akavel 74d8280
review: add comment about max_width_px
akavel 2f456f4
add comment to set_content_truncated FRP
akavel 61b546b
review: expand the comment in shapes_order_dependencies
akavel bc33013
review: tweak docs
akavel 8f2fc4a
link design doc in module doc
akavel d0a13e3
fix for cargo fmt
akavel 8046891
tweak spacing in macro
akavel 1be87d2
use HOVER_COLOR
akavel bd0abc0
drop View from comp. name in label()
akavel e19329c
update name
akavel 33ecb43
delete duplicate set_font evaluation after merge
akavel 0a191c8
review: final minor tweaks
akavel 3930773
Merge branch 'develop' into wip/akavel/cgv-static-181724889
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,11 @@ | ||
[package] | ||
name = "ide-view-component-browser" | ||
version = "0.1.0" | ||
authors = ["Enso Team <[email protected]>"] | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
ide-view-component-group = { path = "component-group" } |
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,17 @@ | ||
[package] | ||
name = "ide-view-component-group" | ||
version = "0.1.0" | ||
authors = ["Enso Team <[email protected]>"] | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
enso-frp = { version = "0.1.0", path = "../../../../../lib/rust/frp" } | ||
ensogl-core = { version = "0.1.0", path = "../../../../../lib/rust/ensogl/core" } | ||
ensogl-gui-component = { version = "0.1.0", path = "../../../../../lib/rust/ensogl/component/gui" } | ||
ensogl-hardcoded-theme = { version = "0.1.0", path = "../../../../../lib/rust/ensogl/app/theme/hardcoded" } | ||
ensogl-list-view = { version = "0.1.0", path = "../../../../../lib/rust/ensogl/component/list-view" } | ||
ensogl-text = { version = "0.1.0", path = "../../../../../lib/rust/ensogl/component/text" } | ||
|
248 changes: 248 additions & 0 deletions
248
app/gui/view/component-browser/component-group/src/lib.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,248 @@ | ||
//! This module defines a widget for displaying a list of entries of a component group and the name | ||
//! of the component group. | ||
//! | ||
//! The widget is defined by the [`View`]. | ||
//! | ||
//! To learn more about component groups, see the [Component Browser Design | ||
//! Document](https://github.com/enso-org/design/blob/e6cffec2dd6d16688164f04a4ef0d9dff998c3e7/epics/component-browser/design.md). | ||
|
||
// === Standard Linter Configuration === | ||
#![deny(non_ascii_idents)] | ||
#![warn(unsafe_code)] | ||
// === Non-Standard Linter Configuration === | ||
#![warn(missing_copy_implementations)] | ||
#![warn(missing_debug_implementations)] | ||
#![warn(missing_docs)] | ||
#![warn(trivial_casts)] | ||
#![warn(trivial_numeric_casts)] | ||
#![warn(unused_import_braces)] | ||
#![warn(unused_qualifications)] | ||
|
||
use ensogl_core::prelude::*; | ||
|
||
use enso_frp as frp; | ||
use ensogl_core::application::Application; | ||
use ensogl_core::data::color::Rgba; | ||
use ensogl_core::display; | ||
use ensogl_core::display::shape::*; | ||
use ensogl_gui_component::component; | ||
use ensogl_hardcoded_theme::application::component_browser::component_group as theme; | ||
use ensogl_list_view as list_view; | ||
use ensogl_text as text; | ||
|
||
|
||
|
||
// ================= | ||
// === Constants === | ||
// ================= | ||
|
||
const HEADER_FONT: &str = "DejaVuSans-Bold"; | ||
|
||
|
||
|
||
// ========================== | ||
// === Shapes Definitions === | ||
// ========================== | ||
|
||
|
||
// === Background === | ||
|
||
/// The background of the [`View`]. | ||
pub mod background { | ||
use super::*; | ||
|
||
ensogl_core::define_shape_system! { | ||
below = [list_view::background]; | ||
(style:Style, color:Vector4) { | ||
let sprite_width: Var<Pixels> = "input_size.x".into(); | ||
let sprite_height: Var<Pixels> = "input_size.y".into(); | ||
let color = Var::<Rgba>::from(color); | ||
let shape = Rect((&sprite_width, &sprite_height)).fill(color); | ||
shape.into() | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
// ======================= | ||
// === Header Geometry === | ||
// ======================= | ||
|
||
#[derive(Debug, Copy, Clone, Default)] | ||
struct HeaderGeometry { | ||
height: f32, | ||
padding_left: f32, | ||
padding_right: f32, | ||
padding_bottom: f32, | ||
} | ||
|
||
impl HeaderGeometry { | ||
fn from_style(style: &StyleWatchFrp, network: &frp::Network) -> frp::Sampler<Self> { | ||
let height = style.get_number(theme::header::height); | ||
let padding_left = style.get_number(theme::header::padding::left); | ||
let padding_right = style.get_number(theme::header::padding::right); | ||
let padding_bottom = style.get_number(theme::header::padding::bottom); | ||
|
||
frp::extend! { network | ||
init <- source_(); | ||
theme <- all_with5(&init,&height,&padding_left,&padding_right,&padding_bottom, | ||
|_,&height,&padding_left,&padding_right,&padding_bottom| | ||
Self{height,padding_left,padding_right,padding_bottom} | ||
); | ||
theme_sampler <- theme.sampler(); | ||
} | ||
init.emit(()); | ||
theme_sampler | ||
} | ||
} | ||
|
||
|
||
|
||
// =========== | ||
// === FRP === | ||
// =========== | ||
|
||
ensogl_core::define_endpoints_2! { | ||
Input { | ||
set_header(String), | ||
set_entries(list_view::entry::AnyModelProvider<list_view::entry::Label>), | ||
set_background_color(Rgba), | ||
set_size(Vector2), | ||
} | ||
Output {} | ||
} | ||
|
||
impl component::Frp<Model> for Frp { | ||
fn init(api: &Self::Private, _app: &Application, model: &Model, style: &StyleWatchFrp) { | ||
let network = &api.network; | ||
let input = &api.input; | ||
let header_text_size = style.get_number(theme::header::text::size); | ||
frp::extend! { network | ||
|
||
// === Geometry === | ||
|
||
let header_geometry = HeaderGeometry::from_style(style, network); | ||
size_and_header_geometry <- all(&input.set_size, &header_geometry); | ||
eval size_and_header_geometry(((size, hdr_geom)) model.resize(*size, *hdr_geom)); | ||
|
||
|
||
// === Header === | ||
|
||
init <- source_(); | ||
header_text_size <- all(&header_text_size, &init)._0(); | ||
model.header.set_default_text_size <+ header_text_size.map(|v| text::Size(*v)); | ||
_set_header <- input.set_header.map2(&size_and_header_geometry, f!( | ||
(t, (size, hdr_geom)) { | ||
model.header_text.replace(t.clone()); | ||
model.update_header_width(*size, *hdr_geom); | ||
}) | ||
); | ||
eval input.set_background_color((c) | ||
model.background.color.set(c.into())); | ||
|
||
|
||
// === Entries === | ||
|
||
model.entries.set_background_color(HOVER_COLOR); | ||
model.entries.show_background_shadow(false); | ||
model.entries.set_background_corners_radius(0.0); | ||
model.entries.set_background_color <+ input.set_background_color; | ||
model.entries.set_entries <+ input.set_entries; | ||
} | ||
init.emit(()); | ||
} | ||
} | ||
|
||
|
||
|
||
// ============= | ||
// === Model === | ||
// ============= | ||
|
||
/// The Model of the [`View`] component. | ||
#[derive(Clone, CloneRef, Debug)] | ||
pub struct Model { | ||
display_object: display::object::Instance, | ||
header: text::Area, | ||
header_text: Rc<RefCell<String>>, | ||
background: background::View, | ||
entries: list_view::ListView<list_view::entry::Label>, | ||
} | ||
|
||
impl display::Object for Model { | ||
fn display_object(&self) -> &display::object::Instance { | ||
&self.display_object | ||
} | ||
} | ||
|
||
impl component::Model for Model { | ||
fn label() -> &'static str { | ||
"ComponentGroup" | ||
} | ||
|
||
fn new(app: &Application, logger: &Logger) -> Self { | ||
let header_text = default(); | ||
let display_object = display::object::Instance::new(&logger); | ||
let background = background::View::new(&logger); | ||
let header = text::Area::new(app); | ||
let entries = list_view::ListView::new(app); | ||
display_object.add_child(&background); | ||
display_object.add_child(&header); | ||
display_object.add_child(&entries); | ||
|
||
header.set_font(HEADER_FONT); | ||
let label_layer = &app.display.default_scene.layers.label; | ||
header.add_to_scene_layer(label_layer); | ||
|
||
Model { display_object, header, header_text, background, entries } | ||
} | ||
} | ||
|
||
impl Model { | ||
fn resize(&self, size: Vector2, header_geometry: HeaderGeometry) { | ||
// === Background === | ||
|
||
self.background.size.set(size); | ||
|
||
|
||
// === Header Text === | ||
|
||
let header_padding_left = header_geometry.padding_left; | ||
let header_text_x = -size.x / 2.0 + header_padding_left; | ||
let header_text_height = self.header.height.value(); | ||
let header_padding_bottom = header_geometry.padding_bottom; | ||
let header_height = header_geometry.height; | ||
let header_bottom_y = size.y / 2.0 - header_height; | ||
let header_text_y = header_bottom_y + header_text_height + header_padding_bottom; | ||
self.header.set_position_xy(Vector2(header_text_x, header_text_y)); | ||
self.update_header_width(size, header_geometry); | ||
|
||
|
||
// === Entries === | ||
|
||
self.entries.resize(size - Vector2(0.0, header_height)); | ||
self.entries.set_position_y(-header_height / 2.0); | ||
} | ||
|
||
fn update_header_width(&self, size: Vector2, header_geometry: HeaderGeometry) { | ||
let header_padding_left = header_geometry.padding_left; | ||
let header_padding_right = header_geometry.padding_right; | ||
let max_text_width = size.x - header_padding_left - header_padding_right; | ||
self.header.set_content_truncated(self.header_text.borrow().clone(), max_text_width); | ||
} | ||
} | ||
|
||
|
||
|
||
// ============ | ||
// === View === | ||
// ============ | ||
|
||
/// A widget for displaying the entries and name of a component group. | ||
/// | ||
/// The widget is rendered as a header label, a list of entries below it, and a colored background. | ||
/// | ||
/// To learn more about component groups, see the [Component Browser Design | ||
/// Document](https://github.com/enso-org/design/blob/e6cffec2dd6d16688164f04a4ef0d9dff998c3e7/epics/component-browser/design.md). | ||
pub type View = component::ComponentView<Model, Frp>; |
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,19 @@ | ||
// === Standard Linter Configuration === | ||
#![deny(non_ascii_idents)] | ||
#![warn(unsafe_code)] | ||
// === Non-Standard Linter Configuration === | ||
#![warn(missing_copy_implementations)] | ||
#![warn(missing_debug_implementations)] | ||
#![warn(missing_docs)] | ||
#![warn(trivial_casts)] | ||
#![warn(trivial_numeric_casts)] | ||
#![warn(unused_import_braces)] | ||
#![warn(unused_qualifications)] | ||
|
||
|
||
// ============== | ||
// === Export === | ||
// ============== | ||
|
||
pub use ide_view_component_group as component_group; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "debug-scene-component-group" | ||
version = "0.1.0" | ||
authors = ["Enso Team <[email protected]>"] | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[dependencies] | ||
enso-frp = { path = "../../../../../lib/rust/frp" } | ||
ensogl-core = { path = "../../../../../lib/rust/ensogl/core" } | ||
ensogl-hardcoded-theme = { path = "../../../../../lib/rust/ensogl/app/theme/hardcoded" } | ||
ensogl-list-view = { path = "../../../../../lib/rust/ensogl/component/list-view" } | ||
ensogl-text-msdf-sys = { path = "../../../../../lib/rust/ensogl/component/text/msdf-sys" } | ||
ide-view-component-group = { path = "../../component-browser/component-group" } | ||
wasm-bindgen = { version = "0.2.78", features = ["nightly"] } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is
t
? It is really poorly named variable