Skip to content

Commit

Permalink
Embed all AQGridSelection* pngs
Browse files Browse the repository at this point in the history
  • Loading branch information
0xced authored and AlanQuatermain committed Aug 9, 2010
1 parent 52e6cfb commit aee526a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
24 changes: 24 additions & 0 deletions AQGridView.xcodeproj/project.pbxproj
Expand Up @@ -193,6 +193,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 1DEB921E08733DC00010E9CD /* Build configuration list for PBXNativeTarget "AQGridView" */;
buildPhases = (
DA62444512102F6E007EC097 /* Embed PNGs */,
D2AAC07A0554694100DB518D /* Headers */,
D2AAC07B0554694100DB518D /* Sources */,
D2AAC07C0554694100DB518D /* Frameworks */,
Expand Down Expand Up @@ -224,6 +225,29 @@
};
/* End PBXProject section */

/* Begin PBXShellScriptBuildPhase section */
DA62444512102F6E007EC097 /* Embed PNGs */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 12;
files = (
);
inputPaths = (
"$(SRCROOT)/Resources/AQGridSelection.png",
"$(SRCROOT)/Resources/AQGridSelectionGray.png",
"$(SRCROOT)/Resources/AQGridSelectionGrayBlue.png",
"$(SRCROOT)/Resources/AQGridSelectionGreen.png",
"$(SRCROOT)/Resources/AQGridSelectionRed.png",
);
name = "Embed PNGs";
outputPaths = (
"$(DERIVED_FILES_DIR)/AQGridViewCell_png.h",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = ". \"${SRCROOT}/Scripts/embed_png.sh\"\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
D2AAC07B0554694100DB518D /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down
20 changes: 13 additions & 7 deletions Classes/AQGridViewCell.m
Expand Up @@ -38,7 +38,7 @@
#import "AQGridViewCell+AQGridViewCellPrivate.h"
#import "UIColor+AQGridView.h"
#import <QuartzCore/QuartzCore.h>
#import <objc/runtime.h>
#import "AQGridViewCell_png.h"

@interface AQGridViewCell ()
@property (nonatomic, retain) UIView * contentView;
Expand Down Expand Up @@ -297,31 +297,37 @@ - (void) _beginBackgroundHighlight: (BOOL) highlightOn animated: (BOOL) animated
{
if ( (_cellFlags.usingDefaultSelectedBackgroundView == 1) && (_selectedBackgroundView == nil) )
{
NSString * imageName = @"AQGridSelection.png";
unsigned char * pngBytes = AQGridSelection_png;
NSUInteger pngLength = AQGridSelection_png_len;
switch ( _cellFlags.selectionStyle )
{
case AQGridViewCellSelectionStyleBlue:
default:
break;

case AQGridViewCellSelectionStyleGray:
imageName = @"AQGridSelectionGray.png";
pngBytes = AQGridSelectionGray_png;
pngLength = AQGridSelectionGray_png_len;
break;

case AQGridViewCellSelectionStyleBlueGray:
imageName = @"AQGridSelectionGrayBlue.png";
pngBytes = AQGridSelectionGrayBlue_png;
pngLength = AQGridSelectionGrayBlue_png_len;
break;

case AQGridViewCellSelectionStyleGreen:
imageName = @"AQGridSelectionGreen.png";
pngBytes = AQGridSelectionGreen_png;
pngLength = AQGridSelectionGreen_png_len;
break;

case AQGridViewCellSelectionStyleRed:
imageName = @"AQGridSelectionRed.png";
pngBytes = AQGridSelectionRed_png;
pngLength = AQGridSelectionRed_png_len;
break;
}

_selectedBackgroundView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: imageName]];
NSData *pngData = [NSData dataWithBytesNoCopy: pngBytes length: pngLength freeWhenDone: NO];
_selectedBackgroundView = [[UIImageView alloc] initWithImage: [UIImage imageWithData: pngData]];
_selectedBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
_selectedBackgroundView.contentMode = UIViewContentModeScaleToFill;
}
Expand Down
11 changes: 11 additions & 0 deletions Scripts/embed_png.sh
@@ -0,0 +1,11 @@
#!/bin/bash

PNG_HEADER="${DERIVED_FILES_DIR}/AQGridViewCell_png.h"

rm -f "${PNG_HEADER}"
mkdir -p "${DERIVED_FILES_DIR}"

cd Resources
for png in *; do
xxd -i "$png" >> "${PNG_HEADER}"
done

0 comments on commit aee526a

Please sign in to comment.