Commit graph

66 commits

Author SHA1 Message Date
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
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
9675f1e02b
dock: Add cache to panel view. (#600) 2025-02-05 17:23:40 +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
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
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
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
Floyd Wang
ceba66c22d dock: Add PanelControl for pinning the toolbar button (#537)
<img width="387" alt="image"
src="https://github.com/user-attachments/assets/b3d3f2a8-dc4e-49e6-8e82-e7f551d70bc7"
/>
2025-01-09 19:18:59 +08:00
Jason Lee
de42cc46a7
panel: Update Panel toolbar_buttons method to use ViewContext<Self>. (#536)
## Break changes

The `toolbar_buttons` trait method in Panel has been changed:

```diff
- fn toolbar_buttons(&self, cx: &WindowContext) -> Vec<Button>
+ fn toolbar_buttons(&self, cx: &mut ViewContext<Self>) -> Option<Vec<Button>>
```
2025-01-09 16:49:35 +08:00
Jason Lee
6851e53183
dock: Fix to active prev tab, when current tab is invisible. (#517) 2024-12-27 11:58:19 +08:00
Jason Lee
1a4ee348f8
dock: Add visible method to Panel trait to control panel visible. (#503)
Closes #502 #499 

## Added

- Add `visible` method to `Panel` trait, if return false this panel will
disappear.

## Break changes

- Renamed `closeable` to `closable`.
- The `title_style`, `closable`, `zoomable` in `Panel` trait have been
change `cx: &WindowContext` to `cx: &AppContext`.
2024-12-20 10:21:21 +08:00
Jason Lee
4b211bfe21
panel: Add set_active, set_zoomed method to Panel trait. (#501)
It will called when the panel active, zoom state changed.
2024-12-19 10:29:58 +08:00
Jason Lee
d4819b34aa
chore: Update GPUI with AnchorCorner renamed to Corner. (#497)
Ref https://github.com/zed-industries/zed/pull/22119
2024-12-18 18:02:47 +08:00
xda
5874c6974f
tiles: Add Tiles (#435)
## Break Changes

- Renamed `DockItemState` to `PanelState`.
- Renamed `DockItemInfo` to `PanelInfo`.
- Update `cx` type from `WindowContext` to `AppContext` for Panel trait
`panel_name` method.

## TODO

- [ ] Support merge panels into TabPanel.
- [ ] Support split panels into Tile.

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2024-12-16 20:33:14 +08:00
Jason Lee
a5a72fcb5a
panel: Avoid render panel when TabPanel is collapsed. (#492)
Close #488

- Fix `collapsed` sync to `TabPanel` when load state.
2024-12-13 11:23:00 +08:00
Jason Lee
d701baed28
dock: Do not active tab when drop to TabPanel right empty area. (#491) 2024-12-12 19:18:42 +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
a941c7b32e
panel: Fix toggle button border overlap with first tab. (#446)
<img width="202" alt="image"
src="https://github.com/user-attachments/assets/ab7b9865-52be-4bdb-bade-9b0c47e83bb7">
2024-11-27 23:00:25 +08:00
Jason Lee
36dcc53824
dock: Add set_dock_collapsible to support setting the Docks to be collapsible or not. (#445)
Close #442 

In this case, the left Dock is not collapsible:

<img width="1165" alt="image"
src="https://github.com/user-attachments/assets/21422cdd-d686-4931-9285-925b8e8d3343">
2024-11-27 21:34:44 +08:00
Jason Lee
7fe91e4e12
dock: Add panel_style to support always show TabBar. (#444)
Close #441 

```rs
DockArea::new(MAIN_DOCK_AREA.id, Some(MAIN_DOCK_AREA.version), cx).panel_style(PanelStyle::TabBar)
```

<img width="1433" alt="image"
src="https://github.com/user-attachments/assets/2013188e-990b-4709-ac7e-43c2de8bc895">
2024-11-27 21:34:27 +08:00
Jason Lee
142d092867
dock: Add add_panel method to add panel to DockArea. (#440)
Ref #438 

https://github.com/user-attachments/assets/93b40aed-39f3-4d16-a442-13aa7a931895
2024-11-27 11:27:04 +08:00
Jason Lee
ea011d11d6
dock: Hide toggle button when side dock is not exist. (#431) 2024-11-22 15:38:47 +08:00
xda
d937a90db6 dock: Render toggle dock buttons inside the Panels. (#414)
Co-authored-by: Jason Lee <huacnlee@gmail.com>
2024-11-22 14:41:04 +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
Jason Lee
079cc35c48
dock: Limit drag move or close when tab panel or parent only have 1 panel. (#418) 2024-11-14 18:33:49 +08:00
Jason Lee
b29f4fb0e6
dock: Add set_locked to lock dock area to limit split, move panels. (#417)
But still allow to resize panels.
2024-11-14 15:47:26 +08:00
Jason Lee
7edbdd01f4
dock: Remove the inside toggle dock button in Dock to reduce complex and add dock::ToggleButtons. (#415)
Draft https://github.com/longbridgeapp/gpui-component/pull/414 to keep
old code.

<img width="1712" alt="image"
src="https://github.com/user-attachments/assets/749a5712-7ec4-43a8-a89d-595a7644a7ec">
2024-11-14 12:05:58 +08:00
xda
47688a8af2
dock: Generalize Dock's panel to accommodate DockItem (#412)
![2024-11-13 23 01
30](https://github.com/user-attachments/assets/dbb92e6b-ac5d-47c7-9a78-4029b414cdfc)
2024-11-14 12:00:23 +08:00
Jason Lee
5149b8a714
panel: Add toolbar_buttons to extend button to panel. (#406)
<img width="635" alt="image"
src="https://github.com/user-attachments/assets/42dc1cb4-a1dd-43c6-8fc3-9d404e86cb85">
2024-11-10 23:17:34 +08:00
Jason Lee
ca44ca6311
chore: Update to use WeakView for avoid dependency issue. (#391) 2024-11-04 16:36:21 +08:00
Jason Lee
a798bd81c6
chore: Fix typos. (#364) 2024-10-18 14:30:24 +08:00
Jason Lee
6a5fff889e
dock: Disallow move panel when it is zoomed in. (#346)
Closes #342
2024-10-15 14:52:40 +08:00
Jason Lee
5fd2ebf522
panel: Always not show active tab style, when the dock is collapsed. (#335)
## Before

<img width="249" alt="image"
src="https://github.com/user-attachments/assets/2dfee593-1a07-4b75-913b-d2e17decb67a">

## After

<img width="271" alt="image"
src="https://github.com/user-attachments/assets/20752d04-1f25-498c-8e6e-4ff0f21401bf">
2024-10-14 10:06:20 +08:00
Jason Lee
5915618928
dock: Fix zoom support for side dock panel. (#327)
- Fix emit `PanelEvent::LayoutChanged` when panel resized.
2024-10-10 15:16:16 +08:00
Jason Lee
0220cf8cc6
dock: Add version to DockArea to allow us check the persisted state is need to update. (#323) 2024-10-08 20:46:12 +08:00
Jason Lee
45d4b445ec
panel: Toggle to zoom out when close a panel. (#322) 2024-10-08 18:09:41 +08:00
Jason Lee
e1e66e8f07
dock: Fix toggle button check will stack overflow bug. (#312)
Continue #297 #309

```
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
[1]    45068 abort      cargo run
```
2024-10-04 15:00:00 +08:00
Jason Lee
494e6d15f3
dock: Fix incorrect toggle button shown, when there is not have left or right dock. (#297) 2024-10-02 23:00:26 +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
6f1be83b6e
dock: Add left, bottom, right fixed dock and support toggle. (#291)
- Improve TabPanel to support control closable.

## Demo 


https://github.com/user-attachments/assets/dcf8cde3-61ee-42f6-be93-76f10fc8cf34
2024-10-02 17:42:52 +08:00
Floyd Wang
c5b4505560
feat(button): Remove track_focus (#282) 2024-09-27 14:39:48 +08:00
Jason Lee
2d6f478512
dock: Add zoomable support to Panel. (#269) 2024-09-24 22:37:29 +08:00
Jason Lee
d33b4b2ea0
dock: Fix panel zoom when it split and added to other StackPanel. (#245) 2024-09-16 10:18:04 +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
ce87c3a001
modal: Improve Modal and Panel focus handle. (#238)
- modal: Improve modal focus take, when modal close, make sure focus
back.
- modal: Fix hover close button will cross to back modal on multiple
modal layer.
- panel: Add focus handle to Panel and TabPanel.
- panel: Update title method to return `AnyElement`.
2024-09-12 19:51:33 +08:00
Jason Lee
840a54850a
Update register_panel to use trait object Fn. (#229) 2024-09-09 19:19:27 +08:00
Jason Lee
bf134b2ff9
Add to support dump/load Dock layout. (#226) 2024-09-09 13:30:22 +08:00
Jason Lee
adf6f70185
dock: Define a better way to init Dock layout. (#218) 2024-09-05 19:33:32 +08:00
Floyd Wang
d6015f636c
panel: Support custom style for the panel title (#220) 2024-09-05 11:36:59 +08:00