summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Gui/RenderArea.cpp82
-rw-r--r--src/Gui/RenderArea.h11
-rw-r--r--src/Util/Xml.h6
-rw-r--r--src/View/TopView.h6
-rw-r--r--src/View/View.h6
-rw-r--r--zoomedit.glade41
6 files changed, 25 insertions, 127 deletions
diff --git a/src/Gui/RenderArea.cpp b/src/Gui/RenderArea.cpp
index 8062b80..eb1f3eb 100644
--- a/src/Gui/RenderArea.cpp
+++ b/src/Gui/RenderArea.cpp
@@ -32,7 +32,7 @@ namespace Gui {
GdkGLConfig *RenderArea::glconfig = 0;
RenderArea::RenderArea(BaseObjectType *cobject, const Glib::RefPtr<Gnome::Glade::Xml> &xml)
-: Gtk::DrawingArea(cobject), view(0), xCenter(0), yCenter(0), zoomLevel(0), scale(100) {
+: Gtk::DrawingArea(cobject), view(0), xCenter(0), yCenter(0), viewWidth(0), viewHeight(0), zoomLevel(0), scale(100) {
if(!glconfig) {
glconfig = gdk_gl_config_new_by_mode((GdkGLConfigMode)(GDK_GL_MODE_RGB | GDK_GL_MODE_DOUBLE));
if(!glconfig) glconfig = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGB); // Hmm, can't find double buffered config
@@ -54,12 +54,6 @@ RenderArea::RenderArea(BaseObjectType *cobject, const Glib::RefPtr<Gnome::Glade:
xml->get_widget("ToolButtonZoomOut", button);
button->signal_clicked().connect(sigc::bind(sigc::mem_fun(this, &RenderArea::zoom), -2, 0.5f, 0.5f));
- xml->get_widget("Hscrollbar", hScrollbar);
- hScrollbar->signal_value_changed().connect(sigc::mem_fun(this, &RenderArea::updateScrolling));
-
- xml->get_widget("Vscrollbar", vScrollbar);
- vScrollbar->signal_value_changed().connect(sigc::mem_fun(this, &RenderArea::updateScrolling));
-
gtk_widget_set_gl_capability(GTK_WIDGET(cobject), glconfig, 0, TRUE, GDK_GL_RGBA_TYPE);
}
@@ -127,7 +121,7 @@ void RenderArea::zoom(int zoom, float x, float y) {
zoomLevel = std::max(std::min(zoomLevel + zoom, 50), -100);
scale = 100*std::pow(1.1f, zoomLevel);
- updateScrollbars(x, y);
+ updateScrolling(x, y);
}
void RenderArea::updateViewport() {
@@ -144,75 +138,17 @@ void RenderArea::updateViewport() {
gdkGLEnd();
- updateScrollbars();
-}
-
-void RenderArea::updateScrollbars(float x, float y) {
- float minX, maxX, minY, maxY;
- const gdouble width = getViewWidth(), height = getViewHeight();
- gdouble lower, upper, pageSize, value;
-
- if(!view)
- return;
-
- view->getBounds(&minX, &maxX, &minY, &maxY);
- float xVal = std::max(std::fabs(minX), std::fabs(maxX));
- float yVal = std::max(std::fabs(minY), std::fabs(maxY));
-
- get_window()->freeze_updates();
-
- lower = hScrollbar->get_adjustment()->get_lower();
- upper = hScrollbar->get_adjustment()->get_upper();
- pageSize = hScrollbar->get_adjustment()->get_page_size();
-
- hScrollbar->get_adjustment()->set_lower(-xVal + width/2);
- hScrollbar->get_adjustment()->set_upper(xVal + width/2);
- hScrollbar->get_adjustment()->set_page_size(width);
-
- if(pageSize > (upper-lower) && width < 2*xVal)
- value = 0;
- else
- value = hScrollbar->get_value() + (x-0.5)*(pageSize-width);
-
- hScrollbar->set_value(std::max(std::min(value, xVal - width/2), -xVal + width/2));
-
- lower = vScrollbar->get_adjustment()->get_lower();
- upper = vScrollbar->get_adjustment()->get_upper();
- pageSize = vScrollbar->get_adjustment()->get_page_size();
-
- vScrollbar->get_adjustment()->set_lower(-yVal + height/2);
- vScrollbar->get_adjustment()->set_upper(yVal + height/2);
- vScrollbar->get_adjustment()->set_page_size(height);
-
- if(pageSize > (upper-lower) && height < 2*yVal)
- value = 0;
- else
- value = vScrollbar->get_value() + (y-0.5)*(pageSize-height);
-
- vScrollbar->set_value(std::max(std::min(value, yVal - height/2), -yVal + height/2));
-
- get_window()->thaw_updates();
-
updateScrolling();
}
-void RenderArea::updateScrolling() {
- const float imageWidth = hScrollbar->get_adjustment()->get_upper()-hScrollbar->get_adjustment()->get_lower();
- const float imageHeight = vScrollbar->get_adjustment()->get_upper()-vScrollbar->get_adjustment()->get_lower();
-
- if(hScrollbar) {
- if(imageWidth < getViewWidth())
- xCenter = 0;
- else
- xCenter = hScrollbar->get_value();
- }
+void RenderArea::updateScrolling(float x, float y) {
+ const float newWidth = get_width()/scale, newHeight = get_height()/scale;
- if(vScrollbar) {
- if(imageHeight < getViewHeight())
- yCenter = 0;
- else
- yCenter = vScrollbar->get_value();
- }
+ xCenter += (x-0.5)*(viewWidth-newWidth);
+ yCenter += (y-0.5)*(viewHeight-newHeight);
+
+ viewWidth = newWidth;
+ viewHeight = newHeight;
queue_draw();
}
diff --git a/src/Gui/RenderArea.h b/src/Gui/RenderArea.h
index 59498d4..8ac72d7 100644
--- a/src/Gui/RenderArea.h
+++ b/src/Gui/RenderArea.h
@@ -44,11 +44,11 @@ class RenderArea : public Gtk::DrawingArea {
}
float getViewWidth() const {
- return get_width()/scale;
+ return viewWidth;
}
float getViewHeight() const {
- return get_height()/scale;
+ return viewHeight;
}
float getScale() const {return scale;}
@@ -59,12 +59,10 @@ class RenderArea : public Gtk::DrawingArea {
private:
static GdkGLConfig *glconfig;
- Gtk::HScrollbar *hScrollbar;
- Gtk::VScrollbar *vScrollbar;
-
View::View *view;
float xCenter, yCenter;
+ float viewWidth, viewHeight;
int zoomLevel;
float scale;
@@ -77,8 +75,7 @@ class RenderArea : public Gtk::DrawingArea {
void zoom(int zoom, float x = 0.5f, float y = 0.5f);
void updateViewport();
- void updateScrollbars(float x = 0.5f, float y = 0.5f);
- void updateScrolling();
+ void updateScrolling(float x = 0.5f, float y = 0.5f);
bool gdkGLBegin() {
GtkWidget *widget = GTK_WIDGET(gobj());
diff --git a/src/Util/Xml.h b/src/Util/Xml.h
index a956ae8..e71f653 100644
--- a/src/Util/Xml.h
+++ b/src/Util/Xml.h
@@ -17,8 +17,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef ZOOMEDIT_DATA_XML_H_
-#define ZOOMEDIT_DATA_XML_H_
+#ifndef ZOOMEDIT_UTIL_XML_H_
+#define ZOOMEDIT_UTIL_XML_H_
#include <libxml++/nodes/element.h>
@@ -36,4 +36,4 @@ class Xml {
}
}
-#endif /*XML_H_*/
+#endif /*ZOOMEDIT_UTIL_XML_H_*/
diff --git a/src/View/TopView.h b/src/View/TopView.h
index 0996ad3..952cd32 100644
--- a/src/View/TopView.h
+++ b/src/View/TopView.h
@@ -17,8 +17,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef ZOOMEDIT_TOPVIEW_H_
-#define ZOOMEDIT_TOPVIEW_H_
+#ifndef ZOOMEDIT_VIEW_TOPVIEW_H_
+#define ZOOMEDIT_VIEW_TOPVIEW_H_
#include "View.h"
@@ -64,4 +64,4 @@ class TopView : public View {
}
}
-#endif /*ZOOMEDIT_TOPVIEW_H_*/
+#endif /*ZOOMEDIT_VIEW_TOPVIEW_H_*/
diff --git a/src/View/View.h b/src/View/View.h
index bb52032..cd4d5f5 100644
--- a/src/View/View.h
+++ b/src/View/View.h
@@ -17,8 +17,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef ZOOMEDIT_VIEW_H_
-#define ZOOMEDIT_VIEW_H_
+#ifndef ZOOMEDIT_VIEW_VIEW_H_
+#define ZOOMEDIT_VIEW_VIEW_H_
namespace ZoomEdit {
@@ -39,4 +39,4 @@ class View {
}
}
-#endif /*ZOOMEDIT_RENDERER_H_*/
+#endif /*ZOOMEDIT_VIEW_VIEW_H_*/
diff --git a/zoomedit.glade b/zoomedit.glade
index 8efd02b..0edfb2e 100644
--- a/zoomedit.glade
+++ b/zoomedit.glade
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.0 on Tue Apr 8 21:03:00 2008 -->
+<!--Generated with glade3 3.4.0 on Wed Apr 16 11:06:45 2008 -->
<glade-interface>
<widget class="GtkWindow" id="WindowMain">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -201,47 +201,12 @@
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
- <widget class="GtkTable" id="tableDrawer">
+ <widget class="GtkDrawingArea" id="RenderArea">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <widget class="GtkDrawingArea" id="RenderArea">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- </widget>
- </child>
- <child>
- <widget class="GtkVScrollbar" id="Vscrollbar">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="adjustment">0 0 100 1 10 10</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="x_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkHScrollbar" id="Hscrollbar">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="adjustment">0 0 100 1 10 10</property>
- </widget>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options"></property>
- </packing>
- </child>
</widget>
<packing>
- <property name="resize">False</property>
+ <property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>