Skip to content
Snippets Groups Projects
MultiComponent.h 1.88 KiB
Newer Older
Odilitime's avatar
Odilitime committed
#ifndef MULTICOMPONENT_H
#define MULTICOMPONENT_H

#include "Component.h"
#include "../opengl/Window.h"

// we're a control with our own componentTree
// we can relay events down to these components
// can be used for documents, tabs and menus
Odilitime's avatar
Odilitime committed
class MultiComponent : public Component {
public:
Odilitime's avatar
Odilitime committed
    MultiComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int passedWindowWidth, const int passedWindowHeight);
Odilitime's avatar
Odilitime committed
    void render();
    void renderComponents(std::shared_ptr<Component> component);
    void renderDocumentComponents(std::shared_ptr<Component> component);
Odilitime's avatar
Odilitime committed
    void renderBoxComponents(std::shared_ptr<Component> component);
    void renderComponentType(std::string str, std::shared_ptr<Component> component);
Odilitime's avatar
Odilitime committed
    void resize(const int passedWindowWidth, const int passedWindowHeight);
    std::shared_ptr<Component> searchComponentTree(const std::shared_ptr<Component> &component, const int passedX, const int passedY);
    
    //
    // Properties
    //
    
    // layers will replace rootComponent
    std::vector<std::shared_ptr<Component>> layers; // each layer's root component
Odilitime's avatar
Odilitime committed
    std::shared_ptr<Component> rootComponent = std::make_shared<Component>();
    
    // handle to signal that a redraw is needed, and access to shader programs
Odilitime's avatar
Odilitime committed
    Window *win;
Odilitime's avatar
Odilitime committed
    bool tabbed = false;

    // we'll need a way to pass events down and up
    // also how do we handle scroll?
    // we'll need searchComponentTree for picking
    std::shared_ptr<Component> hoverComponent = nullptr;
    std::shared_ptr<Component> focusedComponent = nullptr;

    // if the component tree changes, we'll need these to recalculate hoverComponent
    double cursorX = 0;
    double cursorY = 0;
Odilitime's avatar
Odilitime committed
};

//extern const std::unique_ptr<Window> window;
Odilitime's avatar
Odilitime committed

#endif