Skip to content

Conversation

GHOST3118
Copy link
Contributor

@GHOST3118 GHOST3118 commented Jul 29, 2025

Переработка подсистемы UI.

Готовый функционал и фичи:

  • inline-стили
  • class селекторы
  • id селекторы
  • селекторы по тегам
  • сложные селекторы
  • псевдо-селекторы
  • наследование

В планах:

  • вложенные правила css
  • медиа-выражения (возможно)
  • css переменные
  • @ important

Планы:

  • добавить таблицы стилей
    • Stylesheet parser
    • Selector parser
    • Declaration parser
  • Переделать систему узлов
    • Дерево узлов
    • Отрисовка
    • Система состояний
    • Оптимизация
  • Добавить менеджер таблиц стилей
    • Хранилище стилей
    • Вычислитель стилей
  • добавить загрузчики стилей
  • добавить Lua биндинги

GHOST3118 added 11 commits July 30, 2025 00:09
- Introduced `StyleContext` class to manage UI element styles, including tag, ID, classes, and states.
- Implemented methods for adding, removing, and checking classes and states within `StyleContext`.
- Added functionality to synchronize `StyleContext` with associated `UINode`.
- Created `Stylesheet` class to manage style rules and selectors, including parsing CSS-like rules.
- Enhanced `value` class to support various data types and added factory methods for creating values from strings.
- Implemented `StylesheetParser` for parsing CSS strings into style rules and properties.
- Improved type safety and organization of style-related code with enums and structured classes.
- Removed the StylesheetParser.h file as it was no longer needed.
- Updated value.cpp to remove an unnecessary return statement in the Hash operator.
- Implemented Node class in Node.cpp and Node.hpp for XML node representation, including methods for child management, attribute handling, and searching by tag/path.
- Added CSSSelectorParser class in SelectorParser.cpp and SelectorParser.hpp for parsing CSS selectors, including support for combinators and pseudo-classes.
- Introduced StylesheetParser class in StylesheetParser.hpp for parsing stylesheets, including rules and declarations.
- Created a test CSS file (test.css) with a basic style rule.
- Added root property to Node structure to identify root nodes.
- Implemented methods in ElementData for managing ID and class attributes:
  - getId, setId for ID management.
  - getClassList, setClassList, addClass, removeClass, hasClass, toggleClass for class management.
- Updated Node class to include is_root method.
- Introduced ComputedStyle structure in Stylesheet for managing CSS properties.
- Created DeclarationParser for parsing CSS declarations.
- Implemented StyleComputer for computing styles based on stylesheets and node structure.
- Enhanced StylesheetParser to support parsing of stylesheets with improved error handling.
- Consolidated layout computation logic into a single method, `compute_layout`, improving readability and maintainability.
- Removed the `apply_styles_to_layout` method and integrated its functionality directly into the layout computation process.
- Enhanced the handling of text layout by calculating dimensions based on font size.
- Introduced a new `LayoutContext` structure to manage layout context more effectively.
- Updated `LayoutBox` to simplify its structure, focusing on essential properties for layout calculations.
- Improved the handling of child layout computations, allowing for better flexibility in layout direction (vertical/horizontal).
- Refined style value handling in `value.cpp` and `value.h`, ensuring consistent type management and default values.
- Adjusted color handling to default to transparent instead of opaque in `asColor` method.
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.

1 participant