Merge pull request #56768 from YeldhamDev/dock_float_theme
This commit is contained in:
commit
650e218b96
|
@ -11,16 +11,6 @@
|
||||||
<link title="2D Finite State Machine Demo">https://godotengine.org/asset-library/asset/516</link>
|
<link title="2D Finite State Machine Demo">https://godotengine.org/asset-library/asset/516</link>
|
||||||
<link title="3D Inverse Kinematics Demo">https://godotengine.org/asset-library/asset/523</link>
|
<link title="3D Inverse Kinematics Demo">https://godotengine.org/asset-library/asset/523</link>
|
||||||
</tutorials>
|
</tutorials>
|
||||||
<members>
|
|
||||||
<member name="mode" type="int" setter="set_mode" getter="get_mode" enum="Panel.Mode" default="0">
|
|
||||||
</member>
|
|
||||||
</members>
|
|
||||||
<constants>
|
|
||||||
<constant name="MODE_BACKGROUND" value="0" enum="Mode">
|
|
||||||
</constant>
|
|
||||||
<constant name="MODE_FOREGROUND" value="1" enum="Mode">
|
|
||||||
</constant>
|
|
||||||
</constants>
|
|
||||||
<theme_items>
|
<theme_items>
|
||||||
<theme_item name="panel" data_type="style" type="StyleBox">
|
<theme_item name="panel" data_type="style" type="StyleBox">
|
||||||
The style of this [Panel].
|
The style of this [Panel].
|
||||||
|
|
|
@ -4236,8 +4236,9 @@ void EditorNode::_dock_make_float() {
|
||||||
Control *dock = dock_slot[dock_popup_selected]->get_current_tab_control();
|
Control *dock = dock_slot[dock_popup_selected]->get_current_tab_control();
|
||||||
ERR_FAIL_COND(!dock);
|
ERR_FAIL_COND(!dock);
|
||||||
|
|
||||||
const Size2i borders = Size2i(4, 4) * EDSCALE;
|
Size2 borders = Size2(4, 4) * EDSCALE;
|
||||||
Size2 dock_size = dock->get_size() + borders * 2; // remember size
|
// Remember size and position before removing it from the main window.
|
||||||
|
Size2 dock_size = dock->get_size() + borders * 2;
|
||||||
Point2 dock_screen_pos = dock->get_global_position() + get_tree()->get_root()->get_position() - borders;
|
Point2 dock_screen_pos = dock->get_global_position() + get_tree()->get_root()->get_position() - borders;
|
||||||
|
|
||||||
int dock_index = dock->get_index();
|
int dock_index = dock->get_index();
|
||||||
|
@ -4246,7 +4247,7 @@ void EditorNode::_dock_make_float() {
|
||||||
Window *window = memnew(Window);
|
Window *window = memnew(Window);
|
||||||
window->set_title(dock->get_name());
|
window->set_title(dock->get_name());
|
||||||
Panel *p = memnew(Panel);
|
Panel *p = memnew(Panel);
|
||||||
p->set_mode(Panel::MODE_FOREGROUND);
|
p->add_theme_style_override("panel", gui_base->get_theme_stylebox(SNAME("PanelForeground"), SNAME("EditorStyles")));
|
||||||
p->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
|
p->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
|
||||||
window->add_child(p);
|
window->add_child(p);
|
||||||
MarginContainer *margin = memnew(MarginContainer);
|
MarginContainer *margin = memnew(MarginContainer);
|
||||||
|
|
|
@ -1279,7 +1279,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
|
||||||
|
|
||||||
// Panel
|
// Panel
|
||||||
theme->set_stylebox(SNAME("panel"), SNAME("Panel"), make_flat_stylebox(dark_color_1, 6, 4, 6, 4, corner_width));
|
theme->set_stylebox(SNAME("panel"), SNAME("Panel"), make_flat_stylebox(dark_color_1, 6, 4, 6, 4, corner_width));
|
||||||
theme->set_stylebox(SNAME("panel_fg"), SNAME("Panel"), style_default);
|
theme->set_stylebox(SNAME("PanelForeground"), SNAME("EditorStyles"), style_default);
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
theme->set_stylebox(SNAME("normal"), SNAME("Label"), style_empty);
|
theme->set_stylebox(SNAME("normal"), SNAME("Label"), style_empty);
|
||||||
|
|
|
@ -30,35 +30,14 @@
|
||||||
|
|
||||||
#include "panel.h"
|
#include "panel.h"
|
||||||
|
|
||||||
#include "core/string/print_string.h"
|
|
||||||
|
|
||||||
void Panel::_notification(int p_what) {
|
void Panel::_notification(int p_what) {
|
||||||
if (p_what == NOTIFICATION_DRAW) {
|
if (p_what == NOTIFICATION_DRAW) {
|
||||||
RID ci = get_canvas_item();
|
RID ci = get_canvas_item();
|
||||||
Ref<StyleBox> style = mode == MODE_BACKGROUND ? get_theme_stylebox(SNAME("panel")) : get_theme_stylebox(SNAME("panel_fg"));
|
Ref<StyleBox> style = get_theme_stylebox(SNAME("panel"));
|
||||||
style->draw(ci, Rect2(Point2(), get_size()));
|
style->draw(ci, Rect2(Point2(), get_size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Panel::set_mode(Mode p_mode) {
|
|
||||||
mode = p_mode;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
Panel::Mode Panel::get_mode() const {
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Panel::_bind_methods() {
|
|
||||||
ClassDB::bind_method(D_METHOD("set_mode", "mode"), &Panel::set_mode);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_mode"), &Panel::get_mode);
|
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Background,Foreground"), "set_mode", "get_mode");
|
|
||||||
|
|
||||||
BIND_ENUM_CONSTANT(MODE_BACKGROUND);
|
|
||||||
BIND_ENUM_CONSTANT(MODE_FOREGROUND);
|
|
||||||
}
|
|
||||||
|
|
||||||
Panel::Panel() {
|
Panel::Panel() {
|
||||||
// Has visible stylebox, so stop by default.
|
// Has visible stylebox, so stop by default.
|
||||||
set_mouse_filter(MOUSE_FILTER_STOP);
|
set_mouse_filter(MOUSE_FILTER_STOP);
|
||||||
|
|
|
@ -36,26 +36,11 @@
|
||||||
class Panel : public Control {
|
class Panel : public Control {
|
||||||
GDCLASS(Panel, Control);
|
GDCLASS(Panel, Control);
|
||||||
|
|
||||||
public:
|
|
||||||
enum Mode {
|
|
||||||
MODE_BACKGROUND,
|
|
||||||
MODE_FOREGROUND,
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
Mode mode = MODE_BACKGROUND;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
static void _bind_methods();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void set_mode(Mode p_mode);
|
|
||||||
Mode get_mode() const;
|
|
||||||
|
|
||||||
Panel();
|
Panel();
|
||||||
};
|
};
|
||||||
|
|
||||||
VARIANT_ENUM_CAST(Panel::Mode)
|
|
||||||
|
|
||||||
#endif // PANEL_H
|
#endif // PANEL_H
|
||||||
|
|
Loading…
Reference in New Issue