App::I static singleton to pointer

This commit is contained in:
2019-07-11 18:08:17 +02:00
parent 92dd00d910
commit b89274e7a6
33 changed files with 417 additions and 412 deletions

View File

@@ -42,7 +42,7 @@ bool NodePanelStroke::import_abr(const std::string& path)
if (!str_iequals(ext, "abr") || !Asset::exist(path))
return false;
auto pb = App::I.show_progress("Importing ABR");
auto pb = App::I->show_progress("Importing ABR");
abr.open(path);
@@ -55,8 +55,8 @@ bool NodePanelStroke::import_abr(const std::string& path)
auto ii = abr.m_samples.begin();
std::advance(ii, i);
const auto& samp = *ii;
std::string path_high = App::I.data_path + "/brushes/" + samp.first + ".png";
std::string path_thumb = App::I.data_path + "/brushes/thumbs/" + samp.first + ".png";
std::string path_high = App::I->data_path + "/brushes/" + samp.first + ".png";
std::string path_thumb = App::I->data_path + "/brushes/thumbs/" + samp.first + ".png";
auto padded = samp.second->resize_squared(glm::u8vec4(255));
//auto high = padded.resize_power2();
//high.save(path_high);
@@ -87,8 +87,8 @@ bool NodePanelStroke::import_abr(const std::string& path)
auto ii = abr.m_patterns.begin();
std::advance(ii, i);
const auto& patt = *ii;
std::string path_high = App::I.data_path + "/patterns/" + patt.first + ".png";
std::string path_thumb = App::I.data_path + "/patterns/thumbs/" + patt.first + ".png";
std::string path_high = App::I->data_path + "/patterns/" + patt.first + ".png";
std::string path_thumb = App::I->data_path + "/patterns/thumbs/" + patt.first + ".png";
patt.second->save(path_high);
auto thumb = patt.second->resize(64, 64);
thumb.save(path_thumb);
@@ -110,20 +110,20 @@ bool NodePanelStroke::import_abr(const std::string& path)
});
m_pattern_popup->save();
auto brushes = abr.compute_brushes(App::I.data_path);
auto brushes = abr.compute_brushes(App::I->data_path);
for (const auto& pr : brushes)
{
if (pr->valid())
{
LOG("add preset %s", pr->m_name.c_str());
App::I.presets->add_brush(pr);
App::I->presets->add_brush(pr);
}
count++;
float prog = (float)count / (float)tot;
pb->m_progress->SetWidthP(prog * 100.f);
}
App::I.presets->save();
App::I->presets->save();
pb->destroy();
//save();
@@ -281,32 +281,32 @@ void NodePanelStroke::init_controls()
m_preset_button->on_click = [this](Node*) {
auto screen = root()->m_size;
glm::vec2 pos = m_preset_button->m_pos + glm::vec2(m_preset_button->m_size.x, 0);
root()->add_child(App::I.presets);
root()->add_child(App::I->presets);
auto tick = root()->add_child<NodeImage>();
tick->SetPositioning(YGPositionTypeAbsolute);
tick->SetSize(16, 32);
tick->SetPosition(pos.x, pos.y + (m_preset_button->m_size.y - 32) * 0.5f);
tick->set_image("data/ui/popup-tick.png");
float hh = App::I.presets->m_container->m_children.size() > 10 ? App::I.height / App::I.zoom * .75f : 400.f;
App::I.presets->SetHeight(glm::max(hh, 400.f));
float hh = App::I->presets->m_container->m_children.size() > 10 ? App::I->height / App::I->zoom * .75f : 400.f;
App::I->presets->SetHeight(glm::max(hh, 400.f));
root()->update();
if ((pos.y + App::I.presets->m_size.y) > screen.y)
pos.y = screen.y - App::I.presets->m_size.y;
if ((pos.y + App::I->presets->m_size.y) > screen.y)
pos.y = screen.y - App::I->presets->m_size.y;
if (pos.y < 0)
pos.y = 0;
App::I.presets->SetPosition(pos.x + 16, pos.y);
App::I.presets->SetPositioning(YGPositionTypeAbsolute);
App::I.presets->m_mouse_ignore = false;
App::I.presets->m_flood_events = true;
App::I.presets->m_capture_children = false;
App::I.presets->mouse_capture();
App::I->presets->SetPosition(pos.x + 16, pos.y);
App::I->presets->SetPositioning(YGPositionTypeAbsolute);
App::I->presets->m_mouse_ignore = false;
App::I->presets->m_flood_events = true;
App::I->presets->m_capture_children = false;
App::I->presets->mouse_capture();
root()->update();
App::I.presets->on_popup_close = [this, tick](Node*) {
App::I->presets->on_popup_close = [this, tick](Node*) {
tick->destroy();
};
App::I.presets->on_brush_changed = [this](Node* target, std::shared_ptr<Brush>& b) {
App::I->presets->on_brush_changed = [this](Node* target, std::shared_ptr<Brush>& b) {
// don't change some params
//b->m_tip_size = Canvas::I->m_current_brush->m_tip_size;
auto old_color = Canvas::I->m_current_brush->m_tip_color;
@@ -629,7 +629,7 @@ void NodePanelStroke::init_controls()
b->m_tip_opacity = 1.f;
Canvas::I->m_current_brush = b;
update_controls();
App::I.brush_update();
App::I->brush_update();
};
update_controls();