-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from rladstaetter/132-logorrr-remember-scroll…
…-position 132 logorrr remember scroll position
- Loading branch information
Showing
33 changed files
with
590 additions
and
640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,46 @@ | ||
package app.logorrr | ||
|
||
import app.logorrr.conf.{LogoRRRGlobals, Settings, SettingsIO} | ||
import app.logorrr.io.FilePaths | ||
import app.logorrr.meta.AppMeta | ||
import app.logorrr.util.CanLog | ||
import app.logorrr.views.main.LogoRRRStage | ||
import app.logorrr.util.{CanLog, JfxUtils} | ||
import app.logorrr.views.main.{LogoRRRMain, LogoRRRStage} | ||
import javafx.application.{Application, HostServices} | ||
import javafx.stage.Stage | ||
|
||
import java.nio.file.Paths | ||
|
||
object LogoRRRApp extends CanLog { | ||
|
||
/** LogoRRRs own log formatting string */ | ||
val logFormat = """[%1$tF %1$tT.%1$tN] %3$-40s %4$-13s %5$s %6$s %n""" | ||
/** | ||
* Main starting point for LogoRRR Application | ||
*/ | ||
// have fun and thanks for reading the code! | ||
object LogoRRRApp { | ||
|
||
def main(args: Array[String]): Unit = { | ||
System.setProperty("user.language", "en") | ||
System.setProperty("java.util.logging.SimpleFormatter.format", logFormat) | ||
logInfo(s"Started ${AppMeta.fullAppNameWithVersion} in ${Paths.get("").toAbsolutePath.toString}") | ||
System.setProperty("java.util.logging.SimpleFormatter.format", CanLog.LogFormat) | ||
// make sure to set css before anything is initialized otherwise the rules won't apply | ||
LogoRRRNative.loadNativeLibraries() | ||
|
||
javafx.application.Application.launch(classOf[LogoRRRApp], args: _*) | ||
} | ||
|
||
def start(stage: Stage | ||
, settings: Settings | ||
, hostServices: HostServices): Unit = { | ||
LogoRRRGlobals.set(settings, hostServices) | ||
val logoRRRMain = new LogoRRRMain(JfxUtils.closeStage(stage)) | ||
LogoRRRStage.init(stage, logoRRRMain) | ||
LogoRRRStage.show(stage, logoRRRMain) | ||
} | ||
} | ||
|
||
class LogoRRRApp extends javafx.application.Application with CanLog { | ||
|
||
def start(stage: Stage): Unit = { | ||
val settings: Settings = SettingsIO.fromFile() | ||
LogoRRRGlobals.set(settings, getHostServices) | ||
LogoRRRStage(stage).show() | ||
Application.setUserAgentStylesheet("/app/logorrr/LogoRRR.css") | ||
logInfo(s"Started ${AppMeta.fullAppNameWithVersion} in '${Paths.get("").toAbsolutePath.toString}'") | ||
LogoRRRApp.start(stage, SettingsIO.fromFile(FilePaths.settingsFilePath), getHostServices) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,15 @@ | ||
package app.logorrr.util | ||
|
||
import app.logorrr.model.LogEntry | ||
import app.logorrr.views.block.BlockImage | ||
import javafx.beans.property.{ReadOnlyDoubleProperty, SimpleIntegerProperty} | ||
|
||
import scala.math.BigDecimal.RoundingMode | ||
|
||
object MathUtil extends CanLog { | ||
object MathUtil { | ||
|
||
def roundUp(nrRows: Double): Int = { | ||
BigDecimal.double2bigDecimal(nrRows).setScale(0, RoundingMode.UP).intValue | ||
def roundUp(doubleNumber: Double): Int = { | ||
BigDecimal.double2bigDecimal(doubleNumber).setScale(0, RoundingMode.UP).intValue | ||
} | ||
|
||
def roundDown(nrRows: Double): Int = { | ||
BigDecimal.double2bigDecimal(nrRows).setScale(0, RoundingMode.DOWN).intValue | ||
def roundDown(doubleNumber: Double): Int = { | ||
BigDecimal.double2bigDecimal(doubleNumber).setScale(0, RoundingMode.DOWN).intValue | ||
} | ||
|
||
def calcBoundedHeight(widthProperty: ReadOnlyDoubleProperty | ||
, blockSizeProperty: SimpleIntegerProperty | ||
, entriesProperty: java.util.List[LogEntry] | ||
, listViewHeightProperty: ReadOnlyDoubleProperty): (Int, Int, Int) = { | ||
val w = if (widthProperty.get() - BlockImage.ScrollBarWidth >= 0) widthProperty.get() - BlockImage.ScrollBarWidth else widthProperty.get() | ||
|
||
val cols: Int = MathUtil.roundUp(w / blockSizeProperty.get()) | ||
val rows: Int = if (entriesProperty.size() < cols) 1 else entriesProperty.size() / cols | ||
|
||
// per default, use 4 cells per visible page, align height with blocksize such that | ||
// we don't get artifacts. Further, make sure that the calculated height does not exceed | ||
// MaxHeight of underlying texture painting mechanism. | ||
|
||
// DO NOT REMOVE since the first division throws away the remainder and the multiplication | ||
// yields the best approximation of MaxHeight. | ||
val maxHeight = (BlockImage.MaxHeight / blockSizeProperty.get()) * blockSizeProperty.get() | ||
val height = Math.min(MathUtil.roundDown((listViewHeightProperty.get() / BlockImage.DefaultBlocksPerPage) / blockSizeProperty.get()) * blockSizeProperty.get(), maxHeight) | ||
(cols, rows, height) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.