Merge pull request #9160 from karroffel/color-ramp-rename

renamed occurances of ColorRamp with Gradient
This commit is contained in:
Rémi Verschelde
2017-06-14 23:09:30 +02:00
committed by GitHub
8 changed files with 85 additions and 85 deletions
+2 -2
View File
@@ -73,10 +73,10 @@
#include "plugins/collision_polygon_2d_editor_plugin.h"
#include "plugins/collision_polygon_editor_plugin.h"
#include "plugins/collision_shape_2d_editor_plugin.h"
#include "plugins/color_ramp_editor_plugin.h"
#include "plugins/cube_grid_theme_editor_plugin.h"
#include "plugins/curve_editor_plugin.h"
#include "plugins/gi_probe_editor_plugin.h"
#include "plugins/gradient_editor_plugin.h"
#include "plugins/gradient_texture_editor_plugin.h"
#include "plugins/item_list_editor_plugin.h"
#include "plugins/light_occluder_2d_editor_plugin.h"
@@ -6042,7 +6042,7 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(Polygon2DEditorPlugin(this)));
add_editor_plugin(memnew(LightOccluder2DEditorPlugin(this)));
add_editor_plugin(memnew(NavigationPolygonEditorPlugin(this)));
add_editor_plugin(memnew(ColorRampEditorPlugin(this)));
add_editor_plugin(memnew(GradientEditorPlugin(this)));
add_editor_plugin(memnew(GradientTextureEditorPlugin(this)));
add_editor_plugin(memnew(CollisionShape2DEditorPlugin(this)));
add_editor_plugin(memnew(CurveTextureEditorPlugin(this)));
@@ -27,15 +27,15 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "color_ramp_editor_plugin.h"
#include "gradient_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
#include "spatial_editor_plugin.h"
ColorRampEditorPlugin::ColorRampEditorPlugin(EditorNode *p_node) {
GradientEditorPlugin::GradientEditorPlugin(EditorNode *p_node) {
editor = p_node;
ramp_editor = memnew(ColorRampEdit);
ramp_editor = memnew(GradientEdit);
add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, ramp_editor);
@@ -44,21 +44,21 @@ ColorRampEditorPlugin::ColorRampEditorPlugin(EditorNode *p_node) {
ramp_editor->connect("ramp_changed", this, "ramp_changed");
}
void ColorRampEditorPlugin::edit(Object *p_object) {
void GradientEditorPlugin::edit(Object *p_object) {
Gradient *color_ramp = p_object->cast_to<Gradient>();
if (!color_ramp)
Gradient *gradient = p_object->cast_to<Gradient>();
if (!gradient)
return;
color_ramp_ref = Ref<Gradient>(color_ramp);
ramp_editor->set_points(color_ramp_ref->get_points());
gradient_ref = Ref<Gradient>(gradient);
ramp_editor->set_points(gradient_ref->get_points());
}
bool ColorRampEditorPlugin::handles(Object *p_object) const {
bool GradientEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("ColorRamp");
return p_object->is_class("Gradient");
}
void ColorRampEditorPlugin::make_visible(bool p_visible) {
void GradientEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
ramp_editor->show();
@@ -67,43 +67,43 @@ void ColorRampEditorPlugin::make_visible(bool p_visible) {
}
}
void ColorRampEditorPlugin::_ramp_changed() {
void GradientEditorPlugin::_ramp_changed() {
if (color_ramp_ref.is_valid()) {
if (gradient_ref.is_valid()) {
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
//Not sure if I should convert this data to PoolVector
Vector<float> new_offsets = ramp_editor->get_offsets();
Vector<Color> new_colors = ramp_editor->get_colors();
Vector<float> old_offsets = color_ramp_ref->get_offsets();
Vector<Color> old_colors = color_ramp_ref->get_colors();
Vector<float> old_offsets = gradient_ref->get_offsets();
Vector<Color> old_colors = gradient_ref->get_colors();
if (old_offsets.size() != new_offsets.size())
ur->create_action(TTR("Add/Remove Color Ramp Point"));
else
ur->create_action(TTR("Modify Color Ramp"), UndoRedo::MERGE_ENDS);
ur->add_do_method(this, "undo_redo_color_ramp", new_offsets, new_colors);
ur->add_undo_method(this, "undo_redo_color_ramp", old_offsets, old_colors);
ur->add_do_method(this, "undo_redo_gradient", new_offsets, new_colors);
ur->add_undo_method(this, "undo_redo_gradient", old_offsets, old_colors);
ur->commit_action();
//color_ramp_ref->set_points(ramp_editor->get_points());
}
}
void ColorRampEditorPlugin::_undo_redo_color_ramp(const Vector<float> &offsets,
void GradientEditorPlugin::_undo_redo_gradient(const Vector<float> &offsets,
const Vector<Color> &colors) {
color_ramp_ref->set_offsets(offsets);
color_ramp_ref->set_colors(colors);
ramp_editor->set_points(color_ramp_ref->get_points());
gradient_ref->set_offsets(offsets);
gradient_ref->set_colors(colors);
ramp_editor->set_points(gradient_ref->get_points());
ramp_editor->update();
}
ColorRampEditorPlugin::~ColorRampEditorPlugin() {
GradientEditorPlugin::~GradientEditorPlugin() {
}
void ColorRampEditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("ramp_changed"), &ColorRampEditorPlugin::_ramp_changed);
ClassDB::bind_method(D_METHOD("undo_redo_color_ramp", "offsets", "colors"), &ColorRampEditorPlugin::_undo_redo_color_ramp);
void GradientEditorPlugin::_bind_methods() {
ClassDB::bind_method(D_METHOD("ramp_changed"), &GradientEditorPlugin::_ramp_changed);
ClassDB::bind_method(D_METHOD("undo_redo_gradient", "offsets", "colors"), &GradientEditorPlugin::_undo_redo_gradient);
}
@@ -32,21 +32,21 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/gui/color_ramp_edit.h"
#include "scene/gui/gradient_edit.h"
class ColorRampEditorPlugin : public EditorPlugin {
class GradientEditorPlugin : public EditorPlugin {
GDCLASS(ColorRampEditorPlugin, EditorPlugin);
GDCLASS(GradientEditorPlugin, EditorPlugin);
bool _2d;
Ref<Gradient> color_ramp_ref;
ColorRampEdit *ramp_editor;
Ref<Gradient> gradient_ref;
GradientEdit *ramp_editor;
EditorNode *editor;
protected:
static void _bind_methods();
void _ramp_changed();
void _undo_redo_color_ramp(const Vector<float> &offsets, const Vector<Color> &colors);
void _undo_redo_gradient(const Vector<float> &offsets, const Vector<Color> &colors);
public:
virtual String get_name() const { return "ColorRamp"; }
@@ -55,8 +55,8 @@ public:
virtual bool handles(Object *p_node) const;
virtual void make_visible(bool p_visible);
ColorRampEditorPlugin(EditorNode *p_node);
~ColorRampEditorPlugin();
GradientEditorPlugin(EditorNode *p_node);
~GradientEditorPlugin();
};
#endif /* TOOLS_EDITOR_PLUGINS_COLOR_RAMP_EDITOR_PLUGIN_H_ */