Skip to content

Commit

Permalink
#114: reorders toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
rladstaetter committed Oct 26, 2022
1 parent 0d7d651 commit b710c2c
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 41 deletions.
2 changes: 1 addition & 1 deletion app/src/main/scala/app/logorrr/views/LogFileTab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class LogFileTab(val pathAsString: String
val settingsToolBar = new SettingsToolBar(pathAsString)

val opsBorderPane: OpsBorderPane = {
val op = new OpsBorderPane(pathAsString,searchToolBar, filtersToolBar, settingsToolBar)
val op = new OpsBorderPane(pathAsString, searchToolBar, filtersToolBar, settingsToolBar)
op.blockSizeProperty.set(LogoRRRGlobals.getLogFileSettings(pathAsString).blockWidthSettingsProperty.get())
op.fontSizeProperty.set(LogoRRRGlobals.getLogFileSettings(pathAsString).fontSizeProperty.get())
op
Expand Down
32 changes: 18 additions & 14 deletions app/src/main/scala/app/logorrr/views/OpsBorderPane.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import app.logorrr.views.block.{HasBlockSizeProperty, RectButton}
import app.logorrr.views.search.{FiltersToolBar, SearchToolBar}
import app.logorrr.views.text.TextSizeButton
import javafx.beans.property.SimpleIntegerProperty
import javafx.geometry.Pos
import javafx.scene.control.{Control, ToolBar, Tooltip}
import javafx.scene.layout.BorderPane
import javafx.geometry.{Orientation, Pos}
import javafx.scene.control.{Control, Separator, ToolBar, Tooltip}
import javafx.scene.layout.{BorderPane, HBox}
import javafx.scene.paint.Color

/**
Expand All @@ -17,7 +17,7 @@ class OpsBorderPane(pathAsString: String
, searchToolBar: SearchToolBar
, filtersToolBar: FiltersToolBar
, settingsToolBar: SettingsToolBar)
extends BorderPane
extends HBox
with HasBlockSizeProperty {

def setFontSize(fontSize: Int): Unit =
Expand Down Expand Up @@ -72,19 +72,23 @@ class OpsBorderPane(pathAsString: String
Seq(smallerRectBtn, biggerRectBtn, smallerTextBtn, biggerTextBtn)
}

private val box = new ToolBar(items: _*)
setLeft(box)
box.setMaxHeight(Double.PositiveInfinity)
BorderPane.setAlignment(box, Pos.CENTER)

setCenter(filtersToolBar)
filtersToolBar.setMaxHeight(Double.PositiveInfinity)
BorderPane.setAlignment(filtersToolBar, Pos.CENTER_LEFT)

setRight(searchToolBar)
BorderPane.setAlignment(searchToolBar, Pos.CENTER_LEFT)
searchToolBar.setMaxHeight(Double.PositiveInfinity)

// setLeft(searchToolBar)

private val box = new ToolBar(items: _*)
box.setMinWidth(150)
box.setMaxHeight(Double.PositiveInfinity)
// BorderPane.setAlignment(box, Pos.CENTER_LEFT)
// setCenter(box)

filtersToolBar.setMaxHeight(Double.PositiveInfinity)
// BorderPane.setAlignment(filtersToolBar, Pos.CENTER_LEFT)
// setRight(filtersToolBar)
val is = Seq(searchToolBar, box, filtersToolBar)
setAlignment(Pos.CENTER_LEFT)
getChildren.addAll(is: _*)


}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package app.logorrr.views.search

import app.logorrr.util.LogoRRRFonts
import javafx.scene.control.{Label, ToggleButton}
import app.logorrr.util.{LogoRRRFonts, OsUtil}
import javafx.scene.control.{Label, ToggleButton, Tooltip}
import javafx.scene.paint.Color

class SearchActivateRegexToggleButton
Expand All @@ -10,5 +10,9 @@ class SearchActivateRegexToggleButton
label.setStyle(LogoRRRFonts.jetBrainsMono(8))
label.setTextFill(Color.DARKGREY)
setGraphic(label)
setTooltip(new Tooltip(
s"""activate regular expression search
|
|shortcut: ${OsUtil.osFun("CTRL-R", "COMMAND-R")}""".stripMargin))

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
package app.logorrr.views.search

import app.logorrr.util.ColorUtil
import javafx.scene.control.ColorPicker
import javafx.scene.control.{Button, ColorPicker, Tooltip}
import org.kordamp.ikonli.fontawesome5.FontAwesomeSolid
import org.kordamp.ikonli.javafx.FontIcon

class SearchColorPicker extends ColorPicker {
setValue(ColorUtil.randColor)
setMaxWidth(46)
setTooltip(new Tooltip("choose color"))
// see https://stackoverflow.com/questions/45966844/how-to-change-the-icon-size-of-a-color-picker-in-javafx
setStyle("""-fx-color-label-visible: false""".stripMargin)

}

class CustomSearchButton extends Button {
setGraphic(new FontIcon(FontAwesomeSolid.SEARCH))
setTooltip(new Tooltip("search"))
setMaxWidth(40)

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package app.logorrr.views.search

import javafx.scene.control.TextField
import app.logorrr.util.OsUtil
import javafx.scene.control.{TextField, Tooltip}

class SearchTextField extends TextField {
setPrefWidth(200)
setMaxWidth(200)
setTooltip(new Tooltip(s"enter search pattern\n\nshortcut: ${OsUtil.osFun("CTRL-F", "COMMAND-F")}"))

}
33 changes: 11 additions & 22 deletions app/src/main/scala/app/logorrr/views/search/SearchToolBar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import app.logorrr.util.{ColorUtil, OsUtil}
import javafx.beans.binding.StringBinding
import javafx.scene.control._
import javafx.scene.input.{KeyCode, KeyEvent}
import javafx.scene.layout.HBox
import org.kordamp.ikonli.fontawesome5.FontAwesomeSolid
import org.kordamp.ikonli.javafx.FontIcon

Expand All @@ -17,6 +18,7 @@ object SearchToolBar {
|-fx-background-color: CYAN;
|-fx-border-width: 1px 1px 1px 1px;
|-fx-border-color: BLUE;
|-fx-padding: 0px 0px 0px 3px;
|""".stripMargin

}
Expand All @@ -28,28 +30,14 @@ object SearchToolBar {
class SearchToolBar(addFilterFn: Filter => Unit) extends ToolBar {

//setStyle(SearchToolBar.BackgroundSelectedStyle)
setStyle("""-fx-padding: 0px 0px 0px 4px;""")

/** expose for key accelerator */
val searchTextField = {
val stf = new SearchTextField
stf.setTooltip(new Tooltip(s"enter search pattern\n\nshortcut: ${OsUtil.osFun("CTRL-F", "COMMAND-F")}"))
stf
}
private val colorPicker = {
val scp = new SearchColorPicker()
scp.setTooltip(new Tooltip("choose color"))
scp
}
val searchTextField = new SearchTextField
private val colorPicker = new SearchColorPicker()

/** expose for key accelerator */
val regexToggleButton = {
val sartb = new SearchActivateRegexToggleButton()
sartb.setTooltip(new Tooltip(
s"""activate regular expression search
|
|shortcut: ${OsUtil.osFun("CTRL-R", "COMMAND-R")}""".stripMargin))
sartb
}
val regexToggleButton = new SearchActivateRegexToggleButton()

searchTextField.promptTextProperty().bind(new StringBinding {
bind(regexToggleButton.selectedProperty())
Expand All @@ -62,10 +50,8 @@ class SearchToolBar(addFilterFn: Filter => Unit) extends ToolBar {
}
})

class SearchButton extends CustomSearchButton {

class SearchButton extends Button {

setGraphic(new FontIcon(FontAwesomeSolid.SEARCH))
setOnAction(_ => {
if (searchTextField.getText.nonEmpty) {
val filter =
Expand All @@ -84,7 +70,6 @@ class SearchToolBar(addFilterFn: Filter => Unit) extends ToolBar {

private val searchButton = new SearchButton()


// if 'ENTER' is pressed when focus is in searchField, execute a search right away.
// I would prefer to instantiate an accelerator here as well, but there is a NPE if we do it in the constructor.
// Because of that LogoRRRAccelerators class exists. On the other hand it is ok to have a central place to define
Expand All @@ -98,6 +83,10 @@ class SearchToolBar(addFilterFn: Filter => Unit) extends ToolBar {
searchButton.fire()
}
}
val width = 356

setMaxWidth(width)
setMinWidth(width)

getItems.addAll(Seq(searchTextField, regexToggleButton, colorPicker, searchButton).asJava)

Expand Down
Binary file added docs/releases/23.1.0/reordered-toolbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b710c2c

Please sign in to comment.