Commit graph

7 commits

Author SHA1 Message Date
Jason Lee
56fb93bca8
table: Add render_header method to support custom table header. (#1746)
Closes #1733

## Example

```rs
impl TableDelegate for MyTable {
    fn render_header(&mut self, _: &mut Window, _: &mut Context<TableState<Self>>) -> Stateful<Div> {
        div().id("header").h_10()
    }
}
```
2025-12-05 15:17:13 +08:00
Jason Lee
001b1795f1
table: Refactor TableDelegate to easy to access delegate. (#1712)
Closes #1610, #1583

Closes https://github.com/longbridge/gpui-component/discussions/1707

## Description

This change to improve the `TableDelegate` to have `&mut self` and
`Context<TableState<Self>>` to easy access delegate.

## Break Changes

- The argument types of `render_tr`, `render_td`, `render_th`,
`context_menu`, `render_loading`, `render_empty`,
`render_last_empty_col` in `TableDelegate` has been changed.

```diff
- fn render_th(&self, col_ix: usize, _: &mut Window, _: &mut App) -> impl IntoElement
+ fn render_th(&mut self, col_ix: usize, _: &mut Window, _: &mut Context<TableState<Self>>) -> impl IntoElement
```
2025-12-01 17:20:52 +08:00
Jason Lee
4a3f520c5f
scrollbar: Manage ScrollbarState in Scrollbar internal. (#1690)
This PR to improve the Scrollbar API to manage the state in the
internal.

## Break Changes

Describe any breaking changes introduced by this pull request. If none,
remove this section.

- Removed `scrollbar_state` argument from `Scrollbar::new`,
`Scrollbar::both`, `Scrollbar::vertical` and `Scrollbar::horizontal`.

```diff
- Scrollbar::horizontal(&self.scrollbar_state, &self.scroll_handle)
+ Scrollbar::horizontal(&self.scroll_handle)

- Scrollbar::vertical(&self.scrollbar_state, &self.scroll_handle)
+ Scrollbar::vertical(&self.scroll_handle)
```

- Change `struct ScrollbarState` to private, we not need this not.

```diff
- pub struct ScrollbarState {
+ struct ScrollbarState {
```

- Renamed `trait ScrollHandleOffsetable` to `trait ScrollbarHanle`.

```diff
- pub trait ScrollHandleOffsetable {
+ pub trait ScrollbarHanle {
```

- Removed `Scrollbar::both`, now use `Scrollbar::new` instead.

```diff
- Scrollbar::both(&scroll_handle)
+ Scrollbar::new(&scroll_handle)
```
2025-11-27 11:39:58 +08:00
Jason Lee
f2cbc16655
chore: Update to use Rust edition 2024. (#1669) 2025-11-24 14:38:43 +08:00
Jason Lee
857f7973e3
scrollbar: Remove Scrollbar::uniform_scroll, use Scrollbar::vertical instead. (#1659)
## Break Change

- Remove `Scrollbar::uniform_scroll`, use `Scrollbar::vertical` instead.

```diff
- Scrollbar::uniform_scroll(&scroll_state, &scroll_handle)
+ Scrollbar::vertical(&scroll_state, &scroll_handle)
```
2025-11-21 22:53:33 +08: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
Jason Lee
29fbdd371b
table: Split TableState to state.rs (#1599) 2025-11-14 14:08:29 +08:00