KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_gal_cursor.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 The 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 2
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, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <boost/test/unit_test.hpp>
21
25
26
27class TEST_GAL : public KIGFX::GAL
28{
29public:
31 GAL( aOptions )
32 {
33 }
34
35 void ForceDisplayCursor( bool aEnabled ) { m_forceDisplayCursor = aEnabled; }
36};
37
38
40{
41public:
43
45
46 bool IsCursorInCanvas() const override { return m_inCanvas; }
47
48 void HideCursorInCanvas() override { m_inCanvas = false; }
49
50 void Enter() { m_inCanvas = true; }
51
52private:
53 bool m_inCanvas = false;
54};
55
56
57BOOST_AUTO_TEST_SUITE( GalCursor )
58
59
60BOOST_AUTO_TEST_CASE( HiddenOutsideCanvas )
61{
63 TEST_GAL gal( options );
64
65 gal.SetCursorEnabled( true );
67
68 gal.SetCursorInCanvas( true );
70
71 gal.SetCursorInCanvas( false );
73
74 gal.SetCursorEnabled( false );
75 gal.ForceDisplayCursor( true );
77
78 gal.SetCursorInCanvas( true );
80}
81
82
83BOOST_AUTO_TEST_CASE( EnterHidesEveryOtherLiveOwner )
84{
86 TEST_CURSOR_OWNER entering;
87
88 first.Enter();
89
90 {
91 TEST_CURSOR_OWNER destroyed;
92 destroyed.Enter();
93 }
94
95 entering.Enter();
97
98 BOOST_CHECK( !first.IsCursorInCanvas() );
99 BOOST_CHECK( entering.IsCursorInCanvas() );
100}
101
102
void Unregister(EDA_CURSOR_OWNER *aOwner)
static EDA_CURSOR_BROADCASTER & Instance()
void NotifyCursorEntered(EDA_CURSOR_OWNER *aEnteredOwner)
Hide the cursor in every registered owner other than aEnteredOwner.
void Register(EDA_CURSOR_OWNER *aOwner)
Interface implemented by a GAL canvas that wants to participate in cross-window cursor ownership broa...
Abstract interface for drawing on a 2D-surface.
bool IsCursorEnabled() const
Return information about cursor visibility.
void SetCursorEnabled(bool aCursorEnabled)
Enable/disable cursor.
void SetCursorInCanvas(bool aCursorInCanvas)
Set whether the cursor is inside the drawing canvas.
GAL(GAL_DISPLAY_OPTIONS &aOptions)
bool m_forceDisplayCursor
Always show cursor.
~TEST_CURSOR_OWNER() override
bool IsCursorInCanvas() const override
void HideCursorInCanvas() override
Give up canvas ownership, because the pointer has been shown to be somewhere else.
void ForceDisplayCursor(bool aEnabled)
TEST_GAL(KIGFX::GAL_DISPLAY_OPTIONS &aOptions)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_CHECK(res.column_datatype(0)==SQL_NUMERIC||res.column_datatype(0)==SQL_DECIMAL)
BOOST_AUTO_TEST_CASE(HiddenOutsideCanvas)
BOOST_AUTO_TEST_SUITE_END()