class Iup::ColorBar

Displays a palette of colors from which the user can select a primary and secondary color.

Example

The following example sets up a default set of colors in a 2-column layout, responding to color selections by calling redraw which updates an associated display (not given here):

Iup::ColorBar.new do |b|
  # the following settings define the display
  b.rastersize = '70x'  
  b.expand = 'vertical'
  b.num_parts = 2
  b.show_secondary = 'yes'
  b.preview_size = 60
  # this call back responds to single-click color selections by updating display
  b.select_cb = ->(idx, type){
    case type
    when Iup::IUP_PRIMARY
      canvas.foreground = b.cell(idx)
    when Iup::IUP_SECONDARY
      canvas.background = b.cell(idx)
    end
    canvas.redraw
    Iup::DEFAULT
  }
  # this call back responds to double-click color selections by updating display
  b.cell_cb = ->(idx){
    canvas.foreground cell(idx)
    canvas.redraw
    Iup::DEFAULT
  }
  # updates display with a switch between primary and secondary colors
  b.switch_cb = ->(prim_cell, sec_cell){
    fg_colour = canvas.foreground
    canvas.foreground = canvas.background
    canvas.background = fg_colour
    canvas.redraw
    Iup::DEFAULT
  }
end