Commit graph

937 commits

Author SHA1 Message Date
Jason Lee
8e525c6c99
modal: Improve paddings and gap in Modal. (#1153) 2025-08-19 11:41:12 +08:00
Jason Lee
6ae7558c44
theme: Add ThemeRegistry to load and watch themes dir. (#1148) 2025-08-18 19:29:27 +08:00
Jason Lee
dcca730d65
group_box: Add GroupBox element. (#1146)
Close #1144 

## Break Changes

- Renamed used theme variable `card`, `card_foreground` to `group_box`,
`group_box_foreground` for GroupBox.

<img width="1088" height="958" alt="image"
src="https://github.com/user-attachments/assets/adb1cbe6-fd6f-4d22-a434-39455f57ce09"
/>
2025-08-18 11:36:07 +08:00
Floyd Wang
566f5b0d4d fixup! plot: Fix the point scale cannot selecting the last point (#1143) 2025-08-15 17:23:42 +08:00
Floyd Wang
4c545165eb
plot: Fix the point scale cannot selecting the last point (#1143) 2025-08-15 17:09:41 +08:00
Floyd Wang
d559b56fb0
plot: Improve the band scale least_index (#1141) 2025-08-15 11:23:11 +08:00
Jason Lee
406bf8d929
chore: Fork html5minify for HTML render. (#1140)
Continue #1137 

Forked html5minify to improve:

- Resolve `\n` not replaced issue, now no need Regexp to replace.
- Resolve the difference version of html5ever dependency.
2025-08-15 11:10:23 +08:00
Jason Lee
eaeabdb0ef
scrollbar: Remove max_fps method. (#1138) 2025-08-15 10:17:07 +08:00
Jason Lee
899fbd693a
chore: Use html5minify instead of minify-html. (#1137)
Ref #1132 

This change to reduce release mode binary size from 21MB to 12MB.

## HTML Render example

<img width="1712" height="1312" alt="image"
src="https://github.com/user-attachments/assets/f07c02c9-1b0e-4aa4-b81a-d2b0ac4f7260"
/>
2025-08-15 09:52:38 +08:00
Jason Lee
9a389224f3
chore: Update GPUI and other crates. (#1136) 2025-08-14 19:57:53 +08:00
Jason Lee
63f61dca04
chore: Avoid built-in tree-sitter languages in default. (#1135)
With a `tree-sitter-languages` feature to enable it (Default not
enable).

Changed this for reduce the application size (From 52 MB to 22MB), Ref
#1132

Now default only includes `tree-sitter-json`, if you want more:

```toml
[dependencies]
gpui-component = { features = ["tree-sitter-languages"] }
```

---

```
cargo bloat -p hello_world --release -n 10
    Finished `release` profile [optimized] target(s) in 0.27s
    Analyzing target/release/hello_world

 File  .text    Size              Crate Name
 0.4%   1.4% 88.5KiB simple_minify_html simple_minify_html::code_gen::attrs::ATTRS::{{closure}}
 0.3%   1.0% 62.1KiB              taffy taffy::compute::grid::track_sizing::resolve_intrinsic_track_sizes
 0.1%   0.5% 32.6KiB     gpui_component gpui_component::theme::theme_color::ThemeColor::dark
 0.1%   0.5% 30.0KiB     gpui_component gpui_component::theme::theme_color::ThemeColor::light
 0.1%   0.5% 29.9KiB          html5ever html5ever::tree_builder::TreeBuilder<Handle,Sink>::step
 0.1%   0.4% 27.2KiB               gpui taffy::compute::flexbox::compute_flexbox_layout
 0.1%   0.4% 23.3KiB               usvg usvg::text::layout::layout_text
 0.1%   0.4% 22.5KiB              resvg resvg::filter::apply_inner
 0.1%   0.3% 21.4KiB               gpui jpeg_decoder::decoder::Decoder<R>::decode_internal
 0.1%   0.3% 21.2KiB         image_webp image_webp::lossless::LosslessDecoder<R>::decode_image_stream
25.3%  94.3%  5.7MiB                    And 14091 smaller methods. Use -n N to show more.
26.8% 100.0%  6.0MiB                    .text section size, the file size is 22.4MiB
```
2025-08-14 18:02:27 +08:00
Jason Lee
a73273a0f1
text_view: Use simple-minify-html instead of minify-html. (#1134)
To avoid depends on lightningcss, this is a heavy crate.

Ref #1132 

```
cargo bloat --release -n 200  --crates
    Finished `release` profile [optimized] target(s) in 0.30s
    Analyzing target/release/story

 File  .text     Size Crate
 4.6%  16.9%   3.4MiB lightningcss
```
2025-08-14 13:54:00 +08:00
Floyd Wang
37de698a61
list: Fix the scroll_to_item not working (#1129) 2025-08-13 15:12:54 +08:00
Floyd Wang
e37369ea16
plot: Support multiple directions for the tooltip cross line (#1128) 2025-08-12 14:16:31 +08:00
Jason Lee
7f64f8798e
virtual_list: Avoid scroll when list contents not overflow. (#1125)
- Fix scrollbar position in popup menu.
2025-08-08 19:13:18 +08:00
Jason Lee
b1f4a4f642
tabs: Remove underline variant TabBar paddings. (#1126)
<img width="1167" height="1044" alt="image"
src="https://github.com/user-attachments/assets/0a2b34b7-5629-402b-a54a-f975aab77e78"
/>
2025-08-08 19:06:26 +08:00
Jason Lee
85e2a72d03
slider: Add to support range to Slider. (#1121)
- Add to support Styled for Slider, and `bg`, `text_color`, `radius` can
change the slider bar and thumb.

## Break Changes

- The `reverse` method is removed from Slider, the Slider with vertical
now is always display from bottom to top.

<img width="1401" height="1176" alt="image"
src="https://github.com/user-attachments/assets/656592d6-ffac-4fd1-b569-848092c081bc"
/>
2025-08-08 16:59:23 +08:00
Jason Lee
900a4aa652
modal: Fix escape to dismiss Modal when list have selected item. (#1124) 2025-08-08 12:36:27 +08:00
Jason Lee
880d023834
virtual_list: Fix scroll to item not align to paddings. (#1122)
- Fixed List scroll to item at first time rendering.
2025-08-08 11:56:18 +08:00
Jason Lee
123a4a9fcd
chore: Update GPUI to fix click_count API changes. (#1123)
Closes #1116
2025-08-08 11:53:45 +08:00
Floyd Wang
0ab497ea1d
radio: Render the label based on its own size (#1114) 2025-08-06 15:29:07 +08:00
Jason Lee
9a040eaaac
list: Refactor List, Dropdown delegate API to support section. (#1107)
Ref UITableView API:

https://developer.apple.com/documentation/uikit/uitableviewdatasource

## Changes

- Added some section related API to `ListDelegeate` and
`DropdownDelegate` with default implement, so if you don't need section
that you can just keep the default.
- Added `sections_count` method to get the number of sections, default
is 1.
- Added `render_section_header` for special the section header by if
needed, default return None.
- Added `render_section_footer` for special the section footer by if
needed, default return None.

## Break Changes

- The `DropdownState` have change new method to use IndexPath type:

  ```diff
  - DropdownState::new(vec![], Some(1), window, cx);
  + DropdownState::new(vec![], Some(IndexPath::new(1)), window, cx);
  ```

- The `ListDelegeate`, `DropdownDelegate` has changed API:
  - The `ix` are change from `usize` to `IndexPath`.

  ```diff
- fn render_item(&self, ix: usize, window: &mut Window, cx: &mut
Context<List<Self>>) -> Option<Self::Item>
+ fn render_item(&self, ix: IndexPath, window: &mut Window, cx: &mut
Context<List<Self>>) -> Option<Self::Item>

- fn set_selected_index(&mut self, ix: Option<usize>, window: &mut
Window, cx: &mut Context<List<Self>>)
+ fn set_selected_index(&mut self, ix: Option<IndexPath>, window: &mut
Window, cx: &mut Context<List<Self>>)
  ```

- The `items_count` method have added `section` argument to support list
section.
  
  ```diff
  - fn items_count(&self, cx: &App) -> usize
  + fn items_count(&self, section: usize, cx: &App) -> usize
  ```

- The `can_load_more` method has renamed to `is_eof` in `ListDelegate`
and `TableDelegate`.

  ```diff
  - fn can_load_more(&self, cx: &App) -> bool
  + fn is_eof(&self, cx: &App) -> bool
  ```

- The `can_search` method has renamed to `searchable` in `ListDelegate`.

  ```diff
  - fn can_search(&self) -> bool
  + fn searchable(&self) -> bool
  ```

## Showcase

<img width="1196" height="925" alt="image"
src="https://github.com/user-attachments/assets/22750abe-cc3f-427e-903b-51758bd4e027"
/>

<img width="1214" height="934" alt="image"
src="https://github.com/user-attachments/assets/52d42546-e6e7-4448-9c0f-43cd659fb630"
/>

---------

Co-authored-by: Floyd Wang <gassnake999@gmail.com>
2025-08-05 19:23:32 +08:00
Floyd Wang
16f4fc0456
drawer: Fix the overlay_closable not working (#1113) 2025-08-05 19:10:38 +08:00
ihavecoke
163b540681
tiles: Add panels method. (#1112) 2025-08-04 19:33:28 +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
Floyd Wang
4b85cf6ad2
table: Fix the border overlap issue (#1110)
| Before | After |
| - | - |
| <img width="355" height="165" alt="SCR-20250801-kaof"
src="https://github.com/user-attachments/assets/ac073913-7813-43f2-a860-690a2366640b"
/> <img width="268" height="137" alt="SCR-20250801-kgqk"
src="https://github.com/user-attachments/assets/6a01df6d-fbf9-42a3-bfa3-4120a28b1401"
/> | <img width="378" height="176" alt="SCR-20250801-kags"
src="https://github.com/user-attachments/assets/c5a3196d-4d0f-469b-b0d4-ce60b8dbe3f1"
/> <img width="274" height="136" alt="SCR-20250801-kgik"
src="https://github.com/user-attachments/assets/649ff866-f153-40f3-97fa-7715f7480a2f"
/> |
2025-08-01 11:42:58 +08:00
Jason Lee
6c7a28c818
kbd: Fix Kdb to support display - key. (#1109) 2025-07-31 20:39:19 +08:00
Jason Lee
efa2c7c9ef
virtual_list: Add VirtualListScrollHandle to support scroll_to_item. (#1108)
- Also fixed Table scroll to selected column support.


https://github.com/user-attachments/assets/3b7c51a7-addf-4657-9f9f-de9047fffab8
2025-07-31 18:09:23 +08:00
Jason Lee
cb6695c774
dock: Adjust tab panel menu button position to align with content. (#1106)
## Before

<img width="1316" height="981" alt="image"
src="https://github.com/user-attachments/assets/ad2a96a0-5e82-4caa-85da-76f24d4deef1"
/>

## After

<img width="1306" height="796" alt="image"
src="https://github.com/user-attachments/assets/abc2d5d5-d9de-4cf0-9c39-eb965ffb9c46"
/>
2025-07-30 16:35:25 +08:00
Jason Lee
b2ce262da9 chore: Fix release unused method warning. 2025-07-30 15:44:41 +08:00
Jason Lee
e2153c9198
dock: Hide panel toolbar when dock is collapsed. (#1105) 2025-07-30 15:38:14 +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
Jason Lee
518004a014
input: Fix to let set_value works when Input is disabled. (#1103) 2025-07-29 17:55:53 +08:00
obito
7487662343
chrore: Refactor the disabled API for NumberInput, DatePicker, OtpInput, Calandar. (#1102)
- Added `disabled` method to OtpInput.
- Added `disabled` method to DatePicker.
- Added `disabled_matcher` method to CalendarState.

## Break Changes

- The `InputState` has been removed `disabled` and `set_disabled`
method, the disabled state should assign from TextInput element.

```diff
- let state = InputState::new("input1").disabled(true)
+ let state = InputState::new("input1");
+ TextInput::new(&state).disabled(true)
```

- Renamed `set_disabled` method to `set_disabled_matcher` from
`CalendarState`.
- Removed `set_disabled` method from `DatePickerState`, use
`disabled_matcher` method in `DatePicker` element.

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-07-29 17:31:52 +08:00
Floyd Wang
c07bc4aaad
list: Add support for scrolling to item with the given strategy (#1100)
## Breaking Change
- Add `strategy` to the `scroll_to_item` method.

```diff
+ list.scroll_to_item(selected, ScrollStrategy::Center, window, cx);
- list.scroll_to_item(selected, window, cx);
```
2025-07-29 15:14:26 +08:00
Jason Lee
771fd78416
tabs: Fix tab_bar_segmented default fallback color to secondary. (#1101) 2025-07-29 14:42:46 +08:00
Jason Lee
f423b8ffa2
table: Fix table head size. (#1099)
Close #1098, this issue was included from #1094
2025-07-29 10:03:25 +08:00
Jason Lee
058dd27687
tab: Fix tab text vertical center in small, xsmall size. (#1097) 2025-07-28 19:33:04 +08:00
Jason Lee
461ed9c173
chore: Fix Slider, Progress width in horizontal mode. (#1096)
This bug included since Taffy 0.8 update in
[#taffy](https://github.com/zed-industries/zed/pull/34939)
2025-07-28 18:56:09 +08:00
Jason Lee
93b578294c
list: Update ListItem and DropdownListItem style. (#1095)
## Break Change

- The `Selectable` trait has been removed `element_id` method, this is
necessary.
- The `item` of `List` now must impl `Selectable` trait.

## List

> NOTE: The default ListItem is no rounded and paddings.

<img width="1144" height="762" alt="image"
src="https://github.com/user-attachments/assets/32348682-f89a-487a-af9f-5ed379a7f2d8"
/>

## Dropdown

<img width="537" height="387" alt="image"
src="https://github.com/user-attachments/assets/3cc99d9f-3714-4d10-b467-6c91917bcbf0"
/>
2025-07-28 18:38:39 +08:00
Floyd Wang
6d0443998c
table: Fix the incorrect rendering of the header border (#1094) 2025-07-28 10:32:11 +08:00
Jason Lee
37aa26d655
check, radio: Add fade in animation to Checkbox and Radio. (#1092) 2025-07-24 11:41:34 +00:00
Jason Lee
479ab8f0d6
switch: Apply use_keyed_state to store toggle state for animation. (#1091)
Ref https://github.com/zed-industries/zed/pull/34741

Now `Switch` can use impl RenderOnce.
2025-07-24 19:22:55 +08:00
Jason Lee
579c7a3cbb
virtual_list: Fix scrollable size calculate in VirtualList. (#1087)
The `virtual_list` scroll range issue because recently GPUI changed the
`ScrollHandle` API, now we only get the `max_offset`.

So #1086 have fixed this to implementation a `content_size` method to
calculate `max_offset` and `bounds` of the `ScrollHandle`.

But I found that the `Interactivity` prepaint (This is used in
VirtualList) was not to update the `bounds` of the `ScrollHandle`.

Wait https://github.com/zed-industries/zed/pull/35013 to merge.

| Before | After |
| -- | --- |
| <img width="620" alt="image"
src="https://github.com/user-attachments/assets/6ffb8f30-93b4-42ec-a837-90f80ecb2bf5"
/> | <img width="620" alt="image"
src="https://github.com/user-attachments/assets/21466332-030c-495f-8c84-e3a2c6eeb403"
/> |
- Split `Scrollbale` and `VirtualList` story.

## Break Changes

- The `content_size` argument has been removed from `virtual_list`
callback.
2025-07-24 08:30:42 +00:00
Jason Lee
56cf05b749
table: Fix horizontal scroll range when no fixed columns. (#1089) 2025-07-24 15:35:14 +08:00
Floyd Wang
634ab14306 button: Use muted foreground as disabled text color (#1088) 2025-07-24 14:19:10 +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
fcf447d612
theme: Fix scrollbar default color and list hover color. (#1085) 2025-07-23 11:50:42 +00:00
Floyd Wang
6d28cce719
notification: Fix display issues caused by the taffy upgrade (#1084) 2025-07-23 19:12:13 +08:00
Jason Lee
f458cb83f8
accordion: Fix accordion to size full. (#1083)
- Remove `accordion.background` color from themes.
2025-07-23 10:45:02 +00:00