Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / widget / cocoa / nsTouchBarInput.h
blob41ed7979a4fdbd2ab686aa5569c9258c63adbad1
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsTouchBarInput_h_
6 #define nsTouchBarInput_h_
8 #import <Cocoa/Cocoa.h>
10 #include "nsITouchBarInput.h"
11 #include "nsCOMPtr.h"
13 using namespace mozilla::dom;
15 enum class TouchBarInputBaseType : uint8_t {
16 kButton,
17 kLabel,
18 kMainButton,
19 kPopover,
20 kScrollView,
21 kScrubber
24 class nsTouchBarInputIcon;
26 /**
27 * NSObject representation of nsITouchBarInput.
29 @interface TouchBarInput : NSObject {
30 nsCOMPtr<nsIURI> mImageURI;
31 RefPtr<nsTouchBarInputIcon> mIcon;
32 TouchBarInputBaseType mBaseType;
33 NSString* mType;
34 nsCOMPtr<nsITouchBarInputCallback> mCallback;
35 NSMutableArray<TouchBarInput*>* mChildren;
38 @property(strong) NSString* key;
39 @property(strong) NSString* type;
40 @property(strong) NSString* title;
41 @property(strong) NSColor* color;
42 @property(nonatomic, getter=isDisabled) BOOL disabled;
44 - (nsCOMPtr<nsIURI>)imageURI;
45 - (RefPtr<nsTouchBarInputIcon>)icon;
46 - (TouchBarInputBaseType)baseType;
47 - (NSTouchBarItemIdentifier)nativeIdentifier;
48 - (nsCOMPtr<nsITouchBarInputCallback>)callback;
49 - (NSMutableArray<TouchBarInput*>*)children;
50 - (void)setImageURI:(nsCOMPtr<nsIURI>)aImageURI;
51 - (void)setIcon:(RefPtr<nsTouchBarInputIcon>)aIcon;
52 - (void)setCallback:(nsCOMPtr<nsITouchBarInputCallback>)aCallback;
53 - (void)setChildren:(NSMutableArray<TouchBarInput*>*)aChildren;
55 - (id)initWithKey:(NSString*)aKey
56 title:(NSString*)aTitle
57 imageURI:(nsCOMPtr<nsIURI>)aImageURI
58 type:(NSString*)aType
59 callback:(nsCOMPtr<nsITouchBarInputCallback>)aCallback
60 color:(uint32_t)aColor
61 disabled:(BOOL)aDisabled
62 children:(nsCOMPtr<nsIArray>)aChildren;
64 - (TouchBarInput*)initWithXPCOM:(nsCOMPtr<nsITouchBarInput>)aInput;
66 - (void)releaseJSObjects;
68 - (void)dealloc;
70 /**
71 * We make these helper methods static so that other classes can query a
72 * TouchBarInput's nativeIdentifier (e.g. nsTouchBarUpdater looking up a
73 * popover in mappedLayoutItems).
75 + (NSTouchBarItemIdentifier)nativeIdentifierWithType:(NSString*)aType
76 withKey:(NSString*)aKey;
77 + (NSTouchBarItemIdentifier)nativeIdentifierWithXPCOM:
78 (nsCOMPtr<nsITouchBarInput>)aInput;
80 // Non-JS scrubber implemention for the Share Scrubber,
81 // since it is defined by an Apple API.
82 + (NSTouchBarItemIdentifier)shareScrubberIdentifier;
84 // The search popover needs to show/hide depending on if the Urlbar is focused
85 // when it is created. We keep track of its identifier to accommodate this
86 // special handling.
87 + (NSTouchBarItemIdentifier)searchPopoverIdentifier;
89 @end
91 #endif // nsTouchBarInput_h_