Кнопочки покрасивее

This commit is contained in:
Igor Timofeev 2017-09-03 17:12:37 +03:00
parent 5499fd8d40
commit 6eb09505ab
3 changed files with 19 additions and 11 deletions

View File

@ -301,7 +301,7 @@
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/GUI.lua",
type="Library",
preloadFile=true,
version=1.71,
version=1.72,
},
{
path="/lib/rayEngine.lua",

View File

@ -510,11 +510,11 @@ GUI.**button**( x, y, width, height, buttonColor, textColor, buttonPressedColor,
- GUI.**framedButton**(...) отрисовывается с рамкой по краям кнопки
![Imgur](http://i.imgur.com/xwuFWqG.png)
![Imgur](https://i.imgur.com/ajmXYFR.png)
- GUI.**roundedButton**(...) имеет симпатичные скругленные уголки
![Imgur](http://i.imgur.com/p2exfKn.png)
![Imgur](https://i.imgur.com/0UO3Vbm.png)
Для удобства имеется также альтернативные способы создания кнопки:
@ -558,7 +558,7 @@ mainContainer:startEventHandling()
Результат:
![Imgur](http://i.imgur.com/yJ9V4c8.gif)
![Imgur](https://i.imgur.com/9zZvR6g.gif)
GUI.**inputField**( x, y, width, height, backgroundColor, textColor, placeholderTextColor, backgroundFocusedColor, textFocusedColor, text, [placeholderText, eraseTextOnFocus, textMask ): *table* inputField
------------------------------------------------------------------------

View File

@ -475,22 +475,30 @@ end
local function buttonDraw(object)
local xText, yText = GUI.getAlignmentCoordinates(object, {width = unicode.len(object.text), height = 1})
local buttonColor, textColor, transparency = object.colors.default.background, object.colors.default.text, object.colors.default.transparency
local buttonColor, textColor = object.colors.default.background, object.colors.default.text
if object.disabled then
buttonColor, textColor, transparency = object.colors.disabled.background, object.colors.disabled.text, object.colors.disabled.transparency
buttonColor, textColor = object.colors.disabled.background, object.colors.disabled.text
else
if object.pressed then
buttonColor, textColor, transparency = object.colors.pressed.background, object.colors.pressed.text, object.colors.pressed.transparency
buttonColor, textColor = object.colors.pressed.background, object.colors.pressed.text
end
end
if buttonColor then
if object.buttonType == 1 then
buffer.square(object.x, object.y, object.width, object.height, buttonColor, textColor, " ", transparency)
buffer.square(object.x, object.y, object.width, object.height, buttonColor, textColor, " ")
elseif object.buttonType == 2 then
buffer.text(object.x + 1, object.y, buttonColor, string.rep("", object.width - 2), transparency)
buffer.square(object.x, object.y + 1, object.width, object.height - 2, buttonColor, textColor, " ", transparency)
buffer.text(object.x + 1, object.y + object.height - 1, buttonColor, string.rep("", object.width - 2), transparency)
local x2, y2 = object.x + object.width - 1, object.y + object.height - 1
buffer.text(object.x + 1, object.y, buttonColor, string.rep("", object.width - 2))
buffer.text(object.x, object.y, buttonColor, "")
buffer.text(x2, object.y, buttonColor, "")
buffer.square(object.x, object.y + 1, object.width, object.height - 2, buttonColor, textColor, " ")
buffer.text(object.x + 1, y2, buttonColor, string.rep("", object.width - 2))
buffer.text(object.x, y2, buttonColor, "")
buffer.text(x2, y2, buttonColor, "")
else
buffer.frame(object.x, object.y, object.width, object.height, buttonColor)
end