slint/internal/compiler/widgets/material/menu.slint
Olivier Goffart e5289af154 Introduce MenuSeparator
Fixes #7790
2025-04-02 11:50:45 +02:00

78 lines
2.7 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
import { MaterialPalette, MaterialFontSettings } from "styling.slint";
import { MenuBarItemBase, MenuBarBase, MenuFrameBase, MenuItemBase } from "../common/menu-base.slint";
export component MenuBarItem {
in property <MenuEntry> entry <=> base.entry;
callback clicked <=> base.clicked;
callback hovered <=> base.hovered;
min-width: base.min-width;
min-height: base.min-height;
base := MenuBarItemBase {
padding-left: 12px;
padding-right: 12px;
padding-top: 8px;
padding-bottom: 8px;
default-foreground: MaterialPalette.foreground;
hover-foreground: MaterialPalette.foreground;
pressed-foreground: MaterialPalette.foreground;
hover-background: MaterialPalette.surface-container-highest;
pressed-background: MaterialPalette.surface-container-highest;
font-size: MaterialFontSettings.body-large.font-size;
font-weight: MaterialFontSettings.body-large.font-weight;
}
}
export component MenuBar inherits MenuBarBase {
padding-left: 4px;
padding-right: 4px;
spacing: 8px;
min-layout-height: 40px;
}
export component MenuFrame inherits MenuFrameBase {
background: MaterialPalette.surface-container;
border-radius: 4px;
border-width: 1px;
border-color: MaterialPalette.border;
drop-shadow-color: MaterialPalette.shadow;
drop-shadow-offset-y: 2px;
drop-shadow-blur: 6px;
padding-top: 8px;
padding-bottom: 8px;
layout-min-width: 200px;
}
export component MenuItem {
in property <bool> is-current <=> base.is-current;
in property <MenuEntry> entry <=> base.entry;
callback set-current <=> base.set-current;
callback clear-current <=> base.clear-current;
callback activate <=> base.activate;
min-height: max(40px, base.min-height);
HorizontalLayout {
base := MenuItemBase {
default-foreground: MaterialPalette.foreground;
current-foreground: MaterialPalette.foreground;
current-background: MaterialPalette.surface-container-highest;
separator-color: MaterialPalette.border;
font-size: MaterialFontSettings.body-large.font-size;
font-weight: MaterialFontSettings.body-large.font-weight;
padding-left: 12px;
padding-right: 12px;
padding-top: 8px;
padding-bottom: 8px;
spacing: 8px;
sub-menu-icon: @image-url("_arrow_forward.svg");
icon-size: MaterialFontSettings.body-large.font-size;
}
}
}