color_ramp_edit.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef SCENE_GUI_COLOR_RAMP_EDIT_H_
  2. #define SCENE_GUI_COLOR_RAMP_EDIT_H_
  3. #include "scene/gui/popup.h"
  4. #include "scene/gui/color_picker.h"
  5. #include "scene/resources/color_ramp.h"
  6. #include "scene/resources/default_theme/theme_data.h"
  7. #define POINT_WIDTH 8
  8. class ColorRampEdit : public Control {
  9. OBJ_TYPE(ColorRampEdit,Control);
  10. PopupPanel *popup;
  11. ColorPicker *picker;
  12. Ref<ImageTexture> checker;
  13. bool grabbing;
  14. int grabbed;
  15. Vector<ColorRamp::Point> points;
  16. void _draw_checker(int x, int y, int w, int h);
  17. void _color_changed(const Color& p_color);
  18. int _get_point_from_pos(int x);
  19. void _show_color_picker();
  20. protected:
  21. void _input_event(const InputEvent& p_event);
  22. void _notification(int p_what);
  23. static void _bind_methods();
  24. public:
  25. void set_ramp(const Vector<float>& p_offsets,const Vector<Color>& p_colors);
  26. Vector<float> get_offsets() const;
  27. Vector<Color> get_colors() const;
  28. void set_points(Vector<ColorRamp::Point>& p_points);
  29. Vector<ColorRamp::Point>& get_points();
  30. virtual Size2 get_minimum_size() const;
  31. ColorRampEdit();
  32. virtual ~ColorRampEdit();
  33. };
  34. /*class ColorRampEditPanel : public Panel
  35. {
  36. OBJ_TYPE(ColorRampEditPanel, Panel );
  37. };*/
  38. #endif /* SCENE_GUI_COLOR_RAMP_EDIT_H_ */