// Copyright © SixtyFPS GmbH // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 import { CupertinoFontSettings, CupertinoPalette } from "styling.slint"; import { FocusBorder } from "components.slint"; import { LineEditBase } from "../common/lineedit-base.slint"; export component LineEdit { in property enabled <=> base.enabled; in property input-type <=> base.input-type; in property horizontal-alignment <=> base.horizontal-alignment; in property read-only <=> base.read-only; in property font-size <=> base.font-size; in property placeholder-text <=> base.placeholder-text; out property has-focus <=> base.has-focus; in-out property text <=> base.text; callback accepted <=> base.accepted; callback edited <=> base.edited; callback key-pressed <=> base.key-pressed; callback key-released <=> base.key-released; accessible-role: text-input; accessible-enabled: root.enabled; accessible-value <=> text; accessible-placeholder-text: text == "" ? placeholder-text : ""; accessible-action-set-value(v) => { text = v; edited(v); } public function set-selection-offsets(start: int, end: int) { base.set-selection-offsets(start, end); } public function select-all() { base.select-all(); } public function clear-selection() { base.clear-selection(); } public function cut() { base.cut(); } public function copy() { base.copy(); } public function paste() { base.paste(); } vertical-stretch: 0; horizontal-stretch: 1; min-width: max(160px, layout.min-width); min-height: max(22px, layout.min-height); forward-focus: base; states [ disabled when !root.enabled: { base.text-color: CupertinoPalette.foreground; base.placeholder-color: CupertinoPalette.foreground-secondary; background.background: CupertinoPalette.tertiary-control-background; } focused when root.has-focus: { background.background: CupertinoPalette.control-background; } ] FocusBorder { x: (parent.width - self.width) / 2; y: (parent.height - self.height) / 2; width: parent.width + 6px; height: parent.height + 6px; has-focus: root.has-focus; } background := Rectangle { background: CupertinoPalette.control-background; border-color: CupertinoPalette.border; border-width: 1px; opacity: root.enabled ? 1 : 0.5; layout := HorizontalLayout { padding-left: 7px; padding-right: 7px; base := LineEditBase { font-size: CupertinoFontSettings.body.font-size; font-weight: CupertinoFontSettings.body.font-weight; selection-background-color: CupertinoPalette.selection-background; selection-foreground-color: CupertinoPalette.selection-foreground; text-color: CupertinoPalette.foreground; margin: layout.padding-left + layout.padding-right; placeholder-color: CupertinoPalette.foreground-secondary; } } } }