Commit graph

87 commits

Author SHA1 Message Date
Jason Lee
00e5385878
input: Add h, h_full to Input for multi-line mode. (#642)
Close #641
<img width="1712" alt="image"
src="https://github.com/user-attachments/assets/9cbe090c-a5d7-4929-98db-5f71349fe559"
/>
2025-02-25 16:17:39 +08:00
Jason Lee
75212c3aba
chore: Fix focusd_border typo in #635 (#637) 2025-02-17 17:29:40 +08:00
Jason Lee
4c554580c9
chore: Rename outline styled method to focused_border. (#635)
This change to avoid conflict with `outline` method in Button.

## Break changes:

- The `outline` method in `StyledExt` now renamed to `focused_border`.
2025-02-17 14:34:54 +08:00
Jason Lee
d96b4b44d2
number_input: Fix button margin. (#634) 2025-02-17 14:29:33 +08:00
Jason Lee
0ebedbe79f
chrome: Refactor state fields to remove is_ prefix. (#627) 2025-02-14 15:20:18 +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
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
85c6872e68
input: Use closest_index_for_position from GPUI. (#593) 2025-02-03 15:03:31 +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
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
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
1dba2b6c70
input: Fix mouse click to position cursor to before of the char. (#572) 2025-01-23 20:46:52 +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
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
Floyd Wang
0312e47554
input: Move number input into input (#549) 2025-01-17 10:07:41 +08:00
Jason Lee
8dca96469e
chore: Update GPUI with MSAA and PathBuilder. (#548) 2025-01-15 16:52:03 +08:00
Jason Lee
a0f6b48eff
chore: Update GPUI 2025/01/14 (#547) 2025-01-14 19:21:04 +08:00
xda
da4c188bc6
input: Support Cmd+Up, Cmd+Down, Cmd+Shift+Up, Cmd+Shift+Down (#531)
![2025-01-06 22 28
27](https://github.com/user-attachments/assets/16a20c24-b8d6-4d43-bfa0-6b2dd0d80ffc)
2025-01-06 23:02:40 +08:00
Jason Lee
e012eb6d07
history: Add unique mode to keep unique item in History. (#529) 2025-01-06 19:19:36 +08:00
xda
8b89b5ba7c
input: Fix TextInput cursor getting stuck on Down key press (#526)
## Before

![2025-01-03 13 55 08
before](https://github.com/user-attachments/assets/3714e316-289b-4426-b18a-23ac718c05e6)

## After

![2025-01-03 13 54 22
after](https://github.com/user-attachments/assets/5d82a864-6cda-4191-adee-26634ef93506)
2025-01-03 14:46:51 +08:00
xda
0cc6b90cde
input: Handle moving above the first line (#525) 2025-01-03 12:22:48 +08:00
Jason Lee
482a31fa19
input: Fix TextArea enter to newline not work and scroll to visible on move cursor. (#523)
Close #494

- Fix enter to newline.
- Fix to ensure scroll on move cursor or enter.
2024-12-31 19:19:14 +08:00
xda
6a310c618f
input: Up, Down to keep the same column if it possible (#500)
Fix #468
2024-12-20 18:21:22 +08:00
Jason Lee
094611a2ae
input: Avoid handle up, down in Input single line mode. (#485) 2024-12-10 19:01:35 +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
9288dc91c2
input: Add to support multi-line Input. (#463) 2024-12-09 20:17:05 +08:00
Jason Lee
23f9352295
button: Rename ButtonStyle to ButtonVariant. (#460)
This is a breaking changes, we need refactor exist code by this:

- `ButtonStyled` -> `ButtonVariants`
- `.style` -> `.with_variant`
- `ButtonStyle` -> `ButtonVariant`
- `ButtonCustomStyle` -> `ButtonCustomVariant`
2024-12-03 19:22:28 +08:00
Jason Lee
0119c80120
input: Update GPUI and fix Input changes. (#437)
Ref https://github.com/zed-industries/zed/pull/20968
2024-11-26 21:41:34 +08:00
Floyd Wang
ea6ec8aa5d
ui: Add number_input (#433)
https://github.com/user-attachments/assets/ae6f4e48-b0fa-4f8c-bff5-809c70848b06
2024-11-25 19:32:56 +08:00
xda
14ca368be7
input: Ensure resizing the window doesn't force the cursor back into view (#370)
Fix #331

It is ensured that the scroll offset remains consistent during parent
container resizing, preventing the cursor from being forced back into
view unless the user interacts with the input, providing a more
consistent user experience in scenarios where automatic scrolling during
resizing is undesirable.

This behavior aligns with common text editors and input fields where
resizing the window doesn't force the cursor back into view.

![2024-10-21 20 27
00](https://github.com/user-attachments/assets/599ef72d-3ec8-4fe5-a26c-10263044db6f)
2024-10-21 20:01:49 +08:00
Jason Lee
41c64e2912
chore: Update controls detail. (#352)
- Better icon style in Input, Dropdown, DatePicker.
2024-10-16 17:51:39 +08:00
ihavecoke
20b9f9c0f2
input: Move caret to line start or end with selected content (#288)
Ref: https://support.apple.com/en-hk/102650

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2024-10-02 17:35:27 +08:00
Floyd Wang
c5b4505560
feat(button): Remove track_focus (#282) 2024-09-27 14:39:48 +08:00
Jason Lee
2a331fcb79
theme: Add shadow option to support toggle shadow for base controls, default: true. (#268)
- Add shadow to Button if it enabled.
2024-09-24 10:52:01 +08:00
Jason Lee
97e61a507b
otp_input: Fix OtpInput to stop_propagation on keydown. (#249) 2024-09-17 10:55:09 +08:00
Jason Lee
f77993082d
input: Update Input selection behavior to like OS input. (#247)
Revert old implementation

- https://github.com/huacnlee/gpui-component/pull/26
- https://github.com/zed-industries/zed/pull/14340

## Before


https://github.com/user-attachments/assets/52ce2e3a-3e1d-4ba2-af42-76b1df987404


## After


https://github.com/user-attachments/assets/9aa8cfe1-5928-4d20-b534-806140c7ee59

## The Input in the Browser



https://github.com/user-attachments/assets/c913248e-b1dc-46d6-a517-e1231e606171
2024-09-17 09:58:07 +08:00
Jason Lee
0e16d742bb
list: Add set_size method to List and fix input size in small dropdown. (#246) 2024-09-16 19:57:49 +08:00
Jason Lee
a8d4abea69
button: Improve ButtonGroup to add style, size methods. (#241)
- Add `ButtonStyled` trait to apply the style for Button and
ButtonGroup.
2024-09-13 12:00:47 +08:00
Jason Lee
3d8e7a9e54
Update GPUI and fix Input API changes. (#193) 2024-08-31 23:17:14 +08:00
Floyd Wang
ef49753d32
Improve dropdown disabled state (#192) 2024-08-30 15:26:56 +08:00