Added "outside-color" add "outside-filter" properties to Popup interface

This commit is contained in:
Alexei Anoshenko 2026-07-01 17:00:40 +03:00
parent 5272354205
commit c07cf52081
4 changed files with 81 additions and 7 deletions

View File

@ -5,6 +5,7 @@
* Added functions: GetWhiteSpace, GetWordBreak, ScrollIntoViewIfNeeded
* Added Popups, PopupDefault, PopupDefaultsSeq, and SetPopupDefaults methods to Session interface
* Added DismissWithoutAnimation add SetHotKey methods to Popup interface
* Added "outside-color" add "outside-filter" properties to Popup interface
* Added ViewSeq add ViewCount methods to ParentView interface
* Added ToBoundsProperty method to Bounds struct

View File

@ -142,6 +142,18 @@ type filterData struct {
}
// NewFilterProperty creates the new FilterProperty
//
// The argument lists the effects to apply. The following effects are possible:
// - "blur" (Blur) - Gaussian blur in pixels (type: float64, value: 0…10000);
// - "brightness" (Brightness) - Brightness change in percents (type: float64, value: 0…10000);
// - "contrast" (Contrast) - Contrast change in percents (type: float64, value: 0…10000);
// - "drop-shadow" (DropShadow) - Adding shadow (type: []ShadowProperty);
// - "grayscale" (Grayscale) - Converting to grayscale in percents (type: float64, value: 0…100%);
// - "hue-rotate" (HueRotate) - Hue rotation (type: AngleUnit);
// - "invert" (Invert) - Invert colors in percents (type: float64, value: 0…100);
// - "opacity" (Opacity) - Changing transparency in percents (type: float64, value: 0…100);
// - "saturate" (Saturate) - Saturation change in percents (type: float64, value: 0…10000);
// - "sepia" (Sepia) - Conversion to sepia in percents (type: float64, value: 0…100).
func NewFilterProperty(params Params) FilterProperty {
if len(params) > 0 {
filter := new(filterData)

View File

@ -152,6 +152,17 @@ const (
// See SizeUnit description for more details.
ArrowWidth PropertyName = "arrow-width"
// ArrowOffset is the constant for "arrow-offset" property tag.
//
// Used by Popup.
// Set the offset of the popup arrow.
//
// Supported types: SizeUnit, SizeFunc, string, float, int.
//
// Internal type is SizeUnit, other types converted to it during assignment.
// See SizeUnit description for more details.
ArrowOffset PropertyName = "arrow-offset"
// ShowTransform is the constant for "show-transform" property tag.
//
// Used by Popup.
@ -207,16 +218,27 @@ const (
// Internal type is float, other types converted to it during assignment.
ShowOpacity PropertyName = "show-opacity"
// ArrowOffset is the constant for "arrow-offset" property tag.
// OutsideColor is the constant for "outside-color" property tag.
//
// Used by Popup.
// Set the offset of the popup arrow.
// Specifies the color used to paint the space outside and below the Popup.
//
// Supported types: SizeUnit, SizeFunc, string, float, int.
// Supported types: Color, string.
//
// Internal type is SizeUnit, other types converted to it during assignment.
// See SizeUnit description for more details.
ArrowOffset PropertyName = "arrow-offset"
// Internal type is Color, other types converted to it during assignment.
// See [Color] description for more details.
OutsideColor PropertyName = "outside-color"
// OutsideFilter is the constant for "outside-filter" property tag.
//
// Used by Popup.
// Applies graphical effects to the area outside and below a popup, such as blurring, color shifting, changing brightness/contrast,
// etc.
//
// Supported types: FilterProperty.
//
// See FilterProperty description for more details.
OutsideFilter PropertyName = "outside-filter"
// NoneArrow is value of the popup "arrow" property: no arrow
NoneArrow = 0
@ -682,6 +704,24 @@ func (popup *popupData) Set(tag PropertyName, value any) bool {
popup.setRaw(ShowTiming, timing)
return true
}
case OutsideColor:
if len(setColorProperty(popup, OutsideColor, value)) > 0 {
popup.propertyChanged(OutsideColor)
return true
}
return false
case OutsideFilter:
if len(setFilterProperty(popup, OutsideFilter, value)) > 0 {
popup.propertyChanged(OutsideColor)
return true
}
return false
//if filter := GetBackdropFilter(popup.popupView); filter != nil {
//params[BackdropFilter] = filter
}
if popup.supported(tag) {
@ -791,6 +831,12 @@ func (popup *popupData) propertyChanged(tag PropertyName) {
popup.layerView.SetTransition(Transform, popup.animationProperty())
}
case OutsideColor:
popup.layerView.Set(BackgroundColor, popup.Get(OutsideColor))
case OutsideFilter:
popup.layerView.Set(BackdropFilter, popup.Get(OutsideFilter))
default:
if popup.supported(tag) {
popup.popupView.Set(tag, popup.getRaw(tag))
@ -1313,6 +1359,8 @@ func (popup *popupData) createLayerView() GridLayout {
TitleStyle,
CloseButton,
OutsideClose,
OutsideColor,
OutsideFilter,
Buttons,
ButtonsAlign,
DismissEvent,
@ -1379,6 +1427,16 @@ func (popup *popupData) createLayerView() GridLayout {
layerParams[ClickEvent] = popup.cancel
}
if color, ok := colorProperty(popup, OutsideColor, session); ok {
layerParams[BackgroundColor] = color
}
if value := popup.getRaw(OutsideFilter); value != nil {
if filter, ok := value.(FilterProperty); ok {
layerParams[BackdropFilter] = filter
}
}
popup.layerView = NewGridLayout(session, layerParams)
opacity, _ := floatProperty(popup, ShowOpacity, session, 1)

View File

@ -163,7 +163,10 @@ func (popup *popupMenuData) IsListItemEnabled(index int) bool {
// Supported types: `func(index int)`.
const PopupMenuResult PropertyName = "popup-menu-result"
// ShowMenu displays the menu. Menu items are set using the Items property.
// ShowMenu displays the menu.
//
// Menu items are set using the Items property.
//
// The "popup-menu-result" property sets the function (format: func(int)) to be called when a menu item is selected.
func ShowMenu(session Session, params Params) Popup {
value, ok := params[Items]