Path: blob/master/editor/scene/particle_process_material_editor_plugin.h
9903 views
/**************************************************************************/1/* particle_process_material_editor_plugin.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "editor/inspector/editor_properties.h"33#include "editor/plugins/editor_plugin.h"3435class Button;36class EditorSpinSlider;37class Label;38class ParticleProcessMaterial;39class Range;40class VBoxContainer;4142class ParticleProcessMaterialMinMaxPropertyEditor : public EditorProperty {43GDCLASS(ParticleProcessMaterialMinMaxPropertyEditor, EditorProperty);4445enum class Hover {46NONE,47LEFT,48RIGHT,49MIDDLE,50};5152enum class Drag {53NONE,54LEFT,55RIGHT,56MIDDLE,57SCALE,58};5960enum class Mode {61RANGE,62MIDPOINT,63};6465Ref<Texture2D> range_slider_left_icon;66Ref<Texture2D> range_slider_right_icon;6768Color background_color;69Color normal_color;70Color hovered_color;71Color drag_color;72Color midpoint_color;7374Control *range_edit_widget = nullptr;75Button *toggle_mode_button = nullptr;76Range *min_range = nullptr;77Range *max_range = nullptr;7879EditorSpinSlider *min_edit = nullptr;80EditorSpinSlider *max_edit = nullptr;8182Vector2 edit_size;83Vector2 margin;84Vector2 usable_area;8586Vector2 property_range;8788bool mouse_inside = false;89Hover hover = Hover::NONE;9091Drag drag = Drag::NONE;92float drag_from_value = 0.0;93float drag_midpoint = 0.0;94float drag_origin = 0.0;9596Mode slider_mode = Mode::RANGE;9798void _update_sizing();99void _range_edit_draw();100void _range_edit_gui_input(const Ref<InputEvent> &p_event);101void _set_mouse_inside(bool p_inside);102103float _get_min_ratio() const;104float _get_max_ratio() const;105float _get_left_offset() const;106float _get_right_offset() const;107Rect2 _get_middle_rect() const;108109void _set_clamped_values(float p_min, float p_max);110void _sync_property();111112void _update_mode();113void _toggle_mode(bool p_edit_mode);114void _update_slider_values();115void _sync_sliders(float, const EditorSpinSlider *p_changed_slider);116float _get_max_spread() const;117118protected:119void _notification(int p_what);120121public:122void setup(float p_min, float p_max, float p_step, bool p_allow_less, bool p_allow_greater, bool p_degrees);123virtual void update_property() override;124125ParticleProcessMaterialMinMaxPropertyEditor();126};127128class EditorInspectorParticleProcessMaterialPlugin : public EditorInspectorPlugin {129GDCLASS(EditorInspectorParticleProcessMaterialPlugin, EditorInspectorPlugin);130131public:132virtual bool can_handle(Object *p_object) override;133virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide = false) override;134};135136137