Skip to content

Create Frameless(false) overload to undo Frameless() behavior#4856

Merged
swharden merged 6 commits intoScottPlot:mainfrom
manaruto:restore-frameless-operation
Mar 22, 2025
Merged

Create Frameless(false) overload to undo Frameless() behavior#4856
swharden merged 6 commits intoScottPlot:mainfrom
manaruto:restore-frameless-operation

Conversation

@manaruto
Copy link
Contributor

@manaruto manaruto commented Mar 16, 2025

This pull request introduces a new method, RestoreFrameless, to the AxisManager class. Its purpose is to revert the frameless state by restoring the visibility of the axes and title. Additionally, corresponding changes have been made in the LayoutManager and Plot classes to expose this functionality at higher levels.

Changes Made

AxisManager.cs

Added RestoreFrameless(bool showTitle = true) Method:
This new method sets all X and Y axes’ IsVisible property to true, effectively reverting the state applied by Frameless(). The title's visibility is controlled by an optional parameter.

/// <summary>
/// Reverts the frameless state by making all axes visible.
/// </summary>
/// <param name="showTitle">Optional: if true, the title is also shown; default is false.</param>
public void RestoreFrameless(bool showTitle = false)
{
    XAxes.ForEach(x => x.IsVisible = true);
    YAxes.ForEach(x => x.IsVisible = true);
    Title.IsVisible = showTitle;
}

LayoutManager.cs

Added RestoreFrameless() Method:
This method calls the new RestoreFrameless on the plot’s axes. This ensures that users who applied a frameless layout via the LayoutManager can now revert the change.

/// <summary>
/// Reverts the frameless layout by restoring the visibility of axes.
/// </summary>
public void RestoreFrameless()
{
    Plot.Axes.RestoreFrameless();
}

Plot.cs

Added ShowAxesAndGrid(bool showTitle = true) Helper Method:
This method reverses the frameless state by calling RestoreFrameless on the AxisManager and then re-enables grid visibility.

/// <summary>
/// Restore visibility for axes and grid (revert frameless settings).
/// </summary>
public void ShowAxesAndGrid(bool showTitle = false)
{
    Axes.RestoreFrameless(showTitle);
    ShowGrid();
}

Example to undo the frameless operation:

myPlot.Layout.RestoreFrameless();
restore-frameless.mp4

manaruto and others added 5 commits March 16, 2025 09:57
…less mode in AxisManager

Implemented RestoreFrameless(bool showTitle = true), which makes all X and Y axes visible.
…ger to restore axes visibility

-Added RestoreFrameless(), which calls AxisManager.RestoreFrameless().
-Ensures users can revert the frameless mode from LayoutManager.
@swharden
Copy link
Member

Hi @manaruto, thank you so much for this pull request! This is one of the most beautiful and descriptive pull requests I have every seen ✨ Thank you for your great work! 🚀

I'm going to refine this a bit, changing the API slightly, and extending the cookbook to improve how these strategies are documented. I'll merge this in today and make a new release this weekend, so these changes will go live soon.

Thanks again!
Scott

@swharden swharden changed the title Restore frameless operation Create Frameless(false) overload to undo Frameless() behavior Mar 22, 2025
@swharden swharden merged commit d52b463 into ScottPlot:main Mar 22, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Frameless: how to "undo" frameless view?

2 participants