mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-01 01:20:25 +00:00
Merge branch 'master'
This commit is contained in:
commit
e5f96a2bce
@ -1,5 +1,5 @@
|
|||||||
<!-- ASEPRITE -->
|
<!-- ASEPRITE -->
|
||||||
<!-- Copyright (C) 2001-2014 by David Capello -->
|
<!-- Copyright (C) 2001-2015 by David Capello -->
|
||||||
<gui>
|
<gui>
|
||||||
<window text="Canvas Size" id="canvas_size">
|
<window text="Canvas Size" id="canvas_size">
|
||||||
<vbox>
|
<vbox>
|
||||||
@ -7,9 +7,9 @@
|
|||||||
<hbox>
|
<hbox>
|
||||||
<grid columns="2">
|
<grid columns="2">
|
||||||
<label text="Width:" />
|
<label text="Width:" />
|
||||||
<entry text="0" id="width" maxsize="32" maxwidth="64" magnet="true" />
|
<entry text="0" id="width" maxsize="32" maxwidth="64" suffix="px" magnet="true" />
|
||||||
<label text="Height:" />
|
<label text="Height:" />
|
||||||
<entry text="0" id="height" maxsize="32" maxwidth="64" />
|
<entry text="0" id="height" maxsize="32" maxwidth="64" suffix="px" />
|
||||||
<hbox filler="true" cell_hspan="2" />
|
<hbox filler="true" cell_hspan="2" />
|
||||||
</grid>
|
</grid>
|
||||||
<buttonset columns="3" id="dir">
|
<buttonset columns="3" id="dir">
|
||||||
@ -28,16 +28,16 @@
|
|||||||
<separator text="Borders:" left="true" horizontal="true" />
|
<separator text="Borders:" left="true" horizontal="true" />
|
||||||
<grid columns="4">
|
<grid columns="4">
|
||||||
<label text="Left:" />
|
<label text="Left:" />
|
||||||
<entry text="0" id="left" maxsize="32" maxwidth="64" tooltip="Columns to be added/removed in the left side. Use a negative number to remove columns." />
|
<entry text="0" id="left" maxsize="32" maxwidth="64" suffix="px" tooltip="Columns to be added/removed in the left side. Use a negative number to remove columns." />
|
||||||
|
|
||||||
<label text="Top:" />
|
<label text="Top:" />
|
||||||
<entry text="0" id="top" maxsize="32" maxwidth="64" tooltip="Rows to be added/removed in the top side. Use a negative number to remove rows." />
|
<entry text="0" id="top" maxsize="32" maxwidth="64" suffix="px" tooltip="Rows to be added/removed in the top side. Use a negative number to remove rows." />
|
||||||
|
|
||||||
<label text="Right:" />
|
<label text="Right:" />
|
||||||
<entry text="0" id="right" maxsize="32" maxwidth="64" tooltip="Columns to be added/removed in the right side. Use a negative number to remove columns." />
|
<entry text="0" id="right" maxsize="32" maxwidth="64" suffix="px" tooltip="Columns to be added/removed in the right side. Use a negative number to remove columns." />
|
||||||
|
|
||||||
<label text="Bottom:" />
|
<label text="Bottom:" />
|
||||||
<entry text="0" id="bottom" maxsize="32" maxwidth="64" tooltip="Rows to be added/removed in the bottom side. Use a negative number to remove rows." />
|
<entry text="0" id="bottom" maxsize="32" maxwidth="64" suffix="px" tooltip="Rows to be added/removed in the bottom side. Use a negative number to remove rows." />
|
||||||
</grid>
|
</grid>
|
||||||
|
|
||||||
<separator horizontal="true" />
|
<separator horizontal="true" />
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
<separator text="Size:" left="true" horizontal="true" />
|
<separator text="Size:" left="true" horizontal="true" />
|
||||||
<grid columns="2">
|
<grid columns="2">
|
||||||
<label text="Width:" />
|
<label text="Width:" />
|
||||||
<entry id="width" maxsize="8" magnet="true" cell_align="horizontal" tooltip="Width of the new sprite (in pixels)" />
|
<entry id="width" maxsize="8" magnet="true" cell_align="horizontal" suffix="px" />
|
||||||
<label text="Height:" />
|
<label text="Height:" />
|
||||||
<entry id="height" maxsize="8" cell_align="horizontal" tooltip="Height of the new sprite (in pixels)" />
|
<entry id="height" maxsize="8" cell_align="horizontal" suffix="px" />
|
||||||
</grid>
|
</grid>
|
||||||
|
|
||||||
<separator text="Color Mode:" left="true" horizontal="true" />
|
<separator text="Color Mode:" left="true" horizontal="true" />
|
||||||
|
@ -59,8 +59,12 @@ void SwitchColorsCommand::onExecute(Context* context)
|
|||||||
ColorBar* colorbar = ColorBar::instance();
|
ColorBar* colorbar = ColorBar::instance();
|
||||||
app::Color fg = colorbar->getFgColor();
|
app::Color fg = colorbar->getFgColor();
|
||||||
app::Color bg = colorbar->getBgColor();
|
app::Color bg = colorbar->getBgColor();
|
||||||
colorbar->setFgColor(bg);
|
|
||||||
|
// Change the background and then the foreground color so the color
|
||||||
|
// spectrum and color wheel shows the foreground color as the
|
||||||
|
// selected one.
|
||||||
colorbar->setBgColor(fg);
|
colorbar->setBgColor(fg);
|
||||||
|
colorbar->setFgColor(bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command* CommandFactory::createSwitchColorsCommand()
|
Command* CommandFactory::createSwitchColorsCommand()
|
||||||
|
@ -318,6 +318,7 @@ void ColorBar::setColorSelector(ColorSelector selector)
|
|||||||
if (!m_spectrum) {
|
if (!m_spectrum) {
|
||||||
m_spectrum = new ColorSpectrum;
|
m_spectrum = new ColorSpectrum;
|
||||||
m_spectrum->setExpansive(true);
|
m_spectrum->setExpansive(true);
|
||||||
|
m_spectrum->selectColor(m_fgColor.getColor());
|
||||||
m_spectrum->ColorChange.connect(&ColorBar::onPickSpectrum, this);
|
m_spectrum->ColorChange.connect(&ColorBar::onPickSpectrum, this);
|
||||||
m_selectorPlaceholder.addChild(m_spectrum);
|
m_selectorPlaceholder.addChild(m_spectrum);
|
||||||
}
|
}
|
||||||
@ -772,6 +773,9 @@ void ColorBar::onColorButtonChange(const app::Color& color)
|
|||||||
m_paletteView.invalidate();
|
m_paletteView.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_spectrum && m_spectrum->isVisible())
|
||||||
|
m_spectrum->selectColor(color);
|
||||||
|
|
||||||
if (m_wheel && m_wheel->isVisible())
|
if (m_wheel && m_wheel->isVisible())
|
||||||
m_wheel->selectColor(color);
|
m_wheel->selectColor(color);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "app/color_utils.h"
|
#include "app/color_utils.h"
|
||||||
#include "app/ui/skin/skin_theme.h"
|
#include "app/ui/skin/skin_theme.h"
|
||||||
#include "app/ui/status_bar.h"
|
#include "app/ui/status_bar.h"
|
||||||
|
#include "she/surface.h"
|
||||||
#include "ui/graphics.h"
|
#include "ui/graphics.h"
|
||||||
#include "ui/message.h"
|
#include "ui/message.h"
|
||||||
#include "ui/paint_event.h"
|
#include "ui/paint_event.h"
|
||||||
@ -69,6 +70,12 @@ app::Color ColorSpectrum::pickColor(const gfx::Point& pos) const
|
|||||||
MID(0, val, 100));
|
MID(0, val, 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColorSpectrum::selectColor(const app::Color& color)
|
||||||
|
{
|
||||||
|
m_color = color;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
void ColorSpectrum::onPreferredSize(PreferredSizeEvent& ev)
|
void ColorSpectrum::onPreferredSize(PreferredSizeEvent& ev)
|
||||||
{
|
{
|
||||||
ev.setPreferredSize(gfx::Size(32*ui::guiscale(), 32*ui::guiscale()));
|
ev.setPreferredSize(gfx::Size(32*ui::guiscale(), 32*ui::guiscale()));
|
||||||
@ -122,6 +129,20 @@ void ColorSpectrum::onPaint(ui::PaintEvent& ev)
|
|||||||
g->putPixel(color, rc.x+x, rc.y+y);
|
g->putPixel(color, rc.x+x, rc.y+y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_color.getType() != app::Color::MaskType) {
|
||||||
|
int hue = m_color.getHue();
|
||||||
|
int sat = m_color.getSaturation();
|
||||||
|
int val = m_color.getValue();
|
||||||
|
int lit = (200 - sat) * val / 200;
|
||||||
|
gfx::Point pos(rc.x + hue * rc.w / 360,
|
||||||
|
rc.y + rc.h - (lit * rc.h / 100));
|
||||||
|
|
||||||
|
she::Surface* icon = theme->parts.colorWheelIndicator()->getBitmap(0);
|
||||||
|
g->drawRgbaSurface(icon,
|
||||||
|
pos.x-icon->width()/2,
|
||||||
|
pos.y-icon->height()/2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ColorSpectrum::onProcessMessage(ui::Message* msg)
|
bool ColorSpectrum::onProcessMessage(ui::Message* msg)
|
||||||
|
@ -22,6 +22,7 @@ namespace app {
|
|||||||
~ColorSpectrum();
|
~ColorSpectrum();
|
||||||
|
|
||||||
app::Color pickColor(const gfx::Point& pos) const;
|
app::Color pickColor(const gfx::Point& pos) const;
|
||||||
|
void selectColor(const app::Color& color);
|
||||||
|
|
||||||
// Signals
|
// Signals
|
||||||
Signal2<void, const app::Color&, ui::MouseButtons> ColorChange;
|
Signal2<void, const app::Color&, ui::MouseButtons> ColorChange;
|
||||||
@ -31,6 +32,9 @@ namespace app {
|
|||||||
void onResize(ui::ResizeEvent& ev) override;
|
void onResize(ui::ResizeEvent& ev) override;
|
||||||
void onPaint(ui::PaintEvent& ev) override;
|
void onPaint(ui::PaintEvent& ev) override;
|
||||||
bool onProcessMessage(ui::Message* msg) override;
|
bool onProcessMessage(ui::Message* msg) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
app::Color m_color;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -901,8 +901,7 @@ void SkinTheme::paintEntry(PaintEvent& ev)
|
|||||||
gfx::Rect bounds = widget->getClientBounds();
|
gfx::Rect bounds = widget->getClientBounds();
|
||||||
bool password = widget->isPassword();
|
bool password = widget->isPassword();
|
||||||
int scroll, caret, state, selbeg, selend;
|
int scroll, caret, state, selbeg, selend;
|
||||||
std::string textString = widget->getText() + widget->getSuffix();
|
const std::string& textString = widget->getText();
|
||||||
int suffixIndex = widget->getTextLength();
|
|
||||||
int c, ch, x, y, w;
|
int c, ch, x, y, w;
|
||||||
int caret_x;
|
int caret_x;
|
||||||
|
|
||||||
@ -929,7 +928,6 @@ void SkinTheme::paintEntry(PaintEvent& ev)
|
|||||||
|
|
||||||
base::utf8_const_iterator utf8_it = base::utf8_const_iterator(textString.begin());
|
base::utf8_const_iterator utf8_it = base::utf8_const_iterator(textString.begin());
|
||||||
int textlen = base::utf8_length(textString);
|
int textlen = base::utf8_length(textString);
|
||||||
|
|
||||||
if (scroll < textlen)
|
if (scroll < textlen)
|
||||||
utf8_it += scroll;
|
utf8_it += scroll;
|
||||||
|
|
||||||
@ -955,15 +953,6 @@ void SkinTheme::paintEntry(PaintEvent& ev)
|
|||||||
fg = colors.disabled();
|
fg = colors.disabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Suffix
|
|
||||||
if (c >= suffixIndex) {
|
|
||||||
if (widget->hasFocus())
|
|
||||||
break;
|
|
||||||
|
|
||||||
bg = ColorNone;
|
|
||||||
fg = colors.entrySuffix();
|
|
||||||
}
|
|
||||||
|
|
||||||
w = g->measureChar(ch).w;
|
w = g->measureChar(ch).w;
|
||||||
if (x+w > bounds.x2()-3)
|
if (x+w > bounds.x2()-3)
|
||||||
return;
|
return;
|
||||||
@ -977,6 +966,20 @@ void SkinTheme::paintEntry(PaintEvent& ev)
|
|||||||
drawEntryCaret(g, widget, caret_x, y);
|
drawEntryCaret(g, widget, caret_x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw suffix if there is enough space
|
||||||
|
if (!widget->getSuffix().empty()) {
|
||||||
|
Rect sufBounds(x, y,
|
||||||
|
bounds.x2()-3*guiscale()-x,
|
||||||
|
widget->getTextHeight());
|
||||||
|
IntersectClip clip(g, sufBounds);
|
||||||
|
if (clip) {
|
||||||
|
drawTextString(
|
||||||
|
g, widget->getSuffix().c_str(),
|
||||||
|
colors.entrySuffix(), ColorNone,
|
||||||
|
widget, sufBounds, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draw the caret if it is next of the last character
|
// Draw the caret if it is next of the last character
|
||||||
if ((c == caret) && (state) &&
|
if ((c == caret) && (state) &&
|
||||||
(widget->hasFocus()) &&
|
(widget->hasFocus()) &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user