本文整理汇总了C++中HBoxContainer::set_anchors_and_margins_preset方法的典型用法代码示例。如果您正苦于以下问题:C++ HBoxContainer::set_anchors_and_margins_preset方法的具体用法?C++ HBoxContainer::set_anchors_and_margins_preset怎么用?C++ HBoxContainer::set_anchors_and_margins_preset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HBoxContainer
的用法示例。
在下文中一共展示了HBoxContainer::set_anchors_and_margins_preset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memnew
MeshEditor::MeshEditor() {
viewport = memnew(Viewport);
Ref<World> world;
world.instance();
viewport->set_world(world); //use own world
add_child(viewport);
viewport->set_disable_input(true);
set_stretch(true);
camera = memnew(Camera);
camera->set_transform(Transform(Basis(), Vector3(0, 0, 1.1)));
camera->set_perspective(45, 0.1, 10);
viewport->add_child(camera);
light1 = memnew(DirectionalLight);
light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
viewport->add_child(light1);
light2 = memnew(DirectionalLight);
light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
light2->set_color(Color(0.7, 0.7, 0.7));
viewport->add_child(light2);
rotation = memnew(Spatial);
viewport->add_child(rotation);
mesh_instance = memnew(MeshInstance);
rotation->add_child(mesh_instance);
set_custom_minimum_size(Size2(1, 150) * EDSCALE);
HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
hb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2);
hb->add_spacer();
VBoxContainer *vb_light = memnew(VBoxContainer);
hb->add_child(vb_light);
light_1_switch = memnew(TextureButton);
light_1_switch->set_toggle_mode(true);
vb_light->add_child(light_1_switch);
light_1_switch->connect("pressed", this, "_button_pressed", varray(light_1_switch));
light_2_switch = memnew(TextureButton);
light_2_switch->set_toggle_mode(true);
vb_light->add_child(light_2_switch);
light_2_switch->connect("pressed", this, "_button_pressed", varray(light_2_switch));
first_enter = true;
rot_x = 0;
rot_y = 0;
}
示例2: memnew
MaterialEditor::MaterialEditor() {
vc = memnew(ViewportContainer);
vc->set_stretch(true);
add_child(vc);
vc->set_anchors_and_margins_preset(PRESET_WIDE);
viewport = memnew(Viewport);
Ref<World> world;
world.instance();
viewport->set_world(world); //use own world
vc->add_child(viewport);
viewport->set_disable_input(true);
viewport->set_transparent_background(true);
viewport->set_msaa(Viewport::MSAA_4X);
camera = memnew(Camera);
camera->set_transform(Transform(Basis(), Vector3(0, 0, 3)));
camera->set_perspective(45, 0.1, 10);
camera->make_current();
viewport->add_child(camera);
light1 = memnew(DirectionalLight);
light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
viewport->add_child(light1);
light2 = memnew(DirectionalLight);
light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
light2->set_color(Color(0.7, 0.7, 0.7));
viewport->add_child(light2);
sphere_instance = memnew(MeshInstance);
viewport->add_child(sphere_instance);
box_instance = memnew(MeshInstance);
viewport->add_child(box_instance);
Transform box_xform;
box_xform.basis.rotate(Vector3(1, 0, 0), Math::deg2rad(25.0));
box_xform.basis = box_xform.basis * Basis().rotated(Vector3(0, 1, 0), Math::deg2rad(-25.0));
box_xform.basis.scale(Vector3(0.8, 0.8, 0.8));
box_xform.origin.y = 0.2;
box_instance->set_transform(box_xform);
sphere_mesh.instance();
sphere_instance->set_mesh(sphere_mesh);
box_mesh.instance();
box_instance->set_mesh(box_mesh);
box_instance->hide();
set_custom_minimum_size(Size2(1, 150) * EDSCALE);
HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb);
hb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2);
VBoxContainer *vb_shape = memnew(VBoxContainer);
hb->add_child(vb_shape);
sphere_switch = memnew(TextureButton);
sphere_switch->set_toggle_mode(true);
sphere_switch->set_pressed(true);
vb_shape->add_child(sphere_switch);
sphere_switch->connect("pressed", this, "_button_pressed", varray(sphere_switch));
box_switch = memnew(TextureButton);
box_switch->set_toggle_mode(true);
box_switch->set_pressed(false);
vb_shape->add_child(box_switch);
box_switch->connect("pressed", this, "_button_pressed", varray(box_switch));
hb->add_spacer();
VBoxContainer *vb_light = memnew(VBoxContainer);
hb->add_child(vb_light);
light_1_switch = memnew(TextureButton);
light_1_switch->set_toggle_mode(true);
vb_light->add_child(light_1_switch);
light_1_switch->connect("pressed", this, "_button_pressed", varray(light_1_switch));
light_2_switch = memnew(TextureButton);
light_2_switch->set_toggle_mode(true);
vb_light->add_child(light_2_switch);
light_2_switch->connect("pressed", this, "_button_pressed", varray(light_2_switch));
first_enter = true;
}