Something went wrong. Try again.
art software for the rest of us
drawing paint image sdl art
Something went wrong. Try again.
1.8 kB · 87 lines
C++
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788#include "PanelManagementContext.h"
#include "../Panels/BrushesPanel.h"#include "../Panels/ColorsPanel.h"#include "../Panels/LayersPanel.h"#include "../Panels/SettingsPanel.h"
std::stack<PanelManagementMode> PanelManagementContext::modes;std::map<Panels, Panel*> PanelManagementContext::panels = { { BRUSHES, new BrushesPanel() }, { COLORS, new ColorsPanel() }, { LAYERS, new LayersPanel() }, { SETTINGS, new SettingsPanel() }};int PanelManagementContext::uses = 0;
// ok technically when pmc killed then revived we have no panels, meh// not important until uiv2 implements panelsPanelManagementContext::PanelManagementContext() { uses++;}
PanelManagementContext::~PanelManagementContext() { uses--; if (uses > 0) { return; } for (auto panel : panels) { delete panel.second; }}
void PanelManagementContext::Open(Panels panel){ panels.at(panel)->OnActivate(); modes.push(CONFIGURE);}
void PanelManagementContext::Close(Panel* panel){ panel->OnDeactivate(); if (modes.size() > 0 && modes.top() != DEFAULT) { modes.pop(); }}
void PanelManagementContext::CloseAll(){ for (auto panel : panels) { panel.second->OnDeactivate(); } while (!modes.empty()) { modes.pop(); }}
bool PanelManagementContext::IsOpen(Panels panel){ return panels.at(panel)->GetState() == OPEN;}
void PanelManagementContext::PopMode(){ modes.pop();}
void PanelManagementContext::PushMode(PanelManagementMode mode){ modes.push(mode);}
PanelManagementMode PanelManagementContext::GetMode(){ if (modes.empty()) { return DEFAULT; } return modes.top();}
void PanelManagementContext::OnRender(){ for (auto panel : panels) { panel.second->OnRender(); }}