diff --git a/emigui/README.md b/emigui/README.md index c9b70fb5..b730210a 100644 --- a/emigui/README.md +++ b/emigui/README.md @@ -13,8 +13,14 @@ This is the core library crate Emigui. It is fully platform independent without * [x] Movable/resizable windows * [ ] Kinetic windows * [ ] Scroll areas + * [x] Vertical scrolling + * [ ] Horizontal scrolling + * [ ] Scroll-wheel input + * [x] Drag background to scroll + * [ ] Kinetic scrolling * [ ] Menu bar (File, Edit, etc) * [ ] One-line TextField + * [ ] Clipboard copy/paste * [ ] Color picker * [ ] Style editor @@ -45,6 +51,8 @@ I think A) is the correct solution, but might be tedious to get right for every * [ ] Draw as hotmap ### Names and structure +* [ ] Rename things to be more consistent with Dear ImGui + * Foldable -> Collapsible etc * [ ] Combine Emigui and Context * [ ] Rename Region to something shorter? * `region: &Region` `region.add(...)` :/ diff --git a/emigui/src/scroll_area.rs b/emigui/src/scroll_area.rs index dbb0275a..865d98ae 100644 --- a/emigui/src/scroll_area.rs +++ b/emigui/src/scroll_area.rs @@ -51,6 +51,16 @@ impl ScrollArea { add_contents(&mut content_region); let content_size = content_region.bounding_size; + let content_interact = ctx.interact( + outer_region.layer, + inner_rect, + Some(scroll_area_id.with("area")), + ); + if content_interact.active { + // Dragging scroll area to scroll: + state.offset.y -= ctx.input.mouse_move.y; + } + let show_scroll = content_size.y > inner_size.y; if show_scroll { let corner_radius = scroll_bar_width / 2.0; @@ -103,8 +113,6 @@ impl ScrollArea { if inner_rect.min().y <= mouse_pos.y && mouse_pos.y <= inner_rect.max().y { state.offset.y += ctx.input.mouse_move.y * content_size.y / inner_rect.height(); - state.offset.y = state.offset.y.max(0.0); - state.offset.y = state.offset.y.min(content_size.y - inner_rect.height()); } } } @@ -132,6 +140,9 @@ impl ScrollArea { let size = content_size.min(content_region.clip_rect.size()); outer_region.reserve_space_without_padding(size); + state.offset.y = state.offset.y.max(0.0); + state.offset.y = state.offset.y.min(content_size.y - inner_rect.height()); + outer_region .ctx() .memory