Commit graph

76 commits

Author SHA1 Message Date
gxalpha 41650479fe UI: Center preview spacing lines
Currently, the spacing lines begin in the middle of the box and then are
their width wide towards one direction. This means that the larger they
are, the more off-center their middle is.
This commit changes them to start at half their width left/top of the
center and end half the width to the right/bottom of the center, putting
the middle in the center.
2024-05-11 23:12:36 -04:00
gxalpha 67e4853b7d UI: Give private spacing helper sources names 2024-05-11 22:13:42 -04:00
Warchamp7 c54f4371d6 UI: Adjust preview scrolling clamp values 2024-05-04 16:17:12 -07:00
Exeldro f275080abb libobs: Fix crop to bounds ABI break 2024-02-20 21:18:51 -06:00
BGM99 04788d30e2 UI: Fix resize cursor to respect item transformation 2023-12-16 18:19:20 +01:00
Zulleyy3 Zulleyy3 c76760bc1c UI: Fix transform of sources in groups
Group resize is not deferred until adjustments are completed by a
mouseReleaseEvent in certain cases, resulting in unexpected movement of
sources that are part of a group as they are resized or stretched
beyond group bounds.

The bug can be described/reproduced as follow:

1. The user selects within a group in the sources dock
2. The user moves their mouse over the selected source such that the
   cursor would change.
   - This results in a cursor update and a call to GetStrechHandle()
   - as the source is part of a group, stretchGroup will be set to the
    group of the source

3. The user clicks on the canvas without touching a stretch/rotation
   handle
   - A mouseReleaseEvent is fired
   - obs_sceneitem_defer_group_resize_end is called on the group as
     stretchGroup is still defined from earlier
   - the defer_group_resize member of the group will become negative
   - The deferal check in resize_group (obs-scene.c) will always pass
     now
4. When scaling or rotating the source close to the group bounds, the
   group bounds will now dynamically update causing the source in to fly
   off the canvas.

Resolves: https://github.com/obsproject/obs-studio/issues/9754
2023-11-04 18:06:44 -05:00
Lain c8d95005c1 UI: Fix unnecessary GetCurrentScene() call
Missed this with the parent commit; the scene variable is now already
available, thus there is no need to call GetCurrentScene() twice.
2023-08-15 17:20:44 -07:00
Lain e0f7bcaf3f UI: Hold reference to scene when drawing spacers
Just holds a reference to the scene as a safety precaution.
2023-08-15 17:11:23 -07:00
PatTheMav 8d82263513 UI: Fix possible race condition in DrawSpacingHelpers
The use of GetCurrentSceneItem can lead to a race condition between
the graphics thread (where this function will be run) and the main UI
thread, as both access the scene list model and iterate through its
members which can change during iteration (as there is no lock around
its access).
2023-08-15 16:05:04 -07:00
Penwywern 6f885770f8 UI: Fix crop on flipped sceneitems in bounding boxes
Same as previous commits, flipped sceneitems in bounding boxes ought
to be treated as not flipped for the purpose of UI interaction in
order to function correctly.
2023-07-25 15:28:16 -07:00
Penwywern a62993d513 UI: Fix drawing of pixel guides on flipped sceneitems in bounding boxes
Flip state of the item should be ignored when drawing guides for items
in bounding boxes, as the UI uses the countour of the bounding box, not
of the flipped item in it.
2023-07-25 15:28:16 -07:00
Penwywern 8d0f043ac6 UI: Fix draw and find of rot handle with bounding box and flip
The preview interaction and decoration of items inside bounding boxes
is based on the bounding box state, not on the item's state. As such,
the flip state of the item should be ignored when drawing and finding
the rotation handle, since the bounding box itself isn't flipped, only
the item inside the bounding box.
2023-07-25 15:28:16 -07:00
Penwywern 28a48c048d UI: Fix rotation handle find angle
The angle at which the rotation handle is drawn is independant from the
sceneitem's flip. As such, this changes `FindHandleAtPos` to use the rotation
angle of the item, free of its flip, instead of doing post-rotation
corrections. This fixes a bug where when the item was horizontally flipped,
the handle was not "found" at its drawn location.
2023-07-25 15:28:16 -07:00
derrod dcc07cfe4e clang-format: Set AllowAllConstructorInitializersOnNextLine to false 2023-07-15 16:14:55 -07:00
gxalpha a4834efde9 UI: Remove Qt 5 ifdef guards and code 2023-07-12 13:22:13 -04:00
derrod 67f7712d83 UI: Migrate undo/redo to using UUIDs 2023-06-28 11:04:56 -07:00
Jim fcfc2eb5fc UI: Fix 0,0 size transform bug when resizing sources
Fix a bug where if a source's width or height becomes 0 while you're
stretching the size of a source or modifying it from the transform
dialog, it would become permanently invisible

Closes obsproject/obs-studio#7962
2023-05-19 17:31:14 -07:00
cg2121 3a610c698e UI: Remove UNUSED_PARAMETER where unnecessary
Since cpp allows removing the unused parameters from the function name,
UNUSED_PARAMETER is not needed, unless it is in an ifdef.
2023-04-01 16:54:02 -07:00
cg2121 7475261542 UI: Fix rotation handle when source is flipped
The rotation handle and cursor would be drawn at the wrong spot
if the source was flipped.
2023-04-01 16:48:24 -07:00
Norihiro Kamae 23a0b7cacd UI: Fix possible use-after-free of obs_source_t
Also removes an implicit pair of successive obs_source_getref and
obs_source_release calls from OBSSource.
2023-03-18 15:34:47 -07:00
cg2121 b82c8ccdcf UI: Limit preview scrolling
This prevents the preview from being scrolled on forever.
2023-03-11 15:22:23 -08:00
cg2121 b464ba8129 UI: Set min/max zoom levels for preview
Prevents the preview from zooming in or out too far.
Min zoom: 10%
Max zoom: 1000%
2023-03-04 16:31:49 -08:00
cg2121 a3defd4f58 UI: Fix spacing helpers when rotated and flipped
If the scene item was rotated greater than 45 degrees, and flipped
vertically or horizontally, the spacing helpers would be drawn
incorrectly. This fixes the issue by checking the scale before
the rotation, instead of after.
2023-03-04 16:18:38 -08:00
derrod 5bdf492f8a UI: Avoid excessive config reads when drawing preview 2023-02-11 15:58:40 -08:00
Richard Stanway daee83373c UI: Remove unused assignments 2022-10-15 16:17:46 -07:00
PatTheMav e2db9b7f70 UI: Fix possible crash due to UI property access from graphics thread
Selection state can change by main thread while UI thread (which
calls DrawSpacingHelpers) tries to evaluate the amount of selected
items. Get amount of selected items by enumerating over the scene data
instead (which stays within the graphics thread).
2022-10-15 16:06:50 -07:00
tududweb a772e74286 UI: Correctly draw sub-item SpacingHelper on group 2022-08-18 02:35:34 -07:00
tududweb 122b83f4c1 UI: Don't show sub-item SpacingHelper on locked group 2022-08-18 02:35:34 -07:00
cg2121 2b4629848d UI: Fix spacer lines not using accessibility color
The spacer helper lines would not use the selection color set in the
accessibility settings.
2022-08-06 16:14:24 -07:00
gxalpha 3233c455d1 UI: Make spacing helpers DPI aware
Addition to 76ae9cbc which was made independently of the spacing helpers
introduced in 2d6a9c9c
2022-08-06 16:10:20 -07:00
PatTheMav f1cf3ff141 UI: Fix Qt call on UI thread from graphics thread
Calling `devicePixelRatioF` from any thread but the main UI thread
triggers thread-safety warnings at runtime on macOS, because Qt uses
NSView calls to determine the value.

NSView calls are only allowed to be made from the main thread on macOS,
so instead the value is stored as a property of the OBSQTDisplay at
initialization, to be retrieved from the preview object later.

Static functions that do not have access to the preview object have the
pixel ratio passed in their call signature.
2022-07-31 19:36:34 +02:00
Matt Gajownik 68499222ad UI: Fix panning when preview scaling is enabled 2022-07-31 14:19:27 +10:00
Clayton Groeneveld 2d6a9c9cc1 UI: Show spacing helpers in preview
This shows distance between sides of preview and edges of sources.
This will allow users to more easily align sources.

Co-authored-by: Palakis <contact@slepin.fr>
2022-07-30 19:41:18 -07:00
VodBox 76ae9cbc3d UI: Respect DPI for preview interactions
This change makes it so that selection outlines, handles and all
interaction events properly respect DPI scaling for the preview.
2022-07-27 22:43:32 -04:00
VodBox 580ebcc935 UI: Add scene item rotation handle
Add a rotation handle to the scene item selection box that will rotate
the source when clicked and dragged.
2022-07-27 22:40:01 -04:00
VodBox 77694d76e8 UI: Add Accessibility menu to settings
This change introduces an accessibility menu to settings, along with
options for overriding the colors used by OBS in the mixer and in the
preview to be more color blind friendly than the options provided by the
current theme.
2022-07-27 21:37:30 -04:00
VodBox 9299a3dbce UI: Change crop border line style 2022-07-27 21:37:30 -04:00
gxalpha 05c6a408e3 UI: Fix Qt 6 position deprecations 2022-07-22 09:37:17 -04:00
Norihiro Kamae 4ca0273a57 UI: Remove unnecessary UNUSED_PARAMETER 2022-07-19 11:01:00 -04:00
Clayton Groeneveld 066b281db8 UI: Ignore resizing item when it is locked
Fixes https://github.com/obsproject/obs-studio/issues/5724
2022-01-07 15:18:59 -08:00
VodBox 3d544653e8 UI: Cleanup libobs C++ type use 2021-11-26 23:23:51 +13:00
jpark37 c93b040d0d UI: Use patterns that avoid std::min/max
New code is cleaner anyway.
2021-10-10 19:12:45 -07:00
Ryan Foster 1fa45e63a3 UI: Remove fractional scaling ifdefs
Among the systems we officially support, the oldest Qt version is Qt 5.9
on Ubuntu 18.04. Fractional scaling is supported in Qt 5.6 and newer. We
should be able to safely remove these ifdefs.
2021-06-30 01:42:01 -07:00
jp9000 78f1983f7d UI: Remove unnecessary Undo/Redo cleanup func
Since fixing the reference holding issue with scene/source deletion, the
undo/redo cleanup function (last param of add_action) is no longer
required.
2021-04-27 20:45:43 -07:00
Richard Stanway 054a68b8f4 UI: Fix undo data being saved when no changes occur
obs_scene_save_transform_states was called with all_items = true when
starting a transform, but all_items = false when comparing undo data.

Fixes #4510
2021-04-13 00:52:55 +02:00
Clayton Groeneveld 7dfd36f9e8 UI: Force current scene when using undo/redo
The undo/redo functions are setting the current scene. Everytime
it would do this, it would actually transition to the scene.
This forces the current scene, so it fixes a bug where the
transition would be grayed out when undoing/redoing.
2021-04-10 01:49:30 -07:00
Ford Smith 3a620c485e UI: Undo/Redo Transformations
Implements undo/redo for transformations of sources, both through
preview and the transformations properties.
2021-03-29 03:06:26 -04:00
Matt Gajownik b2fb0ca07f UI: Don't attempt to resize parent group when changing cursor
Fixes an issue where resizing a source did not resize the parent group.
2021-03-09 21:15:17 +11:00
Matt Gajownik ff23eb4a24 UI: Change cursor when interacting with the preview
Includes move, resize, crop, stretch, box select.
2020-08-23 06:26:56 -07:00
jpark37 c2ddc428b0 UI: Fix warnings for Qt 5.15
AllDockWidgetFeatures is now deprecated. Use underlying values instead.

Use default QFlags constructor instead of nullptr/0.

Use QWheelEvent::angleDelta() in place of orientation() and delta(), and
position() in place of x() and y().
2020-06-21 18:23:05 -07:00