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

Loading…
Cancel
Save