EasyMenu plugin - devlog (experimental dynamically generated ui system)

Not favoritedFavorited Favorited 0 favourites
From the Asset Store
Casual UI Button is a customizable, ready to use desktop and mobile-friendly game UI Asset.
  • Thought i would add drag scrolling while i was already working on scroll bars.

    -> EasyMenu: Set drag scroll True, inertia 0.90, overscroll True

    You can enable and disable it, adjust the inertia, and enable overscroll so rather than a hard stop at the pages edge it bounces back like on most mobile OS.

  • You can now enable headers and a footers. Not many properties yet, just set height and colour. Header also has the option to enable dragging the window.

    Not going to work on more properties just yet, just needed to get teh basics in before starting work on the layout system.

  • First steps at skinning the ui.

    Boarders can now have a texture. Works like a 9 patch.

    Reference a sprite then use its animations for the corners and sides.

    This means a single sprite can skin the whole ui interface.

    -> EasyMenu: Apply skin from UID Sprite4.UID: TL="tl", T="t", TR="tr", R="r", BR="br", B="b", BL="bl", L="l"
  • I have been spending most of my dev time on adding the new layout system, however in the mean time i have also added independent round corners, and the ability to enable and disable window resizing.

    Window resizing takes into account corner radius and border thickness.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Page Layouts!

    This is a big update and a milestone for this plugin. After trying a number of different approaches I've finally implemented the page layout system, and got it functioning so that it is both easy to understand and use.

    There's number of different aspects to the system which i will try to explain.

    Content Boxes

    Firstly I have added a new object called a "content box". These boxes divide up the page and hold the various menu elements that will be added, like text, images, scroll bars etc.

    The actions are split into 3 parts.

    Create Content Box (set its name, position, size etc).

    Set Content Box Layout (padding, growth, alignment etc).

    Set Content Box Style (colour, border, corner roundness etc).

    Most of the time you will probably want content boxes to just be invisible so only their child menu element is shown, but they can have a colour, a border, corner roundness, transparency etc if say you want a border around your text.

    -> EasyMenu: Set content box "Box1" style: bg "255,255,255,1", border "200,250,120,1" (width 5), radii 20,0,20,0

    Flow system

    The system uses my own unique version of the popular flow approach that many UI libraries use.

    The main defining quality of a flow system being generally objects are positioned from left to right in the order they are created, like typing words in a word processor.

    So a content boxes position is relative to the position of the last content box created before it on the event sheet.

    The first content box added to a page is always relative to 0,0.

    Here we have 3 content boxes with padding.

    Notice how as the page size changes their positions stay fixed.

    A lot of the time you will probably have a fixed page size, so you can arrange your elements without much worry, however what to do when the page size changes?

    Alignments

    In order to anchor a content box to page we set each boxes alignment to either Left (default), Center, or Right.

    Here are the 3 boxes, left, center and right aligned in order.

    Notice how they are now anchored as the page size adjusts.

    The layout system enforces a strict alignment logical flow order,

    Left -> Center -> Right

    ensuring that if you add a Left box after a Center box, it simply "promotes" itself to Center and stacks naturally next to its neighbour, preventing any overlap/collision bugs.

    Here we have Box 1 centre aligned, Box 2 right aligned, and Box 3 left aligned, promoted to right aligned to maintain the flow.

    Also notice how because Box 1 has centre, it takes into account the combined sizes of boxes 2 and 3 with padding.

    Below we can see Box 1 with left aligned and Boxes 2 and 3 right aligned, which fits much better.

    Grow

    Content boxes also have a "grow" property. It allows a box to fill the area between itself and its neighbours.

    Here all boxes are left aligned, and all have grow enabled.

    Since all boxes have grow enabled, they share the grow space equally.

    If you want a specific box to grow more proportionally to others, you can change its "growth ratio".

    Bellow Box 1 has grow ratio set at 0.2, Box 2 in the middle is set to 1.5, and box 3 is set to 0.5. (Removed padding to help see). The result is Box 2 in the middle grows more than the others, with box 1 growing the least.

    In this next example Box 2 has growth disabled maintaining its set width and so gets sandwiched in between the other 2 as they grow.

    Cuts

    You can also visually join content boxes together by cutting specified sides. This allows you to create the effect of box containing multiple elements.

    Here Box 1 has its right side cut, Box 2 has grow enabled and its left and right side cut, and Box 3 has its left side cut.

    The Y axis

    When you create a content box you specify if its position continues across from the last box, or if it starts on a new row beneath.

    And for each page you specify the layout mode type.

    "Carriage Return", which positions the box based on the lowest point of any box on the row above.

    In the example below Box 2 has grow across and down enabled, with Box 4 on the row below. As the page size changes Box 4 is pushed down.

    "Masonry" mode is much smarter and plays Tetris allowing boxes to position themselves in areas where they simply fit.

    Below is the same layout, but now Box 4 positions under Box 1 since Box 2 doesn't obstruct it.

    In this final example Boxes 1 and 4 now both have grow across enabled, and Box 4 grow down enabled, which begins to show how complex layouts can be achieved. The flow order of rows is top down, so Box 2's grow down takes priority over Box 4's grow across.

  • I had some time away from dev work given the time of year.

    Coming back i had to admit my own layout system was not working as i wanted.

    I had tried to mash two different approaches together and it was causing issues i couldn't resolve, so i decided to not try to re invent the wheel and to just use the standard html CSS approach. It was the right choice.

    I used this css webpage as a test bed and was able to reproduce it. Which is great.

    w3schools.com/css/tryit.asp

    Currently, only text is supported. Now i can start adding other elements.

    	+ (no conditions)
    // 1. Setup the Page
    First, create the page where the layout will live.
    -> EasyMenu: Add page "WebLayout"
    -> EasyMenu: Set page "WebLayout" height to 800
    -> EasyMenu: Set page "WebLayout" width to 600
    -> EasyMenu: Set current page to "WebLayout" with Instant transition (Linear tween, 0.5s), dynamic scrollbars False
    ----+ (no conditions)
    ----// 2. Create the Root Container
    This acts as the <body> tag, stacking items vertically (Header, then Body, then Footer).
    -----> EasyMenu: Create Column layout group "Root" in page "WebLayout" (parent: "")
    -----> EasyMenu: Set item "Root" props in page "WebLayout": width -1, height -1, grow 1
    
    ----+ (no conditions)
    ----// 3. The Header
    -----> EasyMenu: Create Column layout group "Header" in page "WebLayout" (parent: "Root")
    -----> EasyMenu: Set item "Header" props in page "WebLayout": width -1, height 120, grow 0
    -----> EasyMenu: Set group "Header" style in page "WebLayout": bg "26,188,156,1", gap 20, pad 0x0, align Center, justify Center
    ----// Add Text to Header 
    -----> EasyMenu: Add text "H1" to page "WebLayout": "My Header Text" (Font: "Arial", Size: 25, Color: "255,255,255", Bold: True, Italic: False, Wrap: False)
    -----> EasyMenu: Add element "H1" to layout group "Header" in page "WebLayout"
    -----> EasyMenu: Add text "H2" to page "WebLayout": "Resize menu window..." (Font: "Arial", Size: 16, Color: "255,255,255", Bold: False, Italic: False, Wrap: False)
    -----> EasyMenu: Add element "H2" to layout group "Header" in page "WebLayout"
    
    ----+ (no conditions)
    ----// 4. The Navigation Bar (Black Box)
    -----> EasyMenu: Create Row layout group "NavBar" in page "WebLayout" (parent: "Root")
    -----> EasyMenu: Set item "NavBar" props in page "WebLayout": width -1, height -1, grow 0
    -----> EasyMenu: Set group "NavBar" style in page "WebLayout": bg "51,51,51,1", gap 20, pad 50x15, align Stretch, justify Start
    --------+ System: Repeat 4 times
    --------// // Add Links
    ---------> EasyMenu: Add text "Link"&LoopIndex+1 to page "WebLayout": "Link "&LoopIndex+1 (Font: "Arial", Size: 16, Color: "255,255,255", Bold: False, Italic: False, Wrap: False)
    ---------> EasyMenu: Add element "Link"&LoopIndex+1 to layout group "NavBar" in page "WebLayout"
    
    ----+ (no conditions)
    ----// 5. The Content Body (Row Container)
    -----> EasyMenu: Create Row layout group "ContentBody" in page "WebLayout" (parent: "Root")
    -----> EasyMenu: Set item "ContentBody" props in page "WebLayout": width -1, height -1, grow 1
    
    ----+ (no conditions)
    ----// 6. The Columns (Side & Main)
    ----// Side Column (Left)
    -----> EasyMenu: Create Column layout group "SideCol" in page "WebLayout" (parent: "ContentBody")
    -----> EasyMenu: Set item "SideCol" props in page "WebLayout": width 60, height -1, grow 1
    -----> EasyMenu: Set group "SideCol" style in page "WebLayout": bg "241,241,241,1", gap 20, pad 20x50, align Stretch, justify Start
    ----// title text
    -----> EasyMenu: Add text "SideTitle" to page "WebLayout": "About Me" (Font: "Arial", Size: 20, Color: "0,0,0", Bold: True, Italic: False, Wrap: False)
    -----> EasyMenu: Add element "SideTitle" to layout group "SideCol" in page "WebLayout"
    ----// photo label
    -----> EasyMenu: Add text "SideDesc" to page "WebLayout": "Photo of me: " (Font: "Arial", Size: 14, Color: "0,0,0", Bold: False, Italic: False, Wrap: False)
    -----> EasyMenu: Add element "SideDesc" to layout group "SideCol" in page "WebLayout"
    ----// fake image box
    -----> EasyMenu: Create Column layout group "SideImgBox" in page "WebLayout" (parent: "SideCol")
    -----> EasyMenu: Set item "SideImgBox" props in page "WebLayout": width -1, height 100, grow 0
    -----> EasyMenu: Set group "SideImgBox" style in page "WebLayout": bg "170,170,170,1", gap 0, pad 10x10, align Start, justify Start
    -----> EasyMenu: Add text "SideImgLbl" to page "WebLayout": "Image" (Font: "Arial", Size: 14, Color: "0,0,0", Bold: False, Italic: False, Wrap: False)
    -----> EasyMenu: Add element "SideImgLbl" to layout group "SideImgBox" in page "WebLayout"
    ----// more text
    -----> EasyMenu: Add text "SideMore" to page "WebLayout": "Hello World. This is some text about me. This has word wrap applied. This is some more text." (Font: "Arial", Size: 14, Color: "0,0,0", Bold: False, Italic: False, Wrap: True)
    -----> EasyMenu: Add element "SideMore" to layout group "SideCol" in page "WebLayout"
    --------+ System: Repeat 3 times
    ---------> EasyMenu: Create Column layout group "SubImgBox"&LoopIndex in page "WebLayout" (parent: "SideCol")
    ---------> EasyMenu: Set item "SubImgBox"&LoopIndex props in page "WebLayout": width -1, height 50, grow 0
    ---------> EasyMenu: Set group "SubImgBox"&LoopIndex style in page "WebLayout": bg "170,170,170,1", gap 0, pad 0x0, align Center, justify Center
    ---------> EasyMenu: Add text "SubImgLbl"&LoopIndex to page "WebLayout": "Image" (Font: "Arial", Size: 14, Color: "0,0,0", Bold: False, Italic: False, Wrap: False)
    ---------> EasyMenu: Add element "SubImgLbl"&LoopIndex to layout group "SubImgBox"&LoopIndex in page "WebLayout"
    --------// create 3 fake images
    
    ----+ (no conditions)
    ----// Main Column (Right)
    -----> EasyMenu: Create Column layout group "MainCol" in page "WebLayout" (parent: "ContentBody")
    -----> EasyMenu: Set item "MainCol" props in page "WebLayout": width 0, height -1, grow 3
    -----> EasyMenu: Set group "MainCol" style in page "WebLayout": bg "255,255,255,1", gap 20, pad 20x50, align Stretch, justify Start
    ----// heading text
    -----> EasyMenu: Add text "MainH1" to page "WebLayout": "HEADING" (Font: "Arial", Size: 24, Color: "0,0,0", Bold: True, Italic: False, Wrap: False)
    -----> EasyMenu: Add element "MainH1" to layout group "MainCol" in page "WebLayout"
    ----// title text
    -----> EasyMenu: Add text "MainDesc" to page "WebLayout": "Title description, December 7, 2017. " (Font: "Arial", Size: 14, Color: "100,100,100", Bold: False, Italic: False, Wrap: False)
    -----> EasyMenu: Add element "MainDesc" to layout group "MainCol" in page "WebLayout"
    ----// main body text
    -----> EasyMenu: Add text "MainBody" to page "WebLayout": "Some text..."&newline&newline&"This is a test of the text. This is a test of the text. This is a test of the text. This is a test of the text. This is a test of the text." (Font: "Arial", Size: 14, Color: "0,0,0", Bold: False, Italic: True, Wrap: True)
    -----> EasyMenu: Add element "MainBody" to layout group "MainCol" in page "WebLayout"
    ----// fake image box
    -----> EasyMenu: Create Column layout group "MainImgBox" in page "WebLayout" (parent: "MainCol")
    -----> EasyMenu: Set item "MainImgBox" props in page "WebLayout": width 0, height 300, grow 0
    -----> EasyMenu: Set group "MainImgBox" style in page "WebLayout": bg "170,170,170,1", gap 0, pad 10x10, align Start, justify Start
    -----> EasyMenu: Add text "MainImgLbl" to page "WebLayout": "Image" (Font: "Arial", Size: 14, Color: "0,0,0", Bold: False, Italic: False, Wrap: False)
    -----> EasyMenu: Add element "MainImgLbl" to layout group "MainImgBox" in page "WebLayout"
    ----// more body text
    -----> EasyMenu: Add text "MainBody1" to page "WebLayout": "This is a test of the text. This is a test of the text. This is a test of the text. This is a test of the text. This is a test of the text." (Font: "Arial", Size: 14, Color: "0,0,0", Bold: False, Italic: True, Wrap: True)
    -----> EasyMenu: Add element "MainBody1" to layout group "MainCol" in page "WebLayout"
    
    ----+ (no conditions)
    ----// 7. The Footer
    -----> EasyMenu: Create Row layout group "Footer" in page "WebLayout" (parent: "Root")
    -----> EasyMenu: Set item "Footer" props in page "WebLayout": width -1, height 50, grow 0
    -----> EasyMenu: Set group "Footer" style in page "WebLayout": bg "221,221,221,1", gap 0, pad 0x0, align Stretch, justify Start
    
    
  • Layout groups can now have borders with round corners, and have background images applied.

    Multiple images can be applied to stack them on top of each other, and you have control of alignments, offsets, stretch or repeat patterns.

    	-> EasyMenu: Add background image to group "MainCol" in page "WebLayout" from Sprite UID Sprite.UID (anim: "Animation 2", frame: 0), repeat: Repeat, align: Top-Left, offset: 0,0, opacity: 1
    -> EasyMenu: Add background image to group "MainCol" in page "WebLayout" from Sprite UID Sprite.UID (anim: "Animation 1", frame: 2), repeat: No Repeat, align: Top-Left, offset: 0,0, opacity: 1
    
  • Added border background image action, making it more feature complete. Going forward i can use this as a template to skin all the elements in the plugin.

    Based on these examples.

    w3schools.com/css/css3_border_images.asp

    css-tricks.com/revisiting-css-border-image

    -> EasyMenu: Set border image for group "MainCol" in page "WebLayout" using Sprite UID Sprite3.UID (Anim: "Animation 3", Frame: 0). Slices T:260 R:150 B:260 L:150, Width T:100 R:60 B:100 L:60, Outset: 0, Repeat H:Stretch V:Round, Fill: True
    
  • Continuing to do a bit each day.

    The biggest updates this week are that the footer and header are now treated as static pages. This means that the same layout code is used to add items to them, and its as easy as specifying the page name as footer and header.

    I also rewrote the window border skinning code from my own original attempt to the same 9 slice code all elements now use. Still need to do work on the drop shadow to match the skin shape.

  • The windows drop shadow now copies the shape of the window border texture if one is set.

  • Wow! That's amazing, great work 👍

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)