Replace Old Widgets
This commit is contained in:
parent
03da5e41d6
commit
c41dc20132
81 changed files with 388 additions and 278 deletions
39
Widgets/public/mangers/LayoutManager.hpp
Normal file
39
Widgets/public/mangers/LayoutManager.hpp
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#pragma once
|
||||
|
||||
#include "Layout.hpp"
|
||||
#include "DebugManager.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace tp {
|
||||
class LayoutManager {
|
||||
friend DebugManager;
|
||||
|
||||
struct DepNode {
|
||||
std::vector<Widget*> depends;
|
||||
int references = 0;
|
||||
int depth = 0;
|
||||
};
|
||||
|
||||
public:
|
||||
LayoutManager() = default;
|
||||
|
||||
void adjust(Widget* root);
|
||||
|
||||
private:
|
||||
void findDependencies(Widget* root);
|
||||
void topologicalSort(Widget* root, int depth = 0);
|
||||
void adjustLayouts();
|
||||
|
||||
private:
|
||||
int getLayoutOrder(WidgetLayout* parent, WidgetLayout* child) const;
|
||||
|
||||
private:
|
||||
std::map<Widget*, DepNode> mDepGraph;
|
||||
std::vector<Widget*> mRoots;
|
||||
|
||||
std::vector<std::pair<Widget*, int>> mLayOrder;
|
||||
bool mVertical = false;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue