Branch: Tag:

2001-01-17

2001-01-17 16:26:00 by Anders Johansson <anders@roxen.com>

Do not convert color values to HSV and back to RGB when they are entered by hand. Fixes [Bug 1042 (#1042)].

Rev: server/base_server/wizard.pike:1.125

1:   // Wizard generator   // This file generats all the nice wizards   // Copyright © 1997 - 2000, Roxen IS. - // $Id: wizard.pike,v 1.124 2000/11/14 16:52:25 nilsson Exp $ + // $Id: wizard.pike,v 1.125 2001/01/17 16:26:00 anders Exp $      /* wizard_automaton operation (old behavior if it isn't defined):   
184:       case "color":    int h, s, v; +  array a;    if(id->variables[m->name+".hsv"])    sscanf(id->variables[m->name+".hsv"], "%d,%d,%d", h, s, v);    else    { -  array tmp = rgb_to_hsv(@parse_color(current||"black")); -  h = tmp[0]; s = tmp[1]; v = tmp[2]; +  a = parse_color(current||"black"); +  [h,s,v] = rgb_to_hsv(@a);    }    if(id->variables[m->name+".foo.x"]) {    h = (int)id->variables[m->name+".foo.x"];
199:    else if(id->variables[m->name+".entered"] &&    strlen(current=id->variables[m->name+".entered"]))    { -  array tmp = rgb_to_hsv(@parse_color(current||"black")); -  h = tmp[0]; s = tmp[1]; v = tmp[2]; +  a = parse_color(current||"black"); +  [h,s,v] = rgb_to_hsv(@a);    }       m_delete(id->variables, m->name+".foo.x");
209:    m_delete(id->variables, m->name+".bar.y");    id->variables[m->name+".hsv"] = h+","+s+","+v;    -  array a=hsv_to_rgb(h,s,v); -  string bgcol=sprintf("#%02x%02x%02x",a[0],a[1],a[2]); +  if(!a) +  a = hsv_to_rgb(h,s,v); +  string bgcol = sprintf("#%02x%02x%02x",a[0],a[1],a[2]);    id->variables[m->name] = bgcol;    return    ("<table><tr>\n"
253:    sscanf(id->variables[m->name+".hsv"], "%d,%d,%d", h, s, v);    else    { -  array tmp = rgb_to_hsv(@parse_color(current||"black")); -  h = tmp[0]; s = tmp[1]; v = tmp[2]; +  a = parse_color(current||"black"); +  [h,s,v] = rgb_to_hsv(@a);    }    if(id->variables[m->name+".foo.x"]) {    h = ((int)id->variables[m->name+".foo.x"])*2;
264:    else if(id->variables[m->name+".entered"] &&    strlen(current=id->variables[m->name+".entered"]))    { -  array tmp = rgb_to_hsv(@parse_color(current||"black")); -  h = tmp[0]; s = tmp[1]; v = tmp[2]; +  a = parse_color(current||"black"); +  [h,s,v] = rgb_to_hsv(@a);    }       m_delete(id->variables, m->name+".foo.x");
274:    m_delete(id->variables, m->name+".bar.y");    id->variables[m->name+".hsv"] = h+","+s+","+v;    -  a=hsv_to_rgb(h,s,v); -  bgcol=sprintf("#%02x%02x%02x",a[0],a[1],a[2]); +  if(!a) +  a = hsv_to_rgb(h,s,v); +  bgcol = sprintf("#%02x%02x%02x",a[0],a[1],a[2]);    id->variables[m->name] = bgcol;    return    ("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>\n"