From 6dbcc94bc10819f999a2963b2c1978a1c60013d3 Mon Sep 17 00:00:00 2001 From: mfacchinelli Date: Mon, 20 Jan 2025 13:47:18 +0000 Subject: [PATCH] fix: issue with `Theme` property empty for MATLAB without new desktop --- .env | 2 +- app/core/+mag/+app/+internal/SelectMissionDialog.m | 2 +- app/core/+mag/+app/+manage/ToolbarManager.m | 2 +- resources/release-notes.md | 7 +------ src/utility/+mag/+internal/isThemeable.m | 14 ++++++++++++++ .../+mag/+graphics/+factory/DefaultFactory.m | 2 +- 6 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 src/utility/+mag/+internal/isThemeable.m diff --git a/.env b/.env index 31af271a..e8626ae7 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -MAG_DATA_VISUALIZATION_VERSION=7.1.3 \ No newline at end of file +MAG_DATA_VISUALIZATION_VERSION=7.1.4 \ No newline at end of file diff --git a/app/core/+mag/+app/+internal/SelectMissionDialog.m b/app/core/+mag/+app/+internal/SelectMissionDialog.m index de1c969c..46a8cdde 100644 --- a/app/core/+mag/+app/+internal/SelectMissionDialog.m +++ b/app/core/+mag/+app/+internal/SelectMissionDialog.m @@ -58,7 +58,7 @@ function instantiate(this) this.GridLayout.ColumnWidth = ["1x", "2x", "1x"]; this.GridLayout.RowHeight = ["2x", "1x", "2x"]; - if isprop(this.Parent, "Theme") && isequal(this.Parent.Theme.BaseColorStyle, "dark") + if mag.internal.isThemeable(this.Parent) && isequal(this.Parent.Theme.BaseColorStyle, "dark") this.GridLayout.BackgroundColor = 0.02 * ones(1, 3); else this.GridLayout.BackgroundColor = 0.98 * ones(1, 3); diff --git a/app/core/+mag/+app/+manage/ToolbarManager.m b/app/core/+mag/+app/+manage/ToolbarManager.m index f65801bb..bce9438e 100644 --- a/app/core/+mag/+app/+manage/ToolbarManager.m +++ b/app/core/+mag/+app/+manage/ToolbarManager.m @@ -29,7 +29,7 @@ function instantiate(this, parent) % Create Toolbar. this.Toolbar = uitoolbar(parent); - if isprop(parent, "Theme") + if mag.internal.isThemeable(parent) theme = parent.Theme.BaseColorStyle; else theme = "light"; diff --git a/resources/release-notes.md b/resources/release-notes.md index 55233e18..d99c22af 100644 --- a/resources/release-notes.md +++ b/resources/release-notes.md @@ -1,8 +1,3 @@ -# App - -- Fix Bartington figures not being registered by app when generated - # Software -- Add sorting and removal of zeroed-out vectors for Bartington analysis processing -- Bartington field figures are also called "Bartington...", instead of "Field..." +- Fix issue with `Theme` property empty for MATLAB without new desktop diff --git a/src/utility/+mag/+internal/isThemeable.m b/src/utility/+mag/+internal/isThemeable.m new file mode 100644 index 00000000..2a426c39 --- /dev/null +++ b/src/utility/+mag/+internal/isThemeable.m @@ -0,0 +1,14 @@ +function value = isThemeable(figure) +% ISTHEMEABLE Determine whether figure is themeable (i.e., if setting +% dark/light mode is supported). + + arguments (Input) + figure (1, 1) matlab.ui.Figure + end + + arguments (Output) + value (1, 1) logical + end + + value = isprop(figure, "Theme") && isa(figure.Theme, "matlab.graphics.theme.GraphicsTheme"); +end diff --git a/src/visualize/+mag/+graphics/+factory/DefaultFactory.m b/src/visualize/+mag/+graphics/+factory/DefaultFactory.m index 46fa79aa..0dc21409 100644 --- a/src/visualize/+mag/+graphics/+factory/DefaultFactory.m +++ b/src/visualize/+mag/+graphics/+factory/DefaultFactory.m @@ -34,7 +34,7 @@ f = figure(Name = options.Name, NumberTitle = "off", WindowState = options.WindowState, Visible = "off"); setVisibility = onCleanup(@() set(f, Visible = matlab.lang.OnOffSwitchState(options.Visible))); - if isprop(f, "Theme") + if mag.internal.isThemeable(f) f.Theme = options.Theme; else warning("Theme ""%s"" cannot be applied.", options.Theme);