Skip to content

Commit

Permalink
api review: callback parameters and properties name adjustements
Browse files Browse the repository at this point in the history
  • Loading branch information
FloVanGH authored Dec 2, 2024
1 parent 6de76e0 commit 901afde
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 54 deletions.
8 changes: 4 additions & 4 deletions docs/src/content/docs/reference/std-widgets/scrollview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ The width of the visible area of the ScrollView (not including the scrollbar)
The height of the visible area of the ScrollView (not including the scrollbar)
</SlintProperty>

### vertical-bar-policy
<SlintProperty propName="vertical-bar-policy" typeName="enum" enumName="ScrollBarPolicy">
### vertical-scrollbar-policy
<SlintProperty propName="vertical-scrollbar-policy" typeName="enum" enumName="ScrollBarPolicy">
The vertical scroll bar visibility policy. The default value is `ScrollBarPolicy.as-needed`.
</SlintProperty>

### horizontal-bar-policy
<SlintProperty propName="horizontal-bar-policy" typeName="enum" enumName="ScrollBarPolicy">
### horizontal-scrollbar-policy
<SlintProperty propName="horizontal-scrollbar-policy" typeName="enum" enumName="ScrollBarPolicy">
The horizontal scroll bar visibility policy. The default value is `ScrollBarPolicy.as-needed`.
</SlintProperty>

Expand Down
12 changes: 6 additions & 6 deletions examples/gallery/ui/pages/list_view_page.slint
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export component ListViewPage inherits Page {
Text {
text: @tr("Vertical:");
}
vertical-bar-policy := ComboBox {
vertical-scrollbar-policy := ComboBox {
in-out property<ScrollBarPolicy> current-policy: policy-from-index(self.current-index);

model: [@tr("As Needed"), @tr("Always On"), @tr("Always Off")];
Expand All @@ -40,7 +40,7 @@ export component ListViewPage inherits Page {
Text {
text: @tr("Horizontal:");
}
horizontal-bar-policy := ComboBox {
horizontal-scrollbar-policy := ComboBox {
in-out property<ScrollBarPolicy> current-policy: policy-from-index(self.current-index);

model: [@tr("As Needed"), @tr("Always On"), @tr("Always Off")];
Expand All @@ -55,8 +55,8 @@ export component ListViewPage inherits Page {
title: @tr("ListView");

ListView {
vertical-bar-policy: vertical-bar-policy.current-policy;
horizontal-bar-policy: horizontal-bar-policy.current-policy;
vertical-scrollbar-policy: vertical-scrollbar-policy.current-policy;
horizontal-scrollbar-policy: horizontal-scrollbar-policy.current-policy;
vertical-stretch: 0;
for i in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] : HorizontalBox {
Image {
Expand All @@ -75,8 +75,8 @@ export component ListViewPage inherits Page {
vertical-stretch: 0;

StandardListView {
vertical-bar-policy: vertical-bar-policy.current-policy;
horizontal-bar-policy: horizontal-bar-policy.current-policy;
vertical-scrollbar-policy: vertical-scrollbar-policy.current-policy;
horizontal-scrollbar-policy: horizontal-scrollbar-policy.current-policy;
model: [
{text: @tr("Lorem")}, {text: @tr("ipsum")},{text: @tr("dolor")},{text: @tr("sit")},{text: @tr("amet")},{text: @tr("consetetur")},
{text: @tr("Lorem")}, {text: @tr("ipsum")},{text: @tr("dolor")},{text: @tr("sit")},{text: @tr("amet")},{text: @tr("consetetur")},
Expand Down
8 changes: 4 additions & 4 deletions internal/backends/qt/qt_widgets/scrollview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pub struct NativeScrollView {
pub native_padding_bottom: Property<LogicalLength>,
pub enabled: Property<bool>,
pub has_focus: Property<bool>,
pub vertical_bar_policy: Property<ScrollBarPolicy>,
pub horizontal_bar_policy: Property<ScrollBarPolicy>,
pub vertical_scrollbar_policy: Property<ScrollBarPolicy>,
pub horizontal_scrollbar_policy: Property<ScrollBarPolicy>,
data: Property<NativeSliderData>,
widget_ptr: std::cell::Cell<SlintTypeErasedWidgetPtr>,
animation_tracker: Property<i32>,
Expand Down Expand Up @@ -295,8 +295,8 @@ impl Item for NativeScrollView {
};
let enabled: bool = this.enabled();
let has_focus: bool = this.has_focus();
let vertical_bar_visible = (this.vertical_bar_policy() == ScrollBarPolicy::AlwaysOn) || ((this.vertical_bar_policy() == ScrollBarPolicy::AsNeeded) && (this.vertical_max().get() > 0.0));
let horizontal_bar_visible = (this.horizontal_bar_policy() == ScrollBarPolicy::AlwaysOn) || ((this.horizontal_bar_policy() == ScrollBarPolicy::AsNeeded) && (this.horizontal_max().get() > 0.0));
let vertical_bar_visible = (this.vertical_scrollbar_policy() == ScrollBarPolicy::AlwaysOn) || ((this.vertical_scrollbar_policy() == ScrollBarPolicy::AsNeeded) && (this.vertical_max().get() > 0.0));
let horizontal_bar_visible = (this.horizontal_scrollbar_policy() == ScrollBarPolicy::AlwaysOn) || ((this.horizontal_scrollbar_policy() == ScrollBarPolicy::AsNeeded) && (this.horizontal_max().get() > 0.0));
let scrollbar_bar_visible = vertical_bar_visible || horizontal_bar_visible;
let frame_around_contents = cpp!(unsafe [
painter as "QPainterPtr*",
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler/builtins.slint
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,8 @@ export component NativeScrollView {
out property <length> native-padding-top;
out property <length> native-padding-bottom;
in property <bool> has_focus;
in property <ScrollBarPolicy> vertical-bar-policy;
in property <ScrollBarPolicy> horizontal-bar-policy;
in property <ScrollBarPolicy> vertical-scrollbar-policy;
in property <ScrollBarPolicy> horizontal-scrollbar-policy;
in property <bool> enabled: true;
//-default_size_binding:expands_to_parent_geometry
//-is_internal
Expand Down
2 changes: 1 addition & 1 deletion internal/compiler/widgets/common/listview.slint
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ component StandardListViewBase inherits ListView {
in-out property <int> current-item: -1;

callback current-item-changed(current-item: int);
callback item-pointer-event(item-index: int, event: PointerEvent, absolute-mouse-position: Point);
callback item-pointer-event(item: int, event: PointerEvent, position: Point);

public function set-current-item(index: int) {
if index < 0 || index >= model.length || index == root.current-item {
Expand Down
2 changes: 1 addition & 1 deletion internal/compiler/widgets/cosmic/datepicker.slint
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export component DatePickerPopup inherits PopupWindow {
in property <Date> date <=> base.date;

callback canceled();
callback accepted(current-date: Date);
callback accepted(date: Date);

width: 360px;
height: 524px;
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler/widgets/cosmic/scrollview.slint
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ export component ScrollView {
in-out property <length> viewport-height <=> flickable.viewport-height;
in-out property <length> viewport-x <=> flickable.viewport-x;
in-out property <length> viewport-y <=> flickable.viewport-y;
in property <ScrollBarPolicy> vertical-bar-policy <=> vertical-bar.policy;
in property <ScrollBarPolicy> horizontal-bar-policy <=> horizontal-bar.policy;
in property <ScrollBarPolicy> vertical-scrollbar-policy <=> vertical-bar.policy;
in property <ScrollBarPolicy> horizontal-scrollbar-policy <=> horizontal-bar.policy;
// FIXME: remove. This property is currently set by the ListView and is used by the native style to draw the scrollbar differently when it has focus
in-out property <bool> has-focus;

Expand Down
8 changes: 4 additions & 4 deletions internal/compiler/widgets/cosmic/tableview.slint
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ component TableViewRow inherits Rectangle {
in property <bool> even;

callback clicked <=> touch-area.clicked;
callback pointer-event(event: PointerEvent, absolute-mouse-position: Point);
callback pointer-event(event: PointerEvent, position: Point);


min-width: layout.min-width;
Expand Down Expand Up @@ -129,9 +129,9 @@ export component StandardTableView {
in-out property <[TableColumn]> columns;
in-out property <int> current-row: -1;

callback sort-ascending(column-index: int);
callback sort-descending(column-index: int);
callback row-pointer-event(row-index: int, event: PointerEvent, mouse-position: Point);
callback sort-ascending(column: int);
callback sort-descending(column: int);
callback row-pointer-event(row: int, event: PointerEvent, position: Point);
callback current-row-changed(current-row: int);

public function set-current-row(index: int) {
Expand Down
2 changes: 1 addition & 1 deletion internal/compiler/widgets/cupertino/datepicker.slint
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export component DatePickerPopup inherits PopupWindow {
in property <Date> date <=> base.date;

callback canceled();
callback accepted(current-date: Date);
callback accepted(date: Date);

width: 360px;
height: 524px;
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler/widgets/cupertino/scrollview.slint
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export component ScrollView {
in-out property <length> viewport-height <=> flickable.viewport-height;
in-out property <length> viewport-x <=> flickable.viewport-x;
in-out property <length> viewport-y <=> flickable.viewport-y;
in property <ScrollBarPolicy> vertical-bar-policy <=> vertical-bar.policy;
in property <ScrollBarPolicy> horizontal-bar-policy <=> horizontal-bar.policy;
in property <ScrollBarPolicy> vertical-scrollbar-policy <=> vertical-bar.policy;
in property <ScrollBarPolicy> horizontal-scrollbar-policy <=> horizontal-bar.policy;
// FIXME: remove. This property is currently set by the ListView and is used by the native style to draw the scrollbar differently when it has focus
in-out property <bool> has-focus;

Expand Down
8 changes: 4 additions & 4 deletions internal/compiler/widgets/cupertino/tableview.slint
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ component TableViewRow inherits Rectangle {
in property <bool> even;

callback clicked <=> i-touch-area.clicked;
callback pointer-event(event: PointerEvent, absolute-mouse-position: Point);
callback pointer-event(event: PointerEvent, position: Point);

min-width: i-layout.min-width;
min-height: max(20px, i-layout.min-height);
Expand Down Expand Up @@ -126,9 +126,9 @@ export component StandardTableView {
in-out property <[TableColumn]> columns;
in-out property <int> current-row: -1;

callback sort-ascending(column-index: int);
callback sort-descending(column-index: int);
callback row-pointer-event(row-index: int, event: PointerEvent, mouse-position: Point);
callback sort-ascending(column: int);
callback sort-descending(column: int);
callback row-pointer-event(row: int, event: PointerEvent, position: Point);
callback current-row-changed(current-row: int);

public function set-current-row(index: int) {
Expand Down
2 changes: 1 addition & 1 deletion internal/compiler/widgets/fluent/datepicker.slint
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export component DatePickerPopup inherits PopupWindow {
in property <Date> date <=> base.date;

callback canceled();
callback accepted(current-date: Date);
callback accepted(date: Date);

width: 368px;
height: 524px;
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler/widgets/fluent/scrollview.slint
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ export component ScrollView {
in-out property <length> viewport-height <=> flickable.viewport-height;
in-out property <length> viewport-x <=> flickable.viewport-x;
in-out property <length> viewport-y <=> flickable.viewport-y;
in property <ScrollBarPolicy> vertical-bar-policy <=> vertical-bar.policy;
in property <ScrollBarPolicy> horizontal-bar-policy <=> horizontal-bar.policy;
in property <ScrollBarPolicy> vertical-scrollbar-policy <=> vertical-bar.policy;
in property <ScrollBarPolicy> horizontal-scrollbar-policy <=> horizontal-bar.policy;

// FIXME: remove. This property is currently set by the ListView and is used by the native style to draw the scrollbar differently when it has focus
in-out property <bool> has-focus;
Expand Down
8 changes: 4 additions & 4 deletions internal/compiler/widgets/fluent/tableview.slint
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ component TableViewRow inherits Rectangle {
in property <bool> even;

callback clicked <=> i-touch-area.clicked;
callback pointer-event(event: PointerEvent, absolute-mouse-position: Point);
callback pointer-event(event: PointerEvent, position: Point);

min-width: i-layout.min-width;
min-height: max(34px, i-layout.min-height);
Expand Down Expand Up @@ -149,9 +149,9 @@ export component StandardTableView {
in-out property <[TableColumn]> columns;
in-out property <int> current-row: -1;

callback sort-ascending(column-index: int);
callback sort-descending(column-index: int);
callback row-pointer-event(row-index: int, event: PointerEvent, mouse-position: Point);
callback sort-ascending(column: int);
callback sort-descending(column: int);
callback row-pointer-event(row: int, event: PointerEvent, position: Point);
callback current-row-changed(current-row: int);

public function set-current-row(index: int) {
Expand Down
2 changes: 1 addition & 1 deletion internal/compiler/widgets/material/datepicker.slint
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export component DatePickerPopup inherits PopupWindow {
in property <Date> date <=> base.date;

callback canceled();
callback accepted(current-date: Date);
callback accepted(date: Date);

width: 360px;
height: 524px;
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler/widgets/material/scrollview.slint
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ export component ScrollView {
in-out property <length> viewport-height <=> flickable.viewport-height;
in-out property <length> viewport-x <=> flickable.viewport-x;
in-out property <length> viewport-y <=> flickable.viewport-y;
in property <ScrollBarPolicy> vertical-bar-policy <=> vertical-bar.policy;
in property <ScrollBarPolicy> horizontal-bar-policy <=> horizontal-bar.policy;
in property <ScrollBarPolicy> vertical-scrollbar-policy <=> vertical-bar.policy;
in property <ScrollBarPolicy> horizontal-scrollbar-policy <=> horizontal-bar.policy;

callback scrolled <=> flickable.flicked;

Expand Down
6 changes: 3 additions & 3 deletions internal/compiler/widgets/material/tableview.slint
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ export component StandardTableView {
in-out property <[TableColumn]> columns;
in-out property <int> current-row: -1;

callback sort-ascending(column-index: int);
callback sort-descending(column-index: int);
callback row-pointer-event(row-index: int, event: PointerEvent, mouse-position: Point);
callback sort-ascending(column: int);
callback sort-descending(column: int);
callback row-pointer-event(row: int, event: PointerEvent, position: Point);
callback current-row-changed(current-row: int);

public function set-current-row(index: int) {
Expand Down
2 changes: 1 addition & 1 deletion internal/compiler/widgets/qt/datepicker.slint
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export component DatePickerPopup inherits PopupWindow {
property <brush> state-secondary: Palette.color-scheme == ColorScheme.dark ? #000000 : #ffffff;

callback canceled();
callback accepted(current-date: Date);
callback accepted(date: Date);

width: 360px;
height: 524px;
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler/widgets/qt/internal-scrollview.slint
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export component InternalScrollView {
out property <length> visible-height <=> fli.height;
in-out property <bool> has-focus <=> native.has-focus;
in property <bool> enabled <=> native.enabled;
in property <ScrollBarPolicy> vertical-bar-policy <=> native.vertical-bar-policy;
in property <ScrollBarPolicy> horizontal-bar-policy <=> native.horizontal-bar-policy;
in property <ScrollBarPolicy> vertical-scrollbar-policy <=> native.vertical-scrollbar-policy;
in property <ScrollBarPolicy> horizontal-scrollbar-policy <=> native.horizontal-scrollbar-policy;

// Used by the StandardTableView
out property <length> native-padding-left: native.native-padding-left;
Expand Down
4 changes: 2 additions & 2 deletions internal/compiler/widgets/qt/scrollview.slint
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export component ScrollView {
in-out property <length> viewport-height <=> internal.viewport-height;
in-out property <length> viewport-x <=> internal.viewport-x;
in-out property <length> viewport-y <=> internal.viewport-y;
in property <ScrollBarPolicy> vertical-bar-policy <=> internal.vertical-bar-policy;
in property <ScrollBarPolicy> horizontal-bar-policy <=> internal.horizontal-bar-policy;
in property <ScrollBarPolicy> vertical-scrollbar-policy <=> internal.vertical-scrollbar-policy;
in property <ScrollBarPolicy> horizontal-scrollbar-policy <=> internal.horizontal-scrollbar-policy;

callback scrolled <=> internal.scrolled;

Expand Down
6 changes: 3 additions & 3 deletions internal/compiler/widgets/qt/tableview.slint
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export component StandardTableView {
private property <length> item-height: scroll-view.viewport-height / rows.length;
private property <length> current-item-y: scroll-view.viewport-y + current-row * item-height;

callback sort-ascending(column-index: int);
callback sort-descending(column-index: int);
callback row-pointer-event(row-index: int, event: PointerEvent, mouse-position: Point);
callback sort-ascending(column: int);
callback sort-descending(column: int);
callback row-pointer-event(row: int, event: PointerEvent, position: Point);
callback current-row-changed(current-row: int);
accessible-role: table;

Expand Down
2 changes: 1 addition & 1 deletion tools/lsp/language/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ mod tests {
let res = get_completions(source).unwrap();
assert_eq!(
res.iter().find(|ci| ci.label == "row-pointer-event").unwrap().insert_text,
Some("row-pointer-event(row-index, event, mouse-position) => {$1}".into())
Some("row-pointer-event(row, event, position) => {$1}".into())
);
// builtin callback don't have named argument yet
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion tools/lsp/language/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export component Test {
assert_tooltip(
get_tooltip(&mut dc, find_tk("row-pointer-event", 0.into())),
// Fixme: this uses LogicalPoint instead of Point because of implementation details
"```slint\ncallback row-pointer-event(row-index: int, event: PointerEvent, mouse-position: LogicalPosition)\n```",
"```slint\ncallback row-pointer-event(row: int, event: PointerEvent, position: LogicalPosition)\n```",
);
assert_tooltip(
get_tooltip(&mut dc, find_tk("pointer-event", 5.into())),
Expand Down

0 comments on commit 901afde

Please sign in to comment.