Merge pull request #71686 from YuriSizov/stylebox-min-size-but-better
Clean-up, harmonize, and improve StyleBox API
This commit is contained in:
commit
5068d82374
21 changed files with 285 additions and 300 deletions
|
|
@ -107,7 +107,7 @@ void EditorAssetLibraryItem::_bind_methods() {
|
|||
EditorAssetLibraryItem::EditorAssetLibraryItem() {
|
||||
Ref<StyleBoxEmpty> border;
|
||||
border.instantiate();
|
||||
border->set_default_margin_all(5 * EDSCALE);
|
||||
border->set_content_margin_all(5 * EDSCALE);
|
||||
add_theme_style_override("panel", border);
|
||||
|
||||
HBoxContainer *hb = memnew(HBoxContainer);
|
||||
|
|
@ -1549,7 +1549,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
|
|||
|
||||
Ref<StyleBoxEmpty> border2;
|
||||
border2.instantiate();
|
||||
border2->set_default_margin_individual(15 * EDSCALE, 15 * EDSCALE, 35 * EDSCALE, 15 * EDSCALE);
|
||||
border2->set_content_margin_individual(15 * EDSCALE, 15 * EDSCALE, 35 * EDSCALE, 15 * EDSCALE);
|
||||
|
||||
PanelContainer *library_vb_border = memnew(PanelContainer);
|
||||
library_scroll->add_child(library_vb_border);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ BitMapEditor::BitMapEditor() {
|
|||
// Reduce extra padding on top and bottom of size label.
|
||||
Ref<StyleBoxEmpty> stylebox;
|
||||
stylebox.instantiate();
|
||||
stylebox->set_default_margin(SIDE_RIGHT, 4 * EDSCALE);
|
||||
stylebox->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
|
||||
size_label->add_theme_style_override("normal", stylebox);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3958,8 +3958,8 @@ void CanvasItemEditor::_notification(int p_what) {
|
|||
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
select_sb->set_texture(get_theme_icon(SNAME("EditorRect2D"), SNAME("EditorIcons")));
|
||||
select_sb->set_margin_size_all(4);
|
||||
select_sb->set_default_margin_all(4);
|
||||
select_sb->set_texture_margin_all(4);
|
||||
select_sb->set_content_margin_all(4);
|
||||
|
||||
AnimationPlayerEditor::get_singleton()->get_track_editor()->connect("visibility_changed", callable_mp(this, &CanvasItemEditor::_keying_changed));
|
||||
_keying_changed();
|
||||
|
|
|
|||
|
|
@ -256,10 +256,10 @@ void TextureRegionEditor::_region_draw() {
|
|||
margins[2] = node_ninepatch->get_patch_margin(SIDE_LEFT);
|
||||
margins[3] = node_ninepatch->get_patch_margin(SIDE_RIGHT);
|
||||
} else if (obj_styleBox.is_valid()) {
|
||||
margins[0] = obj_styleBox->get_margin_size(SIDE_TOP);
|
||||
margins[1] = obj_styleBox->get_margin_size(SIDE_BOTTOM);
|
||||
margins[2] = obj_styleBox->get_margin_size(SIDE_LEFT);
|
||||
margins[3] = obj_styleBox->get_margin_size(SIDE_RIGHT);
|
||||
margins[0] = obj_styleBox->get_texture_margin(SIDE_TOP);
|
||||
margins[1] = obj_styleBox->get_texture_margin(SIDE_BOTTOM);
|
||||
margins[2] = obj_styleBox->get_texture_margin(SIDE_LEFT);
|
||||
margins[3] = obj_styleBox->get_texture_margin(SIDE_RIGHT);
|
||||
}
|
||||
|
||||
Vector2 pos[4] = {
|
||||
|
|
@ -314,10 +314,10 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
|
|||
margins[2] = node_ninepatch->get_patch_margin(SIDE_LEFT);
|
||||
margins[3] = node_ninepatch->get_patch_margin(SIDE_RIGHT);
|
||||
} else if (obj_styleBox.is_valid()) {
|
||||
margins[0] = obj_styleBox->get_margin_size(SIDE_TOP);
|
||||
margins[1] = obj_styleBox->get_margin_size(SIDE_BOTTOM);
|
||||
margins[2] = obj_styleBox->get_margin_size(SIDE_LEFT);
|
||||
margins[3] = obj_styleBox->get_margin_size(SIDE_RIGHT);
|
||||
margins[0] = obj_styleBox->get_texture_margin(SIDE_TOP);
|
||||
margins[1] = obj_styleBox->get_texture_margin(SIDE_BOTTOM);
|
||||
margins[2] = obj_styleBox->get_texture_margin(SIDE_LEFT);
|
||||
margins[3] = obj_styleBox->get_texture_margin(SIDE_RIGHT);
|
||||
}
|
||||
|
||||
Vector2 pos[4] = {
|
||||
|
|
@ -431,8 +431,8 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
|
|||
undo_redo->add_do_method(node_ninepatch, "set_patch_margin", side[edited_margin], node_ninepatch->get_patch_margin(side[edited_margin]));
|
||||
undo_redo->add_undo_method(node_ninepatch, "set_patch_margin", side[edited_margin], prev_margin);
|
||||
} else if (obj_styleBox.is_valid()) {
|
||||
undo_redo->add_do_method(obj_styleBox.ptr(), "set_margin_size", side[edited_margin], obj_styleBox->get_margin_size(side[edited_margin]));
|
||||
undo_redo->add_undo_method(obj_styleBox.ptr(), "set_margin_size", side[edited_margin], prev_margin);
|
||||
undo_redo->add_do_method(obj_styleBox.ptr(), "set_texture_margin", side[edited_margin], obj_styleBox->get_texture_margin(side[edited_margin]));
|
||||
undo_redo->add_undo_method(obj_styleBox.ptr(), "set_texture_margin", side[edited_margin], prev_margin);
|
||||
obj_styleBox->emit_signal(CoreStringNames::get_singleton()->changed);
|
||||
}
|
||||
edited_margin = -1;
|
||||
|
|
@ -474,7 +474,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
|
|||
node_ninepatch->set_patch_margin(side[edited_margin], prev_margin);
|
||||
}
|
||||
if (obj_styleBox.is_valid()) {
|
||||
obj_styleBox->set_margin_size(side[edited_margin], prev_margin);
|
||||
obj_styleBox->set_texture_margin(side[edited_margin], prev_margin);
|
||||
}
|
||||
edited_margin = -1;
|
||||
} else {
|
||||
|
|
@ -535,7 +535,7 @@ void TextureRegionEditor::_region_input(const Ref<InputEvent> &p_input) {
|
|||
node_ninepatch->set_patch_margin(side[edited_margin], new_margin);
|
||||
}
|
||||
if (obj_styleBox.is_valid()) {
|
||||
obj_styleBox->set_margin_size(side[edited_margin], new_margin);
|
||||
obj_styleBox->set_texture_margin(side[edited_margin], new_margin);
|
||||
}
|
||||
} else {
|
||||
Vector2 new_pos = mtx.affine_inverse().xform(mm->get_position());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue