Browse Source

Fixed annoying bug where if there were less images than the limit, the pagination would never render the content.

master
Drew Short 10 years ago
parent
commit
9b1e366e45
  1. 2
      gui/src/main/resources/fxml/mainapp/MainApp.fxml
  2. 20
      gui/src/main/scala/com/sothr/imagetools/ui/controller/AppController.scala

2
gui/src/main/resources/fxml/mainapp/MainApp.fxml

@ -128,7 +128,7 @@
<Insets />
</VBox.margin>
</ScrollPane>
<Pagination fx:id="paginator" maxHeight="1.7976931348623157E308" maxPageIndicatorCount="9" pageCount="1">
<Pagination fx:id="paginator" disable="true" maxHeight="40.0" maxPageIndicatorCount="9" maxWidth="1.7976931348623157E308" minHeight="40.0" pageCount="1" prefHeight="40.0">
<opaqueInsets>
<Insets />
</opaqueInsets></Pagination>

20
gui/src/main/scala/com/sothr/imagetools/ui/controller/AppController.scala

@ -91,6 +91,7 @@ class AppController extends Logging {
})
//override the imageTilePane
debug("Replacing the default TilePane with a custom ImageTilePane")
val newImageTilePane = new ImageTilePane()
newImageTilePane.setHgap(this.imageTilePane.getHgap)
newImageTilePane.setVgap(this.imageTilePane.getVgap)
@ -103,6 +104,7 @@ class AppController extends Logging {
//newImageTilePane.setPrefTileHeight(this.imageTilePane.getPrefTileHeight)
//newImageTilePane.setPrefTileWidth(this.imageTilePane.getPrefTileWidth)
newImageTilePane.setTileAlignment(this.imageTilePane.getTileAlignment)
debug("Assigning the the new ImageTilePane to the ScrollPane")
this.scrollPane.setContent(newImageTilePane)
this.imageTilePane = newImageTilePane
@ -110,9 +112,12 @@ class AppController extends Logging {
//val testImage = new Image()
//testImage.setThumbnailPath("test.jpg")
//testImage.setImagePath("test.jpg")
//val testImageList = new mutable.MutableList[Image]
//for (i <- 1 to 100) {
// imageTilePane.getChildren.add(ImageTileFactory.get(testImage))
// testImageList += testImage
//}
//setPagesContent(testImageList.toList)
//showPage(0)
//val list = FXCollections.observableArrayList[String]()
//for (i <- 1 to 100) {
// list.add(s"test-item ${i}")
@ -181,7 +186,7 @@ class AppController extends Logging {
@FXML
def showAllImages(event: ActionEvent) = {
resetPaginator()
imageTilePane.getChildren.setAll(new java.util.ArrayList[Node]())
getImageTilePane.getChildren.setAll(new java.util.ArrayList[Node]())
val f: Future[List[Image]] = Future {
engine.getImagesForDirectory(currentDirectory, recursive = doRecursiveProcessing.isSelected)
}
@ -194,6 +199,7 @@ class AppController extends Logging {
Platform.runLater(new Runnable() {
override def run() {
setPagesContent(images)
showPage(0)
}
})
case Failure(t) =>
@ -219,10 +225,10 @@ class AppController extends Logging {
for (similarImage <- similarImages) {
debug(s"Adding similar images ${similarImage.rootImage.toString} to app")
tempImages += similarImage.rootImage
imageTilePane.getChildren.add(ImageTileFactory.get(similarImage.rootImage, imageTilePane))
similarImage.similarImages.foreach(image => tempImages += image)
}
setPagesContent(tempImages.toList)
showPage(0)
}
})
case Failure(t) =>
@ -253,13 +259,13 @@ class AppController extends Logging {
val startIndex = pageIndex * itemsPerPage
val endIndex = if ((startIndex + itemsPerPage) > this.currentImages.size) this.currentImages.length else startIndex + itemsPerPage
//clear and populate the scrollpane
imageTilePane.getChildren.setAll(new java.util.ArrayList[Node]())
getImageTilePane.getChildren.setAll(new java.util.ArrayList[Node]())
val images = this.currentImages.slice(startIndex, endIndex)
Platform.runLater(new Runnable() {
override def run() {
for (image <- images) {
debug(s"Adding image ${image.toString} to app")
imageTilePane.getChildren.add(ImageTileFactory.get(image, imageTilePane))
getImageTilePane.getChildren.add(ImageTileFactory.get(image, getImageTilePane))
}
}
})
@ -267,6 +273,10 @@ class AppController extends Logging {
//endregion
def getImageTilePane :TilePane = {
this.imageTilePane
}
//todo: include a templating engine for rendering information
//todo: show a dialog that is rendered from markdown content

Loading…
Cancel
Save