organize palette 2
This commit is contained in:
parent
c382b8addd
commit
48c6711cad
3 changed files with 34 additions and 2 deletions
|
@ -88,6 +88,9 @@ DVAPI void renamePalettePage(TPaletteHandle *paletteHandle, int pageIndex,
|
|||
DVAPI void renamePaletteStyle(TPaletteHandle *paletteHandle,
|
||||
const std::wstring &newName);
|
||||
|
||||
/* called in ColorModelViewer::pick() - move selected style to the first page */
|
||||
DVAPI void organizePaletteStyle(TPaletteHandle *paletteHandle, int styleId);
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -308,10 +308,16 @@ void ColorModelViewer::pick(const QPoint &p) {
|
|||
}
|
||||
|
||||
/*
|
||||
if the Style Picker too is current and "organize palette" is activated,
|
||||
if the Style Picker tool is current and "organize palette" is activated,
|
||||
then move the picked style to the first page of the palette.
|
||||
*/
|
||||
//TODO: write organize palette operation here (maybe implement in PaletteCmd)
|
||||
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
|
||||
if (tool->getName() == "T_StylePicker"){
|
||||
StylePickerTool* spTool = dynamic_cast<StylePickerTool*>(tool);
|
||||
if (spTool && spTool->isOrganizePaletteActive()){
|
||||
PaletteCmd::organizePaletteStyle(ph, styleIndex);
|
||||
}
|
||||
}
|
||||
|
||||
ph->setStyleIndex(styleIndex);
|
||||
}
|
||||
|
|
|
@ -1168,3 +1168,26 @@ void PaletteCmd::renamePaletteStyle(TPaletteHandle *paletteHandle,
|
|||
paletteHandle->notifyColorStyleChanged(false);
|
||||
TUndoManager::manager()->add(undo);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// organizePaletteStyle
|
||||
// called in ColorModelViewer::pick() - move selected style to the first page
|
||||
//-----------------------------------------------------------------------------
|
||||
void PaletteCmd::organizePaletteStyle(TPaletteHandle *paletteHandle, int styleId){
|
||||
if (!paletteHandle) return;
|
||||
TPalette *palette = paletteHandle->getPalette();
|
||||
if (!palette) return;
|
||||
// if the style is already in the first page, then do nothing
|
||||
TPalette::Page* page = palette->getStylePage(styleId);
|
||||
if (!page || page->getIndex() == 0) return;
|
||||
|
||||
int indexInPage = page->search(styleId);
|
||||
|
||||
/*
|
||||
just call arrangeStyles as tentative implementation.
|
||||
TODO: store the picked position into the style name somehow
|
||||
*/
|
||||
arrangeStyles(paletteHandle, 0, palette->getPage(0)->getStyleCount(),
|
||||
page->getIndex(), { indexInPage });
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue