From 23d6ae55fd15368ea8c012dffdbba230995f9573 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Mon, 6 Jun 2016 01:07:54 +0200 Subject: [PATCH] Solve the overlap in Layers&Go extensions entries. * Bug: In Hurricane::PaletteWidget, flush the normal widgets before reading the position of the Extension entry (from GridBuffer). --- hurricane/src/viewer/CellViewer.cpp | 4 +- hurricane/src/viewer/ControllerWidget.cpp | 6 +- .../src/viewer/PaletteExtensionGoItem.cpp | 8 +++ hurricane/src/viewer/PaletteWidget.cpp | 67 +++++++++++++------ .../hurricane/viewer/PaletteExtensionGoItem.h | 1 + 5 files changed, 57 insertions(+), 29 deletions(-) diff --git a/hurricane/src/viewer/CellViewer.cpp b/hurricane/src/viewer/CellViewer.cpp index 7bfb12c5..0b02c5eb 100644 --- a/hurricane/src/viewer/CellViewer.cpp +++ b/hurricane/src/viewer/CellViewer.cpp @@ -62,12 +62,10 @@ namespace Hurricane { // ------------------------------------------------------------------- // Class : "CellObserver". -// void CellObserver::notify ( unsigned int flags ) void CellViewer::notify ( CellViewer* viewer, unsigned int flags ) { - cdebug.log(111) << "CellViewer::notify() " << viewer << endl; + cdebug.log(19) << "CellViewer::notify() " << viewer << endl; - //CellViewer* viewer = getOwner(); switch ( flags & (Cell::Flags::CellAboutToChange |Cell::Flags::CellChanged |Cell::Flags::CellDestroyed) ) { diff --git a/hurricane/src/viewer/ControllerWidget.cpp b/hurricane/src/viewer/ControllerWidget.cpp index 1a46733c..0682a822 100644 --- a/hurricane/src/viewer/ControllerWidget.cpp +++ b/hurricane/src/viewer/ControllerWidget.cpp @@ -605,7 +605,7 @@ namespace Hurricane { Graphics::getGraphics()->addObserver( &_observer ); - resize( Graphics::toHighDpi(600), Graphics::toHighDpi(500) ); + resize( Graphics::toHighDpi(620), Graphics::toHighDpi(500) ); } @@ -661,11 +661,9 @@ namespace Hurricane { // ------------------------------------------------------------------- // Class : "ControllerWidget::GraphicsObserver". -//void ControllerWidget::GraphicsObserver::notify ( unsigned int flags ) void ControllerWidget::notify ( ControllerWidget* controller, unsigned int flags ) { - cdebug.log(111) << "ControllerWidget::notify()" << endl; - //ControllerWidget* controller = getOwner(); + cdebug.log(19) << "ControllerWidget::notify()" << endl; if (flags & Graphics::ChangedDisplayStyles) { controller->graphicsUpdated(); } diff --git a/hurricane/src/viewer/PaletteExtensionGoItem.cpp b/hurricane/src/viewer/PaletteExtensionGoItem.cpp index b1d69f04..19f64736 100644 --- a/hurricane/src/viewer/PaletteExtensionGoItem.cpp +++ b/hurricane/src/viewer/PaletteExtensionGoItem.cpp @@ -35,6 +35,8 @@ namespace Hurricane { { PaletteExtensionGoItem* item = new PaletteExtensionGoItem ( name ); item->_postCreate (); + + cdebug.log(19) << "PaletteExtensionGoItem::create() - " << name << endl; return item; } @@ -66,6 +68,12 @@ namespace Hurricane { } + PaletteExtensionGoItem::~PaletteExtensionGoItem () + { + cdebug.log(19) << "PaletteExtensionGoItem::~PaletteExtensionGoItem() - " << _name << endl; + } + + const Name& PaletteExtensionGoItem::getName () const { return _name; diff --git a/hurricane/src/viewer/PaletteWidget.cpp b/hurricane/src/viewer/PaletteWidget.cpp index 2091161f..1f52b19a 100644 --- a/hurricane/src/viewer/PaletteWidget.cpp +++ b/hurricane/src/viewer/PaletteWidget.cpp @@ -43,15 +43,16 @@ namespace { class GridBuffer { public: - GridBuffer ( QGridLayout*, size_t rowMax, size_t startRow=0, size_t startColumn=0 ); - inline int getRow () const; - inline int getColumn () const; - inline int getCurrentRow () const; - void addSection ( QWidget*, Qt::Alignment align=0 ); - void addWidget ( QWidget*, Qt::Alignment align=0 ); - void newColumn (); - void flushWidgets (); - inline bool columnOverload () const; + GridBuffer ( QGridLayout*, size_t rowMax, size_t startRow=0, size_t startColumn=0 ); + ~GridBuffer (); + inline int getRow () const; + inline int getColumn () const; + inline int getCurrentRow () const; + void addSection ( QWidget*, Qt::Alignment align=0 ); + void addWidget ( QWidget*, Qt::Alignment align=0 ); + void newColumn (); + void flushWidgets (); + inline bool columnOverload () const; protected: QGridLayout* _grid; size_t _rowMax; @@ -66,37 +67,54 @@ namespace { , size_t maxRow , size_t startRow , size_t startColumn ) - : _grid (grid) - , _rowMax (maxRow) - , _row (startRow) - , _column (startColumn) - , _widgets () - , _aligns () - { } + : _grid (grid) + , _rowMax (maxRow) + , _row (startRow) + , _column (startColumn) + , _widgets() + , _aligns () + { + cdebug.log(19) << "GridBuffer::GridBuffer() column:" << _column << " row:" << _row << endl; + } + + + GridBuffer::~GridBuffer () + { + cdebug.log(19) << "GridBuffer::~GridBuffer() column:" << _column << " row:" << _row << endl; + } inline int GridBuffer::getRow () const { return _row; } inline int GridBuffer::getColumn () const { return _column; } inline int GridBuffer::getCurrentRow () const { return _widgets.size() + _row; } - inline bool GridBuffer::columnOverload () const { return getCurrentRow() > (int)_rowMax; } + inline bool GridBuffer::columnOverload () const { return getCurrentRow() >= (int)_rowMax; } void GridBuffer::flushWidgets () { + cdebug.log(19,1) << "GridBuffer::flushWidgets()" << endl; + if ( columnOverload() ) { _column++; _row = 0; } - for ( size_t i=0 ; i < _widgets.size() ; ++i ) + for ( size_t i=0 ; i < _widgets.size() ; ++i ) { + cdebug.log(19) << "add Widget to grid @(" << _column << "," << _row << ")" << endl; + _grid->addWidget ( _widgets[i], _row++, _column, _aligns[i] ); + } _widgets.clear (); _aligns.clear (); + + cdebug.tabw(19,-1); } void GridBuffer::newColumn () { + cdebug.log(19) << "GridBuffer::newColumn()" << endl; + if ( columnOverload() ) return; flushWidgets (); @@ -292,21 +310,22 @@ namespace Hurricane { } } - if ( _columnHeight < numeric_limits::max() ) - gridBuffer.newColumn (); - else - gridBuffer.flushWidgets (); + gridBuffer.flushWidgets (); _extensionRow = gridBuffer.getRow(); _extensionColumn = gridBuffer.getColumn(); _extensionGroup = _createGroupItem ( "Extensions" ); gridBuffer.addSection ( _extensionGroup, Qt::AlignHCenter ); gridBuffer.flushWidgets (); + + cdebug.log(19) << " column:" << _extensionColumn << " row:" << _extensionRow << endl; } void PaletteWidget::updateExtensions ( Cell* cell ) { + cdebug.log(19,1) << "PaletteWidget::updateExtensions()" << endl; + if (_extensionGroup) { _grid->removeWidget ( _extensionGroup ); //_extensionGroup->deleteLater (); @@ -322,6 +341,8 @@ namespace Hurricane { _extensionGoItems.clear (); } + cdebug.log(19) << " column:" << _extensionColumn << " row:" << _extensionRow << endl; + GridBuffer gridBuffer ( _grid, _columnHeight, _extensionRow, _extensionColumn ); _extensionGroup = _createGroupItem ( "Extensions" ); gridBuffer.addSection ( _extensionGroup, Qt::AlignHCenter ); @@ -334,6 +355,8 @@ namespace Hurricane { } } gridBuffer.flushWidgets (); + + cdebug.tabw(19,-1); } diff --git a/hurricane/src/viewer/hurricane/viewer/PaletteExtensionGoItem.h b/hurricane/src/viewer/hurricane/viewer/PaletteExtensionGoItem.h index 061e6cd6..4012340b 100644 --- a/hurricane/src/viewer/hurricane/viewer/PaletteExtensionGoItem.h +++ b/hurricane/src/viewer/hurricane/viewer/PaletteExtensionGoItem.h @@ -47,6 +47,7 @@ namespace Hurricane { protected: PaletteExtensionGoItem ( const Name& ); PaletteExtensionGoItem ( const PaletteExtensionGoItem& ); + virtual ~PaletteExtensionGoItem (); PaletteExtensionGoItem& operator= ( const PaletteExtensionGoItem& ); virtual void _postCreate (); };