Skip to content

Commit

Permalink
Update Detail Items (#14)
Browse files Browse the repository at this point in the history
Restructuree a bit based on things that we are specifically interested in per type.
- Added UTI for Data
- Added Compression for Data and Images
- Added Data Size for Data
- Removed rendition name where it didn't make sense (Data and Color)
- Moved to macOS 12 to support byte formatting
  • Loading branch information
dmaclach authored Aug 11, 2024
1 parent 0f81b62 commit 66946db
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Samra.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15.1;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1;
PRODUCT_BUNDLE_IDENTIFIER = com.serena.Samra;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -556,7 +556,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15.1;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1;
PRODUCT_BUNDLE_IDENTIFIER = com.serena.Samra;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
68 changes: 48 additions & 20 deletions Samra/Backend/DetailItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,44 +59,72 @@ struct DetailItemSection: Hashable {
}

static func from(rendition: Rendition) -> [DetailItemSection] {
var items = [
DetailItemSection(sectionHeader: "Name", items: [
DetailItem(primaryText: "Rendition Name", secondaryText: rendition.cuiRend.name()),
DetailItem(primaryText: "Lookup Name", secondaryText: rendition.namedLookup.name),
])
]

switch rendition.representation {
case .color(let cgColor):
let nsColor = NSColor(cgColor: cgColor)?.usingColorSpace(.deviceRGB)
let cuiRend = rendition.cuiRend
let namedLookup = rendition.namedLookup
let diskSize = cuiRend.srcData.count.formatted(.byteCount(style:.memory,
spellsOutZero: true,
includesActualByteCount: true))
let sizeOnDisk = DetailItem(primaryText: "Size On Disk", secondaryText: diskSize)
var items: [DetailItemSection] = []

switch rendition.type {
case .rawData:
items.append(DetailItemSection(sectionHeader: "Base Attributes", items: [
DetailItem(primaryText: "Name", secondaryText: namedLookup.name),
sizeOnDisk,
DetailItem(primaryText: "Compression", secondaryText:cuiRend.bitmapEncoding())
]))
var details : [DetailItem] = []
if let data = cuiRend.data() {
let size = data.count.formatted(.byteCount(style:.memory,
spellsOutZero: true,
includesActualByteCount: true))
details.append(DetailItem(primaryText: "Data Length", secondaryText:size))

}
if let uti = cuiRend.utiType() {
details.append(DetailItem(primaryText: "UTI", secondaryText:uti))
}
items.append(DetailItemSection(sectionHeader: "Data Attributes", items: details))

case .color:
items.append(DetailItemSection(sectionHeader: "Base Attributes", items: [
DetailItem(primaryText: "Name", secondaryText: cuiRend.name()),
sizeOnDisk,
]))
let cgColor = cuiRend.cgColor().takeUnretainedValue()
let nsColor = NSColor(cgColor:cgColor)?.usingColorSpace(.deviceRGB)
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
var alpha: CGFloat = 0
nsColor?.getRed(&red, green: &green, blue: &blue, alpha: &alpha)

items.append(DetailItemSection(sectionHeader: "Color Info", items: [
items.append(DetailItemSection(sectionHeader: "Color Attributes", items: [
DetailItem(primaryText: "Red", secondaryText: Int(red * 255)),
DetailItem(primaryText: "Blue", secondaryText: Int(blue * 255)),
DetailItem(primaryText: "Green", secondaryText: Int(green * 255)),
DetailItem(primaryText: "Blue", secondaryText: Int(blue * 255)),
]))

default:
break
}

if rendition.type != .color {
let size = rendition.cuiRend.unslicedSize()
items.append(DetailItemSection(sectionHeader: "Base Attributes", items: [
DetailItem(primaryText: "Rendition Name", secondaryText: cuiRend.name()),
DetailItem(primaryText: "Lookup Name", secondaryText: namedLookup.name),
sizeOnDisk,
DetailItem(primaryText: "Compression", secondaryText:cuiRend.bitmapEncoding())
]))
let size = cuiRend.unslicedSize()
items.append(DetailItemSection(sectionHeader: "Dimensions", items: [
DetailItem(primaryText: "Width", secondaryText: size.width),
DetailItem(primaryText: "Height", secondaryText: size.height),
DetailItem(primaryText: "Scale", secondaryText: rendition.cuiRend.scale())
DetailItem(primaryText: "Scale", secondaryText: cuiRend.scale())
]))
}

let key = rendition.namedLookup.key
let key = namedLookup.key
items.append(DetailItemSection(sectionHeader: "Rendition Information", items: [
DetailItem(primaryText: "Display Gamut", secondaryText: Rendition.DisplayGamut(key)),
DetailItem(primaryText: "Appearance", secondaryText: rendition.namedLookup.appearance),
DetailItem(primaryText: "Appearance", secondaryText: namedLookup.appearance),
DetailItem(primaryText: "Idiom", secondaryText: Rendition.Idiom(key))
]))

Expand Down

0 comments on commit 66946db

Please sign in to comment.