Commit graph

1422 commits

Author SHA1 Message Date
obito
c91d806057
tab: Allow tab item to fill remaining space. (#1654)
<img width="2766" height="1818" alt="image"
src="https://github.com/user-attachments/assets/f5c275f7-1165-4a0d-a24d-d35cefb64e2d"
/>
2025-11-21 11:49:30 +08:00
Floyd Wang
41d2b9808b
color_picker: Add radius on focus border (#1652)
| Before | After |
| - | - |
| <img width="143" height="51" alt="SCR-20251121-jwmj"
src="https://github.com/user-attachments/assets/69693a83-dbf8-44ea-b46e-bd88c3c2f1f3"
/> | <img width="135" height="45" alt="SCR-20251121-jvol"
src="https://github.com/user-attachments/assets/177a90fc-8400-4df7-9ee2-3b4f32633c4b"
/> |
2025-11-21 02:53:14 +00:00
Andreas Johansson
b6bf2d8c5e
menu: Use defer to avoid race conditions with click listeners (#1651)
When using `.context_menu` on a parent element, the
`window.on_mouse_event` would fire before, for example, the tables
`on_mouse_down` so it'd be like this:
1. First right click = no context menu, right_clicked_row is set
2. Second right click = context menu, but with the row from the first
click

Before: (Look at `Selected row`)  


https://github.com/user-attachments/assets/5eb89a00-f1ce-4423-b8d7-3ec61b848b83

After:


https://github.com/user-attachments/assets/10033ca4-4c2c-47b5-ace5-6ba745fcfee5

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-21 02:27:21 +00:00
Jason Lee
c8652f9010
setting: Add Settings component. (#1632)
https://github.com/user-attachments/assets/3c6315d9-1183-419c-bb17-a8f7ac0cf25c
2025-11-20 13:51:44 +00:00
Jason Lee
91de551ab0
ci: Update only release docs on tag push. (#1650) 2025-11-20 17:39:50 +08:00
Jason Lee
0a24925a7f Bump v0.4.1 2025-11-20 17:26:14 +08:00
Floyd Wang
d55125149b
list: Fix incorrect selected item background color (#1648)
It will mix `accent` and `list_active` before.
2025-11-20 16:46:57 +08:00
Jason Lee
b6dace13cc
theme: Fix Flexoki Light focus color. (#1647) 2025-11-20 13:37:43 +08:00
grubby
d251a9b08b
icon: Rework icons to make use of the IconNamed trait (#1640)
This makes use of the `IconNamed` trait and a blanked implementation to
convert anything that implements this to an `Icon`.

This allows for easily defined custom versions of `IconName`, while
minimally changing existing code (essentially only if you previously
made use of the `.path()` method on the `IconName` enum; this now
requires an import of the `IconNamed` trait).

# Example
```rust
use gpui_component::IconNamed;

pub enum IconName {
    Encounters,
    Monsters,
    Spells,
}

impl IconNamed for IconName {
    fn path(self) -> gpui::SharedString {
        match self {
            IconName::Encounters => "icons/encounters.svg",
            IconName::Monsters => "icons/monsters.svg",
            IconName::Spells => "icons/spells.svg",
        }
        .into()
    }
}

// this allows for the following interactions (works with anything that has the `.icon(icon)` method
Button::new("my-button").icon(IconName::Spells);
Icon::new(IconName::Monsters); 
```

If you want to directly "render" a custom `IconName` you must implement
the `RenderOnce` trait and derive `IntoElement` on the `IconName`.

```rust
use gpui::{IntoElement, RenderOnce};
use gpui_component::IconNamed;

#[derive(IntoElement)]
pub enum IconName {
    // The same as before
}

impl IconNamed for IconName {
    // The same as before
}

impl RenderOnce for IconName {
    fn render(self, _: &mut gpui::Window, _: &mut gpui::App) -> impl gpui::IntoElement {
        gpui_component::Icon::empty().path(self.path())
    }
}

// this allows for the following interaction
div()
    .child(IconName::Monsters)
```

Overall I think is an improvement to the existing way to do custom
`IconName` implementations.

I am unsure if this change should also be reflected in the documentation
on the section with "Icons & Assets", though I personally think it would
make sense to highlight this way to do custom versions of `IconName` as
it is considerably less involved than the current approach.

Closes #1627.

---------

Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-20 02:30:08 +00:00
Adriano Tumino
2e3387a76f
sidebar: Add to support disable state to sidebar item. (#1645)
Hello,
I added a disabled flag to turn off the SidebarmenuItem

<img width="735" height="528" alt="image"
src="https://github.com/user-attachments/assets/47f60476-004c-4fe5-9baf-519d16b93f93"
/>

---------

Co-authored-by: TUMINOA <adriano.tumino@leonardocompany.com>
Co-authored-by: Jason Lee <huacnlee@gmail.com>
2025-11-20 02:16:41 +00:00
Floyd Wang
65c5bae745
Update README
Removed note about adding dependencies via git.
2025-11-20 10:10:54 +08:00
Jason Lee
96c34a9fb0
sidebar: Improve Sidebar to allows caret icon to expand submenu. (#1642)
https://github.com/user-attachments/assets/7cd4ef52-e633-4db4-bdba-2912bba2120d
2025-11-19 05:39:24 +00:00
obito
9d11418bd1
select: Add render prop to customize item title display. (#1638)
Fixes #1410

## Problem

The `display_title` prop was overriding the default way dropdown option
titles are displayed, causing incorrect rendering of option titles.

**Expected behavior:**
<img width="716" height="944" alt="Expected dropdown display"
src="https://github.com/user-attachments/assets/38926731-32dd-4a16-9d08-7f2eed2c99a4"
/>

**Actual behavior:**
<img width="580" height="974" alt="image"
src="https://github.com/user-attachments/assets/d96b935a-ce4d-462c-a9ce-4995f5c8eeb5"
/>

## Solution

- Revert the `display_title` change that was causing the issue
- Add a `render` function to allow custom rendering of option titles
instead

This approach provides more flexibility for customizing option display
while preserving the default behavior.

cc @stippi
2025-11-18 20:30:37 +08:00
Jason Lee
01082f11d2
button: Add dropdown_caret option to show a caret icon to end of button. (#1637)
<img width="658" height="162" alt="image"
src="https://github.com/user-attachments/assets/7c233982-04c3-408c-8ae4-f672f8b135a3"
/>
2025-11-18 16:41:16 +08:00
Floyd Wang
44dc2c7f38
input: Use input border on the buttons (#1634)
| Before | After |
| - | - |
| <img width="268" height="114" alt="SCR-20251118-nasx"
src="https://github.com/user-attachments/assets/d66d4178-d6f9-4f00-b3ad-94d1aee3a262"
/> | <img width="268" height="112" alt="SCR-20251118-nazg"
src="https://github.com/user-attachments/assets/df1bdc1d-ee8b-4249-b301-4479145f393a"
/> |
2025-11-18 14:57:53 +08:00
Jason Lee
4f882a1b98
docs: Little adjust logo border and radius. (#1635) 2025-11-18 14:57:31 +08:00
Jason Lee
f8a7dd71bf
dropdown_button: Add more button option methods to DropdownButton. (#1633)
- Fix to not handle `dropdown_menu` when Button is disabled.
- Split a single DropdownButtonStory.
2025-11-18 14:31:14 +08:00
Floyd Wang
446831af33
chart: Add support to set stroke color on line chart (#1629)
Close #1625.

<img width="335" height="422" alt="image"
src="https://github.com/user-attachments/assets/f2235b42-9a3e-4ed7-88ae-b694ee579faf"
/>
2025-11-18 05:52:39 +00:00
Floyd Wang
ed92f63a9b
table: Use click event instead of mouse down event (#1622)
Fix the issue where clicking a button inside a table row can't stop the
click event from propagating to the table, causing the `td` element to
be selected unexpectedly.
2025-11-17 16:30:42 +08:00
Floyd Wang
db22454b3a
menu: Fix icon width to tidy indent in PopupMenuItem. (#1620)
Fix the issue of alignment after selection.

| Before | After |
| - | - |
| <img width="291" height="299" alt="image"
src="https://github.com/user-attachments/assets/ed1237dc-d4b9-4934-b2f1-1e5b558c757c"
/> | <img width="292" height="297" alt="SCR-20251117-kjik"
src="https://github.com/user-attachments/assets/200071c2-717e-4033-bf1a-906b43c77f19"
/> |
2025-11-17 11:32:14 +08:00
Jason Lee
6c4de54fa4
theme: Use font_family for all elements. (#1618)
Close #1613

- And add `mono_font_family` and `mono_font_size` for code editor.
2025-11-17 03:18:17 +00:00
Jason Lee
0a5c799aba
editor: Fix may crash on render indent guides. (#1619) 2025-11-17 03:17:06 +00:00
Jason Lee
672a80dcd8 docs: Remove index page warrning. 2025-11-17 10:22:01 +08:00
Jason Lee
aa4f896b20 Bump v0.4.0 2025-11-17 10:05:08 +08:00
Andreas Johansson
0e8b8761a4
docs: Fix theme_name type (#1614) 2025-11-17 09:56:24 +08:00
Jason Lee
7de69d1dd1
assets: Move assets files into crates/assets folder for crate publish. (#1609) 2025-11-14 19:00:29 +08:00
Jason Lee
ec3eda60e0
docs: Fix button gap. (#1608) 2025-11-14 18:46:23 +08:00
Jason Lee
f35d0c5832 Bump v0.4.0-preview3 2025-11-14 18:42:40 +08:00
Jason Lee
83dddfa987
assets: Fix #1605 embed assets for crate. (#1607) 2025-11-14 10:34:59 +00: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
2a98628b5e
docs: Improve docs to use variable version from toml. (#1603) 2025-11-14 16:10:48 +08:00
Jason Lee
37d1678b6f
assets: Add gpui-component-assets crate. (#1601) 2025-11-14 15:03:26 +08:00
Jason Lee
724ccd64a7
chore: Add ui folder to Cargo default-members. (#1600)
This to help `cargo test` default will test `ui` and `story`.
2025-11-14 06:16:03 +00:00
Jason Lee
29fbdd371b
table: Split TableState to state.rs (#1599) 2025-11-14 14:08:29 +08:00
Jason Lee
1375c8cd70
ci: Update CI to only run docs test when only docs changed. (#1596) 2025-11-14 11:55:28 +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
993f9b20ae
example: Follow up #1594 missed changes. (#1595) 2025-11-14 11:22:55 +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