UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QMouseEvent>
|
|
|
|
|
2014-10-14 02:42:30 +02:00
|
|
|
#include <algorithm>
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
#include <cmath>
|
|
|
|
#include <graphics/vec4.h>
|
|
|
|
#include <graphics/matrix4.h>
|
|
|
|
#include "window-basic-preview.hpp"
|
|
|
|
#include "window-basic-main.hpp"
|
|
|
|
#include "obs-app.hpp"
|
|
|
|
|
|
|
|
#define HANDLE_RADIUS 4.0f
|
|
|
|
#define HANDLE_SEL_RADIUS (HANDLE_RADIUS * 1.5f)
|
|
|
|
|
|
|
|
/* TODO: make C++ math classes and clean up code here later */
|
|
|
|
|
|
|
|
OBSBasicPreview::OBSBasicPreview(QWidget *parent, Qt::WindowFlags flags)
|
|
|
|
: OBSQTDisplay(parent, flags)
|
|
|
|
{
|
2016-11-05 12:48:46 -04:00
|
|
|
ResetScrollingOffset();
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
setMouseTracking(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
vec2 OBSBasicPreview::GetMouseEventPos(QMouseEvent *event)
|
|
|
|
{
|
|
|
|
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
2014-07-16 02:01:59 +02:00
|
|
|
float pixelRatio = main->devicePixelRatio();
|
|
|
|
float scale = pixelRatio / main->previewScale;
|
2014-06-16 17:55:48 -07:00
|
|
|
vec2 pos;
|
|
|
|
vec2_set(&pos,
|
2014-07-16 02:01:59 +02:00
|
|
|
(float(event->x()) - main->previewX / pixelRatio) * scale,
|
|
|
|
(float(event->y()) - main->previewY / pixelRatio) * scale);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SceneFindData {
|
|
|
|
const vec2 &pos;
|
|
|
|
OBSSceneItem item;
|
|
|
|
bool selectBelow;
|
|
|
|
|
2014-06-25 01:50:44 -07:00
|
|
|
SceneFindData(const SceneFindData &) = delete;
|
2014-06-25 02:12:30 -07:00
|
|
|
SceneFindData(SceneFindData &&) = delete;
|
2014-06-25 01:50:44 -07:00
|
|
|
SceneFindData& operator=(const SceneFindData &) = delete;
|
|
|
|
SceneFindData& operator=(SceneFindData &&) = delete;
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
inline SceneFindData(const vec2 &pos_, bool selectBelow_)
|
|
|
|
: pos (pos_),
|
|
|
|
selectBelow (selectBelow_)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
static bool SceneItemHasVideo(obs_sceneitem_t *item)
|
2014-07-04 10:58:03 -07:00
|
|
|
{
|
2014-09-25 17:44:05 -07:00
|
|
|
obs_source_t *source = obs_sceneitem_get_source(item);
|
2014-07-04 10:58:03 -07:00
|
|
|
uint32_t flags = obs_source_get_output_flags(source);
|
|
|
|
return (flags & OBS_SOURCE_VIDEO) != 0;
|
|
|
|
}
|
|
|
|
|
2014-10-14 01:52:26 +02:00
|
|
|
static bool CloseFloat(float a, float b, float epsilon=0.01)
|
|
|
|
{
|
2015-04-07 22:15:33 +02:00
|
|
|
using std::abs;
|
2014-10-14 01:52:26 +02:00
|
|
|
return abs(a-b) <= epsilon;
|
|
|
|
}
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
static bool FindItemAtPos(obs_scene_t *scene, obs_sceneitem_t *item,
|
|
|
|
void *param)
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
{
|
|
|
|
SceneFindData *data = reinterpret_cast<SceneFindData*>(param);
|
|
|
|
matrix4 transform;
|
2014-10-14 01:52:26 +02:00
|
|
|
matrix4 invTransform;
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
vec3 transformedPos;
|
2014-06-16 17:55:48 -07:00
|
|
|
vec3 pos3;
|
2014-10-14 01:52:26 +02:00
|
|
|
vec3 pos3_;
|
2014-06-16 17:55:48 -07:00
|
|
|
|
2014-07-04 10:58:03 -07:00
|
|
|
if (!SceneItemHasVideo(item))
|
|
|
|
return true;
|
2017-06-17 19:10:42 -05:00
|
|
|
if (obs_sceneitem_locked(item))
|
|
|
|
return true;
|
2014-07-04 10:58:03 -07:00
|
|
|
|
2014-06-16 17:55:48 -07:00
|
|
|
vec3_set(&pos3, data->pos.x, data->pos.y, 0.0f);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
|
|
|
obs_sceneitem_get_box_transform(item, &transform);
|
|
|
|
|
2014-10-14 01:52:26 +02:00
|
|
|
matrix4_inv(&invTransform, &transform);
|
|
|
|
vec3_transform(&transformedPos, &pos3, &invTransform);
|
|
|
|
vec3_transform(&pos3_, &transformedPos, &transform);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
2014-10-14 01:52:26 +02:00
|
|
|
if (CloseFloat(pos3.x, pos3_.x) && CloseFloat(pos3.y, pos3_.y) &&
|
|
|
|
transformedPos.x >= 0.0f && transformedPos.x <= 1.0f &&
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
transformedPos.y >= 0.0f && transformedPos.y <= 1.0f) {
|
|
|
|
if (data->selectBelow && obs_sceneitem_selected(item)) {
|
|
|
|
if (data->item)
|
|
|
|
return false;
|
|
|
|
else
|
|
|
|
data->selectBelow = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->item = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
UNUSED_PARAMETER(scene);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static vec3 GetTransformedPos(float x, float y, const matrix4 &mat)
|
|
|
|
{
|
|
|
|
vec3 result;
|
|
|
|
vec3_set(&result, x, y, 0.0f);
|
|
|
|
vec3_transform(&result, &result, &mat);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static vec3 GetTransformedPosScaled(float x, float y, const matrix4 &mat,
|
|
|
|
float scale)
|
|
|
|
{
|
|
|
|
vec3 result;
|
|
|
|
vec3_set(&result, x, y, 0.0f);
|
|
|
|
vec3_transform(&result, &result, &mat);
|
|
|
|
vec3_mulf(&result, &result, scale);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline vec2 GetOBSScreenSize()
|
|
|
|
{
|
|
|
|
obs_video_info ovi;
|
2014-06-16 17:55:48 -07:00
|
|
|
vec2 size;
|
|
|
|
vec2_zero(&size);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
|
|
|
if (obs_get_video_info(&ovi)) {
|
|
|
|
size.x = float(ovi.base_width);
|
|
|
|
size.y = float(ovi.base_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2016-04-06 18:03:29 -07:00
|
|
|
vec3 OBSBasicPreview::GetSnapOffset(const vec3 &tl, const vec3 &br)
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
{
|
|
|
|
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
|
|
|
vec2 screenSize = GetOBSScreenSize();
|
|
|
|
vec3 clampOffset;
|
|
|
|
|
|
|
|
vec3_zero(&clampOffset);
|
|
|
|
|
2016-04-06 18:03:29 -07:00
|
|
|
const bool snap = config_get_bool(GetGlobalConfig(),
|
|
|
|
"BasicWindow", "SnappingEnabled");
|
|
|
|
if (snap == false)
|
|
|
|
return clampOffset;
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
2016-04-06 18:03:29 -07:00
|
|
|
const bool screenSnap = config_get_bool(GetGlobalConfig(),
|
|
|
|
"BasicWindow", "ScreenSnapping");
|
2016-04-06 18:10:39 -07:00
|
|
|
const bool centerSnap = config_get_bool(GetGlobalConfig(),
|
|
|
|
"BasicWindow", "CenterSnapping");
|
2016-04-06 18:03:29 -07:00
|
|
|
|
|
|
|
const float clampDist = config_get_double(GetGlobalConfig(),
|
|
|
|
"BasicWindow", "SnapDistance") / main->previewScale;
|
2016-04-06 18:10:39 -07:00
|
|
|
const float centerX = br.x - (br.x - tl.x) / 2.0f;
|
|
|
|
const float centerY = br.y - (br.y - tl.y) / 2.0f;
|
2016-04-06 18:03:29 -07:00
|
|
|
|
|
|
|
// Left screen edge.
|
|
|
|
if (screenSnap &&
|
|
|
|
fabsf(tl.x) < clampDist)
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
clampOffset.x = -tl.x;
|
2016-04-06 18:03:29 -07:00
|
|
|
// Right screen edge.
|
|
|
|
if (screenSnap &&
|
|
|
|
fabsf(clampOffset.x) < EPSILON &&
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
fabsf(screenSize.x - br.x) < clampDist)
|
|
|
|
clampOffset.x = screenSize.x - br.x;
|
2016-04-06 18:10:39 -07:00
|
|
|
// Horizontal center.
|
|
|
|
if (centerSnap &&
|
|
|
|
fabsf(screenSize.x - (br.x - tl.x)) > clampDist &&
|
|
|
|
fabsf(screenSize.x / 2.0f - centerX) < clampDist)
|
|
|
|
clampOffset.x = screenSize.x / 2.0f - centerX;
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
2016-04-06 18:03:29 -07:00
|
|
|
// Top screen edge.
|
|
|
|
if (screenSnap &&
|
|
|
|
fabsf(tl.y) < clampDist)
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
clampOffset.y = -tl.y;
|
2016-04-06 18:03:29 -07:00
|
|
|
// Bottom screen edge.
|
|
|
|
if (screenSnap &&
|
|
|
|
fabsf(clampOffset.y) < EPSILON &&
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
fabsf(screenSize.y - br.y) < clampDist)
|
|
|
|
clampOffset.y = screenSize.y - br.y;
|
2016-04-06 18:10:39 -07:00
|
|
|
// Vertical center.
|
|
|
|
if (centerSnap &&
|
|
|
|
fabsf(screenSize.y - (br.y - tl.y)) > clampDist &&
|
|
|
|
fabsf(screenSize.y / 2.0f - centerY) < clampDist)
|
|
|
|
clampOffset.y = screenSize.y / 2.0f - centerY;
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
|
|
|
return clampOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
OBSSceneItem OBSBasicPreview::GetItemAtPos(const vec2 &pos, bool selectBelow)
|
|
|
|
{
|
|
|
|
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
|
|
|
|
|
|
|
OBSScene scene = main->GetCurrentScene();
|
|
|
|
if (!scene)
|
|
|
|
return OBSSceneItem();
|
|
|
|
|
|
|
|
SceneFindData data(pos, selectBelow);
|
|
|
|
obs_scene_enum_items(scene, FindItemAtPos, &data);
|
|
|
|
return data.item;
|
|
|
|
}
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
static bool CheckItemSelected(obs_scene_t *scene, obs_sceneitem_t *item,
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
void *param)
|
|
|
|
{
|
|
|
|
SceneFindData *data = reinterpret_cast<SceneFindData*>(param);
|
|
|
|
matrix4 transform;
|
|
|
|
vec3 transformedPos;
|
2014-06-16 17:55:48 -07:00
|
|
|
vec3 pos3;
|
|
|
|
|
2014-07-04 10:58:03 -07:00
|
|
|
if (!SceneItemHasVideo(item))
|
|
|
|
return true;
|
|
|
|
|
2014-06-16 17:55:48 -07:00
|
|
|
vec3_set(&pos3, data->pos.x, data->pos.y, 0.0f);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
|
|
|
obs_sceneitem_get_box_transform(item, &transform);
|
|
|
|
|
|
|
|
matrix4_inv(&transform, &transform);
|
|
|
|
vec3_transform(&transformedPos, &pos3, &transform);
|
|
|
|
|
|
|
|
if (transformedPos.x >= 0.0f && transformedPos.x <= 1.0f &&
|
|
|
|
transformedPos.y >= 0.0f && transformedPos.y <= 1.0f) {
|
|
|
|
if (obs_sceneitem_selected(item)) {
|
|
|
|
data->item = item;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UNUSED_PARAMETER(scene);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OBSBasicPreview::SelectedAtPos(const vec2 &pos)
|
|
|
|
{
|
|
|
|
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
|
|
|
|
|
|
|
OBSScene scene = main->GetCurrentScene();
|
|
|
|
if (!scene)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
SceneFindData data(pos, false);
|
|
|
|
obs_scene_enum_items(scene, CheckItemSelected, &data);
|
|
|
|
return !!data.item;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct HandleFindData {
|
|
|
|
const vec2 &pos;
|
|
|
|
const float scale;
|
|
|
|
|
|
|
|
OBSSceneItem item;
|
|
|
|
ItemHandle handle = ItemHandle::None;
|
|
|
|
|
2014-06-25 01:50:44 -07:00
|
|
|
HandleFindData(const HandleFindData &) = delete;
|
2014-06-25 02:12:30 -07:00
|
|
|
HandleFindData(HandleFindData &&) = delete;
|
2014-06-25 01:50:44 -07:00
|
|
|
HandleFindData& operator=(const HandleFindData &) = delete;
|
|
|
|
HandleFindData& operator=(HandleFindData &&) = delete;
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
inline HandleFindData(const vec2 &pos_, float scale_)
|
|
|
|
: pos (pos_),
|
|
|
|
scale (scale_)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
static bool FindHandleAtPos(obs_scene_t *scene, obs_sceneitem_t *item,
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
void *param)
|
|
|
|
{
|
|
|
|
if (!obs_sceneitem_selected(item))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
HandleFindData *data = reinterpret_cast<HandleFindData*>(param);
|
|
|
|
matrix4 transform;
|
2014-06-16 17:55:48 -07:00
|
|
|
vec3 pos3;
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
float closestHandle = HANDLE_SEL_RADIUS;
|
|
|
|
|
2014-06-16 17:55:48 -07:00
|
|
|
vec3_set(&pos3, data->pos.x, data->pos.y, 0.0f);
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
obs_sceneitem_get_box_transform(item, &transform);
|
|
|
|
|
|
|
|
auto TestHandle = [&] (float x, float y, ItemHandle handle)
|
|
|
|
{
|
|
|
|
vec3 handlePos = GetTransformedPosScaled(x, y, transform,
|
|
|
|
data->scale);
|
|
|
|
|
|
|
|
float dist = vec3_dist(&handlePos, &pos3);
|
|
|
|
if (dist < HANDLE_SEL_RADIUS) {
|
|
|
|
if (dist < closestHandle) {
|
|
|
|
closestHandle = dist;
|
|
|
|
data->handle = handle;
|
|
|
|
data->item = item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
TestHandle(0.0f, 0.0f, ItemHandle::TopLeft);
|
|
|
|
TestHandle(0.5f, 0.0f, ItemHandle::TopCenter);
|
|
|
|
TestHandle(1.0f, 0.0f, ItemHandle::TopRight);
|
|
|
|
TestHandle(0.0f, 0.5f, ItemHandle::CenterLeft);
|
|
|
|
TestHandle(1.0f, 0.5f, ItemHandle::CenterRight);
|
|
|
|
TestHandle(0.0f, 1.0f, ItemHandle::BottomLeft);
|
|
|
|
TestHandle(0.5f, 1.0f, ItemHandle::BottomCenter);
|
|
|
|
TestHandle(1.0f, 1.0f, ItemHandle::BottomRight);
|
|
|
|
|
|
|
|
UNUSED_PARAMETER(scene);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
static vec2 GetItemSize(obs_sceneitem_t *item)
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
{
|
|
|
|
obs_bounds_type boundsType = obs_sceneitem_get_bounds_type(item);
|
|
|
|
vec2 size;
|
|
|
|
|
|
|
|
if (boundsType != OBS_BOUNDS_NONE) {
|
|
|
|
obs_sceneitem_get_bounds(item, &size);
|
|
|
|
} else {
|
2014-09-25 17:44:05 -07:00
|
|
|
obs_source_t *source = obs_sceneitem_get_source(item);
|
2016-03-30 18:46:02 -07:00
|
|
|
obs_sceneitem_crop crop;
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
vec2 scale;
|
|
|
|
|
2014-08-03 14:39:19 -07:00
|
|
|
obs_sceneitem_get_scale(item, &scale);
|
2016-03-30 18:46:02 -07:00
|
|
|
obs_sceneitem_get_crop(item, &crop);
|
|
|
|
size.x = float(obs_source_get_width(source) -
|
|
|
|
crop.left - crop.right) * scale.x;
|
|
|
|
size.y = float(obs_source_get_height(source) -
|
|
|
|
crop.top - crop.bottom) * scale.y;
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicPreview::GetStretchHandleData(const vec2 &pos)
|
|
|
|
{
|
|
|
|
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
|
|
|
|
|
|
|
OBSScene scene = main->GetCurrentScene();
|
|
|
|
if (!scene)
|
|
|
|
return;
|
|
|
|
|
2014-07-16 02:01:59 +02:00
|
|
|
HandleFindData data(pos, main->previewScale / main->devicePixelRatio());
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
obs_scene_enum_items(scene, FindHandleAtPos, &data);
|
|
|
|
|
|
|
|
stretchItem = std::move(data.item);
|
|
|
|
stretchHandle = data.handle;
|
|
|
|
|
|
|
|
if (stretchHandle != ItemHandle::None) {
|
|
|
|
matrix4 boxTransform;
|
|
|
|
vec3 itemUL;
|
|
|
|
float itemRot;
|
|
|
|
|
|
|
|
stretchItemSize = GetItemSize(stretchItem);
|
|
|
|
|
|
|
|
obs_sceneitem_get_box_transform(stretchItem, &boxTransform);
|
2014-08-03 14:39:19 -07:00
|
|
|
itemRot = obs_sceneitem_get_rot(stretchItem);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
vec3_from_vec4(&itemUL, &boxTransform.t);
|
|
|
|
|
|
|
|
/* build the item space conversion matrices */
|
|
|
|
matrix4_identity(&itemToScreen);
|
|
|
|
matrix4_rotate_aa4f(&itemToScreen, &itemToScreen,
|
|
|
|
0.0f, 0.0f, 1.0f, RAD(itemRot));
|
|
|
|
matrix4_translate3f(&itemToScreen, &itemToScreen,
|
|
|
|
itemUL.x, itemUL.y, 0.0f);
|
|
|
|
|
|
|
|
matrix4_identity(&screenToItem);
|
|
|
|
matrix4_translate3f(&screenToItem, &screenToItem,
|
|
|
|
-itemUL.x, -itemUL.y, 0.0f);
|
|
|
|
matrix4_rotate_aa4f(&screenToItem, &screenToItem,
|
|
|
|
0.0f, 0.0f, 1.0f, RAD(-itemRot));
|
2016-03-30 18:46:02 -07:00
|
|
|
|
|
|
|
obs_sceneitem_get_crop(stretchItem, &startCrop);
|
|
|
|
obs_sceneitem_get_pos(stretchItem, &startItemPos);
|
|
|
|
|
|
|
|
obs_source_t *source = obs_sceneitem_get_source(stretchItem);
|
|
|
|
cropSize.x = float(obs_source_get_width(source) -
|
|
|
|
startCrop.left - startCrop.right);
|
|
|
|
cropSize.y = float(obs_source_get_height(source) -
|
|
|
|
startCrop.top - startCrop.bottom);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-05 12:48:46 -04:00
|
|
|
void OBSBasicPreview::keyPressEvent(QKeyEvent *event)
|
|
|
|
{
|
2017-05-13 13:13:55 -04:00
|
|
|
if (!IsFixedScaling() || event->isAutoRepeat()) {
|
2016-11-05 12:48:46 -04:00
|
|
|
OBSQTDisplay::keyPressEvent(event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (event->key()) {
|
|
|
|
case Qt::Key_Space:
|
|
|
|
setCursor(Qt::OpenHandCursor);
|
|
|
|
scrollMode = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
OBSQTDisplay::keyPressEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicPreview::keyReleaseEvent(QKeyEvent *event)
|
|
|
|
{
|
|
|
|
if (event->isAutoRepeat()) {
|
|
|
|
OBSQTDisplay::keyReleaseEvent(event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (event->key()) {
|
|
|
|
case Qt::Key_Space:
|
|
|
|
scrollMode = false;
|
|
|
|
setCursor(Qt::ArrowCursor);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
OBSQTDisplay::keyReleaseEvent(event);
|
|
|
|
}
|
|
|
|
|
2017-05-13 13:13:55 -04:00
|
|
|
void OBSBasicPreview::wheelEvent(QWheelEvent *event)
|
|
|
|
{
|
|
|
|
if (scrollMode && IsFixedScaling()
|
|
|
|
&& event->orientation() == Qt::Vertical) {
|
|
|
|
if (event->delta() > 0)
|
|
|
|
SetScalingLevel(scalingLevel + 1);
|
|
|
|
else if (event->delta() < 0)
|
|
|
|
SetScalingLevel(scalingLevel - 1);
|
|
|
|
emit DisplayResized();
|
|
|
|
}
|
|
|
|
|
|
|
|
OBSQTDisplay::wheelEvent(event);
|
|
|
|
}
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
void OBSBasicPreview::mousePressEvent(QMouseEvent *event)
|
|
|
|
{
|
2017-05-13 13:13:55 -04:00
|
|
|
if (scrollMode && IsFixedScaling() &&
|
2016-11-10 09:32:44 -05:00
|
|
|
event->button() == Qt::LeftButton) {
|
|
|
|
setCursor(Qt::ClosedHandCursor);
|
|
|
|
scrollingFrom.x = event->x();
|
|
|
|
scrollingFrom.y = event->y();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event->button() == Qt::RightButton) {
|
|
|
|
scrollMode = false;
|
|
|
|
setCursor(Qt::ArrowCursor);
|
|
|
|
}
|
|
|
|
|
2016-07-26 01:32:43 -07:00
|
|
|
if (locked) {
|
|
|
|
OBSQTDisplay::mousePressEvent(event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
2014-07-16 02:01:59 +02:00
|
|
|
float pixelRatio = main->devicePixelRatio();
|
|
|
|
float x = float(event->x()) - main->previewX / pixelRatio;
|
|
|
|
float y = float(event->y()) - main->previewY / pixelRatio;
|
2016-03-30 18:46:02 -07:00
|
|
|
Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers();
|
|
|
|
bool altDown = (modifiers & Qt::AltModifier);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
2015-04-02 18:05:55 -07:00
|
|
|
OBSQTDisplay::mousePressEvent(event);
|
|
|
|
|
|
|
|
if (event->button() != Qt::LeftButton &&
|
|
|
|
event->button() != Qt::RightButton)
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
return;
|
|
|
|
|
2015-04-02 18:05:55 -07:00
|
|
|
if (event->button() == Qt::LeftButton)
|
|
|
|
mouseDown = true;
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
2016-03-30 18:46:02 -07:00
|
|
|
if (altDown)
|
|
|
|
cropping = true;
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
vec2_set(&startPos, x, y);
|
|
|
|
GetStretchHandleData(startPos);
|
|
|
|
|
2014-07-16 02:01:59 +02:00
|
|
|
vec2_divf(&startPos, &startPos, main->previewScale / pixelRatio);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
startPos.x = std::round(startPos.x);
|
|
|
|
startPos.y = std::round(startPos.y);
|
|
|
|
|
|
|
|
mouseOverItems = SelectedAtPos(startPos);
|
|
|
|
vec2_zero(&lastMoveOffset);
|
|
|
|
}
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
static bool select_one(obs_scene_t *scene, obs_sceneitem_t *item, void *param)
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
{
|
2014-09-25 17:44:05 -07:00
|
|
|
obs_sceneitem_t *selectedItem =
|
|
|
|
reinterpret_cast<obs_sceneitem_t*>(param);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
obs_sceneitem_select(item, (selectedItem == item));
|
|
|
|
|
|
|
|
UNUSED_PARAMETER(scene);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicPreview::DoSelect(const vec2 &pos)
|
|
|
|
{
|
|
|
|
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
|
|
|
|
|
|
|
OBSScene scene = main->GetCurrentScene();
|
|
|
|
OBSSceneItem item = GetItemAtPos(pos, true);
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
obs_scene_enum_items(scene, select_one, (obs_sceneitem_t*)item);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicPreview::DoCtrlSelect(const vec2 &pos)
|
|
|
|
{
|
|
|
|
OBSSceneItem item = GetItemAtPos(pos, false);
|
|
|
|
if (!item)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bool selected = obs_sceneitem_selected(item);
|
|
|
|
obs_sceneitem_select(item, !selected);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicPreview::ProcessClick(const vec2 &pos)
|
|
|
|
{
|
|
|
|
Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers();
|
|
|
|
|
|
|
|
if (modifiers & Qt::ControlModifier)
|
|
|
|
DoCtrlSelect(pos);
|
|
|
|
else
|
|
|
|
DoSelect(pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicPreview::mouseReleaseEvent(QMouseEvent *event)
|
|
|
|
{
|
2016-11-10 09:32:44 -05:00
|
|
|
if (scrollMode)
|
|
|
|
setCursor(Qt::OpenHandCursor);
|
|
|
|
|
2016-07-26 01:32:43 -07:00
|
|
|
if (locked) {
|
|
|
|
OBSQTDisplay::mouseReleaseEvent(event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
if (mouseDown) {
|
|
|
|
vec2 pos = GetMouseEventPos(event);
|
|
|
|
|
|
|
|
if (!mouseMoved)
|
|
|
|
ProcessClick(pos);
|
|
|
|
|
|
|
|
stretchItem = nullptr;
|
|
|
|
mouseDown = false;
|
|
|
|
mouseMoved = false;
|
2016-03-30 18:46:02 -07:00
|
|
|
cropping = false;
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SelectedItemBounds {
|
|
|
|
bool first = true;
|
|
|
|
vec3 tl, br;
|
|
|
|
};
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
static bool AddItemBounds(obs_scene_t *scene, obs_sceneitem_t *item,
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
void *param)
|
|
|
|
{
|
|
|
|
SelectedItemBounds *data = reinterpret_cast<SelectedItemBounds*>(param);
|
|
|
|
|
|
|
|
if (!obs_sceneitem_selected(item))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
matrix4 boxTransform;
|
|
|
|
obs_sceneitem_get_box_transform(item, &boxTransform);
|
|
|
|
|
|
|
|
vec3 t[4] = {
|
|
|
|
GetTransformedPos(0.0f, 0.0f, boxTransform),
|
|
|
|
GetTransformedPos(1.0f, 0.0f, boxTransform),
|
|
|
|
GetTransformedPos(0.0f, 1.0f, boxTransform),
|
|
|
|
GetTransformedPos(1.0f, 1.0f, boxTransform)
|
|
|
|
};
|
|
|
|
|
|
|
|
for (const vec3 &v : t) {
|
|
|
|
if (data->first) {
|
|
|
|
vec3_copy(&data->tl, &v);
|
|
|
|
vec3_copy(&data->br, &v);
|
|
|
|
data->first = false;
|
|
|
|
} else {
|
|
|
|
vec3_min(&data->tl, &data->tl, &v);
|
|
|
|
vec3_max(&data->br, &data->br, &v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UNUSED_PARAMETER(scene);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-06 18:13:56 -07:00
|
|
|
struct OffsetData {
|
|
|
|
float clampDist;
|
|
|
|
vec3 tl, br, offset;
|
|
|
|
};
|
|
|
|
|
|
|
|
static bool GetSourceSnapOffset(obs_scene_t *scene, obs_sceneitem_t *item,
|
|
|
|
void *param)
|
|
|
|
{
|
|
|
|
OffsetData *data = reinterpret_cast<OffsetData*>(param);
|
|
|
|
|
|
|
|
if (obs_sceneitem_selected(item))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
matrix4 boxTransform;
|
|
|
|
obs_sceneitem_get_box_transform(item, &boxTransform);
|
|
|
|
|
|
|
|
vec3 t[4] = {
|
|
|
|
GetTransformedPos(0.0f, 0.0f, boxTransform),
|
|
|
|
GetTransformedPos(1.0f, 0.0f, boxTransform),
|
|
|
|
GetTransformedPos(0.0f, 1.0f, boxTransform),
|
|
|
|
GetTransformedPos(1.0f, 1.0f, boxTransform)
|
|
|
|
};
|
|
|
|
|
|
|
|
bool first = true;
|
|
|
|
vec3 tl, br;
|
|
|
|
vec3_zero(&tl);
|
|
|
|
vec3_zero(&br);
|
|
|
|
for (const vec3 &v : t) {
|
|
|
|
if (first) {
|
|
|
|
vec3_copy(&tl, &v);
|
|
|
|
vec3_copy(&br, &v);
|
|
|
|
first = false;
|
|
|
|
} else {
|
|
|
|
vec3_min(&tl, &tl, &v);
|
|
|
|
vec3_max(&br, &br, &v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Snap to other source edges
|
|
|
|
#define EDGE_SNAP(l, r, x, y) \
|
|
|
|
do { \
|
|
|
|
double dist = fabsf(l.x - data->r.x); \
|
|
|
|
if (dist < data->clampDist && \
|
|
|
|
fabsf(data->offset.x) < EPSILON && \
|
|
|
|
data->tl.y < br.y && \
|
|
|
|
data->br.y > tl.y && \
|
|
|
|
(fabsf(data->offset.x) > dist || data->offset.x < EPSILON)) \
|
|
|
|
data->offset.x = l.x - data->r.x; \
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
EDGE_SNAP(tl, br, x, y);
|
|
|
|
EDGE_SNAP(tl, br, y, x);
|
|
|
|
EDGE_SNAP(br, tl, x, y);
|
|
|
|
EDGE_SNAP(br, tl, y, x);
|
|
|
|
#undef EDGE_SNAP
|
|
|
|
|
|
|
|
UNUSED_PARAMETER(scene);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
void OBSBasicPreview::SnapItemMovement(vec2 &offset)
|
|
|
|
{
|
|
|
|
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
|
|
|
OBSScene scene = main->GetCurrentScene();
|
|
|
|
|
|
|
|
SelectedItemBounds data;
|
|
|
|
obs_scene_enum_items(scene, AddItemBounds, &data);
|
|
|
|
|
|
|
|
data.tl.x += offset.x;
|
|
|
|
data.tl.y += offset.y;
|
|
|
|
data.br.x += offset.x;
|
|
|
|
data.br.y += offset.y;
|
|
|
|
|
2016-04-06 18:03:29 -07:00
|
|
|
vec3 snapOffset = GetSnapOffset(data.tl, data.br);
|
|
|
|
|
|
|
|
const bool snap = config_get_bool(GetGlobalConfig(),
|
|
|
|
"BasicWindow", "SnappingEnabled");
|
2016-04-06 18:13:56 -07:00
|
|
|
const bool sourcesSnap = config_get_bool(GetGlobalConfig(),
|
|
|
|
"BasicWindow", "SourceSnapping");
|
2016-04-06 18:03:29 -07:00
|
|
|
if (snap == false)
|
|
|
|
return;
|
2016-04-06 18:13:56 -07:00
|
|
|
if (sourcesSnap == false) {
|
|
|
|
offset.x += snapOffset.x;
|
|
|
|
offset.y += snapOffset.y;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const float clampDist = config_get_double(GetGlobalConfig(),
|
|
|
|
"BasicWindow", "SnapDistance") / main->previewScale;
|
2016-04-06 18:03:29 -07:00
|
|
|
|
2016-04-06 18:13:56 -07:00
|
|
|
OffsetData offsetData;
|
|
|
|
offsetData.clampDist = clampDist;
|
|
|
|
offsetData.tl = data.tl;
|
|
|
|
offsetData.br = data.br;
|
|
|
|
vec3_copy(&offsetData.offset, &snapOffset);
|
|
|
|
|
|
|
|
obs_scene_enum_items(scene, GetSourceSnapOffset, &offsetData);
|
|
|
|
|
|
|
|
if (fabsf(offsetData.offset.x) > EPSILON ||
|
|
|
|
fabsf(offsetData.offset.y) > EPSILON) {
|
|
|
|
offset.x += offsetData.offset.x;
|
|
|
|
offset.y += offsetData.offset.y;
|
|
|
|
} else {
|
|
|
|
offset.x += snapOffset.x;
|
|
|
|
offset.y += snapOffset.y;
|
|
|
|
}
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
}
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
static bool move_items(obs_scene_t *scene, obs_sceneitem_t *item, void *param)
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
{
|
2017-06-17 19:10:42 -05:00
|
|
|
if (obs_sceneitem_locked(item))
|
|
|
|
return true;
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
vec2 *offset = reinterpret_cast<vec2*>(param);
|
|
|
|
|
|
|
|
if (obs_sceneitem_selected(item)) {
|
|
|
|
vec2 pos;
|
2014-08-03 14:39:19 -07:00
|
|
|
obs_sceneitem_get_pos(item, &pos);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
vec2_add(&pos, &pos, offset);
|
2014-08-03 14:39:19 -07:00
|
|
|
obs_sceneitem_set_pos(item, &pos);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
UNUSED_PARAMETER(scene);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicPreview::MoveItems(const vec2 &pos)
|
|
|
|
{
|
|
|
|
Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers();
|
|
|
|
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
|
|
|
OBSScene scene = main->GetCurrentScene();
|
|
|
|
|
|
|
|
vec2 offset, moveOffset;
|
|
|
|
vec2_sub(&offset, &pos, &startPos);
|
|
|
|
vec2_sub(&moveOffset, &offset, &lastMoveOffset);
|
|
|
|
|
|
|
|
if (!(modifiers & Qt::ControlModifier))
|
|
|
|
SnapItemMovement(moveOffset);
|
|
|
|
|
|
|
|
vec2_add(&lastMoveOffset, &lastMoveOffset, &moveOffset);
|
|
|
|
|
|
|
|
obs_scene_enum_items(scene, move_items, &moveOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
vec3 OBSBasicPreview::CalculateStretchPos(const vec3 &tl, const vec3 &br)
|
|
|
|
{
|
2014-08-03 14:39:19 -07:00
|
|
|
uint32_t alignment = obs_sceneitem_get_alignment(stretchItem);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
vec3 pos;
|
|
|
|
|
|
|
|
vec3_zero(&pos);
|
|
|
|
|
|
|
|
if (alignment & OBS_ALIGN_LEFT)
|
|
|
|
pos.x = tl.x;
|
|
|
|
else if (alignment & OBS_ALIGN_RIGHT)
|
|
|
|
pos.x = br.x;
|
|
|
|
else
|
|
|
|
pos.x = (br.x - tl.x) * 0.5f + tl.x;
|
|
|
|
|
|
|
|
if (alignment & OBS_ALIGN_TOP)
|
|
|
|
pos.y = tl.y;
|
|
|
|
else if (alignment & OBS_ALIGN_BOTTOM)
|
|
|
|
pos.y = br.y;
|
|
|
|
else
|
|
|
|
pos.y = (br.y - tl.y) * 0.5f + tl.y;
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicPreview::ClampAspect(vec3 &tl, vec3 &br, vec2 &size,
|
|
|
|
const vec2 &baseSize)
|
|
|
|
{
|
|
|
|
float baseAspect = baseSize.x / baseSize.y;
|
|
|
|
float aspect = size.x / size.y;
|
|
|
|
uint32_t stretchFlags = (uint32_t)stretchHandle;
|
|
|
|
|
|
|
|
if (stretchHandle == ItemHandle::TopLeft ||
|
|
|
|
stretchHandle == ItemHandle::TopRight ||
|
|
|
|
stretchHandle == ItemHandle::BottomLeft ||
|
|
|
|
stretchHandle == ItemHandle::BottomRight) {
|
2017-01-06 17:07:24 +01:00
|
|
|
if (aspect < baseAspect) {
|
|
|
|
if ((size.y >= 0.0f && size.x >= 0.0f) ||
|
|
|
|
(size.y <= 0.0f && size.x <= 0.0f))
|
|
|
|
size.x = size.y * baseAspect;
|
|
|
|
else
|
|
|
|
size.x = size.y * baseAspect * -1.0f;
|
|
|
|
} else {
|
|
|
|
if ((size.y >= 0.0f && size.x >= 0.0f) ||
|
|
|
|
(size.y <= 0.0f && size.x <= 0.0f))
|
|
|
|
size.y = size.x / baseAspect;
|
|
|
|
else
|
|
|
|
size.y = size.x / baseAspect * -1.0f;
|
|
|
|
}
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
|
|
|
} else if (stretchHandle == ItemHandle::TopCenter ||
|
|
|
|
stretchHandle == ItemHandle::BottomCenter) {
|
2017-01-06 17:07:24 +01:00
|
|
|
if ((size.y >= 0.0f && size.x >= 0.0f) ||
|
|
|
|
(size.y <= 0.0f && size.x <= 0.0f))
|
|
|
|
size.x = size.y * baseAspect;
|
|
|
|
else
|
|
|
|
size.x = size.y * baseAspect * -1.0f;
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
|
|
|
} else if (stretchHandle == ItemHandle::CenterLeft ||
|
|
|
|
stretchHandle == ItemHandle::CenterRight) {
|
2017-01-06 17:07:24 +01:00
|
|
|
if ((size.y >= 0.0f && size.x >= 0.0f) ||
|
|
|
|
(size.y <= 0.0f && size.x <= 0.0f))
|
|
|
|
size.y = size.x / baseAspect;
|
|
|
|
else
|
|
|
|
size.y = size.x / baseAspect * -1.0f;
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
size.x = std::round(size.x);
|
|
|
|
size.y = std::round(size.y);
|
|
|
|
|
|
|
|
if (stretchFlags & ITEM_LEFT)
|
|
|
|
tl.x = br.x - size.x;
|
|
|
|
else if (stretchFlags & ITEM_RIGHT)
|
|
|
|
br.x = tl.x + size.x;
|
|
|
|
|
|
|
|
if (stretchFlags & ITEM_TOP)
|
|
|
|
tl.y = br.y - size.y;
|
|
|
|
else if (stretchFlags & ITEM_BOTTOM)
|
|
|
|
br.y = tl.y + size.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicPreview::SnapStretchingToScreen(vec3 &tl, vec3 &br)
|
|
|
|
{
|
|
|
|
uint32_t stretchFlags = (uint32_t)stretchHandle;
|
|
|
|
vec3 newTL = GetTransformedPos(tl.x, tl.y, itemToScreen);
|
|
|
|
vec3 newTR = GetTransformedPos(br.x, tl.y, itemToScreen);
|
|
|
|
vec3 newBL = GetTransformedPos(tl.x, br.y, itemToScreen);
|
|
|
|
vec3 newBR = GetTransformedPos(br.x, br.y, itemToScreen);
|
|
|
|
vec3 boundingTL;
|
|
|
|
vec3 boundingBR;
|
|
|
|
|
|
|
|
vec3_copy(&boundingTL, &newTL);
|
|
|
|
vec3_min(&boundingTL, &boundingTL, &newTR);
|
|
|
|
vec3_min(&boundingTL, &boundingTL, &newBL);
|
|
|
|
vec3_min(&boundingTL, &boundingTL, &newBR);
|
|
|
|
|
|
|
|
vec3_copy(&boundingBR, &newTL);
|
|
|
|
vec3_max(&boundingBR, &boundingBR, &newTR);
|
|
|
|
vec3_max(&boundingBR, &boundingBR, &newBL);
|
|
|
|
vec3_max(&boundingBR, &boundingBR, &newBR);
|
|
|
|
|
2016-04-06 18:03:29 -07:00
|
|
|
vec3 offset = GetSnapOffset(boundingTL, boundingBR);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
vec3_add(&offset, &offset, &newTL);
|
|
|
|
vec3_transform(&offset, &offset, &screenToItem);
|
|
|
|
vec3_sub(&offset, &offset, &tl);
|
|
|
|
|
|
|
|
if (stretchFlags & ITEM_LEFT)
|
|
|
|
tl.x += offset.x;
|
|
|
|
else if (stretchFlags & ITEM_RIGHT)
|
|
|
|
br.x += offset.x;
|
|
|
|
|
|
|
|
if (stretchFlags & ITEM_TOP)
|
|
|
|
tl.y += offset.y;
|
|
|
|
else if (stretchFlags & ITEM_BOTTOM)
|
|
|
|
br.y += offset.y;
|
|
|
|
}
|
|
|
|
|
2016-05-02 17:07:13 -07:00
|
|
|
static float maxfunc(float x, float y)
|
|
|
|
{
|
|
|
|
return x > y ? x : y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static float minfunc(float x, float y)
|
|
|
|
{
|
|
|
|
return x < y ? x : y;
|
|
|
|
}
|
|
|
|
|
2016-03-30 18:46:02 -07:00
|
|
|
void OBSBasicPreview::CropItem(const vec2 &pos)
|
|
|
|
{
|
|
|
|
obs_bounds_type boundsType = obs_sceneitem_get_bounds_type(stretchItem);
|
|
|
|
uint32_t stretchFlags = (uint32_t)stretchHandle;
|
|
|
|
uint32_t align = obs_sceneitem_get_alignment(stretchItem);
|
|
|
|
vec3 tl, br, pos3;
|
|
|
|
|
|
|
|
if (boundsType != OBS_BOUNDS_NONE) /* TODO */
|
|
|
|
return;
|
|
|
|
|
|
|
|
vec3_zero(&tl);
|
|
|
|
vec3_set(&br, stretchItemSize.x, stretchItemSize.y, 0.0f);
|
|
|
|
|
|
|
|
vec3_set(&pos3, pos.x, pos.y, 0.0f);
|
|
|
|
vec3_transform(&pos3, &pos3, &screenToItem);
|
|
|
|
|
|
|
|
obs_sceneitem_crop crop = startCrop;
|
|
|
|
vec2 scale;
|
|
|
|
|
|
|
|
obs_sceneitem_get_scale(stretchItem, &scale);
|
|
|
|
|
|
|
|
vec2 max_tl;
|
|
|
|
vec2 max_br;
|
|
|
|
|
|
|
|
vec2_set(&max_tl,
|
|
|
|
float(-crop.left) * scale.x,
|
|
|
|
float(-crop.top) * scale.y);
|
|
|
|
vec2_set(&max_br,
|
|
|
|
stretchItemSize.x + crop.right * scale.x,
|
|
|
|
stretchItemSize.y + crop.bottom * scale.y);
|
|
|
|
|
2016-05-02 17:07:13 -07:00
|
|
|
typedef std::function<float (float, float)> minmax_func_t;
|
2016-03-30 18:46:02 -07:00
|
|
|
|
2016-05-02 17:07:13 -07:00
|
|
|
minmax_func_t min_x = scale.x < 0.0f ? maxfunc : minfunc;
|
|
|
|
minmax_func_t min_y = scale.y < 0.0f ? maxfunc : minfunc;
|
|
|
|
minmax_func_t max_x = scale.x < 0.0f ? minfunc : maxfunc;
|
|
|
|
minmax_func_t max_y = scale.y < 0.0f ? minfunc : maxfunc;
|
2016-03-30 18:46:02 -07:00
|
|
|
|
2016-05-02 17:07:13 -07:00
|
|
|
pos3.x = min_x(pos3.x, max_br.x);
|
|
|
|
pos3.x = max_x(pos3.x, max_tl.x);
|
|
|
|
pos3.y = min_y(pos3.y, max_br.y);
|
|
|
|
pos3.y = max_y(pos3.y, max_tl.y);
|
|
|
|
|
|
|
|
if (stretchFlags & ITEM_LEFT) {
|
2016-03-30 18:46:02 -07:00
|
|
|
float maxX = stretchItemSize.x - (2.0 * scale.x);
|
2016-05-02 17:07:13 -07:00
|
|
|
pos3.x = tl.x = min_x(pos3.x, maxX);
|
2016-03-30 18:46:02 -07:00
|
|
|
|
2016-05-02 17:07:13 -07:00
|
|
|
} else if (stretchFlags & ITEM_RIGHT) {
|
2016-03-30 18:46:02 -07:00
|
|
|
float minX = (2.0 * scale.x);
|
2016-05-02 17:07:13 -07:00
|
|
|
pos3.x = br.x = max_x(pos3.x, minX);
|
2016-03-30 18:46:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (stretchFlags & ITEM_TOP) {
|
|
|
|
float maxY = stretchItemSize.y - (2.0 * scale.y);
|
2016-05-02 17:07:13 -07:00
|
|
|
pos3.y = tl.y = min_y(pos3.y, maxY);
|
2016-03-30 18:46:02 -07:00
|
|
|
|
2016-05-02 17:07:13 -07:00
|
|
|
} else if (stretchFlags & ITEM_BOTTOM) {
|
2016-03-30 18:46:02 -07:00
|
|
|
float minY = (2.0 * scale.y);
|
2016-05-02 17:07:13 -07:00
|
|
|
pos3.y = br.y = max_y(pos3.y, minY);
|
2016-03-30 18:46:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ALIGN_X (ITEM_LEFT|ITEM_RIGHT)
|
|
|
|
#define ALIGN_Y (ITEM_TOP|ITEM_BOTTOM)
|
|
|
|
vec3 newPos;
|
|
|
|
vec3_zero(&newPos);
|
|
|
|
|
|
|
|
uint32_t align_x = (align & ALIGN_X);
|
|
|
|
uint32_t align_y = (align & ALIGN_Y);
|
|
|
|
if (align_x == (stretchFlags & ALIGN_X) && align_x != 0)
|
|
|
|
newPos.x = pos3.x;
|
|
|
|
else if (align & ITEM_RIGHT)
|
|
|
|
newPos.x = stretchItemSize.x;
|
|
|
|
else if (!(align & ITEM_LEFT))
|
|
|
|
newPos.x = stretchItemSize.x * 0.5f;
|
|
|
|
|
|
|
|
if (align_y == (stretchFlags & ALIGN_Y) && align_y != 0)
|
|
|
|
newPos.y = pos3.y;
|
|
|
|
else if (align & ITEM_BOTTOM)
|
|
|
|
newPos.y = stretchItemSize.y;
|
|
|
|
else if (!(align & ITEM_TOP))
|
|
|
|
newPos.y = stretchItemSize.y * 0.5f;
|
|
|
|
#undef ALIGN_X
|
|
|
|
#undef ALIGN_Y
|
|
|
|
|
|
|
|
crop = startCrop;
|
|
|
|
|
|
|
|
if (stretchFlags & ITEM_LEFT)
|
|
|
|
crop.left += int(std::round(tl.x / scale.x));
|
|
|
|
else if (stretchFlags & ITEM_RIGHT)
|
|
|
|
crop.right += int(std::round((stretchItemSize.x - br.x) / scale.x));
|
|
|
|
|
|
|
|
if (stretchFlags & ITEM_TOP)
|
|
|
|
crop.top += int(std::round(tl.y / scale.y));
|
|
|
|
else if (stretchFlags & ITEM_BOTTOM)
|
|
|
|
crop.bottom += int(std::round((stretchItemSize.y - br.y) / scale.y));
|
|
|
|
|
|
|
|
vec3_transform(&newPos, &newPos, &itemToScreen);
|
|
|
|
newPos.x = std::round(newPos.x);
|
|
|
|
newPos.y = std::round(newPos.y);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
vec3 curPos;
|
|
|
|
vec3_zero(&curPos);
|
|
|
|
obs_sceneitem_get_pos(stretchItem, (vec2*)&curPos);
|
|
|
|
blog(LOG_DEBUG, "curPos {%d, %d} - newPos {%d, %d}",
|
|
|
|
int(curPos.x), int(curPos.y),
|
|
|
|
int(newPos.x), int(newPos.y));
|
|
|
|
blog(LOG_DEBUG, "crop {%d, %d, %d, %d}",
|
|
|
|
crop.left, crop.top,
|
|
|
|
crop.right, crop.bottom);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
obs_sceneitem_defer_update_begin(stretchItem);
|
|
|
|
obs_sceneitem_set_crop(stretchItem, &crop);
|
|
|
|
obs_sceneitem_set_pos(stretchItem, (vec2*)&newPos);
|
|
|
|
obs_sceneitem_defer_update_end(stretchItem);
|
|
|
|
}
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
void OBSBasicPreview::StretchItem(const vec2 &pos)
|
|
|
|
{
|
|
|
|
Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers();
|
|
|
|
obs_bounds_type boundsType = obs_sceneitem_get_bounds_type(stretchItem);
|
|
|
|
uint32_t stretchFlags = (uint32_t)stretchHandle;
|
|
|
|
bool shiftDown = (modifiers & Qt::ShiftModifier);
|
|
|
|
vec3 tl, br, pos3;
|
|
|
|
|
|
|
|
vec3_zero(&tl);
|
|
|
|
vec3_set(&br, stretchItemSize.x, stretchItemSize.y, 0.0f);
|
|
|
|
|
|
|
|
vec3_set(&pos3, pos.x, pos.y, 0.0f);
|
|
|
|
vec3_transform(&pos3, &pos3, &screenToItem);
|
|
|
|
|
|
|
|
if (stretchFlags & ITEM_LEFT)
|
|
|
|
tl.x = pos3.x;
|
|
|
|
else if (stretchFlags & ITEM_RIGHT)
|
|
|
|
br.x = pos3.x;
|
|
|
|
|
|
|
|
if (stretchFlags & ITEM_TOP)
|
|
|
|
tl.y = pos3.y;
|
|
|
|
else if (stretchFlags & ITEM_BOTTOM)
|
|
|
|
br.y = pos3.y;
|
|
|
|
|
|
|
|
if (!(modifiers & Qt::ControlModifier))
|
|
|
|
SnapStretchingToScreen(tl, br);
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
obs_source_t *source = obs_sceneitem_get_source(stretchItem);
|
2014-06-16 17:55:48 -07:00
|
|
|
|
|
|
|
vec2 baseSize;
|
|
|
|
vec2_set(&baseSize,
|
2014-08-04 08:41:15 -07:00
|
|
|
float(obs_source_get_width(source)),
|
|
|
|
float(obs_source_get_height(source)));
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
2014-06-16 17:55:48 -07:00
|
|
|
vec2 size;
|
|
|
|
vec2_set(&size,br. x - tl.x, br.y - tl.y);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
|
|
|
if (boundsType != OBS_BOUNDS_NONE) {
|
Do not clamp aspect by default when using bounds
If the scene item has a bounding box set up for it, do not make it use
aspect ratio clamping by default.
Instead, make it so that shift will turn on aspect ratio, and make it
also apply to all types of bounding box modes.
The only time where aspect ratio clamping should apply by default is
when bounds are not in use (i.e. when a source is just created). Some
will disagree with me just because that's how photoshop does it, but
we're not photoshop, and I feel that the majority of users will have
more trouble with it disabled by default than enabled by default.
So to sum it up:
If bounds inactive, clamp aspect ratio by default, because scene items
start out with it inactive, and it directly affects the scale.
If bounds active, do not clamp aspect ratio by default, because clamping
to aspect ratio doesn't particularly have an effect for mode bounds
modes except for "stretch to bounds".
2014-06-22 23:53:39 -07:00
|
|
|
if (shiftDown)
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
ClampAspect(tl, br, size, baseSize);
|
|
|
|
|
|
|
|
if (tl.x > br.x) std::swap(tl.x, br.x);
|
|
|
|
if (tl.y > br.y) std::swap(tl.y, br.y);
|
|
|
|
|
|
|
|
vec2_abs(&size, &size);
|
|
|
|
|
|
|
|
obs_sceneitem_set_bounds(stretchItem, &size);
|
|
|
|
} else {
|
2016-03-30 18:46:02 -07:00
|
|
|
obs_sceneitem_crop crop;
|
|
|
|
obs_sceneitem_get_crop(stretchItem, &crop);
|
|
|
|
|
|
|
|
baseSize.x -= float(crop.left + crop.right);
|
|
|
|
baseSize.y -= float(crop.top + crop.bottom);
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
if (!shiftDown)
|
|
|
|
ClampAspect(tl, br, size, baseSize);
|
|
|
|
|
|
|
|
vec2_div(&size, &size, &baseSize);
|
2014-08-03 14:39:19 -07:00
|
|
|
obs_sceneitem_set_scale(stretchItem, &size);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pos3 = CalculateStretchPos(tl, br);
|
|
|
|
vec3_transform(&pos3, &pos3, &itemToScreen);
|
|
|
|
|
2014-06-16 17:55:48 -07:00
|
|
|
vec2 newPos;
|
|
|
|
vec2_set(&newPos, std::round(pos3.x), std::round(pos3.y));
|
2014-08-03 14:39:19 -07:00
|
|
|
obs_sceneitem_set_pos(stretchItem, &newPos);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event)
|
|
|
|
{
|
2016-11-05 12:48:46 -04:00
|
|
|
if (scrollMode && event->buttons() == Qt::LeftButton) {
|
|
|
|
scrollingOffset.x += event->x() - scrollingFrom.x;
|
|
|
|
scrollingOffset.y += event->y() - scrollingFrom.y;
|
|
|
|
scrollingFrom.x = event->x();
|
|
|
|
scrollingFrom.y = event->y();
|
|
|
|
emit DisplayResized();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-11-10 09:32:44 -05:00
|
|
|
if (locked)
|
|
|
|
return;
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
if (mouseDown) {
|
|
|
|
vec2 pos = GetMouseEventPos(event);
|
|
|
|
|
|
|
|
if (!mouseMoved && !mouseOverItems &&
|
|
|
|
stretchHandle == ItemHandle::None) {
|
|
|
|
ProcessClick(startPos);
|
|
|
|
mouseOverItems = SelectedAtPos(startPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
pos.x = std::round(pos.x);
|
|
|
|
pos.y = std::round(pos.y);
|
|
|
|
|
2016-03-30 18:46:02 -07:00
|
|
|
if (stretchHandle != ItemHandle::None) {
|
|
|
|
if (cropping)
|
|
|
|
CropItem(pos);
|
|
|
|
else
|
|
|
|
StretchItem(pos);
|
|
|
|
|
|
|
|
} else if (mouseOverItems) {
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
MoveItems(pos);
|
2016-03-30 18:46:02 -07:00
|
|
|
}
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
|
|
|
mouseMoved = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DrawCircleAtPos(float x, float y, matrix4 &matrix,
|
|
|
|
float previewScale)
|
|
|
|
{
|
|
|
|
struct vec3 pos;
|
|
|
|
vec3_set(&pos, x, y, 0.0f);
|
|
|
|
vec3_transform(&pos, &pos, &matrix);
|
|
|
|
vec3_mulf(&pos, &pos, previewScale);
|
|
|
|
|
|
|
|
gs_matrix_push();
|
|
|
|
gs_matrix_translate(&pos);
|
2014-08-20 12:38:53 -07:00
|
|
|
gs_matrix_scale3f(HANDLE_RADIUS, HANDLE_RADIUS, 1.0f);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
gs_draw(GS_LINESTRIP, 0, 0);
|
|
|
|
gs_matrix_pop();
|
|
|
|
}
|
|
|
|
|
2016-03-30 18:46:02 -07:00
|
|
|
static inline bool crop_enabled(const obs_sceneitem_crop *crop)
|
|
|
|
{
|
|
|
|
return crop->left > 0 ||
|
|
|
|
crop->top > 0 ||
|
|
|
|
crop->right > 0 ||
|
|
|
|
crop->bottom > 0;
|
|
|
|
}
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
bool OBSBasicPreview::DrawSelectedItem(obs_scene_t *scene,
|
|
|
|
obs_sceneitem_t *item, void *param)
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
{
|
2017-06-17 19:10:42 -05:00
|
|
|
if (obs_sceneitem_locked(item))
|
|
|
|
return true;
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
if (!obs_sceneitem_selected(item))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
|
|
|
|
|
|
|
matrix4 boxTransform;
|
2014-10-14 02:42:30 +02:00
|
|
|
matrix4 invBoxTransform;
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
obs_sceneitem_get_box_transform(item, &boxTransform);
|
2014-10-14 02:42:30 +02:00
|
|
|
matrix4_inv(&invBoxTransform, &boxTransform);
|
|
|
|
|
|
|
|
vec3 bounds[] = {
|
|
|
|
{{{0.f, 0.f, 0.f}}},
|
|
|
|
{{{1.f, 0.f, 0.f}}},
|
|
|
|
{{{0.f, 1.f, 0.f}}},
|
|
|
|
{{{1.f, 1.f, 0.f}}},
|
|
|
|
};
|
|
|
|
|
|
|
|
bool visible = std::all_of(std::begin(bounds), std::end(bounds),
|
|
|
|
[&](const vec3 &b)
|
|
|
|
{
|
|
|
|
vec3 pos;
|
|
|
|
vec3_transform(&pos, &b, &boxTransform);
|
|
|
|
vec3_transform(&pos, &pos, &invBoxTransform);
|
|
|
|
return CloseFloat(pos.x, b.x) && CloseFloat(pos.y, b.y);
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!visible)
|
|
|
|
return true;
|
|
|
|
|
2016-03-30 18:46:02 -07:00
|
|
|
obs_transform_info info;
|
|
|
|
obs_sceneitem_get_info(item, &info);
|
|
|
|
|
2014-10-14 02:42:30 +02:00
|
|
|
gs_load_vertexbuffer(main->circle);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
|
|
|
DrawCircleAtPos(0.0f, 0.0f, boxTransform, main->previewScale);
|
|
|
|
DrawCircleAtPos(0.0f, 1.0f, boxTransform, main->previewScale);
|
|
|
|
DrawCircleAtPos(1.0f, 0.0f, boxTransform, main->previewScale);
|
|
|
|
DrawCircleAtPos(1.0f, 1.0f, boxTransform, main->previewScale);
|
|
|
|
DrawCircleAtPos(0.5f, 0.0f, boxTransform, main->previewScale);
|
|
|
|
DrawCircleAtPos(0.0f, 0.5f, boxTransform, main->previewScale);
|
|
|
|
DrawCircleAtPos(0.5f, 1.0f, boxTransform, main->previewScale);
|
|
|
|
DrawCircleAtPos(1.0f, 0.5f, boxTransform, main->previewScale);
|
|
|
|
|
|
|
|
gs_matrix_push();
|
|
|
|
gs_matrix_scale3f(main->previewScale, main->previewScale, 1.0f);
|
2014-08-20 12:38:53 -07:00
|
|
|
gs_matrix_mul(&boxTransform);
|
2016-03-30 18:44:49 -07:00
|
|
|
|
|
|
|
obs_sceneitem_crop crop;
|
|
|
|
obs_sceneitem_get_crop(item, &crop);
|
|
|
|
|
|
|
|
if (info.bounds_type == OBS_BOUNDS_NONE && crop_enabled(&crop)) {
|
|
|
|
vec4 color;
|
|
|
|
gs_effect_t *eff = gs_get_effect();
|
|
|
|
gs_eparam_t *param = gs_effect_get_param_by_name(eff, "color");
|
|
|
|
|
|
|
|
#define DRAW_SIDE(side, vb) \
|
|
|
|
if (crop.side > 0) \
|
|
|
|
vec4_set(&color, 0.0f, 1.0f, 0.0f, 1.0f); \
|
|
|
|
else \
|
|
|
|
vec4_set(&color, 1.0f, 0.0f, 0.0f, 1.0f); \
|
|
|
|
gs_effect_set_vec4(param, &color); \
|
|
|
|
gs_load_vertexbuffer(main->vb); \
|
|
|
|
gs_draw(GS_LINESTRIP, 0, 0);
|
|
|
|
|
|
|
|
DRAW_SIDE(left, boxLeft);
|
|
|
|
DRAW_SIDE(top, boxTop);
|
|
|
|
DRAW_SIDE(right, boxRight);
|
|
|
|
DRAW_SIDE(bottom, boxBottom);
|
|
|
|
#undef DRAW_SIDE
|
|
|
|
} else {
|
|
|
|
gs_load_vertexbuffer(main->box);
|
|
|
|
gs_draw(GS_LINESTRIP, 0, 0);
|
|
|
|
}
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
|
|
|
gs_matrix_pop();
|
|
|
|
|
|
|
|
UNUSED_PARAMETER(scene);
|
2014-06-16 17:55:48 -07:00
|
|
|
UNUSED_PARAMETER(param);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicPreview::DrawSceneEditing()
|
|
|
|
{
|
2016-07-26 01:32:43 -07:00
|
|
|
if (locked)
|
|
|
|
return;
|
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
|
|
|
|
|
2015-10-16 07:31:52 -07:00
|
|
|
gs_effect_t *solid = obs_get_base_effect(OBS_EFFECT_SOLID);
|
2014-09-25 17:44:05 -07:00
|
|
|
gs_technique_t *tech = gs_effect_get_technique(solid, "Solid");
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
|
|
|
vec4 color;
|
|
|
|
vec4_set(&color, 1.0f, 0.0f, 0.0f, 1.0f);
|
2014-08-07 23:42:07 -07:00
|
|
|
gs_effect_set_vec4(gs_effect_get_param_by_name(solid, "color"), &color);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
2014-08-07 23:42:07 -07:00
|
|
|
gs_technique_begin(tech);
|
|
|
|
gs_technique_begin_pass(tech, 0);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
|
|
|
|
OBSScene scene = main->GetCurrentScene();
|
2017-06-17 19:10:42 -05:00
|
|
|
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
if (scene)
|
|
|
|
obs_scene_enum_items(scene, DrawSelectedItem, this);
|
|
|
|
|
|
|
|
gs_load_vertexbuffer(nullptr);
|
|
|
|
|
2014-08-07 23:42:07 -07:00
|
|
|
gs_technique_end_pass(tech);
|
|
|
|
gs_technique_end(tech);
|
UI: Add scene editing
So, scene editing was interesting (and by interesting I mean
excruciating). I almost implemented 'manipulator' visuals (ala 3dsmax
for example), and used 3 modes for controlling position/rotation/size,
but in a 2D editing, it felt clunky, so I defaulted back to simply
click-and-drag for movement, and then took a similar though slightly
different looking approach for handling scaling and reszing.
I also added a number of menu item helpers related to positioning,
scaling, rotating, flipping, and resetting the transform back to
default.
There is also a new 'transform' dialog (accessible via menu) which will
allow you to manually edit every single transform variable of a scene
item directly if desired.
If a scene item does not have bounds active, pulling on the sides of a
source will cause it to resize it via base scale rather than by the
bounding box system (if the source resizes that scale will apply). If
bounds are active, it will modify the bounding box only instead.
How a source scales when a bounding box is active depends on the type of
bounds being used. You can set it to scale to the inner bounds, the
outer bounds, scale to bounds width only, scale to bounds height only,
and a setting to stretch to bounds (which forces a source to always draw
at the bounding box size rather than be affected by its internal size).
You can also set it to be used as a 'maximum' size, so that the source
doesn't necessarily get scaled unless it extends beyond the bounds.
Like in OBS1, objects will snap to the edges unless the control key is
pressed. However, this will now happen even if the object is rotated or
oriented in any strange way. Snapping will also occur when stretching
or changing the bounding box size.
2014-06-15 00:54:48 -07:00
|
|
|
}
|
2016-11-05 12:48:46 -04:00
|
|
|
|
|
|
|
void OBSBasicPreview::ResetScrollingOffset()
|
|
|
|
{
|
|
|
|
vec2_zero(&scrollingOffset);
|
|
|
|
}
|
2017-05-13 13:13:55 -04:00
|
|
|
|
|
|
|
void OBSBasicPreview::SetScalingLevel(int32_t newScalingLevelVal) {
|
|
|
|
float newScalingAmountVal = pow(ZOOM_SENSITIVITY, float(newScalingLevelVal));
|
|
|
|
scalingLevel = newScalingLevelVal;
|
|
|
|
SetScalingAmount(newScalingAmountVal);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicPreview::SetScalingAmount(float newScalingAmountVal) {
|
|
|
|
scrollingOffset.x *= newScalingAmountVal / scalingAmount;
|
|
|
|
scrollingOffset.y *= newScalingAmountVal / scalingAmount;
|
|
|
|
scalingAmount = newScalingAmountVal;
|
|
|
|
}
|