make styles closer to CSS syntax

This commit is contained in:
Eduardo Bart 2011-11-17 19:41:02 -02:00
parent 55136fe866
commit 5c654f685c
35 changed files with 290 additions and 269 deletions

6
TODO
View File

@ -6,11 +6,11 @@ left panel with dragging windows
console history console history
console text selection console text selection
console scrolling console scrolling
padding
scrollbar scrollbar
make otui syntax more like css
a real working border and background property in otui a real working border and background property in otui
load state styles in order load state styles in order
grid layout grid layout
fix moving windows and tooltips conflicts fix moving windows and tooltips conflicts
todo display otclient icon in window bar todo display otclient icon in window bar
remake otui styles states system
padding

View File

@ -5,8 +5,7 @@ local about
-- public functions -- public functions
function About.create() function About.create()
about = UI.display('about.otui') about = UI.display('about.otui', { locked = true })
UI.root:lockChild(about)
end end
function About.destroy() function About.destroy()
@ -16,4 +15,4 @@ end
function About.openWebpage() function About.openWebpage()
displayErrorBox("Error", "Not implemented yet") displayErrorBox("Error", "Not implemented yet")
end end

View File

@ -7,55 +7,55 @@ MainWindow
size: 208 129 size: 208 129
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
margin.top: 32 margin-top: 32
margin.left: 18 margin-left: 18
Label Label
align: center text-align: center
text: |- text: |-
OTClient OTClient
Version 0.2.0 Version 0.2.0
Created by edubart Created by edubart
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top anchors.top: parent.top
margin.top: 20 margin-top: 20
HorizontalSeparator HorizontalSeparator
size: 190 2 size: 190 2
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
margin.top: 83 margin-top: 83
margin.left: 9 margin-left: 9
Label Label
text: Official Website text: Official Website
anchors.left: parent.left anchors.left: parent.left
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.bottom: 14 margin-bottom: 14
margin.left: 9 margin-left: 9
Button Button
text: Github Page text: Github Page
size: 88 24 size: 88 24
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.bottom: 9 margin-bottom: 9
margin.right: 9 margin-right: 9
@onClick: About.openWebpage() @onClick: About.openWebpage()
HorizontalSeparator HorizontalSeparator
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.bottom: 40 margin-bottom: 40
margin.left: 13 margin-left: 13
margin.right: 13 margin-right: 13
Button Button
text: Ok text: Ok
size: 46 24 size: 46 24
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
margin.top: 191 margin-top: 191
margin.left: 188 margin-left: 188
@onClick: About.destroy() @onClick: About.destroy()

View File

@ -8,5 +8,5 @@ Panel
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.top: 1 margin-top: 1
focusable: false focusable: false

View File

@ -15,13 +15,13 @@ Panel
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: chatLineEdit.top anchors.bottom: chatLineEdit.top
margin.right: 6 margin-right: 6
margin.left: 6 margin-left: 6
margin.bottom: 2 margin-bottom: 2
margin.top: 6 margin-top: 6
layout: layout:
type: verticalBox type: verticalBox
align bottom: true align-bottom: true
focusable: false focusable: false
LineEdit LineEdit
@ -29,7 +29,7 @@ Panel
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.right: 6 margin-right: 6
margin.left: 6 margin-left: 6
margin.bottom: 6 margin-bottom: 6
always focused: true always-active: true

View File

@ -15,15 +15,15 @@ RectPanel
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: commandSymbolLabel.top anchors.bottom: commandSymbolLabel.top
margin.left: 2 margin-left: 2
UILabel UILabel
id: commandSymbolLabel id: commandSymbolLabel
size: 20 16 size: 20 16
size fixed: true fixed-size: true
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: parent.left anchors.left: parent.left
margin.left: 2 margin-left: 2
font: terminus-14px-bold font: terminus-14px-bold
text: >> text: >>
@ -33,5 +33,5 @@ RectPanel
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: commandSymbolLabel.right anchors.left: commandSymbolLabel.right
anchors.right: parent.right anchors.right: parent.right
margin.left: 5 margin-left: 5
font: terminus-14px-bold font: terminus-14px-bold

View File

@ -1,8 +1,8 @@
Font Font
name: terminus-14px-bold name: terminus-14px-bold
height: 16 height: 16
top margin: 2 y-offset: 2
texture: terminus-14px-bold.png texture: terminus-14px-bold.png
glyph size: 16 16 glyph-size: 16 16
fixed glyph width: 8 fixed-glyph-width: 8

View File

@ -2,7 +2,7 @@ Font
name: verdana-11px-antialised name: verdana-11px-antialised
texture: verdana-11px-antialised.png texture: verdana-11px-antialised.png
height: 14 height: 14
glyph size: 16 16 glyph-size: 16 16
glyph widths: glyph-widths:
32: 4 32: 4

View File

@ -2,7 +2,7 @@ Font
name: verdana-11px-monochrome name: verdana-11px-monochrome
texture: verdana-11px-monochrome.png texture: verdana-11px-monochrome.png
height: 14 height: 14
glyph size: 16 16 glyph-size: 16 16
glyph widths: glyph-widths:
32: 2 32: 2

View File

@ -2,9 +2,9 @@ Font
name: verdana-11px-rounded name: verdana-11px-rounded
texture: verdana-11px-rounded.png texture: verdana-11px-rounded.png
height: 14 height: 14
glyph size: 16 16 glyph-size: 16 16
glyph widths: glyph-widths:
32: 4 32: 4
33: 4 33: 4
34: 7 34: 7

View File

@ -54,7 +54,7 @@ TopButton < UIButton
MenuButton < UIButton MenuButton < UIButton
color: white color: white
size: 40 18 size: 40 18
align: center text-align: center
border-image: border-image:
source: /core_styles/images/menu.png source: /core_styles/images/menu.png
size: 64 24 size: 64 24

View File

@ -2,7 +2,7 @@ LineEdit < UILineEdit
font: verdana-11px-antialised font: verdana-11px-antialised
color: #aaaaaa color: #aaaaaa
size: 86 20 size: 86 20
text margin: 3 text-margin: 3
border-image: border-image:
source: /core_styles/images/panel_flat.png source: /core_styles/images/panel_flat.png
border: 1 border: 1
@ -11,4 +11,4 @@ LineEdit < UILineEdit
color: #aaaaaa88 color: #aaaaaa88
PasswordLineEdit < LineEdit PasswordLineEdit < LineEdit
text hidden: true text-hidden: true

View File

@ -4,9 +4,9 @@ Window < UIWindow
opacity: 255 opacity: 255
color: white color: white
background-color: white background-color: white
head height: 20 head-height: 20
head text align: center head-text-align: center
move policy: free move-policy: free
stackable: true stackable: true
border-image: border-image:
source: /core_styles/images/window.png source: /core_styles/images/window.png
@ -22,12 +22,12 @@ Window < UIWindow
MiniWindow < UIWindow MiniWindow < UIWindow
font: verdana-11px-antialised font: verdana-11px-antialised
size: 192 200 size: 192 200
head height: 25 head-height: 25
head text align: center head-text-align: center
margin.top: 10 margin-top: 10
margin.left: 6 margin-left: 6
margin.right: 6 margin-right: 6
move policy: free updated move-policy: free updated
border-image: border-image:
source: /core_styles/images/mini_window.png source: /core_styles/images/mini_window.png
border: 4 border: 4

View File

@ -4,9 +4,9 @@ CharacterListLabel < Label
background-color: #00000000 background-color: #00000000
offset: 2 0 offset: 2 0
focusable: true focusable: true
margin.left: 1 margin-left: 1
margin.right: 1 margin-right: 1
margin.top: 1 margin-top: 1
$focus: $focus:
background-color: #ffffff22 background-color: #ffffff22
@ -16,17 +16,17 @@ MainWindow
id: charactersWindow id: charactersWindow
title: Character List title: Character List
size: 250 248 size: 250 248
onEnter: CharacterList.doLogin() @onEnter: CharacterList.doLogin()
onEscape: CharacterList.destroy() @onEscape: CharacterList.destroy()
TextList TextList
id: characterList id: characterList
anchors.fill: parent anchors.fill: parent
anchors.bottom: next.top anchors.bottom: next.top
margin.top: 30 margin-top: 30
margin.bottom: 5 margin-bottom: 5
margin.left: 16 margin-left: 16
margin.right: 16 margin-right: 16
Label Label
id: accountStatusLabel id: accountStatusLabel
@ -36,17 +36,17 @@ MainWindow
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: separator.top anchors.bottom: separator.top
margin.left: 16 margin-left: 16
margin.bottom: 5 margin-bottom: 5
HorizontalSeparator HorizontalSeparator
id: separator id: separator
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: next.top anchors.bottom: next.top
margin.left: 16 margin-left: 16
margin.right: 16 margin-right: 16
margin.bottom: 10 margin-bottom: 10
//CheckBox //CheckBox
// id: charAutoLoginBox // id: charAutoLoginBox
@ -55,9 +55,9 @@ MainWindow
// anchors.left: parent.left // anchors.left: parent.left
// anchors.right: parent.right // anchors.right: parent.right
// anchors.bottom: next.top // anchors.bottom: next.top
// margin.bottom: 6 // margin-bottom: 6
// margin.left: 18 // margin-left: 18
// margin.right: 18 // margin-right: 18
Button Button
id: buttonOk id: buttonOk
@ -65,8 +65,8 @@ MainWindow
width: 64 width: 64
anchors.right: next.left anchors.right: next.left
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.bottom: 16 margin-bottom: 16
margin.right: 16 margin-right: 16
@onClick: CharacterList.doLogin() @onClick: CharacterList.doLogin()
Button Button
@ -75,6 +75,6 @@ MainWindow
width: 64 width: 64
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.bottom: 16 margin-bottom: 16
margin.right: 16 margin-right: 16
@onClick: CharacterList.destroy() @onClick: CharacterList.destroy()

View File

@ -2,39 +2,39 @@ MainWindow
id: enterGame id: enterGame
title: Enter Game title: Enter Game
size: 236 240 size: 236 240
onEnter: EnterGame.doLogin() @onEnter: EnterGame.doLogin()
onEscape: EnterGame.hide() @onEscape: EnterGame.hide()
LargerLabel LargerLabel
text: Account name text: Account name
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
margin.left: 18 margin-left: 18
margin.top: 28 margin-top: 28
LineEdit LineEdit
id: accountNameLineEdit id: accountNameLineEdit
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: prev.bottom anchors.top: prev.bottom
margin.top: 2 margin-top: 2
margin.left: 18 margin-left: 18
margin.right: 18 margin-right: 18
LargerLabel LargerLabel
text: Password text: Password
anchors.left: prev.left anchors.left: prev.left
anchors.top: prev.bottom anchors.top: prev.bottom
margin.top: 8 margin-top: 8
PasswordLineEdit PasswordLineEdit
id: accountPasswordLineEdit id: accountPasswordLineEdit
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: prev.bottom anchors.top: prev.bottom
margin.top: 2 margin-top: 2
margin.left: 18 margin-left: 18
margin.right: 18 margin-right: 18
LargerLabel LargerLabel
id: serverLabel id: serverLabel
@ -42,7 +42,7 @@ MainWindow
text: Server text: Server
anchors.left: prev.left anchors.left: prev.left
anchors.top: prev.bottom anchors.top: prev.bottom
margin.top: 8 margin-top: 8
LineEdit LineEdit
id: serverHostLineEdit id: serverHostLineEdit
@ -50,7 +50,7 @@ MainWindow
anchors.left: serverLabel.left anchors.left: serverLabel.left
anchors.right: serverLabel.right anchors.right: serverLabel.right
anchors.top: serverLabel.bottom anchors.top: serverLabel.bottom
margin.top: 2 margin-top: 2
LargerLabel LargerLabel
id: portLabel id: portLabel
@ -58,7 +58,7 @@ MainWindow
width: 50 width: 50
anchors.left: serverLabel.right anchors.left: serverLabel.right
anchors.top: serverLabel.top anchors.top: serverLabel.top
margin.left: 10 margin-left: 10
LineEdit LineEdit
id: serverPortLineEdit id: serverPortLineEdit
@ -66,7 +66,7 @@ MainWindow
anchors.left: portLabel.left anchors.left: portLabel.left
anchors.right: portLabel.right anchors.right: portLabel.right
anchors.top: portLabel.bottom anchors.top: portLabel.bottom
margin.top: 2 margin-top: 2
CheckBox CheckBox
id: rememberPasswordBox id: rememberPasswordBox
@ -75,9 +75,9 @@ MainWindow
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: prev.bottom anchors.top: prev.bottom
margin.top: 10 margin-top: 10
margin.left: 18 margin-left: 18
margin.right: 18 margin-right: 18
@onCheckChange: | @onCheckChange: |
function(self, checked) function(self, checked)
self:getParent():getChildById('autoLoginBox'):setEnabled(checked) self:getParent():getChildById('autoLoginBox'):setEnabled(checked)
@ -91,17 +91,17 @@ MainWindow
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: prev.bottom anchors.top: prev.bottom
margin.top: 8 margin-top: 8
margin.left: 18 margin-left: 18
margin.right: 18 margin-right: 18
Button Button
text: Ok text: Ok
width: 64 width: 64
anchors.right: next.left anchors.right: next.left
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.bottom: 16 margin-bottom: 16
margin.right: 16 margin-right: 16
@onClick: EnterGame.doLogin() @onClick: EnterGame.doLogin()
Button Button
@ -109,6 +109,6 @@ MainWindow
width: 64 width: 64
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.bottom: 16 margin-bottom: 16
margin.right: 16 margin-right: 16
@onClick: EnterGame.hide() @onClick: EnterGame.hide()

View File

@ -5,7 +5,7 @@ HealthBar < UIProgressBar
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
ManaBar < UIProgressBar ManaBar < UIProgressBar
color: black color: black
height: 15 height: 15
@ -16,27 +16,27 @@ ManaBar < UIProgressBar
HealthLabel < Label HealthLabel < Label
color: white color: white
align: center text-align: center
font: verdana-11px-rounded font: verdana-11px-rounded
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
margin.top: 2 margin-top: 2
ManaLabel < Label ManaLabel < Label
color: white color: white
align: center text-align: center
font: verdana-11px-rounded font: verdana-11px-rounded
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.bottom: -1 margin-bottom: -1
UIWindow UIWindow
id: healthManaPanel id: healthManaPanel
width: 192 width: 192
margin.top: 10 margin-top: 10
margin.left: 6 margin-left: 6
margin.right: 6 margin-right: 6
move policy: free updated move-policy: free updated

View File

@ -1,9 +1,9 @@
UIWindow UIWindow
width: 192 width: 192
margin.top: 10 margin-top: 10
margin.left: 6 margin-left: 6
margin.right: 6 margin-right: 6
move policy: free updated move-policy: free updated
Item Item
id: head id: head
@ -15,82 +15,82 @@ UIWindow
id: armor id: armor
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter anchors.horizontalCenter: prev.horizontalCenter
margin.top: 5 margin-top: 5
Item Item
id: legs id: legs
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter anchors.horizontalCenter: prev.horizontalCenter
margin.top: 5 margin-top: 5
Item Item
id: feet id: feet
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter anchors.horizontalCenter: prev.horizontalCenter
margin.top: 5 margin-top: 5
Item Item
id: necklace id: necklace
anchors.top: parent.top anchors.top: parent.top
anchors.right: head.left anchors.right: head.left
margin.top: 10 margin-top: 10
margin.right: 5 margin-right: 5
Item Item
id: left id: left
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter anchors.horizontalCenter: prev.horizontalCenter
margin.top: 5 margin-top: 5
Item Item
id: ring id: ring
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter anchors.horizontalCenter: prev.horizontalCenter
margin.top: 5 margin-top: 5
Item Item
id: backpack id: backpack
anchors.top: parent.top anchors.top: parent.top
anchors.left: head.right anchors.left: head.right
margin.top: 10 margin-top: 10
margin.left: 5 margin-left: 5
Item Item
id: right id: right
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter anchors.horizontalCenter: prev.horizontalCenter
margin.top: 5 margin-top: 5
Item Item
id: ammo id: ammo
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.horizontalCenter: prev.horizontalCenter anchors.horizontalCenter: prev.horizontalCenter
margin.top: 5 margin-top: 5
Label Label
id: soul id: soul
anchors.top: ring.bottom anchors.top: ring.bottom
anchors.bottom: feet.bottom anchors.bottom: feet.bottom
anchors.left: ring.left anchors.left: ring.left
anchors.right: ring.right anchors.right: ring.right
margin.top: 5 margin-top: 5
align: center text-align: center
border-image: border-image:
source: /core_styles/images/panel_flat.png source: /core_styles/images/panel_flat.png
border: 1 border: 1
Label Label
id: capacity id: capacity
anchors.top: ammo.bottom anchors.top: ammo.bottom
anchors.bottom: feet.bottom anchors.bottom: feet.bottom
anchors.left: ammo.left anchors.left: ammo.left
anchors.right: ammo.right anchors.right: ammo.right
margin.top: 5 margin-top: 5
align: center text-align: center
border-image: border-image:
source: /core_styles/images/panel_flat.png source: /core_styles/images/panel_flat.png
border: 1 border: 1

View File

@ -8,14 +8,14 @@ Window
id: messageBoxLabel id: messageBoxLabel
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top anchors.top: parent.top
margin.top: 27 margin-top: 27
margin.bottom : 27 margin-bottom : 27
Button Button
id: messageBoxRightButton id: messageBoxRightButton
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.right: parent.right anchors.right: parent.right
margin.right: 10 margin-right: 10
margin.bottom: 10 margin-bottom: 10
width: 64 width: 64
visible: true visible: true

View File

@ -10,9 +10,9 @@ MainWindow
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
margin.top: 28 margin-top: 28
margin.left: 18 margin-left: 18
margin.right: 18 margin-right: 18
CheckBox CheckBox
id: fpsCheckBox id: fpsCheckBox
@ -20,15 +20,15 @@ MainWindow
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: prev.bottom anchors.top: prev.bottom
margin.top: 10 margin-top: 10
margin.left: 18 margin-left: 18
margin.right: 18 margin-right: 18
Button Button
text: Ok text: Ok
width: 64 width: 64
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.right: 10 margin-right: 10
margin.bottom: 10 margin-bottom: 10
@onClick: Options.destroy() @onClick: Options.destroy()

View File

@ -9,8 +9,8 @@ Window
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
onEnter: Outfit.accept() @onEnter: Outfit.accept()
onEscape: Outfit.destroy() @onEscape: Outfit.destroy()
Label Label
id: name id: name
@ -18,34 +18,34 @@ Window
width: 100 width: 100
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
margin.top: 34 margin-top: 34
margin.left: 20 margin-left: 20
Creature Creature
id: creature id: creature
anchors.top: name.bottom anchors.top: name.bottom
anchors.left: name.left anchors.left: name.left
margin.top: 5 margin-top: 5
Button Button
id: head id: head
text: Head text: Head
anchors.top: creature.top anchors.top: creature.top
anchors.left: creature.right anchors.left: creature.right
margin.left: 10 margin-left: 10
Button Button
id: primary id: primary
text: Primary text: Primary
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.left: prev.left anchors.left: prev.left
Button Button
id: secondary id: secondary
text: Secondary text: Secondary
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.left: prev.left anchors.left: prev.left
Button Button
id: detail id: detail
text: Detail text: Detail
@ -56,7 +56,7 @@ Window
@onClick: Outfit.nextType() @onClick: Outfit.nextType()
text: >> text: >>
width: 32 width: 32
margin.top: 4 margin-top: 4
anchors.top: creature.bottom anchors.top: creature.bottom
anchors.right: creature.right anchors.right: creature.right
@ -64,7 +64,7 @@ Window
@onClick: Outfit.previousType() @onClick: Outfit.previousType()
text: << text: <<
width: 32 width: 32
margin.top: 4 margin-top: 4
anchors.top: creature.bottom anchors.top: creature.bottom
anchors.left: creature.left anchors.left: creature.left
@ -72,7 +72,7 @@ Window
id: addon1 id: addon1
text: Addon 1 text: Addon 1
enabled: false enabled: false
margin.top: 10 margin-top: 10
width: 100 width: 100
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.left: prev.left anchors.left: prev.left
@ -81,7 +81,7 @@ Window
id: addon2 id: addon2
text: Addon 2 text: Addon 2
enabled: false enabled: false
margin.top: 10 margin-top: 10
width: 100 width: 100
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.left: prev.left anchors.left: prev.left
@ -90,7 +90,7 @@ Window
id: addon3 id: addon3
text: Addon 3 text: Addon 3
enabled: false enabled: false
margin.top: 10 margin-top: 10
width: 100 width: 100
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.left: prev.left anchors.left: prev.left
@ -99,9 +99,9 @@ Window
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: next.top anchors.bottom: next.top
margin.left: 16 margin-left: 16
margin.right: 16 margin-right: 16
margin.bottom: 10 margin-bottom: 10
Button Button
id: buttonOk id: buttonOk
@ -109,8 +109,8 @@ Window
width: 64 width: 64
anchors.right: next.left anchors.right: next.left
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.bottom: 16 margin-bottom: 16
margin.right: 16 margin-right: 16
@onClick: Outfit.accept() @onClick: Outfit.accept()
Button Button
@ -119,6 +119,6 @@ Window
width: 64 width: 64
anchors.right: parent.right anchors.right: parent.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
margin.bottom: 16 margin-bottom: 16
margin.right: 16 margin-right: 16
@onClick: Outfit.destroy() @onClick: Outfit.destroy()

View File

@ -2,9 +2,9 @@ SkillFirstWidget < UIWidget
SkillButton < UIButton SkillButton < UIButton
height: 14 height: 14
margin.top: 4 margin-top: 4
margin.left: 10 margin-left: 10
margin.right: 10 margin-right: 10
SkillNameLabel < Label SkillNameLabel < Label
font: verdana-11px-monochrome font: verdana-11px-monochrome
@ -14,7 +14,7 @@ SkillNameLabel < Label
SkillLevelLabel < Label SkillLevelLabel < Label
font: verdana-11px-monochrome font: verdana-11px-monochrome
align: right text-align: right
width: 32 width: 32
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
@ -25,9 +25,9 @@ SkillPercentPanel < UIProgressBar
background-color: green background-color: green
tooltip: test tooltip: test
height: 5 height: 5
margin.top: 3 margin-top: 3
margin.left: 10 margin-left: 10
margin.right: 10 margin-right: 10
MiniWindow MiniWindow
id: skillWindow id: skillWindow
@ -37,8 +37,8 @@ MiniWindow
Panel Panel
id: skillPanel id: skillPanel
anchors.fill: parent anchors.fill: parent
margin.top: 26 margin-top: 26
margin.bottom: 3 margin-bottom: 3
margin.left: 3 margin-left: 3
margin.right: 3 margin-right: 3
layout: verticalBox layout: verticalBox

View File

@ -1,7 +1,7 @@
CenterLabel < Label CenterLabel < Label
font: verdana-11px-rounded font: verdana-11px-rounded
height: 16 height: 16
align: center text-align: center
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
@ -9,8 +9,8 @@ CenterLabel < Label
BottomLabel < Label BottomLabel < Label
font: verdana-11px-rounded font: verdana-11px-rounded
height: 16 height: 16
align: center text-align: center
margin.bottom: 2 margin-bottom: 2
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right

View File

@ -9,8 +9,8 @@ TopPanel
id: settingsButton id: settingsButton
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
margin.top: 4 margin-top: 4
margin.left: 6 margin-left: 6
tooltip: Options tooltip: Options
icon: /core_styles/icons/settings.png icon: /core_styles/icons/settings.png
@onClick: Options.create() @onClick: Options.create()
@ -20,7 +20,7 @@ TopPanel
id: enterGameButton id: enterGameButton
anchors.top: prev.top anchors.top: prev.top
anchors.left: prev.right anchors.left: prev.right
margin.left: 6 margin-left: 6
tooltip: Enter game with a character tooltip: Enter game with a character
icon: /core_styles/icons/login.png icon: /core_styles/icons/login.png
@onClick: | @onClick: |
@ -34,7 +34,7 @@ TopPanel
id: motdButton id: motdButton
anchors.top: prev.top anchors.top: prev.top
anchors.left: prev.right anchors.left: prev.right
margin.left: 6 margin-left: 6
tooltip: Message of the day tooltip: Message of the day
icon: /core_styles/icons/motd.png icon: /core_styles/icons/motd.png
visible: false visible: false
@ -43,8 +43,8 @@ TopPanel
TopButton TopButton
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
margin.top: 4 margin-top: 4
margin.right: 6 margin-right: 6
tooltip: Logout tooltip: Logout
icon: /core_styles/icons/logout.png icon: /core_styles/icons/logout.png
@onClick: | @onClick: |
@ -57,8 +57,8 @@ TopPanel
TopButton TopButton
anchors.top: parent.top anchors.top: parent.top
anchors.right: prev.left anchors.right: prev.left
margin.top: 4 margin-top: 4
margin.right: 6 margin-right: 6
tooltip: About OTClient tooltip: About OTClient
icon: /core_styles/icons/about.png icon: /core_styles/icons/about.png
@onClick: About.create() @onClick: About.create()
@ -67,5 +67,5 @@ TopPanel
id: frameCounter id: frameCounter
anchors.top: parent.top anchors.top: parent.top
anchors.right: prev.left anchors.right: prev.left
margin.top: 8 margin-top: 8
margin.right: 12 margin-right: 12

View File

@ -1,6 +1,6 @@
VipListLabel < Label VipListLabel < Label
font: verdana-11px-monochrome font: verdana-11px-monochrome
margin.left: 5 margin-left: 5
$disabled: ~ $disabled: ~
@ -12,7 +12,7 @@ MiniWindow
id: vipList id: vipList
border-image: ~ border-image: ~
anchors.fill: parent anchors.fill: parent
margin.top: 26 margin-top: 26
margin.bottom: 6 margin-bottom: 6
margin.left: 6 margin-left: 6
margin.right: 6 margin-right: 6

View File

@ -29,10 +29,10 @@
void Font::load(const OTMLNodePtr& fontNode) void Font::load(const OTMLNodePtr& fontNode)
{ {
std::string textureName = fontNode->valueAt("texture"); std::string textureName = fontNode->valueAt("texture");
Size glyphSize = fontNode->valueAt<Size>("glyph size"); Size glyphSize = fontNode->valueAt<Size>("glyph-size");
m_glyphHeight = fontNode->valueAt<int>("height"); m_glyphHeight = fontNode->valueAt<int>("height");
m_topMargin = fontNode->valueAt("top margin", 0); m_yOffset = fontNode->valueAt("y-offset", 0);
m_firstGlyph = fontNode->valueAt("first glyph", 32); m_firstGlyph = fontNode->valueAt("first-glyph", 32);
m_glyphSpacing = fontNode->valueAt("spacing", Size(0,0)); m_glyphSpacing = fontNode->valueAt("spacing", Size(0,0));
// load font texture // load font texture
@ -40,14 +40,14 @@ void Font::load(const OTMLNodePtr& fontNode)
if(!m_texture) if(!m_texture)
throw std::runtime_error("failed to load texture for font"); throw std::runtime_error("failed to load texture for font");
if(OTMLNodePtr node = fontNode->get("fixed glyph width")) { if(OTMLNodePtr node = fontNode->get("fixed-glyph-width")) {
for(int glyph = m_firstGlyph; glyph < 256; ++glyph) for(int glyph = m_firstGlyph; glyph < 256; ++glyph)
m_glyphsSize[glyph] = Size(node->value<int>(), m_glyphHeight); m_glyphsSize[glyph] = Size(node->value<int>(), m_glyphHeight);
} else } else
calculateGlyphsWidthsAutomatically(glyphSize); calculateGlyphsWidthsAutomatically(glyphSize);
// read custom widths // read custom widths
if(OTMLNodePtr node = fontNode->get("glyph widths")) { if(OTMLNodePtr node = fontNode->get("glyph-widths")) {
for(const OTMLNodePtr& child : node->children()) for(const OTMLNodePtr& child : node->children())
m_glyphsSize[Fw::safeCast<int>(child->tag())].setWidth(child->value<int>()); m_glyphsSize[Fw::safeCast<int>(child->tag())].setWidth(child->value<int>());
} }
@ -200,7 +200,7 @@ const std::vector<Point>& Font::calculateGlyphsPositions(const std::string& text
} }
} }
Point virtualPos(0, m_topMargin); Point virtualPos(0, m_yOffset);
lines = 0; lines = 0;
for(i = 0; i < textLength; ++i) { for(i = 0; i < textLength; ++i) {
glyph = (uchar)text[i]; glyph = (uchar)text[i];

View File

@ -59,7 +59,7 @@ public:
const Rect* getGlyphsTextureCoords() const { return m_glyphsTextureCoords; } const Rect* getGlyphsTextureCoords() const { return m_glyphsTextureCoords; }
const Size* getGlyphsSize() const { return m_glyphsSize; } const Size* getGlyphsSize() const { return m_glyphsSize; }
const TexturePtr& getTexture() const { return m_texture; } const TexturePtr& getTexture() const { return m_texture; }
int getTopMargin() const { return m_topMargin; } int getYOffset() const { return m_yOffset; }
Size getGlyphSpacing() const { return m_glyphSpacing; } Size getGlyphSpacing() const { return m_glyphSpacing; }
private: private:
@ -69,7 +69,7 @@ private:
std::string m_name; std::string m_name;
int m_glyphHeight; int m_glyphHeight;
int m_firstGlyph; int m_firstGlyph;
int m_topMargin; int m_yOffset;
Size m_glyphSpacing; Size m_glyphSpacing;
TexturePtr m_texture; TexturePtr m_texture;
Rect m_glyphsTextureCoords[256]; Rect m_glyphsTextureCoords[256];

View File

@ -29,15 +29,15 @@ UILabel::UILabel()
{ {
m_focusable = false; m_focusable = false;
m_phantom = true; m_phantom = true;
m_align = Fw::AlignLeft; m_textAlign = Fw::AlignLeft;
} }
void UILabel::render() void UILabel::render()
{ {
UIWidget::render(); UIWidget::render();
Rect textRect = m_rect; Rect textRect = m_rect;
textRect.setTopLeft(textRect.topLeft() + m_offset); textRect.setTopLeft(textRect.topLeft() + m_textOffset);
m_font->renderText(m_text, textRect, m_align, m_foregroundColor); m_font->renderText(m_text, textRect, m_textAlign, m_foregroundColor);
} }
void UILabel::setText(const std::string& text) void UILabel::setText(const std::string& text)
@ -66,10 +66,10 @@ void UILabel::onStyleApply(const OTMLNodePtr& styleNode)
for(const OTMLNodePtr& node : styleNode->children()) { for(const OTMLNodePtr& node : styleNode->children()) {
if(node->tag() == "text") if(node->tag() == "text")
setText(node->value()); setText(node->value());
else if(node->tag() == "align") else if(node->tag() == "text-align")
setAlign(Fw::translateAlignment(node->value())); setTextAlign(Fw::translateAlignment(node->value()));
else if(node->tag() == "offset") { else if(node->tag() == "text-offset") {
setOffset(node->value<Point>()); setTextOffset(node->value<Point>());
} }
} }
} }

View File

@ -34,20 +34,20 @@ public:
void resizeToText(); void resizeToText();
void setText(const std::string& text); void setText(const std::string& text);
void setAlign(Fw::AlignmentFlag align) { m_align = align; } void setTextAlign(Fw::AlignmentFlag align) { m_textAlign = align; }
void setOffset(const Point& offset) { m_offset = offset; } void setTextOffset(const Point& offset) { m_textOffset = offset; }
std::string getText() const { return m_text; } std::string getText() const { return m_text; }
Fw::AlignmentFlag getAlign() const { return m_align; } Fw::AlignmentFlag getTextAlign() const { return m_textAlign; }
Point getOffset() const { return m_offset; } Point getTextOffset() const { return m_textOffset; }
protected: protected:
virtual void onStyleApply(const OTMLNodePtr& styleNode); virtual void onStyleApply(const OTMLNodePtr& styleNode);
private: private:
std::string m_text; std::string m_text;
Point m_offset; Point m_textOffset;
Fw::AlignmentFlag m_align; Fw::AlignmentFlag m_textAlign;
}; };
#endif #endif

View File

@ -33,7 +33,7 @@ UILineEdit::UILineEdit()
m_startRenderPos = 0; m_startRenderPos = 0;
m_textHorizontalMargin = 0; m_textHorizontalMargin = 0;
m_textHidden = false; m_textHidden = false;
m_alwaysFocused = false; m_alwaysActive = false;
blinkCursor(); blinkCursor();
} }
@ -51,7 +51,7 @@ void UILineEdit::render()
g_graphics.drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]); g_graphics.drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]);
// render cursor // render cursor
if(isExplicitlyEnabled() && (isActive() || m_alwaysFocused) && m_cursorPos >= 0) { if(isExplicitlyEnabled() && (isActive() || m_alwaysActive) && m_cursorPos >= 0) {
assert(m_cursorPos <= textLength); assert(m_cursorPos <= textLength);
// draw every 333ms // draw every 333ms
const int delay = 333; const int delay = 333;
@ -98,7 +98,7 @@ void UILineEdit::update()
if(m_cursorPos < m_startRenderPos) // cursor is before the previuos first rendered glyph, so we need to update if(m_cursorPos < m_startRenderPos) // cursor is before the previuos first rendered glyph, so we need to update
{ {
m_startInternalPos.x = glyphsPositions[m_cursorPos].x; m_startInternalPos.x = glyphsPositions[m_cursorPos].x;
m_startInternalPos.y = glyphsPositions[m_cursorPos].y - m_font->getTopMargin(); m_startInternalPos.y = glyphsPositions[m_cursorPos].y - m_font->getYOffset();
m_startRenderPos = m_cursorPos; m_startRenderPos = m_cursorPos;
} else if(m_cursorPos > m_startRenderPos || // cursor is after the previuos first rendered glyph } else if(m_cursorPos > m_startRenderPos || // cursor is after the previuos first rendered glyph
(m_cursorPos == m_startRenderPos && textLength == m_cursorPos)) // cursor is at the previuos rendered element, and is the last text element (m_cursorPos == m_startRenderPos && textLength == m_cursorPos)) // cursor is at the previuos rendered element, and is the last text element
@ -119,13 +119,13 @@ void UILineEdit::update()
for(pos = 0; pos < textLength; ++pos) { for(pos = 0; pos < textLength; ++pos) {
glyph = (uchar)text[pos]; glyph = (uchar)text[pos];
glyphRect = Rect(glyphsPositions[pos], glyphsSize[glyph]); glyphRect = Rect(glyphsPositions[pos], glyphsSize[glyph]);
glyphRect.setTop(std::max(glyphRect.top() - m_font->getTopMargin() - m_font->getGlyphSpacing().height(), 0)); glyphRect.setTop(std::max(glyphRect.top() - m_font->getYOffset() - m_font->getGlyphSpacing().height(), 0));
glyphRect.setLeft(std::max(glyphRect.left() - m_font->getGlyphSpacing().width(), 0)); glyphRect.setLeft(std::max(glyphRect.left() - m_font->getGlyphSpacing().width(), 0));
// first glyph entirely visible found // first glyph entirely visible found
if(glyphRect.topLeft() >= startGlyphPos) { if(glyphRect.topLeft() >= startGlyphPos) {
m_startInternalPos.x = glyphsPositions[pos].x; m_startInternalPos.x = glyphsPositions[pos].x;
m_startInternalPos.y = glyphsPositions[pos].y - m_font->getTopMargin(); m_startInternalPos.y = glyphsPositions[pos].y - m_font->getYOffset();
m_startRenderPos = pos; m_startRenderPos = pos;
break; break;
} }
@ -351,7 +351,7 @@ int UILineEdit::getTextPos(Point pos)
int candidatePos = -1; int candidatePos = -1;
for(int i=0;i<textLength;++i) { for(int i=0;i<textLength;++i) {
Rect clickGlyphRect = m_glyphsCoords[i]; Rect clickGlyphRect = m_glyphsCoords[i];
clickGlyphRect.addTop(m_font->getTopMargin() + m_font->getGlyphSpacing().height()); clickGlyphRect.addTop(m_font->getYOffset() + m_font->getGlyphSpacing().height());
clickGlyphRect.addLeft(m_font->getGlyphSpacing().width()+1); clickGlyphRect.addLeft(m_font->getGlyphSpacing().width()+1);
if(clickGlyphRect.contains(pos)) if(clickGlyphRect.contains(pos))
return i; return i;
@ -381,12 +381,12 @@ void UILineEdit::onStyleApply(const OTMLNodePtr& styleNode)
if(node->tag() == "text") { if(node->tag() == "text") {
setText(node->value()); setText(node->value());
setCursorPos(m_text.length()); setCursorPos(m_text.length());
} else if(node->tag() == "text hidden") { } else if(node->tag() == "text-hidden") {
setTextHidden(node->value<bool>()); setTextHidden(node->value<bool>());
} else if(node->tag() == "text margin") { } else if(node->tag() == "text-margin") {
m_textHorizontalMargin = node->value<int>(); m_textHorizontalMargin = node->value<int>();
} else if(node->tag() == "always focused") { } else if(node->tag() == "always-active") {
m_alwaysFocused = true; m_alwaysActive = true;
} }
} }
} }
@ -398,7 +398,7 @@ void UILineEdit::onGeometryUpdate(const Rect& oldRect, const Rect& newRect)
void UILineEdit::onFocusChange(bool focused, Fw::FocusReason reason) void UILineEdit::onFocusChange(bool focused, Fw::FocusReason reason)
{ {
if(focused && !m_alwaysFocused) { if(focused && !m_alwaysActive) {
if(reason == Fw::TabFocusReason) if(reason == Fw::TabFocusReason)
setCursorPos(m_text.length()); setCursorPos(m_text.length());
else else
@ -423,7 +423,7 @@ bool UILineEdit::onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers)
else if(keyCode == Fw::KeyV && keyboardModifiers == Fw::KeyboardCtrlModifier) else if(keyCode == Fw::KeyV && keyboardModifiers == Fw::KeyboardCtrlModifier)
appendText(g_platform.getClipboardText()); appendText(g_platform.getClipboardText());
else if(keyCode == Fw::KeyTab) { else if(keyCode == Fw::KeyTab) {
if(!m_alwaysFocused) { if(!m_alwaysActive) {
if(UIWidgetPtr parent = getParent()) if(UIWidgetPtr parent = getParent())
parent->focusNextChild(Fw::TabFocusReason); parent->focusNextChild(Fw::TabFocusReason);
} }

View File

@ -71,7 +71,7 @@ private:
int m_cursorTicks; int m_cursorTicks;
int m_textHorizontalMargin; int m_textHorizontalMargin;
bool m_textHidden; bool m_textHidden;
bool m_alwaysFocused; bool m_alwaysActive;
std::vector<Rect> m_glyphsCoords; std::vector<Rect> m_glyphsCoords;
std::vector<Rect> m_glyphsTexCoords; std::vector<Rect> m_glyphsTexCoords;

View File

@ -36,7 +36,7 @@ void UIVerticalLayout::applyStyle(const OTMLNodePtr& styleNode)
UILayout::applyStyle(styleNode); UILayout::applyStyle(styleNode);
for(const OTMLNodePtr& node : styleNode->children()) { for(const OTMLNodePtr& node : styleNode->children()) {
if(node->tag() == "align bottom") if(node->tag() == "align-bottom")
m_alignBottom = node->value<bool>(); m_alignBottom = node->value<bool>();
else if(node->tag() == "padding") else if(node->tag() == "padding")
m_padding = node->value<int>(); m_padding = node->value<int>();

View File

@ -40,7 +40,7 @@ UIWidget::UIWidget()
m_states = Fw::DefaultState; m_states = Fw::DefaultState;
m_font = g_fonts.getDefaultFont(); m_font = g_fonts.getDefaultFont();
m_opacity = 255; m_opacity = 255;
m_marginTop = m_marginBottom = m_marginLeft = m_marginRight = 0; m_marginTop = m_marginRight = m_marginBottom = m_marginLeft = 0;
// generate an unique id, this is need because anchored layouts find widgets by id // generate an unique id, this is need because anchored layouts find widgets by id
static unsigned long id = 1; static unsigned long id = 1;
@ -817,7 +817,7 @@ void UIWidget::onStyleApply(const OTMLNodePtr& styleNode)
setWidth(node->value<int>()); setWidth(node->value<int>());
else if(node->tag() == "height") else if(node->tag() == "height")
setHeight(node->value<int>()); setHeight(node->value<int>());
else if(node->tag() == "size fixed") else if(node->tag() == "fixed-size")
setSizeFixed(node->value<bool>()); setSizeFixed(node->value<bool>());
else if(node->tag() == "position") else if(node->tag() == "position")
moveTo(node->value<Point>()); moveTo(node->value<Point>());
@ -825,14 +825,46 @@ void UIWidget::onStyleApply(const OTMLNodePtr& styleNode)
setX(node->value<int>()); setX(node->value<int>());
else if(node->tag() == "y") else if(node->tag() == "y")
setY(node->value<int>()); setY(node->value<int>());
else if(node->tag() == "margin.left") else if(node->tag() == "margin-top")
setMarginLeft(node->value<int>());
else if(node->tag() == "margin.right")
setMarginRight(node->value<int>());
else if(node->tag() == "margin.top")
setMarginTop(node->value<int>()); setMarginTop(node->value<int>());
else if(node->tag() == "margin.bottom") else if(node->tag() == "margin-right")
setMarginRight(node->value<int>());
else if(node->tag() == "margin-bottom")
setMarginBottom(node->value<int>()); setMarginBottom(node->value<int>());
else if(node->tag() == "margin-left")
setMarginLeft(node->value<int>());
else if(node->tag() == "margin") {
std::string marginDesc = node->value();
std::vector<std::string> split;
boost::split(split, marginDesc, boost::is_any_of(std::string(" ")));
if(split.size() == 4) {
setMarginTop(Fw::safeCast<int>(split[0]));
setMarginRight(Fw::safeCast<int>(split[1]));
setMarginBottom(Fw::safeCast<int>(split[2]));
setMarginLeft(Fw::safeCast<int>(split[3]));
} else if(split.size() == 3) {
int marginTop = Fw::safeCast<int>(split[0]);
int marginHorizontal = Fw::safeCast<int>(split[1]);
int marginBottom = Fw::safeCast<int>(split[2]);
setMarginTop(marginTop);
setMarginRight(marginHorizontal);
setMarginBottom(marginBottom);
setMarginLeft(marginHorizontal);
} else if(split.size() == 2) {
int marginVertical = Fw::safeCast<int>(split[0]);
int marginHorizontal = Fw::safeCast<int>(split[1]);
setMarginTop(marginVertical);
setMarginRight(marginHorizontal);
setMarginBottom(marginVertical);
setMarginLeft(marginHorizontal);
} else if(split.size() == 1) {
int margin = Fw::safeCast<int>(split[0]);
setMarginTop(margin);
setMarginRight(margin);
setMarginBottom(margin);
setMarginLeft(margin);
}
}
// layouts // layouts
else if(node->tag() == "layout") { else if(node->tag() == "layout") {
// layout is set only once // layout is set only once

View File

@ -62,10 +62,10 @@ public:
void setOpacity(int opacity) { m_opacity = opacity; } void setOpacity(int opacity) { m_opacity = opacity; }
void setBackgroundColor(const Color& color) { m_backgroundColor = color; } void setBackgroundColor(const Color& color) { m_backgroundColor = color; }
void setForegroundColor(const Color& color) { m_foregroundColor = color; } void setForegroundColor(const Color& color) { m_foregroundColor = color; }
void setMarginLeft(int margin) { m_marginLeft = margin; updateParentLayout(); }
void setMarginRight(int margin) { m_marginRight = margin; updateParentLayout(); }
void setMarginTop(int margin) { m_marginTop = margin; updateParentLayout(); } void setMarginTop(int margin) { m_marginTop = margin; updateParentLayout(); }
void setMarginRight(int margin) { m_marginRight = margin; updateParentLayout(); }
void setMarginBottom(int margin) { m_marginBottom = margin; updateParentLayout(); } void setMarginBottom(int margin) { m_marginBottom = margin; updateParentLayout(); }
void setMarginLeft(int margin) { m_marginLeft = margin; updateParentLayout(); }
void setSizeFixed(bool fixed) { m_fixedSize = fixed; updateParentLayout(); } void setSizeFixed(bool fixed) { m_fixedSize = fixed; updateParentLayout(); }
void setLastFocusReason(Fw::FocusReason reason) { m_lastFocusReason = reason; } void setLastFocusReason(Fw::FocusReason reason) { m_lastFocusReason = reason; }
@ -112,10 +112,10 @@ public:
Color getForegroundColor() { return m_foregroundColor; } Color getForegroundColor() { return m_foregroundColor; }
Color getBackgroundColor() { return m_backgroundColor; } Color getBackgroundColor() { return m_backgroundColor; }
int getOpacity() { return m_opacity; } int getOpacity() { return m_opacity; }
int getMarginLeft() { return m_marginLeft; }
int getMarginRight() { return m_marginRight; }
int getMarginTop() { return m_marginTop; } int getMarginTop() { return m_marginTop; }
int getMarginRight() { return m_marginRight; }
int getMarginBottom() { return m_marginBottom; } int getMarginBottom() { return m_marginBottom; }
int getMarginLeft() { return m_marginLeft; }
Fw::FocusReason getLastFocusReason() { return m_lastFocusReason; } Fw::FocusReason getLastFocusReason() { return m_lastFocusReason; }
OTMLNodePtr getStyle() { return m_style; } OTMLNodePtr getStyle() { return m_style; }
@ -205,10 +205,10 @@ protected:
Color m_foregroundColor; Color m_foregroundColor;
int m_states; int m_states;
int m_opacity; int m_opacity;
int m_marginLeft;
int m_marginRight;
int m_marginTop; int m_marginTop;
int m_marginRight;
int m_marginBottom; int m_marginBottom;
int m_marginLeft;
}; };
#endif #endif

View File

@ -41,19 +41,17 @@ void UIWindow::render()
// render children // render children
UIWidget::render(); UIWidget::render();
// draw window head
// draw window head text // draw window head text
Rect headTextRect = m_rect; Rect headTextRect = m_rect;
headTextRect.addTop(-m_headOffset.y); headTextRect.addTop(-m_headTextOffset.y);
headTextRect.setHeight(m_headHeight); headTextRect.setHeight(m_headHeight);
if(m_titleAlign & Fw::AlignLeft) if(m_titleAlign & Fw::AlignLeft)
headTextRect.addLeft(-m_headOffset.x); headTextRect.addLeft(-m_headTextOffset.x);
else if(m_titleAlign & Fw::AlignRight) else if(m_titleAlign & Fw::AlignRight)
headTextRect.addRight(-m_headOffset.x); headTextRect.addRight(-m_headTextOffset.x);
else { else {
headTextRect.addLeft(-m_headOffset.x); headTextRect.addLeft(-m_headTextOffset.x);
headTextRect.addRight(-m_headOffset.x); headTextRect.addRight(-m_headTextOffset.x);
} }
m_font->renderText(m_title, headTextRect, m_titleAlign, m_foregroundColor); m_font->renderText(m_title, headTextRect, m_titleAlign, m_foregroundColor);
} }
@ -63,15 +61,15 @@ void UIWindow::onStyleApply(const OTMLNodePtr& styleNode)
UIWidget::onStyleApply(styleNode); UIWidget::onStyleApply(styleNode);
for(OTMLNodePtr node : styleNode->children()) { for(OTMLNodePtr node : styleNode->children()) {
if(node->tag() == "head height") if(node->tag() == "head-height")
m_headHeight = node->value<int>(); m_headHeight = node->value<int>();
else if(node->tag() == "head offset") else if(node->tag() == "head-text-offset")
m_headOffset = node->value<Point>(); m_headTextOffset = node->value<Point>();
else if(node->tag() == "title") else if(node->tag() == "title")
setTitle(node->value()); setTitle(node->value());
else if(node->tag() == "head text align") else if(node->tag() == "head-text-align")
m_titleAlign = Fw::translateAlignment(node->value()); m_titleAlign = Fw::translateAlignment(node->value());
else if(node->tag() == "move policy") { else if(node->tag() == "move-policy") {
if(node->value() == "free") if(node->value() == "free")
m_movePolicy = FREE_MOVE; m_movePolicy = FREE_MOVE;
else if(node->value() == "free updated") else if(node->value() == "free updated")
@ -79,14 +77,6 @@ void UIWindow::onStyleApply(const OTMLNodePtr& styleNode)
else else
m_movePolicy = DONT_MOVE; m_movePolicy = DONT_MOVE;
} }
else if(node->tag() == "onEnter") {
g_lua.loadFunction(node->value(), "@" + node->source() + "[" + node->tag() + "]");
luaSetField(node->tag());
}
else if(node->tag() == "onEscape") {
g_lua.loadFunction(node->value(), "@" + node->source() + "[" + node->tag() + "]");
luaSetField(node->tag());
}
} }
} }

View File

@ -53,7 +53,7 @@ private:
bool m_moving; bool m_moving;
MovePolicy m_movePolicy; MovePolicy m_movePolicy;
Fw::AlignmentFlag m_titleAlign; Fw::AlignmentFlag m_titleAlign;
Point m_headOffset; Point m_headTextOffset;
Point m_movingReference; Point m_movingReference;
Point m_oldPos; Point m_oldPos;
int m_oldIndex; int m_oldIndex;