VSeed, an elegant data composer, transforming complexity into simplicity.
!!!###!!!title=2.5 Scene Tree Update——VisActor/VTable Contributing Documents!!!###!!!!!!###!!!description=---title: 2.5 Scene Tree Update
key words: VisActor,VChart,VTable,VStrory,VMind,VGrammar,VRender,Visualization,Chart,Data,Table,Graph,Gis,LLM---
!!!###!!!
Trigger Update
Under what circumstances does the scene tree update occur? Generally, it is triggered in three situations: data change-driven, user interaction, and layout change.
Data-driven: When the attributes of the table change, such as width, height, or element changes: trigger updateColWidth / updateRowHeight / updateCell respectively.
User Interaction: Users interact with the table: trigger resize (drag column width) / updateSortIcon (sort icon)
Layout Change: Changes in device size and display mode trigger changes in layout, which will also lead to table updates: dealWidthMode (adaptive layout)
Update Process
**1. Attribute Modification (Core Method:
Directly modify element attributes (such as position, size, style)
Column Width Update: Modify the width attribute of the column container using setAttribute.
Recalculate container coordinates and dimensions based on attribute changes, specifically controlling the update process through the needUpdateContainer flag. This ensures that layout calculations (column width/coordinate adjustments), size synchronization (table/frozen area), component status (scroll bar), and other steps are executed sequentially only when updates are needed, followed by rendering submission (updateNextFrame). The rendering engine is triggered (rendering the next frame) through stage.renderNextFrame.
Adaptive Layout: Dynamically allocate remaining space, overriding manual adjustment results. My interpretation focuses on dealHeightMode and dealwitdhMode:
dealWidthMode() method is responsible for handling the adaptive layout and auto-fill logic of table column widths: When widthMode: 'adaptive' is enabled, it first clears the historical column width cache, calculates the fixed total width of the row header and the right frozen columns, and proportionally allocates the remaining canvas space to non-frozen columns. If autoFillWidth is enabled, it checks whether the total content width is less than the canvas width, and if insufficient, it proportionally enlarges the non-frozen columns. After completing the column width calculation, it traverses the sub-column elements of the body area (bodyGroup), column header area (colHeaderGroup), row header area (rowHeaderGroup), and corner header area (cornerHeaderGroup), accumulates the actual width of each column, and dynamically sets the total width of the container. Finally, it adjusts the coordinate positions of the column header and the body to ensure that the column header is closely aligned to the right of the corner header and the body area is closely aligned to the right of the row header, forming a complete horizontal layout flow. Ultimately, the container property update drives the rendering engine to synchronize the visual performance.
dealHeightMode The logic for handling height and width is highly similar and symmetrical. Both conform to the core idea of table adaptive layout;
3. Dirty Marking (VRender Internal Mechanism)
Mark the primitives that need to be redrawn to avoid full rendering. Dirty marking is a performance optimization technique used to identify data or objects that need updating, avoiding full computation or rendering, thereby improving efficiency. In graphics rendering, it tracks the changed parts and only processes the "dirty" areas instead of the entire scene. \r