lotrointerface.com
Search Downloads


Go Back   LoTROInterface > LotRO Libraries

Category: LotRO Libraries[Class] Color Picker
Interface Information
Download
Galuhad's Portal Bug Reports Feature Requests
How do I install this? (FAQ)
Name: [Class] Color Picker   Popular!
Author:
Date: 08-02-2011 11:05 AM
Size: 16.54 Kb
Version: 1.0
Rate File: 5 out of 5 with 1 votes  
Pictures
Click to enlarge 

Views: 0
Size: 8.87 Kb
Dimensions: 308 x 164
Color picker
 
Description
I originally created this class for a plugin I was coding at the time (ChatEdit). I wanted the option for players to be able to select a color in the most straight-forward and familiar way, by being presented with a color picker that they can click on.

The original version took the requested dimensions and produced 1x1 pixel controls to fill the area with the colors, taking a few seconds to load and producing thousands of event handlers. Of course this wasn't the most practical way, and thankfully Garan stepped in converting the pixel controls to mouse co-ordinates that would map the color value, using the code that previously generated the pixels, and also placed a picker jpg as the background to display the colors.

The newer version from Garan took a lot less time to load as it was no longer producing thousands of controls, and to the user, produced the same end result.

However, the class was created for ChatEdit so still required other coders to tinker with it a bit if they wanted to use it in their own plugins.
I have spent the past couple of days modifying the class again, this time so it can be used with ease in other plugins. In this version I've added in some mouse-click events and functions to retrieve the clicked color values, you no longer need to place this into the class itself, it can all be done from within your own script


Using the class..

First, make sure you copy the ColorPicker.lua file and the resource folder to your plugin directory.. You will then need to import the ColorPicker file into your script.

You will need to set the value for PICKER_JPG_DIR so it points to the location of picker.jpg in your project.

PICKER_JPG_DIR = "myDir/resources/picker.jpg";


You can then go about creating a color picker control..

myColourPicker = ColorPicker.Create ();
myColourPicker:SetParent ( control );
myColourPicker:SetSize ( width, height );
myColourPicker:SetPosition ( left, top );


Each color picker control has three mouse-click events you can customise, these are when the mouse is left-clicked, right-clicked, or another mouse button is clicked.

myColourPicker.LeftClick = function () -- Left-click mouse event
myColourPicker.RightClick = function () -- Right-Click mouse event
myColourPicker.OtherClick = function () -- Other mouse button click event


Each mouse-click creates 3 possible outputs, a Turbine Color Class, the Hex value, and the RGB values of the color clicked. To access these use:

myColourPicker:GetTurbineColor (); - returns a Turbine color class
myColourPicker:GetHexColor (); -- returns the hex value e.g. FFFFFF
myColourPicker:GetRGBColor (); -- returns three number values, red, green, and blue

Known Issues:
-The class is able to rescale picker.jpg's width only due to problems with Turbines stretch mode property. The default height is 70 pixels, if you want to make it bigger or smaller you will need to first modify picker.jpg externally to change the height. When you create the picker in your script make sure you SetHeight() to the same value otherwise the mapping will be off.
File Statistics
User Rating:
5 out of 5 with 1 votes
Downloads: 9577
Views: 26496
Favorites: 1
Uploaded By:
 
Last Modified: N/A

View Pictures. Download Now! Post A Comment


Post A Reply
Author Comments Comment Options
Unread 08-02-2011, 03:47 PM  
zanttux
The Wary
 
zanttux's Avatar
Interface Author - Click to view interfaces

Forum posts: 0
File comments: 21
Uploads: 1
Ah I see, good explanation. I was assuming the color would be taken from the image.
zanttux is offline Report comment to moderator   Reply With Quote Reply With Quote
Unread 08-02-2011, 03:46 PM  
Garan
The Undying
 
Garan's Avatar
Interface Author - Click to view interfaces

Forum posts: 340
File comments: 980
Uploads: 20
Quote:
Originally Posted by zanttux
Looks good, will test it later. One thought, wouldn't it be better to use tga image format to avoid possible packing artifacts?
Artifacts would only be an issue if you were using the color of the actual pixels for your selection. Here, the image is just a backdrop for the human eye while the color is actually based off of the coordinates where you click, not the color of the pixel at that location. A TGA file would be significantly larger than the JPG file with no significant benefit so the JPG is more efficient in this case.

P.S. Nice control Galuhad. Glad to see you publishing it separately.

Last edited by Garan : 08-02-2011 at 03:50 PM.
Garan is online now Report comment to moderator   Reply With Quote Reply With Quote
Unread 08-02-2011, 03:35 PM  
Galuhad
The Undying
 
Galuhad's Avatar
Interface Author - Click to view interfaces

Forum posts: 24
File comments: 170
Uploads: 20
The image can be converted to tga if preferred, all you'd have to do is point PICKER_JPG_DIR to the tga file rather than the jpg file. I've not had any problems so far using jpg, but please let me know if you find otherwise.
Galuhad is offline Report comment to moderator   Reply With Quote Reply With Quote
Unread 08-02-2011, 03:01 PM  
zanttux
The Wary
 
zanttux's Avatar
Interface Author - Click to view interfaces

Forum posts: 0
File comments: 21
Uploads: 1
Looks good, will test it later. One thought, wouldn't it be better to use tga image format to avoid possible packing artifacts?
zanttux is offline Report comment to moderator   Reply With Quote Reply With Quote
Post A Reply

 
Category Jump:
Search this Category:
 

All times are GMT -5. The time now is 05:06 AM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui