Fix moving styles in palette
This commit is contained in:
parent
69d48e90d5
commit
75e23d520d
3 changed files with 11 additions and 8 deletions
|
@ -202,15 +202,16 @@ void TPalette::Page::insertStyle(int indexInPage, TPixel32 color) {
|
|||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void TPalette::Page::removeStyle(int indexInPage) {
|
||||
void TPalette::Page::removeStyle(int indexInPage, bool flagOnly) {
|
||||
if (indexInPage < 0 || indexInPage >= getStyleCount()) return;
|
||||
assert(m_palette);
|
||||
int styleId = getStyleId(indexInPage);
|
||||
assert(0 <= styleId && styleId < m_palette->getStyleCount());
|
||||
assert(m_palette->m_styles[styleId].first == this);
|
||||
m_palette->m_styles[styleId].first = 0;
|
||||
m_palette->m_styles[styleId].second =
|
||||
TColorStyleP(new TSolidColorStyle(TPixel32::Black));
|
||||
if (!flagOnly)
|
||||
m_palette->m_styles[styleId].second =
|
||||
TColorStyleP(new TSolidColorStyle(TPixel32::Black));
|
||||
m_styleIds.erase(m_styleIds.begin() + indexInPage);
|
||||
}
|
||||
|
||||
|
|
|
@ -163,8 +163,10 @@ public:
|
|||
//! its
|
||||
//! id at the specified position in the page.
|
||||
|
||||
void removeStyle(int indexInPage); //!< Removes the style at the specified
|
||||
//! position from this page.
|
||||
void removeStyle(
|
||||
int indexInPage,
|
||||
bool flagOnly = false); //!< Removes the style at the specified
|
||||
//! position from this page.
|
||||
int search(int styleId)
|
||||
const; //!< Returns the page position of the specified style id,
|
||||
//! or \p -1 if it cannot be found on the page.
|
||||
|
|
|
@ -212,7 +212,7 @@ public:
|
|||
int k;
|
||||
for (k = 0; k < count; k++) {
|
||||
styles.push_back(dstPage->getStyleId(h));
|
||||
dstPage->removeStyle(h);
|
||||
dstPage->removeStyle(h, true);
|
||||
}
|
||||
k = 0;
|
||||
for (i = m_srcIndicesInPage.begin(); i != m_srcIndicesInPage.end();
|
||||
|
@ -235,7 +235,7 @@ public:
|
|||
int index = *i;
|
||||
if (m_dstPageIndex == m_srcPageIndex && index < k) k--;
|
||||
styles.push_back(srcPage->getStyleId(index));
|
||||
srcPage->removeStyle(index);
|
||||
srcPage->removeStyle(index, true);
|
||||
}
|
||||
for (j = styles.begin(); j != styles.end(); ++j)
|
||||
dstPage->insertStyle(k, *j);
|
||||
|
@ -300,7 +300,7 @@ public:
|
|||
assert(page);
|
||||
int indexInPage = page->search(m_styleId);
|
||||
assert(indexInPage >= 0);
|
||||
page->removeStyle(indexInPage);
|
||||
page->removeStyle(indexInPage, true);
|
||||
m_paletteHandle->notifyPaletteChanged();
|
||||
}
|
||||
void redo() const override {
|
||||
|
|
Loading…
Reference in a new issue