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

Add Visual Style manager #2181

Closed
tig opened this issue Nov 4, 2022 · 2 comments
Closed

Add Visual Style manager #2181

tig opened this issue Nov 4, 2022 · 2 comments
Labels
enhancement v2 For discussions, issues, etc... relavant for v2

Comments

@tig
Copy link
Collaborator

tig commented Nov 4, 2022

With

I suggest we invest in a Visual Style manager.

Basic idea:

  • Build a JSON schema for the existing visual style settings on the various Views; it's important that this supports the library as it is NOW.
  • Enhance existing View classes to have static "default" style properties (similar to what I did in my PR to Fixes 2144. Add half-height bottom shadow for Effect3D. #2166 that enabled UI Catalog to set the Button style globally.
  • Build a component that reads a JSON doc and applies the specified styles such that all views that support it get their defaults set when the library loads.
  • Build a mechanism for apps to configure per-app state
    • A visualstyle.json file that gets built into the app's assembly.
  • Build a mechanism for storing user-defined per-app state.
    • A ~/.tui folder for global settings. ~/.tui/UICatalogApp.visualstyle.json would set the visual style of any app with a main class name of UICatalogApp. Unless...
    • A ./.tui folder for local settings.
      • ./.tui/UICatalogApp.visualstyle.json would set the visual style of any app with a main class name of UICatalogApp launched from anywhere under ./.
      • ./.tui/visualstyle.json would set the default visual style of any app launched from anywhere under ./.

I'm sure this has been invented before and we can plagiarize.

Let the debate begin! :-)

@tig tig added the enhancement label Nov 4, 2022
@tig
Copy link
Collaborator Author

tig commented Nov 5, 2022

Assume an app runs. The settings will be applied using the following precedence:

Priority descends in this order:

  1. Global settings in home directory (~/.tui/visualstyle.json) -- highest priority
  2. App settings in home directory (~/.tui/appname/visualstyle.json)
  3. Global settings in local directories (./.tui/visualstyle.json)
  4. App settings in local directories (./.tui/appname/visualstyle.json)
  5. Settings in Terminal.Gui assembly -- lowest priority

The style manager first uses the settings from any copy of the visualstyle.json in the .tui/ directory in the user's home directory. Then it looks for any copies of the file located in the app directories, adding any settings found in them, but ignoring attributes already discovered in higher-priority locations. As a last resort, for any settings not explicitly assigned at either the global or app level, it assigns default values from the settings compiled into Terminal.Gui.dll.

(Up for debate/discussion)

tig added a commit that referenced this issue Feb 20, 2023
Fixes #2181 - Adds configuration manager
@tig tig added the v2 For discussions, issues, etc... relavant for v2 label Feb 28, 2023
@tig tig moved this to ✅ Done in Terminal.Gui V2 Beta Feb 28, 2023
@tig
Copy link
Collaborator Author

tig commented Apr 14, 2023

This is fixed by #2181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement v2 For discussions, issues, etc... relavant for v2
Projects
No open projects
Status: ✅ Done
1 participant