You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.8 KiB

#include "MultiComponent.h"
#include "TextComponent.h"
#include "../../BrowsingHistory.h"
struct Tab {
//std::string title;
// I think these could be unique_ptrs
// have to be shared, because we want shortcut ptrs to them
// would make cleaning up a tab nice
std::shared_ptr<TextComponent> titleBox;
// these could be BoxComponents
std::shared_ptr<Component> selectorBox;
std::shared_ptr<Component> closeBox;
// this can be generic
std::shared_ptr<Component> contents;
int x;
int y;
size_t w;
size_t h;
size_t id;
// need to generalize these out
//std::string url;
// we need to cache components to save inputted data
// or create a special store/load system for it (might be less memory but more cpu)
std::shared_ptr<Node> domRootNode = nullptr;
//BrowsingHistory history;
// FIXME: we should move this into document component
std::unique_ptr<BrowsingHistory> history = nullptr;
std::shared_ptr<Tab> previousTab = nullptr;
// could eventually be broken into "tabSelectorComponent" and "tabViewComponent" so the selector doesn't have to be attached to the view area
class TabbedComponent : public MultiComponent {
TabbedComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int passedWindowWidth, const int passedWindowHeight);
// maybe you could return a handle so we can use it to select
void addTab(std::string passedTitle);
void updateWindowState(std::string newTitle);
std::vector<std::shared_ptr<Tab>>::iterator getTab(size_t tabId);
void selectTab(std::shared_ptr<Tab> tab);
void layoutTab(std::vector<std::shared_ptr<Tab>>::iterator tab);
void layoutTabs(std::vector<std::shared_ptr<Tab>>::iterator startTab, int xAdj);
void loadDomIntoTab(std::shared_ptr<Node> newRoot, std::string newTitle);
void removeTab(size_t tabId);
std::vector<std::shared_ptr<Tab>> tabs;
size_t tabCounter = 0;
size_t selectedTabId = 0;
std::shared_ptr<Tab> mpSelectedTab = nullptr; // we just want a pointer to where we want to go
// this sucks tbh, just phase it out
std::vector<std::shared_ptr<Tab>>::iterator selectedTab;
// was DocumentComponent but generalized to be more general (and compatible with Tab)
std::shared_ptr<Component> documentComponent = nullptr;
unsigned int tabAddColor = 0xF0F0F0FF;
unsigned int tabAddHoverColor = 0x008800FF;
unsigned int tabInactiveColor = 0x808080FF;
unsigned int tabHoverColor = 0x8888BBFF;
unsigned int tabActiveColor = 0xE0E0E0FF;
unsigned int tabTextColor = 0x000000FF;
unsigned int tabTextHoverColor = 0x008888FF;
unsigned int tabCloseColor = 0x222222FF;
unsigned int tabCloseHoverColor = 0x880000FF;