Skip to content
Snippets Groups Projects
Commit 8a7e1800 authored by Kaj Koivunen's avatar Kaj Koivunen :coffee:
Browse files

sivujen lisäys ja poisto

parent fcff6b7a
No related branches found
No related tags found
No related merge requests found
...@@ -45,10 +45,10 @@ class MainView : View("Ronove") { ...@@ -45,10 +45,10 @@ class MainView : View("Ronove") {
} }
menu("Edit") { menu("Edit") {
item("Add page") { action { (app as Ronove).addPage() } } item("Add page") { action { (app as Ronove).addPage() } }
item("Remove page") { action { TODO() } } item("Remove page") { action { (app as Ronove).removePage() } }
separator() separator()
item("Add line") { action { TODO() } } item("Add line") { action { (app as Ronove).addLine() } }
item("Remove line") { action { TODO() } } //item("Remove line") { action { TODO() } }
separator() separator()
item("Project settings...") { action { TODO() } } item("Project settings...") { action { TODO() } }
} }
......
...@@ -52,7 +52,7 @@ class Project { ...@@ -52,7 +52,7 @@ class Project {
fun save() = projectFile?.let { saveFile(it) } fun save() = projectFile?.let { saveFile(it) }
fun new() { fun new() {
pages = mutableListOf(Page()) pages = mutableListOf()
projectFile = null projectFile = null
projectFileSet.value = false projectFileSet.value = false
} }
......
...@@ -2,7 +2,10 @@ package guru.kake.ronove ...@@ -2,7 +2,10 @@ package guru.kake.ronove
import javafx.beans.property.ReadOnlyObjectProperty import javafx.beans.property.ReadOnlyObjectProperty
import javafx.beans.property.SimpleIntegerProperty import javafx.beans.property.SimpleIntegerProperty
import tornadofx.* import javafx.scene.control.TableView
import tornadofx.App
import tornadofx.launch
import tornadofx.toProperty
/** /**
* Main class for the Ronove application * Main class for the Ronove application
...@@ -20,6 +23,8 @@ class Ronove: App(MainView::class, RonoveStylesheet::class) { ...@@ -20,6 +23,8 @@ class Ronove: App(MainView::class, RonoveStylesheet::class) {
/** Amount of pages in project */ /** Amount of pages in project */
var pageCount = SimpleIntegerProperty(project.pages.size) var pageCount = SimpleIntegerProperty(project.pages.size)
lateinit var table: TableView<Line>
/** /**
* Change current page * Change current page
* @param page page to change to * @param page page to change to
...@@ -34,6 +39,18 @@ class Ronove: App(MainView::class, RonoveStylesheet::class) { ...@@ -34,6 +39,18 @@ class Ronove: App(MainView::class, RonoveStylesheet::class) {
fun addPage() { fun addPage() {
project.pages.add(Page()) project.pages.add(Page())
pageCount.set(project.pages.size) pageCount.set(project.pages.size)
table.refresh()
}
fun addLine() {
project.pages[currentPage.value-1].lines.add(Line("kuuku","pööpötin"))
table.refresh()
}
fun removePage() {
project.pages.removeAt(currentPage.value-1)
pageCount.set(project.pages.size)
table.refresh()
} }
} }
......
...@@ -48,6 +48,7 @@ class SplashScreen(project: Project) : View("Ronove") { ...@@ -48,6 +48,7 @@ class SplashScreen(project: Project) : View("Ronove") {
)) ))
) )
close() close()
(app as Ronove).table.refresh()
} }
} }
progressbar(0.2) progressbar(0.2)
...@@ -69,8 +70,16 @@ class SplashScreen(project: Project) : View("Ronove") { ...@@ -69,8 +70,16 @@ class SplashScreen(project: Project) : View("Ronove") {
progressbar(0.9) progressbar(0.9)
} }
field { field {
button("New project") { action { project.new(); close() }} button("New project") { action {
button("Open...") { action { project.open(); close() }} project.new()
(app as Ronove).table.refresh()
close()
}}
button("Open...") { action {
project.open()
(app as Ronove).table.refresh()
close()
}}
button("Exit") { action { exitProcess(0) }} button("Exit") { action { exitProcess(0) }}
} }
} }
......
...@@ -31,6 +31,7 @@ class TranslationPageView(val ronove: Ronove) : View() { ...@@ -31,6 +31,7 @@ class TranslationPageView(val ronove: Ronove) : View() {
contextmenu {} contextmenu {}
} }
ronove.table = tableView
tableView.selectionModel.isCellSelectionEnabled = true tableView.selectionModel.isCellSelectionEnabled = true
tableView.selectionModel.selectedItemProperty().addListener(fun(_, _, newSelection) { tableView.selectionModel.selectedItemProperty().addListener(fun(_, _, newSelection) {
if (newSelection != null) { if (newSelection != null) {
...@@ -61,6 +62,7 @@ class TranslationPageView(val ronove: Ronove) : View() { ...@@ -61,6 +62,7 @@ class TranslationPageView(val ronove: Ronove) : View() {
private fun refresh() { private fun refresh() {
tableView.items = tableView.items =
ronove.project.pages[ronove.currentPage.value-1].lines.asObservable() ronove.project.pages[ronove.currentPage.value-1].lines.asObservable()
tableView.refresh()
} }
init { init {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment