From 918acb6bc81a133e3da1174c2d9bcdc05647c56c Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 2 May 2016 12:25:51 -0300 Subject: [PATCH] Don't focus context bar when we use selection behavior modifiers (fix #1103) --- src/app/ui/button_set.cpp | 13 +++++++------ src/app/ui/button_set.h | 6 +++--- src/app/ui/context_bar.cpp | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/app/ui/button_set.cpp b/src/app/ui/button_set.cpp index 16f2d20b8..86e3c046f 100644 --- a/src/app/ui/button_set.cpp +++ b/src/app/ui/button_set.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2001-2015 David Capello +// Copyright (C) 2001-2016 David Capello // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -322,15 +322,15 @@ int ButtonSet::selectedItem() const return -1; } -void ButtonSet::setSelectedItem(int index) +void ButtonSet::setSelectedItem(int index, bool focusItem) { if (index >= 0 && index < (int)children().size()) - setSelectedItem(static_cast(at(index))); + setSelectedItem(static_cast(at(index)), focusItem); else - setSelectedItem(static_cast(NULL)); + setSelectedItem(static_cast(nullptr), focusItem); } -void ButtonSet::setSelectedItem(Item* item) +void ButtonSet::setSelectedItem(Item* item, bool focusItem) { if (!m_multipleSelection) { if (item && item->isSelected()) @@ -343,7 +343,8 @@ void ButtonSet::setSelectedItem(Item* item) if (item) { item->setSelected(!item->isSelected()); - item->requestFocus(); + if (focusItem) + item->requestFocus(); } } diff --git a/src/app/ui/button_set.h b/src/app/ui/button_set.h index 40f71534c..568c0191e 100644 --- a/src/app/ui/button_set.h +++ b/src/app/ui/button_set.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2001-2015 David Capello +// Copyright (C) 2001-2016 David Capello // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -44,8 +44,8 @@ namespace app { Item* getItem(int index); int selectedItem() const; - void setSelectedItem(int index); - void setSelectedItem(Item* item); + void setSelectedItem(int index, bool focusItem = true); + void setSelectedItem(Item* item, bool focusItem = true); void deselectItems(); void setOfferCapture(bool state); diff --git a/src/app/ui/context_bar.cpp b/src/app/ui/context_bar.cpp index 21e12724f..766574597 100644 --- a/src/app/ui/context_bar.cpp +++ b/src/app/ui/context_bar.cpp @@ -1112,7 +1112,7 @@ public: } void setSelectionMode(gen::SelectionMode mode) { - setSelectedItem((int)mode); + setSelectedItem((int)mode, false); invalidate(); }