summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-08-14 05:36:12 +0200
committerTreeki <treeki@gmail.com>2012-08-14 05:36:12 +0200
commita2f7c5a2b6e1182bdf40c7c51b9af8695b4da302 (patch)
treec238da11cc55a16bab19a9caee81e36595816499
parent6c2f62d82a12a841f3e90c2cc7a483c8db17e69c (diff)
downloadLayoutStudio-a2f7c5a2b6e1182bdf40c7c51b9af8695b4da302.tar.gz
LayoutStudio-a2f7c5a2b6e1182bdf40c7c51b9af8695b4da302.zip
LGLwidget can now be resized to show stuff off-screen, shows boundary lines
-rw-r--r--layoutgl/widget.cpp48
1 files changed, 46 insertions, 2 deletions
diff --git a/layoutgl/widget.cpp b/layoutgl/widget.cpp
index 3ae402b..209b7c9 100644
--- a/layoutgl/widget.cpp
+++ b/layoutgl/widget.cpp
@@ -9,7 +9,7 @@ void LGLWidget::setLayout(LYTLayout *layout) {
// TODO: cleanup stuff for previous layout
m_layout = layout;
- setFixedSize(layout->width, layout->height);
+ resize(layout->width + 64, layout->height + 64);
}
@@ -33,7 +33,10 @@ void LGLWidget::resizeGL(int w, int h) {
glViewport(0, 0, (GLint)w, (GLint)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(-304, 304, -228, 228, -100, 100);
+
+ float halfW = w / 2.0f, halfH = h / 2.0f;
+
+ glOrtho(-halfW, halfW, -halfH, halfH, -100, 100);
glMatrixMode(GL_MODELVIEW);
}
@@ -46,6 +49,47 @@ void LGLWidget::paintGL() {
glLoadIdentity();
renderPane(m_layout->rootPane);
+
+ glColor3ub(255, 0, 0);
+ float halfW = m_layout->width / 2.0f;
+ float halfH = m_layout->height / 2.0f;
+
+ const float lineExtension = 12.0f;
+ glBegin(GL_QUADS);
+
+ // top line
+ glVertex2f(-halfW - 1.0f - lineExtension, halfH + 1.0f);
+ glVertex2f(halfW + 1.0f + lineExtension, halfH + 1.0f);
+ glVertex2f(halfW + 1.0f + lineExtension, halfH);
+ glVertex2f(-halfW - 1.0f - lineExtension, halfH);
+ // bottom line
+ glVertex2f(-halfW - 1.0f - lineExtension, -halfH);
+ glVertex2f(halfW + 1.0f + lineExtension, -halfH);
+ glVertex2f(halfW + 1.0f + lineExtension, -halfH - 1.0f);
+ glVertex2f(-halfW - 1.0f - lineExtension, -halfH - 1.0f);
+ // left line
+ glVertex2f(-halfW - 1.0f, halfH + 1.0f + lineExtension);
+ glVertex2f(-halfW, halfH + 1.0f + lineExtension);
+ glVertex2f(-halfW, -halfH - 1.0f - lineExtension);
+ glVertex2f(-halfW - 1.0f, -halfH - 1.0f - lineExtension);
+ // right line
+ glVertex2f(halfW, halfH + 1.0f + lineExtension);
+ glVertex2f(halfW + 1.0f, halfH + 1.0f + lineExtension);
+ glVertex2f(halfW + 1.0f, -halfH - 1.0f - lineExtension);
+ glVertex2f(halfW, -halfH - 1.0f - lineExtension);
+
+ // centre: horizontal
+ glVertex2f(-lineExtension, 0.5f);
+ glVertex2f(lineExtension, 0.5f);
+ glVertex2f(lineExtension, -0.5f);
+ glVertex2f(-lineExtension, -0.5f);
+ // centre: vertical
+ glVertex2f(-0.5f, lineExtension);
+ glVertex2f(0.5f, lineExtension);
+ glVertex2f(0.5f, -lineExtension);
+ glVertex2f(-0.5f, -lineExtension);
+
+ glEnd();
}
void LGLWidget::renderPane(const LYTPane *pane) {