package system import "image" import "git.tebibyte.media/tomo/tomo" import "git.tebibyte.media/tomo/tomo/input" import "git.tebibyte.media/tomo/tomo/canvas" // parent is any hierarchical type which contains other boxes. This can be a // Hierarchy, containerBox, etc. type parent interface { // hierarchy returns the hierarchy the parent is apart of. getHierarchy () *Hierarchy // canvas returns the canvas held by the parent. getCanvas () canvas.Canvas // getInnerClippingBounds returns the area of the canvas that children // can draw to. getInnerClippingBounds () image.Rectangle // notifyMinimumSizeChange informs the parent that the minimum size of // one of its children has changed. notifyMinimumSizeChange (anyBox) // drawBackgroundPart draws a part of the parent's background to the // given Canvas, filling the Canvas's entire bounds. The origin (0, 0) // of the given Canvas is assumed to be the same as the parent's canvas. drawBackgroundPart (canvas.Canvas) // catches returns whether or not this parent masks events. masks () bool } // anyBox is any tomo.Box type that is implemented by this package. type anyBox interface { tomo.Box canvas.Drawer // setParent sets this anyBox's parent. // getParent returns this anyBox's parent as set by setParent. setParent (parent) getParent () parent // doDraw re-paints the anyBox onto its currently held Canvas non-recursively // doLayout re-calculates the layout of the anyBox non-recursively // doStyle re-applies the box's style non-recursively doDraw () doLayout () doStyle () // flushActionQueue performs any queued actions, like invalidating the // minimum size or grabbing input focus. flushActionQueue () // recursiveRedo recursively recalculates the minimum size, layout, and // re-paints this anyBox and all of its children. recursiveRedo () // loseCanvas causes this anyBox and its children (if applicable) to // lose their canvases and re-cut them as needed. recursiveLoseCanvas () // recursiveReAppply causes this anyBox and its children (if applicable) // to check whether they have an outdated style or icon set, and if so, // update it and trigger the appropriate event broadcasters. recursiveReApply () // minimumSize returns the box's minimum size minimumSize () image.Point // contentMinimum returns the minimum dimensions of this box's content contentMinimum () image.Point // canBeFocused returns whether or not this anyBox is capable of holding // input focus. canBeFocused () bool // boxUnder returns the anyBox under the mouse pointer. It can be this // anyBox, one of its children (if applicable). It must return nil if // the mouse pointer is outside of this anyBox's bounds. boxUnder (image.Point) anyBox // transparent returns whether or not this anyBox contains transparent // pixels or not, and thus needs its parent's backround to be painted // underneath it. transparent () bool // setBounds sets the box's bounds. setBounds (image.Rectangle) // setAttr sets an attribute at the user or style level depending // on the value of user. setAttr (attr tomo.Attr, user bool) // unsetAttr unsets an attribute at the user or style level depending // on the value of user. unsetAttr (kind tomo.AttrKind, user bool) // propagate recursively calls a function on this anyBox, and all of its // children (if applicable) The normal propagate behavior calls the // callback on all children before calling it on this anyBox, and // propagateAlt calls the callback on this anyBox before calling it on // its children. propagate (func (anyBox) bool) bool propagateAlt (func (anyBox) bool) bool handleFocusEnter () handleFocusLeave () // handleDndEnter () // handleDndLeave () // handleDndDrop (data.Data) handleMouseEnter () handleMouseLeave () handleMouseMove () bool handleMouseDown (input.Button) bool handleMouseUp (input.Button) bool handleScroll (float64, float64) bool handleKeyDown (input.Key, bool) bool handleKeyUp (input.Key, bool) bool } type anyContentBox interface { anyBox // recommendedWidth returns the recommended width for a given height. recommendedWidth (int) int // recommendedHeight returns the recommended height for a given height. recommendedHeight (int) int } func assertAnyBox (unknown tomo.Box) anyBox { if box, ok := unknown.(anyBox); ok { return box } else { panic("system: foregin box implementation, i did not make this!") } }