nativeclip

package
v0.82.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package nativeclip works out the geometry of showing only the part of a native control that its viewport still shows.

Every native-control descriptor carries a Clip: the rectangle of the control that is still inside whatever scrolls it. Three backends embed real OS controls -- Cocoa, GTK and Win32 -- and each honours that rectangle with a different primitive:

  • Cocoa and GTK NEST: a clipping view (an NSView, a GtkFixed with overflow hidden) takes the visible rectangle, and the control sits inside it, offset so the right part of it shows. Both want Frames.
  • Win32 MASKS: the control's own window is confined to a region, given in the control's own coordinates. That is Region.

The decision of WHETHER to clip is the same for all three, and it lives here once. Restated at three call sites it would drift: the case that decides whether a control is wrapped at all is easy to spell three subtly different ways, and two of them would be wrong on a platform nobody is looking at.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clipped

func Clipped(rect, clip toolkit.Rect) bool

Clipped says whether a control shows only PART of itself: its clip is a real rectangle, and smaller than where it wants to be.

Equal rectangles are not clipped -- that is the ordinary case and honouring it would cost a view, or a region, per control for nothing. An empty clip is not clipped either: the descriptor already reports that as not Visible, and every backend hides it, which is cheaper and was the only part of this a backend could honour before.

func Frames

func Frames(rect, clip toolkit.Rect) (outer, inner toolkit.Rect)

Frames is, for a backend that nests, where the clipping view goes and where the control goes inside it: the view takes the visible rectangle, and the control keeps its full size at the offset that puts the right part of it on show.

The control is NOT resized to the clip. A button squashed to the sliver of it that shows would redraw its label to fit and look like a different button; moved behind a smaller window, it is the same button with part of it out of sight, which is what scrolling means.

func Region

func Region(rect, clip toolkit.Rect) toolkit.Rect

Region is, for a backend that masks, the part of the control the system may draw -- expressed in the CONTROL's own coordinates, because that is the space a window region is read in, not the window's parent's.

It is the same geometry Frames describes, seen from the other side: where Frames offsets the control inside the visible box, Region offsets the visible box inside the control. The two therefore disagree in sign, and a test here holds them to it.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL