summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/item_list.cpp27
-rw-r--r--scene/gui/item_list.h2
-rw-r--r--scene/gui/video_player.cpp3
3 files changed, 31 insertions, 1 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 51ab49e643..197e474fd6 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -257,6 +257,20 @@ void ItemList::unselect(int p_idx) {
}
update();
}
+
+void ItemList::unselect_all() {
+
+ if (items.size() < 1)
+ return;
+
+ for (int i = 0; i < items.size(); i++) {
+
+ items[i].selected = false;
+ }
+
+ update();
+}
+
bool ItemList::is_selected(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, items.size(), false);
@@ -530,6 +544,9 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
return;
}
+
+ // Since closest is null, more likely we clicked on empty space, so send signal to interested controls. Allows, for example, implement items deselecting.
+ emit_signal("nothing_selected");
}
if (mb.is_valid() && mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed()) {
@@ -1249,6 +1266,15 @@ Vector<int> ItemList::get_selected_items() {
return selected;
}
+bool ItemList::is_anything_selected() {
+ for (int i = 0; i < items.size(); i++) {
+ if (items[i].selected)
+ return true;
+ }
+
+ return false;
+}
+
void ItemList::_set_items(const Array &p_items) {
ERR_FAIL_COND(p_items.size() % 3);
@@ -1409,6 +1435,7 @@ void ItemList::_bind_methods() {
ADD_SIGNAL(MethodInfo("multi_selected", PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::BOOL, "selected")));
ADD_SIGNAL(MethodInfo("item_activated", PropertyInfo(Variant::INT, "index")));
ADD_SIGNAL(MethodInfo("rmb_clicked", PropertyInfo(Variant::VECTOR2, "at_position")));
+ ADD_SIGNAL(MethodInfo("nothing_selected"));
GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec", 2000);
}
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index ccdd705325..b1e1e5eeb0 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -156,8 +156,10 @@ public:
void select(int p_idx, bool p_single = true);
void unselect(int p_idx);
+ void unselect_all();
bool is_selected(int p_idx) const;
Vector<int> get_selected_items();
+ bool is_anything_selected();
void set_current(int p_current);
int get_current() const;
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index 1b6bd30b58..8f567f9796 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -84,7 +84,7 @@ void VideoPlayer::_mix_audio() {
return;
}
- AudioFrame *buffer = mix_buffer.ptr();
+ AudioFrame *buffer = mix_buffer.ptrw();
int buffer_size = mix_buffer.size();
// Resample
@@ -490,6 +490,7 @@ VideoPlayer::VideoPlayer() {
expand = true;
audio_track = 0;
+ bus_index = 0;
buffering_ms = 500;
server_mix_rate = 44100;