diff --git a/deploy/wtDeployVersion.txt b/deploy/wtDeployVersion.txt index 8e8299d..35cee72 100644 --- a/deploy/wtDeployVersion.txt +++ b/deploy/wtDeployVersion.txt @@ -1 +1 @@ -2.4.2 +2.4.3 diff --git a/deploy/wtPackageRelease.m b/deploy/wtPackageRelease.m index e02e184..ee93ef2 100644 --- a/deploy/wtPackageRelease.m +++ b/deploy/wtPackageRelease.m @@ -79,6 +79,9 @@ % Perform the packaging matlab.addons.toolbox.packageToolbox(opts); +% Add the installer to the project +proj.addFile(outputFile) + %% Open the release folder diff --git a/release/Widgets Toolbox 2.4.3.mltbx b/release/Widgets Toolbox 2.4.3.mltbx new file mode 100644 index 0000000..7320e10 Binary files /dev/null and b/release/Widgets Toolbox 2.4.3.mltbx differ diff --git a/resources/project/FVIFMHuse2VWlFgbqX2S_OQzxiU/wiaqm3NNHmVY8LuWBCicO_y5Mh8d.xml b/resources/project/FVIFMHuse2VWlFgbqX2S_OQzxiU/wiaqm3NNHmVY8LuWBCicO_y5Mh8d.xml new file mode 100644 index 0000000..4356a6a --- /dev/null +++ b/resources/project/FVIFMHuse2VWlFgbqX2S_OQzxiU/wiaqm3NNHmVY8LuWBCicO_y5Mh8d.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/project/FVIFMHuse2VWlFgbqX2S_OQzxiU/wiaqm3NNHmVY8LuWBCicO_y5Mh8p.xml b/resources/project/FVIFMHuse2VWlFgbqX2S_OQzxiU/wiaqm3NNHmVY8LuWBCicO_y5Mh8p.xml new file mode 100644 index 0000000..5403f26 --- /dev/null +++ b/resources/project/FVIFMHuse2VWlFgbqX2S_OQzxiU/wiaqm3NNHmVY8LuWBCicO_y5Mh8p.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/project/LwJcy9ZaEyJvuNK-ApM3PZoS5oo/2c0Mb_HC_Bqx0ppy90pAhyL-374d.xml b/resources/project/LwJcy9ZaEyJvuNK-ApM3PZoS5oo/2c0Mb_HC_Bqx0ppy90pAhyL-374d.xml new file mode 100644 index 0000000..99772b4 --- /dev/null +++ b/resources/project/LwJcy9ZaEyJvuNK-ApM3PZoS5oo/2c0Mb_HC_Bqx0ppy90pAhyL-374d.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/resources/project/LwJcy9ZaEyJvuNK-ApM3PZoS5oo/2c0Mb_HC_Bqx0ppy90pAhyL-374p.xml b/resources/project/LwJcy9ZaEyJvuNK-ApM3PZoS5oo/2c0Mb_HC_Bqx0ppy90pAhyL-374p.xml new file mode 100644 index 0000000..6d5b74e --- /dev/null +++ b/resources/project/LwJcy9ZaEyJvuNK-ApM3PZoS5oo/2c0Mb_HC_Bqx0ppy90pAhyL-374p.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/widgets/+wt/+apps/BaseApp.m b/widgets/+wt/+apps/BaseApp.m index a59c721..b7eee00 100644 --- a/widgets/+wt/+apps/BaseApp.m +++ b/widgets/+wt/+apps/BaseApp.m @@ -386,79 +386,8 @@ function moveOnScreen(app) % Show output if Debug is on app.displayDebugText(); - if strcmp(app.Figure.Units,'pixels') - - % Get the corners of each screen - g = groot; - screenPos = g.MonitorPositions; - screenCornerA = screenPos(:,1:2); - screenCornerB = screenPos(:,1:2) + screenPos(:,3:4) - 1; - - % Buffer for title bar - titleBarHeight = 30; - - % Get the corners of the figure (bottom left and top right) - figPos = app.Figure.OuterPosition; - figCornerA = figPos(1:2); - figCornerB = figPos(1:2) + figPos(:,3:4) - 1; - - % Are the corners on any screen? - aIsOnScreen = all( figCornerA >= screenCornerA & ... - figCornerA <= screenCornerB, 2 ); - bIsOnScreen = all( figCornerB >= screenCornerA & ... - figCornerB <= screenCornerB, 2); - - % Are corners on a screen? - - % Are both corners fully on any screen? - if any(aIsOnScreen) && any(bIsOnScreen) - % Yes - do nothing - - elseif any(bIsOnScreen) - % No - only upper right corner is on a screen - - % Calculate the adjustment needed, and make it - figAdjust = max(figCornerA, screenCornerA(bIsOnScreen,:)) ... - - figCornerA; - figPos(1:2) = figPos(1:2) + figAdjust; - - % Ensure the upper right corner still fits - figPos(3:4) = min(figPos(3:4), ... - screenCornerB(bIsOnScreen,:) - figPos(1:2) - [0 titleBarHeight] + 1); - - % Move the figure - app.Figure.Position = figPos; - - elseif any(aIsOnScreen) - % No - only lower left corner is on a screen - - % Calculate the adjustment needed, and make it - figAdjust = min(figCornerB, screenCornerB(aIsOnScreen,:)) ... - - figCornerB; - figPos(1:2) = max( screenCornerA(aIsOnScreen,:),... - figPos(1:2) + figAdjust ); - - % Ensure the upper right corner still fits - figPos(3:4) = min(figPos(3:4), ... - screenCornerB(aIsOnScreen,:) - figPos(1:2) - [0 titleBarHeight] + 1); - - % Move the figure - app.Figure.Position = figPos; - - else - % No - Not on any screen - - % This is slower, but uncommon anyway - movegui(app.Figure,'onscreen'); - - end %if any( all(aIsOnScreen,2) & all(bIsOnScreen,2) ) - - else - - % This is slower, but uncommon anyway - movegui(app.Figure,'onscreen'); - - end %if strcmp(app.Figure.Units,'pixels') + % Move it on screen + wt.utility.moveOnScreen(app.Figure); end %function diff --git a/widgets/+wt/+utility/moveOnScreen.m b/widgets/+wt/+utility/moveOnScreen.m new file mode 100644 index 0000000..ccbbf52 --- /dev/null +++ b/widgets/+wt/+utility/moveOnScreen.m @@ -0,0 +1,87 @@ +function moveOnScreen(fig) +% Ensure the figure is placed on screen + +% Copyright 2025 The MathWorks, Inc. + +% Define arguments +arguments + fig (1,1) matlab.ui.Figure +end + +% Figure must be in pixel units +if ~strcmp(fig.Units,'pixels') + oldUnits = fig.Units; + cleanupObj = onCleanup(@()set(fig,"Units",oldUnits)); + fig.Units = 'pixels'; +end + +% Get screen positions +g = groot; +screenPos = g.MonitorPositions; + +% Buffer for title bar +titleBarHeight = 30; + +% Get the corners of the figure (bottom left and top right) +figPos = fig.OuterPosition; +figCornerA = figPos(1:2); +figCornerB = figPos(1:2) + figPos(:,3:4) - 1; + +% Calculate the figure's area shown on each screen +overlapAreas = zeros(size(screenPos, 1), 1); +for i = 1:size(screenPos, 1) + thisScreen = screenPos(i, :); + overlapWidth = max(0, min(figPos(1) + figPos(3), thisScreen(1) + thisScreen(3)) - max(figPos(1), thisScreen(1))); + overlapHeight = max(0, min(figPos(2) + figPos(4), thisScreen(2) + thisScreen(4)) - max(figPos(2), thisScreen(2))); + overlapAreas(i) = overlapWidth * overlapHeight; +end + +% Determine the screen with the largest overlap +[~, screenIdx] = max(overlapAreas); + +% Get the corners of the screen +screenCornerA = screenPos(screenIdx, 1:2); +screenCornerB = screenCornerA + screenPos(screenIdx, 3:4) - 1; + +% Are the corners on the screen? +aIsOnScreen = all( figCornerA >= screenCornerA & ... + figCornerA <= screenCornerB, 2 ); +bIsOnScreen = all( figCornerB >= screenCornerA & ... + figCornerB <= screenCornerB, 2); + + +% Are both corners fully on one screen? +if aIsOnScreen && bIsOnScreen + % Yes - do nothing + +elseif bIsOnScreen + % Upper right corner is on a screen + % Adjust so the entire figure is on that screen + + % Calculate the adjustment needed, and make it + figAdjust = max(figCornerA, screenCornerA) - figCornerA; + figPos(1:2) = figPos(1:2) + figAdjust; + + % Ensure the upper right corner still fits + requestedSize = screenCornerB - figPos(1:2) - [0 titleBarHeight] + 1; + figPos(3:4) = min(figPos(3:4), requestedSize); + + % Move the figure + fig.Position = figPos; + +else + % Lower left corner is on a screen + % Adjust so the entire figure is on that screen + + % Calculate the adjustment needed, and make it + figAdjust = min(figCornerB, screenCornerB) - figCornerB; + figPos(1:2) = max(screenCornerA, figPos(1:2) + figAdjust); + + % Ensure the upper right corner still fits + requestedSize = screenCornerB - figPos(1:2) - [0 titleBarHeight] + 1; + figPos(3:4) = min(figPos(3:4), requestedSize); + + % Move the figure + fig.Position = figPos; + +end %if