Thu, 16 May 2013 02:26:50 +0300
Better support for dark backgrounds..
src/gldraw.cpp | file | annotate | diff | comparison | revisions | |
src/gldraw.h | file | annotate | diff | comparison | revisions |
--- a/src/gldraw.cpp Thu May 16 00:43:43 2013 +0300 +++ b/src/gldraw.cpp Thu May 16 02:26:50 2013 +0300 @@ -124,9 +124,12 @@ } // ============================================================================= -GLRenderer::~GLRenderer() { +GLRenderer::~GLRenderer () { for (CameraIcon& info : g_CameraIcons) delete info.img; + + for (int i = 0; i < 6; ++i) + delete g_overlays[i].img; } // ============================================================================= @@ -191,9 +194,10 @@ if (!col.isValid ()) return; - m_darkbg = luma (col) < 80; + col.setAlpha (255); - col.setAlpha (255); + m_darkbg = luma (col) < 80; + m_bgcolor = col; qglClearColor (col); } @@ -223,7 +227,7 @@ g = (i / 256) % 256, b = i % 256; - qglColor (QColor (r, g, b, 255)); + qglColor (QColor (r, g, b)); return; } @@ -244,7 +248,7 @@ } if (obj->color == edgecolor) { - qcol = Qt::black; + qcol = luma (m_bgcolor) < 40 ? QColor (64, 64, 64) : Qt::black; color* col; if (!gl_blackedges && obj->parent != null && (col = getColor (obj->parent->color)) != null) @@ -317,7 +321,7 @@ glViewport (0, 0, w, h); glMatrixMode (GL_PROJECTION); glLoadIdentity (); - gluPerspective (45.0f, (double)w / (double)h, 1.0f, 10000.0f); + gluPerspective (45.0f, (double) w / (double) h, 1.0f, 10000.0f); glMatrixMode (GL_MODELVIEW); } @@ -538,7 +542,9 @@ } } - paint.setPen (m_thinBorderPen); + QPen pen = m_thinBorderPen; + pen.setWidth (1); + paint.setPen (pen); paint.setBrush (QColor (128, 192, 0)); // Draw vertex blips @@ -548,7 +554,9 @@ blipsize, blipsize); } - paint.setPen (m_thickBorderPen); + pen.setWidth (2); + pen.setColor (luma (m_bgcolor) < 40 ? Qt::white : Qt::black); + paint.setPen (pen); paint.setBrush (QColor (128, 192, 0, 128)); paint.drawPolygon (poly, numverts); @@ -579,7 +587,7 @@ str label; label.format ("%s Camera", g_CameraNames[camera ()]); - paint.setBrush (Qt::black); + paint.setPen (m_darkbg ? Qt::white : Qt::black); paint.drawText (QPoint (margin, margin + metrics.ascent ()), label); }
--- a/src/gldraw.h Thu May 16 00:43:43 2013 +0300 +++ b/src/gldraw.h Thu May 16 02:26:50 2013 +0300 @@ -101,6 +101,7 @@ std::vector<vertex> m_drawedVerts; EditMode m_editmode; bool m_rectdraw; + QColor m_bgcolor; void calcCameraIcons (); // Compute geometry for camera icons void clampAngle (double& angle) const; // Clamps an angle to [0, 360]