Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add missing vmax_size functionalities #424

Merged
merged 1 commit into from
Sep 12, 2024
Merged

Add missing vmax_size functionalities #424

merged 1 commit into from
Sep 12, 2024

Conversation

PaulSquires
Copy link
Contributor

Simple code additions to size.hpp to add missing vmax_size functions to mirror the existing hmax_size functions.

Changes tested using the following simple skeleton code. Notice that the blue box in the side panel will have its height constrained to 400.0f.

#include "elements/support/color.hpp"
#include <elements.hpp>


using namespace cycfi::elements;

constexpr float initial_client_width = 1024.f;
constexpr float initial_client_height = 768.f;


auto make_sidebar_column(view& view_) {
    auto sidebar_column =
        hmax_size(
            265.0f,
            vtile(
                vmax_size(
                    400.0f,
                    box(colors::blue)
                ),
                box(colors::yellow)
            )
    );
    return sidebar_column;
}


auto make_inbox_column(view& view_) {
    auto inbox_column =
        vtile(
            box(colors::red)
        );
    return inbox_column;
}


auto make_details_column(view& view_) {
    auto details_column =
        hmax_size(
            400.0f,
            vtile(
                box(colors::green)
            )
    );
    return details_column;
}


auto make_layout(view& view_) {
    auto layout =
        htile( 
            make_sidebar_column(view_), 
            make_inbox_column(view_), 
            make_details_column(view_)
        );
    return layout;
}


int run_application() {
    app _app("learn");
    window _win(_app.name(), window::style::standard);
    _win.on_close = [&_app]() { _app.stop(); };

    view view_(_win);

    view_.content(
        min_size(
            {initial_client_width, initial_client_height}, 
            make_layout(view_)
        )
    );

    _app.run();
    return 0;
}


#if defined(_WIN32) // win32 and win64
    int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, PSTR cmdline, int cmdshow) {
        return run_application();
    }
#else
    int main(int argc, char* argv[]) {
        return run_application();
    }
#endif

I am learning Elements and testing the library by attempting to replicate this layout as seen on https://ui.shadcn.com/
Screenshot_20240911_150958-transformed

@djowel
Copy link
Member

djowel commented Sep 12, 2024

Wonderful!

@djowel djowel merged commit 663dcdb into cycfi:master Sep 12, 2024
3 checks passed
djowel pushed a commit that referenced this pull request Oct 27, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants