Skip to content

Apos autoscale9 slim5 greptile#91

Closed
Lightning11wins wants to merge 107 commits intomasterfrom
apos_autoscale9-slim5-greptile
Closed

Apos autoscale9 slim5 greptile#91
Lightning11wins wants to merge 107 commits intomasterfrom
apos_autoscale9-slim5-greptile

Conversation

@Lightning11wins
Copy link
Contributor

After extracting changes into #87, #88, #89, and removing a few minor/unnecessary changes; this PR is hopefully slightly more manageable.

GitHub Relationships:

This PR includes several TODOs:

  • 3 TODOs for Israel to handle after Update Duplicate Detection #77 is merged into master.
  • 4 TODOs for Greg (although other reviewers are welcome to handle these if they have the requisite knowledge), in the following files: ht_render.c, htdrv_page.c, htdrv_tab.c, and htdrv_table.c.

There are several known issues with this code:

  • Table row details sometimes don't appear.
    • e.g. Broken left menus on the Kardia home page.
  • Code that breaks responsive layout.
    • widget/pane: resize action (test apps/kardia/modules/payroll/pay_form.app)
    • widget/image: offset & scale actions (not used anywhere)
    • widget/objcanvas: add_osrc_object()
  • ht_get_parent_w/h__INTERNAL() & wgtrGetContainerWidth/Height() should be merged.
    • They appear to give almost identical results, except when checking a top-level widget. In this case, ht_get_parent_h__INTERNAL() (mine) gives a height 2px taller.
  • Flexibility calculations that depend on page size cause breakage since the client assumes widget flexibility scale is constant.
    • This would be very hard to fix! The best solution I can think of so far is to rewrite the entire layout system to convert px -> % on the server, then do all layout client-side. However, I'm not sure this system could handle flexibility values at all.

…yout, button, editbox, html, image, label, scrollpane, textbutton, & treeview.
Fixes components, dropdowns, and images.
Renames flex variables to be more clear.
Send parent_w and parent_h to client.
Add tab-height support to apos.c.
Add design support to apos.c.
Add IsDesign to the WgtrClientInfo struct.

Fix spelling mistakes.
Clean up.
Add an error message when cxsecVerifySymbol_n() fails.
Improve an existing error message when htr_internal_WriteWgtrProperty() fails to write a property of an unknown type.
Set Centrallix event listener to be explicitly non-passive, fixing a console error when later code assumes that calling preventDefault() is allowed.
Fix a bug in qprintf() that caused % and & characters inside conditional printing areas to always print, regardless of the condition.
Improve documentation for qpfPrintf_va_internal() and qpf_grow_fn_t().
Clean up.
Add shortcut functions: ht_flex_x(), ht_flex_y(), ht_flex_w(), ht_flex_h().
Rename fl_scale_x (was total_fl_x).
Rename fl_scale_y (was total_fl_y).
Rename fl_scale_w (was total_fl_w).
Rename fl_scale_h (was total_fl_h).
Rename fl_parent_w (was parent_w).
Rename fl_parent_h (was parent_h).
Remove ht_flex_format_all and ht_flex_all().
Improve usage of new feature in previously updated widgets.

Fix spelling mistakes.
Clean up.
Clean up some apps.
Add Math.clamp() and Math.isBetween().
Add getParentSize(), getParentW(), and getParentH().
Refactor getRelativeX/Y/W/H() to call the new getRelative().
Refactor setRelativeX/Y/W/H() to call the new setRelative().
Add fast_setRelativeX/Y().
Add setResponsiveX/Y/W/H() using a new shared setResponsive().
Add responsiveness to moveTo() with the new functions.

Fix style guide mistakes.
Clean up.
Add support for more edge cases with undefined values to wgtrGetServerProperty().
Add the Log action (and docs).
Add the ReloadPage action (and docs).
Improve documentation for the Alert widget.
Add htr_action_point() to ht_render.js to handle the point action responsively.
Refactor pane and window widgets to use the htr_action_point().
Improve documentation and code clarity for htutil_point().
Improve documentation for the point action.
Update al_reflow() to create responsive CSS using the setResponsive() functions.
Improve documentation for al_childresize().
Optimize and clean up inefficient code.
Rewrite C & JS code to use responsive styling.
Fix a bug that allowed multiple tabs to be selected at once.

Fix spelling errors.
Clean up.
Remove the moveable attribute.
Simplify clock widget event code.
Clean up cl_get_time().
Fix unresponsive area used on editbox widgets.
Fix unresponsive area used on textarea widgets.
Add tab_w and tab_h parameters to tab_features.app to fix broken left and right tab locations.
Remove unnecessary button widget from autoscale_test.app.
Add dragging cursor styles for window widgets.
Add cursor styles for the checkbox, radiobutton, scrollpane, treeview, and window widgets.
Update existing cursor styles for the button, datetime, dropdown, imagebutton, tab, and textbutton widgets.
Add the .dt_dropdown CSS class to make styling the datetime dropdown easier.
Update table columns to use col-resize instead of move.
Clean up cursor CSS styles to follow consistent code styling.
…atives.

Rewrite getters and setters in the ClipObject polyfill to replace __defineGetter__() and __defineSetter__().
Rewrite getters in the datetime, dropdown, and radiobutton widgets to replace __defineGetter__().
Rewrite pg_area() constructor to replace __defineGetter__().
Define a base when parsing relative properties to fix edge cases.
Remove unused debug setters in the table widget.
Remove unused debug code.
…aster.

Replace calls to fast_setRelativeX/Y() with calls to setRelativeX/Y().
Remove obsolete workaround code.
Remove a completed todo.
Improve a comment.
Fix windows failing to release when the mouseup event comes from outside the web page.
Update responsive event listener to use a pattern more similar to other resize code.
Add .titlebar to window object.
Add global wn_windows array that stores all windows.
Fix critical invalid HTML generation for pgstat.
Add null guards and stack exhaustion checks to ht_get_parent_w/h__INTERNAL().
Add explicit initialization for fl_scale_* fields.
Fix quotes breaking CSS background-color.
Fix incorrect CSS styling.
Replace Math.clamp() & Math.isBetween() debug versions with their development versions.
Improve naming in thExcessiveRecursion().
Clean up.
Add copyright notice to htdrv_button.c.
Fix incorrect line wrap in copyright notice for net_http_conn.c.
Rewrite part of htr_extract_bgcolor() to make it more robust and readable.
Improve tab widget error handling.
Fix code that gets the type of tab pages (and improve its readability).
Fix a missing space that caused malformed scrollpane HTML to be generated for Netscape browsers.
Fix tab_features.app not updating tabs properly.

Remove code that checks the type of tabs because this data is not used.
Remove unused debug function: getClipped().
Clean up.
@Lightning11wins Lightning11wins added duplicate ai-review Request AI review of this PR labels Mar 10, 2026
@greptile-apps
Copy link

greptile-apps bot commented Mar 10, 2026

Greptile Summary

This PR implements a responsive autoscale layout system ("autoscale9 slim5") across 99 files. The core change is a server-side computation of per-widget CSS flexibility values (fl_scale_x/y/w/h, fl_parent_w/h) in apos.c, which are then emitted to the browser as CSS calc(%INTpx + (100%% - %INTpx) * %DBL) expressions via the new ht_flex_format macro family in ht_render.h. Most widget drivers (htdrv_tab, htdrv_table, htdrv_scrollpane, etc.) are updated to use these macros. Supporting changes include: a qprintf.c bug fix for %%/&& inside ignored conditionals, HTML5 modernisation in ht_render.c, and new sample apps for testing.

Key findings from the review:

  • util.h min/max macros use the GCC-only __typeof__ extension without #ifndef guards, risking redefinition conflicts and non-GCC build failures. These are marked temporary (pending branch Update Duplicate Detection #77) but need guards immediately.
  • mtask.c thExcessiveRecursion: the local stack-probe variable was changed to const; volatile is the more appropriate qualifier to prevent the compiler from eliding the allocation.
  • htdrv_radiobutton.c: the rewritten htrbRender() uses bare return -1 at multiple error exits rather than the project-mandated goto error pattern.
  • Multiple strcpy calls introduced across htdrv_tab.c, htdrv_table.c, htdrv_scrollpane.c, and ht_render.c should be strtcpy() per project convention.
  • Minor typo ("feildname") in a comment in htdrv_tab.c.
  • The PR description honestly documents several known breakages (table row details, pane/image/objcanvas resize, flexibility-scale-constant assumption) and deferred TODOs for other team members — reviewers should be aware these are known issues, not surprises.

Confidence Score: 3/5

  • The PR introduces significant new layout functionality with known regressions documented by the author; not yet safe to merge to master without addressing the outstanding breakages.
  • The responsive layout architecture is well-structured and the key recursive functions all retain their thExcessiveRecursion guards. However, the author's own PR description lists multiple known runtime breakages (broken left menus, broken resize actions, flexibility-scale instability), several deferred TODOs for other developers, and the util.h macro addition has a portability risk. These issues lower confidence from what would otherwise be a solid implementation.
  • centrallix/htmlgen/htdrv_tab.c (strcpy, typo), centrallix/htmlgen/htdrv_radiobutton.c (error-handling pattern), centrallix-lib/include/util.h (GCC-only macros without guards), centrallix-lib/src/mtask.c (const vs volatile for stack probe).

Important Files Changed

Filename Overview
centrallix/wgtr/apos.c Major refactor adding responsive CSS layout support (fl_scale_x/y/w/h), expanded aposSetOffsetBools with tabHeight param, new named constants replacing magic numbers. Extensive documentation added. All recursive functions retain thExcessiveRecursion checks. Generally clean.
centrallix/htmlgen/ht_render.c HTML generation modernised (HTML5 attributes, tab-indented output), new DATA_T_DOUBLE/DATETIME/INTVEC/STRINGVEC cases added to htr_internal_WriteWgtrProperty, fl_scale_* properties now emitted to client, script init order fixed. One new strcpy call should use strtcpy.
centrallix/htmlgen/htdrv_tab.c Extensive rewrite with improved error handling (goto err), responsive CSS support, new tab_height/tab_spacing properties, better selected-tab logic with name lookup. Issues: several strcpy calls should be strtcpy, one typo ("feildname"), driver init still uses strcpy.
centrallix/htmlgen/htdrv_table.c Table widget refactored for responsive layout using ht_flex_* macros, init call broken into readable segments, struct fields cleaned up. Two strcpy calls (t->osrc, t->titlecolor) should use strtcpy. demand_scrollbar logic flagged with TODO by the author.
centrallix/htmlgen/htdrv_radiobutton.c Large rewrite reformatting code and adding util.h include. Error handling uses bare return -1 throughout the nontrivial htrbRender() function instead of the project-mandated goto error pattern.
centrallix-lib/src/mtask.c Minor change: buf renamed to stack_ptr with const qualifier in thExcessiveRecursion(). The const qualifier may allow the compiler to elide the stack allocation; volatile would be more appropriate here.
centrallix-lib/src/qprintf.c Bug fix: %% and && escape sequences are now correctly skipped when inside an ignored conditional block (%[...%]), preventing them from being spuriously output. Clean and targeted fix.
centrallix-lib/include/util.h Adds min/max macros using GCC typeof extension without portability guards or #ifndef protection. Marked as temporary (TODO: remove after branch #77 merges) but could cause redefinition conflicts or build failures on non-GCC compilers in the meantime.
centrallix/include/ht_render.h New responsive layout macro system added (ht_flex_format, ht_flex, ht_get_fl_*, ht_flex_x/y/w/h). Well-documented with clear explanation of the responsiveness formula. Clean addition.
centrallix/include/apos.h New named constants (APOS_NOT_LINKED, APOS_IS_BORDER, APOS_VERTICAL, APOS_HORIZONTAL), new AposLine fields (loc_fl, my_fl) for responsive CSS, isScrollpane macro, aposSetOffsetBools signature updated to accept tabHeight. Well-organised.
centrallix/wgtr/wgtr.c New fl_scale_* and fl_parent_* fields added to wgtrGetPropertyType/wgtrGetPropertyValue and wgtrNewNode. Correctly initialised to 0.0/-1. DATA_T_DOUBLE type support added. Clean implementation.
centrallix/htmlgen/htdrv_scrollpane.c Large refactor integrating responsive layout macros and error handling improvements. One new strcpy in driver initialisation should use strtcpy per project convention.

Sequence Diagram

sequenceDiagram
    participant Browser
    participant net_http as net_http.c
    participant htr as ht_render.c
    participant wgtr as wgtr.c
    participant apos as apos.c
    participant drv as Widget Drivers (htdrv_*.c)

    Browser->>net_http: HTTP Request (app page)
    net_http->>htr: htrRender()
    htr->>wgtr: wgtrVerify() / wgtrNewNode()
    wgtr->>apos: aposAutoPositionWidgetTree()
    apos->>apos: aposPrepareTree()
    apos->>apos: aposBuildGrid() [recursion-checked]
    apos->>apos: aposSetFlexibilities() [recursion-checked]
    Note over apos: Calculates fl_scale_x/y/w/h<br/>and fl_parent_w/h per widget
    apos->>apos: aposSetLimits()
    apos->>apos: aposAutoPositionContainers() [recursion-checked]
    apos->>apos: aposSnapWidgetsToGrid(ClientInfo)
    Note over apos: Writes loc_fl / my_fl to AposLines<br/>for responsive CSS calc()
    apos-->>wgtr: fl_scale_* fields populated on pWgtrNode
    wgtr-->>htr: Widget tree with layout
    htr->>drv: htrRenderWidget() per widget
    drv->>drv: htrAddStylesheetItem_va (ht_flex_format calc())
    drv->>drv: htrAddScriptInit_va (tbld_init / tc addTab etc.)
    drv-->>htr: CSS + JS fragments
    htr->>htr: htr_internal_BuildClientWgtr_r()<br/>emits fl_scale_* props to JS
    htr-->>Browser: HTML with responsive calc() CSS<br/>+ wgtr JS object tree
Loading

Last reviewed commit: 9ced9a7

@Lightning11wins
Copy link
Contributor Author

Rereview complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request AI review of this PR duplicate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autoscaling/responsive widgets using CSS calc()

1 participant