Browse Source

major UIWidget rewrite with new features

Eduardo Bart 9 years ago
parent
commit
a1374baee1
83 changed files with 2002 additions and 2022 deletions
  1. 5
    1
      TODO
  2. 5
    3
      modules/addon_mapeffects/mapeffects.lua
  3. 1
    1
      modules/addon_pingbar/pingbar.lua
  4. 2
    2
      modules/addon_terminal/terminal.otui
  5. 3
    4
      modules/client_background/background.otui
  6. 1
    5
      modules/client_entergame/characterlist.otui
  7. 11
    16
      modules/client_topmenu/topmenu.otui
  8. 3
    0
      modules/core_lib/globals.lua
  9. 1
    0
      modules/core_styles/core_styles.otmod
  10. BIN
      modules/core_styles/icons/say.png
  11. BIN
      modules/core_styles/icons/whisper.png
  12. BIN
      modules/core_styles/icons/yell.png
  13. BIN
      modules/core_styles/images/empty_rect.png
  14. BIN
      modules/core_styles/images/empty_rounded_rect.png
  15. 10
    13
      modules/core_styles/styles/buttons.otui
  16. 21
    27
      modules/core_styles/styles/checkboxes.otui
  17. 20
    28
      modules/core_styles/styles/comboboxes.otui
  18. 2
    3
      modules/core_styles/styles/creatures.otui
  19. 2
    3
      modules/core_styles/styles/items.otui
  20. 2
    3
      modules/core_styles/styles/lineedits.otui
  21. 3
    3
      modules/core_styles/styles/listboxes.otui
  22. 10
    18
      modules/core_styles/styles/panels.otui
  23. 8
    12
      modules/core_styles/styles/popupmenus.otui
  24. 4
    0
      modules/core_styles/styles/progressbars.otui
  25. 2
    3
      modules/core_styles/styles/separators.otui
  26. 5
    0
      modules/core_styles/styles/tabbars.otui
  27. 8
    11
      modules/core_styles/styles/windows.otui
  28. 5
    3
      modules/core_widgets/core_widgets.otmod
  29. 2
    2
      modules/core_widgets/tooltip/tooltip.lua
  30. 1
    1
      modules/core_widgets/tooltip/tooltip.otui
  31. 7
    1
      modules/core_widgets/uicheckbox.lua
  32. 19
    0
      modules/core_widgets/uiprogressbar.lua
  33. 1
    0
      modules/core_widgets/uitabbar.lua
  34. 17
    17
      modules/core_widgets/uiwidget.lua
  35. 30
    1
      modules/game_console/console.otui
  36. 2
    4
      modules/game_healthbar/healthbar.otui
  37. 4
    6
      modules/game_inventory/inventory.otui
  38. 4
    5
      modules/game_skills/skills.otui
  39. 3
    3
      modules/game_viplist/viplist.otui
  40. 3
    4
      src/framework/CMakeLists.txt
  41. 0
    201
      src/framework/graphics/borderimage.cpp
  42. 0
    65
      src/framework/graphics/borderimage.h
  43. 0
    4
      src/framework/graphics/declarations.h
  44. 1
    1
      src/framework/graphics/framebuffer.cpp
  45. 0
    82
      src/framework/graphics/image.cpp
  46. 0
    50
      src/framework/graphics/image.h
  47. 3
    3
      src/framework/graphics/painter.h
  48. 1
    1
      src/framework/graphics/particle.cpp
  49. 16
    5
      src/framework/graphics/texture.cpp
  50. 2
    1
      src/framework/graphics/texture.h
  51. 178
    91
      src/framework/luafunctions.cpp
  52. 4
    0
      src/framework/luascript/luavaluecasts.h
  53. 13
    10
      src/framework/math/rect.h
  54. 0
    8
      src/framework/ui/declarations.h
  55. 0
    2
      src/framework/ui/ui.h
  56. 0
    79
      src/framework/ui/uicheckbox.cpp
  57. 0
    49
      src/framework/ui/uicheckbox.h
  58. 2
    2
      src/framework/ui/uiframecounter.cpp
  59. 1
    1
      src/framework/ui/uiframecounter.h
  60. 0
    41
      src/framework/ui/uiimage.cpp
  61. 0
    69
      src/framework/ui/uiimage.h
  62. 4
    1
      src/framework/ui/uilayout.cpp
  63. 5
    0
      src/framework/ui/uilayout.h
  64. 5
    5
      src/framework/ui/uilineedit.cpp
  65. 1
    1
      src/framework/ui/uilineedit.h
  66. 2
    2
      src/framework/ui/uimanager.cpp
  67. 0
    53
      src/framework/ui/uiprogressbar.cpp
  68. 0
    41
      src/framework/ui/uiprogressbar.h
  69. 1
    1
      src/framework/ui/uiverticallayout.cpp
  70. 539
    747
      src/framework/ui/uiwidget.cpp
  71. 332
    171
      src/framework/ui/uiwidget.h
  72. 366
    0
      src/framework/ui/uiwidgetbasestyle.cpp
  73. 175
    0
      src/framework/ui/uiwidgetimage.cpp
  74. 94
    0
      src/framework/ui/uiwidgettext.cpp
  75. 9
    10
      src/framework/ui/uiwindow.cpp
  76. 1
    1
      src/framework/ui/uiwindow.h
  77. 4
    4
      src/otclient/ui/uicreature.cpp
  78. 1
    1
      src/otclient/ui/uicreature.h
  79. 4
    4
      src/otclient/ui/uiitem.cpp
  80. 1
    1
      src/otclient/ui/uiitem.h
  81. 4
    5
      src/otclient/ui/uimap.cpp
  82. 1
    1
      src/otclient/ui/uimap.h
  83. 5
    5
      tools/lua-binding-generator/generate_lua_bindings.lua

+ 5
- 1
TODO View File

@@ -16,6 +16,7 @@
16 16
 == Lua
17 17
 [bart] make possible to bind non LuaObject derived classes on lua engine (for usage with Point,Rect,Color,Size)
18 18
 [bart] bind every global lua function in static classes
19
+[bart] review usage of x,y/width,height in lua instead of point/size
19 20
 
20 21
 == Platform
21 22
 [bart] port to MacOs and iphone
@@ -101,4 +102,7 @@ if a spell is used while pressing arrows keys the walk is canceled and it doesnt
101 102
 game map text message boxes is not displayed like tibia
102 103
 name/shields doesnt follow the creature when walking on parcels
103 104
 hotkeys wont work with caps lock
104
-hotkeys works while windows are locked, it shouldnt
105
+hotkeys works while windows are locked, it shouldnt
106
+
107
+-- current todo
108
+allow usage of background width alone

+ 5
- 3
modules/addon_mapeffects/mapeffects.lua View File

@@ -2,13 +2,15 @@ MapEffects = {}
2 2
 
3 3
 function MapEffects.init()
4 4
 --[[
5
-  local box = createWidget('ComboBox')
6
-  box:moveTo({x=100, y=8})
5
+  local box = createWidget('ComboBox', 'leftButtonsPanel')
6
+  box:addAnchor(AnchorLeft, 'prev', AnchorRight)
7
+  box:addAnchor(AnchorTop, 'parent', AnchorTop)
8
+  box:setMargin(6, 6)
7 9
   box:addOption('Normal')
8 10
   box:addOption('Bloom')
9 11
   box:addOption('TV')
10 12
   displayUI(box)
11
-  ]]--
13
+]]--
12 14
 end
13 15
 
14 16
 function MapEffects.terminate()

+ 1
- 1
modules/addon_pingbar/pingbar.lua View File

@@ -21,7 +21,7 @@ end
21 21
 
22 22
 -- hooked events
23 23
 local function onGamePingUpdate(ping)
24
-  pingLabel:setText('Walk Ping: ' .. ping .. ' ms')
24
+  pingLabel:setText('Ping: ' .. ping .. ' ms')
25 25
 end
26 26
 
27 27
 connect(Game, { onWalkPingUpdate = onGamePingUpdate })

+ 2
- 2
modules/addon_terminal/terminal.otui View File

@@ -2,10 +2,10 @@ TerminalLabel < UILabel
2 2
   font: terminus-14px-bold
3 3
   height: 16
4 4
 
5
-RectPanel
5
+Panel
6 6
   id: terminalPanel
7 7
   background-color: #000000
8
-  opacity: 216
8
+  opacity: 0.85
9 9
   anchors.fill: parent
10 10
   @onEscape: Terminal.hide()
11 11
 

+ 3
- 4
modules/client_background/background.otui View File

@@ -1,9 +1,8 @@
1 1
 Panel
2 2
   id: background
3
-  image:
4
-    source: /client_background/background.png
5
-    smooth: true
6
-    fixed ratio: true
3
+  image-source: /client_background/background.png
4
+  image-smooth: true
5
+  image-fixed-ratio: true
7 6
   anchors.top: topMenu.bottom
8 7
   anchors.left: parent.left
9 8
   anchors.right: parent.right

+ 1
- 5
modules/client_entergame/characterlist.otui View File

@@ -1,12 +1,8 @@
1 1
 CharacterListLabel < Label
2
-  image: /core_styles/images/empty_rect.png
3 2
   font: verdana-11px-monochrome
4
-  background-color: #00000000
3
+  background-color: alpha
5 4
   text-offset: 2 0
6 5
   focusable: true
7
-  margin-left: 1
8
-  margin-right: 1
9
-  margin-top: 1
10 6
 
11 7
   $focus:
12 8
     background-color: #ffffff22

+ 11
- 16
modules/client_topmenu/topmenu.otui View File

@@ -1,27 +1,22 @@
1 1
 TopButton < UIButton
2
-  background-color: white
3 2
   size: 26 26
4
-  text-translate: 0 0
5
-  border-image:
6
-    source: /core_styles/images/top_button.png
7
-    clip: 0 0 26 26
8
-    border: 3
3
+  image-color: white
4
+  image-source: /core_styles/images/top_button.png
5
+  image-clip: 0 0 26 26
6
+  image-border: 3
9 7
 
10 8
   $hover:
11
-    border-image:
12
-      source: /core_styles/images/top_button.png
13
-      clip: 26 0 26 26
14
-      border: 3
9
+    image-source: /core_styles/images/top_button.png
10
+    image-clip: 26 0 26 26
11
+    image-border: 3
15 12
 
16 13
   $pressed:
17
-    text-translate: 1 1
18
-    border-image:
19
-      source: /core_styles/images/top_button.png
20
-      clip: 52 0 26 26
21
-      border: 3
14
+    image-source: /core_styles/images/top_button.png
15
+    image-clip: 52 0 26 26
16
+    image-border: 3
22 17
 
23 18
   $disabled:
24
-    background-color: #ffffff66
19
+    image-color: #ffffff66
25 20
 
26 21
 TopLeftButton < TopButton
27 22
   $first:

+ 3
- 0
modules/core_lib/globals.lua View File

@@ -66,6 +66,9 @@ function createWidget(style, parent)
66 66
 
67 67
   local widget = class.create()
68 68
   if parent then
69
+    if type(parent) == 'string' then
70
+      parent = rootWidget:recursiveGetChildById(parent)
71
+    end
69 72
     parent:addChild(widget)
70 73
   end
71 74
   widget:setStyle(style)

+ 1
- 0
modules/core_styles/core_styles.otmod View File

@@ -11,6 +11,7 @@ Module
11 11
     importStyle 'styles/separators.otui'
12 12
     importStyle 'styles/lineedits.otui'
13 13
     importStyle 'styles/checkboxes.otui'
14
+    importStyle 'styles/progressbars.otui'
14 15
     importStyle 'styles/windows.otui'
15 16
     importStyle 'styles/listboxes.otui'
16 17
     importStyle 'styles/items.otui'

BIN
modules/core_styles/icons/say.png View File


BIN
modules/core_styles/icons/whisper.png View File


BIN
modules/core_styles/icons/yell.png View File


BIN
modules/core_styles/images/empty_rect.png View File


BIN
modules/core_styles/images/empty_rounded_rect.png View File


+ 10
- 13
modules/core_styles/styles/buttons.otui View File

@@ -1,26 +1,23 @@
1 1
 Button < UIButton
2 2
   font: verdana-11px-antialised
3
-  background-color: white
4 3
   color: #f0ad4dff
5 4
   size: 106 24
6
-  text-translate: 0 0
5
+  text-offset: 0 0
7 6
 
8
-  border-image:
9
-    source: /core_styles/images/button.png
10
-    border: 5
7
+  image-color: white
8
+  image-source: /core_styles/images/button.png
9
+  image-border: 5
11 10
 
12 11
   $hover:
13
-    border-image:
14
-      source: /core_styles/images/button_hover.png
15
-      border: 5
12
+    image-source: /core_styles/images/button_hover.png
13
+    image-border: 5
16 14
 
17 15
   $pressed:
18
-    text-translate: 1 1
19
-    border-image:
20
-      source: /core_styles/images/button_down.png
21
-      border: 5
16
+    text-offset: 1 1
17
+    image-source: /core_styles/images/button_down.png
18
+    image-border: 5
22 19
 
23 20
   $disabled:
24 21
     color: #f0ad4d88
25
-    background-color: #ffffff88
22
+    image-color: #ffffff88
26 23
 

+ 21
- 27
modules/core_styles/styles/checkboxes.otui View File

@@ -2,41 +2,38 @@ CheckBox < UICheckBox
2 2
   size: 12 12
3 3
   box-size: 12 12
4 4
   text-align: left
5
-  text-offset: 16 -1
5
+  text-offset: 16 0
6 6
   color: #aaaaaa
7
-  background-color: #ffffffff
7
+  image-color: #ffffffff
8
+  image-rect: 0 0 12 12
8 9
 
9 10
   $hover:
10 11
     color: #cccccc
11 12
 
12 13
   $!checked:
13
-    image:
14
-      source: /core_styles/images/checkbox.png
15
-      clip: 0 0 12 12
14
+    image-source: /core_styles/images/checkbox.png
15
+    image-clip: 0 0 12 12
16 16
 
17 17
   $hover !checked:
18
-    image:
19
-      source: /core_styles/images/checkbox.png
20
-      clip: 0 12 12 12
18
+    image-source: /core_styles/images/checkbox.png
19
+    image-clip: 0 12 12 12
21 20
 
22 21
   $checked:
23
-    image:
24
-      source: /core_styles/images/checkbox.png
25
-      clip: 0 24 12 12
22
+    image-source: /core_styles/images/checkbox.png
23
+    image-clip: 0 24 12 12
26 24
 
27 25
   $hover checked:
28
-    image:
29
-      source: /core_styles/images/checkbox.png
30
-      clip: 0 36 12 12
26
+    image-source: /core_styles/images/checkbox.png
27
+    image-clip: 0 36 12 12
31 28
 
32 29
   $disabled:
33
-    background-color: #ffffff88
30
+    image-color: #ffffff88
34 31
     color: #aaaaaa88
35 32
 
36 33
 ColorBox < UICheckBox
37 34
   size: 16 16
38 35
   box-size: 16 16
39
-  background-color: #ffffffff
36
+  image-color: #ffffffff
40 37
 
41 38
   $checked:
42 39
     image:
@@ -50,28 +47,25 @@ ColorBox < UICheckBox
50 47
 
51 48
 ButtonBox < UICheckBox
52 49
   font: verdana-11px-antialised
53
-  background-color: white
54 50
   color: #f0ad4dff
55 51
   size: 106 24
56 52
   box-size: 106 24
57 53
   text-offset: 0 0
58 54
   text-align: center
59 55
 
60
-  border-image:
61
-    source: /core_styles/images/button.png
62
-    border: 5
56
+  image-color: white
57
+  image-source: /core_styles/images/button.png
58
+  image-border: 5
63 59
 
64 60
   $hover:
65
-    border-image:
66
-      source: /core_styles/images/button_hover.png
67
-      border: 5
61
+    image-source: /core_styles/images/button_hover.png
62
+    image-border: 5
68 63
 
69 64
   $checked:
70 65
     text-offset: 1 1
71
-    border-image:
72
-      source: /core_styles/images/button_down.png
73
-      border: 5
66
+    image-source: /core_styles/images/button_down.png
67
+    image-border: 5
74 68
 
75 69
   $disabled:
76 70
     color: #f0ad4d88
77
-    background-color: #ffffff88
71
+    image-color: #ffffff88

+ 20
- 28
modules/core_styles/styles/comboboxes.otui View File

@@ -1,6 +1,6 @@
1 1
 ComboBoxPopupMenuButton < UIButton
2 2
   font: verdana-11px-antialised
3
-  background-color: alpha
3
+  image-color: alpha
4 4
   text-align: left
5 5
   text-offset: 2 0
6 6
   color: #aaaaaa
@@ -9,10 +9,7 @@ ComboBoxPopupMenuButton < UIButton
9 9
   margin-right: 1
10 10
   margin-top: 0
11 11
   margin-bottom: 0
12
-
13
-  image:
14
-    source: /core_styles/images/empty_rect.png
15
-    repeated: true
12
+  background-color: white
16 13
 
17 14
   $hover:
18 15
     color: #ffffff
@@ -30,19 +27,17 @@ ComboBoxPopupMenuButton < UIButton
30 27
 ComboBoxPopupMenuSeparator < UIWidget
31 28
   margin-left: 1
32 29
   margin-right: 1
33
-  image:
34
-    source: /core_styles/images/combobox.png
35
-    repeated: true
30
+  image-source: /core_styles/images/combobox.png
31
+  image-repeated: true
36 32
     clip: 1 59 89 1
37 33
   height: 1
38 34
   phantom: true
39 35
 
40 36
 ComboBoxPopupMenu < UIPopupMenu
41
-  border-image:
42
-    source: /core_styles/images/combobox.png
43
-    clip: 0 60 89 20
44
-    border: 1
45
-    border.top: 0
37
+  image-source: /core_styles/images/combobox.png
38
+  image-clip: 0 60 89 20
39
+  image-border: 1
40
+  image-border-top: 0
46 41
 
47 42
 ComboBox < UIComboBox
48 43
   font: verdana-11px-antialised
@@ -50,22 +45,19 @@ ComboBox < UIComboBox
50 45
   size: 86 20
51 46
   text-offset: 3 0
52 47
   text-align: left
53
-  border-image:
54
-    source: /core_styles/images/combobox.png
55
-    border: 1
56
-    border.right: 17
57
-    size: 89 20
48
+  image-source: /core_styles/images/combobox.png
49
+  image-border: 1
50
+  image-border-right: 17
51
+  image-clip: 0 0 89 20
58 52
 
59 53
   $hover:
60
-    border-image:
61
-      source: /core_styles/images/combobox.png
62
-      border: 1
63
-      border.right: 17
64
-      clip: 0 20 89 20
54
+    image-source: /core_styles/images/combobox.png
55
+    image-border: 1
56
+    image-border-right: 17
57
+    image-clip: 0 20 89 20
65 58
 
66 59
   $on:
67
-    border-image:
68
-      source: /core_styles/images/combobox.png
69
-      border: 1
70
-      border.right: 17
71
-      clip: 0 40 89 20
60
+    image-source: /core_styles/images/combobox.png
61
+    image-border: 1
62
+    image-border-right: 17
63
+    image-clip: 0 40 89 20

+ 2
- 3
modules/core_styles/styles/creatures.otui View File

@@ -1,6 +1,5 @@
1 1
 Creature < UICreature
2 2
   size: 66 66
3 3
   padding: 1
4
-  border-image:
5
-    source: /core_styles/images/panel_flat.png
6
-    border: 1
4
+  image-source: /core_styles/images/panel_flat.png
5
+  image-border: 1

+ 2
- 3
modules/core_styles/styles/items.otui View File

@@ -1,6 +1,5 @@
1 1
 Item < UIItem
2 2
   size: 34 34
3 3
   padding: 1
4
-  border-image:
5
-    source: /core_styles/images/panel_flat.png
6
-    border: 1
4
+  image-source: /core_styles/images/panel_flat.png
5
+  image-border: 1

+ 2
- 3
modules/core_styles/styles/lineedits.otui View File

@@ -3,9 +3,8 @@ LineEdit < UILineEdit
3 3
   color: #aaaaaa
4 4
   size: 86 20
5 5
   text-margin: 3
6
-  border-image:
7
-    source: /core_styles/images/panel_flat.png
8
-    border: 1
6
+  image-source: /core_styles/images/panel_flat.png
7
+  image-border: 1
9 8
 
10 9
   $disabled:
11 10
     color: #aaaaaa88

+ 3
- 3
modules/core_styles/styles/listboxes.otui View File

@@ -1,5 +1,5 @@
1 1
 TextList < UIWidget
2 2
   layout: verticalBox
3
-  border-image:
4
-    source: /core_styles/images/panel_flat.png
5
-    border: 4
3
+  border-width: 1
4
+  border-color: #1d222b
5
+  background-color: #222833

+ 10
- 18
modules/core_styles/styles/panels.otui View File

@@ -1,34 +1,26 @@
1 1
 Panel < UIWidget
2 2
   phantom: true
3 3
 
4
-RectPanel < UIWidget
5
-  image: /core_styles/images/empty_rect.png
6
-
7 4
 FlatPanel < Panel
8
-  border-image:
9
-    source: /core_styles/images/panel_flat.png
10
-    border: 1
5
+  image-source: /core_styles/images/panel_flat.png
6
+  image-border: 1
11 7
 
12 8
 TopPanel < Panel
13 9
   height: 36
14
-  image:
15
-    source: /core_styles/images/top_panel.png
16
-    repeated: true
10
+  image-source: /core_styles/images/top_panel.png
11
+  image-repeated: true
17 12
 
18 13
 InterfacePanel < Panel
19 14
   focusable: false
20
-  border-image:
21
-    source: /core_styles/images/interface_panel.png
22
-    border: 4
15
+  image-source: /core_styles/images/interface_panel.png
16
+  image-border: 4
23 17
 
24 18
 InterfacePanel2 < Panel
25 19
   focusable: false
26
-  border-image:
27
-    source: /core_styles/images/interface_panel2.png
28
-    border: 4
20
+  image-source: /core_styles/images/interface_panel2.png
21
+  image-border: 4
29 22
 
30 23
 Map< UIMap
31 24
   padding: 4
32
-  border-image:
33
-    source: /core_styles/images/map_panel.png
34
-    border: 4
25
+  image-source: /core_styles/images/map_panel.png
26
+  image-border: 4

+ 8
- 12
modules/core_styles/styles/popupmenus.otui View File

@@ -1,16 +1,13 @@
1 1
 PopupMenuButton < UIButton
2 2
   font: verdana-11px-antialised
3
-  background-color: alpha
3
+  image-color: alpha
4 4
   color: #aaaaaa
5 5
   height: 18
6 6
   margin-left: 3
7 7
   margin-right: 3
8 8
   margin-top: 0
9 9
   margin-bottom: 0
10
-
11
-  image:
12
-    source: /core_styles/images/empty_rect.png
13
-    repeated: true
10
+  background-color: alpha
14 11
 
15 12
   $hover:
16 13
     color: #ffffff
@@ -28,16 +25,15 @@ PopupMenuButton < UIButton
28 25
 PopupMenuSeparator < UIWidget
29 26
   margin-left: 2
30 27
   margin-right: 2
31
-  border-image:
32
-    source: /core_styles/images/menubox.png
33
-    border.left: 1
34
-    border.right: 1
35
-    clip: 0 0 32 2
28
+  image-source: /core_styles/images/menubox.png
29
+  image-border-left: 1
30
+  image-border-right: 1
31
+  image-clip: 0 0 32 2
36 32
   height: 2
37 33
   phantom: true
38 34
 
39 35
 PopupMenu < UIPopupMenu
40 36
   width: 50
41 37
   border-image:
42
-    source: /core_styles/images/menubox.png
43
-    border: 3
38
+  image-source: /core_styles/images/menubox.png
39
+  image-border: 3

+ 4
- 0
modules/core_styles/styles/progressbars.otui View File

@@ -0,0 +1,4 @@
1
+ProgressBar < UIProgressBar
2
+  height: 15
3
+  background-color: red
4
+  border: 1 black

+ 2
- 3
modules/core_styles/styles/separators.otui View File

@@ -1,7 +1,6 @@
1 1
 HorizontalSeparator < UIWidget
2
-  border-image:
3
-    source: /core_styles/images/horizontal_separator.png
4
-    border.top: 2
2
+  image-source: /core_styles/images/horizontal_separator.png
3
+  image-border.top: 2
5 4
   height: 2
6 5
   phantom: true
7 6
   focusable: false

+ 5
- 0
modules/core_styles/styles/tabbars.otui View File

@@ -0,0 +1,5 @@
1
+TabBar < UITabBar
2
+TabBarTabButton < UIButton
3
+TabBarCloseButton < UIButton
4
+TabBarPrevButton < UIButton
5
+TabBarNextButton < UIButton

+ 8
- 11
modules/core_styles/styles/windows.otui View File

@@ -1,20 +1,18 @@
1 1
 Window < UIWindow
2 2
   font: verdana-11px-antialised
3 3
   size: 200 200
4
-  opacity: 255
4
+  opacity: 1
5 5
   color: white
6
-  background-color: white
7 6
   head-height: 20
8 7
   head-text-align: center
9 8
   move-policy: free
10 9
   stackable: true
11
-  border-image:
12
-    source: /core_styles/images/window.png
13
-    border: 4
14
-    border.top: 20
10
+  image-source: /core_styles/images/window.png
11
+  image-border: 4
12
+  image-border-top: 20
15 13
 
16 14
   $pressed:
17
-    opacity: 192
15
+    opacity: 0.75
18 16
 
19 17
   $disabled:
20 18
     color: #aaaaaa88
@@ -28,10 +26,9 @@ MiniWindow < UIWindow
28 26
   margin-left: 6
29 27
   margin-right: 6
30 28
   move-policy: free updated
31
-  border-image:
32
-    source: /core_styles/images/mini_window.png
33
-    border: 4
34
-    border.top: 25
29
+  image-source: /core_styles/images/mini_window.png
30
+  image-border: 4
31
+  image-border-top: 25
35 32
 
36 33
 MainWindow < Window
37 34
   anchors.centerIn: parent

+ 5
- 3
modules/core_widgets/core_widgets.otmod View File

@@ -5,10 +5,12 @@ Module
5 5
   website: https://github.com/edubart/otclient
6 6
 
7 7
   onLoad: |
8
-    require 'tooltip/tooltip'
9
-    require 'messagebox/messagebox'
10 8
     require 'uiwidget'
11 9
     require 'uibutton'
12 10
     require 'uilabel'
11
+    require 'uicheckbox'
13 12
     require 'uicombobox'
14
-    require 'uipopupmenu'
13
+    require 'uiprogressbar'
14
+    require 'uipopupmenu'
15
+    require 'tooltip/tooltip'
16
+    require 'messagebox/messagebox'

+ 2
- 2
modules/core_widgets/tooltip/tooltip.lua View File

@@ -13,7 +13,7 @@ local function moveToolTip(tooltip)
13 13
   else
14 14
     pos.x = pos.x + 10
15 15
   end
16
-  tooltip:moveTo(pos)
16
+  tooltip:setPos(pos)
17 17
 end
18 18
 
19 19
 -- public functions
@@ -28,7 +28,7 @@ function ToolTip.display(text)
28 28
     local size = label:getSize()
29 29
     size.width = size.width + 4
30 30
     size.height = size.height + 4
31
-    currentToolTip:resize(size)
31
+    currentToolTip:setSize(size)
32 32
     moveToolTip(currentToolTip)
33 33
   end
34 34
 end

+ 1
- 1
modules/core_widgets/tooltip/tooltip.otui View File

@@ -1,4 +1,4 @@
1
-RectPanel
1
+Panel
2 2
   background-color: #111111bb
3 3
   size: 200 200
4 4
   id: toolTip

+ 7
- 1
modules/core_widgets/uicheckbox.lua View File

@@ -3,6 +3,12 @@ UICheckBox = extends(UIWidget)
3 3
 function UICheckBox.create()
4 4
   local checkbox = UICheckBox.internalCreate()
5 5
   checkbox:setFocusable(false)
6
-  checkbox:setAlign(AlignLeft)
6
+  checkbox:setTextAlign(AlignLeft)
7 7
   return checkbox
8 8
 end
9
+
10
+function UICheckBox:onMouseRelease(mousePos, mouseButton)
11
+  if self:isPressed() and self:containsPoint(mousePos) then
12
+    self:setChecked(not self:isChecked())
13
+  end
14
+end

+ 19
- 0
modules/core_widgets/uiprogressbar.lua View File

@@ -0,0 +1,19 @@
1
+UIProgressBar = extends(UIWidget)
2
+
3
+function UIProgressBar.create()
4
+  local progressbar = UIProgressBar.internalCreate()
5
+  progressbar:setFocusable(false)
6
+  progressbar:setPhantom(true)
7
+  progressbar.percent = 100
8
+  return progressbar
9
+end
10
+
11
+function UIProgressBar:setPercent(percent)
12
+  self:setBackgroundHeight(self:getHeight())
13
+  self:setBackgroundWidth((percent * self:getWidth())/100)
14
+  self.percent = percent
15
+end
16
+
17
+function UIProgressBar:getPercent()
18
+  return self.percent
19
+end

+ 1
- 0
modules/core_widgets/uitabbar.lua View File

@@ -0,0 +1 @@
1
+UITabBar = extends(UIWidget)

+ 17
- 17
modules/core_widgets/uiwidget.lua View File

@@ -1,19 +1,19 @@
1 1
 function UIWidget:setMargin(...)
2
-    local params = {...}
3
-    if #params == 1 then
4
-        self:setMarginTop(params[1])
5
-        self:setMarginRight(params[1])
6
-        self:setMarginBottom(params[1])
7
-        self:setMarginLeft(params[1])
8
-    elseif #params == 2 then
9
-        self:setMarginTop(params[1])
10
-        self:setMarginRight(params[2])
11
-        self:setMarginBottom(params[1])
12
-        self:setMarginLeft(params[2])
13
-    elseif #params == 4 then
14
-        self:setMarginTop(params[1])
15
-        self:setMarginRight(params[2])
16
-        self:setMarginBottom(params[3])
17
-        self:setMarginLeft(params[4])
18
-    end
2
+  local params = {...}
3
+  if #params == 1 then
4
+    self:setMarginTop(params[1])
5
+    self:setMarginRight(params[1])
6
+    self:setMarginBottom(params[1])
7
+    self:setMarginLeft(params[1])
8
+  elseif #params == 2 then
9
+    self:setMarginTop(params[1])
10
+    self:setMarginRight(params[2])
11
+    self:setMarginBottom(params[1])
12
+    self:setMarginLeft(params[2])
13
+  elseif #params == 4 then
14
+    self:setMarginTop(params[1])
15
+    self:setMarginRight(params[2])
16
+    self:setMarginBottom(params[3])
17
+    self:setMarginLeft(params[4])
18
+  end
19 19
 end

+ 30
- 1
modules/game_console/console.otui View File

@@ -3,6 +3,27 @@ ConsoleLabel < UILabel
3 3
   height: 14
4 4
   color: yellow
5 5
 
6
+SayModeButton < UIButton
7
+  size: 26 26
8
+  icon: /core_styles/icons/say.png
9
+  image-source: /core_styles/images/top_button.png
10
+  image-color: white
11
+  image-clip: 0 0 26 26
12
+  image-border: 3
13
+
14
+  $hover:
15
+    image-source: /core_styles/images/top_button.png
16
+      clip: 26 0 26 26
17
+      border: 3
18
+
19
+  $pressed:
20
+    image-source: /core_styles/images/top_button.png
21
+    image-clip: 52 0 26 26
22
+    image-border: 3
23
+
24
+  $disabled:
25
+    image-color: #ffffff66
26
+
6 27
 Panel
7 28
   id: consolePanel
8 29
   anchors.fill: parent
@@ -22,9 +43,17 @@ Panel
22 43
       align-bottom: true
23 44
     focusable: false
24 45
 
46
+  SayModeButton
47
+    id: sayModeButton
48
+    size: 20 20
49
+    anchors.left: parent.left
50
+    anchors.bottom: parent.bottom
51
+    margin-left: 6
52
+    margin-bottom: 6
53
+
25 54
   LineEdit
26 55
     id: consoleLineEdit
27
-    anchors.left: parent.left
56
+    anchors.left: sayModeButton.right
28 57
     anchors.right: parent.right
29 58
     anchors.bottom: parent.bottom
30 59
     margin-right: 6

+ 2
- 4
modules/game_healthbar/healthbar.otui View File

@@ -1,15 +1,13 @@
1
-HealthBar < UIProgressBar
1
+HealthBar < ProgressBar
2 2
   id: healthBar
3
-  color: black
4 3
   height: 15
5 4
   background-color: red
6 5
   anchors.top: parent.top
7 6
   anchors.left: parent.left
8 7
   anchors.right: parent.right
9 8
 
10
-ManaBar < UIProgressBar
9
+ManaBar < ProgressBar
11 10
   id: manaBar
12
-  color: black
13 11
   height: 15
14 12
   background-color: blue
15 13
   anchors.bottom: parent.bottom

+ 4
- 6
modules/game_inventory/inventory.otui View File

@@ -90,9 +90,8 @@ UIWindow
90 90
 
91 91
     text-align: center
92 92
 
93
-    border-image:
94
-      source: /core_styles/images/panel_flat.png
95
-      border: 1
93
+    image-source: /core_styles/images/panel_flat.png
94
+    image-border: 1
96 95
 
97 96
   GameLabel
98 97
     id: capacity
@@ -104,7 +103,6 @@ UIWindow
104 103
 
105 104
     text-align: center
106 105
 
107
-    border-image:
108
-      source: /core_styles/images/panel_flat.png
109
-      border: 1
106
+    image-source: /core_styles/images/panel_flat.png
107
+    image-border: 1
110 108
 

+ 4
- 5
modules/game_skills/skills.otui View File

@@ -22,9 +22,8 @@ SkillValueLabel < GameLabel
22 22
   anchors.bottom: parent.bottom
23 23
   anchors.left: prev.left
24 24
 
25
-SkillPercentPanel < UIProgressBar
25
+SkillPercentPanel < ProgressBar
26 26
   id: percent
27
-  color: black
28 27
   background-color: green
29 28
   height: 5
30 29
   margin-top: 15
@@ -36,7 +35,7 @@ SkillPercentPanel < UIProgressBar
36 35
 MiniWindow
37 36
   id: skillWindow
38 37
   title: Skills
39
-  size: 200 400
38
+  size: 200 310
40 39
 
41 40
   Panel
42 41
     id: skillPanel
@@ -60,7 +59,7 @@ MiniWindow
60 59
         text: Level
61 60
       SkillValueLabel
62 61
       SkillPercentPanel
63
-        background-color: red
62
+        image-color: red
64 63
 
65 64
     SkillButton
66 65
       id: health
@@ -103,7 +102,7 @@ MiniWindow
103 102
         text: Magic Level
104 103
       SkillValueLabel
105 104
       SkillPercentPanel
106
-        background-color: red
105
+        image-color: red
107 106
 
108 107
     SkillButton
109 108
       id: skillId0

+ 3
- 3
modules/game_viplist/viplist.otui View File

@@ -8,11 +8,11 @@ MiniWindow
8 8
   id: vipWindow
9 9
   title: VIP List
10 10
 
11
-  TextList
11
+  UIWidget
12 12
     id: vipList
13
-    border-image: ~
13
+    layout: verticalBox
14 14
     anchors.fill: parent
15
-    margin-top: 26
15
+    margin-top: 27
16 16
     margin-bottom: 6
17 17
     margin-left: 6
18 18
     margin-right: 6

+ 3
- 4
src/framework/CMakeLists.txt View File

@@ -159,8 +159,6 @@ SET(framework_SOURCES ${framework_SOURCES}
159 159
     ${CMAKE_CURRENT_LIST_DIR}/graphics/framebuffer.cpp
160 160
     ${CMAKE_CURRENT_LIST_DIR}/graphics/animatedtexture.cpp
161 161
     ${CMAKE_CURRENT_LIST_DIR}/graphics/texturemanager.cpp
162
-    ${CMAKE_CURRENT_LIST_DIR}/graphics/borderimage.cpp
163
-    ${CMAKE_CURRENT_LIST_DIR}/graphics/image.cpp
164 162
     ${CMAKE_CURRENT_LIST_DIR}/graphics/particlemanager.cpp
165 163
     ${CMAKE_CURRENT_LIST_DIR}/graphics/particlesystem.cpp
166 164
     ${CMAKE_CURRENT_LIST_DIR}/graphics/particleemitter.cpp
@@ -187,13 +185,14 @@ SET(framework_SOURCES ${framework_SOURCES}
187 185
     # framework ui
188 186
     ${CMAKE_CURRENT_LIST_DIR}/ui/uimanager.cpp
189 187
     ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidget.cpp
188
+    ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidgetimage.cpp
189
+    ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidgettext.cpp
190
+    ${CMAKE_CURRENT_LIST_DIR}/ui/uiwidgetbasestyle.cpp
190 191
     ${CMAKE_CURRENT_LIST_DIR}/ui/uilineedit.cpp
191 192
     ${CMAKE_CURRENT_LIST_DIR}/ui/uiwindow.cpp
192 193
     ${CMAKE_CURRENT_LIST_DIR}/ui/uianchorlayout.cpp
193 194
     ${CMAKE_CURRENT_LIST_DIR}/ui/uiverticallayout.cpp
194 195
     ${CMAKE_CURRENT_LIST_DIR}/ui/uilayout.cpp
195
-    ${CMAKE_CURRENT_LIST_DIR}/ui/uiprogressbar.cpp
196
-    ${CMAKE_CURRENT_LIST_DIR}/ui/uicheckbox.cpp
197 196
     ${CMAKE_CURRENT_LIST_DIR}/ui/uiframecounter.cpp
198 197
     ${CMAKE_CURRENT_LIST_DIR}/ui/uitranslator.cpp
199 198
 

+ 0
- 201
src/framework/graphics/borderimage.cpp View File

@@ -1,201 +0,0 @@
1
-/*
2
- * Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- * THE SOFTWARE.
21
- */
22
-
23
-#include "borderimage.h"
24
-#include "graphics.h"
25
-#include "texture.h"
26
-#include "texturemanager.h"
27
-
28
-#include <framework/otml/otml.h>
29
-
30
-BorderImage::BorderImage(TexturePtr texture,
31
-                             const Rect& left,
32
-                             const Rect& right,
33
-                             const Rect& top,
34
-                             const Rect& bottom,
35
-                             const Rect& topLeft,
36
-                             const Rect& topRight,
37
-                             const Rect& bottomLeft,
38
-                             const Rect& bottomRight,
39
-                             const Rect& center)
40
-{
41
-    m_texture = texture;
42
-    m_leftBorderTexCoords = left;
43
-    m_rightBorderTexCoords = right;
44
-    m_topBorderTexCoords = top;
45
-    m_bottomBorderTexCoords = bottom;
46
-    m_topLeftCornerTexCoords = topLeft;
47
-    m_topRightCornerTexCoords = topRight;
48
-    m_bottomLeftCornerTexCoords = bottomLeft;
49
-    m_bottomRightCornerTexCoords = bottomRight;
50
-    m_centerTexCoords = center;
51
-
52
-    m_bordersSize = Size(left.width() + right.width(),
53
-                         top.height() + bottom.height());
54
-
55
-    m_defaultSize = Size(std::max(std::max(topLeft.width(), bottomLeft.width()), left.width()) +
56
-                            std::max(std::max(topRight.width(), bottomRight.width()), right.width()) +
57
-                            center.width(),
58
-                         std::max(std::max(topLeft.height(), topRight.height()), top.height()) +
59
-                            std::max(std::max(bottomLeft.height(), bottomRight.height()), bottom.height()) +
60
-                            center.height());
61
-}
62
-
63
-BorderImagePtr BorderImage::loadFromOTML(const OTMLNodePtr& borderImageNode)
64
-{
65
-    Rect leftBorder;
66
-    Rect rightBorder;
67
-    Rect topBorder;
68
-    Rect bottomBorder;
69
-    Rect topLeftCorner;
70
-    Rect topRightCorner;
71
-    Rect bottomLeftCorner;
72
-    Rect bottomRightCorner;
73
-    Rect center;
74
-    Rect clipRect;
75
-    int top, bottom, left, right, border;
76
-    Size size;
77
-    Point offset;
78
-
79
-    // load texture
80
-    std::string source = borderImageNode->at("source")->value();
81
-    TexturePtr texture = g_textures.getTexture(source);
82
-
83
-    // load basic border confs
84
-    border = borderImageNode->valueAt("border", 0);
85
-    clipRect = borderImageNode->valueAt("clip", Rect(0, 0, texture->getSize()));
86
-
87
-    // load border margins
88
-    top = bottom = left = right = border;
89
-    top = borderImageNode->valueAt("border.top", top);
90
-    bottom = borderImageNode->valueAt("border.bottom", bottom);
91
-    left = borderImageNode->valueAt("border.left", left);
92
-    right = borderImageNode->valueAt("border.right", right);
93
-
94
-    // calculates border coords
95
-    leftBorder = Rect(clipRect.left(), clipRect.top() + top, left, clipRect.height() - top - bottom);
96
-    rightBorder = Rect(clipRect.right() - right + 1, clipRect.top() + top, right, clipRect.height() - top - bottom);
97
-    topBorder = Rect(clipRect.left() + left, clipRect.top(), clipRect.width() - right - left, top);
98
-    bottomBorder = Rect(clipRect.left() + left, clipRect.bottom() - bottom + 1, clipRect.width() - right - left, bottom);
99
-    topLeftCorner = Rect(clipRect.left(), clipRect.top(), left, top);
100
-    topRightCorner = Rect(clipRect.right() - right + 1, clipRect.top(), right, top);
101
-    bottomLeftCorner = Rect(clipRect.left(), clipRect.bottom() - bottom + 1, left, bottom);
102
-    bottomRightCorner = Rect(clipRect.right() - right + 1, clipRect.bottom() - bottom + 1, right, bottom);
103
-    center = Rect(clipRect.left() + left, clipRect.top() + top, clipRect.width() - right - left, clipRect.height() - top - bottom);
104
-
105
-    // load individual border conf if supplied
106
-    /*
107
-    leftBorder = borderImageNode->valueAt("left border", leftBorder);
108
-    rightBorder = borderImageNode->valueAt("right border", rightBorder);
109
-    topBorder = borderImageNode->valueAt("top border", topBorder);
110
-    bottomBorder = borderImageNode->valueAt("bottom border", bottomBorder);
111
-    topLeftCorner = borderImageNode->valueAt("top left corner", topLeftCorner);
112
-    topRightCorner = borderImageNode->valueAt("top right corner", topRightCorner);
113
-    bottomLeftCorner = borderImageNode->valueAt("bottom left corner", bottomLeftCorner);
114
-    bottomRightCorner = borderImageNode->valueAt("bottom right corner", bottomRightCorner);
115
-    center = borderImageNode->valueAt("center", center);
116
-    */
117
-
118
-    return BorderImagePtr(new BorderImage(texture,
119
-                            leftBorder,
120
-                            rightBorder,
121
-                            topBorder,
122
-                            bottomBorder,
123
-                            topLeftCorner,
124
-                            topRightCorner,
125
-                            bottomLeftCorner,
126
-                            bottomRightCorner,
127
-                            center));
128
-}
129
-
130
-void BorderImage::draw(const Rect& screenCoords)
131
-{
132
-    //TODO: borderimage drawing could be optimized by caching the render into a texture
133
-    if(screenCoords != m_cachedScreenCoords) {
134
-        m_cachedScreenCoords = screenCoords;
135
-        m_coordsBuffer.clear();
136
-
137
-        Rect rectCoords;
138
-        Size centerSize = screenCoords.size() - m_bordersSize;
139
-
140
-        // first the center
141
-        if(centerSize.area() > 0) {
142
-            rectCoords = Rect(screenCoords.left() + m_leftBorderTexCoords.width(),
143
-                            screenCoords.top() + m_topBorderTexCoords.height(),
144
-                            centerSize);
145
-            m_coordsBuffer.addRepeatedRects(rectCoords, m_centerTexCoords);
146
-        }
147
-
148
-        // top left corner
149
-        rectCoords = Rect(screenCoords.topLeft(),
150
-                        m_topLeftCornerTexCoords.size());
151
-        m_coordsBuffer.addRepeatedRects(rectCoords, m_topLeftCornerTexCoords);
152
-
153
-        // top
154
-        rectCoords = Rect(screenCoords.left() + m_topLeftCornerTexCoords.width(),
155
-                        screenCoords.topLeft().y,
156
-                        centerSize.width(),
157
-                        m_topBorderTexCoords.height());
158
-        m_coordsBuffer.addRepeatedRects(rectCoords, m_topBorderTexCoords);
159
-
160
-
161
-        // top right corner
162
-        rectCoords = Rect(screenCoords.left() + m_topLeftCornerTexCoords.width() + centerSize.width(),
163
-                        screenCoords.top(),
164
-                        m_topRightCornerTexCoords.size());
165
-        m_coordsBuffer.addRepeatedRects(rectCoords, m_topRightCornerTexCoords);
166
-
167
-        // left
168
-        rectCoords = Rect(screenCoords.left(),
169
-                        screenCoords.top() + m_topLeftCornerTexCoords.height(),
170
-                        m_leftBorderTexCoords.width(),
171
-                        centerSize.height());
172
-        m_coordsBuffer.addRepeatedRects(rectCoords, m_leftBorderTexCoords);
173
-
174
-        // right
175
-        rectCoords = Rect(screenCoords.left() + m_leftBorderTexCoords.width() + centerSize.width(),
176
-                        screenCoords.top() + m_topRightCornerTexCoords.height(),
177
-                        m_rightBorderTexCoords.width(),
178
-                        centerSize.height());
179
-        m_coordsBuffer.addRepeatedRects(rectCoords, m_rightBorderTexCoords);
180
-
181
-        // bottom left corner
182
-        rectCoords = Rect(screenCoords.left(),
183
-                        screenCoords.top() + m_topLeftCornerTexCoords.height() + centerSize.height(),
184
-                        m_bottomLeftCornerTexCoords.size());
185
-        m_coordsBuffer.addRepeatedRects(rectCoords, m_bottomLeftCornerTexCoords);
186
-
187
-        // bottom
188
-        rectCoords = Rect(screenCoords.left() + m_bottomLeftCornerTexCoords.width(),
189
-                        screenCoords.top() + m_topBorderTexCoords.height() + centerSize.height(),
190
-                        centerSize.width(),
191
-                        m_bottomBorderTexCoords.height());
192
-        m_coordsBuffer.addRepeatedRects(rectCoords, m_bottomBorderTexCoords);
193
-
194
-        // bottom right corner
195
-        rectCoords = Rect(screenCoords.left() + m_bottomLeftCornerTexCoords.width() + centerSize.width(),
196
-                        screenCoords.top() + m_topRightCornerTexCoords.height() + centerSize.height(),
197
-                        m_bottomRightCornerTexCoords.size());
198
-        m_coordsBuffer.addRepeatedRects(rectCoords, m_bottomRightCornerTexCoords);
199
-    }
200
-    g_painter.drawTextureCoords(m_coordsBuffer, m_texture);
201
-}

+ 0
- 65
src/framework/graphics/borderimage.h View File

@@ -1,65 +0,0 @@
1
-/*
2
- * Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- * THE SOFTWARE.
21
- */
22
-
23
-#ifndef BORDERIMAGE_H
24
-#define BORDERIMAGE_H
25
-
26
-#include "image.h"
27
-
28
-class BorderImage : public Image
29
-{
30
-public:
31
-    BorderImage(TexturePtr texture,
32
-                  const Rect& left,
33
-                  const Rect& right,
34
-                  const Rect& top,
35
-                  const Rect& bottom,
36
-                  const Rect& topLeft,
37
-                  const Rect& topRight,
38
-                  const Rect& bottomLeft,
39
-                  const Rect& bottomRight,
40
-                  const Rect& center);
41
-
42
-    static BorderImagePtr loadFromOTML(const OTMLNodePtr& borderImageNode);
43
-
44
-    void draw(const Rect& screenCoords);
45
-
46
-    Size getDefaultSize() const { return m_defaultSize; }
47
-
48
-private:
49
-    Rect m_leftBorderTexCoords;
50
-    Rect m_rightBorderTexCoords;
51
-    Rect m_topBorderTexCoords;
52
-    Rect m_bottomBorderTexCoords;
53
-
54
-    Rect m_topLeftCornerTexCoords;
55
-    Rect m_topRightCornerTexCoords;
56
-    Rect m_bottomLeftCornerTexCoords;
57
-    Rect m_bottomRightCornerTexCoords;
58
-
59
-    Rect m_centerTexCoords;
60
-
61
-    Size m_bordersSize;
62
-    Size m_defaultSize;
63
-};
64
-
65
-#endif

+ 0
- 4
src/framework/graphics/declarations.h View File

@@ -29,8 +29,6 @@
29 29
 class Texture;
30 30
 class AnimatedTexture;
31 31
 class Font;
32
-class Image;
33
-class BorderImage;
34 32
 class FrameBuffer;
35 33
 class Shader;
36 34
 class ShaderProgram;
@@ -46,8 +44,6 @@ typedef std::weak_ptr<ParticleSystem> ParticleSystemWeakPtr;
46 44
 typedef std::shared_ptr<Texture> TexturePtr;
47 45
 typedef std::shared_ptr<AnimatedTexture> AnimatedTexturePtr;
48 46
 typedef std::shared_ptr<Font> FontPtr;
49
-typedef std::shared_ptr<Image> ImagePtr;
50
-typedef std::shared_ptr<BorderImage> BorderImagePtr;
51 47
 typedef std::shared_ptr<FrameBuffer> FrameBufferPtr;
52 48
 typedef std::shared_ptr<Shader> ShaderPtr;
53 49
 typedef std::shared_ptr<ShaderProgram> ShaderProgramPtr;

+ 1
- 1
src/framework/graphics/framebuffer.cpp View File

@@ -44,7 +44,7 @@ void FrameBuffer::resize(const Size& size)
44 44
 {
45 45
     internalBind();
46 46
     m_texture = TexturePtr(new Texture(size.width(), size.height(), 4));
47
-    m_texture->enableBilinearFilter();
47
+    m_texture->setSmooth(true);
48 48
     glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture->getId(), 0);
49 49
 
50 50
     GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);

+ 0
- 82
src/framework/graphics/image.cpp View File

@@ -1,82 +0,0 @@
1
-/*
2
- * Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- * THE SOFTWARE.
21
- */
22
-
23
-#include "image.h"
24
-#include "texture.h"
25
-#include "graphics.h"
26
-#include "texturemanager.h"
27
-
28
-#include <framework/otml/otml.h>
29
-
30
-Image::Image()
31
-{
32
-    m_fixedRatio = false;
33
-    m_repeated = false;
34
-}
35
-
36
-void Image::loadFromOTML(const OTMLNodePtr& imageNode)
37
-{
38
-    // load configs from otml node
39
-    std::string source = imageNode->hasValue() ? imageNode->value() : imageNode->valueAt("source");
40
-    bool smooth = imageNode->valueAt("smooth", false);
41
-    m_fixedRatio = imageNode->valueAt("fixed ratio", false);
42
-    m_repeated = imageNode->valueAt("repeated", false);
43
-
44
-    // load texture
45
-    m_texture = g_textures.getTexture(source);
46
-    m_textureCoords = imageNode->valueAt("clip", Rect(0, 0, m_texture->getSize()));
47
-
48
-    // enable texture bilinear filter
49
-    if(smooth)
50
-        m_texture->enableBilinearFilter();
51
-}
52
-
53
-void Image::draw(const Rect& screenCoords)
54
-{
55
-    if(!m_texture)
56
-        return;
57
-
58
-    if(m_cachedScreenCoords != screenCoords) {
59
-        m_cachedScreenCoords = screenCoords;
60
-        m_coordsBuffer.clear();
61
-
62
-        if(m_fixedRatio) {
63
-            const Size& texSize = m_texture->getSize();
64
-            Size texCoordsSize = screenCoords.size();
65
-            texCoordsSize.scale(texSize, Fw::KeepAspectRatio);
66
-            Point texCoordsOffset;
67
-            if(texSize.height() > texCoordsSize.height())
68
-                texCoordsOffset.y = (texSize.height() - texCoordsSize.height())/2;
69
-            else if(texSize.width() > texCoordsSize.width())
70
-                texCoordsOffset.x = (texSize.width() - texCoordsSize.width())/2;
71
-
72
-            m_coordsBuffer.addRect(screenCoords, Rect(texCoordsOffset, texCoordsSize));
73
-        } else {
74
-            if(m_repeated)
75
-                m_coordsBuffer.addRepeatedRects(screenCoords, m_textureCoords);
76
-            else
77
-                m_coordsBuffer.addRect(screenCoords, m_textureCoords);
78
-        }
79
-    }
80
-
81
-    g_painter.drawTextureCoords(m_coordsBuffer, m_texture);
82
-}

+ 0
- 50
src/framework/graphics/image.h View File

@@ -1,50 +0,0 @@
1
-/*
2
- * Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- * THE SOFTWARE.
21
- */
22
-
23
-#ifndef IMAGE_H
24
-#define IMAGE_H
25
-
26
-#include "declarations.h"
27
-#include "coordsbuffer.h"
28
-
29
-#include <framework/otml/declarations.h>
30
-
31
-class Image
32
-{
33
-public:
34
-    Image();
35
-
36
-    void loadFromOTML(const OTMLNodePtr& imageNode);
37
-
38
-    virtual void draw(const Rect& screenCoords);
39
-
40
-protected:
41
-    TexturePtr m_texture;
42
-    Rect m_textureCoords;
43
-    bool m_fixedRatio;
44
-    bool m_repeated;
45
-
46
-    Rect m_cachedScreenCoords;
47
-    CoordsBuffer m_coordsBuffer;
48
-};
49
-
50
-#endif

+ 3
- 3
src/framework/graphics/painter.h View File

@@ -51,13 +51,13 @@ public:
51 51
     void setColor(const Color& color) { m_currentColor = color; }
52 52
     Color getColor() { return m_currentColor; }
53 53
 
54
-    void setOpacity(int opacity) { m_currentOpacity = opacity / 255.0f; }
55
-    int getOpacity() { return m_currentOpacity * 255.0f; }
54
+    void setOpacity(float opacity) { m_currentOpacity = opacity; }
55
+    float getOpacity() { return m_currentOpacity; }
56 56
 
57 57
     void setCustomProgram(PainterShaderProgramPtr program);
58 58
     void releaseCustomProgram() { m_customProgram = nullptr; }
59 59
     void setCompositionMode(CompositionMode compositionMode);
60
-    
60
+
61 61
     void setProjectionMatrix(const Matrix3& projectionMatrix) { m_projectionMatrix = projectionMatrix; }
62 62
     Matrix3 getProjectionMatrix() { return m_projectionMatrix; }
63 63
 

+ 1
- 1
src/framework/graphics/particle.cpp View File

@@ -91,7 +91,7 @@ void Particle::updatePosition(double elapsedTime)
91 91
         m_velocity += m_acceleration * elapsedTime;
92 92
     }
93 93
 
94
-    m_rect.moveTo((int)m_position.x - m_size.width() / 2, (int)m_position.y - m_size.height() / 2);
94
+    m_rect.move((int)m_position.x - m_size.width() / 2, (int)m_position.y - m_size.height() / 2);
95 95
 }
96 96
 
97 97
 void Particle::updateSize()

+ 16
- 5
src/framework/graphics/texture.cpp View File

@@ -95,12 +95,23 @@ uint Texture::internalLoadGLTexture(uchar *pixels, int channels, int width, int
95 95
     return id;
96 96
 }
97 97
 
98
-void Texture::enableBilinearFilter()
98
+void Texture::setSmooth(bool smooth)
99 99
 {
100
-    // enable smooth texture
101
-    glBindTexture(GL_TEXTURE_2D, m_textureId);
102
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
103
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
100
+    if(smooth == m_smooth)
101
+        return;
102
+
103
+    if(smooth) {
104
+        // enable smooth texture
105
+        glBindTexture(GL_TEXTURE_2D, m_textureId);
106
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
107
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
108
+    } else {
109
+        // nearest filtering (non smooth)
110
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
111
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
112
+    }
113
+
114
+    m_smooth = true;
104 115
 }
105 116
 
106 117
 std::vector<uint8> Texture::getPixels()

+ 2
- 1
src/framework/graphics/texture.h View File

@@ -32,7 +32,7 @@ public:
32 32
     Texture(int width, int height, int channels, uchar* pixels = NULL);
33 33
     virtual ~Texture();
34 34
 
35
-    virtual void enableBilinearFilter();
35
+    virtual void setSmooth(bool smooth);
36 36
     GLuint getId()  { return m_textureId; }
37 37
 
38 38
     std::vector<uint8> getPixels();
@@ -48,6 +48,7 @@ protected:
48 48
 
49 49
     GLuint m_textureId;
50 50
     Size m_size;
51
+    Boolean<false> m_smooth;
51 52
 };
52 53
 
53 54
 #endif

+ 178
- 91
src/framework/luafunctions.cpp View File

@@ -45,55 +45,70 @@ void Application::registerLuaFunctions()
45 45
 
46 46
     // UIWidget
47 47
     g_lua.registerClass<UIWidget>();
48
-    g_lua.bindClassStaticFunction<UIWidget>("create", []{ return UIWidgetPtr(new UIWidget); } );
48
+    g_lua.bindClassStaticFunction<UIWidget>("create", []{ return UIWidgetPtr(new UIWidget); });
49
+    g_lua.bindClassMemberFunction<UIWidget>("addChild", &UIWidget::addChild);
50
+    g_lua.bindClassMemberFunction<UIWidget>("insertChild", &UIWidget::insertChild);
51
+    g_lua.bindClassMemberFunction<UIWidget>("removeChild", &UIWidget::removeChild);
52
+    g_lua.bindClassMemberFunction<UIWidget>("focusChild", &UIWidget::focusChild);
53
+    g_lua.bindClassMemberFunction<UIWidget>("focusNextChild", &UIWidget::focusNextChild);
54
+    g_lua.bindClassMemberFunction<UIWidget>("focusPreviousChild", &UIWidget::focusPreviousChild);
55
+    g_lua.bindClassMemberFunction<UIWidget>("moveChildToTop", &UIWidget::moveChildToTop);
56
+    g_lua.bindClassMemberFunction<UIWidget>("moveChildToIndex", &UIWidget::moveChildToIndex);
57
+    g_lua.bindClassMemberFunction<UIWidget>("lockChild", &UIWidget::lockChild);
58
+    g_lua.bindClassMemberFunction<UIWidget>("unlockChild", &UIWidget::unlockChild);
59
+    g_lua.bindClassMemberFunction<UIWidget>("applyStyle", &UIWidget::applyStyle);
60
+    g_lua.bindClassMemberFunction<UIWidget>("addAnchor", &UIWidget::addAnchor);
61
+    g_lua.bindClassMemberFunction<UIWidget>("fill", &UIWidget::fill);
62
+    g_lua.bindClassMemberFunction<UIWidget>("centerIn", &UIWidget::centerIn);
63
+    g_lua.bindClassMemberFunction<UIWidget>("breakAnchors", &UIWidget::breakAnchors);
64
+    g_lua.bindClassMemberFunction<UIWidget>("updateParentLayout", &UIWidget::updateParentLayout);
65
+    g_lua.bindClassMemberFunction<UIWidget>("updateLayout", &UIWidget::updateLayout);
66
+    g_lua.bindClassMemberFunction<UIWidget>("lock", &UIWidget::lock);
67
+    g_lua.bindClassMemberFunction<UIWidget>("unlock", &UIWidget::unlock);
68
+    g_lua.bindClassMemberFunction<UIWidget>("focus", &UIWidget::focus);
69
+    g_lua.bindClassMemberFunction<UIWidget>("grabMouse", &UIWidget::grabMouse);
70
+    g_lua.bindClassMemberFunction<UIWidget>("ungrabMouse", &UIWidget::ungrabMouse);
71
+    g_lua.bindClassMemberFunction<UIWidget>("grabKeyboard", &UIWidget::grabKeyboard);
72
+    g_lua.bindClassMemberFunction<UIWidget>("ungrabKeyboard", &UIWidget::ungrabKeyboard);
73
+    g_lua.bindClassMemberFunction<UIWidget>("bindRectToParent", &UIWidget::bindRectToParent);
49 74
     g_lua.bindClassMemberFunction<UIWidget>("destroy", &UIWidget::destroy);
50
-    g_lua.bindClassMemberFunction<UIWidget>("setVisible", &UIWidget::setVisible);
75
+    g_lua.bindClassMemberFunction<UIWidget>("setId", &UIWidget::setId);
76
+    g_lua.bindClassMemberFunction<UIWidget>("setParent", &UIWidget::setParent);
77
+    g_lua.bindClassMemberFunction<UIWidget>("setLayout", &UIWidget::setLayout);
78
+    g_lua.bindClassMemberFunction<UIWidget>("setRect", &UIWidget::setRect);
79
+    g_lua.bindClassMemberFunction<UIWidget>("setStyle", &UIWidget::setStyle);
80
+    g_lua.bindClassMemberFunction<UIWidget>("setStyleFromNode", &UIWidget::setStyleFromNode);
51 81
     g_lua.bindClassMemberFunction<UIWidget>("setEnabled", &UIWidget::setEnabled);
52
-    g_lua.bindClassMemberFunction<UIWidget>("setChecked", &UICheckBox::setChecked);
53
-    g_lua.bindClassMemberFunction<UIWidget>("setOn", &UICheckBox::setOn);
82
+    g_lua.bindClassMemberFunction<UIWidget>("setVisible", &UIWidget::setVisible);
54 83
     g_lua.bindClassMemberFunction<UIWidget>("setPressed", &UIWidget::setPressed);
55
-    g_lua.bindClassMemberFunction<UIWidget>("setId", &UIWidget::setId);
84
+    g_lua.bindClassMemberFunction<UIWidget>("setOn", &UIWidget::setOn);
85
+    g_lua.bindClassMemberFunction<UIWidget>("setChecked", &UIWidget::setChecked);
56 86
     g_lua.bindClassMemberFunction<UIWidget>("setFocusable", &UIWidget::setFocusable);
57 87
     g_lua.bindClassMemberFunction<UIWidget>("setPhantom", &UIWidget::setPhantom);
58
-    g_lua.bindClassMemberFunction<UIWidget>("setStyle", &UIWidget::setStyle);
59
-    g_lua.bindClassMemberFunction<UIWidget>("setStyleFromNode", &UIWidget::setStyleFromNode);
60
-    g_lua.bindClassMemberFunction<UIWidget>("setLayout", &UIWidget::setLayout);
61
-    g_lua.bindClassMemberFunction<UIWidget>("setParent", &UIWidget::setParent);
62
-    g_lua.bindClassMemberFunction<UIWidget>("setRect", &UIWidget::setRect);
63
-    g_lua.bindClassMemberFunction<UIWidget>("setX", &UIWidget::setX);
64
-    g_lua.bindClassMemberFunction<UIWidget>("setY", &UIWidget::setY);
65
-    g_lua.bindClassMemberFunction<UIWidget>("setWidth", &UIWidget::setWidth);
66
-    g_lua.bindClassMemberFunction<UIWidget>("setHeight", &UIWidget::setHeight);
67
-    g_lua.bindClassMemberFunction<UIWidget>("setIcon", &UIWidget::setIcon);
68
-    g_lua.bindClassMemberFunction<UIWidget>("setOpacity", &UIWidget::setOpacity);
69
-    g_lua.bindClassMemberFunction<UIWidget>("setBackgroundColor", &UIWidget::setBackgroundColor);
70
-    g_lua.bindClassMemberFunction<UIWidget>("setColor", &UIWidget::setColor);
71
-    g_lua.bindClassMemberFunction<UIWidget>("setMarginTop", &UIWidget::setMarginTop);
72
-    g_lua.bindClassMemberFunction<UIWidget>("setMarginRight", &UIWidget::setMarginRight);
73
-    g_lua.bindClassMemberFunction<UIWidget>("setMarginBottom", &UIWidget::setMarginBottom);
74
-    g_lua.bindClassMemberFunction<UIWidget>("setMarginLeft", &UIWidget::setMarginLeft);
75
-    g_lua.bindClassMemberFunction<UIWidget>("setText", &UIWidget::setText);
76
-    g_lua.bindClassMemberFunction<UIWidget>("setTextAlign", &UIWidget::setTextAlign);
77
-    g_lua.bindClassMemberFunction<UIWidget>("setTextOffset", &UIWidget::setTextOffset);
78
-    g_lua.bindClassMemberFunction<UIWidget>("setFont", &UIWidget::setFont);
79
-    g_lua.bindClassMemberFunction<UIWidget>("setSizeFixed", &UIWidget::setSizeFixed);
88
+    g_lua.bindClassMemberFunction<UIWidget>("setFixedSize", &UIWidget::setFixedSize);
80 89
     g_lua.bindClassMemberFunction<UIWidget>("setLastFocusReason", &UIWidget::setLastFocusReason);
81
-    g_lua.bindClassMemberFunction<UIWidget>("bindRectToParent", &UIWidget::bindRectToParent);
90
+    g_lua.bindClassMemberFunction<UIWidget>("isVisible", &UIWidget::isVisible);
91
+    g_lua.bindClassMemberFunction<UIWidget>("isChildLocked", &UIWidget::isChildLocked);
92
+    g_lua.bindClassMemberFunction<UIWidget>("hasChild", &UIWidget::hasChild);
93
+    g_lua.bindClassMemberFunction<UIWidget>("getChildIndex", &UIWidget::getChildIndex);
94
+    g_lua.bindClassMemberFunction<UIWidget>("getChildrenRect", &UIWidget::getChildrenRect);
95
+    g_lua.bindClassMemberFunction<UIWidget>("getAnchoredLayout", &UIWidget::getAnchoredLayout);
96
+    g_lua.bindClassMemberFunction<UIWidget>("getRootParent", &UIWidget::getRootParent);
97
+    g_lua.bindClassMemberFunction<UIWidget>("getChildAfter", &UIWidget::getChildAfter);
98
+    g_lua.bindClassMemberFunction<UIWidget>("getChildBefore", &UIWidget::getChildBefore);
99
+    g_lua.bindClassMemberFunction<UIWidget>("getChildById", &UIWidget::getChildById);
100
+    g_lua.bindClassMemberFunction<UIWidget>("getChildByPos", &UIWidget::getChildByPos);
101
+    g_lua.bindClassMemberFunction<UIWidget>("getChildByIndex", &UIWidget::getChildByIndex);
102
+    g_lua.bindClassMemberFunction<UIWidget>("recursiveGetChildById", &UIWidget::recursiveGetChildById);
103
+    g_lua.bindClassMemberFunction<UIWidget>("recursiveGetChildByPos", &UIWidget::recursiveGetChildByPos);
104
+    g_lua.bindClassMemberFunction<UIWidget>("backwardsGetWidgetById", &UIWidget::backwardsGetWidgetById);
105
+    g_lua.bindClassMemberFunction<UIWidget>("asUIWidget", &UIWidget::asUIWidget);
82 106
     g_lua.bindClassMemberFunction<UIWidget>("resize", &UIWidget::resize);
83
-    g_lua.bindClassMemberFunction<UIWidget>("resizeToText", &UIWidget::resizeToText);
84
-    g_lua.bindClassMemberFunction<UIWidget>("moveTo", &UIWidget::moveTo);
107
+    g_lua.bindClassMemberFunction<UIWidget>("move", &UIWidget::move);
85 108
     g_lua.bindClassMemberFunction<UIWidget>("hide", &UIWidget::hide);
86 109
     g_lua.bindClassMemberFunction<UIWidget>("show", &UIWidget::show);
87 110
     g_lua.bindClassMemberFunction<UIWidget>("disable", &UIWidget::disable);
88 111
     g_lua.bindClassMemberFunction<UIWidget>("enable", &UIWidget::enable);
89
-    g_lua.bindClassMemberFunction<UIWidget>("lock", &UIWidget::lock);
90
-    g_lua.bindClassMemberFunction<UIWidget>("unlock", &UIWidget::unlock);
91
-    g_lua.bindClassMemberFunction<UIWidget>("focus", &UIWidget::focus);
92
-    g_lua.bindClassMemberFunction<UIWidget>("grabMouse", &UIWidget::grabMouse);
93
-    g_lua.bindClassMemberFunction<UIWidget>("ungrabMouse", &UIWidget::ungrabMouse);
94
-    g_lua.bindClassMemberFunction<UIWidget>("grabKeyboard", &UIWidget::grabKeyboard);
95
-    g_lua.bindClassMemberFunction<UIWidget>("ungrabKeyboard", &UIWidget::ungrabKeyboard);
96
-    g_lua.bindClassMemberFunction<UIWidget>("clearText", &UIWidget::clearText);
97 112
     g_lua.bindClassMemberFunction<UIWidget>("isActive", &UIWidget::isActive);
98 113
     g_lua.bindClassMemberFunction<UIWidget>("isEnabled", &UIWidget::isEnabled);
99 114
     g_lua.bindClassMemberFunction<UIWidget>("isDisabled", &UIWidget::isDisabled);
@@ -104,72 +119,154 @@ void Application::registerLuaFunctions()
104 119
     g_lua.bindClassMemberFunction<UIWidget>("isMiddle", &UIWidget::isMiddle);
105 120
     g_lua.bindClassMemberFunction<UIWidget>("isLast", &UIWidget::isLast);
106 121
     g_lua.bindClassMemberFunction<UIWidget>("isAlternate", &UIWidget::isAlternate);
107
-    g_lua.bindClassMemberFunction<UIWidget>("isVisible", &UIWidget::isVisible);
108
-    g_lua.bindClassMemberFunction<UIWidget>("isOn", &UICheckBox::isOn);
109
-    g_lua.bindClassMemberFunction<UIWidget>("isChecked", &UICheckBox::isChecked);
122
+    g_lua.bindClassMemberFunction<UIWidget>("isChecked", &UIWidget::isChecked);
123
+    g_lua.bindClassMemberFunction<UIWidget>("isOn", &UIWidget::isOn);
110 124
     g_lua.bindClassMemberFunction<UIWidget>("isHidden", &UIWidget::isHidden);
111 125
     g_lua.bindClassMemberFunction<UIWidget>("isExplicitlyEnabled", &UIWidget::isExplicitlyEnabled);
112 126
     g_lua.bindClassMemberFunction<UIWidget>("isExplicitlyVisible", &UIWidget::isExplicitlyVisible);
113 127
     g_lua.bindClassMemberFunction<UIWidget>("isFocusable", &UIWidget::isFocusable);
114 128
     g_lua.bindClassMemberFunction<UIWidget>("isPhantom", &UIWidget::isPhantom);
115
-    g_lua.bindClassMemberFunction<UIWidget>("isSizeFixed", &UIWidget::isSizeFixed);
116
-    g_lua.bindClassMemberFunction<UIWidget>("containsPoint", &UIWidget::containsPoint);
129
+    g_lua.bindClassMemberFunction<UIWidget>("isFixedSize", &UIWidget::isFixedSize);
130
+    g_lua.bindClassMemberFunction<UIWidget>("isDestroyed", &UIWidget::isDestroyed);
117 131
     g_lua.bindClassMemberFunction<UIWidget>("hasChildren", &UIWidget::hasChildren);
118
-    g_lua.bindClassMemberFunction<UIWidget>("hasChild", &UIWidget::hasChild);
132
+    g_lua.bindClassMemberFunction<UIWidget>("containsPoint", &UIWidget::containsPoint);
119 133
     g_lua.bindClassMemberFunction<UIWidget>("getId", &UIWidget::getId);
120
-    g_lua.bindClassMemberFunction<UIWidget>("getChildCount", &UIWidget::getChildCount);
121
-    g_lua.bindClassMemberFunction<UIWidget>("getLayout", &UIWidget::getLayout);
122 134
     g_lua.bindClassMemberFunction<UIWidget>("getParent", &UIWidget::getParent);
123
-    g_lua.bindClassMemberFunction<UIWidget>("getRootParent", &UIWidget::getRootParent);
124
-    g_lua.bindClassMemberFunction<UIWidget>("getPos", &UIWidget::getPos);
125
-    g_lua.bindClassMemberFunction<UIWidget>("getSize", &UIWidget::getSize);
126
-    g_lua.bindClassMemberFunction<UIWidget>("getRect", &UIWidget::getRect);
135
+    g_lua.bindClassMemberFunction<UIWidget>("getFocusedChild", &UIWidget::getFocusedChild);
136
+    g_lua.bindClassMemberFunction<UIWidget>("getChildren", &UIWidget::getChildren);
137
+    g_lua.bindClassMemberFunction<UIWidget>("getFirstChild", &UIWidget::getFirstChild);
138
+    g_lua.bindClassMemberFunction<UIWidget>("getLastChild", &UIWidget::getLastChild);
139
+    g_lua.bindClassMemberFunction<UIWidget>("getLayout", &UIWidget::getLayout);
140
+    g_lua.bindClassMemberFunction<UIWidget>("getStyle", &UIWidget::getStyle);
141
+    g_lua.bindClassMemberFunction<UIWidget>("getChildCount", &UIWidget::getChildCount);
142
+    g_lua.bindClassMemberFunction<UIWidget>("getLastFocusReason", &UIWidget::getLastFocusReason);
143
+    g_lua.bindClassMemberFunction<UIWidget>("getStyleName", &UIWidget::getStyleName);
144
+    g_lua.bindClassMemberFunction<UIWidget>("setX", &UIWidget::setX);
145
+    g_lua.bindClassMemberFunction<UIWidget>("setY", &UIWidget::setY);
146
+    g_lua.bindClassMemberFunction<UIWidget>("setWidth", &UIWidget::setWidth);
147
+    g_lua.bindClassMemberFunction<UIWidget>("setHeight", &UIWidget::setHeight);
148
+    g_lua.bindClassMemberFunction<UIWidget>("setSize", &UIWidget::setSize);
149
+    g_lua.bindClassMemberFunction<UIWidget>("setPos", &UIWidget::setPos);
150
+    g_lua.bindClassMemberFunction<UIWidget>("setColor", &UIWidget::setColor);
151
+    g_lua.bindClassMemberFunction<UIWidget>("setBackgroundColor", &UIWidget::setBackgroundColor);
152
+    g_lua.bindClassMemberFunction<UIWidget>("setBackgroundOffsetX", &UIWidget::setBackgroundOffsetX);
153
+    g_lua.bindClassMemberFunction<UIWidget>("setBackgroundOffsetY", &UIWidget::setBackgroundOffsetY);
154
+    g_lua.bindClassMemberFunction<UIWidget>("setBackgroundOffset", &UIWidget::setBackgroundOffset);
155
+    g_lua.bindClassMemberFunction<UIWidget>("setBackgroundWidth", &UIWidget::setBackgroundWidth);
156
+    g_lua.bindClassMemberFunction<UIWidget>("setBackgroundHeight", &UIWidget::setBackgroundHeight);
157
+    g_lua.bindClassMemberFunction<UIWidget>("setBackgroundSize", &UIWidget::setBackgroundSize);
158
+    g_lua.bindClassMemberFunction<UIWidget>("setBackgroundRect", &UIWidget::setBackgroundRect);
159
+    g_lua.bindClassMemberFunction<UIWidget>("setIcon", &UIWidget::setIcon);
160
+    g_lua.bindClassMemberFunction<UIWidget>("setIconColor", &UIWidget::setIconColor);
161
+    g_lua.bindClassMemberFunction<UIWidget>("setIconOffsetX", &UIWidget::setIconOffsetX);
162
+    g_lua.bindClassMemberFunction<UIWidget>("setIconOffsetY", &UIWidget::setIconOffsetY);
163
+    g_lua.bindClassMemberFunction<UIWidget>("setIconOffset", &UIWidget::setIconOffset);
164
+    g_lua.bindClassMemberFunction<UIWidget>("setIconWidth", &UIWidget::setIconWidth);
165
+    g_lua.bindClassMemberFunction<UIWidget>("setIconHeight", &UIWidget::setIconHeight);
166
+    g_lua.bindClassMemberFunction<UIWidget>("setIconSize", &UIWidget::setIconSize);
167
+    g_lua.bindClassMemberFunction<UIWidget>("setIconRect", &UIWidget::setIconRect);
168
+    g_lua.bindClassMemberFunction<UIWidget>("setBorderWidth", &UIWidget::setBorderWidth);
169
+    g_lua.bindClassMemberFunction<UIWidget>("setBorderColor", &UIWidget::setBorderColor);
170
+    g_lua.bindClassMemberFunction<UIWidget>("setMargin", &UIWidget::setMargin);
171
+    g_lua.bindClassMemberFunction<UIWidget>("setMarginHorizontal", &UIWidget::setMarginHorizontal);
172
+    g_lua.bindClassMemberFunction<UIWidget>("setMarginVertical", &UIWidget::setMarginVertical);
173
+    g_lua.bindClassMemberFunction<UIWidget>("setMarginTop", &UIWidget::setMarginTop);
174
+    g_lua.bindClassMemberFunction<UIWidget>("setMarginRight", &UIWidget::setMarginRight);
175
+    g_lua.bindClassMemberFunction<UIWidget>("setMarginBottom", &UIWidget::setMarginBottom);
176
+    g_lua.bindClassMemberFunction<UIWidget>("setMarginLeft", &UIWidget::setMarginLeft);
177
+    g_lua.bindClassMemberFunction<UIWidget>("setPadding", &UIWidget::setPadding);
178
+    g_lua.bindClassMemberFunction<UIWidget>("setPaddingHorizontal", &UIWidget::setPaddingHorizontal);
179
+    g_lua.bindClassMemberFunction<UIWidget>("setPaddingVertical", &UIWidget::setPaddingVertical);
180
+    g_lua.bindClassMemberFunction<UIWidget>("setPaddingTop", &UIWidget::setPaddingTop);
181
+    g_lua.bindClassMemberFunction<UIWidget>("setPaddingRight", &UIWidget::setPaddingRight);
182
+    g_lua.bindClassMemberFunction<UIWidget>("setPaddingBottom", &UIWidget::setPaddingBottom);
183
+    g_lua.bindClassMemberFunction<UIWidget>("setPaddingLeft", &UIWidget::setPaddingLeft);
184
+    g_lua.bindClassMemberFunction<UIWidget>("setOpacity", &UIWidget::setOpacity);
127 185
     g_lua.bindClassMemberFunction<UIWidget>("getX", &UIWidget::getX);
128 186
     g_lua.bindClassMemberFunction<UIWidget>("getY", &UIWidget::getY);
187
+    g_lua.bindClassMemberFunction<UIWidget>("getPos", &UIWidget::getPos);
129 188
     g_lua.bindClassMemberFunction<UIWidget>("getWidth", &UIWidget::getWidth);
130 189
     g_lua.bindClassMemberFunction<UIWidget>("getHeight", &UIWidget::getHeight);
190
+    g_lua.bindClassMemberFunction<UIWidget>("getSize", &UIWidget::getSize);
191
+    g_lua.bindClassMemberFunction<UIWidget>("getRect", &UIWidget::getRect);
131 192
     g_lua.bindClassMemberFunction<UIWidget>("getColor", &UIWidget::getColor);
132 193
     g_lua.bindClassMemberFunction<UIWidget>("getBackgroundColor", &UIWidget::getBackgroundColor);
133
-    g_lua.bindClassMemberFunction<UIWidget>("getOpacity", &UIWidget::getOpacity);
194
+    g_lua.bindClassMemberFunction<UIWidget>("getBackgroundOffsetX", &UIWidget::getBackgroundOffsetX);
195
+    g_lua.bindClassMemberFunction<UIWidget>("getBackgroundOffsetY", &UIWidget::getBackgroundOffsetY);
196
+    g_lua.bindClassMemberFunction<UIWidget>("getBackgroundOffset", &UIWidget::getBackgroundOffset);
197
+    g_lua.bindClassMemberFunction<UIWidget>("getBackgroundWidth", &UIWidget::getBackgroundWidth);
198
+    g_lua.bindClassMemberFunction<UIWidget>("getBackgroundHeight", &UIWidget::getBackgroundHeight);
199
+    g_lua.bindClassMemberFunction<UIWidget>("getBackgroundSize", &UIWidget::getBackgroundSize);
200
+    g_lua.bindClassMemberFunction<UIWidget>("getBackgroundRect", &UIWidget::getBackgroundRect);
201
+    g_lua.bindClassMemberFunction<UIWidget>("getIconColor", &UIWidget::getIconColor);
202
+    g_lua.bindClassMemberFunction<UIWidget>("getIconOffsetX", &UIWidget::getIconOffsetX);
203
+    g_lua.bindClassMemberFunction<UIWidget>("getIconOffsetY", &UIWidget::getIconOffsetY);
204
+    g_lua.bindClassMemberFunction<UIWidget>("getIconOffset", &UIWidget::getIconOffset);
205
+    g_lua.bindClassMemberFunction<UIWidget>("getIconWidth", &UIWidget::getIconWidth);
206
+    g_lua.bindClassMemberFunction<UIWidget>("getIconHeight", &UIWidget::getIconHeight);
207
+    g_lua.bindClassMemberFunction<UIWidget>("getIconSize", &UIWidget::getIconSize);
208
+    g_lua.bindClassMemberFunction<UIWidget>("getIconRect", &UIWidget::getIconRect);
209
+    g_lua.bindClassMemberFunction<UIWidget>("getBorderTopColor", &UIWidget::getBorderTopColor);
210
+    g_lua.bindClassMemberFunction<UIWidget>("getBorderRightColor", &UIWidget::getBorderRightColor);
211
+    g_lua.bindClassMemberFunction<UIWidget>("getBorderBottomColor", &UIWidget::getBorderBottomColor);
212
+    g_lua.bindClassMemberFunction<UIWidget>("getBorderLeftColor", &UIWidget::getBorderLeftColor);
213
+    g_lua.bindClassMemberFunction<UIWidget>("getBorderTopWidth", &UIWidget::getBorderTopWidth);
214
+    g_lua.bindClassMemberFunction<UIWidget>("getBorderRightWidth", &UIWidget::getBorderRightWidth);
215
+    g_lua.bindClassMemberFunction<UIWidget>("getBorderBottomWidth", &UIWidget::getBorderBottomWidth);
216
+    g_lua.bindClassMemberFunction<UIWidget>("getBorderLeftWidth", &UIWidget::getBorderLeftWidth);
134 217
     g_lua.bindClassMemberFunction<UIWidget>("getMarginTop", &UIWidget::getMarginTop);
135 218
     g_lua.bindClassMemberFunction<UIWidget>("getMarginRight", &UIWidget::getMarginRight);
136 219
     g_lua.bindClassMemberFunction<UIWidget>("getMarginBottom", &UIWidget::getMarginBottom);
137 220
     g_lua.bindClassMemberFunction<UIWidget>("getMarginLeft", &UIWidget::getMarginLeft);
221
+    g_lua.bindClassMemberFunction<UIWidget>("getPaddingTop", &UIWidget::getPaddingTop);
222
+    g_lua.bindClassMemberFunction<UIWidget>("getPaddingRight", &UIWidget::getPaddingRight);
223
+    g_lua.bindClassMemberFunction<UIWidget>("getPaddingBottom", &UIWidget::getPaddingBottom);
224
+    g_lua.bindClassMemberFunction<UIWidget>("getPaddingLeft", &UIWidget::getPaddingLeft);
225
+    g_lua.bindClassMemberFunction<UIWidget>("getOpacity", &UIWidget::getOpacity);
226
+    g_lua.bindClassMemberFunction<UIWidget>("setImageSource", &UIWidget::setImageSource);
227
+    g_lua.bindClassMemberFunction<UIWidget>("setImageClip", &UIWidget::setImageClip);
228
+    g_lua.bindClassMemberFunction<UIWidget>("setImageOffsetX", &UIWidget::setImageOffsetX);
229
+    g_lua.bindClassMemberFunction<UIWidget>("setImageOffsetY", &UIWidget::setImageOffsetY);
230
+    g_lua.bindClassMemberFunction<UIWidget>("setImageOffset", &UIWidget::setImageOffset);
231
+    g_lua.bindClassMemberFunction<UIWidget>("setImageWidth", &UIWidget::setImageWidth);
232
+    g_lua.bindClassMemberFunction<UIWidget>("setImageHeight", &UIWidget::setImageHeight);
233
+    g_lua.bindClassMemberFunction<UIWidget>("setImageSize", &UIWidget::setImageSize);
234
+    g_lua.bindClassMemberFunction<UIWidget>("setImageRect", &UIWidget::setImageRect);
235
+    g_lua.bindClassMemberFunction<UIWidget>("setImageColor", &UIWidget::setImageColor);
236
+    g_lua.bindClassMemberFunction<UIWidget>("setImageFixedRatio", &UIWidget::setImageFixedRatio);
237
+    g_lua.bindClassMemberFunction<UIWidget>("setImageRepeated", &UIWidget::setImageRepeated);
238
+    g_lua.bindClassMemberFunction<UIWidget>("setImageSmooth", &UIWidget::setImageSmooth);
239
+    g_lua.bindClassMemberFunction<UIWidget>("setImageBorderTop", &UIWidget::setImageBorderTop);
240
+    g_lua.bindClassMemberFunction<UIWidget>("setImageBorderRight", &UIWidget::setImageBorderRight);
241
+    g_lua.bindClassMemberFunction<UIWidget>("setImageBorderBottom", &UIWidget::setImageBorderBottom);
242
+    g_lua.bindClassMemberFunction<UIWidget>("setImageBorderLeft", &UIWidget::setImageBorderLeft);
243
+    g_lua.bindClassMemberFunction<UIWidget>("setImageBorder", &UIWidget::setImageBorder);
244
+    g_lua.bindClassMemberFunction<UIWidget>("getImageClip", &UIWidget::getImageClip);
245
+    g_lua.bindClassMemberFunction<UIWidget>("getImageOffsetX", &UIWidget::getImageOffsetX);
246
+    g_lua.bindClassMemberFunction<UIWidget>("getImageOffsetY", &UIWidget::getImageOffsetY);
247
+    g_lua.bindClassMemberFunction<UIWidget>("getImageOffset", &UIWidget::getImageOffset);
248
+    g_lua.bindClassMemberFunction<UIWidget>("getImageWidth", &UIWidget::getImageWidth);
249
+    g_lua.bindClassMemberFunction<UIWidget>("getImageHeight", &UIWidget::getImageHeight);
250
+    g_lua.bindClassMemberFunction<UIWidget>("getImageSize", &UIWidget::getImageSize);
251
+    g_lua.bindClassMemberFunction<UIWidget>("getImageRect", &UIWidget::getImageRect);
252
+    g_lua.bindClassMemberFunction<UIWidget>("getImageColor", &UIWidget::getImageColor);
253
+    g_lua.bindClassMemberFunction<UIWidget>("isImageFixedRatio", &UIWidget::isImageFixedRatio);
254
+    g_lua.bindClassMemberFunction<UIWidget>("isImageSmooth", &UIWidget::isImageSmooth);
255
+    g_lua.bindClassMemberFunction<UIWidget>("getImageBorderTop", &UIWidget::getImageBorderTop);
256
+    g_lua.bindClassMemberFunction<UIWidget>("getImageBorderRight", &UIWidget::getImageBorderRight);
257
+    g_lua.bindClassMemberFunction<UIWidget>("getImageBorderBottom", &UIWidget::getImageBorderBottom);
258
+    g_lua.bindClassMemberFunction<UIWidget>("getImageBorderLeft", &UIWidget::getImageBorderLeft);
259
+    g_lua.bindClassMemberFunction<UIWidget>("resizeToText", &UIWidget::resizeToText);
260
+    g_lua.bindClassMemberFunction<UIWidget>("clearText", &UIWidget::clearText);
261
+    g_lua.bindClassMemberFunction<UIWidget>("setText", &UIWidget::setText);
262
+    g_lua.bindClassMemberFunction<UIWidget>("setTextAlign", &UIWidget::setTextAlign);
263
+    g_lua.bindClassMemberFunction<UIWidget>("setTextOffset", &UIWidget::setTextOffset);
264
+    g_lua.bindClassMemberFunction<UIWidget>("setFont", &UIWidget::setFont);
138 265
     g_lua.bindClassMemberFunction<UIWidget>("getText", &UIWidget::getText);
139 266
     g_lua.bindClassMemberFunction<UIWidget>("getTextAlign", &UIWidget::getTextAlign);
140 267
     g_lua.bindClassMemberFunction<UIWidget>("getTextOffset", &UIWidget::getTextOffset);
141 268
     g_lua.bindClassMemberFunction<UIWidget>("getFont", &UIWidget::getFont);
142 269
     g_lua.bindClassMemberFunction<UIWidget>("getTextSize", &UIWidget::getTextSize);
143
-    g_lua.bindClassMemberFunction<UIWidget>("getLastFocusReason", &UIWidget::getLastFocusReason);
144
-    g_lua.bindClassMemberFunction<UIWidget>("getStyle", &UIWidget::getStyle);
145
-    g_lua.bindClassMemberFunction<UIWidget>("getStyleName", &UIWidget::getStyleName);
146
-    g_lua.bindClassMemberFunction<UIWidget>("getChildren", &UIWidget::getChildren);
147
-    g_lua.bindClassMemberFunction<UIWidget>("getFocusedChild", &UIWidget::getFocusedChild);
148
-    g_lua.bindClassMemberFunction<UIWidget>("getChildAfter", &UIWidget::getChildAfter);
149
-    g_lua.bindClassMemberFunction<UIWidget>("getChildBefore", &UIWidget::getChildBefore);
150
-    g_lua.bindClassMemberFunction<UIWidget>("getChildById", &UIWidget::getChildById);
151
-    g_lua.bindClassMemberFunction<UIWidget>("getChildByPos", &UIWidget::getChildByPos);
152
-    g_lua.bindClassMemberFunction<UIWidget>("getChildByIndex", &UIWidget::getChildByIndex);
153
-    g_lua.bindClassMemberFunction<UIWidget>("getFirstChild", &UIWidget::getFirstChild);
154
-    g_lua.bindClassMemberFunction<UIWidget>("getLastChild", &UIWidget::getLastChild);
155
-    g_lua.bindClassMemberFunction<UIWidget>("recursiveGetChildById", &UIWidget::recursiveGetChildById);
156
-    g_lua.bindClassMemberFunction<UIWidget>("recursiveGetChildByPos", &UIWidget::recursiveGetChildByPos);
157
-    g_lua.bindClassMemberFunction<UIWidget>("backwardsGetWidgetById", &UIWidget::backwardsGetWidgetById);
158
-    g_lua.bindClassMemberFunction<UIWidget>("addChild", &UIWidget::addChild);
159
-    g_lua.bindClassMemberFunction<UIWidget>("insertChild", &UIWidget::insertChild);
160
-    g_lua.bindClassMemberFunction<UIWidget>("removeChild", &UIWidget::removeChild);
161
-    g_lua.bindClassMemberFunction<UIWidget>("focusChild", &UIWidget::focusChild);
162
-    g_lua.bindClassMemberFunction<UIWidget>("focusNextChild", &UIWidget::focusNextChild);
163
-    g_lua.bindClassMemberFunction<UIWidget>("focusPreviousChild", &UIWidget::focusPreviousChild);
164
-    g_lua.bindClassMemberFunction<UIWidget>("moveChildToTop", &UIWidget::moveChildToTop);
165
-    g_lua.bindClassMemberFunction<UIWidget>("moveChildToIndex", &UIWidget::moveChildToIndex);
166
-    g_lua.bindClassMemberFunction<UIWidget>("lockChild", &UIWidget::lockChild);
167
-    g_lua.bindClassMemberFunction<UIWidget>("unlockChild", &UIWidget::unlockChild);
168
-    g_lua.bindClassMemberFunction<UIWidget>("isChildLocked", &UIWidget::isChildLocked);
169
-    g_lua.bindClassMemberFunction<UIWidget>("getChildIndex", &UIWidget::getChildIndex);
170
-    g_lua.bindClassMemberFunction<UIWidget>("updateParentLayout", &UIWidget::updateParentLayout);
171
-    g_lua.bindClassMemberFunction<UIWidget>("updateLayout", &UIWidget::updateLayout);
172
-    g_lua.bindClassMemberFunction<UIWidget>("applyStyle", &UIWidget::applyStyle);
173 270
 
174 271
     // UILayout
175 272
     g_lua.registerClass<UILayout>();
@@ -191,12 +288,6 @@ void Application::registerLuaFunctions()
191 288
     g_lua.bindClassMemberFunction<UIAnchorLayout>("centerIn", &UIAnchorLayout::centerIn);
192 289
     g_lua.bindClassMemberFunction<UIAnchorLayout>("fill", &UIAnchorLayout::fill);
193 290
 
194
-    // UIProgressBar
195
-    g_lua.registerClass<UIProgressBar, UIWidget>();
196
-    g_lua.bindClassStaticFunction<UIProgressBar>("create", []{ return UIProgressBarPtr(new UIProgressBar); } );
197
-    g_lua.bindClassMemberFunction<UIProgressBar>("getPercent", &UIProgressBar::getPercent);
198
-    g_lua.bindClassMemberFunction<UIProgressBar>("setPercent", &UIProgressBar::setPercent);
199
-
200 291
     // UILineEdit
201 292
     g_lua.registerClass<UILineEdit, UIWidget>();
202 293
     g_lua.bindClassStaticFunction<UILineEdit>("create", []{ return UILineEditPtr(new UILineEdit); } );
@@ -216,10 +307,6 @@ void Application::registerLuaFunctions()
216 307
     g_lua.bindClassMemberFunction<UILineEdit>("isAlwaysActive", &UILineEdit::isAlwaysActive);
217 308
     g_lua.bindClassMemberFunction<UILineEdit>("isTextHidden", &UILineEdit::isTextHidden);
218 309
 
219
-    // UICheckBox
220
-    g_lua.registerClass<UICheckBox, UIWidget>();
221
-    g_lua.bindClassStaticFunction<UICheckBox>("create", []{ return UICheckBoxPtr(new UICheckBox); } );
222
-
223 310
     // UIWindow
224 311
     g_lua.registerClass<UIWindow, UIWidget>();
225 312
     g_lua.bindClassStaticFunction<UIWindow>("create", []{ return UIWindowPtr(new UIWindow); } );

+ 4
- 0
src/framework/luascript/luavaluecasts.h View File

@@ -40,6 +40,10 @@ bool luavalue_cast(int index, int& i);
40 40
 void push_luavalue(double d);
41 41
 bool luavalue_cast(int index, double& d);
42 42
 
43
+// float
44
+inline void push_luavalue(float f) { push_luavalue((double)f); }
45
+inline bool luavalue_cast(int index, float& f) { double d; bool r = luavalue_cast(index, d); f = d; return r; }
46
+
43 47
 // int8
44 48
 inline void push_luavalue(int8 v) { push_luavalue((int)v); }
45 49
 inline bool luavalue_cast(int index, int8& v) { int i; bool r = luavalue_cast(index, i); v = i; return r; }

+ 13
- 10
src/framework/math/rect.h View File

@@ -42,6 +42,7 @@ public:
42 42
     TRect(const TRect<T>& other) : x1(other.x1), y1(other.y1), x2(other.x2), y2(other.y2) { }
43 43
     TRect(T x, T y, const TSize<T>& size) : x1(x), y1(y), x2(x+size.width()-1), y2(y+size.height()-1) { }
44 44
     TRect(const TPoint<T>& topLeft, const TSize<T>& size) : x1(topLeft.x), y1(topLeft.y), x2(x1+size.width()-1), y2(y1+size.height()-1) { }
45
+    TRect(const TPoint<T>& topLeft, int width, int height) : x1(topLeft.x), y1(topLeft.y), x2(x1+width-1), y2(y1+height-1) { }
45 46
 
46 47
     bool isNull() const { return x2 == x1 - 1 && y2 == y1 - 1; }
47 48
     bool isEmpty() const { return x1 > x2 || y1 > y2; }
@@ -78,21 +79,23 @@ public:
78 79
     void setBottomLeft(const TPoint<T> &p) { x1 = p.x; y2 = p.y; }
79 80
     void setWidth(T width) { x2 = x1 + width - 1; }
80 81
     void setHeight(T height) { y2 = y1 + height- 1; }
81
-    void resize(T width, T height) { x2 = x1 + width - 1; y2 = y1 + height - 1; }
82
-    void resize(const TSize<T>& size) { x2 = x1 + size.width() - 1; y2 = y1 + size.height() - 1; }
82
+    void setSize(const TSize<T>& size) { x2 = x1 + size.width() - 1; y2 = y1 + size.height() - 1; }
83 83
     void setRect(T x, T y, T width, T height) { x1 = x; y1 = y; x2 = (x + width - 1); y2 = (y + height - 1); }
84 84
     void setCoords(int left, int top, int right, int bottom) { x1 = left; y1 = top; x2 = right; y2 = bottom; }
85 85
 
86
-    void addLeft(T add) { x1 -= add; }
87
-    void addTop(T add) { y1 -= add; }
88
-    void addRight(T add) { x2 += add; }
89
-    void addBottom(T add) { y2 += add; }
90
-    void add(T top, T right, T bottom, T left) { x1 -= left; y1 -= top; x2 += right; y2 += bottom; }
86
+    void expandLeft(T add) { x1 -= add; }
87
+    void expandTop(T add) { y1 -= add; }
88
+    void expandRight(T add) { x2 += add; }
89
+    void expandBottom(T add) { y2 += add; }
90
+    void expand(T top, T right, T bottom, T left) { x1 -= left; y1 -= top; x2 += right; y2 += bottom; }
91
+    void expand(T add) { x1 -= add; y1 -= add; x2 += add; y2 += add; }
91 92
 
92 93
     void translate(T x, T y) { x1 += x; y1 += y; x2 += x; y2 += y; }
93 94
     void translate(const TPoint<T> &p) { x1 += p.x; y1 += p.y; x2 += p.x; y2 += p.y; }
94
-    void moveTo(T x, T y) { x2 += x - x1; y2 += y - y1; x1 = x; y1 = y; }
95
-    void moveTo(const TPoint<T> &p) { x2 += p.x - x1; y2 += p.y - y1; x1 = p.x; y1 = p.y; }
95
+    void resize(const TSize<T>& size) { x2 = x1 + size.width() - 1; y2 = y1 + size.height() - 1; }
96
+    void resize(T width, T height) { x2 = x1 + width - 1; y2 = y1 + height - 1; }
97
+    void move(T x, T y) { x2 += x - x1; y2 += y - y1; x1 = x; y1 = y; }
98
+    void move(const TPoint<T> &p) { x2 += p.x - x1; y2 += p.y - y1; x1 = p.x; y1 = p.y; }
96 99
     void moveLeft(T pos) { x2 += (pos - x1); x1 = pos; }
97 100
     void moveTop(T pos) { y2 += (pos - y1); y1 = pos; }
98 101
     void moveRight(T pos) { x1 += (pos - x2); x2 = pos; }
@@ -105,7 +108,7 @@ public:
105 108
     TRect<T> translated(int x, int y) const { return TRect<T>(TPoint<T>(x1 + x, y1 + y), TPoint<T>(x2 + x, y2 + y)); }
106 109
     TRect<T> translated(const TPoint<T> &p) const { return TRect<T>(TPoint<T>(x1 + p.x, y1 + p.y), TPoint<T>(x2 + p.x, y2 + p.y)); }
107 110
 
108
-    TRect<T> expanded(T pixels) const { return TRect<T>(TPoint<T>(x1 - pixels, y1 - pixels), TPoint<T>(x2 + pixels, y2 + pixels)); }
111
+    TRect<T> expanded(T add) const { return TRect<T>(TPoint<T>(x1 - add, y1 - add), TPoint<T>(x2 + add, y2 + add)); }
109 112
 
110 113
     void moveCenter(const TPoint<T> &p) {
111 114
         T w = x2 - x1;

+ 0
- 8
src/framework/ui/declarations.h View File

@@ -27,11 +27,7 @@
27 27
 
28 28
 class UIManager;
29 29
 class UIWidget;
30
-class UILabel;
31
-class UIButton;
32 30
 class UILineEdit;
33
-class UICheckBox;
34
-class UIProgressBar;
35 31
 class UIFrameCounter;
36 32
 class UIWindow;
37 33
 class UILayout;
@@ -41,11 +37,7 @@ class UIAnchorLayout;
41 37
 typedef std::shared_ptr<UIWidget> UIWidgetPtr;
42 38
 typedef std::weak_ptr<UIWidget> UIWidgetWeakPtr;
43 39
 
44
-typedef std::shared_ptr<UILabel> UILabelPtr;
45
-typedef std::shared_ptr<UIButton> UIButtonPtr;
46 40
 typedef std::shared_ptr<UILineEdit> UILineEditPtr;
47
-typedef std::shared_ptr<UICheckBox> UICheckBoxPtr;
48
-typedef std::shared_ptr<UIProgressBar> UIProgressBarPtr;
49 41
 typedef std::shared_ptr<UIFrameCounter> UIFrameCounterPtr;
50 42
 typedef std::shared_ptr<UIWindow> UIWindowPtr;
51 43
 typedef std::shared_ptr<UILayout> UILayoutPtr;

+ 0
- 2
src/framework/ui/ui.h View File

@@ -28,8 +28,6 @@
28 28
 #include "uilineedit.h"
29 29
 #include "uiwindow.h"
30 30
 #include "uiframecounter.h"
31
-#include "uiprogressbar.h"
32
-#include "uicheckbox.h"
33 31
 #include "uilayout.h"
34 32
 #include "uiverticallayout.h"
35 33
 #include "uianchorlayout.h"

+ 0
- 79
src/framework/ui/uicheckbox.cpp View File

@@ -1,79 +0,0 @@
1
-/*
2
- * Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- * THE SOFTWARE.
21
- */
22
-
23
-#include "uicheckbox.h"
24
-#include "uitranslator.h"
25
-#include <framework/otml/otmlnode.h>
26
-#include <framework/graphics/image.h>
27
-#include <framework/graphics/font.h>
28
-#include <framework/graphics/graphics.h>
29
-#include <framework/core/eventdispatcher.h>
30
-
31
-UICheckBox::UICheckBox()
32
-{
33
-    m_focusable = false;
34
-    m_textAlign = Fw::AlignLeft;
35
-}
36
-
37
-void UICheckBox::render()
38
-{
39
-    if(m_image) {
40
-        Rect boxRect;
41
-        boxRect.resize(m_boxSize);
42
-        boxRect.moveLeft(m_rect.left());
43
-        boxRect.moveVerticalCenter(m_rect.verticalCenter());
44
-        g_painter.setColor(m_backgroundColor);
45
-        m_image->draw(boxRect);
46
-    }
47
-
48
-    if(m_text.length()) {
49
-        Rect textRect(m_rect);
50
-        textRect.setTopLeft(textRect.topLeft() + m_textOffset);
51
-        m_font->renderText(m_text, textRect, m_textAlign, m_color);
52
-    }
53
-}
54
-
55
-void UICheckBox::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
56
-{
57
-    if(isPressed() && getRect().contains(mousePos))
58
-        setChecked(!isChecked());
59
-}
60
-
61
-void UICheckBox::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)
62
-{
63
-    UIWidget::onStyleApply(styleName, styleNode);
64
-
65
-    for(OTMLNodePtr node : styleNode->children()) {
66
-        if(node->tag() == "text-offset")
67
-            m_textOffset = node->value<Point>();
68
-        else if(node->tag() == "text")
69
-            m_text = node->value();
70
-        else if(node->tag() == "box-size")
71
-            m_boxSize = node->value<Size>();
72
-        else if(node->tag() == "text-align")
73
-            m_textAlign = Fw::translateAlignment(node->value());
74
-        else if(node->tag() == "checked") {
75
-            // must be scheduled because setChecked can change the style again
76
-            g_dispatcher.addEvent(std::bind(&UICheckBox::setChecked, asUICheckBox(), node->value<bool>()));
77
-        }
78
-    }
79
-}

+ 0
- 49
src/framework/ui/uicheckbox.h View File

@@ -1,49 +0,0 @@
1
-/*
2
- * Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- * THE SOFTWARE.
21
- */
22
-
23
-#ifndef UICHECKBOX_H
24
-#define UICHECKBOX_H
25
-
26
-#include "uiwidget.h"
27
-
28
-class UICheckBox : public UIWidget
29
-{
30
-public:
31
-    UICheckBox();
32
-    void render();
33
-
34
-    void setText(const std::string& text) { m_text = text; }
35
-    std::string getText() { return m_text; }
36
-
37
-    UICheckBoxPtr asUICheckBox() { return std::static_pointer_cast<UICheckBox>(shared_from_this()); }
38
-
39
-protected:
40
-    virtual void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);
41
-    virtual void onMouseRelease(const Point& mousePos, Fw::MouseButton button);
42
-
43
-    std::string m_text;
44
-    Size m_boxSize;
45
-    Point m_textOffset;
46
-    Fw::AlignmentFlag m_textAlign;
47
-};
48
-
49
-#endif

+ 2
- 2
src/framework/ui/uiframecounter.cpp View File

@@ -36,9 +36,9 @@ UIFrameCounter::UIFrameCounter()
36 36
     m_frameCount = 0;
37 37
 }
38 38
 
39
-void UIFrameCounter::render()
39
+void UIFrameCounter::draw()
40 40
 {
41
-    UIWidget::render();
41
+    UIWidget::draw();
42 42
 
43 43
     if(g_clock.ticksElapsed(m_lastFrameTicks) >= 1000) {
44 44
         m_fpsText = Fw::mkstr("FPS: ", m_frameCount);

+ 1
- 1
src/framework/ui/uiframecounter.h View File

@@ -29,7 +29,7 @@ class UIFrameCounter : public UIWidget
29 29
 {
30 30
 public:
31 31
     UIFrameCounter();
32
-    virtual void render();
32
+    virtual void draw();
33 33
 
34 34
     void setAlign(Fw::AlignmentFlag align) { m_align = align; }
35 35
     Fw::AlignmentFlag getAlign() { return m_align; }

+ 0
- 41
src/framework/ui/uiimage.cpp View File

@@ -1,41 +0,0 @@
1
-#include "uiimage.h"
2
-#include <framework/otml/otmlnode.h>
3
-
4
-void UIImage::draw(const Rect& screenCoords)
5
-{
6
-
7
-}
8
-
9
-void UIImage::applyStyle(const OTMLNodePtr& styleNode)
10
-{
11
-    /*
12
-    for(const OTMLNodePtr& node : styleNode->children()) {
13
-        if(node->tag() == "image-source")
14
-            setImageSource(node->value());
15
-        else if(node->tag() == "image-clip")
16
-            setImageClip(node->value<Rect>());
17
-        else if(node->tag() == "image-rect")
18
-            setImageRect(node->value<Rect>());
19
-        else if(node->tag() == "image-fixed-ratio")
20
-            setImageFixedRatio(node->value<bool>());
21
-        else if(node->tag() == "image-repeated")
22
-            setImageRepeated(node->value<bool>());
23
-        else if(node->tag() == "image-smooth")
24
-            setImageSmooth(node->value<bool>());
25
-        else if(node->tag() == "image-color")
26
-            setImageColor(node->value<Color>());
27
-        else if(node->tag() == "image-border-top")
28
-            setImageBorderTop(node->value<int>());
29
-        else if(node->tag() == "image-border-right")
30
-            setImageBorderRight(node->value<int>());
31
-        else if(node->tag() == "image-border-bottom")
32
-            setImageBorderBottom(node->value<int>());
33
-        else if(node->tag() == "image-border-left")
34
-            setImageBorderLeft(node->value<int>());
35
-        else if(node->tag() == "image-border") {
36
-
37
-        }
38
-    }
39
-    */
40
-}
41
-

+ 0
- 69
src/framework/ui/uiimage.h View File

@@ -1,69 +0,0 @@
1
-/*
2
- * Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- * THE SOFTWARE.
21
- */
22
-
23
-#ifndef UIIMAGE_H
24
-#define UIIMAGE_H
25
-
26
-#include <framework/graphics/declarations.h>
27
-#include <framework/otml/declarations.h>
28
-#include "declarations.h"
29
-
30
-class UIImage
31
-{
32
-public:
33
-    void draw(const Rect& screenCoords);
34
-    void applyStyle(const OTMLNodePtr& styleNode);
35
-
36
-    void setImageSource(const std::string& source);
37
-    void setImageClip(const Rect& clipRect);
38
-    void setImageRect(const Rect& rect);
39
-    void setImageFixedRatio(bool fixedRatio);
40
-    void setImageRepeated(bool repeated);
41
-    void setImageSmooth(bool smooth);
42
-    void setImageColor(const Color& color);
43
-    void setImageBorderTop(int border);
44
-    void setImageBorderRight(int border);
45
-    void setImageBorderBottom(int border);
46
-    void setImageBorderLeft(int border);
47
-
48
-protected:
49
-    TexturePtr m_imageTexture;
50
-    Rect m_imageClipRect;
51
-    Rect m_imageRect;
52
-    Boolean<false> m_imageFixedRatio;
53
-    Boolean<false> m_imageRepeated;
54
-    Color m_imageColor;
55
-
56
-    // border image coords
57
-    Rect m_leftBorderTexCoords;
58
-    Rect m_rightBorderTexCoords;
59
-    Rect m_topBorderTexCoords;
60
-    Rect m_bottomBorderTexCoords;
61
-    Rect m_topLeftCornerTexCoords;
62
-    Rect m_topRightCornerTexCoords;
63
-    Rect m_bottomLeftCornerTexCoords;
64
-    Rect m_bottomRightCornerTexCoords;
65
-    Rect m_centerTexCoords;
66
-    Size m_bordersSize;
67
-};
68
-
69
-#endif

+ 4
- 1
src/framework/ui/uilayout.cpp View File

@@ -26,6 +26,9 @@
26 26
 
27 27
 void UILayout::update()
28 28
 {
29
+    if(m_updateDisabled)
30
+        return;
31
+
29 32
     assert(!m_updating);
30 33
     m_updating = true;
31 34
     internalUpdate();
@@ -34,7 +37,7 @@ void UILayout::update()
34 37
 
35 38
 void UILayout::updateLater()
36 39
 {
37
-    if(m_updateScheduled)
40
+    if(m_updateDisabled || m_updateScheduled)
38 41
         return;
39 42
 
40 43
     if(!getParentWidget())

+ 5
- 0
src/framework/ui/uilayout.h View File

@@ -38,9 +38,13 @@ public:
38 38
     virtual void applyStyle(const OTMLNodePtr& styleNode) { }
39 39
     virtual void addWidget(const UIWidgetPtr& widget) = 0;
40 40
     virtual void removeWidget(const UIWidgetPtr& widget) = 0;
41
+    void disableUpdates() { m_updateDisabled = true; }
42
+    void enableUpdates() { m_updateDisabled = false; }
41 43
 
44
+    void setParent(UIWidgetPtr parentWidget) { m_parentWidget = parentWidget; }
42 45
     UIWidgetPtr getParentWidget() { return m_parentWidget.lock(); }
43 46
 
47
+    bool isUpdateDisabled() { return m_updateDisabled; }
44 48
     bool isUpdating() { return m_updating; }
45 49
     virtual bool needsUpdatesOnChildChange() { return false; }
46 50
 
@@ -51,6 +55,7 @@ public:
51 55
 protected:
52 56
     virtual void internalUpdate() = 0;
53 57
 
58
+    Boolean<false> m_updateDisabled;
54 59
     Boolean<false> m_updating;
55 60
     Boolean<false> m_updateScheduled;
56 61
     UIWidgetWeakPtr m_parentWidget;

+ 5
- 5
src/framework/ui/uilineedit.cpp View File

@@ -38,7 +38,7 @@ UILineEdit::UILineEdit()
38 38
     blinkCursor();
39 39
 }
40 40
 
41
-void UILineEdit::renderSelf()
41
+void UILineEdit::drawSelf()
42 42
 {
43 43
     drawBackground(m_rect);
44 44
     drawBorder(m_rect);
@@ -140,8 +140,8 @@ void UILineEdit::update()
140 140
     }
141 141
 
142 142
     Rect textScreenCoords = m_rect;
143
-    textScreenCoords.addLeft(-m_textHorizontalMargin);
144
-    textScreenCoords.addRight(-m_textHorizontalMargin);
143
+    textScreenCoords.expandLeft(-m_textHorizontalMargin);
144
+    textScreenCoords.expandRight(-m_textHorizontalMargin);
145 145
     m_drawArea = textScreenCoords;
146 146
 
147 147
     if(m_textAlign & Fw::AlignBottom) {
@@ -339,8 +339,8 @@ int UILineEdit::getTextPos(Point pos)
339 339
     int candidatePos = -1;
340 340
     for(int i=0;i<textLength;++i) {
341 341
         Rect clickGlyphRect = m_glyphsCoords[i];
342
-        clickGlyphRect.addTop(m_font->getYOffset() + m_font->getGlyphSpacing().height());
343
-        clickGlyphRect.addLeft(m_font->getGlyphSpacing().width()+1);
342
+        clickGlyphRect.expandTop(m_font->getYOffset() + m_font->getGlyphSpacing().height());
343
+        clickGlyphRect.expandLeft(m_font->getGlyphSpacing().width()+1);
344 344
         if(clickGlyphRect.contains(pos))
345 345
             return i;
346 346
         else if(pos.y >= clickGlyphRect.top() && pos.y <= clickGlyphRect.bottom()) {

+ 1
- 1
src/framework/ui/uilineedit.h View File

@@ -30,7 +30,7 @@ class UILineEdit : public UIWidget
30 30
 public:
31 31
     UILineEdit();
32 32
 
33
-    virtual void renderSelf();
33
+    virtual void drawSelf();
34 34
 
35 35
 private:
36 36
     void update();

+ 2
- 2
src/framework/ui/uimanager.cpp View File

@@ -47,12 +47,12 @@ void UIManager::terminate()
47 47
 
48 48
 void UIManager::render()
49 49
 {
50
-    m_rootWidget->render();
50
+    m_rootWidget->draw();
51 51
 }
52 52
 
53 53
 void UIManager::resize(const Size& size)
54 54
 {
55
-    m_rootWidget->resize(g_window.getSize());
55
+    m_rootWidget->setSize(g_window.getSize());
56 56
 }
57 57
 
58 58
 void UIManager::inputEvent(const InputEvent& event)

+ 0
- 53
src/framework/ui/uiprogressbar.cpp View File

@@ -1,53 +0,0 @@
1
-/*
2
- * Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- * THE SOFTWARE.
21
- */
22
-
23
-#include "uiprogressbar.h"
24
-#include <framework/graphics/graphics.h>
25
-#include <framework/otml/otmlnode.h>
26
-
27
-UIProgressBar::UIProgressBar()
28
-{
29
-    m_phantom = false;
30
-    m_focusable = false;
31
-    m_percent = 0;
32
-}
33
-
34
-void UIProgressBar::render()
35
-{
36
-    UIWidget::render();
37
-
38
-    g_painter.setColor(m_color);
39
-    g_painter.drawBoundingRect(m_rect, 1);
40
-
41
-    Rect fillRect = m_rect.expanded(-1);
42
-    fillRect.setWidth(fillRect.width() * m_percent / 100.0);
43
-
44
-    g_painter.setColor(m_backgroundColor);
45
-    g_painter.drawFilledRect(fillRect);
46
-}
47
-
48
-void UIProgressBar::setPercent(double percent)
49
-{
50
-    if(percent == NAN)
51
-        percent = 0;
52
-    m_percent = std::min(std::max(percent, 0.0), 100.0);
53
-}

+ 0
- 41
src/framework/ui/uiprogressbar.h View File

@@ -1,41 +0,0 @@
1
-/*
2
- * Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
3
- *
4
- * Permission is hereby granted, free of charge, to any person obtaining a copy
5
- * of this software and associated documentation files (the "Software"), to deal
6
- * in the Software without restriction, including without limitation the rights
7
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- * copies of the Software, and to permit persons to whom the Software is
9
- * furnished to do so, subject to the following conditions:
10
- *
11
- * The above copyright notice and this permission notice shall be included in
12
- * all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- * THE SOFTWARE.
21
- */
22
-
23
-#ifndef UIPROGRESSBAR_H
24
-#define UIPROGRESSBAR_H
25
-
26
-#include "uiwidget.h"
27
-
28
-class UIProgressBar : public UIWidget
29
-{
30
-public:
31
-    UIProgressBar();
32
-    virtual void render();
33
-
34
-    void setPercent(double percent);
35
-    double getPercent() { return m_percent; }
36
-
37
-private:
38
-    double m_percent;
39
-};
40
-
41
-#endif

+ 1
- 1
src/framework/ui/uiverticallayout.cpp View File

@@ -97,7 +97,7 @@ void UIVerticalLayout::internalUpdate()
97 97
         pos.y += gap;
98 98
         prefferedHeight += gap;
99 99
 
100
-        if(widget->isSizeFixed()) {
100
+        if(widget->isFixedSize()) {
101 101
             // center it
102 102
             pos.x = childrenRect.left() + (childrenRect.width() - (widget->getMarginLeft() + widget->getWidth() + widget->getMarginRight()))/2;
103 103
             pos.x = std::max(pos.x, parentWidget->getX());

+ 539
- 747
src/framework/ui/uiwidget.cpp
File diff suppressed because it is too large
View File


+ 332
- 171
src/framework/ui/uiwidget.h View File

@@ -28,74 +28,67 @@
28 28
 #include <framework/graphics/declarations.h>
29 29
 #include <framework/otml/otmlnode.h>
30 30
 #include <framework/graphics/font.h>
31
+#include <framework/graphics/coordsbuffer.h>
32
+
33
+template<typename T = int>
34
+struct EdgeGroup {
35
+    EdgeGroup() { top = right = bottom = left = T(0); }
36
+    void set(T value) { top = right = bottom = left = value; }
37
+    T top;
38
+    T right;
39
+    T bottom;
40
+    T left;
41
+};
31 42
 
32 43
 class UIWidget : public LuaObject
33 44
 {
45
+// widget core
34 46
 public:
35 47
     UIWidget();
36
-    virtual ~UIWidget() { }
37
-
38
-    void destroy();
48
+    virtual ~UIWidget();
39 49
 
40 50
 protected:
41
-    virtual void render();
42
-    virtual void renderSelf();
43
-    virtual void renderChildren();
51
+    virtual void draw();
52
+    virtual void drawSelf();
53
+    virtual void drawChildren();
44 54
 
45 55
     friend class UIManager;
46 56
 
47
-    void drawBackground(const Rect& screenCoords);
48
-    void drawBorder(const Rect& screenCoords);
49
-    void drawImage(const Rect& screenCoords);