More freedom of grab translation for all views

This commit is contained in:
Bruno Herbelin
2021-11-17 23:09:49 +01:00
parent fc4e3dc362
commit 6a3ff2f235
7 changed files with 16 additions and 7 deletions

View File

@@ -186,7 +186,7 @@ void GeometryView::resize ( int scale )
scene.root()->scale_.y = z; scene.root()->scale_.y = z;
// Clamp translation to acceptable area // Clamp translation to acceptable area
glm::vec3 border(scene.root()->scale_.x * 1.5, scene.root()->scale_.y * 1.5, 0.f); glm::vec3 border(2.f * Mixer::manager().session()->frame()->aspectRatio(), 2.f, 0.f);
scene.root()->translation_ = glm::clamp(scene.root()->translation_, -border, border); scene.root()->translation_ = glm::clamp(scene.root()->translation_, -border, border);
} }

View File

@@ -217,9 +217,8 @@ void LayerView::resize ( int scale )
scene.root()->scale_.y = z; scene.root()->scale_.y = z;
// Clamp translation to acceptable area // Clamp translation to acceptable area
glm::vec3 border_left(scene.root()->scale_.x * -2.f, scene.root()->scale_.y * -1.f, 0.f); glm::vec3 border(2.f, 1.f, 0.f);
glm::vec3 border_right(scene.root()->scale_.x * 8.f, scene.root()->scale_.y * 8.f, 0.f); scene.root()->translation_ = glm::clamp(scene.root()->translation_, -border, border * 2.f);
scene.root()->translation_ = glm::clamp(scene.root()->translation_, border_left, border_right);
} }
int LayerView::size () int LayerView::size ()

View File

@@ -250,7 +250,8 @@ void MixingView::resize ( int scale )
scene.root()->scale_.y = z; scene.root()->scale_.y = z;
// Clamp translation to acceptable area // Clamp translation to acceptable area
glm::vec3 border(scene.root()->scale_.x * 1.f, scene.root()->scale_.y * 1.f, 0.f); glm::vec2 res = resolution();
glm::vec3 border(2.3f * res.x/res.y, 2.3f, 0.f);
scene.root()->translation_ = glm::clamp(scene.root()->translation_, -border, border); scene.root()->translation_ = glm::clamp(scene.root()->translation_, -border, border);
} }

View File

@@ -252,7 +252,7 @@ void TextureView::resize ( int scale )
scene.root()->scale_.y = z; scene.root()->scale_.y = z;
// Clamp translation to acceptable area // Clamp translation to acceptable area
glm::vec3 border(scene.root()->scale_.x * 1.5, scene.root()->scale_.y * 1.5, 0.f); glm::vec3 border(2.f * Mixer::manager().session()->frame()->aspectRatio(), 2.f, 0.f);
scene.root()->translation_ = glm::clamp(scene.root()->translation_, -border, border); scene.root()->translation_ = glm::clamp(scene.root()->translation_, -border, border);
} }

View File

@@ -287,3 +287,9 @@ void View::lock(Source *s, bool on)
Action::manager().store(s->name() + std::string(": unlock.")); Action::manager().store(s->name() + std::string(": unlock."));
} }
glm::vec2 View::resolution() const
{
const ImGuiIO& io = ImGui::GetIO();
return glm::vec2(io.DisplaySize.x, io.DisplaySize.y);
}

3
View.h
View File

@@ -88,6 +88,9 @@ public:
// left-right [-1 1] and up-down [1 -1] action from arrow keys // left-right [-1 1] and up-down [1 -1] action from arrow keys
virtual void arrow (glm::vec2) {} virtual void arrow (glm::vec2) {}
// resolution on screen
glm::vec2 resolution() const;
// accessible scene // accessible scene
Scene scene; Scene scene;

View File

@@ -40,7 +40,7 @@
#define GEOMETRY_MIN_SCALE 0.4f #define GEOMETRY_MIN_SCALE 0.4f
#define GEOMETRY_MAX_SCALE 7.0f #define GEOMETRY_MAX_SCALE 7.0f
#define LAYER_DEFAULT_SCALE 0.6f #define LAYER_DEFAULT_SCALE 0.6f
#define LAYER_MIN_SCALE 0.4f #define LAYER_MIN_SCALE 0.25f
#define LAYER_MAX_SCALE 1.7f #define LAYER_MAX_SCALE 1.7f
#define LAYER_PERSPECTIVE 2.0f #define LAYER_PERSPECTIVE 2.0f
#define LAYER_BACKGROUND 2.f #define LAYER_BACKGROUND 2.f