Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
057489b3
Unverified
Commit
057489b3
authored
Jun 24, 2020
by
Rémi Verschelde
Committed by
GitHub
Jun 24, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #39805 from RandomShaper/fix_gone_popup_crash
Handle gone TabContainer popup nicely
parents
527ab830
b5e44a12
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
tab_container.cpp
scene/gui/tab_container.cpp
+20
-3
tab_container.h
scene/gui/tab_container.h
+1
-1
No files found.
scene/gui/tab_container.cpp
View file @
057489b3
...
...
@@ -71,6 +71,8 @@ int TabContainer::_get_top_margin() const {
void
TabContainer
::
_gui_input
(
const
Ref
<
InputEvent
>
&
p_event
)
{
Ref
<
InputEventMouseButton
>
mb
=
p_event
;
Popup
*
popup
=
get_popup
();
if
(
mb
.
is_valid
()
&&
mb
->
is_pressed
()
&&
mb
->
get_button_index
()
==
BUTTON_LEFT
)
{
Point2
pos
(
mb
->
get_position
().
x
,
mb
->
get_position
().
y
);
Size2
size
=
get_size
();
...
...
@@ -82,6 +84,7 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) {
// Handle menu button.
Ref
<
Texture2D
>
menu
=
get_theme_icon
(
"menu"
);
if
(
popup
&&
pos
.
x
>
size
.
width
-
menu
->
get_width
())
{
emit_signal
(
"pre_popup_pressed"
);
...
...
@@ -223,6 +226,7 @@ void TabContainer::_notification(int p_what) {
int
header_width
=
get_size
().
width
-
side_margin
*
2
;
// Find the width of the header area.
Popup
*
popup
=
get_popup
();
if
(
popup
)
{
header_width
-=
menu
->
get_width
();
}
...
...
@@ -284,6 +288,7 @@ void TabContainer::_notification(int p_what) {
int
header_x
=
side_margin
;
int
header_width
=
size
.
width
-
side_margin
*
2
;
int
header_height
=
_get_top_margin
();
Popup
*
popup
=
get_popup
();
if
(
popup
)
{
header_width
-=
menu
->
get_width
();
}
...
...
@@ -749,6 +754,7 @@ int TabContainer::get_tab_idx_at_point(const Point2 &p_point) const {
Size2
size
=
get_size
();
int
right_ofs
=
0
;
Popup
*
popup
=
get_popup
();
if
(
popup
)
{
Ref
<
Texture2D
>
menu
=
get_theme_icon
(
"menu"
);
right_ofs
+=
menu
->
get_width
();
...
...
@@ -948,12 +954,24 @@ Size2 TabContainer::get_minimum_size() const {
void
TabContainer
::
set_popup
(
Node
*
p_popup
)
{
ERR_FAIL_NULL
(
p_popup
);
popup
=
Object
::
cast_to
<
Popup
>
(
p_popup
);
Popup
*
popup
=
Object
::
cast_to
<
Popup
>
(
p_popup
);
popup_obj_id
=
popup
?
popup
->
get_instance_id
()
:
ObjectID
();
update
();
}
Popup
*
TabContainer
::
get_popup
()
const
{
return
popup
;
if
(
popup_obj_id
.
is_valid
())
{
Popup
*
popup
=
Object
::
cast_to
<
Popup
>
(
ObjectDB
::
get_instance
(
popup_obj_id
));
if
(
popup
)
{
return
popup
;
}
else
{
#ifdef DEBUG_ENABLED
ERR_PRINT
(
"Popup assigned to TabContainer is gone!"
);
#endif
popup_obj_id
=
ObjectID
();
}
}
return
nullptr
;
}
void
TabContainer
::
set_drag_to_rearrange_enabled
(
bool
p_enabled
)
{
...
...
@@ -1037,7 +1055,6 @@ TabContainer::TabContainer() {
previous
=
0
;
align
=
ALIGN_CENTER
;
tabs_visible
=
true
;
popup
=
nullptr
;
drag_to_rearrange_enabled
=
false
;
tabs_rearrange_group
=
-
1
;
use_hidden_tabs_for_min_size
=
false
;
...
...
scene/gui/tab_container.h
View file @
057489b3
...
...
@@ -57,7 +57,7 @@ private:
TabAlign
align
;
Control
*
_get_tab
(
int
p_idx
)
const
;
int
_get_top_margin
()
const
;
Popup
*
popup
;
mutable
ObjectID
popup_obj_id
;
bool
drag_to_rearrange_enabled
;
bool
use_hidden_tabs_for_min_size
;
int
tabs_rearrange_group
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment