Commit graph

1210 commits

Author SHA1 Message Date
Jason Lee
f35d0c5832 Bump v0.4.0-preview3 2025-11-14 18:42:40 +08:00
Floyd Wang
542346f3c2
number_input: Improve style details (#1606)
| Before | After |
| - | - |
| <img width="401" height="120" alt="SCR-20251114-pmci"
src="https://github.com/user-attachments/assets/75e3936c-1366-4ab1-a70a-164c47826002"
/> <img width="402" height="120" alt="SCR-20251114-pmef"
src="https://github.com/user-attachments/assets/224ca715-4131-4be5-ae4f-d70708463469"
/> | <img width="395" height="120" alt="SCR-20251114-plul"
src="https://github.com/user-attachments/assets/4b68c697-74da-4618-8f1a-fff57273378d"
/> <img width="397" height="118" alt="SCR-20251114-plwi"
src="https://github.com/user-attachments/assets/94d30c02-19e2-4fd7-916e-6e15d100c331"
/> |
2025-11-14 18:01:40 +08:00
Nico Gründel
78efbfdd7b
resizable, dock: Improve Panel adjust size logic on layout changed. (#1588)
This is a follow up to #1560 I noticed a couple small issues with
resizable panels and their use in docks after experimenting a lot:
- Sometimes the resizable group would take about ~500ms to update after
a resize. This was caused by the `StackPanel` not getting notified and
therefore not redrawn when the `ResizableState` was notified, as well as
the notify in `adjust_to_container_size` not actually firing properly.
The latter was fixed by defering the notify, though I'm still not quite
sure why that is necessary.
- In a couple of places, the total size all the panel missmatches the
container size, causing small glitches the first time a panel is
resized. Update the code in those places to properly adjust all the
panel sizes so they match the container size.

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-14 16:12:59 +08:00
Jason Lee
29fbdd371b
table: Split TableState to state.rs (#1599) 2025-11-14 14:08:29 +08:00
Floyd Wang
70fa330748
plot: Rename Label and Axis include Plot prefix (#1597)
## Breaking changes

```diff
- Label::new()
+ PlotLabel::new()

- Axis::new()
+ PlotAxis::new()
```

This is to avoid naming conflicts with `gpui` and `gpui-component`.
2025-11-14 11:49:07 +08:00
Jason Lee
69b21142dc
root: Improve new method argument to use into <AnyView>. (#1594) 2025-11-14 11:02:44 +08:00
Andreas Johansson
cf6d6b71a3
input: Fix x offset resetting for single line inputs (#1591)
Fixes #1589

Before:

https://github.com/user-attachments/assets/ae1dd1c4-de97-4336-94ab-e545a1e97047

After:

https://github.com/user-attachments/assets/62b5cf08-0782-426e-b2ee-dc018f140149

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-14 01:56:10 +00:00
Jason Lee
6d0ff7b335 date_picker: Fix duplicate popover paddings. (#1587) 2025-11-13 18:59:40 +08:00
Nico Gründel
df57b0b847
dock: Add a way for Panels to track the tab bar they belong to (#1580)
Currently, there is no good way for a Panel in a dock to e.g. add a tab
to its own tab bar. This is especially annoying as the state in
DockArea::items isn't synced to the underlying views, meaning the
`DockArea::add_panel` function will do nothing after first splitting the
panel, and then deleting the only element in the first part of the
split.


https://github.com/user-attachments/assets/2c61f2f0-9b1c-4154-8a53-b917335b94f0

This pull request adds a function that is called when a PanelView is
added to a tabbar via `add_panel` or `insert_panel_at` or when it is
removed via `detach_panel`.

This allows for entities that implement Panel to keep track of and
directly access the tab bar they belong to, and for example add new
panels to it through buttons in the dropdown menu or the top right of
the tab bar.
2025-11-13 18:02:05 +08:00
Jason Lee
a176408d81
Revert "root: Render overlays inside Root element by default. (#1570)" (#1584)
Revert #1573, #1570
2025-11-13 13:37:05 +08:00
Nico Gründel
a19826af2b
dock: Don't close tab via action when it can't be closed via context menu (#1581)
Right now the last tab can be closed via the keyboard action, even
though it's explicitly not allowed to be closed via the context menu.
This can result in an invalid app state. This pull request takes the
same check that's currently done to decide whether the close button
should be drawn in the context menu, and adds it to the close action.
2025-11-13 10:30:37 +08:00
chulingera2025
d4c4b9ad37
input: Avoid blocking vertical scroll events in single-line mode (#1562) (#1572)
Fixes #1562

  ## Problem
Single-line input fields were blocking all scroll wheel events,
preventing parent containers from handling vertical page scrolling.

  ## Solution
  - Check if input is in single-line mode and scroll is purely vertical
  - Allow vertical scroll events to propagate in single-line mode
  - Only stop propagation when scroll offset actually changes

  ## Behavior
  - Single-line inputs: vertical scroll passes through to parent
  - Multi-line inputs: all scroll behavior unchanged
  - Horizontal scrolling still works in both modes
2025-11-13 10:19:52 +08:00
Nico Gründel
3ef1ce3d3e
slider: Remove thumb tooltip (#1582) 2025-11-13 08:33:37 +08:00
Moulberry
c62bb8b6a1
notification: Fix close animation not working when closed from content (#1578)
Currently, if dismiss is called from the content_builder or
action_builder, the closing animation doesn't play.

This is because the callback happens after the `closing` variable is
set, so the animation will only start on the next frame, (and for some
reason notify() doesn't trigger another frame?).

This change makes it so that the content_builder is called first, so the
closing animation starts playing immediately on the same frame.

This also adds a check to dismiss to prevent spawning unnecessary
futures if it is called multiple times
2025-11-13 00:12:01 +08:00
ihavecoke
f2ffece9fb
tiles: Add auto-snap support for tiles panel to top and left edges (#1577) 2025-11-12 22:09:39 +08:00
Nico Gründel
5de9a24654
resizable: Improve to avoid panels from improperly resizing on container resizing. (#1560)
This pull request changes the internal behavior of the resizable panel
to get rid of some weird behavior with many panels and resizing.

Previously, when having multiple panels and dragging them into each
other, panels that shouldn't be affected got improperly resized:


https://github.com/user-attachments/assets/20d280c0-8a51-4e96-9c4a-3ade3deaca02

This pull request completely fixes this behavior:


https://github.com/user-attachments/assets/7c207dd8-d0a0-47d3-8d9e-c7127f43fa73

In addition, dragging the container smaller and larger again wasn't
idempotent:


https://github.com/user-attachments/assets/ca54b039-fd79-4fa8-87cf-590c06dd2c18

This is also fixed by this pull request, replacing the behavior with
more intuitive behavior, keeping the fractional size of all panels
constant:


https://github.com/user-attachments/assets/365d0a99-fd4b-4948-bc1b-bafdd826394a


https://github.com/user-attachments/assets/b208b34f-18e7-42a4-825a-9dad421b7ad3

If desired, it would also be easy to only change the size of the panels
that don't have a default size set when the container changes size.

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-12 21:18:05 +08:00
Jason Lee
1074f78fb0
root: Fix Root use text size may override default text color. (#1576) 2025-11-12 19:05:30 +08:00
Jason Lee
3500e5d5bc
label: Fix Label highlight may crash of not a char boundary. (#1574) 2025-11-12 10:19:43 +00:00
Jason Lee
cbd4346b87
root: Impl Styled for Root. (#1573) 2025-11-12 17:57:15 +08:00
Jason Lee
a2c16bfae6
popover: Revert defer_to focus on Popover open. (#1571)
Revert #1559 added defer to focus.

Removed the behavior of focus back to was focused handle on close
Popover, this is not correct for Popover.
2025-11-12 17:29:22 +08:00
Jason Lee
f26f01909e
root: Render overlays inside Root element by default. (#1570)
## Break Change

- The `Root::render_notification_layer`, `Root::render_sheet_layer`,
`Root::render_dialog_layer` has been removed, we don't need it now, the
Root element has default rendered them.
2025-11-12 08:04:54 +00:00
Jason Lee
f88b547b70 Bump v0.4.0-preview2 2025-11-12 15:16:49 +08:00
Jason Lee
214d3f6622
notification: Add &mut Self to content and action method. (#1569) 2025-11-12 15:10:42 +08:00
ihavecoke
e97689f12c
chore: Dependency gpui-macros/inspector to inspector features (#1568) 2025-11-12 15:10:13 +08:00
Jason Lee
b3c0188940
context_menu: Fix ContextMenu to cover parent element area. (#1566)
Close #1541
2025-11-12 06:19:52 +00:00
ihavecoke
838fd6411a
webview: Add inspector feature to enable WebView developer tools (#1564) 2025-11-12 11:11:18 +08:00
Jason Lee
a185d8ed24
menu: Fix #1545 Popover change broken submenu click in dropdown menu. (#1563)
This bug was caused by #1545.
2025-11-11 22:18:26 +08:00
Jason Lee
3cd94ea0be
popover: Fix click trigger to close popover. (#1559) 2025-11-11 21:14:56 +08:00
Jason Lee
eef8abaa15
popover: Fix #1545 incorrect to sync on_open_change to state. (#1557) 2025-11-11 18:41:23 +08:00
Floyd Wang
fbc3a6e4f4
form(field): Fix label line break not working (#1558) 2025-11-11 10:36:10 +00:00
Jason Lee
2dbfba3490
popover: Improve Popover API. (#1545)
- Add `open`, `on_open_change` method to control open state.
- Add `default_open` method.

## Break Change

This PR to rewrite the API of Popover API to make it easy to use. 

- The `content` method now can receive an element directly.

```diff
- .content(|window, cx| {
-     cx.new(|cx| {
-         PopoverContent::new(window, cx, |_, _| {
-             div().child("This popover content.")
-         })
-     })
- })
+ .content(|state, window, cx| {
+     div().child("This popover content.")
+ })
```

- And you can also just use `child` and `children` to add child
elements.

```rs
Popover::new("my-popover")
    .trigger(Button::new("trigger").label("Open Popover"))
    .child("This popover content.")
```

- Removed `PopoverContent`, and changed `Popover` default paddings to
`p_3`.
2025-11-11 17:45:30 +08:00
Floyd Wang
13f25bc4a9
progress: Fix incorrect border radius (#1555)
| Before | After |
| - | - |
| <img width="848" height="274" alt="SCR-20251111-nduc"
src="https://github.com/user-attachments/assets/e04590a3-6154-41f6-9763-a7de7db2301e"
/> | <img width="821" height="272" alt="SCR-20251111-ndpb"
src="https://github.com/user-attachments/assets/04ba2e28-0c7f-4205-b8b5-cc79b661ecef"
/> |
2025-11-11 06:53:50 +00:00
ihavecoke
1a5dd46acd
tiles: Add to support panel auto-snap while drag movement (#1552)
Before: 


https://github.com/user-attachments/assets/b9171a47-e21b-4132-8b13-7d9bf06f083a

After:


https://github.com/user-attachments/assets/e06c8353-41f8-4124-b9f4-1c44e462ab72
2025-11-11 11:56:58 +08:00
Floyd Wang
74f23bfca8
tab: Refactor creation to use builder pattern (#1553)
## Breaking change

```diff
- Tab::new("Account")
+ Tab::new().label("Account")
```

We can currently create a tab item without a label, such as only an
icon.
2025-11-11 10:35:00 +08:00
FlyingYu
9228dbfb13
editor: Improve double-click for word selection (#1491)
Close #876 

https://github.com/user-attachments/assets/bb04b3ab-05ca-456c-bb14-b812a846701d

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-10 05:02:02 +00:00
Nico Gründel
2cba6e8be9
slider: Add option to choose between linear and logarithmic scale (#1543)
Adds the ability to choose between a linear and a logarithmic scale for
the slider. A logarithmic scale is the right and intuitive choice for
many different slider applications. Building this right into the
component has two advantages:
- The user doesn't have to convert at every point where they might use
or update the slider value
- On a logarithmic scale, the distance between steps varies over the
sliders range. This implementation respects that

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-10 02:56:09 +00:00
Moulberry
a4d792f121
button_group: Fix overriding button click when no on_click (#1546)
When `on_click` is not specified on the button group, this PR allows for
specifying on_click on each individual button.

e.g.

```rs
let buttons = ButtonGroup::new(("buttons", index)).layout(Axis::Vertical)
    .child(Button::new(("install", index)).label("Install").icon(download_icon).success().on_click(move |_, _, cx| {
          // Install
    })
    .child(Button::new(("open", index)).label("Open Page").icon(IconName::Globe).info().on_click(move |_, _, cx| {
         // Open page
    }));
```
2025-11-10 09:43:25 +08:00
Nico Gründel
b899100d09
slider: Improve Slider interaction to click on bar to drag. (#1544)
This pull request adds a drag event to the slider bar itself, analogous
to the drag handles, in case the slider is not a range slider. This
allows for a more intuitive interaction with the slider, where one can
click and drag on any part of the slider bar container.

https://github.com/user-attachments/assets/4d41ba10-2992-4a42-beb6-0bc376185c5e

This doesn't change the behavior for range sliders, as it's ambiguous
which slider should be dragged in case the event starts between the
sliders. Though if desired, it wouldn't be difficult to implement the
same behavior for clicks below the start or above the end slider.
2025-11-09 11:31:21 +08:00
Jason Lee
a2c55dda46
form: Rename FormField to Field. (#1539) 2025-11-07 18:43:01 +08:00
Jason Lee
945db0be56
dialog: Rename Modal to Dialog. (#1538)
## Break Change

- Renamed `Modal` to `Dialog`.

```diff
- window.open_modal(...)
+ window.open_dialog(...)

- window.close_modal(...);
+ window.close_dialog(...);
```

- Renamed `show_close` method to `close_button` in Dialog.
```diff
- .show_close(false)
+ .close_button(true)
```
2025-11-07 17:25:55 +08:00
Moulberry
c78811c4b9
button_group: Add vertical (#1537)
Adds a vertical option to the button group

Also added an example of the vertical button group to the story

Also fixed button rounding only working when both tl/bl and tr/br are
both set, now they can be set individually

I'm not sure if the justify_center in `.when(self.vertical, |this|
this.flex_col().justify_center())` is needed, but I added it to match
the behaviour of `.items_center()` when the flex direction is row.
2025-11-07 16:48:14 +08:00
Jason Lee
34c589d45b Bump v0.4.0-preview1. 2025-11-06 22:27:26 +08:00
obito
80cdf6a44c
theme: Allows to use alpha color for active_border but at least 0.3. (#1531)
Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-06 22:23:55 +08:00
Moulberry
7f8eb28cfa
table: Fix missing border on first frame (#1533)
After all the adjustments, the original issue that
https://github.com/longbridge/gpui-component/pull/1505 was trying to fix
reappeared.

The fix is simple: don't consider the table to be filled if the height
is zero.
2025-11-06 22:01:55 +08:00
Moulberry
faee91eda4
table: fix row border missing on first frame (#1505)
Currently, the bounds are zero on the first frame.
Therefore, the extra_rows_count will always be zero on the first frame.
This causes rendering issues for row border & row stripes.

Unfortunately, I don't know how to get the correct height on the first
frame to fix the row stripes.

However, an easy fix for the row border rendering issue is to disable
the table_is_filled check. The check is problematic anyways since the
border affects the height of the element.

I attached a video showing the issue, the border doesn't render on the
first frame and the height of the element also shifts due to the border:


https://github.com/user-attachments/assets/b154c686-cd9c-4b6b-8ba6-c79640297abc

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-06 21:15:13 +08:00
Jason Lee
97ba18fce9
modal: Adjust close button position. (#1532) 2025-11-06 13:10:49 +00:00
Jason Lee
34aa68ad35
table: Fix Table stripe mode overflow scroll. (#1530)
Ref #1505
2025-11-06 19:11:28 +08:00
Floyd Wang
f33d112819
button: Remove duplicate disabled style (#1529) 2025-11-06 18:47:59 +08:00
Jason Lee
80689264e2
sheet: Rename Drawer to Sheet. (#1527)
## Break Change

- Renamed `Drawer` to `Sheet`, also renamed relative method contains
`drawer` to `sheet`.
- Renamed `ContextModal` to `WindowExt`.

```diff
- use gpui_component::drawer::Drawer
+ use gpui_component::sheet::Sheet

- use gpui_component::ContextModal
+ use gpui_component::WindowExt
```
2025-11-06 07:19:10 +00:00
Jason Lee
4dc10165fb
spinner: Rename Indicator to Spinner. (#1526)
## Break Change

- Renamed `Indicator` to `Spinner`.

```diff
- use gpui_component::indicator::Indicator;
+ use gpui_component::spinner::Spinner;
```
2025-11-06 11:36:39 +08:00