summaryrefslogtreecommitdiffstats
path: root/draw.cpp
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2007-09-16 16:07:03 +0200
committerneoraider <devnull@localhost>2007-09-16 16:07:03 +0200
commit01e98d51fedf65ad71d468c3b0410d6e7764a384 (patch)
tree3259e2655249865cd335d96cc4b32815a4236532 /draw.cpp
parent2bdbece75f9dcc9b98d7f9d5794c4b5e5f441b26 (diff)
downloadzoomedit-01e98d51fedf65ad71d468c3b0410d6e7764a384.tar
zoomedit-01e98d51fedf65ad71d468c3b0410d6e7764a384.zip
zoomedit: C++ized Vertex
Diffstat (limited to 'draw.cpp')
-rw-r--r--draw.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/draw.cpp b/draw.cpp
index 3a09628..b6aad02 100644
--- a/draw.cpp
+++ b/draw.cpp
@@ -85,7 +85,7 @@ static void polygon2path(cairo_t *cr, const POLYGON *polygon, const RECTANGLE *r
cairo_new_sub_path(cr);
for(i = 0; i < polygon2.nVertices; i++) {
- cairo_line_to(cr, polygon2.vertices[i].x, polygon2.vertices[i].y);
+ cairo_line_to(cr, polygon2.vertices[i].getX(), polygon2.vertices[i].getY());
}
if(close)
@@ -97,7 +97,7 @@ static void polygon2path(cairo_t *cr, const POLYGON *polygon, const RECTANGLE *r
gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
cairo_t *cr;
- VERTEX v1 = {-1, -1}, v2 = {widget->allocation.width+1, widget->allocation.height+1};
+ Vertex v1(-1, -1), v2(widget->allocation.width+1, widget->allocation.height+1);
RECTANGLE rect;
gboolean vertexOk;
static GdkPixmap *pixmap = NULL;
@@ -112,10 +112,10 @@ gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
viewToImage(&v1);
viewToImage(&v2);
- rect.x = v1.x;
- rect.y = v1.y;
- rect.width = v2.x-v1.x;
- rect.height = v2.y-v1.y;
+ rect.x = v1.getX();
+ rect.y = v1.getY();
+ rect.width = v2.getX()-v1.getX();
+ rect.height = v2.getY()-v1.getY();
if(pixmap == NULL || fabs(lastImageWidth - getImageWidth()) >= 0.000001 || fabs(lastImageHeight - getImageHeight()) >= 0.000001 ||
lastWidth != widget->allocation.width || lastHeight != widget->allocation.height || lastEditMode != getEditMode() || repaint)
@@ -205,7 +205,7 @@ gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
vertexOk = isVertexOk(getHoveredVertex());
if(vertexOk)
- cairo_line_to(cr, getHoveredVertex()->x, getHoveredVertex()->y);
+ cairo_line_to(cr, getHoveredVertex()->getX(), getHoveredVertex()->getY());
}
cairo_set_line_width(cr, 2.0/scale);
@@ -218,8 +218,8 @@ gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) {
cairo_set_source_rgba(cr, 1.0, 0.3, 0.3, 0.7);
i = getActiveRoom()->polygon.nVertices - 1;
- cairo_move_to(cr, getActiveRoom()->polygon.vertices[i].x, getActiveRoom()->polygon.vertices[i].y);
- cairo_line_to(cr, getHoveredVertex()->x, getHoveredVertex()->y);
+ cairo_move_to(cr, getActiveRoom()->polygon.vertices[i].getX(), getActiveRoom()->polygon.vertices[i].getY());
+ cairo_line_to(cr, getHoveredVertex()->getX(), getHoveredVertex()->getY());
cairo_stroke(cr);
}
@@ -240,14 +240,14 @@ void setScale(double s) {
repaint = TRUE;
}
-void imageToView(VERTEX *v) {
- v->x = v->x*scale+getImageWidth()/2-xTranslate;
- v->y = v->y*scale+getImageHeight()/2-yTranslate;
+void imageToView(Vertex *v) {
+ v->setX(v->getX()*scale+getImageWidth()/2-xTranslate);
+ v->setY(v->getY()*scale+getImageHeight()/2-yTranslate);
}
-void viewToImage(VERTEX *v) {
- v->x = (v->x-getImageWidth()/2+xTranslate)/scale;
- v->y = (v->y-getImageHeight()/2+yTranslate)/scale;
+void viewToImage(Vertex *v) {
+ v->setX((v->getX()-getImageWidth()/2+xTranslate)/scale);
+ v->setY((v->getY()-getImageHeight()/2+yTranslate)/scale);
}
double getImageWidth() {
@@ -258,8 +258,8 @@ double getImageWidth() {
if(level) {
for(i = 0; i < level->nRooms; i++) {
for(j = 0; j < level->rooms[i].polygon.nVertices; j++) {
- min = MIN(min, level->rooms[i].polygon.vertices[j].x);
- max = MAX(max, level->rooms[i].polygon.vertices[j].x);
+ min = MIN(min, level->rooms[i].polygon.vertices[j].getX());
+ max = MAX(max, level->rooms[i].polygon.vertices[j].getX());
}
}
}
@@ -275,8 +275,8 @@ double getImageHeight() {
if(level) {
for(i = 0; i < level->nRooms; i++) {
for(j = 0; j < level->rooms[i].polygon.nVertices; j++) {
- min = MIN(min, level->rooms[i].polygon.vertices[j].y);
- max = MAX(max, level->rooms[i].polygon.vertices[j].y);
+ min = MIN(min, level->rooms[i].polygon.vertices[j].getY());
+ max = MAX(max, level->rooms[i].polygon.vertices[j].getY());
}
}
}