| 414 outline.outlineTableColumn = column; |
414 outline.outlineTableColumn = column; |
| 415 outline.headerView = NULL; |
415 outline.headerView = NULL; |
| 416 outline.rowSizeStyle = NSTableViewRowSizeStyleDefault; |
416 outline.rowSizeStyle = NSTableViewRowSizeStyleDefault; |
| 417 outline.usesAutomaticRowHeights = YES; |
417 outline.usesAutomaticRowHeights = YES; |
| 418 outline.indentationPerLevel = 0; |
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; |
|
| 428 |
419 |
| 429 outline.style = NSTableViewStyleSourceList; |
420 outline.style = NSTableViewStyleSourceList; |
| 430 |
421 outline.selectionHighlightStyle = NSTableViewSelectionHighlightStyleSourceList; |
| |
422 |
| 431 // Make background transparent so vibrancy shows through |
423 // Make background transparent so vibrancy shows through |
| 432 outline.backgroundColor = [NSColor clearColor]; |
424 //outline.backgroundColor = [NSColor clearColor]; |
| 433 scrollview.drawsBackground = NO; |
425 scrollview.drawsBackground = NO; |
| 434 |
426 |
| 435 scrollview.documentView = outline; |
427 scrollview.documentView = outline; |
| 436 |
428 |
| 437 UiLayout layout = UI_ARGS2LAYOUT(args); |
429 UiLayout layout = UI_ARGS2LAYOUT(args); |
| 523 } |
518 } |
| 524 return [_sections objectAtIndex:index]; |
519 return [_sections objectAtIndex:index]; |
| 525 } |
520 } |
| 526 |
521 |
| 527 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item { |
522 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item { |
| |
523 /* |
| 528 UiSourceListItem *i = item; |
524 UiSourceListItem *i = item; |
| 529 if([[tableColumn identifier] isEqualToString:@"label"]) { |
525 if([[tableColumn identifier] isEqualToString:@"label"]) { |
| 530 return i.label; |
526 return i.label; |
| 531 } |
527 } |
| |
528 */ |
| 532 return nil; |
529 return nil; |
| 533 } |
530 } |
| 534 |
531 |
| 535 - (void)outlineView:(NSOutlineView *)outlineView |
532 - (void)outlineView:(NSOutlineView *)outlineView |
| 536 setObjectValue:(id)object |
533 setObjectValue:(id)object |
| 555 iconView.translatesAutoresizingMaskIntoConstraints = NO; |
552 iconView.translatesAutoresizingMaskIntoConstraints = NO; |
| 556 [cell addSubview:iconView]; |
553 [cell addSubview:iconView]; |
| 557 cell.imageView = iconView; |
554 cell.imageView = iconView; |
| 558 |
555 |
| 559 // Label |
556 // Label |
| 560 NSTextField *textField = [NSTextField labelWithString:@""]; |
557 //NSTextField *textField = [NSTextField labelWithString:@""]; |
| |
558 NSTextField *textField = [[NSTextField alloc] initWithFrame:NSZeroRect]; |
| 561 textField.translatesAutoresizingMaskIntoConstraints = NO; |
559 textField.translatesAutoresizingMaskIntoConstraints = NO; |
| |
560 textField.bezeled = NO; |
| |
561 textField.editable = NO; |
| |
562 textField.drawsBackground = NO; |
| |
563 textField.selectable = NO; |
| |
564 textField.lineBreakMode = NSLineBreakByTruncatingTail; |
| |
565 |
| |
566 |
| 562 [cell addSubview:textField]; |
567 [cell addSubview:textField]; |
| 563 cell.textField = textField; |
568 cell.textField = textField; |
| 564 |
569 |
| 565 // Layout constraints |
570 if([i isSection]) { |
| 566 [NSLayoutConstraint activateConstraints:@[ |
571 NSFont *font = [NSFont boldSystemFontOfSize:[NSFont systemFontSize]*0.85]; |
| 567 [iconView.leadingAnchor constraintEqualToAnchor:cell.leadingAnchor constant:0], |
572 //NSFont *font = [NSFont preferredFontForTextStyle:NSFontTextStyleCaption1 options:@{}]; |
| 568 [iconView.centerYAnchor constraintEqualToAnchor:cell.centerYAnchor], |
573 NSDictionary *attrs = @{ |
| 569 |
574 NSFontAttributeName: font, |
| 570 [textField.leadingAnchor constraintEqualToAnchor:cell.leadingAnchor constant:0], |
575 NSForegroundColorAttributeName: [NSColor tertiaryLabelColor] |
| 571 [textField.centerYAnchor constraintEqualToAnchor:cell.centerYAnchor], |
576 }; |
| 572 [textField.trailingAnchor constraintEqualToAnchor:cell.trailingAnchor constant:0], |
577 textField.attributedStringValue = [[NSAttributedString alloc] initWithString:i.label attributes:attrs]; |
| 573 ]]; |
578 |
| 574 |
579 // Layout constraints |
| 575 textField.stringValue = i.label; |
580 [NSLayoutConstraint activateConstraints:@[ |
| |
581 [iconView.leadingAnchor constraintEqualToAnchor:cell.leadingAnchor constant:0], |
| |
582 [iconView.bottomAnchor constraintEqualToAnchor:cell.bottomAnchor constant:-1], |
| |
583 |
| |
584 [textField.leadingAnchor constraintEqualToAnchor:cell.leadingAnchor constant:0], |
| |
585 [textField.bottomAnchor constraintEqualToAnchor:cell.bottomAnchor constant:-1], |
| |
586 [textField.trailingAnchor constraintEqualToAnchor:cell.trailingAnchor constant:0], |
| |
587 ]]; |
| |
588 } else { |
| |
589 textField.stringValue = i.label; |
| |
590 |
| |
591 // Layout constraints |
| |
592 [NSLayoutConstraint activateConstraints:@[ |
| |
593 [iconView.leadingAnchor constraintEqualToAnchor:cell.leadingAnchor constant:0], |
| |
594 [iconView.centerYAnchor constraintEqualToAnchor:cell.centerYAnchor], |
| |
595 |
| |
596 [textField.leadingAnchor constraintEqualToAnchor:cell.leadingAnchor constant:0], |
| |
597 [textField.centerYAnchor constraintEqualToAnchor:cell.centerYAnchor], |
| |
598 [textField.trailingAnchor constraintEqualToAnchor:cell.trailingAnchor constant:0], |
| |
599 ]]; |
| |
600 } |
| 576 |
601 |
| 577 return cell; |
602 return cell; |
| 578 } |
603 } |
| 579 |
604 |
| 580 - (NSTableRowView *) outlineView:(NSOutlineView *) outlineView |
605 - (NSTableRowView *) outlineView:(NSOutlineView *) outlineView |
| 586 - (BOOL) outlineView:(NSOutlineView *) outlineView |
611 - (BOOL) outlineView:(NSOutlineView *) outlineView |
| 587 shouldSelectItem:(id)item |
612 shouldSelectItem:(id)item |
| 588 { |
613 { |
| 589 UiSourceListItem *i = item; |
614 UiSourceListItem *i = item; |
| 590 return [i isSection] ? NO : YES; |
615 return [i isSection] ? NO : YES; |
| |
616 } |
| |
617 |
| |
618 - (CGFloat) outlineView:(NSOutlineView *) outlineView |
| |
619 heightOfRowByItem:(id) item |
| |
620 { |
| |
621 UiSourceListItem *i = item; |
| |
622 CGFloat rowHeight = outlineView.rowHeight; |
| |
623 if([i isSection]) { |
| |
624 if(i.index == 0) { |
| |
625 rowHeight -= 12; |
| |
626 } else { |
| |
627 rowHeight += 4; |
| |
628 } |
| |
629 } |
| |
630 return rowHeight; |
| 591 } |
631 } |
| 592 |
632 |
| 593 - (void) outlineViewSelectionDidChange:(NSNotification *) notification { |
633 - (void) outlineViewSelectionDidChange:(NSNotification *) notification { |
| 594 UiEvent event; |
634 UiEvent event; |
| 595 event.obj = _obj; |
635 event.obj = _obj; |
| 688 [subview.identifier isEqualToString:NSOutlineViewShowHideButtonKey]) |
728 [subview.identifier isEqualToString:NSOutlineViewShowHideButtonKey]) |
| 689 { |
729 { |
| 690 NSRect frame = subview.frame; |
730 NSRect frame = subview.frame; |
| 691 frame.origin.x = self.bounds.size.width - frame.size.width - 16.0; |
731 frame.origin.x = self.bounds.size.width - frame.size.width - 16.0; |
| 692 subview.frame = frame; |
732 subview.frame = frame; |
| |
733 |
| |
734 if(!_hover) { |
| |
735 subview.hidden = YES; |
| |
736 } |
| |
737 |
| |
738 if(subview != _disclosureButton) { |
| |
739 // init disclosure button |
| |
740 _disclosureButton = (NSButton*)subview; |
| |
741 if ([subview isKindOfClass:[NSButton class]]) { |
| |
742 NSButton *button = (NSButton*)subview; |
| |
743 button.contentTintColor = [NSColor tertiaryLabelColor]; |
| |
744 } |
| |
745 } |
| |
746 |
| |
747 |
| 693 } else if ([subview.identifier isEqualToString:@"cell"]) { |
748 } else if ([subview.identifier isEqualToString:@"cell"]) { |
| 694 NSRect frame = subview.frame; |
749 NSRect frame = subview.frame; |
| 695 frame.origin.x = 16; |
750 frame.origin.x = 16; |
| 696 subview.frame = frame; |
751 subview.frame = frame; |
| 697 } |
752 } |
| 698 } |
753 } |
| 699 } |
754 } |
| 700 |
755 |
| |
756 - (void)updateTrackingAreas { |
| |
757 [super updateTrackingAreas]; |
| |
758 if(_trackingArea != nil) { |
| |
759 [self removeTrackingArea:_trackingArea]; |
| |
760 } |
| |
761 _trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds |
| |
762 options:NSTrackingMouseEnteredAndExited | |
| |
763 NSTrackingActiveInActiveApp | |
| |
764 NSTrackingInVisibleRect |
| |
765 owner:self |
| |
766 userInfo:nil]; |
| |
767 [self addTrackingArea:_trackingArea]; |
| |
768 } |
| |
769 |
| |
770 - (void)mouseEntered:(NSEvent *)event { |
| |
771 _hover = YES; |
| |
772 _disclosureButton.hidden = NO; |
| |
773 } |
| |
774 |
| |
775 - (void)mouseExited:(NSEvent *)event { |
| |
776 _hover = NO; |
| |
777 _disclosureButton.hidden = YES; |
| |
778 } |
| |
779 |
| 701 @end |
780 @end |