Merge pull request #15049 from YeldhamDev/get_popup_const

Made MenuButton and ColorPickerButton's "get_popup" methods return constant
This commit is contained in:
Noshyaar 2017-12-27 10:20:56 +07:00 committed by GitHub
commit 198bb5309d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 32 deletions

View File

@ -11,14 +11,14 @@
<demos>
</demos>
<methods>
<method name="get_picker">
<method name="get_picker" qualifiers="const">
<return type="ColorPicker">
</return>
<description>
Returns the [code]ColorPicker[/code] that this [code]ColorPickerButton[/code] toggles.
</description>
</method>
<method name="get_popup">
<method name="get_popup" qualifiers="const">
<return type="PopupPanel">
</return>
<description>

View File

@ -11,7 +11,7 @@
<demos>
</demos>
<methods>
<method name="get_popup">
<method name="get_popup" qualifiers="const">
<return type="PopupMenu">
</return>
<description>

View File

@ -39,33 +39,32 @@ void ColorPicker::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
//sample->set_texture(get_icon("color_sample"));
btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
bt_add_preset->set_icon(get_icon("add_preset"));
_update_controls();
} break;
case NOTIFICATION_ENTER_TREE: {
btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
bt_add_preset->set_icon(get_icon("add_preset"));
_update_color();
} break;
case NOTIFICATION_PARENTED: {
for (int i = 0; i < 4; i++)
set_margin((Margin)i, get_constant("margin"));
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
Popup *p = Object::cast_to<Popup>(get_parent());
if (p)
p->set_size(Size2(get_combined_minimum_size().width + get_constant("margin") * 2, get_combined_minimum_size().height + get_constant("margin") * 2));
} break;
case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {
if (screen != NULL) {
if (screen->is_visible()) {
screen->hide();
@ -523,7 +522,6 @@ ColorPicker::ColorPicker() :
add_child(hb_edit);
w_edit = memnew(Control);
//w_edit->set_ignore_mouse(false);
w_edit->set_custom_minimum_size(Size2(get_constant("h_width"), 0));
w_edit->set_h_size_flags(SIZE_FILL);
w_edit->set_v_size_flags(SIZE_EXPAND_FILL);
@ -589,7 +587,6 @@ ColorPicker::ColorPicker() :
c_text->set_h_size_flags(SIZE_EXPAND_FILL);
_update_controls();
//_update_color();
updating = false;
set_pick_color(Color(1, 1, 1));
@ -599,7 +596,6 @@ ColorPicker::ColorPicker() :
preset = memnew(TextureRect);
bbc->add_child(preset);
//preset->set_ignore_mouse(false);
preset->connect("gui_input", this, "_preset_input");
preset->connect("draw", this, "_update_presets");
@ -660,11 +656,13 @@ bool ColorPickerButton::is_editing_alpha() const {
return picker->is_editing_alpha();
}
ColorPicker *ColorPickerButton::get_picker() {
ColorPicker *ColorPickerButton::get_picker() const {
return picker;
}
PopupPanel *ColorPickerButton::get_popup() {
PopupPanel *ColorPickerButton::get_popup() const {
return popup;
}

View File

@ -129,8 +129,8 @@ public:
void set_edit_alpha(bool p_show);
bool is_editing_alpha() const;
ColorPicker *get_picker();
PopupPanel *get_popup();
ColorPicker *get_picker() const;
PopupPanel *get_popup() const;
ColorPickerButton();
};

View File

@ -63,25 +63,10 @@ void MenuButton::pressed() {
void MenuButton::_gui_input(Ref<InputEvent> p_event) {
/*if (p_event.type==InputEvent::MOUSE_BUTTON && p_event->get_button_index()==BUTTON_LEFT) {
clicked=p_event->is_pressed();
}
if (clicked && p_event.type==InputEvent::MOUSE_MOTION && popup->is_visible_in_tree()) {
Point2 gt = Point2(p_event.mouse_motion.x,p_event.mouse_motion.y);
gt = get_global_transform().xform(gt);
Point2 lt = popup->get_transform().affine_inverse().xform(gt);
if (popup->has_point(lt)) {
//print_line("HAS POINT!!!");
popup->call_deferred("grab_click_focus");
}
}*/
BaseButton::_gui_input(p_event);
}
PopupMenu *MenuButton::get_popup() {
PopupMenu *MenuButton::get_popup() const {
return popup;
}

View File

@ -54,7 +54,7 @@ protected:
static void _bind_methods();
public:
PopupMenu *get_popup();
PopupMenu *get_popup() const;
void set_disable_shortcuts(bool p_disabled);
MenuButton();