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

UI styling revision #100

Merged
merged 59 commits into from
Feb 16, 2025
Merged

UI styling revision #100

merged 59 commits into from
Feb 16, 2025

Conversation

martinfouilleul
Copy link
Collaborator

@martinfouilleul martinfouilleul commented Feb 7, 2025

This simplifies the UI styling system and its API:

  • Boxes don't inherit any styling from their parents. This avoids confusion about which attributes are inherited and which are not, and allows reasoning locally without caring as much about the context in which a widget will be called.
  • All boxes are now blocks declared with oc_ui_box_begin()/oc_ui_box_end() (or the oc_ui_box()) macro
  • Boxes don't take flags anymore. These have been moved to styling attributes or removed.
  • Inside a box block you can directly set style attributes with oc_ui_style_set_xxx() functions, eg oc_ui_style_set_i32() for integer attributes or flags, oc_ui_style_set_color() for color attributes, etc.
  • You can tag boxes with strings using oc_ui_tag().
  • You can define a style rule with oc_ui_style_rule_begin()/oc_ui_style_rule_end() (or the oc_ui_style_rule()) macro. Rule patterns are now passed as strings and parsed by the UI system, without needing to setup the pattern structs. E.g. you can target box "A" with tags "x" and "y" with the pattern "A.x.y", or descendant B of A with "A B". Hover and active statuses are also tags, so for example you can target "A.hover".
  • Inside a style rule you can use the same oc_ui_style_set_xxx() functions to set the rule's style.
  • You can define style variables with oc_ui_var_set_xxx() functions (which create/overwrite variables) or oc_ui_var_default_xxx() (which only creates the variable if isn't already declared upstream).
  • You can set a style attribute in a box or in a rule with a variable with oc_ui_style_set_var().
  • Themes have been replaced with a number of default variables. Modifying the theme for a subtree amounts to changing the appropriate variables.

…PU must be done with drawing before we tear down the surface)
…d passing style to them, now that we infer common drawing from the style
…kground, text, ...) but 0 is _enabled_ and 1 is disabled. This allows using style struct to pass colors etc to draw proc but selectively disable default drawing
@martinfouilleul
Copy link
Collaborator Author

There's a couple other things I'd also like to cleanup in the rest of the UI:

  • review and homogeneize the usage of hot/active/focus states
  • Review the light theme
  • Review mouse blocking
  • Layout could also have another pass: some width attributes could use oc_ui_size instead of a float, some could be split into left/right/top/bottom components, etc
  • Custom vars could be modifyable through rules.

But this can probably be left to a subsequent PR

@martinfouilleul martinfouilleul marked this pull request as ready for review February 16, 2025 15:10
@martinfouilleul martinfouilleul merged commit 4f124dd into main Feb 16, 2025
11 checks passed
@martinfouilleul martinfouilleul deleted the ui-styling-revision branch February 16, 2025 16:02
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.

2 participants