Add options to sort the palette by RGBA channels

This commit is contained in:
David Capello 2015-07-23 11:13:43 -03:00
parent 6aeee0b8fa
commit ba4c34a70f
3 changed files with 19 additions and 0 deletions

View File

@ -348,6 +348,10 @@ void ColorBar::onPaletteButtonClick()
sat("Sort by Saturation"),
bri("Sort by Brightness"),
lum("Sort by Luminance"),
red("Sort by Red"),
grn("Sort by Green"),
blu("Sort by Blue"),
alp("Sort by Alpha"),
asc("Ascending"),
des("Descending");
menu.addChild(&rev);
@ -358,6 +362,11 @@ void ColorBar::onPaletteButtonClick()
menu.addChild(&bri);
menu.addChild(&lum);
menu.addChild(new ui::MenuSeparator);
menu.addChild(&red);
menu.addChild(&grn);
menu.addChild(&blu);
menu.addChild(&alp);
menu.addChild(new ui::MenuSeparator);
menu.addChild(&asc);
menu.addChild(&des);
@ -370,6 +379,10 @@ void ColorBar::onPaletteButtonClick()
sat.Click.connect(Bind<void>(&ColorBar::onSortBy, this, SortPaletteBy::SATURATION));
bri.Click.connect(Bind<void>(&ColorBar::onSortBy, this, SortPaletteBy::VALUE));
lum.Click.connect(Bind<void>(&ColorBar::onSortBy, this, SortPaletteBy::LUMA));
red.Click.connect(Bind<void>(&ColorBar::onSortBy, this, SortPaletteBy::RED));
grn.Click.connect(Bind<void>(&ColorBar::onSortBy, this, SortPaletteBy::GREEN));
blu.Click.connect(Bind<void>(&ColorBar::onSortBy, this, SortPaletteBy::BLUE));
alp.Click.connect(Bind<void>(&ColorBar::onSortBy, this, SortPaletteBy::ALPHA));
asc.Click.connect(Bind<void>(&ColorBar::setAscending, this, true));
des.Click.connect(Bind<void>(&ColorBar::setAscending, this, false));

View File

@ -61,6 +61,11 @@ struct PalEntryWithIndexPredicate {
value2 = rgba_getb(c2);
break;
case SortPaletteBy::ALPHA:
value1 = rgba_geta(c1);
value2 = rgba_geta(c2);
break;
case SortPaletteBy::HUE:
case SortPaletteBy::SATURATION:
case SortPaletteBy::VALUE: {

View File

@ -17,6 +17,7 @@ namespace doc {
RED,
GREEN,
BLUE,
ALPHA,
HUE,
SATURATION,
VALUE,