dock: Use disabled instead of hiding the zoom menu (#949)

This commit is contained in:
Floyd Wang 2025-06-12 12:10:03 +08:00 committed by GitHub
parent ed6adc2dae
commit 2febe2611b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 7 deletions

View file

@ -19,7 +19,7 @@ UI components for building fantastic desktop applications using [GPUI](https://g
Here is the first application: [Longbridge Pro](https://longbridge.com/desktop), built using GPUI Component.
<img width="1763" alt="Image" src="https://wp-cdn.4ce.cn/v2/hZRGaJm.png" />
<img width="1763" alt="Image" src="https://assets.lbctrl.com/uploads/32c11b27-b90d-4fce-a6b8-7d72e99fb231/longbridge-pro.png" />
We built multi-theme support in the application. This feature is not included in GPUI Component itself, but is based on the `Theme` feature, so it's easy to implement.

View file

@ -421,7 +421,6 @@ impl TabPanel {
let view = cx.entity().clone();
let zoomable_toolbar_visible = state.zoomable.map_or(false, |v| v.toolbar_visible());
// TODO: Do not show MenuButton if there is no menu items
h_flex()
.gap_1()
.occlude()
@ -466,14 +465,16 @@ impl TabPanel {
move |this, window, cx| {
view.read(cx)
.popup_menu(this, window, cx)
.when(zoomable, |this| {
let name = if zoomed {
.separator()
.menu_with_disabled(
if zoomed {
t!("Dock.Zoom Out")
} else {
t!("Dock.Zoom In")
};
this.separator().menu(name, Box::new(ToggleZoom))
})
},
Box::new(ToggleZoom),
!zoomable,
)
.when(closable, |this| {
this.separator()
.menu(t!("Dock.Close"), Box::new(ClosePanel))