summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/base_button.cpp1
-rw-r--r--scene/gui/control.h2
-rw-r--r--scene/gui/graph_edit.cpp102
-rw-r--r--scene/gui/popup.cpp13
-rw-r--r--scene/gui/scroll_bar.cpp134
-rw-r--r--scene/gui/shortcut.cpp (renamed from scene/gui/input_action.cpp)60
-rw-r--r--scene/gui/shortcut.h (renamed from scene/gui/input_action.h)8
-rw-r--r--scene/gui/text_edit.cpp35
-rw-r--r--scene/gui/tree.cpp32
-rw-r--r--scene/gui/video_player.cpp45
-rw-r--r--scene/gui/video_player.h13
11 files changed, 51 insertions, 394 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index eee23cba9f..8fd19e8655 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "base_button.h"
+
#include "os/keyboard.h"
#include "print_string.h"
#include "scene/main/viewport.h"
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 9d6abecec4..da5c4d0908 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -33,7 +33,7 @@
#include "math_2d.h"
#include "rid.h"
#include "scene/2d/canvas_item.h"
-#include "scene/gui/input_action.h"
+#include "scene/gui/shortcut.h"
#include "scene/main/node.h"
#include "scene/main/timer.h"
#include "scene/resources/theme.h"
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 532887feee..5b00aab2ef 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "graph_edit.h"
+
#include "os/input.h"
#include "os/keyboard.h"
#include "scene/gui/box_container.h"
@@ -593,8 +594,6 @@ void GraphEdit::_bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors,
void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const Vector2 &p_to, const Color &p_color, const Color &p_to_color) {
-#if 1
-
//cubic bezier code
float diff = p_to.x - p_from.x;
float cp_offset;
@@ -621,84 +620,53 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const
colors.push_back(p_to_color);
p_where->draw_polyline_colors(points, colors, 2, true);
-
-#else
-
- static const int steps = 20;
-
- //old cosine code
- Rect2 r;
- r.pos = p_from;
- r.expand_to(p_to);
- Vector2 sign = Vector2((p_from.x < p_to.x) ? 1 : -1, (p_from.y < p_to.y) ? 1 : -1);
- bool flip = sign.x * sign.y < 0;
-
- Vector2 prev;
- for (int i = 0; i <= steps; i++) {
-
- float d = i / float(steps);
- float c = -Math::cos(d * Math_PI) * 0.5 + 0.5;
- if (flip)
- c = 1.0 - c;
- Vector2 p = r.pos + Vector2(d * r.size.width, c * r.size.height);
-
- if (i > 0) {
-
- p_where->draw_line(prev, p, p_color.linear_interpolate(p_to_color, d), 2);
- }
-
- prev = p;
- }
-#endif
}
void GraphEdit::_connections_layer_draw() {
- {
- //draw connections
- List<List<Connection>::Element *> to_erase;
- for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
-
- NodePath fromnp(E->get().from);
+ //draw connections
+ List<List<Connection>::Element *> to_erase;
+ for (List<Connection>::Element *E = connections.front(); E; E = E->next()) {
- Node *from = get_node(fromnp);
- if (!from) {
- to_erase.push_back(E);
- continue;
- }
+ NodePath fromnp(E->get().from);
- GraphNode *gfrom = Object::cast_to<GraphNode>(from);
+ Node *from = get_node(fromnp);
+ if (!from) {
+ to_erase.push_back(E);
+ continue;
+ }
- if (!gfrom) {
- to_erase.push_back(E);
- continue;
- }
+ GraphNode *gfrom = Object::cast_to<GraphNode>(from);
- NodePath tonp(E->get().to);
- Node *to = get_node(tonp);
- if (!to) {
- to_erase.push_back(E);
- continue;
- }
+ if (!gfrom) {
+ to_erase.push_back(E);
+ continue;
+ }
- GraphNode *gto = Object::cast_to<GraphNode>(to);
+ NodePath tonp(E->get().to);
+ Node *to = get_node(tonp);
+ if (!to) {
+ to_erase.push_back(E);
+ continue;
+ }
- if (!gto) {
- to_erase.push_back(E);
- continue;
- }
+ GraphNode *gto = Object::cast_to<GraphNode>(to);
- Vector2 frompos = gfrom->get_connection_output_pos(E->get().from_port) + gfrom->get_offset() * zoom;
- Color color = gfrom->get_connection_output_color(E->get().from_port);
- Vector2 topos = gto->get_connection_input_pos(E->get().to_port) + gto->get_offset() * zoom;
- Color tocolor = gto->get_connection_input_color(E->get().to_port);
- _draw_cos_line(connections_layer, frompos, topos, color, tocolor);
+ if (!gto) {
+ to_erase.push_back(E);
+ continue;
}
- while (to_erase.size()) {
- connections.erase(to_erase.front()->get());
- to_erase.pop_front();
- }
+ Vector2 frompos = gfrom->get_connection_output_pos(E->get().from_port) + gfrom->get_offset() * zoom;
+ Color color = gfrom->get_connection_output_color(E->get().from_port);
+ Vector2 topos = gto->get_connection_input_pos(E->get().to_port) + gto->get_offset() * zoom;
+ Color tocolor = gto->get_connection_input_color(E->get().to_port);
+ _draw_cos_line(connections_layer, frompos, topos, color, tocolor);
+ }
+
+ while (to_erase.size()) {
+ connections.erase(to_erase.front()->get());
+ to_erase.pop_front();
}
}
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 10198f9410..5a2a552943 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -59,17 +59,10 @@ void Popup::_notification(int p_what) {
void Popup::_fix_size() {
-#if 0
- Point2 pos = get_position();
- Size2 size = get_size();
- Point2 window_size = window==this ? get_parent_area_size() :window->get_size();
-#else
-
Point2 pos = get_global_position();
Size2 size = get_size();
Point2 window_size = get_viewport_rect().size;
-#endif
if (pos.x + size.width > window_size.width)
pos.x = window_size.width - size.width;
if (pos.x < 0)
@@ -79,14 +72,8 @@ void Popup::_fix_size() {
pos.y = window_size.height - size.height;
if (pos.y < 0)
pos.y = 0;
-#if 0
- if (pos!=get_pos())
- set_position(pos);
-#else
if (pos != get_position())
set_global_position(pos);
-
-#endif
}
void Popup::set_as_minsize() {
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index 2250dc44d1..16d1b320b7 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -28,9 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "scroll_bar.h"
+
#include "os/keyboard.h"
#include "os/os.h"
#include "print_string.h"
+
bool ScrollBar::focus_by_default = false;
void ScrollBar::set_can_focus_by_default(bool p_can_focus) {
@@ -686,138 +688,6 @@ bool ScrollBar::is_smooth_scroll_enabled() const {
return smooth_scroll_enabled;
}
-#if 0
-
-void ScrollBar::mouse_button(const Point2& p_pos, int b->get_button_index(),bool b->is_pressed(),int p_modifier_mask) {
-
- // wheel!
-
- if (b->get_button_index()==BUTTON_WHEEL_UP && b->is_pressed()) {
-
- if (orientation==VERTICAL)
- set_val( get_val() - get_page() / 4.0 );
- else
- set_val( get_val() + get_page() / 4.0 );
-
- }
- if (b->get_button_index()==BUTTON_WHEEL_DOWN && b->is_pressed()) {
-
- if (orientation==HORIZONTAL)
- set_val( get_val() - get_page() / 4.0 );
- else
- set_val( get_val() + get_page() / 4.0 );
- }
-
- if (b->get_button_index()!=BUTTON_LEFT)
- return;
-
- if (b->is_pressed()) {
-
- int ofs = orientation==VERTICAL ? p_pos.y : p_pos.x ;
- int grabber_ofs = get_grabber_offset();
- int grabber_size = get_grabber_size();
-
- if ( ofs < grabber_ofs ) {
-
- set_val( get_val() - get_page() );
-
- } else if (ofs > grabber_ofs + grabber_size ) {
-
- set_val( get_val() + get_page() );
-
- } else {
-
-
- drag.active=true;
- drag.pos_at_click=get_click_pos(p_pos);
- drag.value_at_click=get_unit_value();
- }
-
-
- } else {
-
- drag.active=false;
- }
-
-}
-void ScrollBar::mouse_motion(const Point2& p_pos, const Point2& p_rel, int b->get_button_index()_mask) {
-
- if (!drag.active)
- return;
-
- double value_ofs=drag.value_at_click+(get_click_pos(p_pos)-drag.pos_at_click);
-
-
- value_ofs=value_ofs*( get_max() - get_min() );
- if (value_ofs<get_min())
- value_ofs=get_min();
- if (value_ofs>(get_max()-get_page()))
- value_ofs=get_max()-get_page();
- if (get_val()==value_ofs)
- return; //don't bother if the value is the same
-
- set_val( value_ofs );
-
-}
-
-bool ScrollBar::key(unsigned long p_unicode, unsigned long p_scan_code,bool b->is_pressed(),bool p_repeat,int p_modifier_mask) {
-
- if (!b->is_pressed())
- return false;
-
- switch (p_scan_code) {
-
- case KEY_LEFT: {
-
- if (orientation!=HORIZONTAL)
- return false;
- set_val( get_val() - get_step() );
-
- } break;
- case KEY_RIGHT: {
-
- if (orientation!=HORIZONTAL)
- return false;
- set_val( get_val() + get_step() );
-
- } break;
- case KEY_UP: {
-
- if (orientation!=VERTICAL)
- return false;
-
- set_val( get_val() - get_step() );
-
-
- } break;
- case KEY_DOWN: {
-
- if (orientation!=VERTICAL)
- return false;
- set_val( get_val() + get_step() );
-
- } break;
- case KEY_HOME: {
-
- set_val( get_min() );
-
- } break;
- case KEY_END: {
-
- set_val( get_max() );
-
- } break;
-
- default:
- return false;
-
- }
-
- return true;
-}
-
-#endif
-
void ScrollBar::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &ScrollBar::_gui_input);
diff --git a/scene/gui/input_action.cpp b/scene/gui/shortcut.cpp
index fb2385dd50..f37410e77b 100644
--- a/scene/gui/input_action.cpp
+++ b/scene/gui/shortcut.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* input_action.cpp */
+/* shortcut.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,7 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "input_action.h"
+#include "shortcut.h"
+
#include "os/keyboard.h"
void ShortCut::set_shortcut(const Ref<InputEvent> &p_shortcut) {
@@ -52,61 +53,6 @@ String ShortCut::get_as_text() const {
return shortcut->as_text();
else
return "None";
-#if 0
- switch (shortcut.type) {
-
- case Ref<InputEvent>::NONE: {
-
- return "None";
- } break;
- case Ref<InputEvent>::KEY: {
-
- String str;
- if (shortcut->get_shift())
- str += RTR("Shift+");
- if (shortcut->get_alt())
- str += RTR("Alt+");
- if (shortcut->get_control())
- str += RTR("Ctrl+");
- if (shortcut->get_metakey())
- str += RTR("Meta+");
-
- str += keycode_get_string(shortcut->get_scancode()).capitalize();
-
- return str;
- } break;
- case Ref<InputEvent>::JOYPAD_BUTTON: {
-
- String str = RTR("Device") + " " + itos(shortcut.device) + ", " + RTR("Button") + " " + itos(shortcut.joy_button->get_button_index());
- str += ".";
-
- return str;
- } break;
- case Ref<InputEvent>::MOUSE_BUTTON: {
-
- String str = RTR("Device") + " " + itos(shortcut.device) + ", ";
- switch (shortcut->get_button_index()) {
- case BUTTON_LEFT: str += RTR("Left Button."); break;
- case BUTTON_RIGHT: str += RTR("Right Button."); break;
- case BUTTON_MIDDLE: str += RTR("Middle Button."); break;
- case BUTTON_WHEEL_UP: str += RTR("Wheel Up."); break;
- case BUTTON_WHEEL_DOWN: str += RTR("Wheel Down."); break;
- default: str += RTR("Button") + " " + itos(shortcut->get_button_index()) + ".";
- }
-
- return str;
- } break;
- case Ref<InputEvent>::JOYPAD_MOTION: {
-
- int ax = shortcut.joy_motion.axis;
- String str = RTR("Device") + " " + itos(shortcut.device) + ", " + RTR("Axis") + " " + itos(ax) + ".";
-
- return str;
- } break;
- }
-
- return "";
-#endif
}
bool ShortCut::is_valid() const {
diff --git a/scene/gui/input_action.h b/scene/gui/shortcut.h
index 0bff5a1762..8d85bb920f 100644
--- a/scene/gui/input_action.h
+++ b/scene/gui/shortcut.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* input_action.h */
+/* shortcut.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,8 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef INPUTACTION_H
-#define INPUTACTION_H
+#ifndef SHORTCUT_H
+#define SHORTCUT_H
#include "os/input_event.h"
#include "resource.h"
@@ -53,4 +53,4 @@ public:
ShortCut();
};
-#endif // INPUTACTION_H
+#endif // SHORTCUT_H
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 9add6eb607..e82044b133 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -27,13 +27,12 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-
#include "text_edit.h"
+
+#include "message_queue.h"
#include "os/input.h"
#include "os/keyboard.h"
#include "os/os.h"
-
-#include "message_queue.h"
#include "project_settings.h"
#include "scene/main/viewport.h"
@@ -4466,18 +4465,6 @@ void TextEdit::_update_completion_candidates() {
// The top of the list is the best match
completion_current = completion_options[0];
-
-#if 0 // even there's only one option, user still get the chance to choose using it or not
- if (completion_options.size()==1) {
- //one option to complete, just complete it automagically
- _confirm_completion();
- //insert_text_at_cursor(completion_options[0].substr(s.length(),completion_options[0].length()-s.length()));
- _cancel_completion();
- return;
-
- }
-#endif
-
completion_enabled = true;
}
@@ -4904,24 +4891,6 @@ TextEdit::TextEdit() {
click_select_held->set_wait_time(0.05);
click_select_held->connect("timeout", this, "_click_selection_held");
-#if 0
- syntax_coloring=true;
- keywords["void"]=Color(0.3,0.0,0.1);
- keywords["int"]=Color(0.3,0.0,0.1);
- keywords["function"]=Color(0.3,0.0,0.1);
- keywords["class"]=Color(0.3,0.0,0.1);
- keywords["extends"]=Color(0.3,0.0,0.1);
- keywords["constructor"]=Color(0.3,0.0,0.1);
- symbol_color=Color(0.1,0.0,0.3,1.0);
-
- color_regions.push_back(ColorRegion("/*","*/",Color(0.4,0.6,0,4)));
- color_regions.push_back(ColorRegion("//","",Color(0.6,0.6,0.4)));
- color_regions.push_back(ColorRegion("\"","\"",Color(0.4,0.7,0.7)));
- color_regions.push_back(ColorRegion("'","'",Color(0.4,0.8,0.8)));
- color_regions.push_back(ColorRegion("#","",Color(0.2,1.0,0.2)));
-
-#endif
-
current_op.type = TextOperation::TYPE_NONE;
undo_enabled = true;
undo_stack_pos = NULL;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 1940cef34d..5e15bceb7d 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "tree.h"
+
#include "os/input.h"
#include "os/keyboard.h"
#include "os/os.h"
@@ -990,41 +991,10 @@ void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, co
rect.size.x -= bmsize.x + cache.hseparation;
}
- /*
- if (p_tool)
- rect.size.x-=Math::floor(rect.size.y/2);
- */
-
rect.position.y += Math::floor((rect.size.y - font->get_height()) / 2.0) + font->get_ascent();
font->draw(ci, rect.position, text, p_color, rect.size.x);
}
-#if 0
-void Tree::draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color) {
-
- RID ci = get_canvas_item();
- if (!p_icon.is_null()) {
- Size2i bmsize = p_icon->get_size();
- if (p_icon_max_w>0 && bmsize.width > p_icon_max_w) {
- bmsize.height = bmsize.height * p_icon_max_w / bmsize.width;
- bmsize.width=p_icon_max_w;
- }
-
- draw_texture_rect(p_icon,Rect2(p_rect.pos + Size2i(0,Math::floor((p_rect.size.y-bmsize.y)/2)),bmsize));
- p_rect.pos.x+=bmsize.x+cache.hseparation;
- p_rect.size.x-=bmsize.x+cache.hseparation;
-
- }
-
- if (p_tool)
- p_rect.size.x-=Math::floor(p_rect.size.y/2);
-
- Ref<Font> font = cache.font;
-
- p_rect.pos.y+=Math::floor((p_rect.size.y-font->get_height())/2.0) +font->get_ascent();
- font->draw(ci,p_rect.pos,p_text,p_color,p_rect.size.x);
-}
-#endif
int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item) {
if (p_pos.y - cache.offset.y > (p_draw_size.height))
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index b39b392017..a92155cc4f 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -28,27 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "video_player.h"
+
#include "os/os.h"
#include "servers/audio_server.h"
-/*
-
-int VideoPlayer::InternalStream::get_channel_count() const {
-
- return player->sp_get_channel_count();
-}
-void VideoPlayer::InternalStream::set_mix_rate(int p_rate){
-
- return player->sp_set_mix_rate(p_rate);
-}
-bool VideoPlayer::InternalStream::mix(int32_t *p_buffer,int p_frames){
-
- return player->sp_mix(p_buffer,p_frames);
-}
-void VideoPlayer::InternalStream::update(){
-
- player->sp_update();
-}
-*/
int VideoPlayer::sp_get_channel_count() const {
@@ -69,31 +51,6 @@ bool VideoPlayer::sp_mix(int32_t *p_buffer, int p_frames) {
return false;
}
-void VideoPlayer::sp_update() {
-#if 0
- _THREAD_SAFE_METHOD_
- //update is unused
- if (!paused && playback.is_valid()) {
-
- if (!playback->is_playing()) {
- //stream depleted data, but there's still audio in the ringbuffer
- //check that all this audio has been flushed before stopping the stream
- int to_mix = resampler.get_total() - resampler.get_todo();
- if (to_mix==0) {
- stop();
- return;
- }
-
- return;
- }
-
- int todo =resampler.get_todo();
- int wrote = playback->mix(resampler.get_write_buffer(),todo);
- resampler.write(wrote);
- }
-#endif
-}
-
int VideoPlayer::_audio_mix_callback(void *p_udata, const int16_t *p_data, int p_frames) {
VideoPlayer *vp = (VideoPlayer *)p_udata;
diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h
index 731ba2abd7..b78f3aabe7 100644
--- a/scene/gui/video_player.h
+++ b/scene/gui/video_player.h
@@ -38,23 +38,12 @@ class VideoPlayer : public Control {
GDCLASS(VideoPlayer, Control);
- /* struct InternalStream : public AudioServer::AudioStream {
- VideoPlayer *player;
- virtual int get_channel_count() const;
- virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate
- virtual bool mix(int32_t *p_buffer,int p_frames);
- virtual void update();
- };
-*/
-
- // InternalStream internal_stream;
Ref<VideoStreamPlayback> playback;
Ref<VideoStream> stream;
int sp_get_channel_count() const;
void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate
bool sp_mix(int32_t *p_buffer, int p_frames);
- void sp_update();
RID stream_rid;
@@ -118,4 +107,4 @@ public:
~VideoPlayer();
};
-#endif
+#endif // VIDEO_PLAYER_H