mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-11 22:14:31 +00:00
Add InkType configuration for tools
This commit is contained in:
parent
d259b5c394
commit
4f1dce5d54
@ -23,6 +23,7 @@
|
||||
#include "gfx/point.h"
|
||||
#include "gfx/rect.h"
|
||||
#include "raster/pen_type.h"
|
||||
#include "tools/ink_type.h"
|
||||
|
||||
class Document;
|
||||
class IDocumentSettings;
|
||||
@ -70,12 +71,15 @@ public:
|
||||
virtual bool getPreviewFilled() = 0;
|
||||
virtual int getSprayWidth() = 0;
|
||||
virtual int getSpraySpeed() = 0;
|
||||
virtual InkType getInkType() = 0;
|
||||
|
||||
virtual void setOpacity(int opacity) = 0;
|
||||
virtual void setTolerance(int tolerance) = 0;
|
||||
virtual void setFilled(bool state) = 0;
|
||||
virtual void setPreviewFilled(bool state) = 0;
|
||||
virtual void setSprayWidth(int width) = 0;
|
||||
virtual void setSpraySpeed(int speed) = 0;
|
||||
virtual void setInkType(InkType inkType) = 0;
|
||||
};
|
||||
|
||||
// Settings for a tool's pen
|
||||
|
@ -417,6 +417,7 @@ class UIToolSettingsImpl : public IToolSettings
|
||||
bool m_previewFilled;
|
||||
int m_spray_width;
|
||||
int m_spray_speed;
|
||||
InkType m_inkType;
|
||||
|
||||
public:
|
||||
|
||||
@ -433,6 +434,7 @@ public:
|
||||
m_previewFilled = get_config_bool(cfg_section.c_str(), "PreviewFilled", false);
|
||||
m_spray_width = 16;
|
||||
m_spray_speed = 32;
|
||||
m_inkType = (InkType)get_config_int(cfg_section.c_str(), "InkType", (int)kDefaultInk);
|
||||
|
||||
m_pen.enableSignals(false);
|
||||
m_pen.setType((PenType)get_config_int(cfg_section.c_str(), "PenType", (int)PEN_TYPE_CIRCLE));
|
||||
@ -456,6 +458,8 @@ public:
|
||||
set_config_int(cfg_section.c_str(), "PenType", m_pen.getType());
|
||||
set_config_int(cfg_section.c_str(), "PenSize", m_pen.getSize());
|
||||
set_config_int(cfg_section.c_str(), "PenAngle", m_pen.getAngle());
|
||||
set_config_int(cfg_section.c_str(), "PenAngle", m_pen.getAngle());
|
||||
set_config_int(cfg_section.c_str(), "InkType", m_inkType);
|
||||
|
||||
if (m_tool->getPointShape(0)->isSpray() ||
|
||||
m_tool->getPointShape(1)->isSpray()) {
|
||||
@ -468,19 +472,21 @@ public:
|
||||
|
||||
IPenSettings* getPen() { return &m_pen; }
|
||||
|
||||
int getOpacity() { return m_opacity; }
|
||||
int getTolerance() { return m_tolerance; }
|
||||
bool getFilled() { return m_filled; }
|
||||
bool getPreviewFilled() { return m_previewFilled; }
|
||||
int getSprayWidth() { return m_spray_width; }
|
||||
int getSpraySpeed() { return m_spray_speed; }
|
||||
int getOpacity() OVERRIDE { return m_opacity; }
|
||||
int getTolerance() OVERRIDE { return m_tolerance; }
|
||||
bool getFilled() OVERRIDE { return m_filled; }
|
||||
bool getPreviewFilled() OVERRIDE { return m_previewFilled; }
|
||||
int getSprayWidth() OVERRIDE { return m_spray_width; }
|
||||
int getSpraySpeed() OVERRIDE { return m_spray_speed; }
|
||||
InkType getInkType() OVERRIDE { return m_inkType; }
|
||||
|
||||
void setOpacity(int opacity) { m_opacity = opacity; }
|
||||
void setTolerance(int tolerance) { m_tolerance = tolerance; }
|
||||
void setFilled(bool state) { m_filled = state; }
|
||||
void setPreviewFilled(bool state) { m_previewFilled = state; }
|
||||
void setSprayWidth(int width) { m_spray_width = width; }
|
||||
void setSpraySpeed(int speed) { m_spray_speed = speed; }
|
||||
void setOpacity(int opacity) OVERRIDE { m_opacity = opacity; }
|
||||
void setTolerance(int tolerance) OVERRIDE { m_tolerance = tolerance; }
|
||||
void setFilled(bool state) OVERRIDE { m_filled = state; }
|
||||
void setPreviewFilled(bool state) OVERRIDE { m_previewFilled = state; }
|
||||
void setSprayWidth(int width) OVERRIDE { m_spray_width = width; }
|
||||
void setSpraySpeed(int speed) OVERRIDE { m_spray_speed = speed; }
|
||||
void setInkType(InkType inkType) OVERRIDE { m_inkType = inkType; }
|
||||
|
||||
private:
|
||||
std::string getCfgSection() const {
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/* ASEPRITE
|
||||
* Copyright (C) 2001-2013 David Capello
|
||||
*
|
||||
|
36
src/tools/ink_type.h
Normal file
36
src/tools/ink_type.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* ASEPRITE
|
||||
* Copyright (C) 2001-2013 David Capello
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef TOOLS_INK_TYPE_H_INCLUDED
|
||||
#define TOOLS_INK_TYPE_H_INCLUDED
|
||||
|
||||
// If you change this enumeration, you should change update the
|
||||
// ContextBar::InkTypeField() UI widget
|
||||
enum InkType {
|
||||
kDefaultInk,
|
||||
kOpaqueInk,
|
||||
kMergeInk,
|
||||
kShadingInk,
|
||||
kReplaceInk,
|
||||
kSelectionInk,
|
||||
kBlurInk,
|
||||
kJumbleInk,
|
||||
kMaxInks
|
||||
};
|
||||
|
||||
#endif // TOOLS_INK_TYPE_H_INCLUDED
|
@ -26,6 +26,7 @@
|
||||
#include "settings/settings.h"
|
||||
#include "skin/skin_theme.h"
|
||||
#include "tools/ink.h"
|
||||
#include "tools/ink_type.h"
|
||||
#include "tools/point_shape.h"
|
||||
#include "tools/tool.h"
|
||||
#include "ui/button.h"
|
||||
@ -242,26 +243,31 @@ protected:
|
||||
|
||||
class ContextBar::InkTypeField : public ComboBox
|
||||
{
|
||||
enum { kMerge, kCopy, kShade, kSelection };
|
||||
|
||||
public:
|
||||
InkTypeField() {
|
||||
// The same order as in InkType
|
||||
addItem("Default");
|
||||
addItem("Opaque");
|
||||
addItem("Merge");
|
||||
addItem("Copy");
|
||||
addItem("Shade");
|
||||
addItem("Shading");
|
||||
addItem("Replace");
|
||||
addItem("Selection");
|
||||
|
||||
setSelectedItem(0);
|
||||
addItem("Blur");
|
||||
addItem("Jumble");
|
||||
}
|
||||
|
||||
void updateSelectedInk(Ink* ink) {
|
||||
if (ink->isPaint()) setSelectedItem(kMerge);
|
||||
else if (ink->isSelection()) setSelectedItem(kSelection);
|
||||
void setInkType(InkType inkType) {
|
||||
setSelectedItem((int)inkType);
|
||||
}
|
||||
|
||||
protected:
|
||||
void onChange() OVERRIDE {
|
||||
ComboBox::onChange();
|
||||
|
||||
ISettings* settings = UIContext::instance()->getSettings();
|
||||
Tool* currentTool = settings->getCurrentTool();
|
||||
settings->getToolSettings(currentTool)
|
||||
->setInkType((InkType)getSelectedItem());
|
||||
}
|
||||
};
|
||||
|
||||
@ -395,8 +401,7 @@ void ContextBar::onCurrentToolChange()
|
||||
|
||||
m_tolerance->setTextf("%d", toolSettings->getTolerance());
|
||||
|
||||
Ink* ink = currentTool->getInk(0);
|
||||
m_inkType->updateSelectedInk(ink);
|
||||
m_inkType->setInkType(toolSettings->getInkType());
|
||||
m_inkOpacity->setTextf("%d", toolSettings->getOpacity());
|
||||
|
||||
m_sprayWidth->setValue(toolSettings->getSprayWidth());
|
||||
|
Loading…
x
Reference in New Issue
Block a user