Commit graph

635 commits

Author SHA1 Message Date
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
Floyd Wang
c7257d36cf
calendar: Add Matcher for disabled dates (#623)
| Day Of Week | Interval | Range |
|--------------|---------|-------|
| <img width="420" alt="image"
src="https://github.com/user-attachments/assets/e23f69b8-3191-4370-8adf-266362680e5c"
/> | <img width="264" alt="image"
src="https://github.com/user-attachments/assets/c211d7c3-9878-402e-a6cc-e3ac1b50e588"
/> | <img width="337" alt="image"
src="https://github.com/user-attachments/assets/2b894ef1-14d0-4fc3-89e5-4e38b5e8572c"
/> |
2025-02-13 17:43:19 +08:00
Jason Lee
83375147fe
panel: Improve resize handle to show highlight color on dragging. (#622)
https://github.com/user-attachments/assets/aabbd73b-3c11-43e2-a4f2-121d46fba1d7
2025-02-13 16:07:00 +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
ec3d8e50ed
chore: Update README for icons usage. (#620)
Fix #619
2025-02-12 14:04:11 +08:00
Floyd Wang
d95cbabcc3
dropdown: Do not reset the selected index when cancelling (#618)
## Before


https://github.com/user-attachments/assets/e33c2324-94f0-42b0-99cc-9e2dcdee3f3d



## After


https://github.com/user-attachments/assets/7c5c6fee-b0f6-4cd5-986e-ea8f6f0e7f9d
2025-02-11 18:54:52 +08:00
Jason Lee
0050685a58
chore: Avoid some unnecessary window.refresh call. (#617)
Ref
https://github.com/zed-industries/zed/discussions/24260#discussioncomment-12135749
2025-02-11 17:06:17 +08:00
Jason Lee
4a26776289
label: Avoid String alloc and remove custom text-align. (#616)
Reverted #615 and recreate again.

## Break changes

- Remove `TextAlign` and `text_left`, `text_right` ... method from
label, we can use same things from GPUI.

<img width="1151" alt="image"
src="https://github.com/user-attachments/assets/95e9066a-e58d-47a8-9acf-b483b0203b1b"
/>
2025-02-11 10:30:45 +08:00
Floyd Wang
44e678b9bc
dock: Make the panel inner padding controllable (#613) 2025-02-10 17:55:57 +08:00
Floyd Wang
cd9c88a0f7
dock: Leave some space between the tabs title and panel (#612)
## Before
<img width="541" alt="image"
src="https://github.com/user-attachments/assets/a41390ec-a86b-4ca2-bcf4-a2b368c1e2e0"
/>

## After
<img width="518" alt="image"
src="https://github.com/user-attachments/assets/0896abe5-d499-4052-aa84-0864029c0346"
/>
2025-02-10 15:55:08 +08:00
Jason Lee
7ceae0acff
Revert "dock: Revert AnyView cached (#607)" (#611)
This reverts commit 2479fc3418.

> NOTE: When we enabled this, we need make sure call `cx.nofity()` when
the data has been updated.

In real world application, this may reduce about 3% CPU cost.

<img width="550" alt="image"
src="https://github.com/user-attachments/assets/9188cde9-3402-4860-9e03-328aa74a74e7"
/>

> I watched this data about 5 minutes, the CPU cost is always like this.
2025-02-10 14:09:09 +08:00
Jason Lee
a5db381ef4
chore: Upgrade GPUI 2025/02/10 (#610)
- Replace `Window::parent_view_id()` with `Window::current_view()`
https://github.com/zed-industries/zed/pull/24212
- Fix SvgImg crash by move `use_asset` to `request_layout`.
- Fix Input to implement `character_index_for_point` method
https://github.com/zed-industries/zed/pull/23989
- Fix Input IME position to under the cursor line.
  <img width="504" alt="image"
src="https://github.com/user-attachments/assets/8a6f56c8-6aae-4c0c-8c5a-3959d6a9d224"
/>
- Fix Input overflow sub crash.
2025-02-10 11:53:25 +08:00
Jens Krause
b1bae7ca21 color_picker: Fix popup does not close by clicking color button again. (#608) 2025-02-09 11:07:46 +08:00
Jens Krause
a6922e3a10
example: Fix tiles needs package gpui-component (#609) 2025-02-08 23:43:37 +08:00
Floyd Wang
2479fc3418
dock: Revert AnyView cached (#607)
* This may cause the interface to not update in real time.
2025-02-07 10:22:29 +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
Floyd Wang
abb3de013e
Rename package from ui to gpui-component (#606)
## 🚨Break Change

Update dependencies from `ui` to `gpui-component`.
2025-02-06 17:21:46 +08:00
Floyd Wang
e423497da6
tooltip: Support render element (#605)
<img width="376" alt="image"
src="https://github.com/user-attachments/assets/52793001-03cb-46ca-80a3-42aa3db57ecb"
/>
2025-02-06 16:05:44 +08:00
Jason Lee
99a4c793c5
chore: Update crate name to gpui-component for publish crate to hold the name. (#603) 2025-02-06 11:57:34 +08:00
Jason Lee
bc579c0b93
table: Fix Table subtract with overflow error. (#602)
```
thread 'main' panicked at gpui-component-f2cfc37a601d48ab/dffb419/crates/ui/src/[table.rs:1562](http://table.rs:1562/):45:
attempt to subtract with overflow
stack backtrace:
```
2025-02-05 19:26:19 +08:00
Jason Lee
9675f1e02b
dock: Add cache to panel view. (#600) 2025-02-05 17:23:40 +08:00
Jason Lee
3e16c0d220
chore: Remove reexport prelude. (#599)
This is useless, we can just use `gpui::prelude`, so I removed it.

## Break changes

- The `ui::prelude` has been removed, you can replace by use
`gpui::prelude`.
2025-02-04 17:37:28 +08:00
Jason Lee
155f2ee3b9
chore: Refactor ClearButton to as method. (#598) 2025-02-04 17:34:26 +08:00
Jason Lee
dffb419145
chore: Fix subscriptions leak. (#597) 2025-02-04 15:43:26 +08:00
Jason Lee
3ffbbb0688
theme: Ensure all elements to use radius. (#596)
- Fix menu dispatch action.
2025-02-03 19:03:16 +08:00
Jason Lee
eaec664a8d
theme: Add doc for Theme variables. (#595)
## Break change

- Removed unused `cx.theme().panel` variable.
2025-02-03 17:03:15 +08:00
Jason Lee
85c6872e68
input: Use closest_index_for_position from GPUI. (#593) 2025-02-03 15:03:31 +08:00
Jason Lee
8e931bd862
list: Avoid duplicate active item background. (#594) 2025-02-03 14:55:51 +08:00
Jason Lee
576dda344c chore: Upgrade GPUI 2025/01/30 2025-01-30 11:06:29 +08:00
Jason Lee
7539e6d44c
input: Fix Input to vertical center the mask chars. (#590)
Close #467

Windows:

<img width="397" alt="image"
src="https://github.com/user-attachments/assets/0a185b42-1432-404a-b889-da1143706035"
/>

macOS:

<img width="510" alt="image"
src="https://github.com/user-attachments/assets/ed186552-862b-404e-96dc-b0f3a0b552d6"
/>
2025-01-30 10:54:02 +08:00
Jason Lee
43f529c6d2
input: Add to support move, select and delete by word. (#591)
Close #466 

https://github.com/user-attachments/assets/48cda905-f2bf-4896-b3ae-08b7cd61467d
2025-01-30 10:47:11 +08:00
Jason Lee
6fa1888ee6
chore: Upgrade for GPUI API changes. (#589) 2025-01-29 16:49:17 +08:00
Jason Lee
d2ff8177ec
chore: Remove unused refactor.sh. (#588) 2025-01-27 10:58:24 +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
8d0773fc62 chore: Remove typo println debug info in Input. 2025-01-27 03:54:06 +08:00
Jason Lee
e658aeee96
table: Improve sort icon color and fix stripe row display. (#578)
- Improve sort icon color:

<img width="139" alt="image"
src="https://github.com/user-attachments/assets/6374c26a-4555-4735-953b-dbd961fe5b31"
/>

- Avoid duplicate border when enabled fixed column.

<img width="587" alt="image"
src="https://github.com/user-attachments/assets/6e186d29-5d8a-404e-b160-20c2af6a16fa"
/>


TODO

- [x] The extra rows not show when `stripe` is true.
2025-01-26 16:25:34 +08:00
Jason Lee
649e765729
story: Add TitleBar to examples. (#586) 2025-01-26 15:07:34 +08:00
Jason Lee
71de5dd882
input: Fix position cursor in multi-line mode. (#583)
Close #581

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

https://github.com/user-attachments/assets/c69d098e-d2cb-4053-b739-6c7dd666e769
2025-01-26 14:12:08 +08:00
Jason Lee
852ce923ae
input: Update carret style. (#585)
- 1px width.
- Add `cx.theme.carret` variable for color and default use foreground
color.
- Reduce height to match with font size.


https://github.com/user-attachments/assets/d16a51eb-2c9a-4586-8b0d-67922a738002
2025-01-26 14:11:51 +08:00
Jason Lee
cd613db6d6
number_input: Improve NumberInput to better handle mouse down position cursor and fix sizable API. (#582)
Close #579 

- Leave some space before the Input to support mouse down to position
cursor at start of line.
- Fix to match with size appearance.
- Keep padding left and right to Input, even setup `appearance: false`.

## Break Changes

- The `xlarge`, `large`, `small`, `xsmall` ... method has been moved to
use `ui::Sizable` trait to same as other component.
2025-01-24 23:39:19 +08:00
Jason Lee
68de692290
input: Fix to position cursor at correct offset on mouse down or select. (#580)
Ref: https://github.com/zed-industries/zed/pull/23603

---

## TODO

Here still have a little bug in multiple lines and soft wrapped line.
Only the first line can get correct position, the wrapped line is always
got the offset +1, so the first char of that soft wrapped line, we can't
position the cursor at the first.
2025-01-24 22:57:24 +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
86db990b51
chore: Add #[inline] to util methods. (#576) 2025-01-24 15:34:57 +08:00
Floyd Wang
7aade44e7a
dock: Fix the tab panel cannot fill the entire height (#575)
## Before
<img width="411" alt="image"
src="https://github.com/user-attachments/assets/8801361d-20fd-4ba5-8b9e-bb18f6e8cc5a"
/>

## After
<img width="410" alt="image"
src="https://github.com/user-attachments/assets/91975382-5ed1-45a4-acd2-a131d2a162f5"
/>
2025-01-24 15:28:51 +08:00
Jason Lee
878a51e5a9
example: Split single examples. (#574)
```bash
cargo run --example table
cargo run --example list
```
2025-01-24 11:13:24 +08:00
Jason Lee
1dba2b6c70
input: Fix mouse click to position cursor to before of the char. (#572) 2025-01-23 20:46:52 +08:00
Jason Lee
77badb5799
radio: Add RadioGroup. (#571)
<img width="1265" alt="image"
src="https://github.com/user-attachments/assets/7ff51cb8-0aad-4d7d-a80a-e97c572c468a"
/>
2025-01-23 20:13:01 +08:00
Floyd Wang
1ff84a9943
popup_menu: Add max_h to set the height of menu (#570) 2025-01-23 18:43:34 +08:00
Jason Lee
e03a0d4f4e
chore: Fix Switch, Radio, Checkbox to use inline layout. (#569) 2025-01-23 18:05:32 +08:00
Floyd Wang
07b12b726c
number_input: Do not trigger step event when the input is disabled (#568) 2025-01-23 16:31:33 +08:00