Commit Graph
4 Commits
Author SHA1 Message Date
David Richardson 8e4742a250 AppKit: Carry Interface Builder's Uses Ruler setting into cibs
nib2cib ignored the text view's Uses Ruler setting, and CPTextView, CPRulerView and CPRulerMarker archived none of their ruler state, so a ruler could not be configured in Interface Builder or survive archiving.

* CPScrollView.j: Set itself as the scroll view of decoded rulers.

* CPTextView/CPRulerMarker.j: Archive the marker's ruler, location, image and image origin, movability, removability and represented object.

* CPTextView/CPRulerView.j: Archive the ruler's orientation, client view, accessory view, markers, thicknesses, origin offset and measurement units.

* CPTextView/CPTextView.j: Archive usesRuler.

* Tools/nib2cib/NSTextView.j, Tools/nib2cib/NSTextViewSharedData.j: Read the Uses Ruler flag.

* Tests/AppKit/CPRulerViewTest.j: Add tests for ruler layout, measurement units, archiving and the Uses Ruler setting.

* Tests/Manual/TextEditor/Resources/MainMenu.xib, Resources/MainMenu.cib: Add the standard Format menu, whose Text submenu shows and hides the ruler.

* Tests/Manual/TextEditor/Resources/DocumentWindow.xib, Resources/DocumentWindow.cib: Rebuild the cib with the ruler setting, and adjust the window's initial position.
2026-10-23 21:10:17 -06:00
David Richardson e88313e34f AppKit: Let a dragged ruler marker follow the pointer off the ruler
A removable marker counted as off the ruler only 16 points beyond its edge, and stayed on its line while dragged off, so a tab stop dragged up off the ruler gave no sign of removal and was not removed on release.

It now follows Cocoa behaviour: the marker stays on its line while the pointer is on the ruler, follows the pointer out over the ruler's outer edge where the ruler clips it, and is removed when released off the ruler.

* CPTextView/CPRulerMarker.j: Reduce the removal distance from 16 points to zero; offset the marker across the ruler as the pointer moves outward during a drag, and draw it faded only when dragged off the inner edge.

* Tests/Manual/TextEditor/WORKLIST.md: Record the marker appearance and vertical alignment as interim until Aristo3, and the drag behaviour in each direction.
2026-10-23 20:42:20 -06:00
David Richardson 1622990436 AppKit: Draw ruler markers sharply as the triangles the ruler always showed
The new ruler drew tab stops as L-shaped brackets, which differed from the triangles earlier versions showed, and placed marker images at fractional positions, so identical markers drew differently along the ruler.

* CPTextView/CPRulerMarker.j: Round marker image positions to whole points.

* CPTextView/CPTextView.j: Draw tab stops as triangles pointing right for a left tab, left for a right tab and down for a centre or decimal tab, with whole-point image origins.

* Tests/Manual/TextEditor/WORKLIST.md: Remove the ruler and text layout entries fixed in this series, move the remaining nib2cib ruler entry to the nib2cib section, and record the ruler and text width as tested.
2026-10-23 19:52:43 -06:00
David Richardson 00851abfa9 AppKit: Model CPRulerView and CPRulerMarker on NSRulerView and NSRulerMarker
Ruler classes departed from canonical NS versions, resulting in functional and visual gaps.:

markers were views that drew text characters and ignored their location argument, the ruler rebuilt its subviews on every update and had no origin offset, measurement units or reserved thicknesses, and CPTextView updated the ruler only on focus and typing attribute changes, had no ruler control methods, and never showed a right indent marker.

* AppKit.j: Import CPRulerMarker and CPRulerView.

* CPScrollView.j: Tile rulers by their required thickness, and give a ruler its scroll view when it is set.

* CPTextView/CPRulerMarker.j: Add CPRulerMarker as an object drawn by its ruler, with a marker location, an image and image origin, movability and removability, and tracking that adds, moves and removes markers through the client view.

* CPTextView/CPRulerView.j: Rewrite CPRulerView with an origin offset, registered measurement units defaulting to the user's region, reserved thicknesses for markers and an accessory view, Cocoa's client view methods, temporary ruler lines, and drawing in a single pass.

* CPTextView/CPTextView.j: Add usesRuler, isRulerVisible, setRulerVisible: and toggleRuler: with a Show Ruler or Hide Ruler title; update the ruler on every selection change; place tab stop, first line, head and tail indent markers relative to the start of the text, with SVG marker images and a context menu for changing tab types and resetting indents.

* Tests/Manual/TextEditor/DocumentWindowController.j: Show the ruler through setRulerVisible:.
2026-10-23 19:30:48 -06:00