Skip to content

feat: add view mode buttons to the FMX studio toolbar - #8

Open
bero wants to merge 2 commits into
GDKsoftware:mainfrom
bero:feature/view-mode-toolbar-buttons-fmx
Open

bero wants to merge 2 commits into
GDKsoftware:mainfrom
bero:feature/view-mode-toolbar-buttons-fmx

Conversation

@bero

@bero bero commented Sep 16, 2026

Copy link
Copy Markdown

Depends on #7

This is stacked on #7, which adds the same buttons to the VCL studio and defines the shared glyph and hint constants. Until #7 merges, this branch also shows that commit. Please merge #7 first.

What

Brings the FMX studio to parity with the VCL one, adding Editor only, Split view and Preview only to its toolbar.

How

The FMX toolbar has no toggle control to lean on. Each button is a TRectangle with a child TText glyph, and hover is drawn by assigning Fill.Color directly. So the active mode is drawn as a filled background, one step beyond the hover tone in both themes.

Two existing behaviors would otherwise wipe that fill:

  • HandleIconMouseLeave reset any button to the plain toolbar fill.
  • The theme switch loops over every icon button and resets its fill.

Both now go through a new RestingColorFor helper, which returns the active color for whichever view button matches the current mode and the toolbar fill for everything else. ApplyViewMode calls UpdateViewModeButtons, the same hook point used in the VCL form, so the lit button follows Ctrl+1 / Ctrl+2 / Ctrl+3, the command palette, session restore and leaving zen mode.

One layout detail: left aligned FMX controls stack in reverse of their creation order, so the three are created preview first in order to read as editor, split, preview on screen and match the VCL toolbar.

Testing

  • Markdown4DStudioFMX builds clean on Win32 Debug with Delphi 12 Athens.
  • Ran the FMX studio and confirmed all three glyphs render and that exactly one button stays filled while clicking through editor, preview and split.
  • Opened a large real world document to check the buttons in a populated session.

The dark theme path is covered by construction rather than by a screenshot: FActiveColor is assigned in both branches of the theme switch, and the button loop there now calls RestingColorFor, so the active button keeps its fill across a theme change.

Add Editor only, Split view and Preview only buttons to the VCL studio
toolbar. The three buttons share a GroupIndex and leave AllowAllUp false,
so the VCL keeps exactly one of them pressed.

ApplyViewMode now syncs the pressed button, so it also follows the other
ways the mode can change: Ctrl+1/2/3, the command palette, session restore
and leaving zen mode.

Glyph and hint constants go in the shared defines unit next to the existing
toolbar glyphs. The code points are present in both Segoe Fluent Icons and
the Segoe MDL2 Assets fallback.
Bring the FMX studio to parity with the VCL one by adding Editor only,
Split view and Preview only buttons to its toolbar.

The FMX toolbar builds each button as a TRectangle with a child TText
glyph, so there is no toggle control to lean on. The active mode is drawn
as a filled background one step beyond the hover tone, through a new
RestingColorFor helper that both the mouse leave handler and the theme
switch consult. Without that the pressed look was cleared as soon as the
pointer left the button or the theme changed.

ApplyViewMode calls UpdateViewModeButtons, the same hook used in the VCL
form, so the lit button follows Ctrl+1/2/3, the command palette, session
restore and leaving zen mode as well as the toolbar itself.

Left aligned FMX controls stack in reverse of their creation order, so the
three are created preview first to read as editor, split, preview on screen
and match the VCL layout.
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