From 1e5b276394ef3fc6d91df9121a90458662a7b75c Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 14 Oct 2024 17:42:29 +0200 Subject: make View instantiate its own controller --- View.cpp | 2 +- View.h | 7 +++---- input/test.xml | 2 +- main.cpp | 7 ++----- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/View.cpp b/View.cpp index 8ca7d94..c269643 100644 --- a/View.cpp +++ b/View.cpp @@ -4,7 +4,7 @@ #include "View.h" #include "ViewController.h" -View::View(ViewController & vc) : controller(vc) { +View::View(Museum & m) : controller(m) { this->worker = new std::thread(&View::work, this); } diff --git a/View.h b/View.h index 58dc33d..ef9e937 100644 --- a/View.h +++ b/View.h @@ -5,12 +5,11 @@ #include "Color.h" #include "Rectangle.h" - -class ViewController; +#include "ViewController.h" class View { public: - View(ViewController & vc); + View(Museum & m); virtual ~View(); public: @@ -27,7 +26,7 @@ public: bool open = true; private: - ViewController & controller; + ViewController controller; private: unsigned int width = 0, height = 0; diff --git a/input/test.xml b/input/test.xml index 8258501..de8a973 100644 --- a/input/test.xml +++ b/input/test.xml @@ -4,7 +4,7 @@ - + diff --git a/main.cpp b/main.cpp index 693a5d2..d824e5a 100644 --- a/main.cpp +++ b/main.cpp @@ -31,6 +31,7 @@ static void parse(FileStrategy & file, Deserializer & deserializer, const char * int main(int argc, char** argv) { Museum museum {}; + museum.set_pause(true); Deserializer deserializer { museum }; @@ -42,11 +43,7 @@ int main(int argc, char** argv) { parse(*file, deserializer, url); } - // printf("%s", museum.canvas.to_string(true).c_str()); - // printf("%s", museum.people.to_string().c_str()); - - ViewController controller { museum }; - View view { controller }; + View view { museum }; museum.set_pause(false); -- cgit v1.2.3