Jump to content

Scroll Panel Example?


Go to solution Solved by Josh,

Recommended Posts

Posted

I'm having a hard time understanding the Scroll Panel widget found here. I tried parenting my custom panels to the subpanel pointer, but it doesn't draw the sliderbar.

A main example would be appreciated as I need this for my settings panel.  

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

  • Solution
Posted

Parent your widgets to scrollpanel->subpanel.

Call SetArea to set the size of the entire subpanel.

The widget will take care of the rest.

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

Got it, here's a main.cpp example.

I may want to consider revamping my settings panel since I now understand this. 

#include "UltraEngine.h"
#include "CustomWidgets/ScrollPanel.h"
using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    //Load plugins
    auto plugin_svg = LoadPlugin("Plugins/SVG.*");

    //Get the displays
    auto displays = GetDisplays();

    //Create a window
    auto window = CreateWindow("Ultra Engine", 0, 0, 800, 600, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR | WINDOW_CLIENTCOORDS | WINDOW_RESIZABLE);

    //Create User Interface
    auto ui = CreateInterface(window);
    auto sz = ui->root->ClientSize();

    auto scrollpanel = CreateScrollPanel(0, 0, sz.x, sz.y, ui->root);
    scrollpanel->SetLayout(1, 1, 1, 1);

    //Parent your widgets to scrollpanel->subpanel.
    auto panel = CreatePanel(0, 0, sz.x - 100, sz.y - 100, scrollpanel->subpanel);
    panel->SetColor(0, 0, 0, 1);

    //Call SetArea to set the size of the entire subpanel.
    scrollpanel->SetArea(1000, 1000);

    while (true)
    {
        const Event ev = WaitEvent();
        switch (ev.id)
        {
        case EVENT_WINDOWCLOSE:
            return 0;
            break;
        }
    }
    return 0;
}

 

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...