JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_Desktop.h
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
38class JUCE_API FocusChangeListener
39{
40public:
42 virtual ~FocusChangeListener() = default;
43
45 virtual void globalFocusChanged (Component* focusedComponent) = 0;
46};
47
48//==============================================================================
60{
61public:
63 virtual ~DarkModeSettingListener() = default;
64
66 virtual void darkModeSettingChanged() = 0;
67};
68
69//==============================================================================
75class JUCE_API Desktop : private DeletedAtShutdown,
76 private Timer,
77 private AsyncUpdater
78{
79public:
80 //==============================================================================
82 static Desktop& JUCE_CALLTYPE getInstance();
83
84 //==============================================================================
93 static Point<int> getMousePosition();
94
100 static void setMousePosition (Point<int> newPosition);
101
109 static Point<int> getLastMouseDownPosition();
110
115 int getMouseButtonClickCounter() const noexcept;
116
121 int getMouseWheelMoveCounter() const noexcept;
122
123 //==============================================================================
138 static void setScreenSaverEnabled (bool isEnabled);
139
148 static bool isScreenSaverEnabled();
149
150 //==============================================================================
156 void addGlobalMouseListener (MouseListener* listener);
157
162 void removeGlobalMouseListener (MouseListener* listener);
163
164 //==============================================================================
170 void addFocusChangeListener (FocusChangeListener* listener);
171
176 void removeFocusChangeListener (FocusChangeListener* listener);
177
178 //==============================================================================
185 void addDarkModeSettingListener (DarkModeSettingListener* listener);
186
191 void removeDarkModeSettingListener (DarkModeSettingListener* listener);
192
200 bool isDarkModeActive() const;
201
202 //==============================================================================
217 void setKioskModeComponent (Component* componentToUse,
218 bool allowMenusAndBars = true);
219
225 Component* getKioskModeComponent() const noexcept { return kioskModeComponent; }
226
227 //==============================================================================
233 int getNumComponents() const noexcept;
234
242 Component* getComponent (int index) const noexcept;
243
251 Component* findComponentAt (Point<int> screenPosition) const;
252
262 ComponentAnimator& getAnimator() noexcept { return animator; }
263
264 //==============================================================================
269 LookAndFeel& getDefaultLookAndFeel() noexcept;
270
278 void setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel);
279
280 //==============================================================================
287 const Array<MouseInputSource>& getMouseSources() const noexcept;
288
296 int getNumMouseSources() const noexcept;
297
304 MouseInputSource* getMouseSource (int index) const noexcept;
305
309 MouseInputSource getMainMouseSource() const noexcept;
310
316 int getNumDraggingMouseSources() const noexcept;
317
322 MouseInputSource* getDraggingMouseSource (int index) const noexcept;
323
339 void beginDragAutoRepeat (int millisecondsBetweenCallbacks);
340
341 //==============================================================================
344 {
345 upright = 1,
346 upsideDown = 2,
347 rotatedClockwise = 4,
348 rotatedAntiClockwise = 8,
350 allOrientations = 1 + 2 + 4 + 8
351 };
352
354 DisplayOrientation getCurrentOrientation() const;
355
363 void setOrientationsEnabled (int allowedOrientations);
364
368 int getOrientationsEnabled() const noexcept;
369
373 bool isOrientationEnabled (DisplayOrientation orientation) const noexcept;
374
375 //==============================================================================
380 const Displays& getDisplays() const noexcept { return *displays; }
381
382 //==============================================================================
386 void setGlobalScaleFactor (float newScaleFactor) noexcept;
387
391 float getGlobalScaleFactor() const noexcept { return masterScaleFactor; }
392
393 //==============================================================================
395 static bool canUseSemiTransparentWindows() noexcept;
396
397 #if JUCE_MAC && ! defined (DOXYGEN)
398 [[deprecated ("This macOS-specific method has been deprecated in favour of the cross-platform "
399 " isDarkModeActive() method.")]]
400 static bool isOSXDarkModeActive() { return Desktop::getInstance().isDarkModeActive(); }
401 #endif
402
403 //==============================================================================
405 bool isHeadless() const noexcept;
406
407private:
408 //==============================================================================
409 static Desktop* instance;
410
411 friend class Component;
412 friend class ComponentPeer;
413 friend class detail::MouseInputSourceImpl;
414 friend class DeletedAtShutdown;
415 friend class detail::TopLevelWindowManager;
416 friend class Displays;
417
418 std::unique_ptr<detail::MouseInputSourceList> mouseSources;
419
420 ListenerList<MouseListener> mouseListeners;
421 ListenerList<FocusChangeListener> focusListeners;
422 ListenerList<DarkModeSettingListener> darkModeSettingListeners;
423
424 Array<Component*> desktopComponents;
425 Array<ComponentPeer*> peers;
426
427 std::unique_ptr<Displays> displays;
428
429 Point<float> lastFakeMouseMove;
430 void sendMouseMove();
431
432 int mouseClickCounter = 0, mouseWheelCounter = 0;
433 void incrementMouseClickCounter() noexcept;
434 void incrementMouseWheelCounter() noexcept;
435
436 std::unique_ptr<LookAndFeel> defaultLookAndFeel;
437 WeakReference<LookAndFeel> currentLookAndFeel;
438
439 std::unique_ptr<FocusOutline> focusOutline;
440
441 Component* kioskModeComponent = nullptr;
442 Rectangle<int> kioskComponentOriginalBounds;
443 bool kioskModeReentrant = false;
444
445 int allowedOrientations = allOrientations;
446 void allowedOrientationsChanged();
447
448 float masterScaleFactor;
449
450 ComponentAnimator animator;
451
452 void timerCallback() override;
453 void resetTimer();
454 ListenerList<MouseListener>& getMouseListeners();
455
456 void addDesktopComponent (Component*);
457 void removeDesktopComponent (Component*);
458 void componentBroughtToFront (Component*);
459
460 void setKioskComponent (Component*, bool shouldBeEnabled, bool allowMenusAndBars);
461
462 void triggerFocusCallback();
463 void updateFocusOutline();
464 void handleAsyncUpdate() override;
465
466 static Point<float> getMousePositionFloat();
467
468 static double getDefaultMasterScale();
469
470 Desktop();
471 ~Desktop() override;
472
473 //==============================================================================
474 class NativeDarkModeChangeDetectorImpl;
475 std::unique_ptr<NativeDarkModeChangeDetectorImpl> nativeDarkModeChangeDetectorImpl;
476
477 static std::unique_ptr<NativeDarkModeChangeDetectorImpl> createNativeDarkModeChangeDetectorImpl();
478 void darkModeChanged();
479
480 //==============================================================================
482};
483
484} // namespace juce
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:56
Has a callback method that is triggered asynchronously.
Animates a set of components, moving them to a new position and/or fading their alpha levels.
The base class for all JUCE user-interface objects.
Classes can implement this interface and register themselves with the Desktop class to receive callba...
virtual ~DarkModeSettingListener()=default
Destructor.
virtual void darkModeSettingChanged()=0
Callback to indicate that the dark mode setting has changed.
Classes derived from this will be automatically deleted when the application exits.
Describes and controls aspects of the computer's desktop.
DisplayOrientation
In a tablet/mobile device which can be turned around, this is used to indicate the orientation.
float getGlobalScaleFactor() const noexcept
Returns the current global scale factor, as set by setGlobalScaleFactor().
Component * getKioskModeComponent() const noexcept
Returns the component that is currently being used in kiosk-mode.
Manages details about connected display devices.
Classes can implement this interface and register themselves with the Desktop class to receive callba...
virtual void globalFocusChanged(Component *focusedComponent)=0
Callback to indicate that the currently focused component has changed.
virtual ~FocusChangeListener()=default
Destructor.
LookAndFeel objects define the appearance of all the JUCE widgets, and subclasses can be used to appl...
Represents a linear source of mouse events from a mouse device or individual finger in a multi-touch ...
A MouseListener can be registered with a component to receive callbacks about mouse events that happe...
A pair of (x, y) coordinates.
Definition juce_Point.h:42
Makes repeated callbacks to a virtual method at a specified time interval.
Definition juce_Timer.h:52
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
#define JUCE_CALLTYPE
This macro defines the C calling convention used as the standard for JUCE calls.
JUCE Namespace.