mirror of
https://github.com/lxsang/Diya-API.git
synced 2024-12-27 03:48:21 +01:00
60 lines
1.1 KiB
Smalltalk
60 lines
1.1 KiB
Smalltalk
|
Class {
|
||
|
#name : #DiyaLoadingBar,
|
||
|
#superclass : #DiyaWidget,
|
||
|
#instVars : [
|
||
|
'label',
|
||
|
'bar',
|
||
|
'progress',
|
||
|
'percent'
|
||
|
],
|
||
|
#category : #'Diya-Widgets'
|
||
|
}
|
||
|
|
||
|
{ #category : #accessing }
|
||
|
DiyaLoadingBar >> bar [
|
||
|
^ bar
|
||
|
]
|
||
|
|
||
|
{ #category : #initialization }
|
||
|
DiyaLoadingBar >> initialize [
|
||
|
super initialize.
|
||
|
bar := self addNode: (DiyaRectangle new).
|
||
|
progress := self addNode: (DiyaRectangle new).
|
||
|
bar styleName: #loadingBar.
|
||
|
progress styleName: #loadingProgress.
|
||
|
"label := self addNode: (DiyaLabel new).
|
||
|
label wordWrap: false."
|
||
|
percent := 0.
|
||
|
]
|
||
|
|
||
|
{ #category : #accessing }
|
||
|
DiyaLoadingBar >> label [
|
||
|
^ label
|
||
|
]
|
||
|
|
||
|
{ #category : #accessing }
|
||
|
DiyaLoadingBar >> percent [
|
||
|
^ percent
|
||
|
]
|
||
|
|
||
|
{ #category : #accessing }
|
||
|
DiyaLoadingBar >> percent: anObject [
|
||
|
percent := anObject.
|
||
|
self setDirty.
|
||
|
]
|
||
|
|
||
|
{ #category : #processing }
|
||
|
DiyaLoadingBar >> process [
|
||
|
|border|
|
||
|
border := bar ? #border.
|
||
|
bar extent: self extent.
|
||
|
progress position: border@border.
|
||
|
progress extent: ((self percent) * (self extent x) / 100 -( border << 1)) @ (self extent y - (border << 1)).
|
||
|
"label extent: self extent."
|
||
|
]
|
||
|
|
||
|
{ #category : #accessing }
|
||
|
DiyaLoadingBar >> progress [
|
||
|
^ progress
|
||
|
]
|