summaryrefslogtreecommitdiff
path: root/scene/gui/tab_container.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/tab_container.cpp')
-rw-r--r--scene/gui/tab_container.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 952f2a9710..6bbfa1aeb0 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -63,11 +63,13 @@ int TabContainer::_get_top_margin() const {
return tab_height + content_height;
}
-void TabContainer::_gui_input(const InputEvent &p_event) {
+void TabContainer::_gui_input(const Ref<InputEvent> &p_event) {
- if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index == BUTTON_LEFT) {
+ Ref<InputEventMouseButton> mb = p_event;
- Point2 pos(p_event.mouse_button.x, p_event.mouse_button.y);
+ if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
+
+ Point2 pos(mb->get_pos().x, mb->get_pos().y);
Size2 size = get_size();
// Click must be on tabs in the tab header area.
@@ -206,9 +208,6 @@ void TabContainer::_notification(int p_what) {
break;
}
- // Draw the tab area.
- panel->draw(canvas, Rect2(0, header_height, size.width, size.height - header_height));
-
// Draw all visible tabs.
int x = 0;
for (int i = 0; i < tab_widths.size(); i++) {
@@ -227,7 +226,7 @@ void TabContainer::_notification(int p_what) {
// Draw the tab background.
int tab_width = tab_widths[i];
- Rect2 tab_rect(tabs_ofs_cache + x, 2, tab_width, header_height);
+ Rect2 tab_rect(tabs_ofs_cache + x, 0, tab_width, header_height);
tab_style->draw(canvas, tab_rect);
// Draw the tab contents.
@@ -282,6 +281,8 @@ void TabContainer::_notification(int p_what) {
Color(1, 1, 1, first_tab_cache > 0 ? 1.0 : 0.5));
}
+ // Draw the tab area.
+ panel->draw(canvas, Rect2(0, header_height, size.width, size.height - header_height));
} break;
case NOTIFICATION_THEME_CHANGED: {
if (get_tab_count() > 0) {
@@ -660,7 +661,7 @@ TabContainer::TabContainer() {
current = 0;
previous = 0;
mouse_x_cache = 0;
- align = ALIGN_LEFT;
+ align = ALIGN_CENTER;
tabs_visible = true;
popup = NULL;
-} \ No newline at end of file
+}