mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Cosmetics. Fixed orientation of mouse cursor for resize
This commit is contained in:
@@ -252,7 +252,7 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
||||
// 2. ..from the top right corner (1,1)
|
||||
vec = ( modelview * glm::vec4(1.f, 1.f, 0.f, 1.f) ) + pos;
|
||||
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
|
||||
|
||||
// 3. draw
|
||||
handle_->draw( ctm, projection );
|
||||
}
|
||||
else if ( type_ == Handles::SCALE ){
|
||||
|
||||
@@ -222,7 +222,7 @@ void UserInterface::handleKeyboard()
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
alt_modifier_active = io.KeyAlt;
|
||||
shift_modifier_active = io.KeyShift;
|
||||
auto ctrl = io.ConfigMacOSXBehaviors ? io.KeySuper : io.KeyCtrl;
|
||||
bool ctrl = io.ConfigMacOSXBehaviors ? io.KeySuper : io.KeyCtrl;
|
||||
|
||||
// Application "CTRL +"" Shortcuts
|
||||
if ( ctrl ) {
|
||||
|
||||
22
View.cpp
22
View.cpp
@@ -746,7 +746,6 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
||||
glm::vec4 source_to = glm::inverse(s->stored_status_->transform_) * glm::vec4( scene_to, 1.f );
|
||||
glm::vec3 source_scaling = glm::vec3(source_to) / glm::vec3(source_from);
|
||||
|
||||
|
||||
// which manipulation to perform?
|
||||
std::ostringstream info;
|
||||
if (pick.first) {
|
||||
@@ -806,8 +805,10 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
||||
center = corner_to_scene_transform * center;
|
||||
// apply to node
|
||||
sourceNode->translation_ = glm::vec3(center);
|
||||
|
||||
// show cursor depending on diagonal (corner picked)
|
||||
T = glm::rotate(glm::identity<glm::mat4>(), s->stored_status_->rotation_.z, glm::vec3(0.f, 0.f, 1.f));
|
||||
T = glm::scale(T, s->stored_status_->scale_);
|
||||
corner = T * glm::vec4( corner, 0.f, 0.f );
|
||||
ret.type = corner.x * corner.y > 0.f ? Cursor_ResizeNESW : Cursor_ResizeNWSE;
|
||||
info << "Size " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
||||
info << " x " << sourceNode->scale_.y;
|
||||
@@ -838,8 +839,9 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
||||
center = corner_to_scene_transform * center;
|
||||
// apply to node
|
||||
sourceNode->translation_ = glm::vec3(center);
|
||||
|
||||
ret.type = Cursor_ResizeEW;
|
||||
// show cursor depending on angle
|
||||
float c = tan(sourceNode->rotation_.z);
|
||||
ret.type = ABS(c) > 1.f ? Cursor_ResizeNS : Cursor_ResizeEW;
|
||||
info << "Size " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
||||
info << " x " << sourceNode->scale_.y;
|
||||
}
|
||||
@@ -869,8 +871,9 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
||||
center = corner_to_scene_transform * center;
|
||||
// apply to node
|
||||
sourceNode->translation_ = glm::vec3(center);
|
||||
|
||||
ret.type = Cursor_ResizeNS;
|
||||
// show cursor depending on angle
|
||||
float c = tan(sourceNode->rotation_.z);
|
||||
ret.type = ABS(c) > 1.f ? Cursor_ResizeEW : Cursor_ResizeNS;
|
||||
info << "Size " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
||||
info << " x " << sourceNode->scale_.y;
|
||||
}
|
||||
@@ -925,18 +928,17 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
||||
info << std::endl << " Size " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
||||
info << " x " << sourceNode->scale_.y ;
|
||||
}
|
||||
|
||||
}
|
||||
// picking anywhere but on a handle: user wants to move the source
|
||||
else {
|
||||
sourceNode->translation_ = s->stored_status_->translation_ + scene_translation;
|
||||
// discretized translation with SHIFT
|
||||
if (UserInterface::manager().shiftModifier()) {
|
||||
// discretized translation with ALT
|
||||
if (UserInterface::manager().altModifier()) {
|
||||
sourceNode->translation_.x = ROUND(sourceNode->translation_.x, 10.f);
|
||||
sourceNode->translation_.y = ROUND(sourceNode->translation_.y, 10.f);
|
||||
}
|
||||
// ALT: single axis movement
|
||||
if (UserInterface::manager().altModifier()) {
|
||||
if (UserInterface::manager().shiftModifier()) {
|
||||
glm::vec3 dif = s->stored_status_->translation_ - sourceNode->translation_;
|
||||
if (ABS(dif.x) > ABS(dif.y) )
|
||||
sourceNode->translation_.y = s->stored_status_->translation_.y;
|
||||
|
||||
Reference in New Issue
Block a user