Initial gui setup for the ProceduralAnimationPlayerEditorPlugin.

This commit is contained in:
Relintai 2020-03-14 02:25:16 +01:00
parent 9b1868668d
commit 579a207388
2 changed files with 91 additions and 4 deletions

View File

@ -22,8 +22,12 @@ SOFTWARE.
#include "procedural_animation_player_editor_plugin.h"
#include "procedural_animation_editor_plugin.h"
#include "editor/editor_scale.h"
#include "core/math/math_defs.h"
void ProceduralAnimationPlayerEditor::edit(ProceduralAnimationPlayer *player) {
_animation_player = player;
@ -41,16 +45,82 @@ ProceduralAnimationPlayerEditor::ProceduralAnimationPlayerEditor() {
}
ProceduralAnimationPlayerEditor::ProceduralAnimationPlayerEditor(EditorNode *p_editor) {
set_h_size_flags(SIZE_EXPAND_FILL);
_animation_player = NULL;
_selected_category = -1;
_selected_animation = -1;
set_h_size_flags(SIZE_EXPAND_FILL);
//top bar
HBoxContainer *hbc = memnew(HBoxContainer);
add_child(hbc);
_category_option_button = memnew(OptionButton);
_category_option_button->set_h_size_flags(SIZE_EXPAND_FILL);
_category_option_button->connect("item_selected", this, "on_category_option_button_pressed");
hbc->add_child(_category_option_button);
_animation_option_button = memnew(OptionButton);
_animation_option_button->set_h_size_flags(SIZE_EXPAND_FILL);
_animation_option_button->connect("item_selected", this, "on_animation_option_button_pressed");
hbc->add_child(_animation_option_button);
_play_bw_from = memnew(ToolButton);
_play_bw_from->set_tooltip(TTR("Play selected animation backwards from current pos. (A)"));
hbc->add_child(_play_bw_from);
_play_bw = memnew(ToolButton);
_play_bw->set_tooltip(TTR("Play selected animation backwards from end. (Shift+A)"));
hbc->add_child(_play_bw);
_stop = memnew(ToolButton);
_stop->set_toggle_mode(true);
hbc->add_child(_stop);
_stop->set_tooltip(TTR("Stop animation playback. (S)"));
_play = memnew(ToolButton);
_play->set_tooltip(TTR("Play selected animation from start. (Shift+D)"));
hbc->add_child(_play);
_play_from = memnew(ToolButton);
_play_from->set_tooltip(TTR("Play selected animation from current pos. (D)"));
hbc->add_child(_play_from);
_pin = memnew(ToolButton);
_pin->set_toggle_mode(true);
_pin->set_tooltip(TTR("Pin"));
hbc->add_child(_pin);
Control *spacer = memnew(Control);
spacer->set_custom_minimum_size(Size2(0, 2 * EDSCALE));
add_child(spacer);
//bottom
_animation_editor = memnew(ProceduralAnimationEditor(p_editor));
//_animation_editor->set_margin(Margin::MARGIN_TOP, 8 * EDSCALE);
_animation_editor->set_v_size_flags(SIZE_EXPAND_FILL);
add_child(_animation_editor);
}
ProceduralAnimationPlayerEditor::~ProceduralAnimationPlayerEditor() {
}
void ProceduralAnimationPlayerEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
_play->set_icon(get_icon("PlayStart", "EditorIcons"));
_play_from->set_icon(get_icon("Play", "EditorIcons"));
_play_bw->set_icon(get_icon("PlayStartBackwards", "EditorIcons"));
_play_bw_from->set_icon(get_icon("PlayBackwards", "EditorIcons"));
_stop->set_icon(get_icon("Stop", "EditorIcons"));
_pin->set_icon(get_icon("Pin", "EditorIcons"));
} break;
}
}
void ProceduralAnimationPlayerEditorPlugin::edit(Object *p_object) {
if (Object::cast_to<ProceduralAnimationPlayer>(p_object)) {
animation_editor->edit(Object::cast_to<ProceduralAnimationPlayer>(p_object));

View File

@ -23,11 +23,15 @@ SOFTWARE.
#ifndef PROCEDURAL_ANIMATION_PLAYER_EDITOR_PLUGIN_H
#define PROCEDURAL_ANIMATION_PLAYER_EDITOR_PLUGIN_H
#include "scene/gui/box_container.h"
#include "editor/editor_plugin.h"
#include "scene/gui/box_container.h"
#include "procedural_animation_player.h"
#include "core/core_string_names.h"
#include "procedural_animation_player.h"
#include "scene/gui/menu_button.h"
class ProceduralAnimationEditor;
class ProceduralAnimationPlayerEditor : public VBoxContainer {
GDCLASS(ProceduralAnimationPlayerEditor, VBoxContainer);
@ -40,12 +44,25 @@ public:
~ProceduralAnimationPlayerEditor();
protected:
void _notification(int p_what);
static void _bind_methods();
private:
int _selected_category;
int _selected_animation;
OptionButton *_category_option_button;
OptionButton *_animation_option_button;
Button *_stop;
Button *_play;
Button *_play_from;
Button *_play_bw;
Button *_play_bw_from;
ToolButton *_pin;
ProceduralAnimationEditor *_animation_editor;
ProceduralAnimationPlayer *_animation_player;
};