@native-sdk/cli 0.9.4 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/build/app.zig +68 -57
- package/build.zig +12 -1
- package/package.json +10 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/scripts/run_external_core_compiler.mjs +19 -9
- package/packages/core/scripts/run_external_service_compiler.mjs +17 -8
- package/packages/core/scripts/vendor_service_packages.mjs +121 -8
- package/packages/core/sdk/events.d.ts +33 -4
- package/packages/core/sdk/events.ts +45 -6
- package/packages/core/src/checker.ts +103 -8
- package/packages/core/src/modules.ts +6 -2
- package/packages/core/src/sqlite_cli.ts +22 -2
- package/packages/core/src/typed_ast.ts +4 -2
- package/packages/core/src/types.ts +8 -8
- package/schemas/app.schema.json +435 -0
- package/skill-data/core/SKILL.md +53 -15
- package/skill-data/core/references/project-anatomy.md +6 -6
- package/skill-data/native-ui/SKILL.md +26 -5
- package/skill-data/ts-core/SKILL.md +6 -6
- package/skills/native-sdk/SKILL.md +2 -2
- package/src/automation/snapshot.zig +91 -3
- package/src/platform/macos/appkit_host.h +41 -2
- package/src/platform/macos/appkit_host.m +198 -9
- package/src/platform/macos/cef_host.mm +191 -9
- package/src/platform/macos/root.zig +110 -3
- package/src/platform/null_platform.zig +50 -1
- package/src/platform/null_platform_tests.zig +53 -0
- package/src/platform/root.zig +9 -0
- package/src/platform/types.zig +58 -0
- package/src/platform/windows/root.zig +88 -15
- package/src/primitives/canvas/reference.zig +37 -15
- package/src/primitives/canvas/reference_tests.zig +63 -0
- package/src/primitives/canvas/ui.zig +9 -0
- package/src/primitives/canvas/ui_markup.zig +29 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +32 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +4 -2
- package/src/primitives/canvas/ui_markup_contract.zig +7 -0
- package/src/primitives/canvas/ui_markup_contract_tests.zig +21 -0
- package/src/primitives/canvas/ui_markup_tests.zig +6 -0
- package/src/primitives/canvas/ui_markup_view.zig +28 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +32 -3
- package/src/primitives/canvas/ui_schema.zig +9 -0
- package/src/primitives/canvas/ui_schema_tests.zig +5 -3
- package/src/primitives/canvas/ui_tests.zig +4 -2
- package/src/primitives/canvas/widget_render.zig +7 -2
- package/src/primitives/canvas/widget_semantics_tests.zig +3 -1
- package/src/root.zig +4 -0
- package/src/runtime/automation_snapshot.zig +3 -0
- package/src/runtime/flow.zig +1 -1
- package/src/runtime/state.zig +14 -0
- package/src/runtime/system_services.zig +62 -0
- package/src/runtime/ts_ui_app.zig +161 -33
- package/src/runtime/ui_app.zig +33 -1
- package/src/runtime/ui_app_tests.zig +63 -0
- package/src/runtime/validation.zig +87 -1
- package/src/tooling/android.zig +5 -4
- package/src/tooling/buildgraph.zig +24 -8
- package/src/tooling/db.zig +1 -1
- package/src/tooling/doctor.zig +1 -1
- package/src/tooling/ios.zig +5 -4
- package/src/tooling/json_to_zon.zig +136 -0
- package/src/tooling/manifest.zig +120 -33
- package/src/tooling/raw_manifest.zig +4 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +165 -116
- package/src/tooling/ts_core.zig +11 -7
- package/src/tooling/verbs.zig +7 -6
- package/src/tooling/web_engine.zig +17 -1
|
@@ -774,6 +774,10 @@ static int NativeSdkCredentialStatus(OSStatus status, int missingCode) {
|
|
|
774
774
|
@property(nonatomic, assign) uint32_t modifiers;
|
|
775
775
|
@end
|
|
776
776
|
|
|
777
|
+
@interface NativeSdkTraySegmentedControl : NSSegmentedControl
|
|
778
|
+
@property(nonatomic, assign) NSInteger sourceSelectedSegment;
|
|
779
|
+
@end
|
|
780
|
+
|
|
777
781
|
@interface NativeSdkStatusItemEntry : NSObject
|
|
778
782
|
@property(nonatomic, assign) uint32_t identifier;
|
|
779
783
|
@property(nonatomic, strong) NSStatusItem *item;
|
|
@@ -784,6 +788,8 @@ static int NativeSdkCredentialStatus(OSStatus status, int missingCode) {
|
|
|
784
788
|
@property(nonatomic, assign) int presentationTone;
|
|
785
789
|
@property(nonatomic, assign) double presentationIconOpacity;
|
|
786
790
|
@property(nonatomic, assign) BOOL presentationMonospaced;
|
|
791
|
+
@property(nonatomic, assign) double presentationFontSize;
|
|
792
|
+
@property(nonatomic, assign) int presentationFontWeight;
|
|
787
793
|
@property(nonatomic, strong) NSString *activationCommand;
|
|
788
794
|
@property(nonatomic, strong) NSString *alternateActivationCommand;
|
|
789
795
|
@property(nonatomic, strong) NSString *openCommand;
|
|
@@ -1095,6 +1101,7 @@ static int NativeSdkCredentialStatus(OSStatus status, int missingCode) {
|
|
|
1095
1101
|
- (NativeSdkStatusItemEntry *)statusEntryForMenu:(NSMenu *)menu;
|
|
1096
1102
|
- (void)emitStatusCommand:(NSString *)command statusItemId:(uint32_t)statusItemId;
|
|
1097
1103
|
- (void)statusItemActivated:(id)sender;
|
|
1104
|
+
- (void)traySegmentChanged:(NSSegmentedControl *)control;
|
|
1098
1105
|
- (uint64_t)activeCommandWindowId;
|
|
1099
1106
|
- (void)setMenusWithTitles:(const char *const *)menuTitles titleLengths:(const size_t *)menuTitleLengths count:(size_t)menuCount itemMenuIndices:(const uint32_t *)itemMenuIndices itemLabels:(const char *const *)itemLabels itemLabelLengths:(const size_t *)itemLabelLengths itemCommands:(const char *const *)itemCommands itemCommandLengths:(const size_t *)itemCommandLengths itemKeys:(const char *const *)itemKeys itemKeyLengths:(const size_t *)itemKeyLengths itemModifiers:(const uint32_t *)itemModifiers itemSeparators:(const int *)itemSeparators itemEnabled:(const int *)itemEnabled itemChecked:(const int *)itemChecked itemCount:(size_t)itemCount;
|
|
1100
1107
|
- (void)runWithCallback:(native_sdk_appkit_event_callback_t)callback context:(void *)context;
|
|
@@ -7480,6 +7487,9 @@ static BOOL NativeSdkScrollDriverCanConsumeHorizontally(NativeSdkScrollDriverVie
|
|
|
7480
7487
|
@implementation NativeSdkShortcut
|
|
7481
7488
|
@end
|
|
7482
7489
|
|
|
7490
|
+
@implementation NativeSdkTraySegmentedControl
|
|
7491
|
+
@end
|
|
7492
|
+
|
|
7483
7493
|
@implementation NativeSdkStatusItemEntry
|
|
7484
7494
|
@end
|
|
7485
7495
|
|
|
@@ -12197,6 +12207,22 @@ static void NativeSdkVideoFittedSize(double naturalWidth, double naturalHeight,
|
|
|
12197
12207
|
}
|
|
12198
12208
|
}
|
|
12199
12209
|
|
|
12210
|
+
- (void)traySegmentChanged:(NSSegmentedControl *)control {
|
|
12211
|
+
NSInteger selected = control.selectedSegment;
|
|
12212
|
+
if (selected < 0 || !self.trayCallback) return;
|
|
12213
|
+
NSInteger itemId = [control tagForSegment:selected];
|
|
12214
|
+
if (itemId <= 0) return;
|
|
12215
|
+
// Selection is model-owned. AppKit applies its optimistic selection
|
|
12216
|
+
// before sending the action; restore the declared state before dispatch
|
|
12217
|
+
// so an ignored or failed command cannot leave native chrome ahead of
|
|
12218
|
+
// the model. A successful dispatch rebuilds the row from the new state.
|
|
12219
|
+
NSInteger sourceSelected = [(NativeSdkTraySegmentedControl *)control sourceSelectedSegment];
|
|
12220
|
+
for (NSInteger index = 0; index < control.segmentCount; index++) {
|
|
12221
|
+
[control setSelected:index == sourceSelected forSegment:index];
|
|
12222
|
+
}
|
|
12223
|
+
self.trayCallback(self.trayContext, (uint32_t)control.tag, (uint32_t)itemId);
|
|
12224
|
+
}
|
|
12225
|
+
|
|
12200
12226
|
- (NativeSdkStatusItemEntry *)statusEntryForId:(uint32_t)identifier {
|
|
12201
12227
|
return self.statusItems[@(identifier)];
|
|
12202
12228
|
}
|
|
@@ -13344,20 +13370,33 @@ static NSImage *NativeSdkTrayImageWithOpacity(NSImage *source, double opacity) {
|
|
|
13344
13370
|
return image;
|
|
13345
13371
|
}
|
|
13346
13372
|
|
|
13347
|
-
static
|
|
13373
|
+
static NSFontWeight NativeSdkTrayFontWeight(int weight) {
|
|
13374
|
+
switch (weight) {
|
|
13375
|
+
case 1: return NSFontWeightMedium;
|
|
13376
|
+
case 2: return NSFontWeightSemibold;
|
|
13377
|
+
case 3: return NSFontWeightBold;
|
|
13378
|
+
default: return NSFontWeightRegular;
|
|
13379
|
+
}
|
|
13380
|
+
}
|
|
13381
|
+
|
|
13382
|
+
static void NativeSdkApplyTrayPresentation(NativeSdkAppKitHost *object, NativeSdkStatusItemEntry *entry, NSString *requestedTitle, double width, int tone, double iconOpacity, BOOL monospaced, double fontSize, int fontWeight) {
|
|
13348
13383
|
if (!entry.item) return;
|
|
13349
13384
|
entry.presentationTitle = requestedTitle ?: @"";
|
|
13350
13385
|
entry.presentationWidth = width;
|
|
13351
13386
|
entry.presentationTone = tone;
|
|
13352
13387
|
entry.presentationIconOpacity = iconOpacity;
|
|
13353
13388
|
entry.presentationMonospaced = monospaced;
|
|
13389
|
+
entry.presentationFontSize = fontSize;
|
|
13390
|
+
entry.presentationFontWeight = fontWeight;
|
|
13354
13391
|
NSString *title = requestedTitle ?: @"";
|
|
13355
13392
|
if (!entry.baseImage && title.length == 0) {
|
|
13356
13393
|
title = object.appName.length > 0 ? [object.appName substringToIndex:MIN(1, object.appName.length)] : @"Z";
|
|
13357
13394
|
}
|
|
13395
|
+
CGFloat resolvedSize = fontSize > 0 ? fontSize : 11;
|
|
13396
|
+
NSFontWeight resolvedWeight = NativeSdkTrayFontWeight(fontWeight);
|
|
13358
13397
|
NSFont *font = monospaced
|
|
13359
|
-
?
|
|
13360
|
-
: [NSFont systemFontOfSize:
|
|
13398
|
+
? [NSFont monospacedSystemFontOfSize:resolvedSize weight:resolvedWeight]
|
|
13399
|
+
: [NSFont systemFontOfSize:resolvedSize weight:resolvedWeight];
|
|
13361
13400
|
NSStatusBarButton *button = entry.item.button;
|
|
13362
13401
|
if (tone == 0) {
|
|
13363
13402
|
button.title = title;
|
|
@@ -13398,7 +13437,7 @@ static void NativeSdkApplyTrayShell(NativeSdkAppKitHost *object, NativeSdkStatus
|
|
|
13398
13437
|
entry.item.visible = visible != 0;
|
|
13399
13438
|
}
|
|
13400
13439
|
|
|
13401
|
-
void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len, int visible, double width, int tone, double icon_opacity, int monospaced, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len) {
|
|
13440
|
+
void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len, int visible, double width, int tone, double icon_opacity, int monospaced, double font_size, int font_weight, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len) {
|
|
13402
13441
|
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
13403
13442
|
@autoreleasepool {
|
|
13404
13443
|
NSNumber *key = @(status_item_id);
|
|
@@ -13415,7 +13454,7 @@ void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t stat
|
|
|
13415
13454
|
entry.item = [[NSStatusBar systemStatusBar] statusItemWithLength:hasTitle ? NSVariableStatusItemLength : NSSquareStatusItemLength];
|
|
13416
13455
|
NSString *titleString = hasTitle ? ([[NSString alloc] initWithBytes:title length:title_len encoding:NSUTF8StringEncoding] ?: @"") : @"";
|
|
13417
13456
|
NativeSdkApplyTrayShell(object, entry, icon_path, icon_path_len, tooltip, tooltip_len, visible, activation_command, activation_command_len, alternate_activation_command, alternate_activation_command_len, open_command, open_command_len);
|
|
13418
|
-
NativeSdkApplyTrayPresentation(object, entry, titleString, width, tone, icon_opacity, monospaced != 0);
|
|
13457
|
+
NativeSdkApplyTrayPresentation(object, entry, titleString, width, tone, icon_opacity, monospaced != 0, font_size, font_weight);
|
|
13419
13458
|
}
|
|
13420
13459
|
}
|
|
13421
13460
|
|
|
@@ -13425,7 +13464,7 @@ void native_sdk_appkit_update_tray_shell(native_sdk_appkit_host_t *host, uint32_
|
|
|
13425
13464
|
NativeSdkStatusItemEntry *entry = [object statusEntryForId:status_item_id];
|
|
13426
13465
|
if (!entry) return;
|
|
13427
13466
|
NativeSdkApplyTrayShell(object, entry, icon_path, icon_path_len, tooltip, tooltip_len, visible, activation_command, activation_command_len, alternate_activation_command, alternate_activation_command_len, open_command, open_command_len);
|
|
13428
|
-
NativeSdkApplyTrayPresentation(object, entry, entry.presentationTitle, entry.presentationWidth, entry.presentationTone, entry.presentationIconOpacity, entry.presentationMonospaced);
|
|
13467
|
+
NativeSdkApplyTrayPresentation(object, entry, entry.presentationTitle, entry.presentationWidth, entry.presentationTone, entry.presentationIconOpacity, entry.presentationMonospaced, entry.presentationFontSize, entry.presentationFontWeight);
|
|
13429
13468
|
if (entry.activationCommand.length == 0 && entry.alternateActivationCommand.length == 0) entry.item.menu = entry.menu;
|
|
13430
13469
|
else entry.item.menu = nil;
|
|
13431
13470
|
}
|
|
@@ -13438,8 +13477,115 @@ enum {
|
|
|
13438
13477
|
NativeSdkTrayRoleHero = 3,
|
|
13439
13478
|
NativeSdkTrayRoleAgent = 4,
|
|
13440
13479
|
NativeSdkTrayRoleContext = 5,
|
|
13480
|
+
NativeSdkTrayRoleSegmented = 6,
|
|
13481
|
+
NativeSdkTrayRoleChart = 7,
|
|
13441
13482
|
};
|
|
13442
13483
|
|
|
13484
|
+
@interface NativeSdkTrayBarChartView : NSView
|
|
13485
|
+
@property(nonatomic, copy) NSArray<NSNumber *> *values;
|
|
13486
|
+
@property(nonatomic, assign) double minValue;
|
|
13487
|
+
@property(nonatomic, assign) double maxValue;
|
|
13488
|
+
@end
|
|
13489
|
+
|
|
13490
|
+
@implementation NativeSdkTrayBarChartView
|
|
13491
|
+
- (BOOL)isFlipped { return YES; }
|
|
13492
|
+
- (void)drawRect:(NSRect)dirtyRect {
|
|
13493
|
+
[super drawRect:dirtyRect];
|
|
13494
|
+
if (self.values.count == 0 || !(self.maxValue > self.minValue)) return;
|
|
13495
|
+
CGFloat gap = 2;
|
|
13496
|
+
CGFloat barWidth = MAX(1, (NSWidth(self.bounds) - gap * (self.values.count - 1)) / self.values.count);
|
|
13497
|
+
CGFloat x = 0;
|
|
13498
|
+
[NSColor.controlAccentColor setFill];
|
|
13499
|
+
for (NSNumber *number in self.values) {
|
|
13500
|
+
double fraction = (number.doubleValue - self.minValue) / (self.maxValue - self.minValue);
|
|
13501
|
+
fraction = MIN(MAX(fraction, 0), 1);
|
|
13502
|
+
CGFloat height = MAX(fraction > 0 ? 1 : 0, floor(fraction * NSHeight(self.bounds)));
|
|
13503
|
+
NSRectFill(NSMakeRect(x, NSHeight(self.bounds) - height, barWidth, height));
|
|
13504
|
+
x += barWidth + gap;
|
|
13505
|
+
}
|
|
13506
|
+
}
|
|
13507
|
+
@end
|
|
13508
|
+
|
|
13509
|
+
static NSString *NativeSdkTrayString(const char *bytes, size_t len) {
|
|
13510
|
+
return bytes && len > 0 ? ([[NSString alloc] initWithBytes:bytes length:len encoding:NSUTF8StringEncoding] ?: @"") : @"";
|
|
13511
|
+
}
|
|
13512
|
+
|
|
13513
|
+
static NSView *NativeSdkTraySegmentedView(NativeSdkAppKitHost *object, uint32_t statusItemId, const native_sdk_appkit_tray_segment_option_t *options, size_t count) {
|
|
13514
|
+
NSView *row = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 320, 38)];
|
|
13515
|
+
NativeSdkTraySegmentedControl *control = [[NativeSdkTraySegmentedControl alloc] initWithFrame:NSMakeRect(14, 5, 292, 28)];
|
|
13516
|
+
control.segmentCount = count;
|
|
13517
|
+
control.segmentStyle = NSSegmentStyleAutomatic;
|
|
13518
|
+
control.trackingMode = NSSegmentSwitchTrackingSelectOne;
|
|
13519
|
+
control.target = object;
|
|
13520
|
+
control.action = @selector(traySegmentChanged:);
|
|
13521
|
+
control.tag = (NSInteger)statusItemId;
|
|
13522
|
+
control.sourceSelectedSegment = -1;
|
|
13523
|
+
control.autoresizingMask = NSViewWidthSizable;
|
|
13524
|
+
for (size_t i = 0; i < count; i++) {
|
|
13525
|
+
[control setLabel:NativeSdkTrayString(options[i].label, options[i].label_len) forSegment:i];
|
|
13526
|
+
[control setEnabled:options[i].enabled != 0 forSegment:i];
|
|
13527
|
+
[control setTag:(NSInteger)options[i].item_id forSegment:i];
|
|
13528
|
+
[control setSelected:options[i].selected != 0 forSegment:i];
|
|
13529
|
+
if (options[i].selected != 0) control.sourceSelectedSegment = (NSInteger)i;
|
|
13530
|
+
}
|
|
13531
|
+
[row addSubview:control];
|
|
13532
|
+
row.accessibilityRole = NSAccessibilityGroupRole;
|
|
13533
|
+
return row;
|
|
13534
|
+
}
|
|
13535
|
+
|
|
13536
|
+
static NSView *NativeSdkTrayMetricView(const native_sdk_appkit_tray_metric_row_t *metric) {
|
|
13537
|
+
NSView *row = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 320, 58)];
|
|
13538
|
+
NSTextField *primary = [NSTextField labelWithString:NativeSdkTrayString(metric->primary_text, metric->primary_text_len)];
|
|
13539
|
+
NSTextField *secondary = [NSTextField labelWithString:NativeSdkTrayString(metric->secondary_text, metric->secondary_text_len)];
|
|
13540
|
+
primary.frame = NSMakeRect(14, 25, 292, 28);
|
|
13541
|
+
secondary.frame = NSMakeRect(14, 6, 292, 16);
|
|
13542
|
+
primary.font = [NSFont fontWithName:@"Geist Mono" size:20] ?: [NSFont monospacedDigitSystemFontOfSize:20 weight:NSFontWeightMedium];
|
|
13543
|
+
secondary.font = [NSFont systemFontOfSize:11];
|
|
13544
|
+
secondary.textColor = NSColor.secondaryLabelColor;
|
|
13545
|
+
primary.autoresizingMask = NSViewWidthSizable;
|
|
13546
|
+
secondary.autoresizingMask = NSViewWidthSizable;
|
|
13547
|
+
primary.accessibilityElement = NO;
|
|
13548
|
+
secondary.accessibilityElement = NO;
|
|
13549
|
+
[row addSubview:primary];
|
|
13550
|
+
[row addSubview:secondary];
|
|
13551
|
+
row.accessibilityLabel = NativeSdkTrayString(metric->accessibility_label, metric->accessibility_label_len);
|
|
13552
|
+
row.accessibilityRole = NSAccessibilityGroupRole;
|
|
13553
|
+
return row;
|
|
13554
|
+
}
|
|
13555
|
+
|
|
13556
|
+
static NSView *NativeSdkTrayChartView(const native_sdk_appkit_tray_chart_row_t *chart) {
|
|
13557
|
+
NSString *leading = NativeSdkTrayString(chart->leading_caption, chart->leading_caption_len);
|
|
13558
|
+
NSString *trailing = NativeSdkTrayString(chart->trailing_summary, chart->trailing_summary_len);
|
|
13559
|
+
NSView *row = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 320, 58)];
|
|
13560
|
+
NSTextField *leadingField = [NSTextField labelWithString:leading];
|
|
13561
|
+
NSTextField *trailingField = [NSTextField labelWithString:trailing];
|
|
13562
|
+
leadingField.frame = NSMakeRect(14, 3, 142, 15);
|
|
13563
|
+
trailingField.frame = NSMakeRect(164, 3, 142, 15);
|
|
13564
|
+
trailingField.alignment = NSTextAlignmentRight;
|
|
13565
|
+
leadingField.font = [NSFont systemFontOfSize:10];
|
|
13566
|
+
trailingField.font = [NSFont monospacedDigitSystemFontOfSize:10 weight:NSFontWeightRegular];
|
|
13567
|
+
leadingField.textColor = NSColor.secondaryLabelColor;
|
|
13568
|
+
trailingField.textColor = NSColor.secondaryLabelColor;
|
|
13569
|
+
leadingField.autoresizingMask = NSViewWidthSizable;
|
|
13570
|
+
trailingField.autoresizingMask = NSViewMinXMargin;
|
|
13571
|
+
leadingField.accessibilityElement = NO;
|
|
13572
|
+
trailingField.accessibilityElement = NO;
|
|
13573
|
+
NativeSdkTrayBarChartView *bars = [[NativeSdkTrayBarChartView alloc] initWithFrame:NSMakeRect(14, 21, 292, 32)];
|
|
13574
|
+
NSMutableArray<NSNumber *> *values = [NSMutableArray arrayWithCapacity:chart->value_count];
|
|
13575
|
+
for (size_t i = 0; i < chart->value_count; i++) [values addObject:@(chart->values[i])];
|
|
13576
|
+
bars.values = values;
|
|
13577
|
+
bars.minValue = chart->min_value;
|
|
13578
|
+
bars.maxValue = chart->max_value;
|
|
13579
|
+
bars.autoresizingMask = NSViewWidthSizable;
|
|
13580
|
+
bars.accessibilityElement = NO;
|
|
13581
|
+
[row addSubview:leadingField];
|
|
13582
|
+
[row addSubview:trailingField];
|
|
13583
|
+
[row addSubview:bars];
|
|
13584
|
+
row.accessibilityLabel = NativeSdkTrayString(chart->accessibility_label, chart->accessibility_label_len);
|
|
13585
|
+
row.accessibilityRole = NSAccessibilityGroupRole;
|
|
13586
|
+
return row;
|
|
13587
|
+
}
|
|
13588
|
+
|
|
13443
13589
|
static NSView *NativeSdkTrayHeroView(NSString *headline, NSString *quota) {
|
|
13444
13590
|
NSArray<NSString *> *parts = [headline componentsSeparatedByString:@"\n"];
|
|
13445
13591
|
NSString *value = parts.count > 0 ? parts[0] : @"";
|
|
@@ -13667,6 +13813,7 @@ void native_sdk_appkit_update_tray_menu(native_sdk_appkit_host_t *host, uint32_t
|
|
|
13667
13813
|
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:label ?: @""
|
|
13668
13814
|
action:@selector(trayMenuItemClicked:)
|
|
13669
13815
|
keyEquivalent:@""];
|
|
13816
|
+
item.representedObject = @(i);
|
|
13670
13817
|
item.tag = (NSInteger)(((uint64_t)status_item_id << 32) | item_ids[i]);
|
|
13671
13818
|
item.target = object;
|
|
13672
13819
|
item.enabled = enabled_flags[i] != 0;
|
|
@@ -13740,6 +13887,46 @@ void native_sdk_appkit_update_tray_menu(native_sdk_appkit_host_t *host, uint32_t
|
|
|
13740
13887
|
}
|
|
13741
13888
|
}
|
|
13742
13889
|
|
|
13890
|
+
void native_sdk_appkit_update_tray_rich_rows(native_sdk_appkit_host_t *host, uint32_t status_item_id, const native_sdk_appkit_tray_segmented_row_t *segmented_rows, size_t segmented_count, const native_sdk_appkit_tray_metric_row_t *metric_rows, size_t metric_count, const native_sdk_appkit_tray_chart_row_t *chart_rows, size_t chart_count) {
|
|
13891
|
+
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
13892
|
+
@autoreleasepool {
|
|
13893
|
+
NativeSdkStatusItemEntry *entry = [object statusEntryForId:status_item_id];
|
|
13894
|
+
if (!entry || !entry.menu) return;
|
|
13895
|
+
for (size_t i = 0; i < segmented_count; i++) {
|
|
13896
|
+
const native_sdk_appkit_tray_segmented_row_t *row = &segmented_rows[i];
|
|
13897
|
+
NSMenuItem *item = nil;
|
|
13898
|
+
for (NSMenuItem *candidate in entry.menu.itemArray) {
|
|
13899
|
+
if ([candidate.representedObject isEqual:@(row->row_index)]) { item = candidate; break; }
|
|
13900
|
+
}
|
|
13901
|
+
if (!item) continue;
|
|
13902
|
+
item.action = NULL;
|
|
13903
|
+
item.target = nil;
|
|
13904
|
+
item.view = NativeSdkTraySegmentedView(object, status_item_id, row->options, row->option_count);
|
|
13905
|
+
}
|
|
13906
|
+
for (size_t i = 0; i < metric_count; i++) {
|
|
13907
|
+
NSMenuItem *item = nil;
|
|
13908
|
+
for (NSMenuItem *candidate in entry.menu.itemArray) {
|
|
13909
|
+
if ([candidate.representedObject isEqual:@(metric_rows[i].row_index)]) { item = candidate; break; }
|
|
13910
|
+
}
|
|
13911
|
+
if (!item) continue;
|
|
13912
|
+
item.action = NULL;
|
|
13913
|
+
item.target = nil;
|
|
13914
|
+
item.view = NativeSdkTrayMetricView(&metric_rows[i]);
|
|
13915
|
+
}
|
|
13916
|
+
for (size_t i = 0; i < chart_count; i++) {
|
|
13917
|
+
const native_sdk_appkit_tray_chart_row_t *row = &chart_rows[i];
|
|
13918
|
+
NSMenuItem *item = nil;
|
|
13919
|
+
for (NSMenuItem *candidate in entry.menu.itemArray) {
|
|
13920
|
+
if ([candidate.representedObject isEqual:@(row->row_index)]) { item = candidate; break; }
|
|
13921
|
+
}
|
|
13922
|
+
if (!item) continue;
|
|
13923
|
+
item.action = NULL;
|
|
13924
|
+
item.target = nil;
|
|
13925
|
+
item.view = NativeSdkTrayChartView(row);
|
|
13926
|
+
}
|
|
13927
|
+
}
|
|
13928
|
+
}
|
|
13929
|
+
|
|
13743
13930
|
void native_sdk_appkit_update_tray_title(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len) {
|
|
13744
13931
|
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
13745
13932
|
@autoreleasepool {
|
|
@@ -13753,18 +13940,20 @@ void native_sdk_appkit_update_tray_title(native_sdk_appkit_host_t *host, uint32_
|
|
|
13753
13940
|
entry.presentationWidth,
|
|
13754
13941
|
entry.presentationTone,
|
|
13755
13942
|
entry.presentationIconOpacity,
|
|
13756
|
-
entry.presentationMonospaced
|
|
13943
|
+
entry.presentationMonospaced,
|
|
13944
|
+
entry.presentationFontSize,
|
|
13945
|
+
entry.presentationFontWeight
|
|
13757
13946
|
);
|
|
13758
13947
|
}
|
|
13759
13948
|
}
|
|
13760
13949
|
|
|
13761
|
-
void native_sdk_appkit_update_tray_presentation(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len, double width, int tone, double icon_opacity, int monospaced) {
|
|
13950
|
+
void native_sdk_appkit_update_tray_presentation(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len, double width, int tone, double icon_opacity, int monospaced, double font_size, int font_weight) {
|
|
13762
13951
|
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
13763
13952
|
@autoreleasepool {
|
|
13764
13953
|
NativeSdkStatusItemEntry *entry = [object statusEntryForId:status_item_id];
|
|
13765
13954
|
if (!entry) return;
|
|
13766
13955
|
NSString *value = title ? ([[NSString alloc] initWithBytes:title length:title_len encoding:NSUTF8StringEncoding] ?: @"") : @"";
|
|
13767
|
-
NativeSdkApplyTrayPresentation(object, entry, value, width, tone, icon_opacity, monospaced != 0);
|
|
13956
|
+
NativeSdkApplyTrayPresentation(object, entry, value, width, tone, icon_opacity, monospaced != 0, font_size, font_weight);
|
|
13768
13957
|
}
|
|
13769
13958
|
}
|
|
13770
13959
|
|
|
@@ -607,6 +607,10 @@ static const char *NativeSdkCefBridgeScript() {
|
|
|
607
607
|
@property(nonatomic, assign) uint32_t modifiers;
|
|
608
608
|
@end
|
|
609
609
|
|
|
610
|
+
@interface NativeSdkCefTraySegmentedControl : NSSegmentedControl
|
|
611
|
+
@property(nonatomic, assign) NSInteger sourceSelectedSegment;
|
|
612
|
+
@end
|
|
613
|
+
|
|
610
614
|
@interface NativeSdkChromiumStatusItemEntry : NSObject
|
|
611
615
|
@property(nonatomic, assign) uint32_t identifier;
|
|
612
616
|
@property(nonatomic, strong) NSStatusItem *item;
|
|
@@ -617,6 +621,8 @@ static const char *NativeSdkCefBridgeScript() {
|
|
|
617
621
|
@property(nonatomic, assign) int presentationTone;
|
|
618
622
|
@property(nonatomic, assign) double presentationIconOpacity;
|
|
619
623
|
@property(nonatomic, assign) BOOL presentationMonospaced;
|
|
624
|
+
@property(nonatomic, assign) double presentationFontSize;
|
|
625
|
+
@property(nonatomic, assign) int presentationFontWeight;
|
|
620
626
|
@property(nonatomic, strong) NSString *activationCommand;
|
|
621
627
|
@property(nonatomic, strong) NSString *alternateActivationCommand;
|
|
622
628
|
@property(nonatomic, strong) NSString *openCommand;
|
|
@@ -769,6 +775,7 @@ static const char *NativeSdkCefBridgeScript() {
|
|
|
769
775
|
- (BOOL)handleShortcutEvent:(NSEvent *)event;
|
|
770
776
|
- (void)emitShortcutWithId:(NSString *)identifier key:(NSString *)key modifiers:(uint32_t)modifiers event:(NSEvent *)event;
|
|
771
777
|
- (void)trayMenuItemClicked:(NSMenuItem *)menuItem;
|
|
778
|
+
- (void)traySegmentChanged:(NSSegmentedControl *)control;
|
|
772
779
|
- (void)menuWillOpen:(NSMenu *)menu;
|
|
773
780
|
- (NativeSdkChromiumStatusItemEntry *)statusEntryForId:(uint32_t)identifier;
|
|
774
781
|
- (NativeSdkChromiumStatusItemEntry *)statusEntryForMenu:(NSMenu *)menu;
|
|
@@ -779,6 +786,9 @@ static const char *NativeSdkCefBridgeScript() {
|
|
|
779
786
|
@implementation NativeSdkChromiumShortcut
|
|
780
787
|
@end
|
|
781
788
|
|
|
789
|
+
@implementation NativeSdkCefTraySegmentedControl
|
|
790
|
+
@end
|
|
791
|
+
|
|
782
792
|
@implementation NativeSdkChromiumStatusItemEntry
|
|
783
793
|
@end
|
|
784
794
|
|
|
@@ -2132,6 +2142,20 @@ static const char *NativeSdkCefBridgeScript() {
|
|
|
2132
2142
|
}
|
|
2133
2143
|
}
|
|
2134
2144
|
|
|
2145
|
+
- (void)traySegmentChanged:(NSSegmentedControl *)control {
|
|
2146
|
+
NSInteger selected = control.selectedSegment;
|
|
2147
|
+
if (selected < 0 || !self.trayCallback) return;
|
|
2148
|
+
NSInteger itemId = [control tagForSegment:selected];
|
|
2149
|
+
if (itemId <= 0) return;
|
|
2150
|
+
// Keep the native control on the model-declared selection until the
|
|
2151
|
+
// dispatched command commits a new model and rebuilds this menu row.
|
|
2152
|
+
NSInteger sourceSelected = [(NativeSdkCefTraySegmentedControl *)control sourceSelectedSegment];
|
|
2153
|
+
for (NSInteger index = 0; index < control.segmentCount; index++) {
|
|
2154
|
+
[control setSelected:index == sourceSelected forSegment:index];
|
|
2155
|
+
}
|
|
2156
|
+
self.trayCallback(self.trayContext, (uint32_t)control.tag, (uint32_t)itemId);
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2135
2159
|
- (NativeSdkChromiumStatusItemEntry *)statusEntryForId:(uint32_t)identifier {
|
|
2136
2160
|
return self.statusItems[@(identifier)];
|
|
2137
2161
|
}
|
|
@@ -3604,16 +3628,29 @@ static NSImage *NativeSdkCefTrayImageWithOpacity(NSImage *source, double opacity
|
|
|
3604
3628
|
return image;
|
|
3605
3629
|
}
|
|
3606
3630
|
|
|
3607
|
-
static
|
|
3631
|
+
static NSFontWeight NativeSdkCefTrayFontWeight(int weight) {
|
|
3632
|
+
switch (weight) {
|
|
3633
|
+
case 1: return NSFontWeightMedium;
|
|
3634
|
+
case 2: return NSFontWeightSemibold;
|
|
3635
|
+
case 3: return NSFontWeightBold;
|
|
3636
|
+
default: return NSFontWeightRegular;
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
|
|
3640
|
+
static void NativeSdkCefApplyTrayPresentation(NativeSdkChromiumHost *object, NativeSdkChromiumStatusItemEntry *entry, NSString *requestedTitle, double width, int tone, double iconOpacity, BOOL monospaced, double fontSize, int fontWeight) {
|
|
3608
3641
|
if (!entry.item) return;
|
|
3609
3642
|
entry.presentationTitle = requestedTitle ?: @"";
|
|
3610
3643
|
entry.presentationWidth = width;
|
|
3611
3644
|
entry.presentationTone = tone;
|
|
3612
3645
|
entry.presentationIconOpacity = iconOpacity;
|
|
3613
3646
|
entry.presentationMonospaced = monospaced;
|
|
3647
|
+
entry.presentationFontSize = fontSize;
|
|
3648
|
+
entry.presentationFontWeight = fontWeight;
|
|
3614
3649
|
NSString *title = requestedTitle ?: @"";
|
|
3615
3650
|
if (!entry.baseImage && title.length == 0) title = object.appName.length > 0 ? [object.appName substringToIndex:MIN(1, object.appName.length)] : @"Z";
|
|
3616
|
-
|
|
3651
|
+
CGFloat resolvedSize = fontSize > 0 ? fontSize : 11;
|
|
3652
|
+
NSFontWeight resolvedWeight = NativeSdkCefTrayFontWeight(fontWeight);
|
|
3653
|
+
NSFont *font = monospaced ? [NSFont monospacedSystemFontOfSize:resolvedSize weight:resolvedWeight] : [NSFont systemFontOfSize:resolvedSize weight:resolvedWeight];
|
|
3617
3654
|
if (tone == 0) {
|
|
3618
3655
|
entry.item.button.title = title;
|
|
3619
3656
|
entry.item.button.font = font;
|
|
@@ -3650,7 +3687,7 @@ static void NativeSdkCefApplyTrayShell(NativeSdkChromiumHost *object, NativeSdkC
|
|
|
3650
3687
|
entry.item.visible = visible != 0;
|
|
3651
3688
|
}
|
|
3652
3689
|
|
|
3653
|
-
void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len, int visible, double width, int tone, double icon_opacity, int monospaced, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len) {
|
|
3690
|
+
void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len, int visible, double width, int tone, double icon_opacity, int monospaced, double font_size, int font_weight, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len) {
|
|
3654
3691
|
NativeSdkChromiumHost *object = (__bridge NativeSdkChromiumHost *)host;
|
|
3655
3692
|
@autoreleasepool {
|
|
3656
3693
|
NSNumber *key = @(status_item_id);
|
|
@@ -3669,7 +3706,7 @@ void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t stat
|
|
|
3669
3706
|
entry.item = [[NSStatusBar systemStatusBar] statusItemWithLength:hasTitle ? NSVariableStatusItemLength : NSSquareStatusItemLength];
|
|
3670
3707
|
NSString *titleString = hasTitle ? ([[NSString alloc] initWithBytes:title length:title_len encoding:NSUTF8StringEncoding] ?: @"") : @"";
|
|
3671
3708
|
NativeSdkCefApplyTrayShell(object, entry, icon_path, icon_path_len, tooltip, tooltip_len, visible, activation_command, activation_command_len, alternate_activation_command, alternate_activation_command_len, open_command, open_command_len);
|
|
3672
|
-
NativeSdkCefApplyTrayPresentation(object, entry, titleString, width, tone, icon_opacity, monospaced != 0);
|
|
3709
|
+
NativeSdkCefApplyTrayPresentation(object, entry, titleString, width, tone, icon_opacity, monospaced != 0, font_size, font_weight);
|
|
3673
3710
|
}
|
|
3674
3711
|
}
|
|
3675
3712
|
|
|
@@ -3679,7 +3716,7 @@ void native_sdk_appkit_update_tray_shell(native_sdk_appkit_host_t *host, uint32_
|
|
|
3679
3716
|
NativeSdkChromiumStatusItemEntry *entry = [object statusEntryForId:status_item_id];
|
|
3680
3717
|
if (!entry) return;
|
|
3681
3718
|
NativeSdkCefApplyTrayShell(object, entry, icon_path, icon_path_len, tooltip, tooltip_len, visible, activation_command, activation_command_len, alternate_activation_command, alternate_activation_command_len, open_command, open_command_len);
|
|
3682
|
-
NativeSdkCefApplyTrayPresentation(object, entry, entry.presentationTitle, entry.presentationWidth, entry.presentationTone, entry.presentationIconOpacity, entry.presentationMonospaced);
|
|
3719
|
+
NativeSdkCefApplyTrayPresentation(object, entry, entry.presentationTitle, entry.presentationWidth, entry.presentationTone, entry.presentationIconOpacity, entry.presentationMonospaced, entry.presentationFontSize, entry.presentationFontWeight);
|
|
3683
3720
|
if (entry.activationCommand.length == 0 && entry.alternateActivationCommand.length == 0) entry.item.menu = entry.menu;
|
|
3684
3721
|
else entry.item.menu = nil;
|
|
3685
3722
|
}
|
|
@@ -3694,6 +3731,107 @@ static NSEventModifierFlags NativeSdkCefTrayModifiers(uint32_t modifiers) {
|
|
|
3694
3731
|
return flags;
|
|
3695
3732
|
}
|
|
3696
3733
|
|
|
3734
|
+
@interface NativeSdkCefTrayBarChartView : NSView
|
|
3735
|
+
@property(nonatomic, copy) NSArray<NSNumber *> *values;
|
|
3736
|
+
@property(nonatomic, assign) double minValue;
|
|
3737
|
+
@property(nonatomic, assign) double maxValue;
|
|
3738
|
+
@end
|
|
3739
|
+
|
|
3740
|
+
@implementation NativeSdkCefTrayBarChartView
|
|
3741
|
+
- (BOOL)isFlipped { return YES; }
|
|
3742
|
+
- (void)drawRect:(NSRect)dirtyRect {
|
|
3743
|
+
[super drawRect:dirtyRect];
|
|
3744
|
+
if (self.values.count == 0 || !(self.maxValue > self.minValue)) return;
|
|
3745
|
+
CGFloat gap = 2;
|
|
3746
|
+
CGFloat barWidth = MAX(1, (NSWidth(self.bounds) - gap * (self.values.count - 1)) / self.values.count);
|
|
3747
|
+
CGFloat x = 0;
|
|
3748
|
+
[NSColor.controlAccentColor setFill];
|
|
3749
|
+
for (NSNumber *number in self.values) {
|
|
3750
|
+
double fraction = (number.doubleValue - self.minValue) / (self.maxValue - self.minValue);
|
|
3751
|
+
fraction = MIN(MAX(fraction, 0), 1);
|
|
3752
|
+
CGFloat height = MAX(fraction > 0 ? 1 : 0, floor(fraction * NSHeight(self.bounds)));
|
|
3753
|
+
NSRectFill(NSMakeRect(x, NSHeight(self.bounds) - height, barWidth, height));
|
|
3754
|
+
x += barWidth + gap;
|
|
3755
|
+
}
|
|
3756
|
+
}
|
|
3757
|
+
@end
|
|
3758
|
+
|
|
3759
|
+
static NSString *NativeSdkCefTrayString(const char *bytes, size_t len) {
|
|
3760
|
+
return bytes && len > 0 ? ([[NSString alloc] initWithBytes:bytes length:len encoding:NSUTF8StringEncoding] ?: @"") : @"";
|
|
3761
|
+
}
|
|
3762
|
+
|
|
3763
|
+
static NSView *NativeSdkCefTraySegmentedView(NativeSdkChromiumHost *object, uint32_t statusItemId, const native_sdk_appkit_tray_segment_option_t *options, size_t count) {
|
|
3764
|
+
NSView *row = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 320, 38)];
|
|
3765
|
+
NativeSdkCefTraySegmentedControl *control = [[NativeSdkCefTraySegmentedControl alloc] initWithFrame:NSMakeRect(14, 5, 292, 28)];
|
|
3766
|
+
control.segmentCount = count;
|
|
3767
|
+
control.trackingMode = NSSegmentSwitchTrackingSelectOne;
|
|
3768
|
+
control.target = object;
|
|
3769
|
+
control.action = @selector(traySegmentChanged:);
|
|
3770
|
+
control.tag = (NSInteger)statusItemId;
|
|
3771
|
+
control.sourceSelectedSegment = -1;
|
|
3772
|
+
control.autoresizingMask = NSViewWidthSizable;
|
|
3773
|
+
for (size_t i = 0; i < count; i++) {
|
|
3774
|
+
[control setLabel:NativeSdkCefTrayString(options[i].label, options[i].label_len) forSegment:i];
|
|
3775
|
+
[control setEnabled:options[i].enabled != 0 forSegment:i];
|
|
3776
|
+
[control setTag:(NSInteger)options[i].item_id forSegment:i];
|
|
3777
|
+
[control setSelected:options[i].selected != 0 forSegment:i];
|
|
3778
|
+
if (options[i].selected != 0) control.sourceSelectedSegment = (NSInteger)i;
|
|
3779
|
+
}
|
|
3780
|
+
[row addSubview:control];
|
|
3781
|
+
return row;
|
|
3782
|
+
}
|
|
3783
|
+
|
|
3784
|
+
static NSView *NativeSdkCefTrayMetricView(const native_sdk_appkit_tray_metric_row_t *metric) {
|
|
3785
|
+
NSView *row = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 320, 58)];
|
|
3786
|
+
NSTextField *primary = [NSTextField labelWithString:NativeSdkCefTrayString(metric->primary_text, metric->primary_text_len)];
|
|
3787
|
+
NSTextField *secondary = [NSTextField labelWithString:NativeSdkCefTrayString(metric->secondary_text, metric->secondary_text_len)];
|
|
3788
|
+
primary.frame = NSMakeRect(14, 25, 292, 28);
|
|
3789
|
+
secondary.frame = NSMakeRect(14, 6, 292, 16);
|
|
3790
|
+
primary.font = [NSFont fontWithName:@"Geist Mono" size:20] ?: [NSFont monospacedDigitSystemFontOfSize:20 weight:NSFontWeightMedium];
|
|
3791
|
+
secondary.font = [NSFont systemFontOfSize:11];
|
|
3792
|
+
secondary.textColor = NSColor.secondaryLabelColor;
|
|
3793
|
+
primary.autoresizingMask = NSViewWidthSizable;
|
|
3794
|
+
secondary.autoresizingMask = NSViewWidthSizable;
|
|
3795
|
+
primary.accessibilityElement = NO;
|
|
3796
|
+
secondary.accessibilityElement = NO;
|
|
3797
|
+
[row addSubview:primary];
|
|
3798
|
+
[row addSubview:secondary];
|
|
3799
|
+
row.accessibilityLabel = NativeSdkCefTrayString(metric->accessibility_label, metric->accessibility_label_len);
|
|
3800
|
+
row.accessibilityRole = NSAccessibilityGroupRole;
|
|
3801
|
+
return row;
|
|
3802
|
+
}
|
|
3803
|
+
|
|
3804
|
+
static NSView *NativeSdkCefTrayChartView(const native_sdk_appkit_tray_chart_row_t *chart) {
|
|
3805
|
+
NSView *row = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 320, 58)];
|
|
3806
|
+
NSTextField *leading = [NSTextField labelWithString:NativeSdkCefTrayString(chart->leading_caption, chart->leading_caption_len)];
|
|
3807
|
+
NSTextField *trailing = [NSTextField labelWithString:NativeSdkCefTrayString(chart->trailing_summary, chart->trailing_summary_len)];
|
|
3808
|
+
leading.frame = NSMakeRect(14, 3, 142, 15);
|
|
3809
|
+
trailing.frame = NSMakeRect(164, 3, 142, 15);
|
|
3810
|
+
trailing.alignment = NSTextAlignmentRight;
|
|
3811
|
+
leading.font = [NSFont systemFontOfSize:10];
|
|
3812
|
+
trailing.font = [NSFont monospacedDigitSystemFontOfSize:10 weight:NSFontWeightRegular];
|
|
3813
|
+
leading.textColor = NSColor.secondaryLabelColor;
|
|
3814
|
+
trailing.textColor = NSColor.secondaryLabelColor;
|
|
3815
|
+
leading.autoresizingMask = NSViewWidthSizable;
|
|
3816
|
+
trailing.autoresizingMask = NSViewMinXMargin;
|
|
3817
|
+
leading.accessibilityElement = NO;
|
|
3818
|
+
trailing.accessibilityElement = NO;
|
|
3819
|
+
NativeSdkCefTrayBarChartView *bars = [[NativeSdkCefTrayBarChartView alloc] initWithFrame:NSMakeRect(14, 21, 292, 32)];
|
|
3820
|
+
NSMutableArray<NSNumber *> *values = [NSMutableArray arrayWithCapacity:chart->value_count];
|
|
3821
|
+
for (size_t i = 0; i < chart->value_count; i++) [values addObject:@(chart->values[i])];
|
|
3822
|
+
bars.values = values;
|
|
3823
|
+
bars.minValue = chart->min_value;
|
|
3824
|
+
bars.maxValue = chart->max_value;
|
|
3825
|
+
bars.autoresizingMask = NSViewWidthSizable;
|
|
3826
|
+
bars.accessibilityElement = NO;
|
|
3827
|
+
[row addSubview:leading];
|
|
3828
|
+
[row addSubview:trailing];
|
|
3829
|
+
[row addSubview:bars];
|
|
3830
|
+
row.accessibilityLabel = NativeSdkCefTrayString(chart->accessibility_label, chart->accessibility_label_len);
|
|
3831
|
+
row.accessibilityRole = NSAccessibilityGroupRole;
|
|
3832
|
+
return row;
|
|
3833
|
+
}
|
|
3834
|
+
|
|
3697
3835
|
void native_sdk_appkit_update_tray_menu(native_sdk_appkit_host_t *host, uint32_t status_item_id, const uint32_t *item_ids, const char *const *labels, const size_t *label_lens, const int *separators, const int *enabled_flags, const char *const *details, const size_t *detail_lens, const int *roles, const char *const *keys, const size_t *key_lens, const uint32_t *modifiers, size_t count) {
|
|
3698
3836
|
NativeSdkChromiumHost *object = (__bridge NativeSdkChromiumHost *)host;
|
|
3699
3837
|
@autoreleasepool {
|
|
@@ -3716,9 +3854,10 @@ void native_sdk_appkit_update_tray_menu(native_sdk_appkit_host_t *host, uint32_t
|
|
|
3716
3854
|
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:label ?: @""
|
|
3717
3855
|
action:@selector(trayMenuItemClicked:)
|
|
3718
3856
|
keyEquivalent:@""];
|
|
3857
|
+
item.representedObject = @(i);
|
|
3719
3858
|
item.tag = (NSInteger)(((uint64_t)status_item_id << 32) | item_ids[i]);
|
|
3720
3859
|
item.target = object;
|
|
3721
|
-
item.enabled = enabled_flags[i] != 0 && (roles[i] == 0 || roles[i] == 4);
|
|
3860
|
+
item.enabled = enabled_flags[i] != 0 && (roles[i] == 0 || roles[i] == 4 || roles[i] == 6);
|
|
3722
3861
|
if (details[i] && detail_lens[i] > 0) {
|
|
3723
3862
|
NSString *detail = [[NSString alloc] initWithBytes:details[i] length:detail_lens[i] encoding:NSUTF8StringEncoding] ?: @"";
|
|
3724
3863
|
if (detail.length > 0 && roles[i] != 0) item.title = [NSString stringWithFormat:@"%@ — %@", label ?: @"", detail];
|
|
@@ -3735,6 +3874,47 @@ void native_sdk_appkit_update_tray_menu(native_sdk_appkit_host_t *host, uint32_t
|
|
|
3735
3874
|
}
|
|
3736
3875
|
}
|
|
3737
3876
|
|
|
3877
|
+
void native_sdk_appkit_update_tray_rich_rows(native_sdk_appkit_host_t *host, uint32_t status_item_id, const native_sdk_appkit_tray_segmented_row_t *segmented_rows, size_t segmented_count, const native_sdk_appkit_tray_metric_row_t *metric_rows, size_t metric_count, const native_sdk_appkit_tray_chart_row_t *chart_rows, size_t chart_count) {
|
|
3878
|
+
NativeSdkChromiumHost *object = (__bridge NativeSdkChromiumHost *)host;
|
|
3879
|
+
@autoreleasepool {
|
|
3880
|
+
NativeSdkChromiumStatusItemEntry *entry = [object statusEntryForId:status_item_id];
|
|
3881
|
+
if (!entry || !entry.menu) return;
|
|
3882
|
+
for (size_t i = 0; i < segmented_count; i++) {
|
|
3883
|
+
NSMenuItem *item = nil;
|
|
3884
|
+
for (NSMenuItem *candidate in entry.menu.itemArray) {
|
|
3885
|
+
if ([candidate.representedObject isEqual:@(segmented_rows[i].row_index)]) { item = candidate; break; }
|
|
3886
|
+
}
|
|
3887
|
+
if (item) {
|
|
3888
|
+
item.action = NULL;
|
|
3889
|
+
item.target = nil;
|
|
3890
|
+
item.view = NativeSdkCefTraySegmentedView(object, status_item_id, segmented_rows[i].options, segmented_rows[i].option_count);
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
for (size_t i = 0; i < metric_count; i++) {
|
|
3894
|
+
NSMenuItem *item = nil;
|
|
3895
|
+
for (NSMenuItem *candidate in entry.menu.itemArray) {
|
|
3896
|
+
if ([candidate.representedObject isEqual:@(metric_rows[i].row_index)]) { item = candidate; break; }
|
|
3897
|
+
}
|
|
3898
|
+
if (item) {
|
|
3899
|
+
item.action = NULL;
|
|
3900
|
+
item.target = nil;
|
|
3901
|
+
item.view = NativeSdkCefTrayMetricView(&metric_rows[i]);
|
|
3902
|
+
}
|
|
3903
|
+
}
|
|
3904
|
+
for (size_t i = 0; i < chart_count; i++) {
|
|
3905
|
+
NSMenuItem *item = nil;
|
|
3906
|
+
for (NSMenuItem *candidate in entry.menu.itemArray) {
|
|
3907
|
+
if ([candidate.representedObject isEqual:@(chart_rows[i].row_index)]) { item = candidate; break; }
|
|
3908
|
+
}
|
|
3909
|
+
if (item) {
|
|
3910
|
+
item.action = NULL;
|
|
3911
|
+
item.target = nil;
|
|
3912
|
+
item.view = NativeSdkCefTrayChartView(&chart_rows[i]);
|
|
3913
|
+
}
|
|
3914
|
+
}
|
|
3915
|
+
}
|
|
3916
|
+
}
|
|
3917
|
+
|
|
3738
3918
|
int native_sdk_appkit_set_window_content_min_size(native_sdk_appkit_host_t *host, uint64_t window_id, double min_width, double min_height) {
|
|
3739
3919
|
NativeSdkChromiumHost *object = (__bridge NativeSdkChromiumHost *)host;
|
|
3740
3920
|
NSWindow *window = object.windows[@(window_id)];
|
|
@@ -3761,18 +3941,20 @@ void native_sdk_appkit_update_tray_title(native_sdk_appkit_host_t *host, uint32_
|
|
|
3761
3941
|
entry.presentationWidth,
|
|
3762
3942
|
entry.presentationTone,
|
|
3763
3943
|
entry.presentationIconOpacity,
|
|
3764
|
-
entry.presentationMonospaced
|
|
3944
|
+
entry.presentationMonospaced,
|
|
3945
|
+
entry.presentationFontSize,
|
|
3946
|
+
entry.presentationFontWeight
|
|
3765
3947
|
);
|
|
3766
3948
|
}
|
|
3767
3949
|
}
|
|
3768
3950
|
|
|
3769
|
-
void native_sdk_appkit_update_tray_presentation(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len, double width, int tone, double icon_opacity, int monospaced) {
|
|
3951
|
+
void native_sdk_appkit_update_tray_presentation(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len, double width, int tone, double icon_opacity, int monospaced, double font_size, int font_weight) {
|
|
3770
3952
|
NativeSdkChromiumHost *object = (__bridge NativeSdkChromiumHost *)host;
|
|
3771
3953
|
@autoreleasepool {
|
|
3772
3954
|
NativeSdkChromiumStatusItemEntry *entry = [object statusEntryForId:status_item_id];
|
|
3773
3955
|
if (!entry) return;
|
|
3774
3956
|
NSString *value = title ? ([[NSString alloc] initWithBytes:title length:title_len encoding:NSUTF8StringEncoding] ?: @"") : @"";
|
|
3775
|
-
NativeSdkCefApplyTrayPresentation(object, entry, value, width, tone, icon_opacity, monospaced != 0);
|
|
3957
|
+
NativeSdkCefApplyTrayPresentation(object, entry, value, width, tone, icon_opacity, monospaced != 0, font_size, font_weight);
|
|
3776
3958
|
}
|
|
3777
3959
|
}
|
|
3778
3960
|
|