Skip to content

Commit

Permalink
dev: Add Collage image combination functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin42 committed Feb 11, 2025
1 parent e811d19 commit 71daf2f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
36 changes: 34 additions & 2 deletions osx/PhotoBook/PhotoBook/Pages/TableContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,39 @@ struct TableContentView: View, PhotobookUIListener {
.background(Color.gray)

Button(action: {
print("Make collage tapped")
var imagesIndices:[Int] = []
var imagesList: [FrontendImage] = []
if !self.splModel.selectedIndices.isEmpty
{
imagesIndices = self.splModel.selectedIndices

imagesList = imagesIndices.compactMap { index in
guard index >= 0, index < splModel.list.count else { return nil }
return splModel.list[index]
}
}
else if !self.uplModel.selectedIndices.isEmpty
{
imagesIndices = self.uplModel.selectedIndices
imagesList = imagesIndices.compactMap { index in
guard index >= 0, index < uplModel.list.count else { return nil }
return uplModel.list[index]
}
}
else
{
// TODO: Show error here
return
}
if let selectedCollageIndex = self.collagesGridModel.selectedIndex
{
self.photobook.createCollage(UInt32(selectedCollageIndex), images: imagesList)
}
else
{
// TODO: Show error
return
}
}) {
Image(systemName: "square.grid.2x2")
.scaledToFit()
Expand Down Expand Up @@ -383,6 +415,6 @@ struct TableContentView: View, PhotobookUIListener {

func onCollageCreated(image: FrontendImage)
{

self.splModel.insert(image: image, position: UInt(self.splModel.list.count))
}
}
1 change: 1 addition & 0 deletions osx/PhotoBook/PhotoBook/Photobook.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- (void) RecallMetadata;
- (void) unloadProject;
- (void) makeCollages;
- (void) createCollage:(unsigned)collageIndex images:(NSArray<FrontendImage*>*)images;
- (NSArray<ProjectMetadataEntry*>*) projectsList;
- (ProjectManagementServiceWrapper*) projectManagementService;
- (void) addImportFolder:(NSString*)root;
Expand Down
11 changes: 11 additions & 0 deletions osx/PhotoBook/PhotoBook/Photobook.mm
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,17 @@ - (void) makeCollages
mPhotobook->makeCollages();
}

- (void) createCollage:(unsigned)collageIndex images:(NSArray<FrontendImage*>*)images
{
std::vector<PB::GenericImagePtr> nativeImages;
for (NSUInteger i = 0; i < [images count]; i++)
{
auto nativeImage = [[images objectAtIndex:i] unwrap];
nativeImages.push_back(nativeImage);
}
mPhotobook->collageService()->combineImages(collageIndex, nativeImages);
}

- (ProjectManagementServiceWrapper*) projectManagementService
{
auto projectManagementService = mPhotobook->projectManagementService();
Expand Down

0 comments on commit 71daf2f

Please sign in to comment.