Skip to content

[codex suggestion] Make ruler corner placements axis-specific #209

Closed

Description

@pascalpp

Depends on #192 landing, because this suggestion builds on the zero-corner/orientation placement work from that feature.

Background

The current RulerCornerPlacement stores both axes as RulerSide:

  • xSide: RulerSide
  • ySide: RulerSide

That works at runtime because ZeroCornerGeometry only creates valid combinations, but the type can still represent invalid states such as xSide == .top or ySide == .left. Because of that, callers like UnitLabelView.labelFrame(...) still need defensive fallback/assertion cases even after their valid corner cases are covered.

Suggestion

After #192 lands, consider making the placement axes explicit, for example:

enum RulerHorizontalSide {
    case left
    case right
}

enum RulerVerticalSide {
    case top
    case bottom
}

struct RulerCornerPlacement: Equatable {
    let xSide: RulerHorizontalSide
    let ySide: RulerVerticalSide
}

Then impossible states become unrepresentable: xSide could only be left/right, and ySide could only be top/bottom.

Expected Benefit

This should simplify consumers such as UnitLabelView and ResizeHandleView, make placement switches genuinely exhaustive, and remove some fallback assertion branches that only exist because invalid side combinations are currently type-representable.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions