Commit graph

63 commits

Author SHA1 Message Date
Floyd Wang
1358b2906e
Bump gpui (#1324)
* Wireup the `Pixels` change
https://github.com/zed-industries/zed/pull/39367.
2025-10-03 14:32:29 +08:00
Jason Lee
02b432ed17
scrollbar: Fix scrollbar width on always show mode. (#1196)
And fixes #1192 render bug.
2025-09-02 15:48:06 +08:00
Jason Lee
eaeabdb0ef
scrollbar: Remove max_fps method. (#1138) 2025-08-15 10:17:07 +08:00
Jason Lee
fe8a1e8e9f
scrollbar: Show scrollbar immediately when scroll offset changed. (#1111)
https://github.com/user-attachments/assets/823f3ac7-4335-4dae-a540-a2ccd11b8fc8
2025-08-04 17:00:20 +08:00
Cyandev
b8db00dd3c
scrollbar: Reduce unnecessary frame updates (#1104)
The current scrollbar implementation calls
`Window::request_animation_frame` during the delay phase, which causes
unnecessary CPU usage. This PR updates the scrollbar to use a timer to
wait before starting the fade-out animation, allowing the CPU to remain
idle during this phase.

There is the comparison with Instruments.
**Before:**
<img width="632" height="75" alt="image"
src="https://github.com/user-attachments/assets/b407f1e5-8337-4f8f-b308-2cc16f6bf7ba"
/>

**After:**
<img width="608" height="75" alt="image"
src="https://github.com/user-attachments/assets/965787cf-1a42-413a-9a5e-ad0910c5cbee"
/>
2025-07-30 09:55:24 +08:00
Cyandev
e9d8741835
scrollbar: Fix content size (#1086)
Caused by PR #1078 incorrect changes, and GPUI was changed API
https://github.com/zed-industries/zed/pull/34832

The content size of the scrollable area should be its max scroll offset
plus the container size.

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-07-24 10:20:04 +08:00
Jason Lee
7d3301d695
tab_bar: Fix some incorrect style in TabBar. (#1078)
This change to fix some incorrect style use, that will break in Taffy
0.5.2+

Ref https://github.com/zed-industries/zed/pull/34827

- Add `Tab::empty` to create a Tab without label.
- Fix form layout in Taffy new version.
- Update GPUI for scroll API changes.
2025-07-22 13:30:04 +08:00
Jason Lee
8bf66443b2
theme: Add theme schema to support JSON theme config. (#1050) 2025-07-07 19:40:00 +08:00
Jason Lee
d7e04ecdd0
scrollbar: Improve Scrollbar to get correct scroll size. (#985)
Continue #984

- Fixes there may Scrollbar size not match the content size. Close #979
- Improved Table scrollbar to only render at scrollable area when there
have fixed columns.

<img width="850" alt="image"
src="https://github.com/user-attachments/assets/84f54515-e61a-484f-b2b4-ea5abb98ddb8"
/>


## Break Changes

- The `Scrollbar` has been removed `entity_id` and `scroll_size`
argument from new method, it will get that value from `scroll_handle`.
- There still have a `scroll_size` optional method, if you want to give
your own.
  - Also changed the `scroll_state`, `scroll_handle` to receive a ref.

```diff
- Scrollbar::vertical(entity_id, scroll_state, scroll_handle, scroll_size);
+ Scrollbar::vertical(&scroll_state, &scroll_handle);
+ Scrollbar::vertical(&scroll_state, &scroll_handle).scroll_size(scroll_size);
```
2025-06-18 19:09:34 +08:00
Jason Lee
1752d3e2b4
chore: Improve Scrollbar and Scrollable to support Axis and ScrollbarAxis. (#983) 2025-06-18 16:00:35 +08:00
Jason Lee
61283a71f0
scrollbar: Refactor ScrollbarState to have Cell inside. (#959)
## Break Change

- Now we added `Rc<Cell<>>` inside the ScrollbarState.

```diff
- scroll_state: Rc<Cell<ScrollbarState>>,
+ scroll_state: ScrollbarState,
```
2025-06-16 15:11:52 +08:00
Floyd Wang
44ec74f1fb
chart: Draw dashed lines using gpui PathBuilder (#927)
https://github.com/zed-industries/zed/pull/31678
2025-06-09 11:55:32 +08:00
Jason Lee
901312bc5a
chore: Switch gpui to depends on Zed official. (#912)
Now, GPUI have merged `window_handle` support for all platforms.

- https://github.com/zed-industries/zed/pull/24327
- https://github.com/zed-industries/zed/pull/24545
- https://github.com/zed-industries/zed/pull/28152

It's time to depends on Zed official main branch.
2025-06-02 10:05:45 +08:00
Jason Lee
a95482fdd8
chore: Upgrade GPUI 2025/05/26 with inspector changes. (#895)
https://github.com/zed-industries/zed/pull/31315
2025-05-26 13:40:27 +08:00
Jason Lee
0c6d631a39
scrollbar: Improve the scrollbar size. (#830)
## Idle

<img width="1086" alt="image"
src="https://github.com/user-attachments/assets/1acd847c-9ea4-477f-a1be-a9dd6305de60"
/>

## Hover

<img width="1086" alt="image"
src="https://github.com/user-attachments/assets/08a700ce-98f5-41ff-b504-37ea3cf90d81"
/>
2025-05-06 14:45:22 +08:00
Jason Lee
e921621a8b
scrollbar: Update min thumb size to 24px. (#766)
<img width="330" alt="image"
src="https://github.com/user-attachments/assets/ace52246-65ed-4d28-9906-c16281b6bd79"
/>
2025-04-02 11:37:19 +08:00
Floyd Wang
13de7d5a7e
chore: Update GPUI 2025/03/31 (#752) 2025-03-31 10:31:39 +08:00
Jason Lee
6bf26f6f72
scrollbar: Update Scrollbar default to use hover to show on Linux. (#687)
Continue #686
2025-03-05 10:34:16 +08:00
Jens Krause
c06a0c5d78
scrollbar: Fix Scrollbar not clickable when it is always showing. (#686)
On `platform` level,
[should_auto_hide_scrollbars()](76a81607de/crates/gpui/src/platform.rs (L205))
might be `false` for some `platform`s, e.g. for `Linux`.

That's why another check is needed to make scrollbars work properly on
Linux.

Fixes #685

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-03-05 10:14:22 +08:00
Jason Lee
6c9a317b3b
scrollbar: Fix scroll to show scrollbar. (#681)
Fix #624 was broke scroll to show behaviors.
2025-03-04 15:37:13 +08:00
Jason Lee
6e2bb3fb58
scrollbar: Update scrollbar hitbox to it bounds, not fill the full of parent view. (#624)
And revert some #621 wrong changes for hover to show scrollbar.
2025-02-14 13:54:02 +08:00
Jason Lee
437f1b2098
theme: Add to support always show scrollbar mode and default to match with system style. (#621)
Close #573

- Fix theme settings to keeping when switch theme mode.
2025-02-12 15:15:33 +08:00
Jason Lee
2e3f3dd669
scrollbar: Add max_fps to limit drag scroll update rate for reduce CPU usage. (#604)
And set Table to use 60 FPS.
2025-02-07 10:07:47 +08:00
Jason Lee
9675f1e02b
dock: Add cache to panel view. (#600) 2025-02-05 17:23:40 +08:00
Jason Lee
327d40e0e0
chore: Upgrade GPUI 3 (#587)
The pervious version has keep on
[gpui2](https://github.com/longbridge/gpui-component/tree/gpui2) branch,
if there need to use.

Ref https://github.com/zed-industries/zed/pull/22632

## Prepare

### Generate index.scip

```bash
rust-analyzer scip ./ > index.scip
```

### Get [refactor](https://github.com/zed-industries/refactor)

```bash
https://github.com/zed-industries/refactor.git
```

## Refactor exist code

```bash
cd refactor
cargo run -- ~/work/gpui-component
```

Then will get result if successed:

```
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/refactor /Users/jason/work/gpui-component`
Loaded 115 SCIP documents
Processing files starting with focus path: ""
Changed 90 files
```

-------------

## Changes

```diff
- View<T>
- Model<T>
+ Entity<T>

- WeakView<T>
+ WeakEntity<T>

- FocusableView
+ Focusable

- cx.bounds()
+ window.bounds()
- cx.refresh()
+ window.refresh()
- cx.focused()
+ window.focused(cx)
- cx.with_optional_element_state
- window.with_optional_element_state
```

```diff
- &mut WindowContext
+ &mut Window, &mut App

- cx: &mut WindowContext
+ window: &mut Window, cx: &mut App

- &mut ViewContext<
+ &mut Window, &mut Context<

- cx: &mut ViewContext<
+ window: &mut Window, cx: &mut Context<
```

```diff
- cx.spawn(|_, mut cx| async move { 
+ cx.spawn_in(window, |_, mut cx| async move {
- cx.dispatch_action(Box::new(...))
+ window.dispatch_action(Box::new(...), cx)
```

`cx.spawn`

```diff
- cx.spawn(|view, mut cx| async move {
+ cx.spawn_in(window, |view, mut window| async move {
+     _ = view.update_in(&mut window, move |view, window, cx| {
```
2025-01-27 03:58:48 +08:00
Jason Lee
1689f4208f
table: Add measure to table. (#577)
- Improve to not calc extra rows if `stripe` not enable.
- Improve to not change offset, when scrollbar drag changed less than
1px.
- Improve render cells to use `Vec::with_capacity` to prepare enough
space.

```bash
ZED_MEASUREMENTS=1 MTL_HUD_ENABLED=1 cargo run --release --example table
```
2025-01-24 18:59:01 +08:00
Jason Lee
9f2cd84b23
color: Add mix method and merge ColorExt to Colorize. (#561)
- Add `mix` method to mix two color.
- Export `ui::theme::*` to crate root, before `use
ui:theme::ActiveTheme` to `use ui::ActiveTheme`.

## Break Changes

- Moved `ui::theme::Colorize` to `ui::Colorize`.
- Merged `ColorExt` to `Colorize`.
- Renamed `to_hex_string` to `to_hex`, `parse_hex_string` to
`parse_hex`.
2025-01-21 18:31:01 +08:00
Jason Lee
11dbdb125a
chore: Removed ScrollableAxis use Axis instead. (#509) 2024-12-23 15:30:36 +08:00
Jason Lee
500aa2d7c5 table: Fix to only handle one way scrolling at same time. (#507)
Closes #314
2024-12-20 22:07:01 +08:00
Jason Lee
24982fb78c
scrollbar: Improve thumb bounds for avoid trigger scrollbar. (#496) 2024-12-18 17:21:57 +08:00
Jason Lee
64a3b4399b
chore: Update GPUI with gradient support. (#487) 2024-12-12 10:19:38 +08:00
Jason Lee
9f0f05af2d
scrollbar: Adjust scrollbar style and add scrollbar_thumb_hover to theme. (#482)
<img width="297" alt="image"
src="https://github.com/user-attachments/assets/1779bf6c-2d01-4a12-9052-2ba571bff68b">

<img width="301" alt="image"
src="https://github.com/user-attachments/assets/9971b248-9a48-47ff-847c-00eafff17fe1">
2024-12-10 17:08:09 +08:00
Jason Lee
2836540260
scrollbar: Improve scrollbar behaviour. (#481)
- Only show scroll when recent scrolled.
- Keep showing scrollbar when is visible and hovered on.
- Delay 3s to fade out.
- If not visible, do not handle mouse down event.
- Add `cx.theme().scrollbar_show` option to control scrollbar show
`[Hover, Scrolling]`, default: `Scrolling`.

Close #472

![CleanShot 2024-12-10 at 15 43
43](https://github.com/user-attachments/assets/17e5f46a-5602-4544-9a5c-82ec68a24dd4)
2024-12-10 16:18:38 +08:00
Jason Lee
26024ba2b5
scrollbar: Use default cursor style when hovered on scrollbar. (#480)
- Move prepare code to `prepaint` stage.

Close #474
2024-12-10 14:43:02 +08:00
Jason Lee
62ce148c19
scrollbar: Fix position may out of container bounds when clicked scrollbar bg. (#475) 2024-12-09 17:21:48 +08:00
Jason Lee
9d476f9517
scrollbar: Use paint_layer for scrollbar paint. (#448)
And increase scrollbar thumb color in normal mode.

But, it looks like no difference for performance.
2024-11-28 11:42:19 +08:00
Jason Lee
ea011d11d6
dock: Hide toggle button when side dock is not exist. (#431) 2024-11-22 15:38:47 +08:00
Jason Lee
c2678268b2 chore: Update background assign to use into. 2024-11-21 15:02:46 +08:00
Jason Lee
fa6abe5a9e
chore: Upgrade GPUI and fix API changes. (#426)
Refs:

- https://github.com/zed-industries/zed/pull/20349
- https://github.com/zed-industries/zed/pull/20371
- https://github.com/zed-industries/zed/pull/20686
2024-11-18 11:35:49 +08:00
xda
19f6b82b61
scrollbar: show the narrower scrollbar in idle state (#389)
![2024-11-03 11 36
16](https://github.com/user-attachments/assets/4879d5dd-e337-41a5-9411-d64c06166b3c)

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2024-11-04 11:34:57 +08:00
xda
5c8d0d7eb4
scrollbar: Do not show scrollbar event mouse is in Element rect, only show when hovered on scrollbar area or scrolled (#333)
Let the scrollbar only display when hovering and scrolling. The effect
comparison is on the left GPUI and on the right mac. I guess they used
the 10th power ease-in function, and the effect is similar.

Fixes https://github.com/huacnlee/gpui-component/issues/260

![2024-10-11 22 06
51](https://github.com/user-attachments/assets/4fa35150-2f93-4b79-bdbb-d8b7783e4b5a)
2024-10-13 10:53:53 +08:00
Jason Lee
efa044f417
menu: Fix Menu scrollbar will always showing bug. (#328)
- Improved Scrollbar size.
2024-10-10 18:10:28 +08:00
Jason Lee
cbed7b1ea1
menu: Add scrollable support to menu. (#310)
<img width="274" alt="image"
src="https://github.com/user-attachments/assets/eaff16a6-1294-4381-96c0-c178c195999b">
2024-10-04 14:24:05 +08:00
Jason Lee
185eca6c67
scrollbar: Update GPUI and fix scrollbar with new API. (#307)
The https://github.com/zed-industries/zed/pull/18513 has been changed
the `UniformListScrollHandle` API, it provided the scroll contents size,
so we not need calculate it again.
2024-10-04 10:23:11 +08:00
Jason Lee
33e5fdcb78
scrollbar: Smaller the scrollbar size. (#294)
<img width="918" alt="image"
src="https://github.com/user-attachments/assets/787766ab-63eb-4568-972b-5abd668511f7">
2024-10-02 18:15:53 +08:00
Jason Lee
dc3dc4a9ec
table: Avoid Table handle mouse wheel event, when it is blocked by some other element like Modal. (#261) 2024-09-23 14:32:16 +08:00
Jason Lee
cf551654fe
scrollbar: Fix Scrollbar inset and remove bar border. (#236)
<img width="920" alt="image"
src="https://github.com/user-attachments/assets/f834a920-8f89-4be8-9100-d2b5e4364449">
2024-09-11 11:59:37 +08:00
xda
4f8c4ccd5d
scrollbar: Keep the original thumb position when mouse down to dragging (#234)
![2024-09-10 23 18
50](https://github.com/user-attachments/assets/58c480a3-9c92-4c7c-8e7a-b37c2ffc3526)

fix #224
2024-09-11 09:37:07 +08:00
Jason Lee
2c469da55a
Update GPUI and apply opacity feature. (#215) 2024-09-04 19:29:51 +08:00
Jason Lee
476f97d5e0
scrollbar: Opacity scrollbar when not hover on it. (#213)
https://github.com/user-attachments/assets/ea070e6f-3d4c-4a0d-b6da-be34e7dfc579
2024-09-04 16:48:49 +08:00