private void btn_Click(object sender, EventArgs e) { RadioButton btn = (RadioButton)sender; Alignment = (ObsAlignment)btn.Tag; if (AlignmentChanged != null) { AlignmentChanged(align); } }
public unsafe void SetBounds(Vector2 bounds, ObsBoundsType type, ObsAlignment alignment) { libobs.obs_sceneitem_set_bounds(instance, out bounds); libobs.obs_sceneitem_set_bounds_type(instance, (libobs.obs_bounds_type)type); libobs.obs_sceneitem_set_bounds_alignment(instance, (uint)alignment); }
public unsafe void SetBounds(Vector2 bounds, ObsBoundsType type, ObsAlignment alignment) { libobs.obs_sceneitem_set_bounds(instance, out bounds); libobs.obs_sceneitem_set_bounds_type(instance, (libobs.obs_bounds_type)type); libobs.obs_sceneitem_set_bounds_alignment(instance, (uint)alignment); }
public TestTransform(ObsSceneItem item) { InitializeComponent(); // Store scene item _selectedItem = item; // Set minmax on numerics // the rendercontext minmax are bigger than the decimal one so this is fine const decimal min = decimal.MinValue; const decimal max = decimal.MaxValue; xNumeric.Minimum = min; xNumeric.Maximum = max; yNumeric.Minimum = min; yNumeric.Maximum = max; wNumeric.Minimum = min; wNumeric.Maximum = max; hNumeric.Minimum = min; hNumeric.Maximum = max; // Populate Controls // Position _oldPos = _selectedItem.Position; xNumeric.Value = (decimal)_oldPos.x; yNumeric.Value = (decimal)_oldPos.y; // Scale _oldScale = _selectedItem.Scale; wNumeric.Value = (decimal)_oldScale.x; hNumeric.Value = (decimal)_oldScale.y; // Rotation _oldRot = _selectedItem.Rotation; Rotation.Rotation = (int)Math.Round(_oldRot); // Alignment _oldAlignment = _selectedItem.Alignment; Alignment.Alignment = _oldAlignment; // Delegates to change transform properties xNumeric.ValueChanged += (sender, args) => _selectedItem.Position = ItemPosition; yNumeric.ValueChanged += (sender, args) => _selectedItem.Position = ItemPosition; wNumeric.ValueChanged += (sender, args) => _selectedItem.Scale = ItemScale; hNumeric.ValueChanged += (sender, args) => _selectedItem.Scale = ItemScale; // These even handlers return the exact value we need // Do this in the future for all custom even handlers // Makes creating inline event handlers a breeze! Rotation.RotationChanged += rotation => _selectedItem.Rotation = rotation; Alignment.AlignmentChanged += alignment => _selectedItem.Alignment = alignment; // Close form methods okButton.Click += (sender, args) => Close(); cancelButton.Click += (sender, args) => { _selectedItem.Position = _oldPos; _selectedItem.Scale = _oldScale; _selectedItem.Rotation = _oldRot; _selectedItem.Alignment = _oldAlignment; Close(); }; }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); Vector2 mousePosition = GetPositionInScene(new Vector2(e.Location)); Vector2 dragOffset = mousePosition - dragLastPosition; if (dragging) { // move all the selected items foreach (ObsSceneItem item in scene.Items) { if (!item.Selected) { continue; } item.Position += dragOffset; } dragLastPosition = mousePosition; } else if (resizeEdge != ResizeEdge.None && (dragOffset.x != 0.0f || dragOffset.y != 0.0f)) { // move all the selected items foreach (ObsSceneItem item in scene.Items) { if (!item.Selected) { continue; } Vector2 newPos = item.Position; Vector2 newSize = item.Bounds; Vector2 offset = new Vector2(0.0f, 0.0f); ObsAlignment alignment = item.Alignment; if (resizeEdge.HasFlag(ResizeEdge.Left) || resizeEdge.HasFlag(ResizeEdge.Right)) { offset.x = dragOffset.x; } if (resizeEdge.HasFlag(ResizeEdge.Top) || resizeEdge.HasFlag(ResizeEdge.Bottom)) { offset.y = dragOffset.y; } if (resizeEdge.HasFlag(ResizeEdge.Left)) { newSize.x -= offset.x; newPos.x += offset.x; } if (resizeEdge.HasFlag(ResizeEdge.Top)) { newSize.y -= offset.y; newPos.y += offset.y; } if (resizeEdge.HasFlag(ResizeEdge.Right)) { newSize.x += offset.x; } if (resizeEdge.HasFlag(ResizeEdge.Bottom)) { newSize.y += offset.y; } Vector2 adjust = newPos - item.Position; if (alignment == ObsAlignment.Left) { adjust.x = offset.x; } else if (alignment == ObsAlignment.Right) { adjust.x = offset.x; } else { adjust.x = offset.x / 2.0f; } if (alignment == ObsAlignment.Top) { adjust.y = offset.y; } else if (alignment == ObsAlignment.Bottom) { adjust.y = offset.y; } else { adjust.y = offset.y / 2.0f; } if (resizeEdge.HasFlag(ResizeEdge.Left)) { adjust.x = -adjust.x; } if (resizeEdge.HasFlag(ResizeEdge.Top)) { adjust.y = -adjust.y; } newPos.x += adjust.x; newPos.y += adjust.y; item.Position = newPos; item.Bounds = newSize; } dragLastPosition = mousePosition; } // mouse hover over scene items SetHoveredItem(GetItemAtPosition(mousePosition)); if (hoveredItem != null && hoveredItem.Selected) { SetHoveredItem(null); } }
private void btn_Click(object sender, EventArgs e) { RadioButton btn = (RadioButton)sender; Alignment = (ObsAlignment)btn.Tag; if (AlignmentChanged != null) { AlignmentChanged(align); } }
public TestTransform(ObsSceneItem item) { InitializeComponent(); // Store scene item _selectedItem = item; // Set minmax on numerics // the rendercontext minmax are bigger than the decimal one so this is fine const decimal min = decimal.MinValue; const decimal max = decimal.MaxValue; xNumeric.Minimum = min; xNumeric.Maximum = max; yNumeric.Minimum = min; yNumeric.Maximum = max; wNumeric.Minimum = min; wNumeric.Maximum = max; hNumeric.Minimum = min; hNumeric.Maximum = max; // Populate Controls // Position _oldPos = _selectedItem.Position; xNumeric.Value = (decimal)_oldPos.x; yNumeric.Value = (decimal)_oldPos.y; // Scale _oldScale = _selectedItem.Scale; wNumeric.Value = (decimal)_oldScale.x; hNumeric.Value = (decimal)_oldScale.y; // Rotation _oldRot = _selectedItem.Rotation; Rotation.Rotation = (int)Math.Round(_oldRot); // Alignment _oldAlignment = _selectedItem.Alignment; Alignment.Alignment = _oldAlignment; // Delegates to change transform properties xNumeric.ValueChanged += (sender, args) => _selectedItem.Position = ItemPosition; yNumeric.ValueChanged += (sender, args) => _selectedItem.Position = ItemPosition; wNumeric.ValueChanged += (sender, args) => _selectedItem.Scale = ItemScale; hNumeric.ValueChanged += (sender, args) => _selectedItem.Scale = ItemScale; // These even handlers return the exact value we need // Do this in the future for all custom even handlers // Makes creating inline event handlers a breeze! Rotation.RotationChanged += rotation => _selectedItem.Rotation = rotation; Alignment.AlignmentChanged += alignment => _selectedItem.Alignment = alignment; // Close form methods okButton.Click += (sender, args) => Close(); cancelButton.Click += (sender, args) => { _selectedItem.Position = _oldPos; _selectedItem.Scale = _oldScale; _selectedItem.Rotation = _oldRot; _selectedItem.Alignment = _oldAlignment; Close(); }; }