Logo Search packages:      
Sourcecode: ardour version File versions

void TimeAxisViewItem::compute_colors ( Gdk::Color base_color  )  [protected, virtual]

Calculates some contrasting color for displaying various parts of this item, based upon the base color

Parameters:
color the base color of the item

Definition at line 671 of file time_axis_view_item.cc.

References Gdk::Color::get_blue(), Gdk::Color::get_green(), and Gdk::Color::get_red().

{
      unsigned char radius ;
      char minor_shift ;
      
      unsigned char r,g,b ;

      /* FILL: this is simple */
      r = base_color.get_red()/256 ;
      g = base_color.get_green()/256 ;
      b = base_color.get_blue()/256 ;
      fill_color = RGBA_TO_UINT(r,g,b,255) ;

      /*  for minor colors:
            if the overall saturation is strong, make the minor colors light.
            if its weak, make them dark.
  
            we do this by moving an equal distance to the other side of the
            central circle in the color wheel from where we started.
      */

      radius = (unsigned char) rint (floor (sqrt (static_cast<double>(r*r + g*g + b+b))/3.0f)) ;
      minor_shift = 125 - radius ;

      /* LABEL: rotate around color wheel by 120 degrees anti-clockwise */

      r = base_color.get_red()/256;
      g = base_color.get_green()/256;
      b = base_color.get_blue()/256;
  
      if (r > b)
      {
            if (r > g)
            {
                  /* red sector => green */
                  swap (r,g);
            }
            else
            {
                  /* green sector => blue */
                  swap (g,b);
            } 
      }
      else
      {
            if (b > g)
            {
                  /* blue sector => red */
                  swap (b,r);
            }
            else
            {
                  /* green sector => blue */
                  swap (g,b);
            }
      }

      r += minor_shift;
      b += minor_shift;
      g += minor_shift;
  
      label_color = RGBA_TO_UINT(r,g,b,255);
      r = (base_color.get_red()/256)   + 127 ;
      g = (base_color.get_green()/256) + 127 ;
      b = (base_color.get_blue()/256)  + 127 ;
  
      label_color = RGBA_TO_UINT(r,g,b,255);

      /* XXX can we do better than this ? */
      /* We're trying ;) */
      /* NUKECOLORS */
      
      //frame_color_r = 192;
      //frame_color_g = 192;
      //frame_color_b = 194;
      
      //selected_frame_color_r = 182;
      //selected_frame_color_g = 145;
      //selected_frame_color_b = 168;
      
      //handle_color_r = 25 ;
      //handle_color_g = 0 ;
      //handle_color_b = 255 ;
      //lock_handle_color_r = 235 ;
      //lock_handle_color_g = 16;
      //lock_handle_color_b = 16;
}


Generated by  Doxygen 1.6.0   Back to index