### Create and Show a Bloc Space Source: https://github.com/pharo-graphics/bloc/blob/dev/doc/1-GettingStarted.md Demonstrates the initial steps to create a new Bloc space (window) and display it. It also shows how to set basic properties like title and size. ```smalltalk aSpace := BlSpace new. aSpace show. "Edit the space's properties, like title and size" aSpace title: 'Bloc basics'. aSpace extent: 800 @ 600. ``` -------------------------------- ### Transform Child Element (Scale) Source: https://github.com/pharo-graphics/bloc/blob/dev/doc/1-GettingStarted.md Demonstrates how to apply transformations to a child element, specifically scaling it up by a factor of 1.2 using a transformation builder. ```smalltalk circle transformDo: [ :builder | builder scaleBy: 1.2 ]. ``` -------------------------------- ### Install Bloc using Metacello Source: https://github.com/pharo-graphics/bloc/wiki/Install This script uses Metacello to load the Bloc graphics library. It specifies the baseline, repository, and load action. Users can replace 'master' with 'dev' or a specific version tag like 'v2.5.0'. ```smalltalk Metacello new baseline: 'Bloc'; repository: 'github://pharo-graphics/Bloc:master/src'; load ``` -------------------------------- ### Nest Element with Circle Geometry Source: https://github.com/pharo-graphics/bloc/blob/dev/doc/1-GettingStarted.md Illustrates how to create a new BlElement with a specific geometry, in this case, a circle, and nest it as a child within another element (the rectangle). ```smalltalk circle := BlElement new background: Color blue; geometry: BlCircleGeometry new; size: 80 @ 80; yourself. rectangle addChild: circle. ``` -------------------------------- ### Animate Bloc Element Properties Source: https://github.com/pharo-graphics/bloc/blob/dev/doc/1-GettingStarted.md Covers adding various animations to a Bloc element, including opacity changes, translations, and creating sequential, infinite animation loops. ```smalltalk "Animate opacity" rectangle addAnimation: (BlOpacityAnimation new opacity: 0.5). "Animate transformations" fallAnimation := (BlTransformAnimation translate: 0 @ 200) absolute. rectangle addAnimation: fallAnimation. climbAnimation := (BlTransformAnimation translate: 0 @ 0) absolute. rectangle addAnimation: climbAnimation. "Create a sequence of animations" animationSequence := BlSequentialAnimation withAll: { fallAnimation. climbAnimation }. animationSequence beInfinite. rectangle addAnimation: animationSequence ``` -------------------------------- ### Handle Bloc Events (Click, Hover) Source: https://github.com/pharo-graphics/bloc/blob/dev/doc/1-GettingStarted.md Shows how to attach event handlers to Bloc elements for user interactions like clicks and mouse hovering. It demonstrates changing element appearance on click and animating opacity on mouse enter/leave. ```smalltalk "Change color on click" rectangle addEventHandlerOn: BlClickEvent do: [ :event | event target background: Color lightGray ]. "Animate on hover" rectangle addEventHandlerOn: BlMouseEnterEvent do: [ :event | event target addAnimation: (BlOpacityAnimation new opacity: 0.2) ]; addEventHandlerOn: BlMouseLeaveEvent do: [ :event | event target addAnimation: (BlOpacityAnimation new opacity: 1.0) ] ``` -------------------------------- ### Add Bloc to Baseline Specification Source: https://github.com/pharo-graphics/bloc/wiki/Install This code snippet demonstrates how to add the Bloc project to a Pharo Baseline configuration. It defines the repository path and version for integration into a project's dependencies. ```smalltalk spec baseline: 'Bloc' with: [ spec repository: 'github://pharo-graphics/Bloc:v2.5.0/src' ]. ``` -------------------------------- ### Install and Depend on Bloc in Pharo Source: https://github.com/pharo-graphics/bloc/blob/dev/README.md Provides instructions for loading Bloc into a Pharo environment using Metacello. It also shows how to declare Bloc as a dependency in a Pharo Baseline specification, allowing users to specify different versions or branches. ```smalltalk Metacello new baseline: 'Bloc'; repository: 'github://pharo-graphics/Bloc:master/src'; load ``` ```smalltalk spec baseline: 'Bloc' with: [ spec repository: 'github://pharo-graphics/Bloc:v2.5.0/src' ]. ``` -------------------------------- ### Add a Red Rectangle Element to Bloc Space Source: https://github.com/pharo-graphics/bloc/blob/dev/doc/1-GettingStarted.md Shows how to create a basic BlElement, set its background color and size, and add it as a child to the Bloc space's root element. It also covers updating element properties like background, position, and border. ```smalltalk "Create a red rectangle" rectangle := BlElement new sbackground: Color red; size: 150 @ 150; yourself. "Add it to the space" aSpace root addChild: rectangle. "Update its properties" rectangle background: Color lightBlue; position: 100 @ 100; border: (BlBorder paint: Color blue width: 10). ``` -------------------------------- ### Disable Child Clipping in Bloc Source: https://github.com/pharo-graphics/bloc/blob/dev/doc/1-GettingStarted.md Explains how to turn off the clipping behavior for child elements within a parent element, allowing children to render outside the parent's bounds. ```smalltalk rectangle clipChildren: false. ``` -------------------------------- ### Bloc Scene Graph Attachment Hooks and Properties Source: https://github.com/pharo-graphics/bloc/blob/dev/doc/3-ElementAddedToSceneGraph.md Details the methods and properties related to an element's attachment to the Bloc scene graph. This includes checking attachment status, accessing the parent space, and the primary hook for reacting to attachment. ```APIDOC BlElement>>#onAddedToSceneGraph - A template method (hook) that can be overridden to perform actions when an element is attached to the scene graph. - When overriding, it is mandatory to delegate the hook method to the superclass to ensure children are notified. - Use cases include subscribing/unsubscribing from SystemAnnouncer, cache handling (pre-loading/releasing resources), and adding/removing event handlers to the space. - Should NOT be used when an element's state directly or indirectly depends on its parents' state (e.g., font size in em units), as changes in parent composition can lead to inefficient recomputation. BlElement>>#isAttachedToSceneGraph - Returns true if the element or one of its parents is the root of a space, indicating it is attached to the scene graph. - Returns false otherwise. BlElement>>#space - Returns the BlSpace instance to which the element is added when it is attached to the scene graph. - Returns nil if the element is not attached to the scene graph. BlElementProperty>>#canPropagateToChildren - A property that can be used as an alternative to scene graph attachment hooks for managing state that depends on parents. - Allows properties to be propagated down the element tree efficiently. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.