The color pick pseudo object




Although you will probably choose an attractive color scheme for your GUI applications, the user's satisfaction with the application may be greatly improved by allowing them to choose the colors used for the major screen objects. By using the ColorPick pseudo object you allow the user to efficiently choose the screen colors in a consistent way within and among your applications. Also, you will find that selecting colors using the ColorPick figure is much easier than using the typical Windows style palette which attempts to show all possible colors in a single palette. I've found you need to see a fairly large area of your potential color choice before you can decide if the color is suitable. It is not possible to accomplish that using a single palette which is what makes it frustrating to use. By allowing you to fix one of the colors, ColorPick presents an 11x11 palette of choices for the remaining two colors which gives you plenty of area for each color block. (If that is not enough, you can resize the ColorPick figure to be as large as you want.) Even more important is that the instant you click on one of the 121 colors in the current palette the larger patch above the palette AND the objects in the gui that you are adjusting instantly change to the selected color. This instant feedback is really necessary to remove the frustration that usually arises from the task. Scrolling through the many possible palettes is also very quick. Just pick any slider and click on the left/right arrows for a finely changing palette, or click in the trough area of the slider for a more coarsely changing palette (which should be fine enough all but the most picky color chooser).

Any Matlab object that has either a callback property or a buttondownfunction property may be used to bring up the ColorPick window shown here. Before I describe how this is done from a programming perspective I will give a few more details about how the user selects colors from this window.

The text above the sliders is generally used to identify the object or objects that are to receive the color being selected. The three sliders always indicate the RGB values of the currently selected color. In the example shown at the left, the RGB values are 35%, 80%, and 60% respectively. In Matlab, this color would be represented by the vector [0.35  0.8  0.6]. The large rectangular patch object in the upper right corner always indicates the color that results when the proportions are set to agree with the values of the three RGB sliders. One of the sliders (the red one in this example) will always be shown with its text value in yellow and is referred to as the "active slider". A slider will become the active slider whenever you either type in a value into its edit box or when you click on the left or right slider arrows. There are 3 ways to alter the currently selected color:
Next, I will describe how the ColorPick object is created from the programmer's viewpoint. I will call the object that initiates the creation of the ColorPick figure window the "main object". You must do the following two things to make a ColorPick figure appear:
Only one detail remains to describe the operation of the ColorPick object, and that has to do with how ColorPick determines the starting positions of the RGB sliders when the window is first opened. It's very simple when the 'm' appdata is not defined, since in that case the initial color will be the same as the color of the main object (either its 'Color' or 'Backgr' properties depending on which property it has.) When the 'm' appdata is defined, this is a two-step process. First ColorPick must decide which object will be used to determine the initial color. Once the object is chosen, ColorPick must decide which property of this object to use. Here are the details of these two steps:
  1. Picking the object which will determine the initial color. Usually the handle of the main object will be among one of the handles included in the 'm' application data cell array and in this case the main object itself is used to determine the initial RGB slider positions. However, sometimes this is not the case. For example, in the demoplt.m program, we would like to open the ColorPick window when we click on the text object "text color" which serves as a label for the text color patch. However since this is just a label, it is not entirely appropriate for the color of this text object to change which means that it will not appear in the list of handles in the 'm' cell array. So in this instance, ColorPick determines the initial color from the object whose handle is the first element of H1 in the 'm' cell array. (This is the only instance where the order of the handles in this array is significant.)
  2. Picking the property of the selected object that determines the initial color.
While all this sounds quite complicated, using ColorPick is usually not that difficult because in most cases it does what you would expect. It may be easier just to look at some examples of ColorPick in action which you can do in the following programs:

      demo folder:   demoplt pub0 trigplt vbar
      math folder: gpsLog
      sig folder: afilt
      util folder: pltpub

In the simplest cases, the 'm' appdata may not needed (for example in gpsLog.m, vbar.m, and and trigplt.m). The remaining examples use the 'm' appdata to tailor how the ColorPick pseudo object is used.