GraphicBlock(3U)
π GraphicBlock β the interactor that shows off a graphic π
okay so this is GraphicBlock(3U) from the InterViews Reference Manual, and bestie, it's literally just an interactor whose whole personality is displaying a graphic. iconic behavior honestly.
β¨ SYNOPSIS β¨
#include <Unidraw/Graphic/grblock.h>
πΈ NAME πΈ
GraphicBlock β an interactor that displays a graphic. that's it. that's the girl. π
π¦ DESCRIPTION π¦
so a GraphicBlock is an interactor that displays a graphic, periodt. and the way that this is so useful is for interactors whose whole look is easiest to define with structured graphics β like, why fight it when structured graphics already ate? your GraphicBlock will draw its graphic whenever it gets a Draw or a Redraw call. no cap, it just does it. β¨
the graphic can also be aligned with respect to the GraphicBlock's canvas. here's the tea: the GraphicBlock positions its graphic so that its bounding box is aligned with the canvas when the canvas is allocated. on subsequent resizes, the portion of the graphic within the canvas is aligned. with the default alignment, for example, a graphic will be centered in the canvas initially. and if the canvas gets resized? then the part of the graphic that was in the center of the canvas before resizing will appear in the center of the canvas after resizing. it's giving "always keeps its fave in frame." πΈ
the graphic can be scrolled and zoomed as well. changing either the curwidth/curheight or the width/height members of the GraphicBlock's perspective effectively zooms the graphic. for example β and this one's important, write it down β calling the Adjust member function with a perspective whose curwidth and curheight are half that of the GraphicBlock's canvas will enlarge the graphic by a factor of two. π you can limit zooming to magnifications that are powers of two by specifying Binary for the Zooming parameter. slay.
and a GraphicBlock's natural size depends on the size of the graphic it displays and on any padding (that's white space surrounding the graphic, iykyk) that you specify. also: GraphicBlocks are infinitely stretchable horizontally and vertically by default. infinitely. stretchy. π
π PUBLIC OPERATIONS π
GraphicBlock(Graphic*, Coord pad = 0, Alignment = Center, Zooming = Continuous)GraphicBlock(const char*, Graphic*, Coord pad = 0, Alignment = Center, Zooming = Continuous)β create a newGraphicBlockwith the specified graphic, padding, alignment, and zooming behavior. and yes, with the second form you can also specify theGraphicBlock's instance name. two flavors, both valid. πvoid Update()βUpdateupdates theGraphicBlock's perspective to reflect any change in the values returned byGetGraphicBox(described below, keep scrolling bestie), which defines the extremities of the scrolling area.Updateshould be called after the graphic is changed. don't skip this step, fr fr.virtual void Highlight(boolean)β when highlighted,GraphicBlockdraws itself with the foreground and background colors of its graphic and its painter reversed. π³ reversed!!GraphicBlockuses its output painter to fill its canvas with background color, thus providing a background for the graphic. aesthetic support system.Graphic* GetGraphic()β return the graphic in theGraphicBlock, stored in the_graphicprotected member variable. she's protected, she's variable, she's yours. πfloat GetMagnification()void SetMagnification(float)β get and set the magnification applied to the graphic, relative to its magnification when theGraphicBlockwas created (that's1x, the baseline, the original selfie). π
π PROTECTED OPERATIONS π
void Init()β initialize theGraphicBlock, positioning its graphic according to the alignment specified in the constructor. the constructor calls this operation. subclasses should callInitif they should replace the displayed graphic with another. new graphic, who dis. πvoid UpdatePerspective()β change theGraphicBlock's perspective to reflect the bounding box of the graphic.UpdatePerspectiveencapsulates this functionality to facilitate redefinition of theUpdatefunction in derived classes. encapsulation nation, we love to see it.void GrabScroll(Event&)void RateScroll(Event&)β initiate grab scrolling or rate scrolling. once called,GrabScroll(RateScroll) polls the current mouse position as long as the middle (right) button is pressed. β οΈ middle button forGrabScroll, right button forRateScroll, do not mix these up.
as GrabScroll polls, it scrolls the GraphicBlock to follow the mouse position, making it appear as though the user is dragging the GraphicBlock's graphic itself. so fun. so tactile.
each time RateScroll polls the mouse, it scrolls the GraphicBlock by an amount corresponding to the differential between the current and initial mouse positions. this creates the illusion of a joystick interface: the further away the mouse is from its initial position, the greater the scrolling increment and the faster the graphic appears to scroll; scrolling slows down, stops, and reverses direction as the user drags the mouse back towards and past the initial position. πΉοΈ literally a joystick. the range of motion is giving main character energy.
virtual void GetGraphicBox(Coord&, Coord&, Coord&, Coord&)β return the lower-left and upper-right coordinates of the total area in which to scroll. by default, this area corresponds to the graphic's bounding box. (the original says "this area is corresponds to" β typo stays a mystery, but the meaning is clear: bounding box, default, done.) π¦virtual void Zoom(Perspective&)virtual void Scroll(Perspective&)β these functions define how zooming and scrolling are inferred from the perspective supplied toAdjust. the default behaviors implement standard scrolling semantics and zooming as described above. (scroll up if you need the recap, bestie π)virtual float LimitMagnification(float)β limit the amount of magnification that can be applied to the graphic. this function is used as a filter to convert desired magnifications into legal ones. by default, the argument is returned; no limits are imposed. she said "no limits, I'm free." π¦
π SEE ALSO π
Graphic(3U)Interactor(3I)Perspective(3I)
go read those next, they're the supporting cast and they ate too.
a lil note for my besties: GraphicBlock is the one you reach for when your interactor's look is structured-graphics-shaped, and you want it centered, scrollable, zoomable, and infinitely stretchy with zero extra effort. obsessed.
okay and that's the whole page!! this one came from the InterViews Reference Manual, it's GraphicBlock(3U), and the source/version + date at the bottom of the original was Unidraw, 30 January 1991 β so shoutout to Unidraw and to January 1991 for giving us this absolute classic. π«Άπβ¨
π¦ where this page comes from
- debian bookworm: ivtools-dev 2.0.11d.a1-1+b4
- debian trixie: ivtools-dev 2.0.11d.a1-3+b4
- ubuntu jammy: ivtools-dev 2.0.11d.a1-1build1
- ubuntu noble: ivtools-dev 2.0.11d.a1-3build1
- ubuntu questing: ivtools-dev 2.0.11d.a1-3build7
- ubuntu resolute: ivtools-dev 2.0.11d.a1-3build9
- ubuntu stonking: ivtools-dev 2.1.1+git.2025.07.26.a1-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms