OpenToonz - An open-source full-featured 2D animation creation software
C
organize palette 1
shun_iwasawa06bcc2ea0a3e
diff --git a/toonz/sources/include/tools/cursors.h b/toonz/sources/include/tools/cursors.hindex a912ffaf5..16eec827c 100644--- a/toonz/sources/include/tools/cursors.h+++ b/toonz/sources/include/tools/cursors.h@@ -66,6 +66,8 @@ enum {PickerCursorWhite,PickerCursorWhiteLine,PickerCursorWhiteArea,+ PickerCursorOrganize,+ PickerCursorWhiteOrganize,PickerRGB,PickerRGBWhite,diff --git a/toonz/sources/tnztools/CMakeLists.txt b/toonz/sources/tnztools/CMakeLists.txtindex ae100a992..8e036db4a 100644--- a/toonz/sources/tnztools/CMakeLists.txt+++ b/toonz/sources/tnztools/CMakeLists.txt@@ -10,7 +10,8 @@ set(MOC_HEADERS../include/tools/tooloptions.h../include/tools/screenpicker.hrgbpickertool.h- rulertool.h)+ rulertool.h+ stylepickertool.h)set(HEADERS ${MOC_HEADERS}autofill.hdiff --git a/toonz/sources/tnztools/Resources/picker_style_organize.png b/toonz/sources/tnztools/Resources/picker_style_organize.pngnew file mode 100644index 000000000..c502b37c6Binary files /dev/null and b/toonz/sources/tnztools/Resources/picker_style_organize.png differdiff --git a/toonz/sources/tnztools/Resources/picker_style_white_organize.png b/toonz/sources/tnztools/Resources/picker_style_white_organize.pngnew file mode 100644index 000000000..b90546674Binary files /dev/null and b/toonz/sources/tnztools/Resources/picker_style_white_organize.png differdiff --git a/toonz/sources/tnztools/cursormanager.cpp b/toonz/sources/tnztools/cursormanager.cppindex 126610fe5..849ce8054 100644--- a/toonz/sources/tnztools/cursormanager.cpp+++ b/toonz/sources/tnztools/cursormanager.cpp@@ -73,6 +73,8 @@ const struct {{ToolCursor::PickerCursorWhiteLine, "picker_style_white_line", 7, 22},{ToolCursor::PickerCursorWhiteArea, "picker_style_white_area", 7, 22},{ToolCursor::PickerCursorWhite, "picker_style_white", 7, 22},+ {ToolCursor::PickerCursorOrganize, "picker_style_organize", 7, 22},+ {ToolCursor::PickerCursorWhiteOrganize, "picker_style_white_organize", 7, 22},{ToolCursor::PickerRGB, "picker_rgb", 7, 22},{ToolCursor::PickerRGBWhite, "picker_rgb_white", 7, 22},{ToolCursor::FillCursorF, "fill_f", 6, 23},diff --git a/toonz/sources/tnztools/stylepickertool.cpp b/toonz/sources/tnztools/stylepickertool.cppindex e73625c58..459cfec89 100644--- a/toonz/sources/tnztools/stylepickertool.cpp+++ b/toonz/sources/tnztools/stylepickertool.cpp@@ -1,238 +1,311 @@+#include "stylepickertool.h"-+//TnzTools includes#include "tools/tool.h"#include "tools/cursors.h"#include "tools/stylepicker.h"-#include "toonz/txshsimplelevel.h"-#include "toonz/txshlevelhandle.h"+#include "tools/toolhandle.h"-#include "drawutil.h"-#include "tvectorimage.h"-#include "ttoonzimage.h"-#include "tundo.h"+//TnzQt includes+#include "toonzqt/tselectionhandle.h"+#include "toonzqt/styleselection.h"+//TnzLib includes+#include "toonz/txshsimplelevel.h"+#include "toonz/txshlevelhandle.h"#include "toonz/tpalettehandle.h"-#include "toonz/stage2.h"-#include "tproperty.h"-#include "toonzqt/tselectionhandle.h"-#include "toonzqt/styleselection.h"-#include "tools/toolhandle.h"#include "toonz/tframehandle.h"#include "toonz/txsheethandle.h"#include "toonz/preferences.h"#include "toonz/tcolumnhandle.h"#include "toonz/dpiscale.h"#include "toonz/palettecontroller.h"+#include "toonz/txshleveltypes.h"+#include "toonz/txshpalettelevel.h"++// TnzCore includes+#include "drawutil.h"+#include "tvectorimage.h"+#include "ttoonzimage.h"+#include "tundo.h"+#include "tmsgcore.h"#define LINES L"Lines"#define AREAS L"Areas"#define ALL L"Lines & Areas"-namespace {-//========================================================================// Pick Style Tool//-------------------------------------------------------------------------class StylePickerTool final : public TTool {- int m_oldStyleId, m_currentStyleId;-- TEnumProperty m_colorType;- TPropertyGroup m_prop;-- TBoolProperty m_passivePick;+StylePickerTool::StylePickerTool()+ : TTool("T_StylePicker")+ , m_currentStyleId(0)+ , m_colorType("Mode:")+ , m_passivePick("Passive Pick", false)+ , m_organizePalette("Organize Palette", false)+ , m_paletteToBeOrganized(NULL) {+ m_prop.bind(m_colorType);+ m_colorType.addValue(AREAS);+ m_colorType.addValue(LINES);+ m_colorType.addValue(ALL);+ m_colorType.setId("Mode");+ bind(TTool::CommonLevels);++ m_prop.bind(m_passivePick);+ m_passivePick.setId("PassivePick");++ m_prop.bind(m_organizePalette);+ m_organizePalette.setId("OrganizePalette");+}-public:- TPropertyGroup *getProperties(int targetType) override { return &m_prop; }- StylePickerTool()- : TTool("T_StylePicker")- , m_currentStyleId(0)- , m_colorType("Mode:")- , m_passivePick("Passive Pick", false) {- m_prop.bind(m_colorType);- m_colorType.addValue(AREAS);- m_colorType.addValue(LINES);- m_colorType.addValue(ALL);- m_colorType.setId("Mode");- bind(TTool::CommonLevels);+void StylePickerTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e) {+ m_oldStyleId = m_currentStyleId =+ getApplication()->getCurrentLevelStyleIndex();+ pick(pos, e);+}++void StylePickerTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) {+ pick(pos, e);+}- m_prop.bind(m_passivePick);- m_passivePick.setId("PassivePick");+void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e) {+ // Area = 0, Line = 1, All = 2+ int modeValue = m_colorType.getIndex();++ //------------------------------------+ // MultiLayerStylePicker+ /*---+ PickしたStyleId = 0、かつ+ Preference で MultiLayerStylePickerが有効、かつ+ Scene編集モード、かつ+ 下のカラムから拾った色がTransparentでない場合、+ → カレントLevelを移動する。+ ---*/+ if (Preferences::instance()->isMultiLayerStylePickerEnabled() &&+ getApplication()->getCurrentFrame()->isEditingScene()) {+ int superPickedColumnId = getViewer()->posToColumnIndex(+ e.m_pos, getPixelSize() * getPixelSize(), false);++ if (superPickedColumnId >= 0 /*-- 何かColumnに当たった場合 --*/+ &&+ getApplication()->getCurrentColumn()->getColumnIndex() !=+ superPickedColumnId) /*-- かつ、Current Columnでない場合 --*/+ {+ /*-- そのColumnからPickを試みる --*/+ int currentFrame = getApplication()->getCurrentFrame()->getFrame();+ TXshCell pickedCell =+ getApplication()->getCurrentXsheet()->getXsheet()->getCell(+ currentFrame, superPickedColumnId);+ TImageP pickedImage = pickedCell.getImage(false).getPointer();+ TToonzImageP picked_ti = pickedImage;+ TVectorImageP picked_vi = pickedImage;+ TXshSimpleLevel *picked_level = pickedCell.getSimpleLevel();+ if ((picked_ti || picked_vi) && picked_level) {+ TPointD tmpMousePosition =+ getColumnMatrix(superPickedColumnId).inv() *+ getViewer()->winToWorld(e.m_pos);++ TPointD tmpDpiScale =+ getCurrentDpiScale(picked_level, getCurrentFid());++ tmpMousePosition.x /= tmpDpiScale.x;+ tmpMousePosition.y /= tmpDpiScale.y;++ StylePicker superPicker(pickedImage);+ int picked_subsampling =+ picked_level->getImageSubsampling(pickedCell.getFrameId());+ int superPicked_StyleId = superPicker.pickStyleId(+ TScale(1.0 / picked_subsampling) * tmpMousePosition ++ TPointD(-0.5, -0.5),+ getPixelSize() * getPixelSize(), modeValue);+ /*-- 何かStyleが拾えて、Transparentでない場合 --*/+ if (superPicked_StyleId > 0) {+ /*-- Levelの移動 --*/+ getApplication()->getCurrentLevel()->setLevel(picked_level);+ /*-- Columnの移動 --*/+ getApplication()->getCurrentColumn()->setColumnIndex(+ superPickedColumnId);+ /*-- 選択の解除 --*/+ if (getApplication()->getCurrentSelection()->getSelection())+ getApplication()+ ->getCurrentSelection()+ ->getSelection()+ ->selectNone();+ /*-- StyleIdの移動 --*/+ getApplication()->setCurrentLevelStyleIndex(superPicked_StyleId);+ return;+ }+ }+ }+ }+ /*-- MultiLayerStylePicker ここまで --*/+ //------------------------------------+ TImageP image = getImage(false);+ TToonzImageP ti = image;+ TVectorImageP vi = image;+ TXshSimpleLevel *level =+ getApplication()->getCurrentLevel()->getSimpleLevel();+ if ((!ti && !vi) || !level) return;++ /*-- 画面外をpickしても拾えないようにする --*/+ if (!m_viewer->getGeometry().contains(pos)) return;++ int subsampling = level->getImageSubsampling(getCurrentFid());+ StylePicker picker(image);+ int styleId = picker.pickStyleId(+ TScale(1.0 / subsampling) * pos + TPointD(-0.5, -0.5),+ getPixelSize() * getPixelSize(), modeValue);++ if (styleId < 0) return;++ if (modeValue == 1) // LINES+ {+ /*-- pickLineモードのとき、取得Styleが0の場合はカレントStyleを変えない。+ * --*/+ if (styleId == 0) return;+ /*--+ * pickLineモードのとき、PurePaintの部分をクリックしてもカレントStyleを変えない+ * --*/+ if (ti &&+ picker.pickTone(TScale(1.0 / subsampling) * pos ++ TPointD(-0.5, -0.5)) == 255)+ return;}- ToolType getToolType() const override { return TTool::LevelReadTool; }+ /*--- Styleを選択している場合は選択を解除する ---*/+ TSelection *selection =+ TTool::getApplication()->getCurrentSelection()->getSelection();+ if (selection) {+ TStyleSelection *styleSelection =+ dynamic_cast<TStyleSelection *>(selection);+ if (styleSelection) styleSelection->selectNone();+ }- void draw() override {}+ getApplication()->setCurrentLevelStyleIndex(styleId);+}- void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override {- m_oldStyleId = m_currentStyleId =- getApplication()->getCurrentLevelStyleIndex();- pick(pos, e);- }- void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override {- pick(pos, e);+void StylePickerTool::mouseMove(const TPointD &pos, const TMouseEvent &e) {+ if (!m_passivePick.getValue()) return;+ /*--- PassiveにStyleを拾う機能 ---*/+ PaletteController *controller =+ TTool::getApplication()->getPaletteController();++ TImageP image = getImage(false);+ TToonzImageP ti = image;+ TVectorImageP vi = image;+ TXshSimpleLevel *level =+ getApplication()->getCurrentLevel()->getSimpleLevel();+ if ((!ti && !vi) || !level || !m_viewer->getGeometry().contains(pos)) {+ controller->notifyStylePassivePicked(-1, -1, -1);+ return;}- void pick(const TPointD &pos, const TMouseEvent &e) {- // Area = 0, Line = 1, All = 2- int modeValue = m_colorType.getIndex();-- //------------------------------------- // MultiLayerStylePicker- /*---- PickしたStyleId = 0、かつ- Preference で MultiLayerStylePickerが有効、かつ- Scene編集モード、かつ- 下のカラムから拾った色がTransparentでない場合、- → カレントLevelを移動する。- ---*/- if (Preferences::instance()->isMultiLayerStylePickerEnabled() &&- getApplication()->getCurrentFrame()->isEditingScene()) {- int superPickedColumnId = getViewer()->posToColumnIndex(- e.m_pos, getPixelSize() * getPixelSize(), false);-- if (superPickedColumnId >= 0 /*-- 何かColumnに当たった場合 --*/- &&- getApplication()->getCurrentColumn()->getColumnIndex() !=- superPickedColumnId) /*-- かつ、Current Columnでない場合 --*/- {- /*-- そのColumnからPickを試みる --*/- int currentFrame = getApplication()->getCurrentFrame()->getFrame();- TXshCell pickedCell =- getApplication()->getCurrentXsheet()->getXsheet()->getCell(- currentFrame, superPickedColumnId);- TImageP pickedImage = pickedCell.getImage(false).getPointer();- TToonzImageP picked_ti = pickedImage;- TVectorImageP picked_vi = pickedImage;- TXshSimpleLevel *picked_level = pickedCell.getSimpleLevel();- if ((picked_ti || picked_vi) && picked_level) {- TPointD tmpMousePosition =- getColumnMatrix(superPickedColumnId).inv() *- getViewer()->winToWorld(e.m_pos);-- TPointD tmpDpiScale =- getCurrentDpiScale(picked_level, getCurrentFid());-- tmpMousePosition.x /= tmpDpiScale.x;- tmpMousePosition.y /= tmpDpiScale.y;-- StylePicker superPicker(pickedImage);- int picked_subsampling =- picked_level->getImageSubsampling(pickedCell.getFrameId());- int superPicked_StyleId = superPicker.pickStyleId(- TScale(1.0 / picked_subsampling) * tmpMousePosition +- TPointD(-0.5, -0.5),- getPixelSize() * getPixelSize(), modeValue);- /*-- 何かStyleが拾えて、Transparentでない場合 --*/- if (superPicked_StyleId > 0) {- /*-- Levelの移動 --*/- getApplication()->getCurrentLevel()->setLevel(picked_level);- /*-- Columnの移動 --*/- getApplication()->getCurrentColumn()->setColumnIndex(- superPickedColumnId);- /*-- 選択の解除 --*/- if (getApplication()->getCurrentSelection()->getSelection())- getApplication()- ->getCurrentSelection()- ->getSelection()- ->selectNone();- /*-- StyleIdの移動 --*/- getApplication()->setCurrentLevelStyleIndex(superPicked_StyleId);- return;- }- }- }- }- /*-- MultiLayerStylePicker ここまで --*/- //------------------------------------- TImageP image = getImage(false);- TToonzImageP ti = image;- TVectorImageP vi = image;- TXshSimpleLevel *level =- getApplication()->getCurrentLevel()->getSimpleLevel();- if ((!ti && !vi) || !level) return;-- /*-- 画面外をpickしても拾えないようにする --*/- if (!m_viewer->getGeometry().contains(pos)) return;-- int subsampling = level->getImageSubsampling(getCurrentFid());- StylePicker picker(image);- int styleId = picker.pickStyleId(- TScale(1.0 / subsampling) * pos + TPointD(-0.5, -0.5),- getPixelSize() * getPixelSize(), modeValue);-- if (styleId < 0) return;-- if (modeValue == 1) // LINES- {- /*-- pickLineモードのとき、取得Styleが0の場合はカレントStyleを変えない。- * --*/- if (styleId == 0) return;- /*--- * pickLineモードのとき、PurePaintの部分をクリックしてもカレントStyleを変えない- * --*/- if (ti &&- picker.pickTone(TScale(1.0 / subsampling) * pos +- TPointD(-0.5, -0.5)) == 255)- return;- }-- /*--- Styleを選択している場合は選択を解除する ---*/- TSelection *selection =- TTool::getApplication()->getCurrentSelection()->getSelection();- if (selection) {- TStyleSelection *styleSelection =- dynamic_cast<TStyleSelection *>(selection);- if (styleSelection) styleSelection->selectNone();- }+ int subsampling = level->getImageSubsampling(getCurrentFid());+ StylePicker picker(image);+ TPointD pickPos(TScale(1.0 / subsampling) * pos + TPointD(-0.5, -0.5));+ int inkStyleId =+ picker.pickStyleId(pickPos, getPixelSize() * getPixelSize(), 1);+ int paintStyleId =+ picker.pickStyleId(pickPos, getPixelSize() * getPixelSize(), 0);+ int tone = picker.pickTone(pickPos);+ controller->notifyStylePassivePicked(inkStyleId, paintStyleId, tone);+}- getApplication()->setCurrentLevelStyleIndex(styleId);- }+int StylePickerTool::getCursorId() const {+ bool isBlackBG = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg;++ /* in case the "organize palette" option is active */+ if (m_organizePalette.getValue())+ return (isBlackBG) ? ToolCursor::PickerCursorWhiteOrganize+ : ToolCursor::PickerCursorOrganize;++ if (m_colorType.getValue() == LINES)+ return (isBlackBG) ? ToolCursor::PickerCursorWhiteLine+ : ToolCursor::PickerCursorLine;+ else if (m_colorType.getValue() == AREAS)+ return (isBlackBG) ? ToolCursor::PickerCursorWhiteArea+ : ToolCursor::PickerCursorArea;+ else // line&areas+ return (isBlackBG) ? ToolCursor::PickerCursorWhite+ : ToolCursor::PickerCursor;+}- void mouseMove(const TPointD &pos, const TMouseEvent &e) override {- if (!m_passivePick.getValue()) return;- /*--- PassiveにStyleを拾う機能 ---*/- PaletteController *controller =- TTool::getApplication()->getPaletteController();-- TImageP image = getImage(false);- TToonzImageP ti = image;- TVectorImageP vi = image;- TXshSimpleLevel *level =- getApplication()->getCurrentLevel()->getSimpleLevel();- if ((!ti && !vi) || !level || !m_viewer->getGeometry().contains(pos)) {- controller->notifyStylePassivePicked(-1, -1, -1);- return;+bool StylePickerTool::onPropertyChanged(std::string propertyName) {+ if (propertyName == m_organizePalette.getName()){++ if (m_organizePalette.getValue()) {+ if (!startOrganizePalette()){+ m_organizePalette.setValue(false);+ getApplication()->getCurrentTool()->notifyToolChanged();+ return false;+ }+ } else {+ std::cout << "End Organize Palette" << std::endl;+ m_paletteToBeOrganized = NULL;}+ }+ return true;+}- int subsampling = level->getImageSubsampling(getCurrentFid());- StylePicker picker(image);- TPointD pickPos(TScale(1.0 / subsampling) * pos + TPointD(-0.5, -0.5));- int inkStyleId =- picker.pickStyleId(pickPos, getPixelSize() * getPixelSize(), 1);- int paintStyleId =- picker.pickStyleId(pickPos, getPixelSize() * getPixelSize(), 0);- int tone = picker.pickTone(pickPos);- controller->notifyStylePassivePicked(inkStyleId, paintStyleId, tone);+bool StylePickerTool::startOrganizePalette() {+ /* Check if the organizing operation is available */+ TXshLevel* level = getApplication()->getCurrentLevel()->getLevel();+ if (!level) {+ DVGui::error(tr("No current level."));+ return false;+ }+ if ( level->getType() != PLI_XSHLEVEL && level->getType() != TZP_XSHLEVEL+ && level->getType() != PLT_XSHLEVEL ) {+ DVGui::error(tr("Current level has no available palette."));+ return false;+ }+ /* palette should have more than one page to organize */+ TPalette* pal = NULL;+ if (level->getType() == PLT_XSHLEVEL)+ pal = level->getPaletteLevel()->getPalette();+ else+ pal = level->getSimpleLevel()->getPalette();+ if (!pal || pal->getPageCount() < 2){+ DVGui::error(tr("Palette must have more than one palette to be organized."));+ return false;}- void onActivate() override {}+ m_paletteToBeOrganized = pal;++ std::cout << "Start Organize Palette" << std::endl;- int getCursorId() const override {- bool isBlackBG = ToonzCheck::instance()->getChecks() & ToonzCheck::eBlackBg;+ return true;+}- if (m_colorType.getValue() == LINES)- return (isBlackBG) ? ToolCursor::PickerCursorWhiteLine- : ToolCursor::PickerCursorLine;- else if (m_colorType.getValue() == AREAS)- return (isBlackBG) ? ToolCursor::PickerCursorWhiteArea- : ToolCursor::PickerCursorArea;- else // line&areas- return (isBlackBG) ? ToolCursor::PickerCursorWhite- : ToolCursor::PickerCursor;+/*+ If the working palette is changed, then deactivate the "organize palette" toggle.+*/+void StylePickerTool::onImageChanged() {+ std::cout << "StylePickerTool::onImageChanged" << std::endl;+ if (!m_organizePalette.getValue() || !m_paletteToBeOrganized)return;++ TXshLevel* level = getApplication()->getCurrentLevel()->getLevel();+ if (!level) {+ m_organizePalette.setValue(false);+ getApplication()->getCurrentTool()->notifyToolChanged();+ return;+ }+ TPalette* pal = NULL;+ if (level->getType() == PLT_XSHLEVEL)+ pal = level->getPaletteLevel()->getPalette();+ else if (level->getSimpleLevel()) {+ pal = level->getSimpleLevel()->getPalette();+ }+ if (!pal || pal != m_paletteToBeOrganized) {+ m_organizePalette.setValue(false);+ getApplication()->getCurrentTool()->notifyToolChanged();+ return;}--} stylePickerTool;}+++StylePickerTool stylePickerTool;+diff --git a/toonz/sources/tnztools/stylepickertool.h b/toonz/sources/tnztools/stylepickertool.hnew file mode 100644index 000000000..333ac0e17--- /dev/null+++ b/toonz/sources/tnztools/stylepickertool.h@@ -0,0 +1,53 @@+#pragma once++#ifndef STYLEPICKERTOOL_H+#define STYLEPICKERTOOL_H++#include "tools/tool.h"+#include "tproperty.h"+#include <QObject>++class StylePickerTool final : public TTool, public QObject {+ int m_oldStyleId, m_currentStyleId;++ TEnumProperty m_colorType;+ TPropertyGroup m_prop;+ TBoolProperty m_passivePick;++ TBoolProperty m_organizePalette;+ TPalette* m_paletteToBeOrganized;++ bool startOrganizePalette();+public:+ TPropertyGroup *getProperties(int targetType) override { return &m_prop; }++ StylePickerTool();++ ToolType getToolType() const override { return TTool::LevelReadTool; }++ void draw() override {}++ void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override;++ void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override;++ void pick(const TPointD &pos, const TMouseEvent &e);++ void mouseMove(const TPointD &pos, const TMouseEvent &e) override;++ int getCursorId() const override;++ bool onPropertyChanged(std::string propertyName);++ bool isOrganizePaletteActive() { return m_organizePalette.getValue(); }++ /*+ This function is called when either frame/column/level/scene is switched or+ either scene/level/object is changed (see tapp.cpp).+ If the working palette is changed, then deactivate the "organize palette" toggle.+ */+ void onImageChanged() override;+};+++#endif\ No newline at end of filediff --git a/toonz/sources/tnztools/tnztools.qrc b/toonz/sources/tnztools/tnztools.qrcindex 98087dc9e..1b5b91bb0 100644--- a/toonz/sources/tnztools/tnztools.qrc+++ b/toonz/sources/tnztools/tnztools.qrc@@ -50,6 +50,8 @@<file>Resources/picker_style_white_line.png</file><file>Resources/picker_style_white_area.png</file><file>Resources/picker_style_white.png</file>+ <file>Resources/picker_style_organize.png</file>+ <file>Resources/picker_style_white_organize.png</file><file>Resources/picker_rgb.png</file><file>Resources/picker_rgb_white.png</file><file>Resources/fill_f.png</file>diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cppindex ea777d38c..ceb051732 100644--- a/toonz/sources/tnztools/tooloptions.cpp+++ b/toonz/sources/tnztools/tooloptions.cpp@@ -2173,6 +2173,15 @@ StylePickerToolOptionsBox::StylePickerToolOptionsBox(m_layout->addWidget(m_currentStyleLabel, 0);m_layout->addStretch(1);+ // retrieve the "organize palette" checkbox from the layout and insert+ // into rightmost of the tool option bar+ ToolOptionCheckbox* organizePaletteCB =+ dynamic_cast<ToolOptionCheckbox *>(m_controls.value("Organize Palette"));+ m_layout->removeWidget(organizePaletteCB);+ m_layout->addWidget(new ToolOptionsBarSeparator(this), 0);+ m_layout->addWidget(organizePaletteCB);+ organizePaletteCB->setToolTip(tr("With this option being activated, the picked style will be\nmoved to the end of the first page of the palette."));+if (m_realTimePickMode) {connect(m_realTimePickMode, SIGNAL(toggled(bool)), m_currentStyleLabel,SLOT(setVisible(bool)));diff --git a/toonz/sources/toonz/colormodelviewer.cpp b/toonz/sources/toonz/colormodelviewer.cppindex 2e063b5b2..69e207fd2 100644--- a/toonz/sources/toonz/colormodelviewer.cpp+++ b/toonz/sources/toonz/colormodelviewer.cpp@@ -14,6 +14,7 @@#include "tools/toolcommandids.h"#include "tools/tool.h"#include "tools/toolhandle.h"+#include "../tnztools/stylepickertool.h"// TnzQt includes#include "toonzqt/menubarcommand.h"@@ -306,6 +307,12 @@ void ColorModelViewer::pick(const QPoint &p) {if (styleSelection) styleSelection->selectNone();}+ /*+ if the Style Picker too 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)+ph->setStyleIndex(styleIndex);}@@ -356,8 +363,16 @@ void ColorModelViewer::showEvent(QShowEvent *e) {//-----------------------------------------------------------------------------/*- ツールのTypeに合わせてPickのタイプも変え、カーソルも切り替える -*/void ColorModelViewer::changePickType() {- TPropertyGroup *propGroup =- TApp::instance()->getCurrentTool()->getTool()->getProperties(0);+ TTool *tool = TApp::instance()->getCurrentTool()->getTool();+ if (tool->getName() == T_StylePicker) {+ StylePickerTool* stylePickerTool = dynamic_cast<StylePickerTool*>(tool);+ if (stylePickerTool->isOrganizePaletteActive()) {+ setToolCursor(m_imageViewer, ToolCursor::PickerCursorOrganize);+ return;+ }+ }++ TPropertyGroup *propGroup = tool->getProperties(0);/*- Propertyの無いツールの場合 -*/if (!propGroup) {m_mode = 2;diff --git a/toonz/sources/toonz/colormodelviewer.h b/toonz/sources/toonz/colormodelviewer.hindex e06808054..3a4a00fb8 100644--- a/toonz/sources/toonz/colormodelviewer.h+++ b/toonz/sources/toonz/colormodelviewer.h@@ -48,6 +48,7 @@ protected:* UseCurrentFrameのLevelに移動してきたときに、改めてCurrentFrameを格納しなおす* -*/void reloadCurrentFrame();+protected slots:void showCurrentImage();diff --git a/toonz/sources/toonzlib/convert2tlv.cpp b/toonz/sources/toonzlib/convert2tlv.cppindex 8e9c52920..6663848ca 100644--- a/toonz/sources/toonzlib/convert2tlv.cpp+++ b/toonz/sources/toonzlib/convert2tlv.cpp@@ -566,6 +566,17 @@ TPalette *Convert2Tlv::buildPalette() {page->addStyle(stylesToBeAddedToPage.at(s));}+ /*+ If the palette path is empty, an initial palette with four colors are set in the palette here.+ ( see Convert2Tlv::init() ) So here I make the latter three styles in the initial palette to set+ "AutoPaint" options.+ */+ if (m_palettePath.isEmpty()) {+ assert(m_palette->getStyleCount() >= 5);+ for (int id = 2; id <= 4; id++)+ m_palette->getStyle(id)->setFlags(1);+ }+if (!m_appendDefaultPalette) return m_palette;/*-- Adding styles in the default palette to the result palette, starts here@@ -810,11 +821,16 @@ bool Convert2Tlv::init(std::string &errorMessage) {m_it = m_level1->begin();- /*- 既定のパレットを作る。黒、赤、青、緑の順 -*/- m_colorMap[TPixel::Black] = ++m_lastIndex;- m_colorMap[TPixel::Red] = ++m_lastIndex;- m_colorMap[TPixel::Blue] = ++m_lastIndex;- m_colorMap[TPixel::Green] = ++m_lastIndex;+ /*-+ If the palette is empty, make an initial palette with black, red, blue and green styles.+ For the latter three styles the "autopaint" option should be set.+ -*/+ if (m_lastIndex == 0) {+ m_colorMap[TPixel::Black] = ++m_lastIndex;+ m_colorMap[TPixel::Red] = ++m_lastIndex;+ m_colorMap[TPixel::Blue] = ++m_lastIndex;+ m_colorMap[TPixel::Green] = ++m_lastIndex;+ }return true;}