diff options
author | neoraider <devnull@localhost> | 2007-10-05 01:38:05 +0200 |
---|---|---|
committer | neoraider <devnull@localhost> | 2007-10-05 01:38:05 +0200 |
commit | b660b965bcb679e53cc89e7b8903190d2d162ff6 (patch) | |
tree | 31d2e3309e0906e03a8e415f430a99f8716b23b6 | |
parent | ea3fc9f27f6feb14ea3b7cfc8b1e921195dd3c3f (diff) | |
download | zoomedit-b660b965bcb679e53cc89e7b8903190d2d162ff6.tar zoomedit-b660b965bcb679e53cc89e7b8903190d2d162ff6.zip |
zoomedit: Gro?e Teile der GUI in Klassen gekapselt.
-rw-r--r-- | Drawer.cpp | 218 | ||||
-rw-r--r-- | Drawer.h | 57 | ||||
-rw-r--r-- | EditManager.cpp | 40 | ||||
-rw-r--r-- | EditManager.h | 36 | ||||
-rw-r--r-- | Makefile.am | 6 | ||||
-rw-r--r-- | Makefile.in | 141 | ||||
-rw-r--r-- | Polygon.cpp | 2 | ||||
-rw-r--r-- | Sidebar.h | 16 | ||||
-rw-r--r-- | SidebarAdd.cpp | 43 | ||||
-rw-r--r-- | SidebarAdd.h | 30 | ||||
-rw-r--r-- | SidebarManager.cpp | 46 | ||||
-rw-r--r-- | SidebarManager.h | 37 | ||||
-rw-r--r-- | SidebarView.cpp | 88 | ||||
-rw-r--r-- | SidebarView.h | 30 | ||||
-rw-r--r-- | Triangle.cpp | 2 | ||||
-rw-r--r-- | Triangle.h | 2 | ||||
-rw-r--r-- | Window.cpp | 55 | ||||
-rw-r--r-- | Window.h | 50 | ||||
-rw-r--r-- | WindowManager.cpp | 28 | ||||
-rw-r--r-- | WindowManager.h | 24 | ||||
-rw-r--r-- | draw.cpp | 2 | ||||
-rw-r--r-- | edit.cpp | 9 | ||||
-rw-r--r-- | edit.h | 3 | ||||
-rw-r--r-- | ui.cpp | 7 | ||||
-rw-r--r-- | window.cpp | 419 | ||||
-rw-r--r-- | window.h | 17 | ||||
-rw-r--r-- | zoomedit.cpp | 13 |
27 files changed, 940 insertions, 481 deletions
diff --git a/Drawer.cpp b/Drawer.cpp new file mode 100644 index 0000000..48bc730 --- /dev/null +++ b/Drawer.cpp @@ -0,0 +1,218 @@ +#include "Drawer.h" +#include "Window.h" +#include "draw.h" +#include "edit.h" +#include <GL/gl.h> +#include <math.h> + + +void Drawer::realize(GtkWidget *widget, Drawer *drawer) { + GdkGLContext *context = gtk_widget_get_gl_context(widget); + GdkGLDrawable *drawable = gtk_widget_get_gl_drawable(widget); + + if(!gdk_gl_drawable_gl_begin(drawable, context)) + return; + + glClearColor(0, 0, 0, 1); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + glEnable(GL_LINE_SMOOTH); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + gdk_gl_drawable_gl_end(drawable); +} + +gboolean Drawer::eventHandler(GtkWidget *widget, GdkEvent *event, Drawer *drawer) { + switch(event->type) { + case GDK_CONFIGURE: + drawer->updateViewport(); + drawer->updateScrollbars(); + return TRUE; + + case GDK_EXPOSE: + drawTopView(widget, &event->expose, NULL); + return TRUE; + + case GDK_MOTION_NOTIFY: + drawer->updateHoveredPoint(event->motion.x, event->motion.y); + return TRUE; + + case GDK_ENTER_NOTIFY: + drawer->updateHoveredPoint(event->crossing.x, event->crossing.y); + return TRUE; + + case GDK_LEAVE_NOTIFY: + setHoveredVertex(NULL); + drawer->window->update(); + return TRUE; + + case GDK_BUTTON_PRESS: + switch(event->button.button) { + case 1: + if(!getHoveredVertex()) + break; + + switch(drawer->window->getEditManager().getMode()) { + case EditManager::VIEW: + setActiveRoom(getHoveredRoom()); + break; + + case EditManager::ADD: + if(isVertexOk(getHoveredVertex())) + drawer->window->getEditManager().addVertex(*getHoveredVertex()); + } + + drawer->window->update(); + break; + + default: + return FALSE; + } + return TRUE; + + case GDK_SCROLL: + switch(event->scroll.direction) { + case GDK_SCROLL_UP: + drawer->zoom(1, event->scroll.x/widget->allocation.width, event->scroll.y/widget->allocation.height); + break; + case GDK_SCROLL_DOWN: + drawer->zoom(-1, event->scroll.x/widget->allocation.width, event->scroll.y/widget->allocation.height); + break; + default: + return FALSE; + } + return TRUE; + + default: + return FALSE; + } +} + +void Drawer::valueChanged(GtkAdjustment *adjustment, Drawer *drawer) { + drawer->updateScrolling(); +} + + +void Drawer::updateViewport() { + GdkGLContext *context = gtk_widget_get_gl_context(drawingArea); + GdkGLDrawable *drawable = gtk_widget_get_gl_drawable(drawingArea); + + if(!gdk_gl_drawable_gl_begin(drawable, context)) + return; + + glViewport(0, 0, getWidth(), getHeight()); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + if(getWidth() != 0 && getHeight() != 0) { + glTranslatef(-1, 1, 0); + glScalef(2.0f/getWidth(), -2.0f/getHeight(), 1); + } + + gdk_gl_drawable_gl_end(drawable); +} + +void Drawer::updateScrolling() { + if(getImageWidth() < getWidth()) + setXTranslate((getImageWidth()-getWidth())/2); + else + setXTranslate(gtk_adjustment_get_value(hAdjustment)); + + if(getImageHeight() < getHeight()) + setYTranslate((getImageHeight()-getHeight())/2); + else + setYTranslate(gtk_adjustment_get_value(vAdjustment)); + + update(); +} + +void Drawer::updateScrollbars(float x, float y) { + const gdouble imageWidth = getImageWidth(), imageHeight = getImageHeight(); + const gdouble width = getWidth(), height = getHeight(); + gdouble upper, pageSize, value; + + gdk_window_freeze_updates(drawingArea->window); + + g_object_get(G_OBJECT(hAdjustment), "upper", &upper, "page_size", &pageSize, NULL); + g_object_set(G_OBJECT(hAdjustment), "upper", imageWidth, "page_size", width, NULL); + gtk_adjustment_changed(hAdjustment); + + if((pageSize > upper && width < imageWidth) || upper == 0) + value = (imageWidth-width)/2; + else + value = (gtk_adjustment_get_value(hAdjustment)+pageSize*x)/upper*imageWidth-width*x; + gtk_adjustment_set_value(hAdjustment, MAX(MIN(value, imageWidth-width), 0)); + + g_object_get(G_OBJECT(vAdjustment), "upper", &upper, "page_size", &pageSize, NULL); + g_object_set(G_OBJECT(vAdjustment), "upper", imageHeight, "page_size", height, NULL); + gtk_adjustment_changed(vAdjustment); + + if((pageSize > upper && height < imageHeight) || upper == 0) + value = (imageHeight-height)/2; + else + value = (gtk_adjustment_get_value(vAdjustment)+pageSize*y)/upper*imageHeight-height*y; + gtk_adjustment_set_value(vAdjustment, MAX(MIN(value, imageHeight-height), 0)); + + gdk_window_thaw_updates(drawingArea->window); + + updateScrolling(); +} + +void Drawer::updateHoveredPoint(float x, float y) { + Vertex v(x, y); + viewToImage(&v); + setHoveredVertex(&v); + + window->update(); +} + +Drawer::Drawer(Window *window, GdkGLConfig *glconfig) { + this->window = window; + zoomExp = 0; + + drawer = gtk_table_new(2, 2, FALSE); + g_object_ref_sink(G_OBJECT(drawer)); + + drawingArea = gtk_drawing_area_new(); + gtk_widget_set_gl_capability(drawingArea, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); + g_signal_connect(G_OBJECT(drawingArea), "realize", G_CALLBACK(realize), this); + g_signal_connect(G_OBJECT(drawingArea), "configure-event", G_CALLBACK(eventHandler), this); + g_signal_connect(G_OBJECT(drawingArea), "expose-event", G_CALLBACK(eventHandler), this); + g_signal_connect(G_OBJECT(drawingArea), "button-press-event", G_CALLBACK(eventHandler), this); + //g_signal_connect(G_OBJECT(drawingArea), "button-release-event", G_CALLBACK(eventHandler), this); + g_signal_connect(G_OBJECT(drawingArea), "enter-notify-event", G_CALLBACK(eventHandler), this); + g_signal_connect(G_OBJECT(drawingArea), "leave-notify-event", G_CALLBACK(eventHandler), this); + g_signal_connect(G_OBJECT(drawingArea), "motion-notify-event", G_CALLBACK(eventHandler), this); + g_signal_connect(G_OBJECT(drawingArea), "scroll-event", G_CALLBACK(eventHandler), this); + gtk_widget_add_events(drawingArea, GDK_SCROLL_MASK | GDK_POINTER_MOTION_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); + gtk_table_attach(GTK_TABLE(drawer), drawingArea, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL|GTK_EXPAND|GTK_SHRINK), (GtkAttachOptions)(GTK_FILL|GTK_EXPAND|GTK_SHRINK), 0, 0); + + hAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 0, 10, 100, 100)); + GtkWidget *hScroll = gtk_hscrollbar_new(hAdjustment); + g_signal_connect(G_OBJECT(hScroll), "value-changed", G_CALLBACK(valueChanged), this); + gtk_table_attach(GTK_TABLE(drawer), hScroll, 0, 1, 1, 2, (GtkAttachOptions)(GTK_FILL|GTK_EXPAND|GTK_SHRINK), (GtkAttachOptions)0, 0, 0); + + vAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 0, 10, 100, 100)); + GtkWidget *vScroll = gtk_vscrollbar_new(vAdjustment); + g_signal_connect(G_OBJECT(vScroll), "value-changed", G_CALLBACK(valueChanged), this); + gtk_table_attach(GTK_TABLE(drawer), vScroll, 1, 2, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)(GTK_FILL|GTK_EXPAND|GTK_SHRINK), 0, 0); + + gtk_widget_show_all(drawer); +} + +Drawer::~Drawer() { + g_object_unref(G_OBJECT(drawer)); +} + +void Drawer::zoom(int zoom, float x, float y) { + zoomExp = MAX(MIN(zoomExp + zoom, 50), -100); + + setScale(100*powf(1.1f, zoomExp)); + + updateScrollbars(x, y); +} diff --git a/Drawer.h b/Drawer.h new file mode 100644 index 0000000..4cc0e2b --- /dev/null +++ b/Drawer.h @@ -0,0 +1,57 @@ +#ifndef DRAWER_H_ +#define DRAWER_H_ + +#include <gtk/gtk.h> +#include <gtk/gtkgl.h> + + +class Window; + + +class Drawer { + private: + GtkWidget *drawer; + GtkWidget *drawingArea; + GtkAdjustment *hAdjustment, *vAdjustment; + int zoomExp; + + Window *window; + + // prevent shallow copy + Drawer(const Drawer &w); + const Drawer& operator=(const Drawer &w); + + void updateViewport(); + void updateScrolling(); + void updateScrollbars(float x = 0.5f, float y = 0.5f); + + void updateHoveredPoint(float x, float y); + + gint getWidth() const { + return drawingArea->allocation.width; + } + + gint getHeight() const { + return drawingArea->allocation.height; + } + + static void realize(GtkWidget *widget, Drawer *drawer); + static gboolean eventHandler(GtkWidget *widget, GdkEvent *event, Drawer *drawer); + static void valueChanged(GtkAdjustment *adjustment, Drawer *drawer); + + public: + Drawer(Window *window, GdkGLConfig *glconfig); + virtual ~Drawer(); + + void zoom(int zoom, float x = 0.5f, float y = 0.5f); + + GtkWidget *getWidget() { + return drawer; + } + + void update() { + gtk_widget_queue_draw(drawingArea); + } +}; + +#endif /*DRAWER_H_*/ diff --git a/EditManager.cpp b/EditManager.cpp new file mode 100644 index 0000000..34d53be --- /dev/null +++ b/EditManager.cpp @@ -0,0 +1,40 @@ +#include "EditManager.h" +#include "Window.h" +#include "edit.h" + + +EditManager::EditManager(Window *window) { + this->window = window; + + mode = VIEW; +} + +void EditManager::addRoom() { + //newRoom = Room(); + mode = ADD; + + startAddMode(); + + window->update(); +} + +void EditManager::finishRoom() { + mode = VIEW; + + if(getActiveRoom() && getActiveRoom()->size() > 2 && isPolygonOk(getActiveRoom())) { + getLevel()->push_back(*getActiveRoom()); + setActiveRoom(&getLevel()->back()); + + endAddMode(); + } + + window->update(); +} + +void EditManager::addVertex(const Vertex &v) { + if(mode != ADD || !getActiveRoom()) + return; + + getActiveRoom()->push_back(v); + window->update(); +} diff --git a/EditManager.h b/EditManager.h new file mode 100644 index 0000000..a1561eb --- /dev/null +++ b/EditManager.h @@ -0,0 +1,36 @@ +#ifndef EDITMANAGER_H_ +#define EDITMANAGER_H_ + +#include "Room.h" + + +class Window; + + +class EditManager { + public: + enum Mode { + VIEW, ADD + }; + + private: + Mode mode; + + Window *window; + + //Room newRoom; + + public: + EditManager(Window *window); + + void addRoom(); + void finishRoom(); + + void addVertex(const Vertex &v); + + Mode getMode() { + return mode; + } +}; + +#endif /*EDITMANAGER_H_*/ diff --git a/Makefile.am b/Makefile.am index 86aa883..2510265 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,8 @@ bin_PROGRAMS = zoomedit -zoomedit_SOURCES = zoomedit.cpp window.cpp ui.cpp draw.cpp edit.cpp Vertex.cpp \ +zoomedit_SOURCES = zoomedit.cpp ui.cpp draw.cpp edit.cpp Vertex.cpp \ Line.cpp Polygon.cpp Rectangle.cpp Room.cpp Triangle.cpp \ - IdManager.cpp + IdManager.cpp WindowManager.cpp SidebarManager.cpp \ + Window.cpp SidebarView.cpp SidebarAdd.cpp Drawer.cpp \ + EditManager.cpp zoomedit_CPPFLAGS = @GTK_CFLAGS@ @GTKGLEXT_CFLAGS@ zoomedit_LDADD = @GTK_LIBS@ @GTKGLEXT_LIBS@
\ No newline at end of file diff --git a/Makefile.in b/Makefile.in index 9265def..785f3aa 100644 --- a/Makefile.in +++ b/Makefile.in @@ -49,12 +49,15 @@ am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_zoomedit_OBJECTS = zoomedit-zoomedit.$(OBJEXT) \ - zoomedit-window.$(OBJEXT) zoomedit-ui.$(OBJEXT) \ - zoomedit-draw.$(OBJEXT) zoomedit-edit.$(OBJEXT) \ - zoomedit-Vertex.$(OBJEXT) zoomedit-Line.$(OBJEXT) \ - zoomedit-Polygon.$(OBJEXT) zoomedit-Rectangle.$(OBJEXT) \ - zoomedit-Room.$(OBJEXT) zoomedit-Triangle.$(OBJEXT) \ - zoomedit-IdManager.$(OBJEXT) + zoomedit-ui.$(OBJEXT) zoomedit-draw.$(OBJEXT) \ + zoomedit-edit.$(OBJEXT) zoomedit-Vertex.$(OBJEXT) \ + zoomedit-Line.$(OBJEXT) zoomedit-Polygon.$(OBJEXT) \ + zoomedit-Rectangle.$(OBJEXT) zoomedit-Room.$(OBJEXT) \ + zoomedit-Triangle.$(OBJEXT) zoomedit-IdManager.$(OBJEXT) \ + zoomedit-WindowManager.$(OBJEXT) \ + zoomedit-SidebarManager.$(OBJEXT) zoomedit-Window.$(OBJEXT) \ + zoomedit-SidebarView.$(OBJEXT) zoomedit-SidebarAdd.$(OBJEXT) \ + zoomedit-Drawer.$(OBJEXT) zoomedit-EditManager.$(OBJEXT) zoomedit_OBJECTS = $(am_zoomedit_OBJECTS) zoomedit_DEPENDENCIES = DEFAULT_INCLUDES = -I.@am__isrc@ @@ -174,9 +177,11 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -zoomedit_SOURCES = zoomedit.cpp window.cpp ui.cpp draw.cpp edit.cpp Vertex.cpp \ +zoomedit_SOURCES = zoomedit.cpp ui.cpp draw.cpp edit.cpp Vertex.cpp \ Line.cpp Polygon.cpp Rectangle.cpp Room.cpp Triangle.cpp \ - IdManager.cpp + IdManager.cpp WindowManager.cpp SidebarManager.cpp \ + Window.cpp SidebarView.cpp SidebarAdd.cpp Drawer.cpp \ + EditManager.cpp zoomedit_CPPFLAGS = @GTK_CFLAGS@ @GTKGLEXT_CFLAGS@ zoomedit_LDADD = @GTK_LIBS@ @GTKGLEXT_LIBS@ @@ -268,17 +273,23 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-Drawer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-EditManager.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-IdManager.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-Line.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-Polygon.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-Rectangle.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-Room.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-SidebarAdd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-SidebarManager.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-SidebarView.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-Triangle.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-Vertex.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-Window.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-WindowManager.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-draw.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-edit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-ui.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-window.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-zoomedit.Po@am__quote@ .cpp.o: @@ -309,20 +320,6 @@ zoomedit-zoomedit.obj: zoomedit.cpp @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-zoomedit.obj `if test -f 'zoomedit.cpp'; then $(CYGPATH_W) 'zoomedit.cpp'; else $(CYGPATH_W) '$(srcdir)/zoomedit.cpp'; fi` -zoomedit-window.o: window.cpp -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-window.o -MD -MP -MF $(DEPDIR)/zoomedit-window.Tpo -c -o zoomedit-window.o `test -f 'window.cpp' || echo '$(srcdir)/'`window.cpp -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-window.Tpo $(DEPDIR)/zoomedit-window.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='window.cpp' object='zoomedit-window.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-window.o `test -f 'window.cpp' || echo '$(srcdir)/'`window.cpp - -zoomedit-window.obj: window.cpp -@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-window.obj -MD -MP -MF $(DEPDIR)/zoomedit-window.Tpo -c -o zoomedit-window.obj `if test -f 'window.cpp'; then $(CYGPATH_W) 'window.cpp'; else $(CYGPATH_W) '$(srcdir)/window.cpp'; fi` -@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-window.Tpo $(DEPDIR)/zoomedit-window.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='window.cpp' object='zoomedit-window.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-window.obj `if test -f 'window.cpp'; then $(CYGPATH_W) 'window.cpp'; else $(CYGPATH_W) '$(srcdir)/window.cpp'; fi` - zoomedit-ui.o: ui.cpp @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-ui.o -MD -MP -MF $(DEPDIR)/zoomedit-ui.Tpo -c -o zoomedit-ui.o `test -f 'ui.cpp' || echo '$(srcdir)/'`ui.cpp @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-ui.Tpo $(DEPDIR)/zoomedit-ui.Po @@ -463,6 +460,104 @@ zoomedit-IdManager.obj: IdManager.cpp @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-IdManager.obj `if test -f 'IdManager.cpp'; then $(CYGPATH_W) 'IdManager.cpp'; else $(CYGPATH_W) '$(srcdir)/IdManager.cpp'; fi` +zoomedit-WindowManager.o: WindowManager.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-WindowManager.o -MD -MP -MF $(DEPDIR)/zoomedit-WindowManager.Tpo -c -o zoomedit-WindowManager.o `test -f 'WindowManager.cpp' || echo '$(srcdir)/'`WindowManager.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-WindowManager.Tpo $(DEPDIR)/zoomedit-WindowManager.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='WindowManager.cpp' object='zoomedit-WindowManager.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-WindowManager.o `test -f 'WindowManager.cpp' || echo '$(srcdir)/'`WindowManager.cpp + +zoomedit-WindowManager.obj: WindowManager.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-WindowManager.obj -MD -MP -MF $(DEPDIR)/zoomedit-WindowManager.Tpo -c -o zoomedit-WindowManager.obj `if test -f 'WindowManager.cpp'; then $(CYGPATH_W) 'WindowManager.cpp'; else $(CYGPATH_W) '$(srcdir)/WindowManager.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-WindowManager.Tpo $(DEPDIR)/zoomedit-WindowManager.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='WindowManager.cpp' object='zoomedit-WindowManager.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-WindowManager.obj `if test -f 'WindowManager.cpp'; then $(CYGPATH_W) 'WindowManager.cpp'; else $(CYGPATH_W) '$(srcdir)/WindowManager.cpp'; fi` + +zoomedit-SidebarManager.o: SidebarManager.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-SidebarManager.o -MD -MP -MF $(DEPDIR)/zoomedit-SidebarManager.Tpo -c -o zoomedit-SidebarManager.o `test -f 'SidebarManager.cpp' || echo '$(srcdir)/'`SidebarManager.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-SidebarManager.Tpo $(DEPDIR)/zoomedit-SidebarManager.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='SidebarManager.cpp' object='zoomedit-SidebarManager.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-SidebarManager.o `test -f 'SidebarManager.cpp' || echo '$(srcdir)/'`SidebarManager.cpp + +zoomedit-SidebarManager.obj: SidebarManager.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-SidebarManager.obj -MD -MP -MF $(DEPDIR)/zoomedit-SidebarManager.Tpo -c -o zoomedit-SidebarManager.obj `if test -f 'SidebarManager.cpp'; then $(CYGPATH_W) 'SidebarManager.cpp'; else $(CYGPATH_W) '$(srcdir)/SidebarManager.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-SidebarManager.Tpo $(DEPDIR)/zoomedit-SidebarManager.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='SidebarManager.cpp' object='zoomedit-SidebarManager.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-SidebarManager.obj `if test -f 'SidebarManager.cpp'; then $(CYGPATH_W) 'SidebarManager.cpp'; else $(CYGPATH_W) '$(srcdir)/SidebarManager.cpp'; fi` + +zoomedit-Window.o: Window.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-Window.o -MD -MP -MF $(DEPDIR)/zoomedit-Window.Tpo -c -o zoomedit-Window.o `test -f 'Window.cpp' || echo '$(srcdir)/'`Window.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-Window.Tpo $(DEPDIR)/zoomedit-Window.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='Window.cpp' object='zoomedit-Window.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-Window.o `test -f 'Window.cpp' || echo '$(srcdir)/'`Window.cpp + +zoomedit-Window.obj: Window.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-Window.obj -MD -MP -MF $(DEPDIR)/zoomedit-Window.Tpo -c -o zoomedit-Window.obj `if test -f 'Window.cpp'; then $(CYGPATH_W) 'Window.cpp'; else $(CYGPATH_W) '$(srcdir)/Window.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-Window.Tpo $(DEPDIR)/zoomedit-Window.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='Window.cpp' object='zoomedit-Window.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-Window.obj `if test -f 'Window.cpp'; then $(CYGPATH_W) 'Window.cpp'; else $(CYGPATH_W) '$(srcdir)/Window.cpp'; fi` + +zoomedit-SidebarView.o: SidebarView.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-SidebarView.o -MD -MP -MF $(DEPDIR)/zoomedit-SidebarView.Tpo -c -o zoomedit-SidebarView.o `test -f 'SidebarView.cpp' || echo '$(srcdir)/'`SidebarView.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-SidebarView.Tpo $(DEPDIR)/zoomedit-SidebarView.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='SidebarView.cpp' object='zoomedit-SidebarView.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-SidebarView.o `test -f 'SidebarView.cpp' || echo '$(srcdir)/'`SidebarView.cpp + +zoomedit-SidebarView.obj: SidebarView.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-SidebarView.obj -MD -MP -MF $(DEPDIR)/zoomedit-SidebarView.Tpo -c -o zoomedit-SidebarView.obj `if test -f 'SidebarView.cpp'; then $(CYGPATH_W) 'SidebarView.cpp'; else $(CYGPATH_W) '$(srcdir)/SidebarView.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-SidebarView.Tpo $(DEPDIR)/zoomedit-SidebarView.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='SidebarView.cpp' object='zoomedit-SidebarView.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-SidebarView.obj `if test -f 'SidebarView.cpp'; then $(CYGPATH_W) 'SidebarView.cpp'; else $(CYGPATH_W) '$(srcdir)/SidebarView.cpp'; fi` + +zoomedit-SidebarAdd.o: SidebarAdd.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-SidebarAdd.o -MD -MP -MF $(DEPDIR)/zoomedit-SidebarAdd.Tpo -c -o zoomedit-SidebarAdd.o `test -f 'SidebarAdd.cpp' || echo '$(srcdir)/'`SidebarAdd.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-SidebarAdd.Tpo $(DEPDIR)/zoomedit-SidebarAdd.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='SidebarAdd.cpp' object='zoomedit-SidebarAdd.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-SidebarAdd.o `test -f 'SidebarAdd.cpp' || echo '$(srcdir)/'`SidebarAdd.cpp + +zoomedit-SidebarAdd.obj: SidebarAdd.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-SidebarAdd.obj -MD -MP -MF $(DEPDIR)/zoomedit-SidebarAdd.Tpo -c -o zoomedit-SidebarAdd.obj `if test -f 'SidebarAdd.cpp'; then $(CYGPATH_W) 'SidebarAdd.cpp'; else $(CYGPATH_W) '$(srcdir)/SidebarAdd.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-SidebarAdd.Tpo $(DEPDIR)/zoomedit-SidebarAdd.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='SidebarAdd.cpp' object='zoomedit-SidebarAdd.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-SidebarAdd.obj `if test -f 'SidebarAdd.cpp'; then $(CYGPATH_W) 'SidebarAdd.cpp'; else $(CYGPATH_W) '$(srcdir)/SidebarAdd.cpp'; fi` + +zoomedit-Drawer.o: Drawer.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-Drawer.o -MD -MP -MF $(DEPDIR)/zoomedit-Drawer.Tpo -c -o zoomedit-Drawer.o `test -f 'Drawer.cpp' || echo '$(srcdir)/'`Drawer.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-Drawer.Tpo $(DEPDIR)/zoomedit-Drawer.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='Drawer.cpp' object='zoomedit-Drawer.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-Drawer.o `test -f 'Drawer.cpp' || echo '$(srcdir)/'`Drawer.cpp + +zoomedit-Drawer.obj: Drawer.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-Drawer.obj -MD -MP -MF $(DEPDIR)/zoomedit-Drawer.Tpo -c -o zoomedit-Drawer.obj `if test -f 'Drawer.cpp'; then $(CYGPATH_W) 'Drawer.cpp'; else $(CYGPATH_W) '$(srcdir)/Drawer.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-Drawer.Tpo $(DEPDIR)/zoomedit-Drawer.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='Drawer.cpp' object='zoomedit-Drawer.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-Drawer.obj `if test -f 'Drawer.cpp'; then $(CYGPATH_W) 'Drawer.cpp'; else $(CYGPATH_W) '$(srcdir)/Drawer.cpp'; fi` + +zoomedit-EditManager.o: EditManager.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-EditManager.o -MD -MP -MF $(DEPDIR)/zoomedit-EditManager.Tpo -c -o zoomedit-EditManager.o `test -f 'EditManager.cpp' || echo '$(srcdir)/'`EditManager.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-EditManager.Tpo $(DEPDIR)/zoomedit-EditManager.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='EditManager.cpp' object='zoomedit-EditManager.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-EditManager.o `test -f 'EditManager.cpp' || echo '$(srcdir)/'`EditManager.cpp + +zoomedit-EditManager.obj: EditManager.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-EditManager.obj -MD -MP -MF $(DEPDIR)/zoomedit-EditManager.Tpo -c -o zoomedit-EditManager.obj `if test -f 'EditManager.cpp'; then $(CYGPATH_W) 'EditManager.cpp'; else $(CYGPATH_W) '$(srcdir)/EditManager.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-EditManager.Tpo $(DEPDIR)/zoomedit-EditManager.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='EditManager.cpp' object='zoomedit-EditManager.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-EditManager.obj `if test -f 'EditManager.cpp'; then $(CYGPATH_W) 'EditManager.cpp'; else $(CYGPATH_W) '$(srcdir)/EditManager.cpp'; fi` + ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ diff --git a/Polygon.cpp b/Polygon.cpp index 7eaeaa9..8b32bb4 100644 --- a/Polygon.cpp +++ b/Polygon.cpp @@ -20,7 +20,7 @@ float Polygon::signedArea() const { Polygon::Direction Polygon::getDirection() const { float area = signedArea(); - return (area > 0) ? Triangle::CW : (area < 0) ? Triangle::CCW : Triangle::Unknown; + return (area > 0) ? Triangle::CW : (area < 0) ? Triangle::CCW : Triangle::UNKNOWN; } float Polygon::area() const { diff --git a/Sidebar.h b/Sidebar.h new file mode 100644 index 0000000..7d30afc --- /dev/null +++ b/Sidebar.h @@ -0,0 +1,16 @@ +#ifndef SIDEBAR_H_ +#define SIDEBAR_H_ + +#include <gtk/gtk.h> + + +class Sidebar { + public: + virtual ~Sidebar() {} + + virtual GtkWidget* getWidget() = 0; + + virtual void update() = 0; +}; + +#endif /*SIDEBAR_H_*/ diff --git a/SidebarAdd.cpp b/SidebarAdd.cpp new file mode 100644 index 0000000..78509e0 --- /dev/null +++ b/SidebarAdd.cpp @@ -0,0 +1,43 @@ +#include "SidebarAdd.h" +#include "edit.h" + + +void SidebarAdd::buttonClicked(GtkButton *button, SidebarAdd *sidebar) { + sidebar->editor->finishRoom(); +} + +SidebarAdd::SidebarAdd(EditManager *editor) { + this->editor = editor; + + sidebar = gtk_vbox_new(FALSE, 0); + g_object_ref_sink(G_OBJECT(sidebar)); + + GtkWidget *labelRoomInfo = gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(labelRoomInfo), "<b>Add room</b>"); + gtk_misc_set_alignment(GTK_MISC(labelRoomInfo), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(sidebar), labelRoomInfo, FALSE, FALSE, 5); + + buttonAdd = gtk_button_new_with_label("Add room"); + g_signal_connect(G_OBJECT(buttonAdd), "clicked", G_CALLBACK(buttonClicked), this); + gtk_box_pack_end(GTK_BOX(sidebar), buttonAdd, FALSE, FALSE, 0); + + gtk_widget_show_all(sidebar); +} + +SidebarAdd::~SidebarAdd() { + g_object_unref(G_OBJECT(sidebar)); +} + +GtkWidget* SidebarAdd::getWidget() { + return sidebar; +} + +void SidebarAdd::update() { + if(!getActiveRoom()) + return; + + if(getActiveRoom()->size() > 2 && isPolygonOk(getActiveRoom())) + gtk_widget_set_sensitive(buttonAdd, TRUE); + else + gtk_widget_set_sensitive(buttonAdd, FALSE); +} diff --git a/SidebarAdd.h b/SidebarAdd.h new file mode 100644 index 0000000..e5571f8 --- /dev/null +++ b/SidebarAdd.h @@ -0,0 +1,30 @@ +#ifndef SIDEBARADD_H_ +#define SIDEBARADD_H_ + +#include "Sidebar.h" +#include "EditManager.h" + + +class SidebarAdd : public Sidebar { + private: + GtkWidget *sidebar; + GtkWidget *buttonAdd; + + EditManager *editor; + + // prevent shallow copy + SidebarAdd(const SidebarAdd &w); + const SidebarAdd& operator=(const SidebarAdd &w); + + static void buttonClicked(GtkButton *button, SidebarAdd *sidebar); + + public: + SidebarAdd(EditManager *editor); + virtual ~SidebarAdd(); + + GtkWidget* getWidget(); + + void update(); +}; + +#endif /*SIDEBARADD_H_*/ diff --git a/SidebarManager.cpp b/SidebarManager.cpp new file mode 100644 index 0000000..86e70d0 --- /dev/null +++ b/SidebarManager.cpp @@ -0,0 +1,46 @@ +#include "SidebarManager.h" + + +SidebarManager::SidebarManager(EditManager *editor) + : sidebarView(editor), sidebarAdd(editor) +{ + this->editor = editor; + activeSidebar = NULL; + + sidebar = gtk_scrolled_window_new(NULL, NULL); + g_object_ref_sink(G_OBJECT(sidebar)); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sidebar), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + + viewport = gtk_viewport_new(NULL, NULL); + gtk_container_add(GTK_CONTAINER(sidebar), viewport); + gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE); + + gtk_widget_show(sidebar); +} + +SidebarManager::~SidebarManager() { + g_object_unref(G_OBJECT(sidebar)); +} + +void SidebarManager::update() { + Sidebar *newSidebar = activeSidebar; + + switch(editor->getMode()) { + case EditManager::VIEW: + newSidebar = &sidebarView; + break; + case EditManager::ADD: + newSidebar = &sidebarAdd; + } + + if(activeSidebar != newSidebar) { + if(activeSidebar) + gtk_container_remove(GTK_CONTAINER(viewport), gtk_bin_get_child(GTK_BIN(viewport))); + + gtk_container_add(GTK_CONTAINER(viewport), newSidebar->getWidget()); + + activeSidebar = newSidebar; + } + + activeSidebar->update(); +} diff --git a/SidebarManager.h b/SidebarManager.h new file mode 100644 index 0000000..c195f08 --- /dev/null +++ b/SidebarManager.h @@ -0,0 +1,37 @@ +#ifndef SIDEBARMANAGER_H_ +#define SIDEBARMANAGER_H_ + +#include <gtk/gtk.h> +#include "Sidebar.h" +#include "SidebarView.h" +#include "SidebarAdd.h" +#include "EditManager.h" + + +class SidebarManager { + private: + GtkWidget *sidebar, *viewport; + + SidebarView sidebarView; + SidebarAdd sidebarAdd; + + Sidebar *activeSidebar; + + EditManager *editor; + + // prevent shallow copy + SidebarManager(const SidebarManager &w); + const SidebarManager& operator=(const SidebarManager &w); + + public: + SidebarManager(EditManager *editor); + virtual ~SidebarManager(); + + GtkWidget *getWidget() { + return sidebar; + } + + void update(); +}; + +#endif /*SIDEBARMANAGER_H_*/ diff --git a/SidebarView.cpp b/SidebarView.cpp new file mode 100644 index 0000000..82d4713 --- /dev/null +++ b/SidebarView.cpp @@ -0,0 +1,88 @@ +#include "SidebarView.h" +#include "edit.h" + + +void SidebarView::buttonClicked(GtkButton *button, SidebarView *sidebar) { + sidebar->editor->addRoom(); +} + +SidebarView::SidebarView(EditManager *editor) { + this->editor = editor; + + sidebar = gtk_vbox_new(FALSE, 0); + g_object_ref_sink(G_OBJECT(sidebar)); + + GtkWidget *labelRoomInfo = gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(labelRoomInfo), "<b>Room info:</b>"); + gtk_misc_set_alignment(GTK_MISC(labelRoomInfo), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(sidebar), labelRoomInfo, FALSE, FALSE, 5); + + gtk_box_pack_start(GTK_BOX(sidebar), gtk_hseparator_new(), FALSE, FALSE, 5); + + GtkWidget *labelName = gtk_label_new("Name:"); + gtk_misc_set_alignment(GTK_MISC(labelName), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(sidebar), labelName, FALSE, FALSE, 0); + + entryName = gtk_entry_new(); + gtk_widget_set_sensitive(entryName, FALSE); + //g_signal_connect(G_OBJECT(entryName), "focus-out-event", G_CALLBACK(sidebarNameFocusOutEvent), NULL); + //gtk_widget_add_events(entryName, GDK_FOCUS_CHANGE_MASK); + gtk_box_pack_start(GTK_BOX(sidebar), entryName, FALSE, FALSE, 0); + + GtkWidget *tableRoomData = gtk_table_new(2, 2, FALSE); + gtk_table_set_row_spacings(GTK_TABLE(tableRoomData), 5); + gtk_table_set_col_spacings(GTK_TABLE(tableRoomData), 10); + gtk_box_pack_start(GTK_BOX(sidebar), tableRoomData, FALSE, FALSE, 5); + + GtkWidget *labelAreaLabel = gtk_label_new("Room area:"); + gtk_misc_set_alignment(GTK_MISC(labelAreaLabel), 0.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelAreaLabel, 0, 1, 0, 1); + + labelArea = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(labelArea), 1.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelArea, 1, 2, 0, 1); + + GtkWidget *labelPerimeterLabel = gtk_label_new("Room perimeter:"); + gtk_misc_set_alignment(GTK_MISC(labelPerimeterLabel), 0.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelPerimeterLabel, 0, 1, 1, 2); + + labelPerimeter = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(labelPerimeter), 1.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelPerimeter, 1, 2, 1, 2); + + buttonAdd = gtk_button_new_with_label("Add room"); + g_signal_connect(G_OBJECT(buttonAdd), "clicked", G_CALLBACK(buttonClicked), this); + gtk_box_pack_end(GTK_BOX(sidebar), buttonAdd, FALSE, FALSE, 0); + + gtk_widget_show_all(sidebar); +} + +SidebarView::~SidebarView() { + g_object_unref(G_OBJECT(sidebar)); +} + +GtkWidget* SidebarView::getWidget() { + return sidebar; +} + +void SidebarView::update() { + if(getActiveRoom()) { + gtk_entry_set_text(GTK_ENTRY(entryName), getActiveRoom()->getName().c_str()); + gtk_widget_set_sensitive(entryName, TRUE); + + gchar *string = g_strdup_printf("%.2f", getActiveRoom()->area()); + gtk_label_set_text(GTK_LABEL(labelArea), string); + g_free(string); + + string = g_strdup_printf("%.2f", getActiveRoom()->perimeter()); + gtk_label_set_text(GTK_LABEL(labelPerimeter), string); + g_free(string); + } + else { + gtk_entry_set_text(GTK_ENTRY(entryName), ""); + gtk_widget_set_sensitive(entryName, FALSE); + + gtk_label_set_text(GTK_LABEL(labelArea), NULL); + gtk_label_set_text(GTK_LABEL(labelPerimeter), NULL); + } +} diff --git a/SidebarView.h b/SidebarView.h new file mode 100644 index 0000000..ae3ee28 --- /dev/null +++ b/SidebarView.h @@ -0,0 +1,30 @@ +#ifndef SIDEBARVIEW_H_ +#define SIDEBARVIEW_H_ + +#include "Sidebar.h" +#include "EditManager.h" + + +class SidebarView : public Sidebar { + private: + GtkWidget *sidebar; + GtkWidget *entryName, *labelArea, *labelPerimeter, *buttonAdd; + + EditManager *editor; + + // prevent shallow copy + SidebarView(const SidebarView &w); + const SidebarView& operator=(const SidebarView &w); + + static void buttonClicked(GtkButton *button, SidebarView *view); + + public: + SidebarView(EditManager *editor); + virtual ~SidebarView(); + + GtkWidget* getWidget(); + + void update(); +}; + +#endif /*SIDEBARVIEW_H_*/ diff --git a/Triangle.cpp b/Triangle.cpp index 124d16c..7587589 100644 --- a/Triangle.cpp +++ b/Triangle.cpp @@ -7,7 +7,7 @@ Triangle::Direction Triangle::getDirection() const { float c = (va.getX()-vb.getX())*(vc.getY()-vb.getY()) - (vc.getX()-vb.getX())*(va.getY()-vb.getY()); - return (c < 0) ? CW : (c > 0) ? CCW : Unknown; + return (c < 0) ? CW : (c > 0) ? CCW : UNKNOWN; } float Triangle::area() const { @@ -10,7 +10,7 @@ class Triangle { Vertex va, vb, vc; public: enum Direction { - CW, CCW, Unknown + CW, CCW, UNKNOWN }; Triangle() {} diff --git a/Window.cpp b/Window.cpp new file mode 100644 index 0000000..7e4dd63 --- /dev/null +++ b/Window.cpp @@ -0,0 +1,55 @@ +#include "Window.h" +#include "WindowManager.h" +#include "ui.h" +#include "edit.h" + + +gboolean Window::deleteEvent(GtkWidget *widget, GdkEvent *event, Window *window) { + gtk_widget_hide(widget); + + window->manager->windowClosed(window); + + return TRUE; +} + +Window::Window(GdkGLConfig *glconfig, WindowManager *manager) + : editor(this), drawer(this, glconfig), sidebar(&editor) +{ + this->manager = manager; + setLevel(&level); + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(window), 640, 480); + g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(deleteEvent), this); + + GtkWidget *vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(window), vbox); + + gtk_box_pack_start(GTK_BOX(vbox), getMenu(), FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), getToolbar(), FALSE, FALSE, 0); + + gtk_window_add_accel_group(GTK_WINDOW(window), getAccels()); + + GtkWidget *hPaned = gtk_hpaned_new(); + gtk_box_pack_end(GTK_BOX(vbox), hPaned, TRUE, TRUE, 0); + + gtk_paned_pack1(GTK_PANED(hPaned), drawer.getWidget(), TRUE, TRUE); + + gtk_paned_pack2(GTK_PANED(hPaned), sidebar.getWidget(), FALSE, TRUE); + sidebar.update(); + + gtk_widget_show_all(vbox); +} + +Window::~Window() { + gtk_widget_destroy(window); +} + +void Window::show() { + gtk_widget_show(window); +} + +void Window::update() { + drawer.update(); + sidebar.update(); +} diff --git a/Window.h b/Window.h new file mode 100644 index 0000000..1b44439 --- /dev/null +++ b/Window.h @@ -0,0 +1,50 @@ +#ifndef WINDOW_H_ +#define WINDOW_H_ + +#include <gtk/gtk.h> +#include <gtk/gtkgl.h> +#include "Drawer.h" +#include "SidebarManager.h" +#include "EditManager.h" +#include "Level.h" + + +class WindowManager; + + +class Window { + private: + GtkWidget *window; + + EditManager editor; + + Drawer drawer; + SidebarManager sidebar; + + WindowManager *manager; + + Level level; + + // prevent shallow copy + Window(const Window &w); + const Window& operator=(const Window &w); + + static gboolean deleteEvent(GtkWidget *widget, GdkEvent *event, Window *window); + public: + Window(GdkGLConfig *glconfig, WindowManager *manager); + virtual ~Window(); + + void show(); + + void update(); + + EditManager& getEditManager() { + return editor; + } + + Level& getLevel() { + return level; + } +}; + +#endif /*WINDOW_H_*/ diff --git a/WindowManager.cpp b/WindowManager.cpp new file mode 100644 index 0000000..971a1df --- /dev/null +++ b/WindowManager.cpp @@ -0,0 +1,28 @@ +#include "WindowManager.h" + + +WindowManager::WindowManager(GdkGLConfig *glconfig) { + this->glconfig = glconfig; + + windows.push_back(new Window(glconfig, this)); +} + +WindowManager::~WindowManager() { + for(std::list<Window*>::iterator w = windows.begin(); w != windows.end(); w++) + delete *w; +} + +void WindowManager::run() { + for(std::list<Window*>::iterator w = windows.begin(); w != windows.end(); w++) + (*w)->show(); + + gtk_main(); +} + +void WindowManager::windowClosed(Window *window) { + windows.remove(window); + delete window; + + if(windows.empty()) + gtk_main_quit(); +} diff --git a/WindowManager.h b/WindowManager.h new file mode 100644 index 0000000..20829e5 --- /dev/null +++ b/WindowManager.h @@ -0,0 +1,24 @@ +#ifndef WINDOWMANAGER_H_ +#define WINDOWMANAGER_H_ + +#include <list> +#include <gtk/gtk.h> +#include <gtk/gtkgl.h> +#include "Window.h" + + +class WindowManager { + private: + GdkGLConfig *glconfig; + std::list<Window*> windows; + + public: + WindowManager(GdkGLConfig *glconfig); + virtual ~WindowManager(); + + void run(); + + void windowClosed(Window *window); +}; + +#endif /*WINDOWMANAGER_H_*/ @@ -193,7 +193,7 @@ float getScale() { } void setScale(float s) { - scale = MAX(0.005, MIN(s, 10000)); + scale = s; } void imageToView(Vertex *v) { @@ -1,4 +1,3 @@ -#include "Level.h" #include "edit.h" @@ -14,6 +13,8 @@ static Room addRoom; static Vertex hoveredVertex; static int hasHoveredVertex = 0; +static IdManager idManager; + int getEditMode() { return editMode; } @@ -67,7 +68,7 @@ void setHoveredVertex(Vertex *v) { } void startAddMode() { - addRoom = Room(); + addRoom = Room(idManager.generate("room")); activeRoom = &addRoom; editMode = EDIT_MODE_ADD; @@ -81,6 +82,10 @@ Room *getHoveredRoom() { return hoveredRoom; } +IdManager *getIdManager() { + return &idManager; +} + static bool isLineOk(Line *l) { Line l2; @@ -2,6 +2,7 @@ #define EDIT_H_ #include "Level.h" +#include "IdManager.h" #define EDIT_MODE_VIEW 0 #define EDIT_MODE_SELECTED 1 @@ -23,6 +24,8 @@ Room *getHoveredRoom(); Vertex *getHoveredVertex(); void setHoveredVertex(Vertex *v); +IdManager *getIdManager(); + bool isVertexOk(Vertex *v); bool isPolygonOk(Polygon *polygon); @@ -1,6 +1,5 @@ #include "ui.h" #include "draw.h" -#include "window.h" #include <gtk/gtk.h> #include <string.h> @@ -27,12 +26,12 @@ static const gchar *uiData = static void handleAction(GtkAction *action, gpointer user_data) { - const gchar* name = gtk_action_get_name(action); + //const gchar* name = gtk_action_get_name(action); - if(!strcmp(name, "zoomIn")) + /*if(!strcmp(name, "zoomIn")) zoomInCentered(1.2f); else if(!strcmp(name, "zoomOut")) - zoomOutCentered(1.2f); + zoomOutCentered(1.2f);*/ } static GtkActionGroup *createActions() { diff --git a/window.cpp b/window.cpp deleted file mode 100644 index 1deff6d..0000000 --- a/window.cpp +++ /dev/null @@ -1,419 +0,0 @@ -#include "window.h" -#include "ui.h" -#include "edit.h" -#include "draw.h" -#include <gtk/gtk.h> -#include <gtk/gtkgl.h> -#include <GL/gl.h> - - -static GtkWidget *drawingArea = NULL, *sidebarView = NULL, *sidebarAdd = NULL; -static GtkAdjustment *hAdjustment = NULL, *vAdjustment = NULL; - -static GtkWidget *entryName, *labelArea = NULL, *labelPerimeter = NULL, *buttonAdd = NULL, *buttonAddDo = NULL; - - -static void refreshScrolling() { - if(getImageWidth() < drawingArea->allocation.width) - setXTranslate((getImageWidth()-drawingArea->allocation.width)/2); - else - setXTranslate(gtk_adjustment_get_value(hAdjustment)); - - if(getImageHeight() < drawingArea->allocation.height) - setYTranslate((getImageHeight()-drawingArea->allocation.height)/2); - else - setYTranslate(gtk_adjustment_get_value(vAdjustment)); - - gtk_widget_queue_draw(drawingArea); -} - -static void updateScrollbars(float x, float y) { - const gdouble imageWidth = getImageWidth(), imageHeight = getImageHeight(); - const gdouble width = drawingArea->allocation.width, height = drawingArea->allocation.height; - gdouble upper, pageSize, value; - - gdk_window_freeze_updates(drawingArea->window); - - g_object_get(G_OBJECT(hAdjustment), "upper", &upper, "page_size", &pageSize, NULL); - g_object_set(G_OBJECT(hAdjustment), "upper", imageWidth, "page_size", width, NULL); - gtk_adjustment_changed(hAdjustment); - - if((pageSize > upper && width < imageWidth) || upper == 0) - value = (imageWidth-width)/2; - else - value = (gtk_adjustment_get_value(hAdjustment)+pageSize*x)/upper*imageWidth-width*x; - gtk_adjustment_set_value(hAdjustment, MAX(MIN(value, imageWidth-width), 0)); - - g_object_get(G_OBJECT(vAdjustment), "upper", &upper, "page_size", &pageSize, NULL); - g_object_set(G_OBJECT(vAdjustment), "upper", imageHeight, "page_size", height, NULL); - gtk_adjustment_changed(vAdjustment); - - if((pageSize > upper && height < imageHeight) || upper == 0) - value = (imageHeight-height)/2; - else - value = (gtk_adjustment_get_value(vAdjustment)+pageSize*y)/upper*imageHeight-height*y; - gtk_adjustment_set_value(vAdjustment, MAX(MIN(value, imageHeight-height), 0)); - - gdk_window_thaw_updates(drawingArea->window); - - refreshScrolling(); -} - -static gboolean deleteEvent(GtkWidget *widget, GdkEvent *event, gpointer data) { - return FALSE; -} - -static void realize(GtkWidget *widget, gpointer data) { - GdkGLContext *context = gtk_widget_get_gl_context(widget); - GdkGLDrawable *drawable = gtk_widget_get_gl_drawable(widget); - - if(!gdk_gl_drawable_gl_begin(drawable, context)) - return; - - glClearColor(0.0, 0.0, 0.0, 1.0); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - glEnable(GL_LINE_SMOOTH); - - glViewport(0, 0, widget->allocation.width, widget->allocation.height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - if(widget->allocation.width != 0 && widget->allocation.height != 0) { - glTranslatef(-1, 1, 0); - glScalef(2.0f/widget->allocation.width, -2.0f/widget->allocation.height, 1); - } - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - gdk_gl_drawable_gl_end(drawable); -} - -static gboolean configureEvent(GtkWidget *widget, GdkEventConfigure *event, gpointer data) { - GdkGLContext *context = gtk_widget_get_gl_context(widget); - GdkGLDrawable *drawable = gtk_widget_get_gl_drawable(widget); - - if(!gdk_gl_drawable_gl_begin(drawable, context)) - return FALSE; - - glViewport(0, 0, widget->allocation.width, widget->allocation.height); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - if(widget->allocation.width != 0 && widget->allocation.height != 0) { - glTranslatef(-1, 1, 0); - glScalef(2.0f/widget->allocation.width, -2.0f/widget->allocation.height, 1); - } - - gdk_gl_drawable_gl_end(drawable); - - updateScrollbars(0.5, 0.5); - - return TRUE; -} - - -static gboolean scrollEvent(GtkWidget *widget, GdkEventScroll *event, gpointer user_data) { - const float x = event->x/widget->allocation.width, y = event->y/widget->allocation.height; - - switch(event->direction) { - case GDK_SCROLL_UP: - zoomIn(1.1f, x, y); - return TRUE; - case GDK_SCROLL_DOWN: - zoomOut(1.1f, x, y); - return TRUE; - default: - return FALSE; - } -} - -static gboolean buttonEvent(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - Vertex v(event->x, event->y); - - switch(event->type) { - case GDK_BUTTON_PRESS: - switch(event->button) { - case 1: - switch(getEditMode()) { - case EDIT_MODE_VIEW: - case EDIT_MODE_SELECTED: - setActiveRoom(getHoveredRoom()); - - updateSidebar(); - - break; - case EDIT_MODE_ADD: - viewToImage(&v); - - if(isVertexOk(&v)) { - getActiveRoom()->push_back(v); - updateSidebar(); - } - } - - gtk_widget_queue_draw(drawingArea); - } - - return TRUE; - default: - return FALSE; - } -} - -gboolean crossingNotifyEvent(GtkWidget *widget, GdkEventCrossing *event, gpointer user_data) { - Vertex v(event->x, event->y); - - switch(event->type) { - case GDK_ENTER_NOTIFY: - viewToImage(&v); - - setHoveredVertex(&v); - - gtk_widget_queue_draw(drawingArea); - - return TRUE; - case GDK_LEAVE_NOTIFY: - setHoveredVertex(NULL); - - gtk_widget_queue_draw(drawingArea); - - return TRUE; - default: - return FALSE; - } -} - -gboolean motionNotifyEvent(GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { - Vertex v(event->x, event->y); - Room *last = getHoveredRoom(); - - viewToImage(&v); - - setHoveredVertex(&v); - - if(getHoveredRoom() != last || getEditMode() == EDIT_MODE_ADD) - gtk_widget_queue_draw(drawingArea); - - return TRUE; -} - -static void destroy(GtkWidget *widget, gpointer data) { - gtk_main_quit(); -} - -static void sidebarNameChanged(GtkEditable *editable, gpointer user_data) { - if(getActiveRoom() == NULL) return; - - getActiveRoom()->setName(std::string(gtk_entry_get_text(GTK_ENTRY(entryName)))); -} - -static void sidebarButtonClicked(GtkButton *button, gpointer user_data) { - if(button == GTK_BUTTON(buttonAdd)) { - startAddMode(); - updateSidebar(); - - gtk_widget_queue_draw(drawingArea); - } - else if(button == GTK_BUTTON(buttonAddDo)) { - if(getActiveRoom() && getActiveRoom()->size() > 2 && isPolygonOk(getActiveRoom())) { - getLevel()->push_back(*getActiveRoom()); - setActiveRoom(&getLevel()->back()); - } - - endAddMode(); - updateSidebar(); - - gtk_widget_queue_draw(drawingArea); - } -} - -static GtkWidget* createSidebar() { - GtkWidget *sidebar, *labelRoomInfo, *labelName; - GtkWidget *tableRoomData, *labelAreaLabel, *labelPerimeterLabel; - - sidebar = gtk_hbox_new(FALSE, 0); - - // View sidebar - sidebarView = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(sidebar), sidebarView, FALSE, FALSE, 5); - - labelRoomInfo = gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(labelRoomInfo), "<b>Room info:</b>"); - gtk_misc_set_alignment(GTK_MISC(labelRoomInfo), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(sidebarView), labelRoomInfo, FALSE, FALSE, 5); - - gtk_box_pack_start(GTK_BOX(sidebarView), gtk_hseparator_new(), FALSE, FALSE, 5); - - labelName = gtk_label_new("Name:"); - gtk_misc_set_alignment(GTK_MISC(labelName), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(sidebarView), labelName, FALSE, FALSE, 0); - - entryName = gtk_entry_new(); - gtk_widget_set_sensitive(entryName, FALSE); - g_signal_connect(G_OBJECT(entryName), "changed", G_CALLBACK(sidebarNameChanged), NULL); - gtk_box_pack_start(GTK_BOX(sidebarView), entryName, FALSE, FALSE, 0); - - tableRoomData = gtk_table_new(2, 2, FALSE); - gtk_table_set_row_spacings(GTK_TABLE(tableRoomData), 5); - gtk_table_set_col_spacings(GTK_TABLE(tableRoomData), 10); - gtk_box_pack_start(GTK_BOX(sidebarView), tableRoomData, FALSE, FALSE, 5); - - labelAreaLabel = gtk_label_new("Room area:"); - gtk_misc_set_alignment(GTK_MISC(labelAreaLabel), 0.0, 0.5); - gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelAreaLabel, 0, 1, 0, 1); - - labelArea = gtk_label_new(NULL); - gtk_misc_set_alignment(GTK_MISC(labelArea), 1.0, 0.5); - gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelArea, 1, 2, 0, 1); - - labelPerimeterLabel = gtk_label_new("Room perimeter:"); - gtk_misc_set_alignment(GTK_MISC(labelPerimeterLabel), 0.0, 0.5); - gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelPerimeterLabel, 0, 1, 1, 2); - - labelPerimeter = gtk_label_new(NULL); - gtk_misc_set_alignment(GTK_MISC(labelPerimeter), 1.0, 0.5); - gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelPerimeter, 1, 2, 1, 2); - - buttonAdd = gtk_button_new_with_label("Add room"); - g_signal_connect(G_OBJECT(buttonAdd), "clicked", G_CALLBACK(sidebarButtonClicked), NULL); - gtk_box_pack_end(GTK_BOX(sidebarView), buttonAdd, FALSE, FALSE, 0); - - // Add sidebar - sidebarAdd = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(sidebar), sidebarAdd, FALSE, FALSE, 5); - - labelRoomInfo = gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(labelRoomInfo), "<b>Add room</b>"); - gtk_misc_set_alignment(GTK_MISC(labelRoomInfo), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(sidebarAdd), labelRoomInfo, FALSE, FALSE, 5); - - buttonAddDo = gtk_button_new_with_label("Add room"); - g_signal_connect(G_OBJECT(buttonAddDo), "clicked", G_CALLBACK(sidebarButtonClicked), NULL); - gtk_box_pack_end(GTK_BOX(sidebarAdd), buttonAddDo, FALSE, FALSE, 0); - - return sidebar; -} - -GtkWidget* createMainWindow(GdkGLConfig *glconfig) { - GtkWidget *window, *hPaned, *vbox, *table, *vScroll, *hScroll, *sidebar; - - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size(GTK_WINDOW(window), 640, 480); - g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(deleteEvent), NULL); - g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL); - - vbox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(window), vbox); - - gtk_box_pack_start(GTK_BOX(vbox), getMenu(), FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), getToolbar(), FALSE, FALSE, 0); - - gtk_window_add_accel_group(GTK_WINDOW(window), getAccels()); - - hPaned = gtk_hpaned_new(); - gtk_box_pack_end(GTK_BOX(vbox), hPaned, TRUE, TRUE, 0); - - table = gtk_table_new(2, 2, FALSE); - gtk_paned_pack1(GTK_PANED(hPaned), table, TRUE, TRUE); - - drawingArea = gtk_drawing_area_new(); - gtk_widget_set_gl_capability(drawingArea, glconfig, NULL, TRUE, GDK_GL_RGBA_TYPE); - gtk_widget_set_double_buffered(drawingArea, FALSE); - g_signal_connect(G_OBJECT(drawingArea), "realize", G_CALLBACK(realize), NULL); - g_signal_connect(G_OBJECT(drawingArea), "configure-event", G_CALLBACK(configureEvent), NULL); - g_signal_connect(G_OBJECT(drawingArea), "expose-event", G_CALLBACK(drawTopView), NULL); - g_signal_connect(G_OBJECT(drawingArea), "button-press-event", G_CALLBACK(buttonEvent), NULL); - g_signal_connect(G_OBJECT(drawingArea), "button-release-event", G_CALLBACK(buttonEvent), NULL); - g_signal_connect(G_OBJECT(drawingArea), "enter-notify-event", G_CALLBACK(crossingNotifyEvent), NULL); - g_signal_connect(G_OBJECT(drawingArea), "leave-notify-event", G_CALLBACK(crossingNotifyEvent), NULL); - g_signal_connect(G_OBJECT(drawingArea), "motion-notify-event", G_CALLBACK(motionNotifyEvent), NULL); - g_signal_connect(G_OBJECT(drawingArea), "scroll-event", G_CALLBACK(scrollEvent), NULL); - gtk_widget_add_events(drawingArea, GDK_SCROLL_MASK | GDK_POINTER_MOTION_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - gtk_table_attach(GTK_TABLE(table), drawingArea, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL|GTK_EXPAND|GTK_SHRINK), (GtkAttachOptions)(GTK_FILL|GTK_EXPAND|GTK_SHRINK), 0, 0); - - hAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 0, 10, 100, 100)); - hScroll = gtk_hscrollbar_new(hAdjustment); - g_signal_connect(G_OBJECT(hScroll), "value-changed", G_CALLBACK(refreshScrolling), NULL); - gtk_table_attach(GTK_TABLE(table), hScroll, 0, 1, 1, 2, (GtkAttachOptions)(GTK_FILL|GTK_EXPAND|GTK_SHRINK), (GtkAttachOptions)0, 0, 0); - - vAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 0, 10, 100, 100)); - vScroll = gtk_vscrollbar_new(vAdjustment); - g_signal_connect(G_OBJECT(vScroll), "value-changed", G_CALLBACK(refreshScrolling), NULL); - gtk_table_attach(GTK_TABLE(table), vScroll, 1, 2, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)(GTK_FILL|GTK_EXPAND|GTK_SHRINK), 0, 0); - - sidebar = createSidebar(); - gtk_paned_pack2(GTK_PANED(hPaned), sidebar, FALSE, TRUE); - - gtk_widget_show_all(vbox); - gtk_widget_hide(sidebarAdd); - - return window; -} - -void updateSidebar() { - gchar *string; - - switch(getEditMode()) { - case EDIT_MODE_VIEW: - case EDIT_MODE_SELECTED: - gtk_widget_hide(sidebarAdd); - gtk_widget_show(sidebarView); - - if(getActiveRoom()) { - gtk_entry_set_text(GTK_ENTRY(entryName), getActiveRoom()->getName().c_str()); - gtk_widget_set_sensitive(entryName, TRUE); - - string = g_strdup_printf("%.2f", getActiveRoom()->area()); - gtk_label_set_text(GTK_LABEL(labelArea), string); - g_free(string); - - string = g_strdup_printf("%.2f", getActiveRoom()->perimeter()); - gtk_label_set_text(GTK_LABEL(labelPerimeter), string); - g_free(string); - } - else { - gtk_entry_set_text(GTK_ENTRY(entryName), ""); - gtk_widget_set_sensitive(entryName, FALSE); - - gtk_label_set_text(GTK_LABEL(labelArea), NULL); - gtk_label_set_text(GTK_LABEL(labelPerimeter), NULL); - } - - break; - case EDIT_MODE_ADD: - gtk_widget_hide(sidebarView); - gtk_widget_show(sidebarAdd); - - if(getActiveRoom()) { - if(getActiveRoom()->size() > 2 && isPolygonOk(getActiveRoom())) - gtk_widget_set_sensitive(buttonAddDo, TRUE); - else - gtk_widget_set_sensitive(buttonAddDo, FALSE); - } - } -} - -void zoomIn(float factor, float x, float y) { - setScale(getScale()*factor); - updateScrollbars(x, y); -} - -void zoomOut(float factor, float x, float y) { - setScale(getScale()/factor); - updateScrollbars(x, y); -} - -void zoomInCentered(float factor) { - zoomIn(factor, 0.5, 0.5); -} - -void zoomOutCentered(float factor) { - zoomOut(factor, 0.5, 0.5); -} diff --git a/window.h b/window.h deleted file mode 100644 index ba0562e..0000000 --- a/window.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef WINDOW_H_ -#define WINDOW_H_ - -#include <gtk/gtk.h> -#include <gtk/gtkgl.h> - - -GtkWidget* createMainWindow(GdkGLConfig *glconfig); - -void updateSidebar(); - -void zoomIn(float factor, float x, float y); -void zoomOut(float factor, float x, float y); -void zoomInCentered(float factor); -void zoomOutCentered(float factor); - -#endif /*WINDOW_H_*/ diff --git a/zoomedit.cpp b/zoomedit.cpp index 580e224..682127c 100644 --- a/zoomedit.cpp +++ b/zoomedit.cpp @@ -2,15 +2,12 @@ #include <gtk/gtkgl.h> #include <stdlib.h> #include "Level.h" -#include "window.h" +#include "WindowManager.h" #include "edit.h" int main(int argc, char *argv[]) { GdkGLConfig *glconfig; - GtkWidget *window; - - setLevel(new Level()); gtk_init(&argc, &argv); gtk_gl_init(&argc, &argv); @@ -22,13 +19,9 @@ int main(int argc, char *argv[]) { exit (1); } - window = createMainWindow(glconfig); - - gtk_widget_show(window); - - gtk_main(); + WindowManager window(glconfig); - delete getLevel(); + window.run(); return 0; } |