@@ -2,6 +2,7 @@ import 'dart:async';
22
33import 'package:flutter/services.dart' ;
44import 'package:macos_window_utils/macos/ns_visual_effect_view_state.dart' ;
5+ import 'package:macos_window_utils/macos/ns_window_level.dart' ;
56import 'package:macos_window_utils/macos/ns_window_toolbar_style.dart' ;
67import 'package:macos_window_utils/macos/visual_effect_view_properties.dart' ;
78import 'package:macos_window_utils/macos/ns_visual_effect_view_material.dart' ;
@@ -458,4 +459,58 @@ class WindowManipulator {
458459 'subtitle' : subtitle,
459460 });
460461 }
462+
463+ /// Sets the level of the window.
464+ ///
465+ /// Each level in the list groups windows within it in front of those in all
466+ /// preceding groups. Floating windows, for example, appear in front of all
467+ /// normal-level windows. When a window enters a new level, it’s ordered in
468+ /// front of all its peers in that level.
469+ ///
470+ /// Usage examples:
471+ ///
472+ /// ```dart
473+ /// // Set the window to appear in front of all normal-level windows:
474+ /// WindowManipulator.setLevel(NSWindowLevel.floating);
475+ ///
476+ /// // Set the window to appear behind all normal-level windows:
477+ /// WindowManipulator.setLevel(NSWindowLevel.normal.withOffset(-1));
478+ ///
479+ /// // Reset the window's level to the default value:
480+ /// WindowManipulator.setLevel(NSWindowLevel.normal);
481+ /// ```
482+ static Future <void > setLevel (NSWindowLevel level) async {
483+ await _completer.future;
484+ await _methodChannel.invokeMethod ('setLevel' , {
485+ 'base' : level.baseName,
486+ 'offset' : level.offset,
487+ });
488+ }
489+
490+ /// Removes the window from the screen list, which hides the window.
491+ static Future <void > orderOut () async {
492+ await _completer.future;
493+ await _methodChannel.invokeMethod ('orderOut' );
494+ }
495+
496+ /// Moves the window to the back of its level in the screen list, without
497+ /// changing either the key window or the main window.
498+ static Future <void > orderBack () async {
499+ await _completer.future;
500+ await _methodChannel.invokeMethod ('orderBack' );
501+ }
502+
503+ /// Moves the window to the front of its level in the screen list, without
504+ /// changing either the key window or the main window.
505+ static Future <void > orderFront () async {
506+ await _completer.future;
507+ await _methodChannel.invokeMethod ('orderFront' );
508+ }
509+
510+ /// Moves the window to the front of its level, even if its application isn't
511+ /// active, without changing either the key window or the main window.
512+ static Future <void > orderFrontRegardless () async {
513+ await _completer.future;
514+ await _methodChannel.invokeMethod ('orderFrontRegardless' );
515+ }
461516}
0 commit comments