Browse Source

Made MenuButton and ColorPickerButton's "get_popup" methods return constant.

Michael Alexsander Silva Dias 7 years ago
parent
commit
23080c7ed7

+ 2 - 2
doc/classes/ColorPickerButton.xml

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

+ 1 - 1
doc/classes/MenuButton.xml

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

+ 8 - 10
scene/gui/color_picker.cpp

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

+ 2 - 2
scene/gui/color_picker.h

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

+ 1 - 16
scene/gui/menu_button.cpp

@@ -63,25 +63,10 @@ void MenuButton::pressed() {
 
 
 void MenuButton::_gui_input(Ref<InputEvent> p_event) {
 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);
 	BaseButton::_gui_input(p_event);
 }
 }
 
 
-PopupMenu *MenuButton::get_popup() {
+PopupMenu *MenuButton::get_popup() const {
 
 
 	return popup;
 	return popup;
 }
 }

+ 1 - 1
scene/gui/menu_button.h

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