Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
RBSplitSubview(RB___SubviewAdditions) Category Reference

#include <RBSplitViewPrivateDefines.h>

Instance Methods

(void) - RB___setHidden:
 
(animationData *) - RB___animationData:resize:
 
(void) - RB___stepAnimation
 
(BOOL) - RB___stopAnimation
 
(CGFloat) - RB___visibleDimension
 
(CGFloat) - RB___setMinAndMaxTo:savingMin:andMax:
 
(CGFloat) - RB___collapse
 
(CGFloat) - RB___expandAndSetToMinimum:
 
(void) - RB___finishCollapse:withFraction:
 
(void) - RB___finishExpand:withFraction:
 
(void) - RB___setFrameSize:withFraction:
 
(void) - RB___setFrame:withFraction:notify:
 
(double) - RB___fraction
 
(void) - RB___copyIntoCache:
 
(void) - RB___updateFromCache:withTotalDimension:
 
(BOOL) - RB___clearResponder
 

Detailed Description

Definition at line 620 of file RBSplitSubview.m.

Method Documentation

◆ RB___animationData:resize:

- (animationData *) RB___animationData: (BOOL) start
resize: (BOOL) resize 

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

631 :(BOOL)start resize:(BOOL)resize {
632 if (currentAnimation&&(currentAnimation->owner!=self)) {
633// There already is an animation in progress on some other subview.
634 return nil;
635 }
636 if (start) {
637// We want to start (or restart) an animation.
638 RBSplitView* sv = [self splitView];
639 if (sv) {
640 CGFloat dim = [self dimension];
641// First assume the default time, then ask the delegate.
642 NSTimeInterval total = dim*(0.2/150.0);
643 id delegate = [sv delegate];
644 if ([delegate respondsToSelector:@selector(splitView:willAnimateSubview:withDimension:)]) {
645 total = [delegate splitView:sv willAnimateSubview:self withDimension:dim];
646 }
647// No use animating anything shorter than the frametime.
648 if (total>FRAMETIME) {
649 if (!currentAnimation) {
650 currentAnimation = (animationData*)malloc(sizeof(animationData));
651 }
652 if (currentAnimation) {
653 currentAnimation->owner = self;
657 currentAnimation->collapsing = ![self isCollapsed];
659 currentAnimation->finishTime = [NSDate timeIntervalSinceReferenceDate]+total;
660 currentAnimation->resizing = resize;
661 [sv RB___setDragging:YES];
662 }
663 } else if (currentAnimation) {
664 free(currentAnimation);
665 currentAnimation = NULL;
666 }
667 }
668 }
669 return currentAnimation;
670}
return self
return nil
static animationData * currentAnimation
#define FRAMETIME
IBOutlet id delegate
Definition RBSplitView.h:25
void RB___setDragging:(BOOL flag)

◆ RB___clearResponder

- (BOOL) RB___clearResponder

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

796 {
797 NSWindow* window = [self window];
798 if (window) {
799 NSView* responder = (NSView*)[window firstResponder];
800 if (responder&&[responder respondsToSelector:@selector(isDescendantOf:)]) {
801 if ([responder isDescendantOf:self]) {
802 if ([window makeFirstResponder:nil]) {
803 [responder display];
804 return YES;
805 }
806 }
807 }
808 }
809 return NO;
810}

◆ RB___collapse

- (CGFloat) RB___collapse

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

814 {
815 CGFloat result = 0.0;
816 if (![self isCollapsed]) {
817 RBSplitView* sv = [self splitView];
818 if (sv&&[self canCollapse]) {
819 [self RB___clearResponder];
820 NSRect frame = [self frame];
821 BOOL ishor = [sv isHorizontal];
822 result = DIM(frame.size);
823// For collapsed views, fraction will contain the fraction of the dimension previously occupied
824 DIM(frame.size) = 0.0;
825 [self RB___finishCollapse:frame withFraction:result/[sv RB___dimensionWithoutDividers]];
826 }
827 }
828 return -result;
829}
#define DIM(x)
CGFloat RB___dimensionWithoutDividers()
BOOL isHorizontal
Definition RBSplitView.h:33

◆ RB___copyIntoCache:

- (void) RB___copyIntoCache: (subviewCache*) cache

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

746 :(subviewCache*)cache {
747 cache->sub = self;
748 cache->rect = [self frame];
749 cache->size = [self RB___visibleDimension];
750 cache->fraction = fraction;
751 cache->constrain = NO;
752}

◆ RB___expandAndSetToMinimum:

- (CGFloat) RB___expandAndSetToMinimum: (BOOL) setToMinimum

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

849 :(BOOL)setToMinimum {
850 CGFloat result = 0.0;
851 RBSplitView* sv = [self splitView];
852 if (sv&&[self isCollapsed]) {
853 NSRect frame = [super frame];
854 double frac = fraction;
855 BOOL ishor = [sv isHorizontal];
856 if (setToMinimum) {
857 result = DIM(frame.size) = minDimension;
858 } else {
859 result = [sv RB___dimensionWithoutDividers]*frac;
860// We need to apply a compensation factor for proportional resizing in adjustSubviews.
861 CGFloat newdim = floor((frac>=1.0)?result:result/(1.0-frac));
862 DIM(frame.size) = newdim;
863 result = floor(result);
864 }
865 [self RB___finishExpand:frame withFraction:0.0];
866 }
867 return result;
868}

◆ RB___finishCollapse:withFraction:

- (void) RB___finishCollapse: (NSRect) rect
withFraction: (double) value 

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

833 :(NSRect)rect withFraction:(double)value {
834 RBSplitView* sv = [self splitView];
835 BOOL finish = [self RB___stopAnimation];
836 [self RB___setFrame:rect withFraction:value notify:YES];
837 [sv RB___setMustClearFractions];
838 if (finish) {
839 [self display];
840 }
841 id delegate = [sv delegate];
842 if ([delegate respondsToSelector:@selector(splitView:didCollapse:)]) {
843 [delegate splitView:sv didCollapse:self];
844 }
845}

◆ RB___finishExpand:withFraction:

- (void) RB___finishExpand: (NSRect) rect
withFraction: (double) value 

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

872 :(NSRect)rect withFraction:(double)value {
873 RBSplitView* sv = [self splitView];
874 BOOL finish = [self RB___stopAnimation];
875 [self RB___setFrame:rect withFraction:value notify:YES];
876 [sv RB___setMustClearFractions];
877 if (finish) {
878 [self display];
879 }
880 id delegate = [sv delegate];
881 if ([delegate respondsToSelector:@selector(splitView:didExpand:)]) {
882 [delegate splitView:sv didExpand:self];
883 }
884}

◆ RB___fraction

- (double) RB___fraction

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

917 {
918 return fraction;
919}

◆ RB___setFrame:withFraction:notify:

- (void) RB___setFrame: (NSRect) rect
withFraction: (double) value
notify: (BOOL) notify 

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

888 :(NSRect)rect withFraction:(double)value notify:(BOOL)notify {
889 RBSplitView* sv = [self splitView];
890 id delegate = nil;
891 if (notify) {
892 delegate = [sv delegate];
893// If the delegate method isn't implemented, we ignore the delegate altogether.
894 if ([delegate respondsToSelector:@selector(splitView:changedFrameOfSubview:from:to:)]) {
895// If the rects are equal, the delegate isn't called.
896 if (NSEqualRects(previous,rect)) {
897 delegate = nil;
898 }
899 } else {
900 delegate = nil;
901 }
902 }
903 [sv setMustAdjust];
904 [self setFrame:rect];
905 fraction = value;
906 [delegate splitView:sv changedFrameOfSubview:self from:previous to:rect];
907 previous = delegate?rect:NSZeroRect;
908}

◆ RB___setFrameSize:withFraction:

- (void) RB___setFrameSize: (NSSize) size
withFraction: (double) value 

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

910 :(NSSize)size withFraction:(double)value {
911 [[self splitView] setMustAdjust];
912 [self setFrameSize:size];
913 fraction = value;
914}
voidpf void uLong size
Definition ioapi.h:134

◆ RB___setHidden:

- (void) RB___setHidden: (BOOL) flag

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

623 :(BOOL)flag {
624 [super setHidden:flag];
625}

◆ RB___setMinAndMaxTo:savingMin:andMax:

- (CGFloat) RB___setMinAndMaxTo: (CGFloat) value
savingMin: (CGFloat*) oldmin
andMax: (CGFloat*) oldmax 

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

780 :(CGFloat)value savingMin:(CGFloat*)oldmin andMax:(CGFloat*)oldmax {
781 *oldmin = [self minDimension];
782 *oldmax = [self maxDimension];
783 if (value<*oldmin) {
784 value = *oldmin;
785 }
786 if (value>*oldmax) {
787 value = *oldmax;
788 }
789 minDimension = maxDimension = value;
790 return value;
791}

◆ RB___stepAnimation

- (void) RB___stepAnimation

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

673 {
674 NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
675 animationData* anim = [self RB___animationData:NO resize:NO];
676 if (anim) {
677 RBSplitView* sv = [self splitView];
678 NSTimeInterval remain = anim->finishTime-now;
679 NSRect frame = [self frame];
680 BOOL ishor = [sv isHorizontal];
681// Continuing animation only makes sense if we still have at least FRAMETIME available.
682 if (remain>=FRAMETIME) {
683 CGFloat avg = anim->elapsedTime;
684// We try to keep a record of how long it takes, on the average, to resize and adjust
685// one animation frame.
686 if (anim->stepsDone) {
687 avg /= anim->stepsDone;
688 }
689 NSTimeInterval delay = MIN(0.0,FRAMETIME-avg);
690// We adjust the new dimension proportionally to how much of the designated time has passed.
691 CGFloat dim = floor(anim->dimension*(remain-avg)/anim->totalTime);
692 if (dim>4.0) {
693 if (!anim->collapsing) {
694 dim = anim->dimension-dim;
695 }
696 DIM(frame.size) = dim;
697 [self RB___setFrame:frame withFraction:0.0 notify:NO];
698 [sv adjustSubviews];
699 [self display];
700 anim->elapsedTime += [NSDate timeIntervalSinceReferenceDate]-now;
701 ++anim->stepsDone;
702// Schedule a timer to do the next animation step.
703 [self performSelector:@selector(RB___stepAnimation) withObject:nil afterDelay:delay inModes:[NSArray arrayWithObjects:NSDefaultRunLoopMode,NSModalPanelRunLoopMode,
704 NSEventTrackingRunLoopMode,nil]];
705 return;
706 }
707 }
708// We're finished, either collapse or expand entirely now.
709 if (anim->collapsing) {
710 DIM(frame.size) = 0.0;
711 [self RB___finishCollapse:frame withFraction:anim->dimension/[sv RB___dimensionWithoutDividers]];
712 } else {
713 CGFloat savemin,savemax;
714 CGFloat dim = [self RB___setMinAndMaxTo:anim->dimension savingMin:&savemin andMax:&savemax];
715 DIM(frame.size) = dim;
716 [self RB___finishExpand:frame withFraction:0.0];
717 minDimension = savemin;
718 maxDimension = savemax;
719 }
720 }
721}
#define MIN(A, B)
Definition OOMaths.h:111
void adjustSubviews()

◆ RB___stopAnimation

- (BOOL) RB___stopAnimation

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

725 {
727 [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(RB___stepAnimation) object:nil];
728 free(currentAnimation);
729 currentAnimation = NULL;
730 [[self splitView] RB___setDragging:NO];
731 return YES;
732 }
733 return NO;
734}

◆ RB___updateFromCache:withTotalDimension:

- (void) RB___updateFromCache: (subviewCache*) cache
withTotalDimension: (CGFloat) value 

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

754 :(subviewCache*)cache withTotalDimension:(CGFloat)value {
755 CGFloat dim = [self RB___visibleDimension];
756 if (cache->size>=1.0) {
757// New state is not collapsed.
758 if (dim>=1.0) {
759// Old state was not collapsed, so we just change the frame.
760 [self RB___setFrame:cache->rect withFraction:cache->fraction notify:YES];
761 } else {
762// Old state was collapsed, so we expand it.
763 [self RB___finishExpand:cache->rect withFraction:cache->fraction];
764 }
765 } else {
766// New state is collapsed.
767 if (dim>=1.0) {
768// Old state was not collapsed, so we clear first responder and change the frame.
769 [self RB___clearResponder];
770 [self RB___finishCollapse:cache->rect withFraction:dim/value];
771 } else {
772// It was collapsed already, but the frame may have changed, so we set it.
773 [self RB___setFrame:cache->rect withFraction:cache->fraction notify:YES];
774 }
775 }
776}

◆ RB___visibleDimension

- (CGFloat) RB___visibleDimension

Extends class RBSplitSubview.

Definition at line 16 of file RBSplitSubview.m.

738 {
739 BOOL ishor = [self splitViewIsHorizontal];
740 NSRect frame = [self frame];
741 return MAX(0.0,DIM(frame.size));
742}
#define MAX(A, B)
Definition OOMaths.h:114

The documentation for this category was generated from the following files: