aboutsummaryrefslogtreecommitdiff
path: root/ViewController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ViewController.cpp')
-rw-r--r--ViewController.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/ViewController.cpp b/ViewController.cpp
index 9723dbd..e6ffe2e 100644
--- a/ViewController.cpp
+++ b/ViewController.cpp
@@ -2,32 +2,37 @@
#include "View.h"
#include "Museum.h"
-ViewController::ViewController(View & v, Museum & m) : view(v), museum(m) {};
+ViewController::ViewController(Museum & m) : museum(m) {};
-void ViewController::update() {
- // set size
- Canvas & canvas = this->museum.canvas;
- unsigned width = canvas.data.columns;
- unsigned height = canvas.data.rows;
- this->view.set_size(scale * width, scale * height);
+void ViewController::update(View & view) {
+ this->update_size(view);
+ this->update_tiles(view);
+ this->update_artists(view);
+}
- this->view.draw_begin();
+void ViewController::update_size(View & view) {
+ view.set_size(
+ this->scale * this->museum.canvas.data.columns,
+ this->scale * this->museum.canvas.data.rows
+ );
+}
- // draw tiles
- for (unsigned y = 0; y < height; y++) {
- for (unsigned x = 0; x < width; x++) {
- Tile & tile = canvas.get_tile(x, y);
+void ViewController::update_tiles(View & view) {
+ for (unsigned y = 0; y < this->museum.canvas.data.rows; y++) {
+ for (unsigned x = 0; x < this->museum.canvas.data.columns; x++) {
+ Tile & tile = this->museum.canvas.get_tile(x, y);
Rectangle rect = {
.x = x * scale,
.y = y * scale,
.width = scale - line_width,
.height = scale - line_width,
};
- this->view.draw_rect(rect, tile.color);
+ view.draw_rect(rect, tile.color);
}
}
+}
- // draw artists
+void ViewController::update_artists(View & view) {
People & people = this->museum.people;
for (size_t i = 0; i < people.artists_size(); i++) {
Artist & artist = people.get_artist(i);
@@ -37,9 +42,7 @@ void ViewController::update() {
.width = artist_size,
.height = artist_size,
};
- this->view.draw_rect(rect, { 0, 0, 0 });
+ view.draw_rect(rect, { 0, 0, 0 });
}
-
- this->view.draw_end();
}