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:
Thomas Goyne 2010-05-19 03:24:01 +00:00
parent 115dacb37e
commit f4124e373c
4 changed files with 41 additions and 38 deletions

View file

@ -158,9 +158,16 @@ void VisualTool::OnMouseEvent (wxMouseEvent &event) {
if (dragging) { if (dragging) {
// Dragging // Dragging
if (event.LeftIsDown()) { if (event.LeftIsDown()) {
// Update position
features[curFeature].x = (video.x - dragStartX + dragOrigX); features[curFeature].x = (video.x - dragStartX + dragOrigX);
features[curFeature].y = (video.y - dragStartY + dragOrigY); 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 // Update drag
UpdateDrag(features[curFeature]); UpdateDrag(features[curFeature]);

View file

@ -34,11 +34,12 @@
/// @ingroup visual_ts /// @ingroup visual_ts
/// ///
///////////
// Headers
#include "config.h" #include "config.h"
#ifndef AGI_PRE
#include <math.h>
#endif
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_file.h" #include "ass_file.h"
#include "subs_edit_box.h" #include "subs_edit_box.h"
@ -194,25 +195,21 @@ void VisualToolRotateXY::UpdateHold() {
// Deltas // Deltas
float deltaX = screenAngleX - startAngleX; float deltaX = screenAngleX - startAngleX;
float deltaY = screenAngleY - startAngleY; float deltaY = screenAngleY - startAngleY;
if (ctrlDown) { if (shiftDown) {
if (fabs(deltaX) >= fabs(deltaY)) deltaY = 0; if (fabs(deltaX) >= fabs(deltaY)) deltaY = 0;
else deltaX = 0; else deltaX = 0;
} }
// Calculate // Calculate
curAngleX = deltaX + origAngleX; curAngleX = fmodf(deltaX + origAngleX + 360., 360.);
curAngleY = deltaY + origAngleY; curAngleY = fmodf(deltaY + origAngleY + 360., 360.);
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;
// Oh Snap // Oh Snap
if (shiftDown) { if (ctrlDown) {
curAngleX = (float)((int)((curAngleX+15.0f)/30.0f))*30.0f; curAngleX = floorf(curAngleX/30.f+.5f)*30.0f;
curAngleY = (float)((int)((curAngleY+15.0f)/30.0f))*30.0f; curAngleY = floorf(curAngleY/30.f+.5f)*30.0f;
if (curAngleX == 360.0f) curAngleX = 0.0f; if (curAngleX > 359.0f) curAngleX = 0.0f;
if (curAngleY == 360.0f) curAngleX = 0.0f; if (curAngleY > 359.0f) curAngleY = 0.0f;
} }
} }

View file

@ -34,11 +34,12 @@
/// @ingroup visual_ts /// @ingroup visual_ts
/// ///
///////////
// Headers
#include "config.h" #include "config.h"
#ifndef AGI_PRE
#include <math.h>
#endif
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_file.h" #include "ass_file.h"
#include "subs_edit_box.h" #include "subs_edit_box.h"
@ -172,14 +173,12 @@ void VisualToolRotateZ::InitializeHold() {
void VisualToolRotateZ::UpdateHold() { void VisualToolRotateZ::UpdateHold() {
// Find angle // Find angle
float screenAngle = atan2(double(orgy-video.y),double(video.x-orgx)) * 180.0 / 3.1415926535897932; float screenAngle = atan2(double(orgy-video.y),double(video.x-orgx)) * 180.0 / 3.1415926535897932;
curAngle = screenAngle - startAngle + origAngle; curAngle = fmodf(screenAngle - startAngle + origAngle + 360.f, 360.f);
while (curAngle < 0.0f) curAngle += 360.0f;
while (curAngle >= 360.0f) curAngle -= 360.0f;
// Snap // Oh Snap
if (shiftDown) { if (ctrlDown) {
curAngle = (float)((int)((curAngle+15.0f)/30.0f))*30.0f; curAngle = floorf(curAngle/30.f+.5f)*30.0f;
if (curAngle == 360.0f) curAngle = 0.0f; if (curAngle > 359.0f) curAngle = 0.0f;
} }
} }

View file

@ -34,11 +34,12 @@
/// @ingroup visual_ts /// @ingroup visual_ts
/// ///
///////////
// Headers
#include "config.h" #include "config.h"
#ifndef AGI_PRE
#include <math.h>
#endif
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_file.h" #include "ass_file.h"
#include "subs_edit_box.h" #include "subs_edit_box.h"
@ -144,24 +145,23 @@ void VisualToolScale::InitializeHold() {
/// @brief Update hold /// @brief Update hold
/// ///
void VisualToolScale::UpdateHold() { void VisualToolScale::UpdateHold() {
using std::max;
// Deltas // Deltas
int deltaX = video.x - startX; int deltaX = video.x - startX;
int deltaY = startY - video.y; int deltaY = startY - video.y;
if (ctrlDown) { if (shiftDown) {
if (abs(deltaX) >= abs(deltaY)) deltaY = 0; if (abs(deltaX) >= abs(deltaY)) deltaY = 0;
else deltaX = 0; else deltaX = 0;
} }
// Calculate // Calculate
curScaleX = (float(deltaX)/0.8f) + origScaleX; curScaleX = max(deltaX*1.25f + origScaleX, 0.f);
curScaleY = (float(deltaY)/0.8f) + origScaleY; curScaleY = max(deltaY*1.25f + origScaleY, 0.f);
if (curScaleX < 0.0f) curScaleX = 0.0f;
if (curScaleY < 0.0f) curScaleY = 0.0f;
// Snap // Oh Snap
if (shiftDown) { if (ctrlDown) {
curScaleX = (float)((int)((curScaleX+12.5f)/25.0f))*25.0f; curScaleX = floorf(curScaleX/25.f+.5f)*25.0f;
curScaleY = (float)((int)((curScaleY+12.5f)/25.0f))*25.0f; curScaleY = floorf(curScaleY/25.f+.5f)*25.0f;
} }
} }