#import <GlyphsKit/GSFlowView.h>

NS_ASSUME_NONNULL_BEGIN

/// A flow-layout segmented control that wraps across multiple lines when the
/// available width is exhausted. The API closely mirrors NSSegmentedControl.
///
/// Set `segmentCount`, then configure each segment with `setLabel:forSegment:`,
/// `setImage:forSegment:`, etc. Attach a target/action to be notified when
/// selection changes.
///
/// All GSFlowView layout properties (spacing, insets, alignment) apply.
IB_DESIGNABLE
@interface GSFlowSegmentedControl : GSFlowView

// ---------------------------------------------------------------------------
#pragma mark Segments
// ---------------------------------------------------------------------------

/// Number of segments. Increasing this appends new (empty) segments; decreasing
/// it removes segments from the trailing end.
@property (nonatomic, assign) IBInspectable NSInteger segmentCount;

// ---------------------------------------------------------------------------
#pragma mark Selection
// ---------------------------------------------------------------------------

/// The index of the selected segment, or –1 if no segment is selected.
/// In `NSSegmentSwitchTrackingSelectAny` mode, reflects the most recently
/// toggled segment. Setting this programmatically does not fire the action.
@property (nonatomic, assign) NSInteger selectedSegment;

/// Controls how segments respond to clicks. Default: `NSSegmentSwitchTrackingSelectOne`.
@property (nonatomic, assign) NSSegmentSwitchTracking trackingMode;

/// Selects or deselects a specific segment without firing the action.
/// In `SelectOne` mode, selecting a segment deselects all others.
- (void)setSelected:(BOOL)selected forSegment:(NSInteger)segment;
- (BOOL)isSelectedForSegment:(NSInteger)segment;

// ---------------------------------------------------------------------------
#pragma mark Per-segment configuration
// ---------------------------------------------------------------------------

- (void)setLabel:(nullable NSString *)label forSegment:(NSInteger)segment;
- (nullable NSString *)labelForSegment:(NSInteger)segment;

- (void)setImage:(nullable NSImage *)image forSegment:(NSInteger)segment;
- (nullable NSImage *)imageForSegment:(NSInteger)segment;

- (void)setEnabled:(BOOL)enabled forSegment:(NSInteger)segment;
- (BOOL)isEnabledForSegment:(NSInteger)segment;

/// Fixed pixel width for the segment. Pass 0 to let the segment size itself to
/// fit its content (the default).
- (void)setWidth:(CGFloat)width forSegment:(NSInteger)segment;
- (CGFloat)widthForSegment:(NSInteger)segment;

// ---------------------------------------------------------------------------
#pragma mark Target / Action
// ---------------------------------------------------------------------------

@property (nullable, nonatomic, weak)   id  target;
@property (nullable, nonatomic, assign) SEL action;

@end

NS_ASSUME_NONNULL_END
