mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-13 19:29:58 +01:00
Implement lock source mechanism in TextureView
This commit is contained in:
@@ -424,6 +424,7 @@ void Source::attach(FrameBuffer *renderbuffer)
|
|||||||
groups_[View::LAYER]->attach( locker_ );
|
groups_[View::LAYER]->attach( locker_ );
|
||||||
groups_[View::MIXING]->attach( locker_ );
|
groups_[View::MIXING]->attach( locker_ );
|
||||||
groups_[View::GEOMETRY]->attach( locker_ );
|
groups_[View::GEOMETRY]->attach( locker_ );
|
||||||
|
groups_[View::TEXTURE]->attach( locker_ );
|
||||||
|
|
||||||
// scale all icon nodes to match aspect ratio
|
// scale all icon nodes to match aspect ratio
|
||||||
for (int v = View::MIXING; v < View::INVALID; v++) {
|
for (int v = View::MIXING; v < View::INVALID; v++) {
|
||||||
|
|||||||
@@ -346,16 +346,16 @@ std::pair<Node *, glm::vec2> TextureView::pick(glm::vec2 P)
|
|||||||
if ( !pv.empty()) {
|
if ( !pv.empty()) {
|
||||||
// keep edit source active if it is clicked
|
// keep edit source active if it is clicked
|
||||||
// AND if the cursor is not for drawing
|
// AND if the cursor is not for drawing
|
||||||
Source *s = edit_source_;
|
Source *current = edit_source_;
|
||||||
if (s != nullptr) {
|
if (current != nullptr) {
|
||||||
|
|
||||||
// special case for drawing in the mask
|
// special case for drawing in the mask
|
||||||
if ( s->maskShader()->mode == MaskShader::PAINT && mask_cursor_paint_ > 0) {
|
if ( current->maskShader()->mode == MaskShader::PAINT && mask_cursor_paint_ > 0) {
|
||||||
pick = { mask_cursor_circle_, P };
|
pick = { mask_cursor_circle_, P };
|
||||||
return pick;
|
return pick;
|
||||||
}
|
}
|
||||||
// special case for cropping the mask shape
|
// special case for cropping the mask shape
|
||||||
else if ( s->maskShader()->mode == MaskShader::SHAPE && mask_cursor_shape_ > 0) {
|
else if ( current->maskShader()->mode == MaskShader::SHAPE && mask_cursor_shape_ > 0) {
|
||||||
pick = { mask_cursor_crop_, P };
|
pick = { mask_cursor_crop_, P };
|
||||||
return pick;
|
return pick;
|
||||||
}
|
}
|
||||||
@@ -365,24 +365,33 @@ std::pair<Node *, glm::vec2> TextureView::pick(glm::vec2 P)
|
|||||||
for (; itp != pv.rend(); itp++){
|
for (; itp != pv.rend(); itp++){
|
||||||
// test if source contains this node
|
// test if source contains this node
|
||||||
Source::hasNode is_in_source( (*itp).first );
|
Source::hasNode is_in_source( (*itp).first );
|
||||||
if ( is_in_source( s ) ){
|
if ( is_in_source( current ) ){
|
||||||
// a node in the current source was clicked !
|
// a node in the current source was clicked !
|
||||||
pick = *itp;
|
pick = *itp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// not found: the edit source was not clicked
|
// not found: the edit source was not clicked
|
||||||
if ( itp == pv.rend() )
|
if ( itp == pv.rend() ) {
|
||||||
s = nullptr;
|
current = nullptr;
|
||||||
|
}
|
||||||
// picking on the menu handle
|
// picking on the menu handle
|
||||||
else if ( pick.first == s->handles_[mode_][Handles::MENU] ) {
|
else if ( pick.first == current->handles_[mode_][Handles::MENU] ) {
|
||||||
// show context menu
|
// show context menu
|
||||||
openContextMenu(MENU_SOURCE);
|
openContextMenu(MENU_SOURCE);
|
||||||
}
|
}
|
||||||
|
// pick on the lock icon; unlock source
|
||||||
|
else if ( pick.first == current->lock_ ) {
|
||||||
|
lock(current, false);
|
||||||
|
}
|
||||||
|
// pick on the open lock icon; lock source and cancel pick
|
||||||
|
else if ( pick.first == current->unlock_ ) {
|
||||||
|
lock(current, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// not the edit source (or no edit source)
|
// not the edit source (or no edit source)
|
||||||
if (s == nullptr) {
|
if (current == nullptr) {
|
||||||
// cancel pick
|
// cancel pick
|
||||||
pick = { nullptr, glm::vec2(0.f) };
|
pick = { nullptr, glm::vec2(0.f) };
|
||||||
}
|
}
|
||||||
@@ -526,7 +535,7 @@ void TextureView::draw()
|
|||||||
if (edit_source_ != nullptr){
|
if (edit_source_ != nullptr){
|
||||||
|
|
||||||
// force to redraw the frame of the edit source (even if source is not visible)
|
// force to redraw the frame of the edit source (even if source is not visible)
|
||||||
DrawVisitor dv(edit_source_->frames_[mode_], Rendering::manager().Projection(), true);
|
DrawVisitor dv(edit_source_->groups_[mode_], Rendering::manager().Projection(), true);
|
||||||
scene.accept(dv);
|
scene.accept(dv);
|
||||||
|
|
||||||
// display interface
|
// display interface
|
||||||
@@ -887,7 +896,7 @@ View::Cursor TextureView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pa
|
|||||||
glm::vec3 scene_translation = scene_to - scene_from;
|
glm::vec3 scene_translation = scene_to - scene_from;
|
||||||
|
|
||||||
// Not grabbing a source
|
// Not grabbing a source
|
||||||
if (!s) {
|
if (!s || s->locked()) {
|
||||||
// work on the edited source
|
// work on the edited source
|
||||||
if ( edit_source_ != nullptr ) {
|
if ( edit_source_ != nullptr ) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user