Draw transformation handles only in active editor (fix #82, fix #632)

This commit is contained in:
David Capello 2015-04-27 10:08:48 -03:00
parent 3810cfc1fa
commit ceb469339d
4 changed files with 14 additions and 4 deletions

View File

@ -18,6 +18,7 @@
#include "app/commands/params.h"
#include "app/console.h"
#include "app/ini_file.h"
#include "app/modules/editors.h"
#include "app/modules/gfx.h"
#include "app/modules/gui.h"
#include "app/modules/palettes.h"
@ -190,6 +191,11 @@ Editor::~Editor()
m_mask_timer.stop();
}
bool Editor::isActive() const
{
return (current_editor == this);
}
WidgetType editor_type()
{
static WidgetType type = kGenericWidget;

View File

@ -81,6 +81,8 @@ namespace app {
Editor(Document* document, EditorFlags flags = kDefaultEditorFlags);
~Editor();
bool isActive() const;
DocumentView* getDocumentView() { return m_docView; }
void setDocumentView(DocumentView* docView) { m_docView = docView; }

View File

@ -67,7 +67,7 @@ void EditorView::onPaint(PaintEvent& ev)
// Only show the view selected if it is the current editor
case CurrentEditorMode:
selected = (editor() == current_editor);
selected = (editor()->isActive());
break;
// Always show selected

View File

@ -206,7 +206,7 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
if (clickedInk->isSelection()) {
// Transform selected pixels
if (document->isMaskVisible() && m_decorator->getTransformHandles(editor)) {
if (editor->isActive() && document->isMaskVisible() && m_decorator->getTransformHandles(editor)) {
TransformHandles* transfHandles = m_decorator->getTransformHandles(editor);
// Get the handle covered by the mouse.
@ -485,7 +485,8 @@ TransformHandles* StandbyState::Decorator::getTransformHandles(Editor* editor)
bool StandbyState::Decorator::onSetCursor(Editor* editor)
{
if (!editor->document()->isMaskVisible())
if (!editor->isActive() ||
!editor->document()->isMaskVisible())
return false;
const gfx::Transformation transformation(m_standbyState->getTransformation(editor));
@ -559,7 +560,8 @@ void StandbyState::Decorator::postRenderDecorator(EditorPostRender* render)
Editor* editor = render->getEditor();
// Draw transformation handles (if the mask is visible and isn't frozen).
if (editor->editorFlags() & Editor::kShowMask &&
if (editor->isActive() &&
editor->editorFlags() & Editor::kShowMask &&
editor->document()->isMaskVisible() &&
!editor->document()->mask()->isFrozen()) {
// And draw only when the user has a selection tool as active tool.