Skip to content

Commit

Permalink
Short circuit same-value setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
avaidyam committed Oct 18, 2012
1 parent 12eaffc commit 8d2aa9c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
7 changes: 0 additions & 7 deletions lib/UIKit/TUITableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ typedef enum {
TUITableViewCellStyleDefault,
} TUITableViewCellStyle;

// Identifiers representing a cell's current state.
typedef enum {
TUITableViewCellStateBackground,
TUITableViewCellStateHighlighted,
TUITableViewCellStateSelected
} TUITableViewCellState;

typedef enum {

// The cell has no distinct separator style.
Expand Down
33 changes: 33 additions & 0 deletions lib/UIKit/TUITableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ - (void)setHighlighted:(BOOL)h {
}

- (void)setHighlighted:(BOOL)h animated:(BOOL)animated {
if(_tableViewCellFlags.highlighted == h)
return;

_tableViewCellFlags.highlighted = h;
tui_viewAnimateRedrawConditionally(self, animated);
}
Expand All @@ -331,51 +334,81 @@ - (void)setSelected:(BOOL)s {
}

- (void)setSelected:(BOOL)s animated:(BOOL)animated {
if(_tableViewCellFlags.selected == s)
return;

_tableViewCellFlags.selected = s;
tui_viewAnimateRedrawConditionally(self, animated);
}

- (void)setSeparatorStyle:(TUITableViewCellSeparatorStyle)separatorStyle {
if(_separatorStyle == separatorStyle)
return;

_separatorStyle = separatorStyle;
tui_viewAnimateRedrawConditionally(self, self.animatesAppearanceChanges);
}

- (void)setBackgroundStyle:(TUITableViewCellColorStyle)style {
if(_backgroundStyle == style)
return;

_backgroundStyle = style;
tui_viewAnimateRedrawConditionally(self, self.animatesAppearanceChanges);
}

- (void)setHighlightStyle:(TUITableViewCellColorStyle)style {
if(_highlightStyle == style)
return;

_highlightStyle = style;
tui_viewAnimateRedrawConditionally(self, self.animatesAppearanceChanges);
}

- (void)setSelectionStyle:(TUITableViewCellColorStyle)style {
if(_selectionStyle == style)
return;

_selectionStyle = style;
tui_viewAnimateRedrawConditionally(self, self.animatesAppearanceChanges);
}

- (void)setHighlightColor:(NSColor *)highlightColor {
if(_highlightColor == highlightColor)
return;

_highlightColor = highlightColor;
tui_viewAnimateRedrawConditionally(self, self.animatesAppearanceChanges);
}

- (void)setSelectionColor:(NSColor *)selectionColor {
if(_selectionColor == selectionColor)
return;

_selectionColor = selectionColor;
tui_viewAnimateRedrawConditionally(self, self.animatesAppearanceChanges);
}

- (void)setAlternateBackgroundColor:(NSColor *)alternateColor {
if(_alternateBackgroundColor == alternateColor)
return;

_alternateBackgroundColor = alternateColor;
tui_viewAnimateRedrawConditionally(self, self.animatesAppearanceChanges);
}

- (void)setAlternateHighlightColor:(NSColor *)alternateColor {
if(_alternateHighlightColor == alternateColor)
return;

_alternateHighlightColor = alternateColor;
tui_viewAnimateRedrawConditionally(self, self.animatesAppearanceChanges);
}

- (void)setAlternateSelectionColor:(NSColor *)alternateColor {
if(_alternateSelectionColor == alternateColor)
return;

_alternateSelectionColor = alternateColor;
tui_viewAnimateRedrawConditionally(self, self.animatesAppearanceChanges);
}
Expand Down

0 comments on commit 8d2aa9c

Please sign in to comment.