OSL ‐ Frames - Mistium/Origin-OS GitHub Wiki

1. Frame Definition:

The frame command is used to define a rectangular area on the screen. All content placed inside the frame will be constrained to this area.

Syntax:

frame left top right bottom content_height id
  • left, top, right, bottom: These parameters specify the position and size of the frame on the screen.
  • content_height: Specifies the height of the content within the frame. If the content height exceeds the frame’s height, you will need a scroll area.
  • id (optional but recommended): A unique identifier for the frame. It is recommended to assign an ID for ease of management, especially when dealing with multiple scrollable frames.

Note: Everything inside the frame will be clipped, meaning it will stay within the frame boundaries and won’t overflow outside of it.


2. Goto Command:

goto 0 scroll_yid
  • scroll_yid: A unique y scroll value for the corresponding frame. This ensures that the content starts at the top of the frame when rendering begins.

Note: The goto command is essential for placing elements in the desired position within a frame or scroll area.


3. Frame Clearing:

To return back to the main window context, and to stop clipping within the frame, you can use the "clear" argument. Syntax:

frame "clear"
  • "clear": This argument signifies that the current frame is being closed, and the rendering context returns to the main window. It also ensures that all content is clipped to stay within the frame.

Example: After adding all your content within the frame, use frame "clear" to close the frame and return to the main rendering context.


4. Putting It All Together:

Here’s a basic example of how these commands might be used in a typical GUI layout:

frame 10 10 300 300 500 scroll_area_1

goto 0 scroll_area_1
// Render elements within the frame here
frame "clear"
  • This creates a frame starting at (10,10) with a size of 300x300 pixels.
  • The content height is set to 500 pixels, and a scroll area (scroll_area_1) is used to enable vertical scrolling.
  • goto 0 scroll_area_1 positions the next element at the top of the scrollable area.
  • Finally, frame "clear" closes the frame, returning to the main rendering context.

5. Tips:

  • ID Management: Always assign IDs to your frames and scroll areas to keep your layout organized.
  • Clipping: Use frame "clear" to ensure that no content escapes the frame boundaries.
  • Positioning: Utilize the goto command effectively to control where elements are placed within the frames