Git Product home page Git Product logo

cpp-gui's Introduction

cpp-gui

Disclaimer (archived exploration): This project is not meant to be used in any serious way. Feel free to get inspired, but keep in mind that I would probably do things differently now.

This is a reactive c++ gui "library".

screenshot

Perhaps the most interesting "feature" is the use of virtual inheritance to implement widget composition:

// the simple button shall be:
// rounded (changes collision & draw behavior),
// solid (draws a solid (rounded) rectangle as the background),
// and have a shadow.
struct Simple_Button_Widget : virtual Base_Button_Widget, Rounded_Widget, Solid_Widget, Shadow_Widget {
    V4f base_fill_color;
    V4f base_stroke_color;
    // ...
};


// an example of composition:
void Simple_Button_Widget::on_paint(ID2D1RenderTarget* target) {
    // first do whatever we need to do.
    auto scale = 1.0f;
    if(this->hovered()) { scale *= 1.1f; }
    if(this->pressed()) { scale *= 1.1f; }

    this->fill_color   = V4f(scale * V3f(this->base_fill_color),   this->base_fill_color.a);
    this->stroke_color = V4f(scale * V3f(this->base_stroke_color), this->base_stroke_color.a);

    // then call the components.
    // we have control over the order,
    // which is important, because the shadow
    // needs to be at the bottom.
    Shadow_Widget::on_paint(target);
    Solid_Widget::on_paint(target);
    Single_Child_Widget::on_paint(target);
}

License: MIT. Any libraries used may of course have different licenses.

cpp-gui's People

Contributors

leddoo avatar

Stargazers

Brynjard Øvergård avatar GAURAV avatar

Watchers

 avatar

Forkers

icodein

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.