RGB sliders behaving like CSP/Krita, Hex editbox and various bugfixes
This commit is contained in:
parent
f7a1076116
commit
7a23b1e29a
10 changed files with 654 additions and 140 deletions
164
stuff/config/colornames.txt
Normal file
164
stuff/config/colornames.txt
Normal file
|
@ -0,0 +1,164 @@
|
|||
<colors>
|
||||
<!-- color name is not case-sensitive and must have no spaces, items on bottom takes priority -->
|
||||
<!-- Japanese test -->
|
||||
<color name="レッド">#FF0000</color>
|
||||
<color name="グリーン">#00FF00</color>
|
||||
<color name="ブルー">#0000FF</color>
|
||||
<!-- Miscellaneous Names -->
|
||||
<color name="Transparency">#FFFFFF00</color>
|
||||
<color name="Transparent">#FFFFFF00</color>
|
||||
<color name="Void">#00000000</color>
|
||||
<color name="0">#000000</color>
|
||||
<color name="1">#FF0000</color>
|
||||
<color name="2">#00FF00</color>
|
||||
<color name="3">#0000FF</color>
|
||||
<!-- HTML Color Names -->
|
||||
<color name="AliceBlue">#F0F8FF</color>
|
||||
<color name="AntiqueWhite">#FAEBD7</color>
|
||||
<color name="Aqua">#00FFFF</color>
|
||||
<color name="Aquamarine">#7FFFD4</color>
|
||||
<color name="Azure">#F0FFFF</color>
|
||||
<color name="Beige">#F5F5DC</color>
|
||||
<color name="Bisque">#FFE4C4</color>
|
||||
<color name="Black">#000000</color>
|
||||
<color name="BlanchedAlmond">#FFEBCD</color>
|
||||
<color name="Blue">#0000FF</color>
|
||||
<color name="BlueViolet">#8A2BE2</color>
|
||||
<color name="Brown">#A52A2A</color>
|
||||
<color name="BurlyWood">#DEB887</color>
|
||||
<color name="CadetBlue">#5F9EA0</color>
|
||||
<color name="Chartreuse">#7FFF00</color>
|
||||
<color name="Chocolate">#D2691E</color>
|
||||
<color name="Coral">#FF7F50</color>
|
||||
<color name="CornflowerBlue">#6495ED</color>
|
||||
<color name="Cornsilk">#FFF8DC</color>
|
||||
<color name="Crimson">#DC143C</color>
|
||||
<color name="Cyan">#00FFFF</color>
|
||||
<color name="DarkBlue">#00008B</color>
|
||||
<color name="DarkCyan">#008B8B</color>
|
||||
<color name="DarkGoldenRod">#B8860B</color>
|
||||
<color name="DarkGray">#A9A9A9</color>
|
||||
<color name="DarkGrey">#A9A9A9</color>
|
||||
<color name="DarkGreen">#006400</color>
|
||||
<color name="DarkKhaki">#BDB76B</color>
|
||||
<color name="DarkMagenta">#8B008B</color>
|
||||
<color name="DarkOliveGreen">#556B2F</color>
|
||||
<color name="DarkOrange">#FF8C00</color>
|
||||
<color name="DarkOrchid">#9932CC</color>
|
||||
<color name="DarkRed">#8B0000</color>
|
||||
<color name="DarkSalmon">#E9967A</color>
|
||||
<color name="DarkSeaGreen">#8FBC8F</color>
|
||||
<color name="DarkSlateBlue">#483D8B</color>
|
||||
<color name="DarkSlateGray">#2F4F4F</color>
|
||||
<color name="DarkSlateGrey">#2F4F4F</color>
|
||||
<color name="DarkTurquoise">#00CED1</color>
|
||||
<color name="DarkViolet">#9400D3</color>
|
||||
<color name="DeepPink">#FF1493</color>
|
||||
<color name="DeepSkyBlue">#00BFFF</color>
|
||||
<color name="DimGray">#696969</color>
|
||||
<color name="DimGrey">#696969</color>
|
||||
<color name="DodgerBlue">#1E90FF</color>
|
||||
<color name="FireBrick">#B22222</color>
|
||||
<color name="FloralWhite">#FFFAF0</color>
|
||||
<color name="ForestGreen">#228B22</color>
|
||||
<color name="Fuchsia">#FF00FF</color>
|
||||
<color name="Gainsboro">#DCDCDC</color>
|
||||
<color name="GhostWhite">#F8F8FF</color>
|
||||
<color name="Gold">#FFD700</color>
|
||||
<color name="GoldenRod">#DAA520</color>
|
||||
<color name="Gray">#808080</color>
|
||||
<color name="Grey">#808080</color>
|
||||
<color name="Green">#008000</color>
|
||||
<color name="GreenYellow">#ADFF2F</color>
|
||||
<color name="HoneyDew">#F0FFF0</color>
|
||||
<color name="HotPink">#FF69B4</color>
|
||||
<color name="IndianRed">#CD5C5C</color>
|
||||
<color name="Indigo">#4B0082</color>
|
||||
<color name="Ivory">#FFFFF0</color>
|
||||
<color name="Khaki">#F0E68C</color>
|
||||
<color name="Lavender">#E6E6FA</color>
|
||||
<color name="LavenderBlush">#FFF0F5</color>
|
||||
<color name="LawnGreen">#7CFC00</color>
|
||||
<color name="LemonChiffon">#FFFACD</color>
|
||||
<color name="LightBlue">#ADD8E6</color>
|
||||
<color name="LightCoral">#F08080</color>
|
||||
<color name="LightCyan">#E0FFFF</color>
|
||||
<color name="LightGoldenRodYellow">#FAFAD2</color>
|
||||
<color name="LightGray">#D3D3D3</color>
|
||||
<color name="LightGrey">#D3D3D3</color>
|
||||
<color name="LightGreen">#90EE90</color>
|
||||
<color name="LightPink">#FFB6C1</color>
|
||||
<color name="LightSalmon">#FFA07A</color>
|
||||
<color name="LightSeaGreen">#20B2AA</color>
|
||||
<color name="LightSkyBlue">#87CEFA</color>
|
||||
<color name="LightSlateGray">#778899</color>
|
||||
<color name="LightSlateGrey">#778899</color>
|
||||
<color name="LightSteelBlue">#B0C4DE</color>
|
||||
<color name="LightYellow">#FFFFE0</color>
|
||||
<color name="Lime">#00FF00</color>
|
||||
<color name="LimeGreen">#32CD32</color>
|
||||
<color name="Linen">#FAF0E6</color>
|
||||
<color name="Magenta">#FF00FF</color>
|
||||
<color name="Maroon">#800000</color>
|
||||
<color name="MediumAquaMarine">#66CDAA</color>
|
||||
<color name="MediumBlue">#0000CD</color>
|
||||
<color name="MediumOrchid">#BA55D3</color>
|
||||
<color name="MediumPurple">#9370DB</color>
|
||||
<color name="MediumSeaGreen">#3CB371</color>
|
||||
<color name="MediumSlateBlue">#7B68EE</color>
|
||||
<color name="MediumSpringGreen">#00FA9A</color>
|
||||
<color name="MediumTurquoise">#48D1CC</color>
|
||||
<color name="MediumVioletRed">#C71585</color>
|
||||
<color name="MidnightBlue">#191970</color>
|
||||
<color name="MintCream">#F5FFFA</color>
|
||||
<color name="MistyRose">#FFE4E1</color>
|
||||
<color name="Moccasin">#FFE4B5</color>
|
||||
<color name="NavajoWhite">#FFDEAD</color>
|
||||
<color name="Navy">#000080</color>
|
||||
<color name="OldLace">#FDF5E6</color>
|
||||
<color name="Olive">#808000</color>
|
||||
<color name="OliveDrab">#6B8E23</color>
|
||||
<color name="Orange">#FFA500</color>
|
||||
<color name="OrangeRed">#FF4500</color>
|
||||
<color name="Orchid">#DA70D6</color>
|
||||
<color name="PaleGoldenRod">#EEE8AA</color>
|
||||
<color name="PaleGreen">#98FB98</color>
|
||||
<color name="PaleTurquoise">#AFEEEE</color>
|
||||
<color name="PaleVioletRed">#DB7093</color>
|
||||
<color name="PapayaWhip">#FFEFD5</color>
|
||||
<color name="PeachPuff">#FFDAB9</color>
|
||||
<color name="Peru">#CD853F</color>
|
||||
<color name="Pink">#FFC0CB</color>
|
||||
<color name="Plum">#DDA0DD</color>
|
||||
<color name="PowderBlue">#B0E0E6</color>
|
||||
<color name="Purple">#800080</color>
|
||||
<color name="RebeccaPurple">#663399</color>
|
||||
<color name="Red">#FF0000</color>
|
||||
<color name="RosyBrown">#BC8F8F</color>
|
||||
<color name="RoyalBlue">#4169E1</color>
|
||||
<color name="SaddleBrown">#8B4513</color>
|
||||
<color name="Salmon">#FA8072</color>
|
||||
<color name="SandyBrown">#F4A460</color>
|
||||
<color name="SeaGreen">#2E8B57</color>
|
||||
<color name="SeaShell">#FFF5EE</color>
|
||||
<color name="Sienna">#A0522D</color>
|
||||
<color name="Silver">#C0C0C0</color>
|
||||
<color name="SkyBlue">#87CEEB</color>
|
||||
<color name="SlateBlue">#6A5ACD</color>
|
||||
<color name="SlateGray">#708090</color>
|
||||
<color name="SlateGrey">#708090</color>
|
||||
<color name="Snow">#FFFAFA</color>
|
||||
<color name="SpringGreen">#00FF7F</color>
|
||||
<color name="SteelBlue">#4682B4</color>
|
||||
<color name="Tan">#D2B48C</color>
|
||||
<color name="Teal">#008080</color>
|
||||
<color name="Thistle">#D8BFD8</color>
|
||||
<color name="Tomato">#FF6347</color>
|
||||
<color name="Turquoise">#40E0D0</color>
|
||||
<color name="Violet">#EE82EE</color>
|
||||
<color name="Wheat">#F5DEB3</color>
|
||||
<color name="White">#FFFFFF</color>
|
||||
<color name="WhiteSmoke">#F5F5F5</color>
|
||||
<color name="Yellow">#FFFF00</color>
|
||||
<color name="YellowGreen">#9ACD32</color>
|
||||
</colors>
|
|
@ -36,6 +36,25 @@ class TPaletteHandle;
|
|||
|
||||
namespace DVGui {
|
||||
|
||||
//=============================================================================
|
||||
// CommonChessboard singleton
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class DVAPI CommonChessboard final : public QObject {
|
||||
Q_OBJECT
|
||||
TRaster32P m_bgRas;
|
||||
QPixmap m_bgPix;
|
||||
void setChessboardColors(const TPixel32 &col1, const TPixel32 &col2);
|
||||
|
||||
public:
|
||||
CommonChessboard();
|
||||
|
||||
const QPixmap &getPixmap() { return m_bgPix; }
|
||||
void update();
|
||||
|
||||
static CommonChessboard *instance();
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
// StyleSample
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -49,6 +68,10 @@ class DVAPI StyleSample final : public QWidget {
|
|||
bool m_drawEnable;
|
||||
TPixel m_chessColor1;
|
||||
TPixel m_chessColor2;
|
||||
bool m_cloneStyle;
|
||||
bool m_sysChessboard;
|
||||
bool m_stretch;
|
||||
QColor m_currentColor;
|
||||
|
||||
bool m_isEditing;
|
||||
|
||||
|
@ -58,7 +81,7 @@ public:
|
|||
|
||||
void enableClick(bool on) { m_clickEnabled = on; }
|
||||
|
||||
void setStyle(TColorStyle &style);
|
||||
void setStyle(TColorStyle &style, int colorParameterIndex);
|
||||
TColorStyle *getStyle() const;
|
||||
|
||||
void setColor(const TPixel32 &color);
|
||||
|
@ -73,13 +96,16 @@ public:
|
|||
void setEnable(bool drawEnable) { m_drawEnable = drawEnable; }
|
||||
bool isEnable() const { return m_drawEnable; }
|
||||
|
||||
void setCloneStyle(bool enable) { m_cloneStyle = enable; }
|
||||
void setSystemChessboard(bool enable) { m_sysChessboard = enable; }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
|
||||
signals:
|
||||
void clicked(const TColorStyle &style);
|
||||
void clicked();
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -83,13 +83,29 @@ class HexLineEdit : public QLineEdit {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HexLineEdit(const QString &contents, QWidget *parent)
|
||||
: QLineEdit(contents, parent) {}
|
||||
HexLineEdit(const QString &contents, QWidget *parent);
|
||||
~HexLineEdit() {}
|
||||
|
||||
bool loadDefaultColorNames(bool reload);
|
||||
bool hasUserColorNames();
|
||||
bool loadUserColorNames(bool reload);
|
||||
void setStyle(TColorStyle &style, int index);
|
||||
void updateColor();
|
||||
void setColor(TPixel color);
|
||||
TPixel getColor() { return m_color; }
|
||||
bool fromText(QString text);
|
||||
bool fromHex(QString text);
|
||||
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent *event) override;
|
||||
void loadColorTableXML(QMap<QString, QString> &table, const TFilePath &fp);
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void focusOutEvent(QFocusEvent *event) override;
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
||||
bool m_editing;
|
||||
TPixel m_color;
|
||||
static QMap<QString, QString> s_defcolornames; // make it shared
|
||||
static QMap<QString, QString> s_usercolornames; // ...
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
@ -257,13 +273,13 @@ signals:
|
|||
//=============================================================================
|
||||
/*! \brief The ColorSlider is used to set a color channel.
|
||||
|
||||
Inherits \b QSlider.
|
||||
Inherits \b QAbstractSlider.
|
||||
|
||||
This object show a bar which colors differ from minimum to
|
||||
maximum channel color
|
||||
value.
|
||||
*/
|
||||
class DVAPI ColorSlider final : public QSlider {
|
||||
class DVAPI ColorSlider final : public QAbstractSlider {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ColorSlider(Qt::Orientation orientation, QWidget *parent = 0);
|
||||
|
@ -278,6 +294,9 @@ protected:
|
|||
void paintEvent(QPaintEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
|
||||
void chandleMouse(int x, int y);
|
||||
|
||||
// QIcon getFirstArrowIcon();
|
||||
// QIcon getLastArrowIcon();
|
||||
|
@ -287,6 +306,8 @@ protected:
|
|||
private:
|
||||
ColorChannel m_channel;
|
||||
ColorModel m_color;
|
||||
static int s_chandle_size;
|
||||
static int s_chandle_tall;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
@ -795,7 +816,6 @@ class DVAPI StyleEditor final : public QWidget, public SaveLoadQSettings {
|
|||
TPaletteHandle *m_paletteHandle;
|
||||
TPaletteHandle *m_cleanupPaletteHandle;
|
||||
HexLineEdit *m_hexLineEdit;
|
||||
QWidgetAction *m_hexAction;
|
||||
QWidget *m_parent;
|
||||
TXshLevelHandle
|
||||
*m_levelHandle; //!< for clearing the level cache when the color changed
|
||||
|
@ -833,6 +853,7 @@ class DVAPI StyleEditor final : public QWidget, public SaveLoadQSettings {
|
|||
QAction *m_hsvAction;
|
||||
QAction *m_alphaAction;
|
||||
QAction *m_rgbAction;
|
||||
QAction *m_hexAction;
|
||||
|
||||
TColorStyleP
|
||||
m_oldStyle; //!< A copy of current style \a before the last change.
|
||||
|
@ -975,7 +996,8 @@ protected slots:
|
|||
void onStyleSwitched();
|
||||
void onStyleChanged(bool isDragging);
|
||||
void onCleanupStyleChanged(bool isDragging);
|
||||
void onOldStyleClicked(const TColorStyle &);
|
||||
void onOldStyleClicked();
|
||||
void onNewStyleClicked();
|
||||
void updateOrientationButton();
|
||||
void checkPaletteLock();
|
||||
// called (e.g.) by PaletteController when an other StyleEditor change the
|
||||
|
@ -1001,6 +1023,7 @@ protected slots:
|
|||
void onParamStyleChanged(bool isDragging);
|
||||
|
||||
void onHexChanged();
|
||||
|
||||
void onHexEdited(const QString &text);
|
||||
void onHideMenu();
|
||||
void onPageChanged(int index);
|
||||
|
|
|
@ -693,6 +693,12 @@ void PreferencesPopup::onUseThemeViewerColorsChanged() {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PreferencesPopup::onChessboardChanged() {
|
||||
CommonChessboard::instance()->update();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PreferencesPopup::onSVNEnabledChanged() {
|
||||
if (m_pref->getBoolValue(SVNEnabled)) {
|
||||
if (!VersionControl::instance()->testSetup())
|
||||
|
@ -2012,6 +2018,10 @@ QWidget* PreferencesPopup::createColorsPage() {
|
|||
&PreferencesPopup::notifySceneChanged);
|
||||
m_onEditedFuncMap.insert(chessboardColor2,
|
||||
&PreferencesPopup::notifySceneChanged);
|
||||
m_onEditedFuncMap.insert(chessboardColor1,
|
||||
&PreferencesPopup::onChessboardChanged);
|
||||
m_onEditedFuncMap.insert(chessboardColor2,
|
||||
&PreferencesPopup::onChessboardChanged);
|
||||
m_onEditedFuncMap.insert(useThemeViewerColors,
|
||||
&PreferencesPopup::onUseThemeViewerColorsChanged);
|
||||
|
||||
|
|
|
@ -161,6 +161,7 @@ private:
|
|||
void onOnionColorChanged();
|
||||
// Colors
|
||||
void onTranspCheckDataChanged();
|
||||
void onChessboardChanged();
|
||||
void onUseThemeViewerColorsChanged();
|
||||
// Version Control
|
||||
void onSVNEnabledChanged();
|
||||
|
|
10
toonz/sources/toonzqt/Resources/h_chandle_arrow.svg
Normal file
10
toonz/sources/toonzqt/Resources/h_chandle_arrow.svg
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="11px" height="8px" viewBox="0 0 11 8" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g transform="matrix(0.9,0,0,1,1,-1.11022e-16)">
|
||||
<path d="M5,1C5,1 8.952,4.556 9.829,5.346C9.938,5.445 10,5.578 10,5.718C10,5.922 10,6.235 10,6.501C10,6.776 9.752,7 9.445,7C7.695,7 2.305,7 0.555,7C0.248,7 0,6.776 0,6.501C-0,6.235 -0,5.922 -0,5.718C-0,5.578 0.062,5.445 0.171,5.346C1.048,4.556 5,1 5,1Z" style="fill:rgb(235,235,235);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.9,0,0,1,1,-1.11022e-16)">
|
||||
<path d="M5.786,0.293C5.352,-0.098 4.648,-0.098 4.214,0.293C4.214,0.293 0.263,3.849 -0.615,4.639C-0.932,4.925 -1.111,5.313 -1.111,5.718L-1.111,6.501C-1.111,7.329 -0.365,8 0.555,8C2.305,8 7.695,8 9.445,8C10.365,8 11.111,7.329 11.111,6.501L11.111,5.718C11.111,5.313 10.932,4.925 10.615,4.639C9.737,3.849 5.786,0.293 5.786,0.293ZM5,1C5,1 8.952,4.556 9.829,5.346C9.938,5.445 10,5.578 10,5.718C10,5.922 10,6.235 10,6.501C10,6.776 9.752,7 9.445,7C7.695,7 2.305,7 0.555,7C0.248,7 0,6.776 0,6.501C-0,6.235 -0,5.922 -0,5.718C-0,5.578 0.062,5.445 0.171,5.346C1.048,4.556 5,1 5,1Z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
10
toonz/sources/toonzqt/Resources/v_chandle_arrow.svg
Normal file
10
toonz/sources/toonzqt/Resources/v_chandle_arrow.svg
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="8px" height="11px" viewBox="0 0 8 11" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g transform="matrix(-1.65327e-16,-0.9,1,-1.83697e-16,-4.7895e-13,10)">
|
||||
<path d="M5,1C5,1 8.952,4.556 9.829,5.346C9.938,5.445 10,5.578 10,5.718C10,5.922 10,6.235 10,6.501C10,6.776 9.752,7 9.445,7C7.695,7 2.305,7 0.555,7C0.248,7 0,6.776 0,6.501C-0,6.235 -0,5.922 -0,5.718C-0,5.578 0.062,5.445 0.171,5.346C1.048,4.556 5,1 5,1Z" style="fill:rgb(235,235,235);"/>
|
||||
</g>
|
||||
<g transform="matrix(-1.65327e-16,-0.9,1,-1.83697e-16,-4.7895e-13,10)">
|
||||
<path d="M5.786,0.293C5.352,-0.098 4.648,-0.098 4.214,0.293C4.214,0.293 0.263,3.849 -0.615,4.639C-0.932,4.925 -1.111,5.313 -1.111,5.718L-1.111,6.501C-1.111,7.329 -0.365,8 0.555,8C2.305,8 7.695,8 9.445,8C10.365,8 11.111,7.329 11.111,6.501L11.111,5.718C11.111,5.313 10.932,4.925 10.615,4.639C9.737,3.849 5.786,0.293 5.786,0.293ZM5,1C5,1 8.952,4.556 9.829,5.346C9.938,5.445 10,5.578 10,5.718C10,5.922 10,6.235 10,6.501C10,6.776 9.752,7 9.445,7C7.695,7 2.305,7 0.555,7C0.248,7 0,6.776 0,6.501C-0,6.235 -0,5.922 -0,5.718C-0,5.578 0.062,5.445 0.171,5.346C1.048,4.556 5,1 5,1Z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
|
@ -47,6 +47,31 @@ QPixmap getIconPm(const QColor &color) {
|
|||
|
||||
} // namespace
|
||||
|
||||
//=============================================================================
|
||||
|
||||
CommonChessboard *CommonChessboard::instance() {
|
||||
static CommonChessboard _instance;
|
||||
return &_instance;
|
||||
}
|
||||
|
||||
CommonChessboard::CommonChessboard() : m_bgRas(40.0, 40.0) { update(); }
|
||||
|
||||
void CommonChessboard::setChessboardColors(const TPixel32 &col1,
|
||||
const TPixel32 &col2) {
|
||||
TRop::checkBoard(m_bgRas, col1, col2,
|
||||
TDimensionD(m_bgRas->getLx() / 8, m_bgRas->getLy() / 8),
|
||||
TPointD(0, 0));
|
||||
QImage img(m_bgRas->getRawData(), m_bgRas->getLx(), m_bgRas->getLy(),
|
||||
QImage::Format_ARGB32);
|
||||
m_bgPix = QPixmap::fromImage(img);
|
||||
}
|
||||
|
||||
void CommonChessboard::update() {
|
||||
TPixel32 col1, col2;
|
||||
Preferences::instance()->getChessboardColors(col1, col2);
|
||||
setChessboardColors(col1, col2);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*! \class DVGui::StyleSample
|
||||
\brief The StyleSample class provides to view a square color.
|
||||
|
@ -82,6 +107,8 @@ StyleSample::StyleSample(QWidget *parent, int sizeX, int sizeY)
|
|||
, m_clickEnabled(false)
|
||||
, m_chessColor1(180, 180, 180)
|
||||
, m_chessColor2(239, 239, 239)
|
||||
, m_sysChessboard(false)
|
||||
, m_stretch(true)
|
||||
, m_isEditing(false) {
|
||||
setMinimumSize(sizeX, sizeY);
|
||||
setColor(TPixel32::Transparent);
|
||||
|
@ -106,17 +133,26 @@ TColorStyle *StyleSample::getStyle() const { return m_style; }
|
|||
/*! Update current square colore and, if click event is enable set current
|
||||
StyleSample \b TColorStyle style to \b style.
|
||||
*/
|
||||
void StyleSample::setStyle(TColorStyle &style) {
|
||||
void StyleSample::setStyle(TColorStyle &style, int colorParameterIndex) {
|
||||
// Store current color
|
||||
TPixel32 color = style.getColorParamValue(colorParameterIndex);
|
||||
m_currentColor = QColor(color.r, color.g, color.b, color.m);
|
||||
|
||||
/*-- TSolidColorStyleの場合のみ、単色塗りつぶし --*/
|
||||
if (style.getTagId() == 3)
|
||||
if (style.getTagId() == 3) {
|
||||
setColor(style.getMainColor());
|
||||
else {
|
||||
m_stretch = true;
|
||||
} else {
|
||||
TRaster32P icon =
|
||||
style.getIcon(qsize2Dimension(m_samplePixmap.rect().size()));
|
||||
m_samplePixmap = rasterToQImage(icon, false); // modified in 6.2
|
||||
m_stretch = false;
|
||||
update();
|
||||
}
|
||||
if (m_clickEnabled) m_style = style.clone();
|
||||
if (m_cloneStyle) {
|
||||
if (m_style) delete m_style; // avoid memory leak
|
||||
m_style = style.clone();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -149,10 +185,22 @@ void StyleSample::setChessboardColors(const TPixel32 &col1,
|
|||
void StyleSample::paintEvent(QPaintEvent *event) {
|
||||
if (!isEnable()) return;
|
||||
QPainter painter(this);
|
||||
QImage img(m_bgRas->getRawData(), m_bgRas->getLx(), m_bgRas->getLy(),
|
||||
QImage::Format_ARGB32);
|
||||
painter.drawImage(0, 0, img.scaled(size()));
|
||||
painter.drawImage(0, 0, m_samplePixmap.scaled(size()));
|
||||
if (m_sysChessboard) {
|
||||
painter.drawTiledPixmap(rect(),
|
||||
DVGui::CommonChessboard::instance()->getPixmap());
|
||||
} else {
|
||||
QImage img(m_bgRas->getRawData(), m_bgRas->getLx(), m_bgRas->getLy(),
|
||||
QImage::Format_ARGB32);
|
||||
painter.drawImage(0, 0, img.scaled(size()));
|
||||
}
|
||||
if (m_stretch) {
|
||||
painter.drawImage(0, 0, m_samplePixmap.scaled(size()));
|
||||
} else {
|
||||
int x = (width() - m_samplePixmap.width()) / 2;
|
||||
int y = (height() - m_samplePixmap.height()) / 2;
|
||||
painter.fillRect(rect(), m_currentColor);
|
||||
painter.drawImage(x, y, m_samplePixmap);
|
||||
}
|
||||
if (m_isEditing) {
|
||||
// QRect rect(0,0,m_bgRas->getLx(),m_bgRas->getLy());
|
||||
painter.setPen(Qt::white);
|
||||
|
@ -168,8 +216,8 @@ void StyleSample::paintEvent(QPaintEvent *event) {
|
|||
clicked(const TColorStyle &style).
|
||||
*/
|
||||
void StyleSample::mousePressEvent(QMouseEvent *event) {
|
||||
if (m_style && m_clickEnabled)
|
||||
emit clicked(*m_style);
|
||||
if (m_clickEnabled)
|
||||
emit clicked();
|
||||
else
|
||||
event->ignore();
|
||||
}
|
||||
|
@ -771,7 +819,7 @@ CleanupColorField::CleanupColorField(QWidget *parent,
|
|||
}
|
||||
}
|
||||
|
||||
m_colorSample->setStyle(*cleanupStyle);
|
||||
m_colorSample->setStyle(*cleanupStyle, 0);
|
||||
|
||||
//---- layout
|
||||
|
||||
|
@ -828,7 +876,7 @@ CleanupColorField::CleanupColorField(QWidget *parent,
|
|||
void CleanupColorField::updateColor() {
|
||||
if (m_cleanupStyle->canUpdate()) {
|
||||
m_cleanupStyle->invalidateIcon();
|
||||
m_colorSample->setStyle(*m_cleanupStyle);
|
||||
m_colorSample->setStyle(*m_cleanupStyle, 0);
|
||||
|
||||
m_brightnessChannel->setChannel(m_cleanupStyle->getBrightness());
|
||||
if (m_cleanupStyle->isContrastEnabled())
|
||||
|
@ -860,7 +908,7 @@ void CleanupColorField::setColor(const TPixel32 &color) {
|
|||
|
||||
m_cleanupStyle->setMainColor(color);
|
||||
m_cleanupStyle->invalidateIcon();
|
||||
m_colorSample->setStyle(*m_cleanupStyle);
|
||||
m_colorSample->setStyle(*m_cleanupStyle, 0);
|
||||
m_ph->notifyColorStyleChanged(false);
|
||||
}
|
||||
|
||||
|
@ -877,7 +925,7 @@ void CleanupColorField::setOutputColor(const TPixel32 &color) {
|
|||
|
||||
m_cleanupStyle->setColorParamValue(1, color);
|
||||
m_cleanupStyle->invalidateIcon();
|
||||
m_colorSample->setStyle(*m_cleanupStyle);
|
||||
m_colorSample->setStyle(*m_cleanupStyle, 0);
|
||||
m_ph->notifyColorStyleChanged();
|
||||
}
|
||||
|
||||
|
@ -891,7 +939,7 @@ void CleanupColorField::setStyle(TColorStyle *style) {
|
|||
m_cleanupStyle->setMainColor(style->getMainColor());
|
||||
m_cleanupStyle->setColorParamValue(1, style->getColorParamValue(1));
|
||||
m_cleanupStyle->invalidateIcon();
|
||||
m_colorSample->setStyle(*m_cleanupStyle);
|
||||
m_colorSample->setStyle(*m_cleanupStyle, 0);
|
||||
m_ph->notifyColorStyleChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "tvectorrenderdata.h"
|
||||
#include "tsimplecolorstyles.h"
|
||||
#include "tvectorbrushstyle.h"
|
||||
#include "tenv.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QHBoxLayout>
|
||||
|
@ -70,6 +71,212 @@
|
|||
using namespace StyleEditorGUI;
|
||||
using namespace DVGui;
|
||||
|
||||
//*****************************************************************************
|
||||
// Hex line editor
|
||||
//*****************************************************************************
|
||||
|
||||
#define COLORNAMES_FILE "colornames.txt"
|
||||
|
||||
QMap<QString, QString> HexLineEdit::s_defcolornames;
|
||||
QMap<QString, QString> HexLineEdit::s_usercolornames;
|
||||
|
||||
HexLineEdit::HexLineEdit(const QString &contents, QWidget *parent)
|
||||
: QLineEdit(contents, parent), m_editing(false), m_color(0, 0, 0) {}
|
||||
|
||||
bool HexLineEdit::loadDefaultColorNames(bool reload) {
|
||||
TFilePath defCTFp = TEnv::getConfigDir() + COLORNAMES_FILE;
|
||||
|
||||
// Load default color names
|
||||
try {
|
||||
if (reload || s_defcolornames.size() == 0) {
|
||||
s_defcolornames.clear();
|
||||
loadColorTableXML(s_defcolornames, defCTFp);
|
||||
}
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HexLineEdit::hasUserColorNames() {
|
||||
TFilePath userCTFp = ToonzFolder::getMyModuleDir() + COLORNAMES_FILE;
|
||||
return TFileStatus(userCTFp).doesExist();
|
||||
}
|
||||
|
||||
bool HexLineEdit::loadUserColorNames(bool reload) {
|
||||
TFilePath userCTFp = ToonzFolder::getMyModuleDir() + COLORNAMES_FILE;
|
||||
|
||||
// Load user color names (if exists...)
|
||||
if (TFileStatus(userCTFp).doesExist()) {
|
||||
try {
|
||||
if (reload || s_usercolornames.size() == 0) {
|
||||
s_usercolornames.clear();
|
||||
loadColorTableXML(s_usercolornames, userCTFp);
|
||||
}
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void HexLineEdit::updateColor() {
|
||||
if (m_color.m == 255) {
|
||||
// Opaque, omit alpha
|
||||
setText(QString("#%1%2%3")
|
||||
.arg(m_color.r, 2, 16, QLatin1Char('0'))
|
||||
.arg(m_color.g, 2, 16, QLatin1Char('0'))
|
||||
.arg(m_color.b, 2, 16, QLatin1Char('0'))
|
||||
.toUpper());
|
||||
} else {
|
||||
setText(QString("#%1%2%3%4")
|
||||
.arg(m_color.r, 2, 16, QLatin1Char('0'))
|
||||
.arg(m_color.g, 2, 16, QLatin1Char('0'))
|
||||
.arg(m_color.b, 2, 16, QLatin1Char('0'))
|
||||
.arg(m_color.m, 2, 16, QLatin1Char('0'))
|
||||
.toUpper());
|
||||
}
|
||||
}
|
||||
|
||||
void HexLineEdit::setColor(TPixel color) {
|
||||
if (m_color != color) {
|
||||
m_color = color;
|
||||
if (isVisible()) updateColor();
|
||||
}
|
||||
}
|
||||
|
||||
bool HexLineEdit::fromText(QString text) {
|
||||
static QRegExp space("\\s");
|
||||
text.remove(space);
|
||||
if (text.size() == 0) return false;
|
||||
if (text[0] == "#") return fromHex(text);
|
||||
text = text.toLower(); // table names are lowercase
|
||||
|
||||
// Find color from tables, user takes priority
|
||||
QMap<QString, QString>::const_iterator it;
|
||||
it = s_usercolornames.constFind(text);
|
||||
if (it == s_usercolornames.constEnd()) {
|
||||
it = s_defcolornames.constFind(text);
|
||||
if (it == s_defcolornames.constEnd()) return false;
|
||||
}
|
||||
|
||||
QString hexText = it.value();
|
||||
return fromHex(hexText);
|
||||
}
|
||||
|
||||
// Whitespaces can break this implementation, thankfully
|
||||
// '.fromText' already took care of it.
|
||||
bool HexLineEdit::fromHex(QString text) {
|
||||
if (text.size() == 0) return false;
|
||||
if (text[0] != "#") return false;
|
||||
text.remove(0, 1);
|
||||
bool ok;
|
||||
uint parsedValue = text.toUInt(&ok, 16);
|
||||
if (!ok) return false;
|
||||
|
||||
switch (text.length()) {
|
||||
case 8: // #RRGGBBAA
|
||||
m_color.r = parsedValue >> 24;
|
||||
m_color.g = parsedValue >> 16;
|
||||
m_color.b = parsedValue >> 8;
|
||||
m_color.m = parsedValue;
|
||||
break;
|
||||
case 6: // #RRGGBB
|
||||
m_color.r = parsedValue >> 16;
|
||||
m_color.g = parsedValue >> 8;
|
||||
m_color.b = parsedValue;
|
||||
m_color.m = 255;
|
||||
break;
|
||||
case 4: // #RGBA
|
||||
m_color.r = (parsedValue >> 12) & 15;
|
||||
m_color.r |= m_color.r << 4;
|
||||
m_color.g = (parsedValue >> 8) & 15;
|
||||
m_color.g |= m_color.g << 4;
|
||||
m_color.b = (parsedValue >> 4) & 15;
|
||||
m_color.b |= m_color.b << 4;
|
||||
m_color.m = parsedValue & 15;
|
||||
m_color.m |= m_color.m << 4;
|
||||
break;
|
||||
case 3: // #RGB
|
||||
m_color.r = (parsedValue >> 8) & 15;
|
||||
m_color.r |= m_color.r << 4;
|
||||
m_color.g = (parsedValue >> 4) & 15;
|
||||
m_color.g |= m_color.g << 4;
|
||||
m_color.b = parsedValue & 15;
|
||||
m_color.b |= m_color.b << 4;
|
||||
m_color.m = 255;
|
||||
break;
|
||||
case 2: // #VV (non-standard)
|
||||
m_color.r = parsedValue;
|
||||
m_color.g = m_color.r;
|
||||
m_color.b = m_color.r;
|
||||
m_color.m = 255;
|
||||
break;
|
||||
case 1: // #V (non-standard)
|
||||
m_color.r = parsedValue & 15;
|
||||
m_color.r |= m_color.r << 4;
|
||||
m_color.g = m_color.r;
|
||||
m_color.b = m_color.r;
|
||||
m_color.m = 255;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
updateColor();
|
||||
return true;
|
||||
}
|
||||
|
||||
void HexLineEdit::loadColorTableXML(QMap<QString, QString> &table,
|
||||
const TFilePath &fp) {
|
||||
if (!TFileStatus(fp).doesExist()) throw TException("File not found");
|
||||
|
||||
TIStream is(fp);
|
||||
if (!is) throw TException("Can't read color names");
|
||||
|
||||
std::string tagName;
|
||||
if (!is.matchTag(tagName) || tagName != "colors")
|
||||
throw TException("Not a color names file");
|
||||
|
||||
while (!is.matchEndTag()) {
|
||||
if (!is.matchTag(tagName)) throw TException("Expected tag");
|
||||
if (tagName == "color") {
|
||||
QString name, hex;
|
||||
name = QString::fromStdString(is.getTagAttribute("name"));
|
||||
std::string hexs;
|
||||
is >> hexs;
|
||||
hex = QString::fromStdString(hexs);
|
||||
if (name.size() != 0 && hex.size() != 0)
|
||||
table.insert(name.toLower(), hex);
|
||||
if (!is.matchEndTag()) throw TException("Expected end tag");
|
||||
} else
|
||||
throw TException("unexpected tag /" + tagName + "/");
|
||||
}
|
||||
}
|
||||
|
||||
void HexLineEdit::setStyle(TColorStyle &style, int index) {
|
||||
setColor(style.getColorParamValue(index));
|
||||
}
|
||||
|
||||
void HexLineEdit::mousePressEvent(QMouseEvent *event) {
|
||||
QLineEdit::mousePressEvent(event);
|
||||
// Make Ctrl key disable select all so the user can click a specific character
|
||||
// after a focus-in, this likely will fall into a hidden feature thought.
|
||||
bool ctrlDown = event->modifiers() & Qt::ControlModifier;
|
||||
if (!m_editing && !ctrlDown) selectAll();
|
||||
m_editing = true;
|
||||
}
|
||||
|
||||
void HexLineEdit::focusOutEvent(QFocusEvent *event) {
|
||||
QLineEdit::focusOutEvent(event);
|
||||
deselect();
|
||||
m_editing = false;
|
||||
}
|
||||
|
||||
void HexLineEdit::showEvent(QShowEvent *event) {
|
||||
QLineEdit::showEvent(event);
|
||||
updateColor();
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// UndoPaletteChange definition
|
||||
//*****************************************************************************
|
||||
|
@ -153,12 +360,6 @@ TPixel32 hex2Color(QString hex) {
|
|||
if (hasAlpha) color.m = values.at(3).toInt(&dummy, 16);
|
||||
return color;
|
||||
}
|
||||
void HexLineEdit::focusInEvent(QFocusEvent *event) {
|
||||
// QLineEdit::focusInEvent(event);
|
||||
selectAll();
|
||||
}
|
||||
|
||||
void HexLineEdit::showEvent(QShowEvent *event) { selectAll(); }
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -572,25 +773,13 @@ QPixmap makeLinearShading(const ColorModel &color, ColorChannel channel,
|
|||
int size, bool isVertical) {
|
||||
switch (channel) {
|
||||
case eRed:
|
||||
if (isVertical)
|
||||
return makeLinearShading(RedShadeMaker(color), size, isVertical);
|
||||
else
|
||||
return QPixmap(":Resources/grad_r.png").scaled(size, 1);
|
||||
return makeLinearShading(RedShadeMaker(color), size, isVertical);
|
||||
case eGreen:
|
||||
if (isVertical)
|
||||
return makeLinearShading(GreenShadeMaker(color), size, isVertical);
|
||||
else
|
||||
return QPixmap(":Resources/grad_g.png").scaled(size, 1);
|
||||
return makeLinearShading(GreenShadeMaker(color), size, isVertical);
|
||||
case eBlue:
|
||||
if (isVertical)
|
||||
return makeLinearShading(BlueShadeMaker(color), size, isVertical);
|
||||
else
|
||||
return QPixmap(":Resources/grad_b.png").scaled(size, 1);
|
||||
return makeLinearShading(BlueShadeMaker(color), size, isVertical);
|
||||
case eAlpha:
|
||||
if (isVertical)
|
||||
return makeLinearShading(AlphaShadeMaker(color), size, isVertical);
|
||||
else
|
||||
return QPixmap(":Resources/grad_m.png").scaled(size, 1);
|
||||
return makeLinearShading(AlphaShadeMaker(color), size, isVertical);
|
||||
case eHue:
|
||||
return makeLinearShading(HueShadeMaker(color), size, isVertical);
|
||||
case eSaturation:
|
||||
|
@ -1077,8 +1266,12 @@ void SquaredColorWheel::setChannel(int channel) {
|
|||
// ColorSlider implementation
|
||||
//*****************************************************************************
|
||||
|
||||
// Adquire size later...
|
||||
int ColorSlider::s_chandle_size = -1;
|
||||
int ColorSlider::s_chandle_tall = -1;
|
||||
|
||||
ColorSlider::ColorSlider(Qt::Orientation orientation, QWidget *parent)
|
||||
: QSlider(orientation, parent), m_channel(eRed), m_color() {
|
||||
: QAbstractSlider(parent), m_channel(eRed), m_color() {
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
setOrientation(orientation);
|
||||
|
@ -1088,6 +1281,13 @@ ColorSlider::ColorSlider(Qt::Orientation orientation, QWidget *parent)
|
|||
setMinimumHeight(7);
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
|
||||
// Get color handle size once
|
||||
if (s_chandle_size == -1) {
|
||||
QImage chandle = QImage(":Resources/h_chandle_arrow.svg");
|
||||
s_chandle_size = chandle.width();
|
||||
s_chandle_tall = chandle.height();
|
||||
}
|
||||
|
||||
// Attenzione: necessario per poter individuare l'oggetto nel file di
|
||||
// definizione dello stile
|
||||
setObjectName("colorSlider");
|
||||
|
@ -1118,21 +1318,25 @@ void ColorSlider::paintEvent(QPaintEvent *event) {
|
|||
|
||||
bool isVertical = orientation() == Qt::Vertical;
|
||||
|
||||
if (!isVertical) h -= 5;
|
||||
if (isVertical) {
|
||||
y += s_chandle_size / 2;
|
||||
h -= s_chandle_size;
|
||||
w -= 3;
|
||||
} else {
|
||||
x += s_chandle_size / 2;
|
||||
w -= s_chandle_size;
|
||||
h -= 3;
|
||||
}
|
||||
|
||||
QPixmap bgPixmap =
|
||||
makeLinearShading(m_color, m_channel, isVertical ? h : w, isVertical);
|
||||
|
||||
if (m_channel == eAlpha) {
|
||||
static QPixmap checkboard(":Resources/backg.png");
|
||||
p.drawTiledPixmap(x + (handleSize / 2), y + 1, w - handleSize, h,
|
||||
checkboard);
|
||||
p.drawTiledPixmap(x, y, w, h, DVGui::CommonChessboard::instance()->getPixmap());
|
||||
}
|
||||
|
||||
if (!bgPixmap.isNull()) {
|
||||
p.drawTiledPixmap(x + (handleSize / 2), y + 1, w - handleSize, h, bgPixmap);
|
||||
p.setPen(Qt::black);
|
||||
p.drawRect(x + (handleSize / 2), y + 1, x + w - handleSize, y + h);
|
||||
p.drawTiledPixmap(x, y, w, h, bgPixmap);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -1140,59 +1344,20 @@ void ColorSlider::paintEvent(QPaintEvent *event) {
|
|||
In this case we draw "manually" the slider handle at correct position
|
||||
*/
|
||||
if (isVertical) {
|
||||
int pos = QStyle::sliderPositionFromValue(minimum(), maximum(), value(),
|
||||
h - 9, true);
|
||||
static QPixmap vHandlePixmap(":Resources/v_chandle.png");
|
||||
p.drawPixmap(0, pos, vHandlePixmap);
|
||||
static QPixmap vHandlePixmap = svgToPixmap(":Resources/v_chandle_arrow.svg");
|
||||
int pos = QStyle::sliderPositionFromValue(0, maximum(), value(), h, true);
|
||||
p.drawPixmap(width() - s_chandle_tall, pos, vHandlePixmap);
|
||||
} else {
|
||||
static QPixmap hHandleUpPm(":Resources/h_chandle_up.svg");
|
||||
static QPixmap hHandleDownPm(":Resources/h_chandle_down.svg");
|
||||
static QPixmap hHandleCenterPm(":Resources/h_chandle_center.svg");
|
||||
int pos = QStyle::sliderPositionFromValue(
|
||||
0, maximum(), value(), width() - hHandleCenterPm.width(), false);
|
||||
p.drawPixmap(pos, 0, hHandleUpPm);
|
||||
p.drawPixmap(pos, height() - hHandleDownPm.height(), hHandleDownPm);
|
||||
p.drawPixmap(pos, hHandleUpPm.height(), hHandleCenterPm.width(),
|
||||
height() - hHandleUpPm.height() - hHandleDownPm.height(),
|
||||
hHandleCenterPm);
|
||||
static QPixmap hHandlePixmap = svgToPixmap(":Resources/h_chandle_arrow.svg");
|
||||
int pos = QStyle::sliderPositionFromValue(0, maximum(), value(), w, false);
|
||||
p.drawPixmap(pos, height() - s_chandle_tall, hHandlePixmap);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ColorSlider::mousePressEvent(QMouseEvent *event) {
|
||||
// vogliamo che facendo click sullo slider, lontano dall'handle
|
||||
// l'handle salti subito nella posizione giusta invece di far partire
|
||||
// l'autorepeat.
|
||||
//
|
||||
// cfr. qslider.cpp:429: sembra che questo comportamento si possa ottenere
|
||||
// anche con SH_Slider_AbsoluteSetButtons. Ma non capisco come si possa fare
|
||||
// per definire quest hint
|
||||
QStyleOptionSlider opt;
|
||||
initStyleOption(&opt);
|
||||
const QRect handleRect = style()->subControlRect(
|
||||
QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
|
||||
if (!handleRect.contains(event->pos())) {
|
||||
const QPoint handleCenter = handleRect.center();
|
||||
const QRect grooveRect = style()->subControlRect(
|
||||
QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, this);
|
||||
int pos, span;
|
||||
bool upsideDown = false;
|
||||
if (opt.orientation == Qt::Vertical) {
|
||||
upsideDown = true;
|
||||
int handleSize = handleRect.height();
|
||||
pos = event->pos().y();
|
||||
span = grooveRect.height();
|
||||
} else {
|
||||
int handleSize = QPixmap(":Resources/h_chandle_center.svg").width();
|
||||
pos = event->pos().x();
|
||||
span = grooveRect.width();
|
||||
}
|
||||
int value = QStyle::sliderValueFromPosition(minimum(), maximum(), pos, span,
|
||||
upsideDown);
|
||||
setValue(value);
|
||||
}
|
||||
QSlider::mousePressEvent(event);
|
||||
chandleMouse(event->pos().x(), event->pos().y());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -1201,6 +1366,26 @@ void ColorSlider::mouseReleaseEvent(QMouseEvent *event) {
|
|||
emit sliderReleased();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ColorSlider::mouseMoveEvent(QMouseEvent *event) {
|
||||
chandleMouse(event->pos().x(), event->pos().y());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ColorSlider::chandleMouse(int mouse_x, int mouse_y) {
|
||||
if (orientation() == Qt::Vertical) {
|
||||
int pos = mouse_y - s_chandle_size / 2;
|
||||
int span = height() - s_chandle_size;
|
||||
setValue(QStyle::sliderValueFromPosition(0, maximum(), pos, span, true));
|
||||
} else {
|
||||
int pos = mouse_x - s_chandle_size / 2;
|
||||
int span = width() - s_chandle_size;
|
||||
setValue(QStyle::sliderValueFromPosition(0, maximum(), pos, span, false));
|
||||
}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// ArrowButton implementation
|
||||
//*****************************************************************************
|
||||
|
@ -1534,7 +1719,7 @@ StyleEditorPage::StyleEditorPage(QWidget *parent) : QFrame(parent) {
|
|||
|
||||
ColorParameterSelector::ColorParameterSelector(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_index(-1)
|
||||
, m_index(0)
|
||||
, m_chipSize(21, 21)
|
||||
, m_chipOrigin(0, 1)
|
||||
, m_chipDelta(21, 0) {
|
||||
|
@ -1588,7 +1773,7 @@ void ColorParameterSelector::setStyle(const TColorStyle &style) {
|
|||
|
||||
void ColorParameterSelector::clear() {
|
||||
if (m_colors.size() != 0) m_colors.clear();
|
||||
m_index = -1;
|
||||
m_index = 0;
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -1599,7 +1784,7 @@ void ColorParameterSelector::mousePressEvent(QMouseEvent *event) {
|
|||
int index = pos.x() / m_chipDelta.x();
|
||||
QRect chipRect(index * m_chipDelta, m_chipSize);
|
||||
if (chipRect.contains(pos)) {
|
||||
m_index = index;
|
||||
if (index < m_colors.size()) m_index = index;
|
||||
emit colorParamChanged();
|
||||
update();
|
||||
}
|
||||
|
@ -4125,28 +4310,25 @@ StyleEditor::StyleEditor(PaletteController *paletteController, QWidget *parent)
|
|||
m_hsvAction = new QAction(tr("HSV"), this);
|
||||
m_alphaAction = new QAction(tr("Alpha"), this);
|
||||
m_rgbAction = new QAction(tr("RGB"), this);
|
||||
m_hexAction = new QAction(tr("Hex"), this);
|
||||
|
||||
m_wheelAction->setCheckable(true);
|
||||
m_hsvAction->setCheckable(true);
|
||||
m_alphaAction->setCheckable(true);
|
||||
m_rgbAction->setCheckable(true);
|
||||
m_hexAction->setCheckable(true);
|
||||
m_wheelAction->setChecked(true);
|
||||
m_hsvAction->setChecked(false);
|
||||
m_alphaAction->setChecked(true);
|
||||
m_rgbAction->setChecked(false);
|
||||
m_hexAction->setChecked(false);
|
||||
menu->addAction(m_wheelAction);
|
||||
menu->addAction(m_alphaAction);
|
||||
menu->addAction(m_hsvAction);
|
||||
menu->addAction(m_rgbAction);
|
||||
|
||||
m_hexAction = new QWidgetAction(this);
|
||||
m_hexLineEdit = new HexLineEdit("", this);
|
||||
m_hexLineEdit->setObjectName("HexLineEdit");
|
||||
m_hexAction->setDefaultWidget(m_hexLineEdit);
|
||||
m_hexAction->setText(" ");
|
||||
menu->addAction(m_hexAction);
|
||||
|
||||
QFontMetrics fm(QApplication::font());
|
||||
m_hexLineEdit->setFixedWidth(75);
|
||||
|
||||
m_plainColorPage->m_hsvFrame->setVisible(false);
|
||||
m_plainColorPage->m_rgbFrame->setVisible(false);
|
||||
|
@ -4223,6 +4405,10 @@ StyleEditor::StyleEditor(PaletteController *paletteController, QWidget *parent)
|
|||
m_plainColorPage->m_alphaFrame, SLOT(setVisible(bool)));
|
||||
ret = ret && connect(m_rgbAction, SIGNAL(toggled(bool)),
|
||||
m_plainColorPage->m_rgbFrame, SLOT(setVisible(bool)));
|
||||
ret = ret && connect(m_hexAction, SIGNAL(toggled(bool)), m_hexLineEdit,
|
||||
SLOT(setVisible(bool)));
|
||||
ret = ret && connect(m_hexLineEdit, SIGNAL(editingFinished()), this,
|
||||
SLOT(onHexChanged()));
|
||||
ret = ret && connect(m_toggleOrientationAction, SIGNAL(triggered()),
|
||||
m_plainColorPage, SLOT(toggleOrientation()));
|
||||
ret = ret && connect(m_toggleOrientationAction, SIGNAL(triggered()), this,
|
||||
|
@ -4263,8 +4449,8 @@ void StyleEditor::setPaletteHandle(TPaletteHandle* paletteHandle)
|
|||
QFrame *StyleEditor::createBottomWidget() {
|
||||
QFrame *bottomWidget = new QFrame(this);
|
||||
m_autoButton = new QPushButton(tr("Auto"));
|
||||
m_oldColor = new DVGui::StyleSample(this, 42, 30);
|
||||
m_newColor = new DVGui::StyleSample(this, 32, 32);
|
||||
m_oldColor = new DVGui::StyleSample(this, 42, 24);
|
||||
m_newColor = new DVGui::StyleSample(this, 42, 24);
|
||||
m_applyButton = new QPushButton(tr("Apply"));
|
||||
m_fillColorWidget = new QFrame(this);
|
||||
|
||||
|
@ -4283,9 +4469,18 @@ QFrame *StyleEditor::createBottomWidget() {
|
|||
m_oldColor->setToolTip(tr("Return To Previous Style"));
|
||||
m_oldColor->enableClick(true);
|
||||
m_oldColor->setEnable(false);
|
||||
m_oldColor->setSystemChessboard(true);
|
||||
m_oldColor->setCloneStyle(true);
|
||||
m_newColor->setToolTip(tr("Current Style"));
|
||||
m_newColor->enableClick(true);
|
||||
m_newColor->setEnable(false);
|
||||
m_newColor->setFixedWidth(32);
|
||||
m_newColor->setSystemChessboard(true);
|
||||
|
||||
m_hexLineEdit = new HexLineEdit("", this);
|
||||
m_hexLineEdit->setObjectName("HexLineEdit");
|
||||
m_hexLineEdit->setFixedWidth(75);
|
||||
m_hexLineEdit->loadDefaultColorNames(false);
|
||||
m_hexLineEdit->loadUserColorNames(false);
|
||||
|
||||
m_fillColorWidget->setFixedHeight(32);
|
||||
m_fillColorWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
@ -4303,11 +4498,14 @@ QFrame *StyleEditor::createBottomWidget() {
|
|||
hLayout->setSpacing(0);
|
||||
{
|
||||
hLayout->addWidget(m_autoButton);
|
||||
// hLayout->addSpacing(2);
|
||||
hLayout->addWidget(m_applyButton);
|
||||
// hLayout->addSpacing(2);
|
||||
hLayout->addWidget(m_newColor, 1);
|
||||
hLayout->addWidget(m_oldColor, 0);
|
||||
hLayout->addWidget(m_fillColorWidget, 0);
|
||||
hLayout->addSpacing(2);
|
||||
hLayout->addWidget(m_hexLineEdit);
|
||||
m_oldColor->hide();
|
||||
}
|
||||
mainLayout->addLayout(hLayout);
|
||||
|
@ -4328,9 +4526,10 @@ QFrame *StyleEditor::createBottomWidget() {
|
|||
// SLOT(applyButtonClicked()));
|
||||
ret = ret && connect(m_autoButton, SIGNAL(toggled(bool)), this,
|
||||
SLOT(autoCheckChanged(bool)));
|
||||
// ret = ret && connect(m_oldColor, SIGNAL(clicked(const TColorStyle &)),
|
||||
// this,
|
||||
// SLOT(onOldStyleClicked(const TColorStyle &)));
|
||||
// ret = ret && connect(m_oldColor, SIGNAL(clicked()), this,
|
||||
// SLOT(onOldStyleClicked()));
|
||||
// ret = ret && connect(m_newColor, SIGNAL(clicked()), this,
|
||||
// SLOT(onNewStyleClicked()));
|
||||
assert(ret);
|
||||
|
||||
return bottomWidget;
|
||||
|
@ -4526,6 +4725,7 @@ void StyleEditor::showEvent(QShowEvent *) {
|
|||
m_plainColorPage->m_alphaFrame->setVisible(m_alphaAction->isChecked());
|
||||
m_plainColorPage->m_hsvFrame->setVisible(m_hsvAction->isChecked());
|
||||
m_plainColorPage->m_rgbFrame->setVisible(m_rgbAction->isChecked());
|
||||
m_hexLineEdit->setVisible(m_hexAction->isChecked());
|
||||
updateOrientationButton();
|
||||
assert(ret);
|
||||
}
|
||||
|
@ -4807,7 +5007,7 @@ void StyleEditor::onStyleChanged(bool isDragging) {
|
|||
m_plainColorPage->setColor(*m_editedStyle, getColorParam());
|
||||
m_colorParameterSelector->setStyle(*m_editedStyle);
|
||||
m_settingsPage->setStyle(m_editedStyle);
|
||||
m_newColor->setStyle(*m_editedStyle);
|
||||
m_newColor->setStyle(*m_editedStyle, getColorParam());
|
||||
int tag = m_editedStyle->getTagId();
|
||||
if (tag == 4 || tag == 2000 || tag == 2800 || getStyleIndex() == 0) {
|
||||
m_fillColorWidget->hide();
|
||||
|
@ -4828,7 +5028,9 @@ void StyleEditor::onStyleChanged(bool isDragging) {
|
|||
m_fillColorWidget->setStyleSheet(styleSheet.arg(myColor));
|
||||
}
|
||||
m_oldColor->setStyle(
|
||||
*m_oldStyle); // This line is needed for proper undo behavior
|
||||
*m_oldStyle,
|
||||
getColorParam()); // This line is needed for proper undo behavior
|
||||
m_hexLineEdit->setStyle(*m_editedStyle, getColorParam());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -4917,7 +5119,7 @@ void StyleEditor::onColorChanged(const ColorModel &color, bool isDragging) {
|
|||
delete style;
|
||||
}
|
||||
|
||||
m_newColor->setStyle(*m_editedStyle);
|
||||
m_newColor->setStyle(*m_editedStyle, getColorParam());
|
||||
int tag = m_editedStyle->getTagId();
|
||||
if (tag == 4 || tag == 2000 || tag == 2800 || getStyleIndex() == 0) {
|
||||
m_fillColorWidget->hide();
|
||||
|
@ -4937,6 +5139,7 @@ void StyleEditor::onColorChanged(const ColorModel &color, bool isDragging) {
|
|||
m_fillColorWidget->setStyleSheet(styleSheet.arg(myColor));
|
||||
}
|
||||
m_colorParameterSelector->setStyle(*m_editedStyle);
|
||||
m_hexLineEdit->setStyle(*m_editedStyle, getColorParam());
|
||||
|
||||
if (m_autoButton->isChecked()) {
|
||||
copyEditedStyleToPalette(isDragging);
|
||||
|
@ -4958,6 +5161,7 @@ void StyleEditor::enable(bool enabled, bool enabledOnlyFirstTab,
|
|||
m_applyButton->setDisabled(!enabled || m_autoButton->isChecked());
|
||||
m_oldColor->setEnable(enabled);
|
||||
m_newColor->setEnable(enabled);
|
||||
m_hexLineEdit->setEnabled(enabled);
|
||||
|
||||
if (enabled == false) {
|
||||
m_oldColor->setColor(TPixel32::Transparent);
|
||||
|
@ -4997,13 +5201,19 @@ void StyleEditor::checkPaletteLock() {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void StyleEditor::onOldStyleClicked(const TColorStyle &) {
|
||||
void StyleEditor::onOldStyleClicked() {
|
||||
if (!m_enabled) return;
|
||||
selectStyle(*(m_oldColor->getStyle()));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void StyleEditor::onNewStyleClicked() {
|
||||
applyButtonClicked();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void StyleEditor::setPage(int index) {
|
||||
if (!m_enabledFirstAndLastTab) {
|
||||
if (index == 1)
|
||||
|
@ -5081,8 +5291,9 @@ bool StyleEditor::setStyle(TColorStyle *currentStyle) {
|
|||
if (currentStyle) {
|
||||
m_colorParameterSelector->setStyle(*currentStyle);
|
||||
m_plainColorPage->setColor(*currentStyle, getColorParam());
|
||||
m_oldColor->setStyle(*currentStyle);
|
||||
m_newColor->setStyle(*currentStyle);
|
||||
m_oldColor->setStyle(*currentStyle, getColorParam());
|
||||
m_newColor->setStyle(*currentStyle, getColorParam());
|
||||
m_hexLineEdit->setStyle(*m_editedStyle, getColorParam());
|
||||
|
||||
int tag = currentStyle->getTagId();
|
||||
if (tag == 4 || tag == 2000 || tag == 2800 || getStyleIndex() == 0) {
|
||||
|
@ -5166,7 +5377,7 @@ void StyleEditor::selectStyle(const TColorStyle &newStyle) {
|
|||
}
|
||||
|
||||
// Update editor widgets
|
||||
m_newColor->setStyle(*m_editedStyle);
|
||||
m_newColor->setStyle(*m_editedStyle, getColorParam());
|
||||
int tag = m_editedStyle->getTagId();
|
||||
if (tag == 4 || tag == 2000 || tag == 2800 || getStyleIndex() == 0) {
|
||||
m_fillColorWidget->hide();
|
||||
|
@ -5188,6 +5399,7 @@ void StyleEditor::selectStyle(const TColorStyle &newStyle) {
|
|||
m_plainColorPage->setColor(*m_editedStyle, getColorParam());
|
||||
m_colorParameterSelector->setStyle(*m_editedStyle);
|
||||
m_settingsPage->setStyle(m_editedStyle);
|
||||
m_hexLineEdit->setStyle(*m_editedStyle, getColorParam());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -5212,7 +5424,8 @@ void StyleEditor::addToPalette(const TColorStyle &newStyle) {
|
|||
palette->setDirtyFlag(true);
|
||||
|
||||
// Update editor widgets
|
||||
m_newColor->setStyle(*m_editedStyle);
|
||||
m_newColor->setStyle(*m_editedStyle, getColorParam());
|
||||
m_oldColor->setStyle(*m_editedStyle, getColorParam());
|
||||
int tag = m_editedStyle->getTagId();
|
||||
if (tag == 4 || tag == 2000 || tag == 2800 || getStyleIndex() == 0) {
|
||||
m_fillColorWidget->hide();
|
||||
|
@ -5234,6 +5447,7 @@ void StyleEditor::addToPalette(const TColorStyle &newStyle) {
|
|||
m_plainColorPage->setColor(*m_editedStyle, getColorParam());
|
||||
m_colorParameterSelector->setStyle(*m_editedStyle);
|
||||
m_settingsPage->setStyle(m_editedStyle);
|
||||
m_hexLineEdit->setStyle(*m_editedStyle, getColorParam());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -5250,8 +5464,12 @@ void StyleEditor::onColorParamChanged() {
|
|||
if (TColorStyle *currentStyle = palette->getStyle(styleIndex)) {
|
||||
setEditedStyleToStyle(currentStyle);
|
||||
|
||||
m_newColor->setStyle(*m_editedStyle, getColorParam());
|
||||
m_oldColor->setStyle(*m_editedStyle, getColorParam());
|
||||
m_plainColorPage->setColor(*m_editedStyle, getColorParam());
|
||||
m_colorParameterSelector->setStyle(*m_editedStyle);
|
||||
m_settingsPage->setStyle(m_editedStyle);
|
||||
m_hexLineEdit->setStyle(*m_editedStyle, getColorParam());
|
||||
}
|
||||
int tag = m_editedStyle->getTagId();
|
||||
if (tag == 4 || tag == 2000 || tag == 2800 || getStyleIndex() == 0) {
|
||||
|
@ -5286,7 +5504,7 @@ void StyleEditor::onParamStyleChanged(bool isDragging) {
|
|||
if (m_autoButton->isChecked()) copyEditedStyleToPalette(isDragging);
|
||||
|
||||
m_editedStyle->invalidateIcon(); // Refresh the new color icon
|
||||
m_newColor->setStyle(*m_editedStyle); //
|
||||
m_newColor->setStyle(*m_editedStyle, getColorParam());
|
||||
|
||||
int tag = m_editedStyle->getTagId();
|
||||
if (tag == 4 || tag == 2000 || tag == 2800 || getStyleIndex() == 0) {
|
||||
|
@ -5306,6 +5524,18 @@ void StyleEditor::onParamStyleChanged(bool isDragging) {
|
|||
QString styleSheet = "QFrame {background-color: rgb(%1);}";
|
||||
m_fillColorWidget->setStyleSheet(styleSheet.arg(myColor));
|
||||
}
|
||||
m_hexLineEdit->setStyle(*m_editedStyle, getColorParam());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void StyleEditor::onHexChanged() {
|
||||
if (m_hexLineEdit->fromText(m_hexLineEdit->text())) {
|
||||
ColorModel cm;
|
||||
cm.setTPixel(m_hexLineEdit->getColor());
|
||||
onColorChanged(cm, false);
|
||||
m_hexLineEdit->selectAll();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -5350,18 +5580,6 @@ void StyleEditor::onPageChanged(int index) {
|
|||
onUpdateFavorites();
|
||||
update();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void StyleEditor::onHexChanged() {
|
||||
m_hsvAction->parentWidget()->clearFocus();
|
||||
QString hex = m_hexLineEdit->text();
|
||||
if (isHex(hex)) {
|
||||
TPixel32 color = hex2Color(hex);
|
||||
ColorModel cm;
|
||||
cm.setTPixel(color);
|
||||
onColorChanged(cm, false);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QStringList StyleEditor::savePageStates(StylePageType pageType) const {
|
||||
|
@ -5456,6 +5674,7 @@ void StyleEditor::save(QSettings &settings) const {
|
|||
if (m_hsvAction->isChecked()) visibleParts |= 0x02;
|
||||
if (m_alphaAction->isChecked()) visibleParts |= 0x04;
|
||||
if (m_rgbAction->isChecked()) visibleParts |= 0x08;
|
||||
if (m_hexAction->isChecked()) visibleParts |= 0x10;
|
||||
settings.setValue("visibleParts", visibleParts);
|
||||
settings.setValue("splitterState", m_plainColorPage->getSplitterState());
|
||||
settings.setValue("texturePageStates",
|
||||
|
@ -5490,6 +5709,10 @@ void StyleEditor::load(QSettings &settings) {
|
|||
m_rgbAction->setChecked(true);
|
||||
else
|
||||
m_rgbAction->setChecked(false);
|
||||
if (visiblePartsInt & 0x10)
|
||||
m_hexAction->setChecked(true);
|
||||
else
|
||||
m_hexAction->setChecked(false);
|
||||
}
|
||||
QVariant splitterState = settings.value("splitterState");
|
||||
if (splitterState.canConvert(QVariant::ByteArray))
|
||||
|
|
|
@ -26,9 +26,8 @@
|
|||
<file>Resources/grad_g.png</file>
|
||||
<file>Resources/grad_b.png</file>
|
||||
<file>Resources/grad_m.png</file>
|
||||
<file>Resources/h_chandleDown.png</file>
|
||||
<file>Resources/h_chandleCenter.png</file>
|
||||
<file>Resources/h_chandleUp.png</file>
|
||||
<file>Resources/h_chandle_arrow.svg</file>
|
||||
<file>Resources/v_chandle_arrow.svg</file>
|
||||
<file>Resources/h_chandle_down.svg</file>
|
||||
<file>Resources/h_chandle_center.svg</file>
|
||||
<file>Resources/h_chandle_top.svg</file>
|
||||
|
|
Loading…
Reference in a new issue