Mon, 24 Feb 2014 00:59:57 +0200
Merge ../ldforge into gl
Conflicts:
src/Document.h
src/Document.cc | file | annotate | diff | comparison | revisions | |
src/Document.h | file | annotate | diff | comparison | revisions | |
src/GLCompiler.cc | file | annotate | diff | comparison | revisions | |
src/GLRenderer.cc | file | annotate | diff | comparison | revisions |
--- 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); }
--- 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<LDDocumentPointer*>, 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<LDPolygon>, 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();
--- 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);
--- 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();
--- 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);
--- 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<LDQuickColor> m_quickColors; - QList<QToolButton*> m_colorButtons; - QList<QAction*> m_recentFiles; - MessageManager* m_msglog; - Ui_LDForgeUI* ui; + GLRenderer* m_renderer; + LDObjectList m_sel; + QList<LDQuickColor> m_quickColors; + QList<QToolButton*> m_colorButtons; + QList<QAction*> m_recentFiles; + MessageManager* m_msglog; + Ui_LDForgeUI* ui; + QTabBar* m_tabs; + bool m_updatingTabs; private slots: void slot_selectionChanged();
--- 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 @@ <widget class="QWidget" name="centralwidget"> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,4,2"> - <item> - <widget class="QListWidget" name="fileList"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> + <layout class="QHBoxLayout" name="horizontalLayout" stretch="3,1"> <item> <widget class="QFrame" name="rendererFrame"> <property name="sizePolicy">