Miranor Widget Store

x

You have to be logged in to use this function.

Username:
Paswword:

   Create New Account ˖ Forgot password?
COLOR PICKER (GUI App)Buy this Widget!
10 Credits

Description:
The 'ColorPicker' class (derived from 'MWindow') enables the user to select any 24-bit depth color using a color wheel and/or the slider. Clicking the color wheel selects hue (0 to 360 degrees) and saturation (0-center to 255-rim). The slider to the right of the color wheel selects luma (similar to lightness), from 0 (all black) to 255 (all white). Additionally, the luma can be changed using the mouse wheel, the saturation - up/down arrows, and hue - left/right arrows. Pressing the Ctrl key with the arrows or the mouse wheel allows a faster change.
The color wheel is always drawn with the current luma to allow intuitive selection. The current hue, saturation, and luma values (HSL) appear above the color wheel and the slider (drawn with the current ForeColor), and also as a cross-like indicator on the color wheel. The currently selected color also appears in a bar under the color wheel with the RGB values listed within the bar. The color of the RGB labels and of the cross-like indicator is adjusted automatically (black or white) to remain comfortably visible for any color.
The only new public methods are 'setColor' and 'getColor', which change and reveal the current color programmatically. When the color selection changes, the widget generates a "ColorChanged" notice. The widget automatically adjusts itself to any size, but it looks best when the size is close to a square and is not too small.

Author: Dimitry Rotstein

Tags: color, wheel, selector, hue, saturation, luma, lightness, slider, red, green, blue, RGB, HSL


Code preview:

class ColorPicker : public MWindow { private: // Auxiliary widget - displays/selects color luma ([0..255] integer) // Needed to draw custom (more informative) background for the slider // struct LightnessSlider : public MSlideBox { LightnessSlider(MWindow& parent, const MRect& rect) : MSlideBox(parent,rect,Auto,255) { thumb().setBackColor(clOrange); setForeColor(clGray+20); }
...

***************Buy the widget to get the rest of the code***************

Miranor Home | About Miranor | About Elgrint | Create account | Login | Account settings | Contact Us | Privacy Policy | Site map

© Copyright 2014 by Miranor. All rights reserved. By using this site you agree to the Terms of Use.

Page last updated on August 10th, 2014.

Real Time Web Analytics