Skip to content

Commit

Permalink
ui: Add Lut structures.
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin42 committed Jan 25, 2025
1 parent 44d95fa commit f8bd1ab
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 15 deletions.
14 changes: 14 additions & 0 deletions osx/PhotoBook/PhotoBook.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@
73AC50142D44FAB9001E19C8 /* CollagesGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73AC50132D44FAB2001E19C8 /* CollagesGrid.swift */; };
73AC50162D44FAC3001E19C8 /* CollagesGridModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73AC50152D44FABE001E19C8 /* CollagesGridModel.swift */; };
73AC501B2D4500A2001E19C8 /* CollageItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73AC501A2D4500A0001E19C8 /* CollageItem.mm */; };
73AC501E2D452AF9001E19C8 /* LutItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 73AC501D2D452AF6001E19C8 /* LutItem.mm */; };
73AC50202D452B04001E19C8 /* LutGrid.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73AC501F2D452B00001E19C8 /* LutGrid.swift */; };
73AC50222D452B0D001E19C8 /* LutGridModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73AC50212D452B07001E19C8 /* LutGridModel.swift */; };
73C4ECA22AA0C0E1006C4108 /* PhotoBookApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73C4ECA12AA0C0E1006C4108 /* PhotoBookApp.swift */; };
73C4ECA42AA0C0E1006C4108 /* DashboardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73C4ECA32AA0C0E1006C4108 /* DashboardView.swift */; };
73C4ECA62AA0C0E3006C4108 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 73C4ECA52AA0C0E3006C4108 /* Assets.xcassets */; };
Expand Down Expand Up @@ -850,6 +853,10 @@
73AC50152D44FABE001E19C8 /* CollagesGridModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollagesGridModel.swift; sourceTree = "<group>"; };
73AC50192D450093001E19C8 /* CollageItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CollageItem.h; sourceTree = "<group>"; };
73AC501A2D4500A0001E19C8 /* CollageItem.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CollageItem.mm; sourceTree = "<group>"; };
73AC501C2D452AEB001E19C8 /* LutItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LutItem.h; sourceTree = "<group>"; };
73AC501D2D452AF6001E19C8 /* LutItem.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LutItem.mm; sourceTree = "<group>"; };
73AC501F2D452B00001E19C8 /* LutGrid.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LutGrid.swift; sourceTree = "<group>"; };
73AC50212D452B07001E19C8 /* LutGridModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LutGridModel.swift; sourceTree = "<group>"; };
73C4EC9E2AA0C0E1006C4108 /* PhotoBook.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PhotoBook.app; sourceTree = BUILT_PRODUCTS_DIR; };
73C4ECA12AA0C0E1006C4108 /* PhotoBookApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoBookApp.swift; sourceTree = "<group>"; };
73C4ECA32AA0C0E1006C4108 /* DashboardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1664,6 +1671,10 @@
73C4ECA02AA0C0E1006C4108 /* PhotoBook */ = {
isa = PBXGroup;
children = (
73AC50212D452B07001E19C8 /* LutGridModel.swift */,
73AC501F2D452B00001E19C8 /* LutGrid.swift */,
73AC501D2D452AF6001E19C8 /* LutItem.mm */,
73AC501C2D452AEB001E19C8 /* LutItem.h */,
73AC501A2D4500A0001E19C8 /* CollageItem.mm */,
73AC50192D450093001E19C8 /* CollageItem.h */,
73AC50152D44FABE001E19C8 /* CollagesGridModel.swift */,
Expand Down Expand Up @@ -1892,9 +1903,11 @@
73AC50162D44FAC3001E19C8 /* CollagesGridModel.swift in Sources */,
739DA5E32CDA98A800CB0B58 /* ColorExtension.swift in Sources */,
73AC50142D44FAB9001E19C8 /* CollagesGrid.swift in Sources */,
73AC501E2D452AF9001E19C8 /* LutItem.mm in Sources */,
73D02E5C2D18A2C50090476A /* ProjectManagementService.mm in Sources */,
73049E212C160EA9009EA667 /* PhotoBook-Bridging-Header.m in Sources */,
732A622C2D1CBC550012CB8A /* NewProjectDialog.swift in Sources */,
73AC50202D452B04001E19C8 /* LutGrid.swift in Sources */,
73AC50102D4040FF001E19C8 /* MediaList.swift in Sources */,
732A62282D1CBBDF0012CB8A /* DeleteProjectDialog.swift in Sources */,
73AC4FEC2D3B84C9001E19C8 /* MediaItem.swift in Sources */,
Expand All @@ -1906,6 +1919,7 @@
73C4ECA42AA0C0E1006C4108 /* DashboardView.swift in Sources */,
73023A3C2CD7B9FD005EA3CF /* PhotobookUIListener.swift in Sources */,
73AC4FF92D3BAFE5001E19C8 /* FrontendImageResources.mm in Sources */,
73AC50222D452B0D001E19C8 /* LutGridModel.swift in Sources */,
73AC4FFF2D3BB3BC001E19C8 /* UnstagedImagesRepo.mm in Sources */,
73C4ECA22AA0C0E1006C4108 /* PhotoBookApp.swift in Sources */,
73AC500E2D403D7C001E19C8 /* UnstagedPhotoLine.swift in Sources */,
Expand Down
7 changes: 0 additions & 7 deletions osx/PhotoBook/PhotoBook/CollageItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
// Created by Cosmin Mihai on 25.01.2025.
//

//
// FrontendImageResources.h
// PhotoBook
//
// Created by Cosmin Mihai on 18.01.2025.
//

#ifndef CollageItem_h
#define CollageItem_h

Expand Down
45 changes: 45 additions & 0 deletions osx/PhotoBook/PhotoBook/LutGrid.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// LutGrid.swift
// PhotoBook
//
// Created by Cosmin Mihai on 25.01.2025.
//

import SwiftUI

struct LutGrid: View
{
@State private var frameSize:CGSize
@ObservedObject var model: LutGridModel

private var tabViewRatio = 0.5

init(frameSize: CGSize, model: LutGridModel)
{
self.frameSize = frameSize
self.model = model
}

var body: some View {
ScrollView {
LazyVGrid(columns: model.columns, spacing: 10) {
ForEach(self.model.images, id: \.self) { item in
if let fileName = item.path
{
if let nsImage = NSImage(contentsOfFile: fileName) {
Image(nsImage: nsImage)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(height: 80)
} else {
Text("Image not found")
}
}
}
}
.frame(width: frameSize.width * tabViewRatio)
}
.frame(alignment:.leading)
.tag(2)
}
}
26 changes: 26 additions & 0 deletions osx/PhotoBook/PhotoBook/LutGridModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// LutGridModel.swift
// PhotoBook
//
// Created by Cosmin Mihai on 25.01.2025.
//

import SwiftUI

class LutGridModel: ObservableObject
{
@State var photobook: Photobook
@Published public var images:[LutItem] = []

// TODO: Do a flexible calculation here
@Published public var columns = [
GridItem(.flexible()),
GridItem(.flexible()),
GridItem(.flexible())
]

init(photobook: Photobook)
{
_photobook = State(initialValue: photobook)
}
}
25 changes: 25 additions & 0 deletions osx/PhotoBook/PhotoBook/LutItem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// LutItem.h
// PhotoBook
//
// Created by Cosmin Mihai on 25.01.2025.
//

#ifndef LutItem_h
#define LutItem_h

#import <Foundation/Foundation.h>

#if __cplusplus
#include <pb/entities/LutIconInfo.h>
#endif

@interface LutItem : NSObject
@property (nonatomic, strong) NSString* path;
@property (nonatomic, strong) NSString* name;
#if __cplusplus
- (id)initWithCpp:(PB::LutIconInfo)lutIconInfo;
#endif
@end

#endif /* LutItem_h */
17 changes: 17 additions & 0 deletions osx/PhotoBook/PhotoBook/LutItem.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// LutItem.mm
// PhotoBook
//
// Created by Cosmin Mihai on 25.01.2025.
//

#include "LutItem.h"

@implementation LutItem
- (id)initWithCpp:(PB::LutIconInfo)lutIconInfo;
{
self.name = [NSString stringWithUTF8String:lutIconInfo.name.c_str()];
self.path = [NSString stringWithUTF8String:lutIconInfo.path.c_str()];
return self;
}
@end
1 change: 1 addition & 0 deletions osx/PhotoBook/PhotoBook/PhotoBook-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#import <Foundation/Foundation.h>

#include "CollageItem.h"
#include "LutItem.h"
#include "PaperSettings.h"
#include "FrontendImageResources.h"
#include "FrontendImage.h"
Expand Down
12 changes: 4 additions & 8 deletions osx/PhotoBook/PhotoBook/TableContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ struct TableContentView: View, PhotobookUIListener {

@State private var collagesGridModel: CollagesGridModel

@State private var lutGridModel: LutGridModel

init(navigationPath:Binding<[String]>, photobook: Photobook)
{
_photobook = State(initialValue: photobook)
_navigationPath = navigationPath

mediaListModel = MediaListModel(photobook: photobook)
collagesGridModel = CollagesGridModel(photobook: photobook)
lutGridModel = LutGridModel(photobook: photobook)
}

var body: some View {
Expand Down Expand Up @@ -210,14 +213,7 @@ struct TableContentView: View, PhotobookUIListener {

CollagesGrid(frameSize: geometry.size, model: self.collagesGridModel)

VStack{
List(0..<20, id: \.self) { item in
Text("Item \(item)")
}
.frame(width: geometry.size.width * tabViewRatio)
}
.frame(alignment:.leading)
.tag(2)
LutGrid(frameSize: geometry.size, model: self.lutGridModel)
}
.frame(alignment:.leading)
.scrollIndicators(.hidden)
Expand Down

0 comments on commit f8bd1ab

Please sign in to comment.