29 #ifndef _GG_ColorDlg_h_
30 #define _GG_ColorDlg_h_
48 HSVClr(
double h_,
double s_,
double v_, GLubyte a_ = 255);
70 virtual void Render();
74 void SetHueSaturation(
double hue,
double saturation);
85 void SetHueSaturationFromPt(
Pt pt);
89 std::vector<std::vector<std::pair<double, double> > > m_vertices;
90 std::vector<std::vector<Clr> > m_colors;
108 virtual void Render();
114 void SetHueSaturation(
double hue,
double saturation);
115 void SetValue(
double value);
126 void SetValueFromPt(
Pt pt);
156 Clr RepresentedColor()
const;
161 void SetRepresentedColor(
const Clr& color);
170 virtual void RenderUnpressed();
171 virtual void RenderPressed();
172 virtual void RenderRollover();
176 Clr m_represented_color;
193 virtual void Render();
204 ColorDlg(
X x,
Y y,
const boost::shared_ptr<Font>& font,
205 Clr dialog_color,
Clr border_color,
Clr text_color = CLR_BLACK);
208 ColorDlg(
X x,
Y y,
Clr original_color,
const boost::shared_ptr<Font>& font,
209 Clr dialog_color,
Clr border_color,
Clr text_color = CLR_BLACK);
216 bool ColorWasSelected()
const;
221 const std::string& NewString(
const std::string& str)
const;
222 const std::string& OldString(
const std::string& str)
const;
223 const std::string& RedString(
const std::string& str)
const;
224 const std::string& GreenString(
const std::string& str)
const;
225 const std::string& BlueString(
const std::string& str)
const;
226 const std::string& HueString(
const std::string& str)
const;
227 const std::string& SaturationString(
const std::string& str)
const;
228 const std::string& ValueString(
const std::string& str)
const;
229 const std::string& AlphaString(
const std::string& str)
const;
230 const std::string& OkString(
const std::string& str)
const;
231 const std::string& CancelString(
const std::string& str)
const;
235 void SetNewString(
const std::string& str);
236 void SetOldString(
const std::string& str);
237 void SetRedString(
const std::string& str);
238 void SetGreenString(
const std::string& str);
239 void SetBlueString(
const std::string& str);
240 void SetHueString(
const std::string& str);
241 void SetSaturationString(
const std::string& str);
242 void SetValueString(
const std::string& str);
243 void SetAlphaString(
const std::string& str);
244 void SetOkString(
const std::string& str);
245 void SetCancelString(
const std::string& str);
247 virtual void Render();
248 virtual void KeyPress(
Key key, boost::uint32_t key_code_point,
Flags<ModKey> mod_keys);
251 static const std::size_t INVALID_COLOR_BUTTON;
259 struct ColorButtonClickFunctor
261 ColorButtonClickFunctor(std::size_t
id,
ColorDlg* picker_);
263 const std::size_t button_id;
267 enum {R, G, B, A, H, S, V};
269 void Init(
const boost::shared_ptr<Font>& font);
270 void ConnectSignals();
271 void ColorChanged(HSVClr color);
272 void HueSaturationPickerChanged(
double hue,
double saturation);
273 void ValuePickerChanged(
double value);
274 void UpdateRGBSliders();
275 void UpdateHSVSliders();
276 void ColorChangeFromRGBSlider();
277 void ColorButtonClicked(std::size_t i);
278 void RedSliderChanged(
int value,
int low,
int high);
279 void GreenSliderChanged(
int value,
int low,
int high);
280 void BlueSliderChanged(
int value,
int low,
int high);
281 void AlphaSliderChanged(
int value,
int low,
int high);
282 void HueSliderChanged(
int value,
int low,
int high);
283 void SaturationSliderChanged(
int value,
int low,
int high);
284 void ValueSliderChanged(
int value,
int low,
int high);
286 void CancelClicked();
288 HSVClr m_current_color;
289 Clr m_original_color;
290 bool m_original_color_specified;
291 bool m_color_was_picked;
293 std::string m_new_str;
294 std::string m_old_str;
295 std::string m_red_str;
296 std::string m_green_str;
297 std::string m_blue_str;
298 std::string m_hue_str;
299 std::string m_saturation_str;
300 std::string m_value_str;
301 std::string m_alpha_str;
302 std::string m_ok_str;
303 std::string m_cancel_str;
305 HueSaturationPicker* m_hue_saturation_picker;
306 ValuePicker* m_value_picker;
307 Layout* m_pickers_layout;
308 ColorDisplay* m_new_color_square;
309 ColorDisplay* m_old_color_square;
310 TextControl* m_new_color_square_text;
311 TextControl* m_old_color_square_text;
312 Layout* m_color_squares_layout;
313 std::vector<ColorButton*> m_color_buttons;
314 Layout* m_color_buttons_layout;
315 std::size_t m_current_color_button;
316 std::vector<TextControl*> m_slider_labels;
317 std::vector<TextControl*> m_slider_values;
318 std::vector<Slider<int>*> m_sliders;
321 Layout* m_sliders_ok_cancel_layout;
327 static std::vector<Clr> s_custom_colors;
329 friend struct ColorButtonClickFunctor;