| 411 NSOutlineView *outline = [[NSOutlineView alloc]init]; |
411 NSOutlineView *outline = [[NSOutlineView alloc]init]; |
| 412 NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:@"label"]; |
412 NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:@"label"]; |
| 413 [outline addTableColumn:column]; |
413 [outline addTableColumn:column]; |
| 414 outline.outlineTableColumn = column; |
414 outline.outlineTableColumn = column; |
| 415 outline.headerView = NULL; |
415 outline.headerView = NULL; |
| |
416 outline.rowSizeStyle = NSTableViewRowSizeStyleDefault; |
| |
417 outline.usesAutomaticRowHeights = YES; |
| |
418 outline.indentationPerLevel = 0; |
| |
419 outline.indentationMarkerFollowsCell = NO; |
| |
420 |
| |
421 outline.floatsGroupRows = NO; |
| |
422 outline.indentationPerLevel = 0.0; |
| |
423 outline.indentationMarkerFollowsCell = NO; |
| |
424 outline.selectionHighlightStyle = NSTableViewSelectionHighlightStyleRegular; |
| |
425 |
| |
426 // Hide the disclosure triangle |
| |
427 //outline.disclosureButtonImage = nil; |
| 416 |
428 |
| 417 outline.style = NSTableViewStyleSourceList; |
429 outline.style = NSTableViewStyleSourceList; |
| 418 |
430 |
| 419 // Make background transparent so vibrancy shows through |
431 // Make background transparent so vibrancy shows through |
| 420 outline.backgroundColor = [NSColor clearColor]; |
432 outline.backgroundColor = [NSColor clearColor]; |
| 442 data.onbuttonclick = args->onbuttonclick; |
454 data.onbuttonclick = args->onbuttonclick; |
| 443 data.onactivatedata = args->onbuttonclickdata; |
455 data.onactivatedata = args->onbuttonclickdata; |
| 444 [data update:-1]; |
456 [data update:-1]; |
| 445 |
457 |
| 446 outline.dataSource = data; |
458 outline.dataSource = data; |
| 447 //outline.delegate = data; |
459 outline.delegate = data; |
| 448 |
460 |
| 449 objc_setAssociatedObject(outline, "ui_datasource", data, OBJC_ASSOCIATION_RETAIN); |
461 objc_setAssociatedObject(outline, "ui_datasource", data, OBJC_ASSOCIATION_RETAIN); |
| 450 |
462 |
| 451 return (__bridge void*)scrollview; |
463 return (__bridge void*)scrollview; |
| 452 } |
464 } |
| 517 - (void)outlineView:(NSOutlineView *)outlineView |
529 - (void)outlineView:(NSOutlineView *)outlineView |
| 518 setObjectValue:(id)object |
530 setObjectValue:(id)object |
| 519 forTableColumn:(NSTableColumn *)tableColumn |
531 forTableColumn:(NSTableColumn *)tableColumn |
| 520 byItem:(id)item { |
532 byItem:(id)item { |
| 521 |
533 |
| |
534 } |
| |
535 |
| |
536 // NSOutlineViewDelegate implementation |
| |
537 |
| |
538 - (NSView *)outlineView:(NSOutlineView *)outlineView |
| |
539 viewForTableColumn:(NSTableColumn *)tableColumn |
| |
540 item:(id)item { |
| |
541 UiSourceListItem *i = item; |
| |
542 |
| |
543 NSTableCellView *cell = [[NSTableCellView alloc] init]; |
| |
544 cell.identifier = @"cell"; |
| |
545 // Icon |
| |
546 NSImageView *iconView = [[NSImageView alloc] initWithFrame:NSZeroRect]; |
| |
547 iconView.translatesAutoresizingMaskIntoConstraints = NO; |
| |
548 //[cell addSubview:iconView]; |
| |
549 //cell.imageView = iconView; |
| |
550 |
| |
551 // Label |
| |
552 NSTextField *textField = [NSTextField labelWithString:@""]; |
| |
553 textField.translatesAutoresizingMaskIntoConstraints = NO; |
| |
554 [cell addSubview:textField]; |
| |
555 cell.textField = textField; |
| |
556 |
| |
557 // Layout constraints |
| |
558 [NSLayoutConstraint activateConstraints:@[ |
| |
559 //[iconView.leadingAnchor constraintEqualToAnchor:cell.leadingAnchor constant:0], |
| |
560 //[iconView.centerYAnchor constraintEqualToAnchor:cell.centerYAnchor], |
| |
561 //[iconView.widthAnchor constraintEqualToConstant:0], |
| |
562 //[iconView.heightAnchor constraintEqualToConstant:0], |
| |
563 |
| |
564 [textField.leadingAnchor constraintEqualToAnchor:cell.leadingAnchor constant:0], |
| |
565 [textField.centerYAnchor constraintEqualToAnchor:cell.centerYAnchor], |
| |
566 [textField.trailingAnchor constraintEqualToAnchor:cell.trailingAnchor constant:0], |
| |
567 ]]; |
| |
568 |
| |
569 textField.stringValue = i.label; |
| |
570 |
| |
571 return cell; |
| |
572 } |
| |
573 |
| |
574 - (NSTableRowView *) outlineView:(NSOutlineView *) outlineView |
| |
575 rowViewForItem:(id) item { |
| |
576 UiSourceListRow *row = [[UiSourceListRow alloc]init]; |
| |
577 return row; |
| 522 } |
578 } |
| 523 |
579 |
| 524 @end |
580 @end |
| 525 |
581 |
| 526 @implementation UiSourceListItem |
582 @implementation UiSourceListItem |
| 575 } |
631 } |
| 576 } |
632 } |
| 577 |
633 |
| 578 @end |
634 @end |
| 579 |
635 |
| |
636 @implementation UiSourceListRow |
| |
637 |
| |
638 - (void)layout { |
| |
639 [super layout]; |
| |
640 |
| |
641 for (NSView *subview in self.subviews) { |
| |
642 if ([subview.identifier isEqualToString:NSOutlineViewDisclosureButtonKey] || |
| |
643 [subview.identifier isEqualToString:NSOutlineViewShowHideButtonKey]) |
| |
644 { |
| |
645 NSRect frame = subview.frame; |
| |
646 frame.origin.x = self.bounds.size.width - frame.size.width - 16.0; |
| |
647 subview.frame = frame; |
| |
648 } else if ([subview.identifier isEqualToString:@"cell"]) { |
| |
649 NSRect frame = subview.frame; |
| |
650 frame.origin.x = 16; |
| |
651 subview.frame = frame; |
| |
652 } |
| |
653 } |
| |
654 } |
| |
655 |
| |
656 @end |