KiCad PCB EDA Suite
selection_tool.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2021 KiCad Developers, see AUTHORS.TXT for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/gpl-3.0.html
19  * or you may search the http://www.gnu.org website for the version 3 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #include <tool/selection_tool.h>
25 
26 
28  m_additive( false ),
29  m_subtractive( false ),
30  m_exclusive_or( false ),
31  m_multiple( false ),
32  m_skip_heuristics( false ),
33  m_highlight_modifier( false ),
34  m_drag_additive( false ),
35  m_drag_subtractive( false ),
36  m_canceledMenu( false )
37 {
38 }
39 
40 void SELECTION_TOOL::setModifiersState( bool aShiftState, bool aCtrlState, bool aAltState )
41 {
42  // Set the configuration of m_additive, m_subtractive, m_exclusive_or from the state of
43  // modifier keys SHIFT and CTRL
44 
45  // ALT key cannot be used on MSW because of a conflict with the system menu
46 
47  m_subtractive = aCtrlState && aShiftState;
48  m_additive = !aCtrlState && aShiftState;
49  m_exclusive_or = false;
50  m_highlight_modifier = aCtrlState && !aShiftState;
51 
52  // Drag is more forgiving and allows either Ctrl+Drag or Shift+Drag to add to the selection
53  // Note, however that we cannot provide disambiguation at the same time as the box selection
54  m_drag_additive = ( aCtrlState || aShiftState ) && !aAltState;
55  m_drag_subtractive = aCtrlState && aShiftState && !aAltState;
56 
57  // While the ALT key has some conflicts under MSW (and some flavors of Linux WMs), it remains
58  // useful for users who only use tap-click rather than holding the button. We disable it for
59  // windows because it flashes the disambiguation menu without showing data
60 #ifndef __WINDOWS__
61  m_skip_heuristics = aAltState;
62 #else
63  m_skip_heuristics = false;
64 #endif
65 
66 }
bool m_highlight_modifier
void setModifiersState(bool aShiftState, bool aCtrlState, bool aAltState)
Set the configuration of m_additive, m_subtractive, m_exclusive_or, m_skip_heuristics from the state ...