openshot-audio  0.1.2
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) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_DESKTOP_H_INCLUDED
26 #define JUCE_DESKTOP_H_INCLUDED
27 
28 
29 //==============================================================================
37 {
38 public:
40  virtual ~FocusChangeListener() {}
41 
43  virtual void globalFocusChanged (Component* focusedComponent) = 0;
44 };
45 
46 
47 //==============================================================================
53  private Timer,
54  private AsyncUpdater
55 {
56 public:
57  //==============================================================================
59  static Desktop& JUCE_CALLTYPE getInstance();
60 
61  //==============================================================================
70  static Point<int> getMousePosition();
71 
75  static void setMousePosition (Point<int> newPosition);
76 
84  static Point<int> getLastMouseDownPosition();
85 
90  int getMouseButtonClickCounter() const noexcept;
91 
96  int getMouseWheelMoveCounter() const noexcept;
97 
98  //==============================================================================
113  static void setScreenSaverEnabled (bool isEnabled);
114 
123  static bool isScreenSaverEnabled();
124 
125  //==============================================================================
131  void addGlobalMouseListener (MouseListener* listener);
132 
138  void removeGlobalMouseListener (MouseListener* listener);
139 
140  //==============================================================================
144  void addFocusChangeListener (FocusChangeListener* listener);
145 
147  void removeFocusChangeListener (FocusChangeListener* listener);
148 
149  //==============================================================================
164  void setKioskModeComponent (Component* componentToUse,
165  bool allowMenusAndBars = true);
166 
172  Component* getKioskModeComponent() const noexcept { return kioskModeComponent; }
173 
174  //==============================================================================
180  int getNumComponents() const noexcept;
181 
189  Component* getComponent (int index) const noexcept;
190 
198  Component* findComponentAt (Point<int> screenPosition) const;
199 
209  ComponentAnimator& getAnimator() noexcept { return animator; }
210 
211  //==============================================================================
216  LookAndFeel& getDefaultLookAndFeel() noexcept;
217 
225  void setDefaultLookAndFeel (LookAndFeel* newDefaultLookAndFeel);
226 
227  //==============================================================================
234  const Array<MouseInputSource>& getMouseSources() const noexcept;
235 
243  int getNumMouseSources() const noexcept;
244 
251  MouseInputSource* getMouseSource (int index) const noexcept;
252 
256  MouseInputSource getMainMouseSource() const noexcept;
257 
263  int getNumDraggingMouseSources() const noexcept;
264 
269  MouseInputSource* getDraggingMouseSource (int index) const noexcept;
270 
286  void beginDragAutoRepeat (int millisecondsBetweenCallbacks);
287 
288  //==============================================================================
291  {
292  upright = 1,
293  upsideDown = 2,
294  rotatedClockwise = 4,
295  rotatedAntiClockwise = 8,
297  allOrientations = 1 + 2 + 4 + 8
298  };
299 
301  DisplayOrientation getCurrentOrientation() const;
302 
310  void setOrientationsEnabled (int allowedOrientations);
311 
315  bool isOrientationEnabled (DisplayOrientation orientation) const noexcept;
316 
317  //==============================================================================
319  {
320  public:
322  struct Display
323  {
327 
330 
336  double scale;
337 
342  double dpi;
343 
345  bool isMain;
346  };
347 
349  const Display& getMainDisplay() const noexcept;
350 
354  const Display& getDisplayContaining (Point<int> position) const noexcept;
355 
357  RectangleList<int> getRectangleList (bool userAreasOnly) const;
358 
360  Rectangle<int> getTotalBounds (bool userAreasOnly) const;
361 
363  Array<Display> displays;
364 
365  #ifndef DOXYGEN
366 
367  void refresh();
368  #endif
369 
370  private:
371  friend class Desktop;
373  Displays (Desktop&);
374  ~Displays();
375 
376  void init (Desktop&);
377  void findDisplays (float masterScale);
378  };
379 
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 private:
398  //==============================================================================
399  static Desktop* instance;
400 
401  friend class Component;
402  friend class ComponentPeer;
404  friend class DeletedAtShutdown;
405  friend class TopLevelWindowManager;
406 
408 
409  ListenerList<MouseListener> mouseListeners;
410  ListenerList<FocusChangeListener> focusListeners;
411 
412  Array<Component*> desktopComponents;
413  Array<ComponentPeer*> peers;
414 
415  ScopedPointer<Displays> displays;
416 
417  Point<float> lastFakeMouseMove;
418  void sendMouseMove();
419 
420  int mouseClickCounter, mouseWheelCounter;
421  void incrementMouseClickCounter() noexcept;
422  void incrementMouseWheelCounter() noexcept;
423 
424  ScopedPointer<LookAndFeel> defaultLookAndFeel;
425  WeakReference<LookAndFeel> currentLookAndFeel;
426 
427  Component* kioskModeComponent;
428  Rectangle<int> kioskComponentOriginalBounds;
429  bool kioskModeReentrant;
430 
431  int allowedOrientations;
432  float masterScaleFactor;
433 
434  ComponentAnimator animator;
435 
436  void timerCallback() override;
437  void resetTimer();
438  ListenerList<MouseListener>& getMouseListeners();
439 
440  void addDesktopComponent (Component*);
441  void removeDesktopComponent (Component*);
442  void componentBroughtToFront (Component*);
443 
444  void setKioskComponent (Component*, bool shouldBeEnabled, bool allowMenusAndBars);
445 
446  void triggerFocusCallback();
447  void handleAsyncUpdate() override;
448 
449  static Point<float> getMousePositionFloat();
450 
451  static double getDefaultMasterScale();
452 
453  Desktop();
454  ~Desktop();
455 
457 };
458 
459 
460 #endif // JUCE_DESKTOP_H_INCLUDED
const Displays & getDisplays() const noexcept
Definition: juce_Desktop.h:380
#define noexcept
Definition: juce_CompilerSupport.h:141
Definition: juce_Desktop.h:36
#define override
Definition: juce_CompilerSupport.h:156
Definition: juce_RectangleList.h:40
float getGlobalScaleFactor() const noexcept
Definition: juce_Desktop.h:391
Definition: juce_DeletedAtShutdown.h:40
Definition: juce_LookAndFeel.h:74
bool isMain
Definition: juce_Desktop.h:345
#define JUCE_CALLTYPE
Definition: juce_PlatformDefs.h:50
Definition: juce_Desktop.h:52
Definition: juce_Point.h:39
ComponentAnimator & getAnimator() noexcept
Definition: juce_Desktop.h:209
#define JUCE_API
Definition: juce_StandardHeader.h:139
#define const
DisplayOrientation
Definition: juce_Desktop.h:290
Definition: juce_AsyncUpdater.h:39
Definition: juce_TopLevelWindow.cpp:26
Definition: juce_Desktop.h:318
Definition: juce_ComponentAnimator.h:50
Definition: juce_Rectangle.h:36
double dpi
Definition: juce_Desktop.h:342
Definition: juce_Desktop.h:322
Definition: juce_Component.h:33
Definition: juce_MouseListener.h:36
Definition: juce_MouseInputSource.h:49
Definition: juce_WeakReference.h:82
Definition: juce_MouseInputSource.cpp:25
Definition: juce_ContainerDeletePolicy.h:44
virtual ~FocusChangeListener()
Definition: juce_Desktop.h:40
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
double scale
Definition: juce_Desktop.h:336
Rectangle< int > userArea
Definition: juce_Desktop.h:326
Definition: juce_Timer.h:52
Rectangle< int > totalArea
Definition: juce_Desktop.h:329
Definition: juce_ComponentPeer.h:41
Component * getKioskModeComponent() const noexcept
Definition: juce_Desktop.h:172