Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

live-preview: sidebar management #6125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tools/lsp/ui/assets/layout-sidebar-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tools/lsp/ui/assets/layout-sidebar-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions tools/lsp/ui/components/group.slint
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export component GroupHeader {

@children
}
Rectangle {
height: 1px;
background: Palette.foreground.transparentize(0.9);
width: 100%;
y:parent.height + self.height;
}
}

export component Group {
Expand All @@ -29,6 +35,12 @@ export component Group {
background: Palette.alternate-background;
}

Rectangle {
height: 1px;
background: Palette.control-background;
width: 100%;
}

content-layer := VerticalLayout {
@children
}
Expand Down
9 changes: 7 additions & 2 deletions tools/lsp/ui/components/status-line.slint
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ export component StatusLine {
background-layer := Rectangle {
background: Palette.alternate-background;

HorizontalBox {
HorizontalLayout {
padding-left: 10px;
padding-bottom: 6px;
padding-top: 4px;
Text {
text <=> StatusLineApi.help-text;
height: 1.8rem;
height: 1.5rem;
font-italic: true;
font-weight: 300;
vertical-alignment: TextVerticalAlignment.center;
}
}
Expand Down
6 changes: 4 additions & 2 deletions tools/lsp/ui/components/styling.slint
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ export global Icons {
out property <image> add: @image-url("../assets/add.svg");
out property <image> drop-down: @image-url("../assets/drop-down.svg");
out property <image> inspect: @image-url("../assets/inspect.svg");
out property <image> sidebar-left: @image-url("../assets/layout-sidebar-left-off.svg");
out property <image> sidebar-right: @image-url("../assets/layout-sidebar-right-off.svg");
out property <image> sidebar-left-off: @image-url("../assets/layout-sidebar-left-off.svg");
out property <image> sidebar-right-off: @image-url("../assets/layout-sidebar-right-off.svg");
out property <image> sidebar-left: @image-url("../assets/layout-sidebar-left.svg");
out property <image> sidebar-right: @image-url("../assets/layout-sidebar-right.svg");
out property <image> sync: @image-url("../assets/sync.svg");
}

Expand Down
50 changes: 30 additions & 20 deletions tools/lsp/ui/main.slint
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { EditorSpaceSettings, Icons } from "./components/styling.slint";
import { StatusLine } from "./components/status-line.slint";
import { HeaderView } from "./views/header-view.slint";
import { LibraryView } from "./views/library-view.slint";
import { DrawAreaMode, PreviewView } from "./views/preview-view.slint";
import { DrawAreaMode, PreviewView, SidebarApi } from "./views/preview-view.slint";
import { PropertyView } from "./views/property-view.slint";

export { Api }


export component PreviewUi inherits Window {
property <length> border: 20px;
property <ComponentItem> visible-component: {
Expand All @@ -25,8 +25,6 @@ export component PreviewUi inherits Window {
is-user-defined: false,
is-currently-shown: false,
};
property <bool> show-left-sidebar: true;
property <bool> show-right-sidebar: true;

title: "Slint Live-Preview";
icon: @image-url("assets/slint-logo-small-light.png");
Expand All @@ -51,10 +49,8 @@ export component PreviewUi inherits Window {
}
if Api.show-preview-ui: Rectangle {
VerticalLayout {
alignment: stretch;
header-view := HeaderView {
show-left-sidebar <=> root.show-left-sidebar;
show-right-sidebar <=> root.show-right-sidebar;

edit-mode <=> Api.design-mode;
current-style <=> Api.current-style;
known-styles <=> Api.known-styles;
Expand All @@ -67,30 +63,40 @@ export component PreviewUi inherits Window {
Api.style-changed();
}

Button {
icon: Icons.sync;
colorize-icon: true;
clicked => { Api.reload-preview(); }
}
Button {
icon: Icons.inspect;
colorize-icon: true;
checkable: true;
width: 30px;
checked <=> preview.select-mode;
enabled: !preview.design-mode;
visible: !preview.design-mode;
}
}

HorizontalLayout {
spacing: EditorSpaceSettings.default-spacing;
Rectangle {
// spacing: EditorSpaceSettings.default-spacing;

if Api.design-mode && root.show-left-sidebar: LibraryView {
preview := PreviewView {
left-margin: libraryView.width + libraryView.x;
right-margin: self.width - propertyView.x;
visible-component <=> root.visible-component;
}

libraryView := LibraryView {
x: (Api.design-mode && SidebarApi.show-left-sidebar) ? 0 : -self.width;
y: 0;
height: 100%;
known-components: Api.known-components;
preview-area-position-x: preview.preview-area-position-x;
preview-area-position-y: preview.preview-area-position-y;
preview-area-width: preview.preview-area-width;
preview-area-height: preview.preview-area-height;
visible-component <=> root.visible-component;
animate x {
duration: 100ms;
easing: ease-in;
}

can-drop(index, x, y, on-drop-area) => {
Api.can-drop(index, x, y, on-drop-area);
Expand All @@ -105,14 +111,18 @@ export component PreviewUi inherits Window {
}
}

preview := PreviewView {
visible-component <=> root.visible-component;
propertyView := PropertyView {
x: Api.design-mode && SidebarApi.show-right-sidebar ? (parent.width - self.width) : parent.width;
height: parent.height;
y: 0;
animate x {
duration: 100ms;
easing: ease-in;
}
}

if Api.design-mode && root.show-right-sidebar: PropertyView { }
}

StatusLine { }
statusLine := StatusLine { }
}

key-handler := FocusScope {
Expand Down
118 changes: 68 additions & 50 deletions tools/lsp/ui/views/header-view.slint
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,49 @@ import { BodyText } from "../components/body-text.slint";
import { HeaderText } from "../components/header-text.slint";
import { Api } from "../api.slint";
import { EditorSpaceSettings, Icons } from "../components/styling.slint";
import { SidebarApi } from "../views/preview-view.slint";


export component HeaderView {
in-out property <bool> show-left-sidebar <=> left-panel-button.checked;
in-out property <bool> show-right-sidebar <=> right-panel-button.checked;
export component HeaderView inherits Rectangle {
in-out property <bool> edit-mode <=> interaction-switch.checked;
in-out property <string> current-style <=> style-combobox.current-value;
in property <[string]> known-styles <=> style-combobox.model;

callback style-selected();
callback edit-mode-toggled();

background-layer := Rectangle {
background: Palette.alternate-background;

content-layer := HorizontalBox {
HeaderText {
text: @tr("Preview");
horizontal-stretch: 0;
}
background: Palette.alternate-background;
content-layer := HorizontalBox {
z: 0;
spacing: 5px;
horizontal-stretch: 1;
alignment: stretch;
// spacing:80px;

HorizontalLayout {
horizontal-stretch: 1;
alignment: start;
spacing: EditorSpaceSettings.default-spacing;
@children
alignment: start;
spacing: 5px;
Button {
width: 30px;
icon: Icons.sync;
colorize-icon: true;
clicked => {
Api.reload-preview();
}
}

BodyText {
visible: Api.uses-widgets;
HeaderText {
text: @tr("Preview");
horizontal-stretch: 0;

text: @tr("Style");
}
}

style-combobox := ComboBox {
visible: Api.uses-widgets;
horizontal-stretch: 0;

selected => {
root.style-selected();
}
}
HorizontalLayout {
alignment: center;
spacing: 12px;

@children
HorizontalLayout {
horizontal-stretch: 0;
spacing: 4px;

spacing: 5px;
BodyText {
text: @tr("Interact");
}
Expand All @@ -69,30 +64,53 @@ export component HeaderView {
}
}

left-panel-button := Button {
horizontal-stretch: 0;

checkable: true;
icon: Icons.sidebar-left;
colorize-icon: true;
enabled: root.edit-mode;
}

right-panel-button := Button {
horizontal-stretch: 0;
HorizontalLayout {
visible: root.edit-mode;
spacing: 5px;
left-panel-button := Button {
width: 30px;
horizontal-stretch: 0;
checkable: true;
icon: SidebarApi.show-left-sidebar ? Icons.sidebar-left : Icons.sidebar-left-off;
colorize-icon: true;
enabled: root.edit-mode;
checked <=> SidebarApi.show-left-sidebar;
}

checkable: true;
icon: Icons.sidebar-right;
colorize-icon: true;
enabled: root.edit-mode;
right-panel-button := Button {
horizontal-stretch: 0;
width: 30px;
checkable: true;
icon: SidebarApi.show-right-sidebar ? Icons.sidebar-right : Icons.sidebar-right-off;
colorize-icon: true;
enabled: root.edit-mode;
checked <=> SidebarApi.show-right-sidebar;
}
}
}

Rectangle {
y: parent.height - self.height;
height: 1px;
styleContent := HorizontalLayout {
alignment: end;
spacing: 5px;
visible: Api.uses-widgets;
BodyText {
text: @tr("Style");
}

background: Palette.border;
style-combobox := ComboBox {
visible: Api.uses-widgets;
horizontal-stretch: 0;
selected => {
root.style-selected();
}
}
}
}

Rectangle {
y: parent.height - self.height;
height: 1px;
z: 2;
background: Palette.border;
}
}
39 changes: 27 additions & 12 deletions tools/lsp/ui/views/library-view.slint
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0

import { Group, GroupHeader } from "../components/group.slint";
import { Palette } from "std-widgets.slint";
import { ExpandableListView } from "../components/expandable-listview.slint";
import { Icons, EditorSizeSettings } from "../components/styling.slint";
import { ComponentListItem, ComponentItem } from "../api.slint";
import { IconButton } from "../components/icon-button.slint";

export component LibraryView {
export component LibraryView inherits Rectangle {
in property <[ComponentListItem]> known-components <=> component-list-view.known-components;
in property <length> preview-area-position-x <=> component-list-view.preview-area-position-x;
in property <length> preview-area-position-y <=> component-list-view.preview-area-position-y;
Expand All @@ -18,20 +19,34 @@ export component LibraryView {
pure callback can-drop <=> component-list-view.can-drop;
callback drop <=> component-list-view.drop;
callback show-preview-for <=> component-list-view.show-preview-for;

width: EditorSizeSettings.side-bar-width;
min-height: side-bar.min-height;

side-bar := Group {
width: 100%;
clip: true;
width: EditorSizeSettings.side-bar-width+5px;
background: transparent;
Rectangle {
width: EditorSizeSettings.side-bar-width;
height: 100%;

GroupHeader {
title: @tr("Library");
x: 0;
drop-shadow-blur: 5px;
drop-shadow-color: #777;
min-height: side-bar.min-height;
background-layer := Rectangle {
height: 100%;
width: 100%;
background: Palette.background;
z: 0;
}

component-list-view := ExpandableListView {
vertical-stretch: 1;
side-bar := Group {
width: 100%;
height: 100%;

GroupHeader {
title: @tr("Library");
}

component-list-view := ExpandableListView {
vertical-stretch: 1;
}
}
}
}
Loading
Loading