Add single-axis modes to all visual tools
Make all visual tools only update the most-changed axis whenever shift is held down. Previously the rotate and scale tools used ctrl for this and shift for snapping to round values; these have been swapped for consistency. Closes #993. Originally committed to SVN as r4310.
This commit is contained in:
parent
115dacb37e
commit
f4124e373c
4 changed files with 41 additions and 38 deletions
|
@ -158,9 +158,16 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) {
|
|||
if (dragging) {
|
||||
// Dragging
|
||||
if (event.LeftIsDown()) {
|
||||
// Update position
|
||||
features[curFeature].x = (video.x - dragStartX + dragOrigX);
|
||||
features[curFeature].y = (video.y - dragStartY + dragOrigY);
|
||||
if (shiftDown) {
|
||||
if (abs(video.x - dragStartX) > abs(video.y - dragStartY)) {
|
||||
features[curFeature].y = dragOrigY;
|
||||
}
|
||||
else {
|
||||
features[curFeature].x = dragOrigX;
|
||||
}
|
||||
}
|
||||
|
||||
// Update drag
|
||||
UpdateDrag(features[curFeature]);
|
||||
|
|
|
@ -34,11 +34,12 @@
|
|||
/// @ingroup visual_ts
|
||||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "config.h"
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#include "ass_dialogue.h"
|
||||
#include "ass_file.h"
|
||||
#include "subs_edit_box.h"
|
||||
|
@ -194,25 +195,21 @@ void VisualToolRotateXY::UpdateHold() {
|
|||
// Deltas
|
||||
float deltaX = screenAngleX - startAngleX;
|
||||
float deltaY = screenAngleY - startAngleY;
|
||||
if (ctrlDown) {
|
||||
if (shiftDown) {
|
||||
if (fabs(deltaX) >= fabs(deltaY)) deltaY = 0;
|
||||
else deltaX = 0;
|
||||
}
|
||||
|
||||
// Calculate
|
||||
curAngleX = deltaX + origAngleX;
|
||||
curAngleY = deltaY + origAngleY;
|
||||
while (curAngleX < 0.0) curAngleX += 360.0;
|
||||
while (curAngleX >= 360.0) curAngleX -= 360.0;
|
||||
while (curAngleY < 0.0) curAngleY += 360.0;
|
||||
while (curAngleY >= 360.0) curAngleY -= 360.0;
|
||||
curAngleX = fmodf(deltaX + origAngleX + 360., 360.);
|
||||
curAngleY = fmodf(deltaY + origAngleY + 360., 360.);
|
||||
|
||||
// Oh Snap
|
||||
if (shiftDown) {
|
||||
curAngleX = (float)((int)((curAngleX+15.0f)/30.0f))*30.0f;
|
||||
curAngleY = (float)((int)((curAngleY+15.0f)/30.0f))*30.0f;
|
||||
if (curAngleX == 360.0f) curAngleX = 0.0f;
|
||||
if (curAngleY == 360.0f) curAngleX = 0.0f;
|
||||
if (ctrlDown) {
|
||||
curAngleX = floorf(curAngleX/30.f+.5f)*30.0f;
|
||||
curAngleY = floorf(curAngleY/30.f+.5f)*30.0f;
|
||||
if (curAngleX > 359.0f) curAngleX = 0.0f;
|
||||
if (curAngleY > 359.0f) curAngleY = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,12 @@
|
|||
/// @ingroup visual_ts
|
||||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "config.h"
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#include "ass_dialogue.h"
|
||||
#include "ass_file.h"
|
||||
#include "subs_edit_box.h"
|
||||
|
@ -172,14 +173,12 @@ void VisualToolRotateZ::InitializeHold() {
|
|||
void VisualToolRotateZ::UpdateHold() {
|
||||
// Find angle
|
||||
float screenAngle = atan2(double(orgy-video.y),double(video.x-orgx)) * 180.0 / 3.1415926535897932;
|
||||
curAngle = screenAngle - startAngle + origAngle;
|
||||
while (curAngle < 0.0f) curAngle += 360.0f;
|
||||
while (curAngle >= 360.0f) curAngle -= 360.0f;
|
||||
curAngle = fmodf(screenAngle - startAngle + origAngle + 360.f, 360.f);
|
||||
|
||||
// Snap
|
||||
if (shiftDown) {
|
||||
curAngle = (float)((int)((curAngle+15.0f)/30.0f))*30.0f;
|
||||
if (curAngle == 360.0f) curAngle = 0.0f;
|
||||
// Oh Snap
|
||||
if (ctrlDown) {
|
||||
curAngle = floorf(curAngle/30.f+.5f)*30.0f;
|
||||
if (curAngle > 359.0f) curAngle = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,12 @@
|
|||
/// @ingroup visual_ts
|
||||
///
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#include "config.h"
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#include "ass_dialogue.h"
|
||||
#include "ass_file.h"
|
||||
#include "subs_edit_box.h"
|
||||
|
@ -144,24 +145,23 @@ void VisualToolScale::InitializeHold() {
|
|||
/// @brief Update hold
|
||||
///
|
||||
void VisualToolScale::UpdateHold() {
|
||||
using std::max;
|
||||
// Deltas
|
||||
int deltaX = video.x - startX;
|
||||
int deltaY = startY - video.y;
|
||||
if (ctrlDown) {
|
||||
if (shiftDown) {
|
||||
if (abs(deltaX) >= abs(deltaY)) deltaY = 0;
|
||||
else deltaX = 0;
|
||||
}
|
||||
|
||||
// Calculate
|
||||
curScaleX = (float(deltaX)/0.8f) + origScaleX;
|
||||
curScaleY = (float(deltaY)/0.8f) + origScaleY;
|
||||
if (curScaleX < 0.0f) curScaleX = 0.0f;
|
||||
if (curScaleY < 0.0f) curScaleY = 0.0f;
|
||||
curScaleX = max(deltaX*1.25f + origScaleX, 0.f);
|
||||
curScaleY = max(deltaY*1.25f + origScaleY, 0.f);
|
||||
|
||||
// Snap
|
||||
if (shiftDown) {
|
||||
curScaleX = (float)((int)((curScaleX+12.5f)/25.0f))*25.0f;
|
||||
curScaleY = (float)((int)((curScaleY+12.5f)/25.0f))*25.0f;
|
||||
// Oh Snap
|
||||
if (ctrlDown) {
|
||||
curScaleX = floorf(curScaleX/25.f+.5f)*25.0f;
|
||||
curScaleY = floorf(curScaleY/25.f+.5f)*25.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue