Commit graph

624 commits

Author SHA1 Message Date
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
Jason Lee
a89e2430d3
form: Add Form and FormField. (#565)
<img width="899" alt="image"
src="https://github.com/user-attachments/assets/842dac65-36c3-4f3a-b55a-59d204d9a93c"
/>
<img width="901" alt="image"
src="https://github.com/user-attachments/assets/616b7a3a-4a84-4d27-b554-63ebd5213ad7"
/>
2025-01-23 16:09:50 +08:00
Jason Lee
4028f46cb9
date_picker: Avoid focus back to DatePicker, when dismiss picker by clicked on Input. (#567) 2025-01-23 11:52:58 +08:00
Jason Lee
78ce573a52
list, table: Refactor to control loading by use delegate. (#562)
- Add `loading` method to `ListDelegate` and `TableDelegate` to control
loading view display.

## Break Changes

- Remove `loading`, `set_loading` method from List and Table, use
`loading` method in delegate instead.
2025-01-21 20:33:37 +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
73c92f3a6b
input: Fix crash cause by incorrect selected range. (#560)
The `selected_range` should be UTF-8.
2025-01-21 11:49:36 +08:00
Jason Lee
493acdefab story: Fix story and merge checkbox, radio to switch story. 2025-01-21 10:43:10 +08:00
Jason Lee
20feab5f40
modal: Add confirm Modal with default Ok, Cancel buttons. (#558)
<img width="581" alt="image"
src="https://github.com/user-attachments/assets/ad53fb63-f3be-41e6-90c0-f03cba48c4db"
/>

- Added `overlay_closable` method to Modal to control overlay click to
close modal.
- Added `on_ok`, `on_cancel` callback method.
- Added `confirm` to setup to use default confirm style (With a Ok,
Cancel button).

## Break Changes

- The `footer` method has been changed to with a fn not a element.
2025-01-20 17:42:05 +08:00
Jason Lee
ad04b699fc
clipboard: Add value_fn to get copy value with callback to Clipboard. (#557) 2025-01-20 15:54:27 +08:00
Jason Lee
355dfa5556
slider: Add vertical and reverse support to Slider. (#556)
- Fix to support stop at any position.
- Fix click bounds.
2025-01-20 15:22:28 +08:00
Floyd Wang
06e9b1a25c
dropdown_button: Add compact style (#555) 2025-01-20 13:49:42 +08:00
Floyd Wang
bd3cdd7167
dropdown_button: Add more style preferences (#554) 2025-01-17 16:24:46 +08:00