Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
deskscreen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kowis-projects
deskscreen
Commits
f3ca1ac0
Commit
f3ca1ac0
authored
Mar 18, 2019
by
David
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lots of comment clean up
parent
59e74014
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
30 deletions
+18
-30
src/main/kotlin/is/kow/deskscreen/ticker/TickerView.kt
src/main/kotlin/is/kow/deskscreen/ticker/TickerView.kt
+18
-30
No files found.
src/main/kotlin/is/kow/deskscreen/ticker/TickerView.kt
View file @
f3ca1ac0
...
...
@@ -50,7 +50,6 @@ open class TickerEntry<out T : Node>(
*/
class
TickerView
:
View
()
{
private
val
sampleText
=
"What is going on? How did this get added to the pane? It shouldn't have."
private
val
logger
=
KotlinLogging
.
logger
{}
private
val
marqueeView
:
MarqueeView
by
inject
()
...
...
@@ -94,7 +93,7 @@ class TickerView : View() {
}
}
val
cpuTemp
=
object
:
TickerEntry
<
Text
>(
title
=
"CPU Temp"
,
content
=
createText
(
"88${DEGREE}C"
),
reschedule
=
true
)
{
val
cpuTemp
=
object
:
TickerEntry
<
Text
>(
title
=
"CPU Temp"
,
content
=
createText
(
"88
.0
${DEGREE}C"
),
reschedule
=
true
)
{
val
temperatureFile
=
Paths
.
get
(
"/sys/class/thermal/thermal_zone0/temp"
).
toFile
()
override
fun
updateObservable
():
Completable
?
{
...
...
@@ -112,7 +111,7 @@ class TickerView : View() {
it
.
toDouble
().
div
(
1000
)
}
.
doOnNextFx
{
content
.
text
=
"%.
2
f%sC"
.
format
(
it
,
DEGREE
)
content
.
text
=
"%.
1
f%sC"
.
format
(
it
,
DEGREE
)
}
.
ignoreElements
()
}
...
...
@@ -126,9 +125,6 @@ class TickerView : View() {
currentTime
,
TickerEntry
<
Node
>(
"blorp"
,
createText
(
"Third!"
)),
TickerEntry
<
Node
>(
"blerp"
,
createText
(
"this is the second"
)),
//time as TickerEntry<Node>,
//TickerEntry<Node>("test", createText(sampleText)),
//TickerEntry<Node>("more", createText("Some more words")),
TickerEntry
<
Node
>(
"another"
,
createText
(
"This is happening"
)),
TickerEntry
<
Node
>(
"time"
,
createText
(
ZonedDateTime
.
now
().
format
(
DateTimeFormatter
.
ISO_ZONED_DATE_TIME
))),
cpuTemp
...
...
@@ -164,15 +160,18 @@ class MarqueeView : View() {
private
val
logger
=
KotlinLogging
.
logger
{}
private
val
OFFSET
=
5.0
//Amount of space between entries!
data class
ActiveTick
(
val
entry
:
TickerEntry
<
Node
>,
var
cleared
:
Boolean
=
false
)
private
data class
ActiveTick
(
val
entry
:
TickerEntry
<
Node
>,
var
cleared
:
Boolean
=
false
)
private
val
activeTicks
=
ConcurrentLinkedQueue
<
ActiveTick
>()
//This might not need to be threadsafe, only one thing is adding/removing it
private
val
queuedTicks
=
ConcurrentLinkedQueue
<
TickerEntry
<
Node
>>()
//This one does, multiple threads!
private
val
pane
:
Pane
=
pane
()
private
val
timeline
=
Timeline
()
//Timeline is up here in case I need to pause, play the animation
//TODO: on animation pause, should pause all the observables? maybe that doesn't matter
override
val
root
=
pane
//This is needed to make sure the pane fills up the entire space of whatever we've been put in.
fun
inside
(
of
:
Pane
)
{
//I need this guy to autofill to max size
pane
.
prefWidthProperty
().
bind
(
of
.
widthProperty
())
...
...
@@ -183,8 +182,7 @@ class MarqueeView : View() {
val
rectangle
=
Rectangle
(
25.0
,
25.0
)
//Need to figure out what size my clipping rectangle needs to be
//Bind the clipping to the size of the thing
rectangle
.
widthProperty
().
bind
(
root
.
widthProperty
())
rectangle
.
heightProperty
().
bind
(
root
.
heightProperty
())
root
.
clip
=
rectangle
...
...
@@ -196,15 +194,9 @@ class MarqueeView : View() {
queuedTicks
.
add
(
entry
)
}
//
Will need to fire one of these for each thing, with some space detection, based on when one is ending.
//
Fire up the animation process for the ticker
private
fun
startAnimation
()
{
//For each entry in the active ticks, animate it, until it's off th edge, and then drop it from the thing
//if there's space to add a queue'd tick, stick it in there
val
timeline
=
Timeline
()
//Don't appear to need to unstart/restart this, it seems to not spinlock too bad
//TODO: this is kind of an expensive operation, should trigger only once...
//If it's already cleared, don't keep checking
fun
lastOneCleared
():
Boolean
{
//Determine if the last entry in the activeQueue has cleared
val
last
=
activeTicks
.
last
()
...
...
@@ -218,36 +210,31 @@ class MarqueeView : View() {
return
last
.
cleared
}
//Keep track of the things we've started, so we can dispose them
val
subscriptions
=
HashMap
<
TickerEntry
<
Node
>,
Disposable
>()
//
I want any rendering delays to slow the whole thing, not just the individual item. Also then it's less threads
//
Could also update this things speed time so that stuff scrolls faster
val
updateFrame
=
KeyFrame
(
Duration
.
millis
(
35.0
),
EventHandler
<
ActionEvent
>
{
//Th
is appears to move too fast!
//Th
ere's possible some thread bugs in there, but only on the very first creation
if
(
activeTicks
.
isEmpty
()
||
lastOneCleared
())
{
val
newTickerEntry
:
TickerEntry
<
Node
>?
=
queuedTicks
.
poll
()
if
(
newTickerEntry
!=
null
)
{
//Then just put it into the active queue, so it will start processing like normal
newTickerEntry
.
content
.
layoutX
=
root
.
prefWidth
//Where to start
activeTicks
.
add
(
ActiveTick
(
newTickerEntry
))
root
.
add
(
newTickerEntry
.
content
)
//this is where it gets added
//But I never remove them!?!? UH OH They get removed later
}
}
//Something isn't working out right here.
activeTicks
.
forEach
{
active
->
val
entry
=
active
.
entry
val
content
=
entry
.
content
//I don't intend to bounce this
val
textWidth
=
content
.
layoutBounds
.
width
val
layoutX
=
content
.
layoutX
//instead I want to move completely from the right all the way off until it's gone
//end state of this text is the entire width of the text off the right so layoutX <= 0 - textWidth - offset
//I don't think I need to do anything about this, only know when it's been moved off the end
//Check to see if it's been animated out.
if
(
layoutX
<=
0
-
textWidth
-
(
2
*
OFFSET
))
{
logger
.
debug
(
"ANIMATED ${entry.title} COMPLETELY OUT THE PANEL!"
)
//Now I ned to figure out how to remove it
...
...
@@ -263,15 +250,16 @@ class MarqueeView : View() {
enqueueTickEntry
(
entry
)
}
}
else
{
//It's not moved out, so move it a pixel. We could move it some number of pixels
content
.
layoutX
=
content
.
layoutX
-
1
//TODO: I should probably do animation in larger chunks perhaps, so that it can use less CPU?
//If there's an observable that we haven't started, fire it up!
val
updateObservable
=
entry
.
updateObservable
()
if
(
updateObservable
!=
null
&&
!
subscriptions
.
containsKey
(
entry
))
{
//Start up the observable that updates the
UI
//Start up the observable that updates the
component, whatever it is
logger
.
debug
(
"Starting observable for ${entry.title}"
)
val
disposable
=
updateObservable
.
subscribe
()
subscriptions
[
entry
]
=
disposable
//Need a thing to track these with
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment