mirror of https://github.com/aseprite/aseprite.git
Merge branch 'main' into beta
This commit is contained in:
commit
db38a56558
|
@ -227,6 +227,7 @@
|
||||||
<option id="use_native_clipboard" type="bool" default="true" />
|
<option id="use_native_clipboard" type="bool" default="true" />
|
||||||
<option id="use_native_file_dialog" type="bool" default="false" />
|
<option id="use_native_file_dialog" type="bool" default="false" />
|
||||||
<option id="use_shaders_for_color_selectors" type="bool" default="true" />
|
<option id="use_shaders_for_color_selectors" type="bool" default="true" />
|
||||||
|
<option id="hue_with_sat_value_for_color_selector" type="bool" default="false" />
|
||||||
<option id="one_finger_as_mouse_movement" type="bool" default="true" />
|
<option id="one_finger_as_mouse_movement" type="bool" default="true" />
|
||||||
<option id="load_wintab_driver" type="bool" default="false" />
|
<option id="load_wintab_driver" type="bool" default="false" />
|
||||||
<option id="flash_layer" type="bool" default="false" />
|
<option id="flash_layer" type="bool" default="false" />
|
||||||
|
|
|
@ -1407,6 +1407,7 @@ new_render_engine = New render engine for sprite editor
|
||||||
native_clipboard = Use native clipboard
|
native_clipboard = Use native clipboard
|
||||||
native_file_dialog = Use native file dialog
|
native_file_dialog = Use native file dialog
|
||||||
shaders_for_color_selectors = Use shaders for color selectors
|
shaders_for_color_selectors = Use shaders for color selectors
|
||||||
|
hue_with_sat_value = Apply Saturation/Value to Hue slider on Tint/Shade/Tone selector
|
||||||
one_finger_as_mouse_movement = Interpret one finger as mouse movement
|
one_finger_as_mouse_movement = Interpret one finger as mouse movement
|
||||||
one_finger_as_mouse_movement_tooltip = <<<END
|
one_finger_as_mouse_movement_tooltip = <<<END
|
||||||
Only for Windows 8/10 Pointer API: Interprets one finger as mouse movement
|
Only for Windows 8/10 Pointer API: Interprets one finger as mouse movement
|
||||||
|
|
|
@ -519,7 +519,10 @@
|
||||||
pref="experimental.use_shaders_for_color_selectors" />
|
pref="experimental.use_shaders_for_color_selectors" />
|
||||||
<link text="(#960)" url="https://github.com/aseprite/aseprite/issues/960" />
|
<link text="(#960)" url="https://github.com/aseprite/aseprite/issues/960" />
|
||||||
</hbox>
|
</hbox>
|
||||||
<hbox id="load_wintab_driver_box">
|
<check id="tint_shade_tone_hue_with_sat_value"
|
||||||
|
text="@.hue_with_sat_value"
|
||||||
|
pref="experimental.hue_with_sat_value_for_color_selector" />
|
||||||
|
<hbox id="load_wintab_driver_box">
|
||||||
<check id="load_wintab_driver2"
|
<check id="load_wintab_driver2"
|
||||||
text="@.load_wintab_driver"
|
text="@.load_wintab_driver"
|
||||||
tooltip="@.load_wintab_driver_tooltip" />
|
tooltip="@.load_wintab_driver_tooltip" />
|
||||||
|
|
|
@ -626,6 +626,7 @@ void ColorSelector::updateColorSpace()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SK_ENABLE_SKSL
|
#if SK_ENABLE_SKSL
|
||||||
|
|
||||||
// static
|
// static
|
||||||
const char* ColorSelector::getAlphaBarShader()
|
const char* ColorSelector::getAlphaBarShader()
|
||||||
{
|
{
|
||||||
|
@ -678,6 +679,12 @@ sk_sp<SkRuntimeEffect> ColorSelector::buildEffect(const char* code)
|
||||||
return result.effect;
|
return result.effect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColorSelector::resetBottomEffect()
|
||||||
|
{
|
||||||
|
m_bottomEffect.reset();
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SK_ENABLE_SKSL
|
#endif // SK_ENABLE_SKSL
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|
|
@ -104,6 +104,11 @@ namespace app {
|
||||||
// atomic because we need atomic bitwise operations.
|
// atomic because we need atomic bitwise operations.
|
||||||
std::atomic<int> m_paintFlags;
|
std::atomic<int> m_paintFlags;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
#if SK_ENABLE_SKSL
|
||||||
|
void resetBottomEffect();
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
app::Color getAlphaBarColor(const int u, const int umax);
|
app::Color getAlphaBarColor(const int u, const int umax);
|
||||||
void onPaintAlphaBar(ui::Graphics* g, const gfx::Rect& rc);
|
void onPaintAlphaBar(ui::Graphics* g, const gfx::Rect& rc);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "app/ui/color_tint_shade_tone.h"
|
#include "app/ui/color_tint_shade_tone.h"
|
||||||
|
|
||||||
#include "app/color_utils.h"
|
#include "app/color_utils.h"
|
||||||
|
#include "app/pref/preferences.h"
|
||||||
#include "app/ui/skin/skin_theme.h"
|
#include "app/ui/skin/skin_theme.h"
|
||||||
#include "app/util/shader_helpers.h"
|
#include "app/util/shader_helpers.h"
|
||||||
#include "ui/graphics.h"
|
#include "ui/graphics.h"
|
||||||
|
@ -26,6 +27,18 @@ using namespace ui;
|
||||||
|
|
||||||
ColorTintShadeTone::ColorTintShadeTone()
|
ColorTintShadeTone::ColorTintShadeTone()
|
||||||
{
|
{
|
||||||
|
m_conn = Preferences::instance()
|
||||||
|
.experimental.hueWithSatValueForColorSelector.AfterChange.connect(
|
||||||
|
[this](){
|
||||||
|
m_paintFlags |= AllAreasFlag;
|
||||||
|
|
||||||
|
#if SK_ENABLE_SKSL
|
||||||
|
m_bottomShader.clear();
|
||||||
|
resetBottomEffect();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
invalidate();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SK_ENABLE_SKSL
|
#if SK_ENABLE_SKSL
|
||||||
|
@ -55,12 +68,20 @@ const char* ColorTintShadeTone::getBottomBarShader()
|
||||||
m_bottomShader += "uniform half3 iRes;"
|
m_bottomShader += "uniform half3 iRes;"
|
||||||
"uniform half4 iHsv;";
|
"uniform half4 iHsv;";
|
||||||
m_bottomShader += kHSV_to_RGB_sksl;
|
m_bottomShader += kHSV_to_RGB_sksl;
|
||||||
// TODO should we display the hue bar with the current sat/value?
|
|
||||||
m_bottomShader += R"(
|
if (m_hueWithSatValue)
|
||||||
|
m_bottomShader += R"(
|
||||||
half4 main(vec2 fragcoord) {
|
half4 main(vec2 fragcoord) {
|
||||||
half h = (fragcoord.x / iRes.x);
|
half h = (fragcoord.x / iRes.x);
|
||||||
return hsv_to_rgb(half3(h, iHsv.y, iHsv.z)).rgb1;
|
return hsv_to_rgb(half3(h, iHsv.y, iHsv.z)).rgb1;
|
||||||
}
|
}
|
||||||
|
)";
|
||||||
|
else
|
||||||
|
m_bottomShader += R"(
|
||||||
|
half4 main(vec2 fragcoord) {
|
||||||
|
half h = (fragcoord.x / iRes.x);
|
||||||
|
return hsv_to_rgb(half3(h, 1.0, 1.0)).rgb1;
|
||||||
|
}
|
||||||
)";
|
)";
|
||||||
}
|
}
|
||||||
return m_bottomShader.c_str();
|
return m_bottomShader.c_str();
|
||||||
|
@ -107,11 +128,22 @@ void ColorTintShadeTone::onPaintMainArea(ui::Graphics* g, const gfx::Rect& rc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColorTintShadeTone::onPaint(ui::PaintEvent& ev)
|
||||||
|
{
|
||||||
|
m_hueWithSatValue = Preferences::instance().experimental.hueWithSatValueForColorSelector();
|
||||||
|
ColorSelector::onPaint(ev);
|
||||||
|
}
|
||||||
|
|
||||||
void ColorTintShadeTone::onPaintBottomBar(ui::Graphics* g, const gfx::Rect& rc)
|
void ColorTintShadeTone::onPaintBottomBar(ui::Graphics* g, const gfx::Rect& rc)
|
||||||
{
|
{
|
||||||
if (m_color.getType() != app::Color::MaskType) {
|
if (m_color.getType() != app::Color::MaskType) {
|
||||||
double hue = m_color.getHsvHue();
|
double hue = m_color.getHsvHue();
|
||||||
double val = m_color.getHsvValue();
|
double val;
|
||||||
|
if (m_hueWithSatValue)
|
||||||
|
val = m_color.getHsvValue();
|
||||||
|
else
|
||||||
|
val = 1.0;
|
||||||
|
|
||||||
gfx::Point pos(rc.x + int(rc.w * hue / 360.0),
|
gfx::Point pos(rc.x + int(rc.w * hue / 360.0),
|
||||||
rc.y + rc.h/2);
|
rc.y + rc.h/2);
|
||||||
paintColorIndicator(g, pos, val < 0.5);
|
paintColorIndicator(g, pos, val < 0.5);
|
||||||
|
@ -151,9 +183,16 @@ void ColorTintShadeTone::onPaintSurfaceInBgThread(
|
||||||
|
|
||||||
if (m_paintFlags & BottomBarFlag) {
|
if (m_paintFlags & BottomBarFlag) {
|
||||||
os::Paint paint;
|
os::Paint paint;
|
||||||
|
double sat, val;
|
||||||
|
|
||||||
const double sat = m_color.getHsvSaturation();
|
if (m_hueWithSatValue) {
|
||||||
const double val = m_color.getHsvValue();
|
sat = m_color.getHsvSaturation();
|
||||||
|
val = m_color.getHsvValue();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sat = 1.0;
|
||||||
|
val = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
for (int x=0; x<bottom.w && !stop; ++x) {
|
for (int x=0; x<bottom.w && !stop; ++x) {
|
||||||
paint.color(
|
paint.color(
|
||||||
|
@ -174,12 +213,17 @@ void ColorTintShadeTone::onPaintSurfaceInBgThread(
|
||||||
|
|
||||||
int ColorTintShadeTone::onNeedsSurfaceRepaint(const app::Color& newColor)
|
int ColorTintShadeTone::onNeedsSurfaceRepaint(const app::Color& newColor)
|
||||||
{
|
{
|
||||||
return
|
int flags =
|
||||||
// Only if the hue changes we have to redraw the main surface.
|
// Only if the hue changes we have to redraw the main surface.
|
||||||
(cs_double_diff(m_color.getHsvHue(), newColor.getHsvHue()) ? MainAreaFlag: 0) |
|
(cs_double_diff(m_color.getHsvHue(), newColor.getHsvHue()) ? MainAreaFlag: 0) |
|
||||||
(cs_double_diff(m_color.getHsvSaturation(), newColor.getHsvSaturation()) ||
|
|
||||||
cs_double_diff(m_color.getHsvValue(), newColor.getHsvValue()) ? BottomBarFlag: 0) |
|
|
||||||
ColorSelector::onNeedsSurfaceRepaint(newColor);
|
ColorSelector::onNeedsSurfaceRepaint(newColor);
|
||||||
|
|
||||||
|
if (m_hueWithSatValue) {
|
||||||
|
flags |=
|
||||||
|
(cs_double_diff(m_color.getHsvSaturation(), newColor.getHsvSaturation()) ||
|
||||||
|
cs_double_diff(m_color.getHsvValue(), newColor.getHsvValue()) ? BottomBarFlag: 0);
|
||||||
|
}
|
||||||
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "app/ui/color_selector.h"
|
#include "app/ui/color_selector.h"
|
||||||
|
#include "obs/connection.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
class Color;
|
class Color;
|
||||||
|
@ -27,6 +28,8 @@ namespace app {
|
||||||
app::Color getMainAreaColor(const int u, const int umax,
|
app::Color getMainAreaColor(const int u, const int umax,
|
||||||
const int v, const int vmax) override;
|
const int v, const int vmax) override;
|
||||||
app::Color getBottomBarColor(const int u, const int umax) override;
|
app::Color getBottomBarColor(const int u, const int umax) override;
|
||||||
|
|
||||||
|
void onPaint(ui::PaintEvent& ev) override;
|
||||||
void onPaintMainArea(ui::Graphics* g, const gfx::Rect& rc) override;
|
void onPaintMainArea(ui::Graphics* g, const gfx::Rect& rc) override;
|
||||||
void onPaintBottomBar(ui::Graphics* g, const gfx::Rect& rc) override;
|
void onPaintBottomBar(ui::Graphics* g, const gfx::Rect& rc) override;
|
||||||
void onPaintSurfaceInBgThread(os::Surface* s,
|
void onPaintSurfaceInBgThread(os::Surface* s,
|
||||||
|
@ -37,8 +40,12 @@ namespace app {
|
||||||
int onNeedsSurfaceRepaint(const app::Color& newColor) override;
|
int onNeedsSurfaceRepaint(const app::Color& newColor) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if SK_ENABLE_SKSL
|
||||||
std::string m_mainShader;
|
std::string m_mainShader;
|
||||||
std::string m_bottomShader;
|
std::string m_bottomShader;
|
||||||
|
#endif
|
||||||
|
bool m_hueWithSatValue = false;
|
||||||
|
obs::scoped_connection m_conn;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
|
|
@ -52,6 +52,8 @@ namespace doc {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBounds(const gfx::Rect& bounds) {
|
void setBounds(const gfx::Rect& bounds) {
|
||||||
|
ASSERT(bounds.w > 0);
|
||||||
|
ASSERT(bounds.h > 0);
|
||||||
m_bounds = bounds;
|
m_bounds = bounds;
|
||||||
if (m_boundsF)
|
if (m_boundsF)
|
||||||
*m_boundsF = gfx::RectF(bounds);
|
*m_boundsF = gfx::RectF(bounds);
|
||||||
|
@ -64,6 +66,8 @@ namespace doc {
|
||||||
m_boundsF = std::make_unique<gfx::RectF>(boundsF);
|
m_boundsF = std::make_unique<gfx::RectF>(boundsF);
|
||||||
|
|
||||||
m_bounds = gfx::Rect(boundsF);
|
m_bounds = gfx::Rect(boundsF);
|
||||||
|
if (m_bounds.w <= 0) m_bounds.w = 1;
|
||||||
|
if (m_bounds.h <= 0) m_bounds.h = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gfx::RectF& boundsF() const {
|
const gfx::RectF& boundsF() const {
|
||||||
|
|
Loading…
Reference in New Issue