Merge pull request #3311 from WizardCM/preview-cursors-hover
UI: Change cursor when interacting with the previewmaster
commit
d1f77d9c59
|
@ -583,6 +583,25 @@ void OBSBasicPreview::mousePressEvent(QMouseEvent *event)
|
|||
mousePos = startPos;
|
||||
}
|
||||
|
||||
void OBSBasicPreview::UpdateCursor(uint32_t &flags)
|
||||
{
|
||||
if (!flags && cursor().shape() != Qt::OpenHandCursor)
|
||||
unsetCursor();
|
||||
if (cursor().shape() != Qt::ArrowCursor)
|
||||
return;
|
||||
|
||||
if ((flags & ITEM_LEFT && flags & ITEM_TOP) ||
|
||||
(flags & ITEM_RIGHT && flags & ITEM_BOTTOM))
|
||||
setCursor(Qt::SizeFDiagCursor);
|
||||
else if ((flags & ITEM_LEFT && flags & ITEM_BOTTOM) ||
|
||||
(flags & ITEM_RIGHT && flags & ITEM_TOP))
|
||||
setCursor(Qt::SizeBDiagCursor);
|
||||
else if (flags & ITEM_LEFT || flags & ITEM_RIGHT)
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
else if (flags & ITEM_TOP || flags & ITEM_BOTTOM)
|
||||
setCursor(Qt::SizeVerCursor);
|
||||
}
|
||||
|
||||
static bool select_one(obs_scene_t *scene, obs_sceneitem_t *item, void *param)
|
||||
{
|
||||
obs_sceneitem_t *selectedItem =
|
||||
|
@ -685,6 +704,7 @@ void OBSBasicPreview::mouseReleaseEvent(QMouseEvent *event)
|
|||
mouseMoved = false;
|
||||
cropping = false;
|
||||
selectionBox = false;
|
||||
unsetCursor();
|
||||
|
||||
OBSSceneItem item = GetItemAtPos(pos, true);
|
||||
|
||||
|
@ -1090,6 +1110,9 @@ void OBSBasicPreview::BoxItems(const vec2 &startPos, const vec2 &pos)
|
|||
if (!scene)
|
||||
return;
|
||||
|
||||
if (cursor().shape() != Qt::CrossCursor)
|
||||
setCursor(Qt::CrossCursor);
|
||||
|
||||
SceneFindBoxData data(startPos, pos);
|
||||
obs_scene_enum_items(scene, FindItemsInBox, &data);
|
||||
|
||||
|
@ -1423,6 +1446,8 @@ void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event)
|
|||
if (locked)
|
||||
return;
|
||||
|
||||
bool updateCursor = false;
|
||||
|
||||
if (mouseDown) {
|
||||
vec2 pos = GetMouseEventPos(event);
|
||||
|
||||
|
@ -1458,6 +1483,8 @@ void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event)
|
|||
StretchItem(pos);
|
||||
|
||||
} else if (mouseOverItems) {
|
||||
if (cursor().shape() != Qt::SizeAllCursor)
|
||||
setCursor(Qt::SizeAllCursor);
|
||||
selectionBox = false;
|
||||
MoveItems(pos);
|
||||
} else {
|
||||
|
@ -1476,6 +1503,27 @@ void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event)
|
|||
std::lock_guard<std::mutex> lock(selectMutex);
|
||||
hoveredPreviewItems.clear();
|
||||
hoveredPreviewItems.push_back(item);
|
||||
|
||||
if (!mouseMoved && hoveredPreviewItems.size() > 0) {
|
||||
mousePos = pos;
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(
|
||||
App()->GetMainWindow());
|
||||
#ifdef SUPPORTS_FRACTIONAL_SCALING
|
||||
float scale = main->devicePixelRatioF();
|
||||
#else
|
||||
float scale = main->devicePixelRatio();
|
||||
#endif
|
||||
float x = float(event->x()) - main->previewX / scale;
|
||||
float y = float(event->y()) - main->previewY / scale;
|
||||
vec2_set(&startPos, x, y);
|
||||
updateCursor = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (updateCursor) {
|
||||
GetStretchHandleData(startPos);
|
||||
uint32_t stretchFlags = (uint32_t)stretchHandle;
|
||||
UpdateCursor(stretchFlags);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,8 @@ private:
|
|||
|
||||
void GetStretchHandleData(const vec2 &pos);
|
||||
|
||||
void UpdateCursor(uint32_t &flags);
|
||||
|
||||
void SnapStretchingToScreen(vec3 &tl, vec3 &br);
|
||||
void ClampAspect(vec3 &tl, vec3 &br, vec2 &size, const vec2 &baseSize);
|
||||
vec3 CalculateStretchPos(const vec3 &tl, const vec3 &br);
|
||||
|
|
Loading…
Reference in New Issue