Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple spectrum indicators 4338 #4340

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/app/ui/color_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,14 +577,15 @@ int ColorSelector::onNeedsSurfaceRepaint(const app::Color& newColor)

void ColorSelector::paintColorIndicator(ui::Graphics* g,
const gfx::Point& pos,
const bool white)
const bool white,
const int alpha)
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
{
auto theme = SkinTheme::get(this);
os::Surface* icon = theme->parts.colorWheelIndicator()->bitmap(0);

g->drawColoredRgbaSurface(
icon,
white ? gfx::rgba(255, 255, 255): gfx::rgba(0, 0, 0),
white ? gfx::rgba(255, 255, 255, alpha): gfx::rgba(0, 0, 0, alpha),
pos.x-icon->width()/2,
pos.y-icon->height()/2);
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/ui/color_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ namespace app {

void paintColorIndicator(ui::Graphics* g,
const gfx::Point& pos,
const bool white);
const bool white,
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
const int alpha=255);
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved

// Returns the 255 if m_color is the mask color, or the
// m_color.getAlpha() if it's really a color.
Expand Down
73 changes: 58 additions & 15 deletions src/app/ui/color_spectrum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "app/color_utils.h"
#include "app/ui/skin/skin_theme.h"
#include "app/ui/status_bar.h"
#include "app/ui/color_bar.h"
#include "app/util/shader_helpers.h"
#include "os/surface.h"
#include "ui/graphics.h"
Expand Down Expand Up @@ -103,26 +104,68 @@ app::Color ColorSpectrum::getBottomBarColor(const int u, const int umax)

void ColorSpectrum::onPaintMainArea(ui::Graphics* g, const gfx::Rect& rc)
{
if (m_color.getType() != app::Color::MaskType) {
double hue = m_color.getHslHue();
double lit = m_color.getHslLightness();
gfx::Point pos(rc.x + int(hue * rc.w / 360.0),
rc.y + rc.h - int(lit * rc.h));

paintColorIndicator(g, pos, lit < 0.5);
doc::PalettePicks picks;
ColorBar::instance()->getPaletteView()->getSelectedEntries(picks);
if (picks.picks() > 1)
{
for (int i = 0; i<picks.size(); i++) {
if (!picks[i])
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
continue;
Color color = app::Color::fromIndex(i);
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
if (color.getType() != app::Color::MaskType) {
double hue = color.getHslHue();
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
double lit = color.getHslLightness();
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
gfx::Point pos(rc.x + int(hue * rc.w / 360.0),
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
rc.y + rc.h - int(lit * rc.h));

int alpha = color == m_color ? 255 : 100;
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
paintColorIndicator(g, pos, lit < 0.5, alpha);
}
}
}
else
{
if (m_color.getType() != app::Color::MaskType) {
double hue = m_color.getHslHue();
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
double lit = m_color.getHslLightness();
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
gfx::Point pos(rc.x + int(hue * rc.w / 360.0),
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
rc.y + rc.h - int(lit * rc.h));

paintColorIndicator(g, pos, lit < 0.5);
}
}
}

void ColorSpectrum::onPaintBottomBar(ui::Graphics* g, const gfx::Rect& rc)
{
double lit = m_color.getHslLightness();

if (m_color.getType() != app::Color::MaskType) {
double sat = m_color.getHslSaturation();
gfx::Point pos(rc.x + int(double(rc.w) * sat),
rc.y + rc.h/2);
paintColorIndicator(g, pos, lit < 0.5);
}
doc::PalettePicks picks;
ColorBar::instance()->getPaletteView()->getSelectedEntries(picks);
if (picks.picks() > 1)
{
for (int i = 0; i<picks.size(); i++) {
if (!picks[i])
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
continue;
Color color = app::Color::fromIndex(i);
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
double lit = color.getHslLightness();
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
if (color.getType() != app::Color::MaskType) {
double sat = color.getHslSaturation();
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
gfx::Point pos(rc.x + int(double(rc.w) * sat),
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
rc.y + rc.h/2);
int alpha = color == m_color ? 255 : 100;
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
paintColorIndicator(g, pos, lit < 0.5, alpha);
}
}
}
else
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
{
double lit = m_color.getHslLightness();
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
if (m_color.getType() != app::Color::MaskType) {
double sat = m_color.getHslSaturation();
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
gfx::Point pos(rc.x + int(double(rc.w) * sat),
Charlie-83 marked this conversation as resolved.
Show resolved Hide resolved
rc.y + rc.h/2);
paintColorIndicator(g, pos, lit < 0.5);
}
}
}

void ColorSpectrum::onPaintSurfaceInBgThread(
Expand Down