mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-02 11:59:58 +00:00
Fix ColorWheel harmonies picker
This commit is contained in:
parent
b7f8efc0a3
commit
e8c1975f63
@ -12,6 +12,7 @@
|
||||
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "base/scoped_value.h"
|
||||
#include "she/surface.h"
|
||||
#include "ui/manager.h"
|
||||
#include "ui/message.h"
|
||||
@ -89,7 +90,7 @@ bool ColorSelector::onProcessMessage(ui::Message* msg)
|
||||
|
||||
app::Color color = getColorByPosition(mouseMsg->position());
|
||||
if (color != app::Color::fromMask()) {
|
||||
// base::ScopedValue<bool> switcher(m_lockColor, m_harmonyPicked, false);
|
||||
base::ScopedValue<bool> switcher(m_lockColor, subColorPicked(), false);
|
||||
|
||||
StatusBar::instance()->showColor(0, "", color);
|
||||
if (hasCapture())
|
||||
|
@ -35,6 +35,7 @@ namespace app {
|
||||
virtual app::Color getBottomBarColor(const int u, const int umax) = 0;
|
||||
virtual void onPaintMainArea(ui::Graphics* g, const gfx::Rect& rc) = 0;
|
||||
virtual void onPaintBottomBar(ui::Graphics* g, const gfx::Rect& rc) = 0;
|
||||
virtual bool subColorPicked() { return false; }
|
||||
|
||||
void paintColorIndicator(ui::Graphics* g,
|
||||
const gfx::Point& pos,
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/pi.h"
|
||||
#include "base/scoped_value.h"
|
||||
#include "filters/color_curve.h"
|
||||
#include "she/surface.h"
|
||||
#include "ui/graphics.h"
|
||||
@ -106,16 +105,16 @@ app::Color ColorWheel::getMainAreaColor(const int _u, const int umax,
|
||||
|
||||
// Pick harmonies
|
||||
if (m_color.getAlpha() > 0) {
|
||||
const gfx::Rect& rc = m_clientBounds;
|
||||
const gfx::Point pos(_u, _v);
|
||||
int n = getHarmonies();
|
||||
int boxsize = MIN(rc.w/10, rc.h/10);
|
||||
int boxsize = MIN(umax/10, vmax/10);
|
||||
|
||||
for (int i=0; i<n; ++i) {
|
||||
app::Color color = getColorInHarmony(i);
|
||||
|
||||
if (gfx::Rect(rc.x+rc.w-(n-i)*boxsize,
|
||||
rc.y+rc.h-boxsize,
|
||||
boxsize, boxsize).contains(gfx::Point(u, v))) {
|
||||
if (gfx::Rect(umax-(n-i)*boxsize,
|
||||
vmax-boxsize,
|
||||
boxsize, boxsize).contains(pos)) {
|
||||
m_harmonyPicked = true;
|
||||
|
||||
color = app::Color::fromHsv(convertHueAngle(int(color.getHsvHue()), 1),
|
||||
@ -140,10 +139,10 @@ app::Color ColorWheel::getBottomBarColor(const int u, const int umax)
|
||||
|
||||
void ColorWheel::onPaintMainArea(ui::Graphics* g, const gfx::Rect& rc)
|
||||
{
|
||||
bool oldHarmonyPicked = m_harmonyPicked;
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->theme());
|
||||
|
||||
int r = MIN(rc.w/2, rc.h/2);
|
||||
m_clientBounds = rc;
|
||||
m_wheelRadius = r;
|
||||
m_wheelBounds = gfx::Rect(rc.x+rc.w/2-r,
|
||||
rc.y+rc.h/2-r,
|
||||
@ -198,6 +197,8 @@ void ColorWheel::onPaintMainArea(ui::Graphics* g, const gfx::Rect& rc)
|
||||
boxsize, boxsize));
|
||||
}
|
||||
}
|
||||
|
||||
m_harmonyPicked = oldHarmonyPicked;
|
||||
}
|
||||
|
||||
void ColorWheel::onPaintBottomBar(ui::Graphics* g, const gfx::Rect& rc)
|
||||
|
@ -46,6 +46,7 @@ namespace app {
|
||||
app::Color getBottomBarColor(const int u, const int umax) override;
|
||||
void onPaintMainArea(ui::Graphics* g, const gfx::Rect& rc) override;
|
||||
void onPaintBottomBar(ui::Graphics* g, const gfx::Rect& rc) override;
|
||||
bool subColorPicked() override { return m_harmonyPicked; }
|
||||
|
||||
private:
|
||||
void onResize(ui::ResizeEvent& ev) override;
|
||||
@ -58,7 +59,6 @@ namespace app {
|
||||
// With dir == -1, the angle came from HSV and is converted to the current color model.
|
||||
int convertHueAngle(int angle, int dir) const;
|
||||
|
||||
gfx::Rect m_clientBounds;
|
||||
gfx::Rect m_wheelBounds;
|
||||
int m_wheelRadius;
|
||||
bool m_discrete;
|
||||
|
Loading…
Reference in New Issue
Block a user