# HG changeset patch # User Santeri Piippo # Date 1393196397 -7200 # Node ID 2f4dcc323a8581240e6080eac694c3c75cf254ce # Parent 77d7c22ec9f31db336c688ffa83559c6c2cd9e83# Parent 220e79cd6837bc0828f855f08785b6f3ed8d0273 Merge ../ldforge into gl Conflicts: src/Document.h diff -r 77d7c22ec9f3 -r 2f4dcc323a85 src/Document.cc --- a/src/Document.cc Sun Feb 23 20:13:32 2014 +0200 +++ b/src/Document.cc Mon Feb 24 00:59:57 2014 +0200 @@ -126,7 +126,7 @@ { setImplicit (true); setSavePosition (-1); - setListItem (null); + setTabIndex (-1); setHistory (new History); m_History->setDocument (this); } diff -r 77d7c22ec9f3 -r 2f4dcc323a85 src/Document.h --- a/src/Document.h Sun Feb 23 20:13:32 2014 +0200 +++ b/src/Document.h Mon Feb 24 00:59:57 2014 +0200 @@ -58,9 +58,9 @@ { properties: Q_OBJECT - PROPERTY (private, LDObjectList, Objects, LIST_OPS, STOCK_WRITE) + PROPERTY (private, LDObjectList, Objects, LIST_OPS, STOCK_WRITE) PROPERTY (private, History*, History, NO_OPS, STOCK_WRITE) - PROPERTY (private, LDObjectList, Vertices, LIST_OPS, STOCK_WRITE) + PROPERTY (private, LDObjectList, Vertices, LIST_OPS, STOCK_WRITE) PROPERTY (private, QList, References, LIST_OPS, STOCK_WRITE) PROPERTY (public, QString, Name, STR_OPS, STOCK_WRITE) PROPERTY (public, QString, FullPath, STR_OPS, STOCK_WRITE) @@ -68,7 +68,7 @@ PROPERTY (public, bool, Implicit, BOOL_OPS, STOCK_WRITE) PROPERTY (public, QList, PolygonData, NO_OPS, STOCK_WRITE) PROPERTY (public, long, SavePosition, NUM_OPS, STOCK_WRITE) - PROPERTY (public, QListWidgetItem*, ListItem, NO_OPS, STOCK_WRITE) + PROPERTY (public, int, TabIndex, NO_OPS, STOCK_WRITE) public: LDDocument(); diff -r 77d7c22ec9f3 -r 2f4dcc323a85 src/GLCompiler.cc --- a/src/GLCompiler.cc Sun Feb 23 20:13:32 2014 +0200 +++ b/src/GLCompiler.cc Mon Feb 24 00:59:57 2014 +0200 @@ -257,6 +257,7 @@ // void GLCompiler::compileObject (LDObject* obj) { + log ("compile #%1\n", obj->getID() ); ObjectVBOInfo info; dropObject (obj); compileSubObject (obj, obj, &info); diff -r 77d7c22ec9f3 -r 2f4dcc323a85 src/GLRenderer.cc --- a/src/GLRenderer.cc Sun Feb 23 20:13:32 2014 +0200 +++ b/src/GLRenderer.cc Mon Feb 24 00:59:57 2014 +0200 @@ -411,16 +411,6 @@ glEnableClientState (GL_VERTEX_ARRAY); glEnableClientState (GL_COLOR_ARRAY); - if (gl_axes) - { - glBindBuffer (GL_ARRAY_BUFFER, g_GLAxes_VBO); - glVertexPointer (3, GL_FLOAT, 0, NULL); - glBindBuffer (GL_ARRAY_BUFFER, g_GLAxes_VBO); - glColorPointer (3, GL_FLOAT, 0, NULL); - glDrawArrays (GL_LINES, 0, 6); - checkGLError(); - } - if (isPicking()) { drawVBOs (vboTriangles, vboPickColors, GL_TRIANGLES); @@ -449,6 +439,16 @@ drawVBOs (vboLines, vboNormalColors, GL_LINES); drawVBOs (vboCondLines, vboNormalColors, GL_LINES); + + if (gl_axes) + { + glBindBuffer (GL_ARRAY_BUFFER, g_GLAxes_VBO); + glVertexPointer (3, GL_FLOAT, 0, NULL); + glBindBuffer (GL_ARRAY_BUFFER, g_GLAxes_VBO); + glColorPointer (3, GL_FLOAT, 0, NULL); + glDrawArrays (GL_LINES, 0, 6); + checkGLError(); + } } glPopMatrix(); diff -r 77d7c22ec9f3 -r 2f4dcc323a85 src/MainWindow.cc --- a/src/MainWindow.cc Sun Feb 23 20:13:32 2014 +0200 +++ b/src/MainWindow.cc Mon Feb 24 00:59:57 2014 +0200 @@ -67,10 +67,12 @@ MainWindow::MainWindow() { g_win = this; - m_renderer = new GLRenderer; - ui = new Ui_LDForgeUI; ui->setupUi (this); + m_updatingTabs = false; + m_renderer = new GLRenderer (this); + m_tabs = new QTabBar; + ui->verticalLayout->insertWidget (0, m_tabs); // Stuff the renderer into its frame QVBoxLayout* rendererLayout = new QVBoxLayout (ui->rendererFrame); @@ -78,7 +80,7 @@ connect (ui->objectList, SIGNAL (itemSelectionChanged()), this, SLOT (slot_selectionChanged())); connect (ui->objectList, SIGNAL (itemDoubleClicked (QListWidgetItem*)), this, SLOT (slot_editObject (QListWidgetItem*))); - connect (ui->fileList, SIGNAL (currentItemChanged (QListWidgetItem*, QListWidgetItem*)), this, SLOT (changeCurrentFile())); + connect (m_tabs, SIGNAL (currentChanged(int)), this, SLOT (changeCurrentFile())); // Init message log manager m_msglog = new MessageManager; @@ -892,7 +894,10 @@ void MainWindow::updateDocumentList() { - ui->fileList->clear(); + m_updatingTabs = true; + + while (m_tabs->count() > 0) + m_tabs->removeTab (0); for (LDDocument* f : g_loadedFiles) { @@ -900,18 +905,21 @@ if (f->isImplicit() && !gui_implicitfiles) continue; - // Add an item to the list for this file and store a pointer to it in - // the file, so we can find files by the list item. - ui->fileList->addItem (""); - QListWidgetItem* item = ui->fileList->item (ui->fileList->count() - 1); - f->setListItem (item); + // Add an item to the list for this file and store the tab index + // in the document so we can find documents by tab index. + f->setTabIndex (m_tabs->addTab ("")); updateDocumentListItem (f); } + + m_updatingTabs = false; } void MainWindow::updateDocumentListItem (LDDocument* f) { - if (f->getListItem() == null) + bool oldUpdatingTabs = m_updatingTabs; + m_updatingTabs = true; + + if (f->getTabIndex() == -1) { // We don't have a list item for this file, so the list either doesn't // exist yet or is out of date. Build the list now. @@ -922,17 +930,13 @@ // If this is the current file, it also needs to be the selected item on // the list. if (f == getCurrentDocument()) - ui->fileList->setCurrentItem (f->getListItem()); + m_tabs->setCurrentIndex (f->getTabIndex()); + + m_tabs->setTabText (f->getTabIndex(), f->getDisplayName()); - // If we list implicit files, draw them with a shade of gray to make them - // distinct. - if (f->isImplicit()) - f->getListItem()->setForeground (QColor (96, 96, 96)); - - f->getListItem()->setText (f->getDisplayName()); - - // If the Document.has unsaved changes, draw a little icon next to it to mark that. - f->getListItem()->setIcon (f->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); + // If the document.has unsaved changes, draw a little icon next to it to mark that. + m_tabs->setTabIcon (f->getTabIndex(), f->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); + m_updatingTabs = oldUpdatingTabs; } // ============================================================================= @@ -940,13 +944,16 @@ // which file was picked and change to it. void MainWindow::changeCurrentFile() { + if (m_updatingTabs) + return; + LDDocument* f = null; - QListWidgetItem* item = ui->fileList->currentItem(); + int tabIndex = m_tabs->currentIndex(); // Find the file pointer of the item that was selected. for (LDDocument* it : g_loadedFiles) { - if (it->getListItem() == item) + if (it->getTabIndex() == tabIndex) { f = it; break; @@ -955,7 +962,7 @@ // If we picked the same file we're currently on, we don't need to do // anything. - if (!f || f == getCurrentDocument()) + if (f == null || f == getCurrentDocument()) return; LDDocument::setCurrent (f); diff -r 77d7c22ec9f3 -r 2f4dcc323a85 src/MainWindow.h --- a/src/MainWindow.h Sun Feb 23 20:13:32 2014 +0200 +++ b/src/MainWindow.h Mon Feb 24 00:59:57 2014 +0200 @@ -235,13 +235,15 @@ void closeEvent (QCloseEvent* ev); private: - GLRenderer* m_renderer; - LDObjectList m_sel; - QList m_quickColors; - QList m_colorButtons; - QList m_recentFiles; - MessageManager* m_msglog; - Ui_LDForgeUI* ui; + GLRenderer* m_renderer; + LDObjectList m_sel; + QList m_quickColors; + QList m_colorButtons; + QList m_recentFiles; + MessageManager* m_msglog; + Ui_LDForgeUI* ui; + QTabBar* m_tabs; + bool m_updatingTabs; private slots: void slot_selectionChanged(); diff -r 77d7c22ec9f3 -r 2f4dcc323a85 ui/ldforge.ui --- a/ui/ldforge.ui Sun Feb 23 20:13:32 2014 +0200 +++ b/ui/ldforge.ui Mon Feb 24 00:59:57 2014 +0200 @@ -20,17 +20,7 @@ - - - - - - 0 - 0 - - - - +