Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Headers/AppKit/AppKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@
#import <AppKit/NSTouch.h>
#import <AppKit/NSTouchBar.h>
#import <AppKit/NSTouchBarItem.h>
#import <AppKit/GSTouchBarWindow.h>
#import <AppKit/NSScrubberTouchBarItem.h>
#import <AppKit/NSTokenField.h>
#import <AppKit/NSTokenFieldCell.h>
#import <AppKit/NSToolbar.h>
Expand Down
139 changes: 139 additions & 0 deletions Headers/AppKit/GSTouchBarWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/** <title>GSTouchBarWindow</title>

<abstract>Touch Bar fallback window class for systems without Touch Bar hardware</abstract>

GSTouchBarWindow provides a way to display NSTouchBar items in a regular
window on systems that don't have physical Touch Bar hardware, such as
Linux systems. This allows applications using Touch Bar APIs to still
function and provide their touch controls through a standard window interface.

The fallback window system provides:
* Automatic detection of Touch Bar hardware availability
* Graceful fallback to windowed display mode
* Proper layout and presentation of Touch Bar items
* Integration with the existing NSTouchBar API

Copyright (C) 2025 Free Software Foundation, Inc.

By: GNUstep Contributors
Date: Sep 30 2025

This file is part of the GNUstep Library.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/

#ifndef _GSTouchBarWindow_h_GNUSTEP_GUI_INCLUDE
#define _GSTouchBarWindow_h_GNUSTEP_GUI_INCLUDE
#import <AppKit/AppKitDefines.h>

#import <AppKit/NSWindow.h>

#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)

#if defined(__cplusplus)
extern "C" {
#endif

@class NSTouchBar;

/**
* GSTouchBarWindow displays NSTouchBar items in a regular window
* for systems without physical Touch Bar hardware.
*/
APPKIT_EXPORT_CLASS
@interface GSTouchBarWindow : NSWindow
{
NSTouchBar *_touchBar;
NSView *_itemContainerView;
NSMutableArray *_itemViews;
BOOL _autoHidesOnDeactivate;
}

/**
* The touch bar whose items are displayed in this window.
*/
- (NSTouchBar *) touchBar;
- (void) setTouchBar: (NSTouchBar *)touchBar;

/**
* Whether the window automatically hides when the application becomes inactive.
*/
- (BOOL) autoHidesOnDeactivate;
- (void) setAutoHidesOnDeactivate: (BOOL)autoHides;

/**
* Creates a new touch bar window for the specified touch bar.
*/
- (id) initWithTouchBar: (NSTouchBar *)touchBar;

/**
* Updates the window's content to reflect the current touch bar items.
*/
- (void) updateContent;

/**
* Positions the window appropriately relative to the main window.
*/
- (void) positionRelativeToMainWindow;

@end

/**
* GSTouchBarFallbackManager manages the fallback display system
* for Touch Bars on systems without hardware support.
*/
APPKIT_EXPORT_CLASS
@interface GSTouchBarFallbackManager : NSObject
{
NSMutableDictionary *_fallbackWindows;
BOOL _touchBarHardwareAvailable;
}

/**
* Returns the shared fallback manager instance.
*/
+ (GSTouchBarFallbackManager *) sharedManager;

/**
* Whether Touch Bar hardware is available on this system.
*/
- (BOOL) isTouchBarHardwareAvailable;

/**
* Shows a fallback window for the specified touch bar.
*/
- (void) showFallbackWindowForTouchBar: (NSTouchBar *)touchBar;

/**
* Hides the fallback window for the specified touch bar.
*/
- (void) hideFallbackWindowForTouchBar: (NSTouchBar *)touchBar;

/**
* Returns the fallback window for the specified touch bar, if any.
*/
- (GSTouchBarWindow *) fallbackWindowForTouchBar: (NSTouchBar *)touchBar;

@end

#if defined(__cplusplus)
}
#endif

#endif /* GS_API_MACOSX */

#endif /* _GSTouchBarWindow_h_GNUSTEP_GUI_INCLUDE */
22 changes: 22 additions & 0 deletions Headers/AppKit/NSScrubberItemView.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ APPKIT_EXPORT_CLASS

@end

/**
* NSScrubberTextItemView displays a text label in a scrubber item.
*/
APPKIT_EXPORT_CLASS
@interface NSScrubberTextItemView : NSScrubberItemView
{
NSTextField *_textField;
}

/**
* The title displayed by this text item view.
*/
- (NSString *) title;
- (void) setTitle: (NSString *)title;

/**
* The text field that displays the title.
*/
- (NSTextField *) textField;

@end

#if defined(__cplusplus)
}
#endif
Expand Down
74 changes: 74 additions & 0 deletions Headers/AppKit/NSScrubberTouchBarItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/** <title>NSScrubberTouchBarItem</title>

<abstract>Touch bar item that displays an NSScrubber control</abstract>

NSScrubberTouchBarItem is a specialized touch bar item that hosts
an NSScrubber control, allowing horizontal scrolling lists to be
displayed in the Touch Bar or fallback window.

Copyright (C) 2025 Free Software Foundation, Inc.

By: GNUstep Contributors
Date: Sep 30 2025

This file is part of the GNUstep Library.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
*/

#ifndef _NSScrubberTouchBarItem_h_GNUSTEP_GUI_INCLUDE
#define _NSScrubberTouchBarItem_h_GNUSTEP_GUI_INCLUDE
#import <AppKit/AppKitDefines.h>

#import <AppKit/NSTouchBarItem.h>

#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)

#if defined(__cplusplus)
extern "C" {
#endif

@class NSScrubber;

/**
* NSScrubberTouchBarItem is a touch bar item that displays an NSScrubber control.
*/
APPKIT_EXPORT_CLASS
@interface NSScrubberTouchBarItem : NSTouchBarItem
{
NSScrubber *_scrubber;
}

/**
* The scrubber control displayed by this item.
*/
- (NSScrubber *) scrubber;
- (void) setScrubber: (NSScrubber *)scrubber;

/**
* Creates a new scrubber touch bar item with the specified identifier.
*/
- (id) initWithIdentifier: (NSString *)identifier;

@end

#if defined(__cplusplus)
}
#endif

#endif /* GS_API_MACOSX */

#endif /* _NSScrubberTouchBarItem_h_GNUSTEP_GUI_INCLUDE */
97 changes: 96 additions & 1 deletion Headers/AppKit/NSTouchBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,110 @@
#import <AppKit/AppKitDefines.h>

#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>
#import <Foundation/NSArray.h>

#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)

#if defined(__cplusplus)
extern "C" {
#endif

@class NSTouchBarItem;
@class NSView;
@class NSWindow;

/**
* NSTouchBar manages a collection of touch bar items and their presentation.
* On systems without physical touch bar hardware, it can display items in
* a fallback window.
*/
APPKIT_EXPORT_CLASS
@interface NSTouchBar : NSObject
@interface NSTouchBar : NSObject <NSCoding>
{
NSString *_customizationIdentifier;
NSArray *_defaultItemIdentifiers;
NSArray *_itemIdentifiers;
NSString *_principalItemIdentifier;
id _delegate;
NSMutableDictionary *_items;
NSWindow *_fallbackWindow;
NSView *_fallbackContentView;
BOOL _isVisible;
BOOL _showsFallbackWindow;
}

/**
* A string that uniquely identifies the touch bar for customization purposes.
*/
- (NSString *) customizationIdentifier;
- (void) setCustomizationIdentifier: (NSString *)identifier;

/**
* An array of item identifiers that defines the default set of items.
*/
- (NSArray *) defaultItemIdentifiers;
- (void) setDefaultItemIdentifiers: (NSArray *)identifiers;

/**
* An array of item identifiers for the items currently in the touch bar.
*/
- (NSArray *) itemIdentifiers;
- (void) setItemIdentifiers: (NSArray *)identifiers;

/**
* The identifier of the principal item, which receives special treatment.
*/
- (NSString *) principalItemIdentifier;
- (void) setPrincipalItemIdentifier: (NSString *)identifier;

/**
* The delegate object that provides touch bar items.
*/
- (id) delegate;
- (void) setDelegate: (id)delegate;

/**
* Returns the touch bar item with the specified identifier.
*/
- (NSTouchBarItem *) itemForIdentifier: (NSString *)identifier;

/**
* Whether the touch bar is currently visible.
*/
- (BOOL) isVisible;

/**
* Shows or hides the touch bar fallback window on systems without hardware.
*/
- (void) setShowsFallbackWindow: (BOOL)shows;
- (BOOL) showsFallbackWindow;

/**
* Shows the fallback window containing touch bar items.
*/
- (void) showFallbackWindow;

/**
* Hides the fallback window.
*/
- (void) hideFallbackWindow;

@end

/**
* Informal protocol for NSTouchBar delegate methods.
* Delegates may implement these methods to provide items dynamically.
*/
@interface NSObject (NSTouchBarDelegate)

/**
* Returns the touch bar item for the specified identifier.
* This method will be called when the touch bar needs an item
* that is not already cached.
*/
- (NSTouchBarItem *) touchBar: (NSTouchBar *)touchBar
makeItemForIdentifier: (NSString *)identifier;

@end

Expand Down
Loading
Loading