Skip to content

Commit

Permalink
live-preview: Disable property editor when preview is not current
Browse files Browse the repository at this point in the history
  • Loading branch information
hunger committed Dec 9, 2024
1 parent 498ef2a commit d154cde
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 134 deletions.
9 changes: 6 additions & 3 deletions tools/lsp/ui/main.slint
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export component PreviewUi inherits Window {
checkable: true;
checked <=> preview.select-mode;
primary: preview.select-mode;
enabled: Api.diagnostic-summary != DiagnosticSummary.Errors;
enabled: preview.preview-is-current;
}
}

Expand All @@ -77,7 +77,8 @@ export component PreviewUi inherits Window {
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;

visible-component: root.visible-component;

can-drop(index, x, y, on-drop-area) => {
Api.can-drop(index, x, y, on-drop-area);
Expand All @@ -96,7 +97,9 @@ export component PreviewUi inherits Window {
visible-component <=> root.visible-component;
}

if root.show-right-sidebar: PropertyView { }
if root.show-right-sidebar: PropertyView {
enabled: preview.preview-is-current;
}
}

StatusLine { }
Expand Down
15 changes: 14 additions & 1 deletion tools/lsp/ui/views/preview-view.slint
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ component SelectionFrame {
export component PreviewView {
property <[Selection]> selections <=> Api.selections;
in property <ComponentItem> visible-component;
in-out property <bool> preview-is-current: Api.diagnostic-summary != DiagnosticSummary.Errors;
property <DiagnosticSummary> diagnostic-summary <=> Api.diagnostic-summary;
out property <bool> preview-is-current: self.diagnostic-summary != DiagnosticSummary.Errors;

property <DropMark> drop-mark <=> Api.drop-mark;
property <component-factory> preview-area <=> Api.preview-area;
in-out property <bool> select-mode: false;
Expand All @@ -206,6 +208,17 @@ export component PreviewView {
preferred-height: max(max(preview-area-container.preferred-height, preview-area-container.min-height) + 2 * scroll-view.border, 10 * scroll-view.border);
preferred-width: max(max(preview-area-container.preferred-width, preview-area-container.min-width) + 2 * scroll-view.border, 10 * scroll-view.border);

changed diagnostic-summary => {
if self.diagnostic-summary == DiagnosticSummary.NothingDetected {
StatusLineApi.help-text = @tr("");
} else if self.diagnostic-summary == DiagnosticSummary.Warnings {
StatusLineApi.help-text = @tr("Check your text editor for warnings");
}
if self.diagnostic-summary == DiagnosticSummary.Errors {
StatusLineApi.help-text = @tr("Check your text editor for errors");
}
}

scroll-view := ScrollView {
out property <length> border: 30px;

Expand Down
Loading

0 comments on commit d154cde

Please sign in to comment.