mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-21 21:38:00 +01:00
WPrefs: set default to 1st color in gradient texture
This patch is updating the gradient texture user experience by auto selecting the first color in the list when possible and fixing the autoselection after a delete action. In fact what that is called gradient colors is just a list of colors with hue/saturation/brightness value. That patch is loading the first one from the list (color, hue, saturation, brightness) and setting the 3 sliders according to that value instead of using some default hardcoded values. The default color value on the top-right is never modified. Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
This commit is contained in:
committed by
Carlos R. Mafra
parent
10e0bdf39b
commit
7082561a42
@@ -357,10 +357,9 @@ static void sliderChangeCallback(WMWidget * w, void *data)
|
||||
{
|
||||
TexturePanel *panel = (TexturePanel *) data;
|
||||
RHSVColor hsv;
|
||||
int row, rows;
|
||||
int i, row, rows;
|
||||
WMListItem *item;
|
||||
RColor **colors;
|
||||
int i;
|
||||
RImage *image;
|
||||
WMScreen *scr = WMWidgetScreen(w);
|
||||
|
||||
@@ -368,7 +367,20 @@ static void sliderChangeCallback(WMWidget * w, void *data)
|
||||
hsv.saturation = WMGetSliderValue(panel->gsatS);
|
||||
hsv.value = WMGetSliderValue(panel->gvalS);
|
||||
|
||||
rows = WMGetListNumberOfRows(panel->gcolL);
|
||||
row = WMGetListSelectedItemRow(panel->gcolL);
|
||||
|
||||
if (row < 0 && rows > 0) {
|
||||
row = 0;
|
||||
WMSelectListItem(panel->gcolL, row);
|
||||
item = WMGetListItem(panel->gcolL, row);
|
||||
RRGBtoHSV((RColor *) item->clientData, &hsv);
|
||||
|
||||
WMSetSliderValue(panel->ghueS, hsv.hue);
|
||||
WMSetSliderValue(panel->gsatS, hsv.saturation);
|
||||
WMSetSliderValue(panel->gvalS, hsv.value);
|
||||
}
|
||||
|
||||
if (row >= 0) {
|
||||
RColor *rgb;
|
||||
|
||||
@@ -382,6 +394,7 @@ static void sliderChangeCallback(WMWidget * w, void *data)
|
||||
}
|
||||
|
||||
if (w == panel->ghueS) {
|
||||
updateHueSlider(panel->ghueS, panel->listFont, &hsv);
|
||||
updateSVSlider(panel->gsatS, True, panel->listFont, &hsv);
|
||||
updateSVSlider(panel->gvalS, False, panel->listFont, &hsv);
|
||||
} else if (w == panel->gsatS) {
|
||||
@@ -392,7 +405,6 @@ static void sliderChangeCallback(WMWidget * w, void *data)
|
||||
updateSVSlider(panel->gsatS, True, panel->listFont, &hsv);
|
||||
}
|
||||
|
||||
rows = WMGetListNumberOfRows(panel->gcolL);
|
||||
if (rows == 0)
|
||||
return;
|
||||
|
||||
@@ -503,7 +515,7 @@ static void gradDeleteCallback(WMWidget * w, void *data)
|
||||
{
|
||||
TexturePanel *panel = (TexturePanel *) data;
|
||||
WMListItem *item;
|
||||
int row;
|
||||
int row, rows;
|
||||
|
||||
/* Parameter not used, but tell the compiler that it is ok */
|
||||
(void) w;
|
||||
@@ -516,9 +528,14 @@ static void gradDeleteCallback(WMWidget * w, void *data)
|
||||
wfree(item->clientData);
|
||||
|
||||
WMRemoveListItem(panel->gcolL, row);
|
||||
if (row > 0)
|
||||
WMSelectListItem(panel->gcolL, row - 1);
|
||||
else {
|
||||
rows = WMGetListNumberOfRows(panel->gcolL);
|
||||
if (rows > 0)
|
||||
WMSelectListItem(panel->gcolL, 0);
|
||||
|
||||
WMSelectListItem(panel->gcolL, row - 1);
|
||||
|
||||
}
|
||||
updateGradButtons(panel);
|
||||
|
||||
gradClickCallback(panel->gcolL, panel);
|
||||
|
||||
Reference in New Issue
Block a user