summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorMarianoGNU <marianognu.easyrpg@gmail.com>2016-01-18 22:10:44 -0300
committerMarianoGNU <marianognu.easyrpg@gmail.com>2016-01-18 22:10:44 -0300
commit76ee2035b6726dbe9f2dc356e71069ff7b6c9d78 (patch)
tree1ddf0826ababb9e08f04bff1973a8997a0b40ca8 /scene/gui
parentc2aaeaaf5afb612cde195075575a955fa0650f4f (diff)
Add a slider to handle zoom
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/graph_edit.cpp22
-rw-r--r--scene/gui/graph_edit.h5
2 files changed, 24 insertions, 3 deletions
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 884d24c813..d0c82c15b8 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -1,6 +1,7 @@
#include "graph_edit.h"
#include "os/input.h"
#include "os/keyboard.h"
+#include "scene/gui/box_container.h"
bool GraphEditFilter::has_point(const Point2& p_point) const {
return ge->_filter_input(p_point);
@@ -185,6 +186,8 @@ void GraphEdit::_notification(int p_what) {
h_scroll->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,hmin.height);
h_scroll->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,0);
+ zoom_icon->set_texture( get_icon("Zoom", "EditorIcons"));
+
}
if (p_what==NOTIFICATION_DRAW) {
VS::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
@@ -687,11 +690,11 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
}
if (b.button_index==BUTTON_WHEEL_UP && b.pressed) {
- set_zoom(zoom/0.9);
+ sl_zoom->set_val(zoom/0.9);
}
if (b.button_index==BUTTON_WHEEL_DOWN && b.pressed) {
- set_zoom(zoom*0.9);
+ sl_zoom->set_val(zoom*0.9);
}
}
@@ -826,4 +829,19 @@ GraphEdit::GraphEdit() {
v_scroll->connect("value_changed", this,"_scroll_moved");
zoom = 1;
+
+ HBoxContainer* tools = memnew( HBoxContainer );
+ add_child(tools);
+
+ zoom_icon = memnew( TextureFrame );
+ tools->add_child(zoom_icon);
+
+ sl_zoom = memnew( HSlider );
+ sl_zoom->set_min(0.01);
+ sl_zoom->set_max(4);
+ sl_zoom->set_val(1);
+ sl_zoom->set_step(0.01);
+ sl_zoom->connect("value_changed", this, "set_zoom");
+ tools->add_child(sl_zoom);
+ sl_zoom->set_custom_minimum_size(Size2(200,0));
}
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index b63597afba..ec278827b1 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -3,7 +3,8 @@
#include "scene/gui/graph_node.h"
#include "scene/gui/scroll_bar.h"
-
+#include "scene/gui/slider.h"
+#include "texture_frame.h"
class GraphEdit;
class GraphEditFilter : public Control {
@@ -34,6 +35,8 @@ public:
};
private:
+ TextureFrame* zoom_icon;
+ HSlider* sl_zoom;
HScrollBar* h_scroll;
VScrollBar* v_scroll;