From 64485ac368e675ff184e699e907d60ec62c2d3aa Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Thu, 12 Jan 2017 18:56:35 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=80=D0=B0=20=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=B3=D1=80=D1=8F=D0=B7=D0=BD=D1=83=D1=8E?= =?UTF-8?q?=20=D0=B2=D0=B0=D0=B3=D0=B8=D0=BD=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 18436 -> 18436 bytes Applications.txt | 4 ++-- lib/GUI.lua | 60 ++++++++++++++++++++--------------------------- lib/windows.lua | 14 +++-------- 4 files changed, 31 insertions(+), 47 deletions(-) diff --git a/.DS_Store b/.DS_Store index 197a6671b4341f3677d50ff9e10898872bd2b833..c83143c2b420905205023c0fbc6e8895f99801d6 100644 GIT binary patch delta 595 zcmXYt%TE(Q9LMJ?BD={LrUfEhLzWh84>T2t_$X?N5(R;1v|>%sWbICMp|pgpFErs& zjrE}D#E6L(jX@IwY8up|(F=b7@#e`hM=vHmX11NfB;WbY@A3VV7f@cn`-2QE;t;C} zYiDeJUDwx}na|%IFzAGBmH1fEc5)84*{W7^Is%4~QO?m>E^k}Yyn`3bq!dF2h*wpvO&Z0!&Y{;uo~@{??kU*tFWL;jL~ z(9ni$Xh#4c#IOrJIDo@QVgN@lf>St+Gf3eAvf#+!GG=fCbGU`uxPu3HgvStgj<;CG z3f|!}zT%sx_|r}1(C~?7Iw%tCg{ZVlieO`SUQ*m13{lF64~neP;fQInO%kW($?m90 zS%U{nxsr#;8a+HpN)VK7_5dmw@0act$*ESGNXk~4hd{Z55!niwu5~4|okSk7*m^t@ z!ycLM7=~oJQH)_6X=E@V6XtLQlbAvtS8*LTy_99##XVGTU#5J5r&z=@yu>Rk;Wggi g1FBfXM|{E;mAe{m+t|_6yT32m*}JbAi+|txAMeJGMgRZ+ delta 478 zcmXYt%S%*Y9EQ(Bh3BI$=9|&PIT^$_nbIW2q|~64EvC{e7gL&6G&%HT%OX?A=AGq`3P)tr+91@TdECyHoZ+Iq!q~w_FKlj{36Pi- z7b^d#kdd)_`dqTPZSN+m5YoHf_|aB5hM&jc>+xDgT8r~ zql_}ngzujAy)LulI7gZDT;LKF-+ztkf&Uh_xx-x^^Mt27<2ehw<_(LyWr>e`s-@Qd Sh&LpAdJ>zG$y!(H%esG{1bL?b diff --git a/Applications.txt b/Applications.txt index b75ef068..06c99f72 100644 --- a/Applications.txt +++ b/Applications.txt @@ -300,13 +300,13 @@ name="lib/GUI.lua", url="IgorTimofeev/OpenComputers/master/lib/GUI.lua", type="Library", - version=1.26, + version=1.27, }, { name="lib/windows.lua", url="IgorTimofeev/OpenComputers/master/lib/windows.lua", type="Library", - version=1.08, + version=1.09, }, { name="lib/rayEngine.lua", diff --git a/lib/GUI.lua b/lib/GUI.lua index d29cf103..4bc2b991 100755 --- a/lib/GUI.lua +++ b/lib/GUI.lua @@ -1425,12 +1425,17 @@ local function scrollBarDraw(scrollBar) local isVertical = scrollBar.height > scrollBar.width local valuesDelta = scrollBar.maximumValue - scrollBar.minimumValue + 1 local part = scrollBar.value / valuesDelta - local barSize = math.ceil(scrollBar.shownValueCount / valuesDelta * scrollBar.height) - local halfBarSize = math.floor(barSize / 2) - buffer.square(scrollBar.x, scrollBar.y, scrollBar.width, scrollBar.height, scrollBar.colors.background, 0x0, " ") + if not isVertical and scrollBar.thinHorizontalMode then + buffer.text(scrollBar.x, scrollBar.y, scrollBar.colors.background, string.rep("▄", scrollBar.width)) + else + buffer.square(scrollBar.x, scrollBar.y, scrollBar.width, scrollBar.height, scrollBar.colors.background, 0x0, " ") + end if isVertical then + local barSize = math.ceil(scrollBar.shownValueCount / valuesDelta * scrollBar.height) + local halfBarSize = math.floor(barSize / 2) + scrollBar.ghostPosition.x = scrollBar.x scrollBar.ghostPosition.y = scrollBar.y + halfBarSize scrollBar.ghostPosition.width = scrollBar.width @@ -1444,24 +1449,31 @@ local function scrollBarDraw(scrollBar) scrollBar.colors.foreground, 0x0, " " ) else + local barSize = math.ceil(scrollBar.shownValueCount / valuesDelta * scrollBar.width) + local halfBarSize = math.floor(barSize / 2) + scrollBar.ghostPosition.x = scrollBar.x + halfBarSize scrollBar.ghostPosition.y = scrollBar.y scrollBar.ghostPosition.width = scrollBar.width - barSize scrollBar.ghostPosition.height = scrollBar.height - buffer.square( - math.floor(scrollBar.ghostPosition.x + part * scrollBar.ghostPosition.width - halfBarSize), - scrollBar.ghostPosition.y, - barSize, - scrollBar.ghostPosition.height, - scrollBar.colors.foreground, 0x0, " " - ) + if not isVertical and scrollBar.thinHorizontalMode then + buffer.text(math.floor(scrollBar.ghostPosition.x + part * scrollBar.ghostPosition.width - halfBarSize), scrollBar.ghostPosition.y, scrollBar.colors.foreground, string.rep("▄", barSize)) + else + buffer.square( + math.floor(scrollBar.ghostPosition.x + part * scrollBar.ghostPosition.width - halfBarSize), + scrollBar.ghostPosition.y, + barSize, + scrollBar.ghostPosition.height, + scrollBar.colors.foreground, 0x0, " " + ) + end end return scrollBar end -function GUI.scrollBar(x, y, width, height, backgroundColor, foregroundColor, minimumValue, maximumValue, value, shownValueCount, onScrollValueIncrement, horizontalThin) +function GUI.scrollBar(x, y, width, height, backgroundColor, foregroundColor, minimumValue, maximumValue, value, shownValueCount, onScrollValueIncrement, thinHorizontalMode) local scrollBar = GUI.object(x, y, width, height) scrollBar.maximumValue = maximumValue @@ -1469,7 +1481,7 @@ function GUI.scrollBar(x, y, width, height, backgroundColor, foregroundColor, mi scrollBar.value = value scrollBar.onScrollValueIncrement = onScrollValueIncrement scrollBar.shownValueCount = shownValueCount - scrollBar.thin = horizontalThin + scrollBar.thinHorizontalMode = thinHorizontalMode scrollBar.colors = { background = backgroundColor, foreground = foregroundColor, @@ -1482,33 +1494,13 @@ end -------------------------------------------------------------------------------------------------------------------------------- -buffer.start() -buffer.clear(0x1b1b1b) +-- buffer.start() +-- buffer.clear(0x1b1b1b) -- GUI.scrollBar(1, 5, 1, 20, 0x444444, 0x00DBFF, 1, 100, 50, 20, 1, true):draw() -- buffer.draw() --- local comboBox = GUI.comboBox(2, 2, 30, 1, 0xFFFFFF, 0x262626, 0xDDDDDD, 0x262626, {"PIC", "RAW", "PNG", "JPG"}) --- comboBox:selectItem() - --- buffer.draw() - --- GUI.chart(2, 10, 40, 20, 0xFFFFFF, 0xBBBBBB, 0xFFDB40, "t", "EU", 0, 2, { --- 0.5, --- 0.12 --- }):draw() - --- local menu = GUI.dropDownMenu(2, 2, 40, 1, 0xFFFFFF, 0x000000, 0xFFDB40, 0xFFFFFF, 0x999999, 0x777777, 50) --- menu:addItem("New") --- menu:addItem("Open") --- menu:addSeparator() --- menu:addItem("Save") --- menu:addItem("Save as") --- menu:show() - --- GUI.contextMenu(2, 2, {"Hello"}, {"World"}, "-", {"You are the"}, {"Best of best", false, "^S"}, {"And bestest yopta"}):show() - -------------------------------------------------------------------------------------------------------------------------------- return GUI diff --git a/lib/windows.lua b/lib/windows.lua index 65c63349..8a456431 100755 --- a/lib/windows.lua +++ b/lib/windows.lua @@ -282,18 +282,10 @@ end -- buffer.draw(true) -- local myWindow = windows.empty(2, 2, 60, 20, 60, 20) --- myWindow:addScrollBar(1, 1, 1, 20, 0x444444, 0x00DBFF, 1, 100, 50, 20, 4, true) --- myWindow:draw() --- buffer.draw() --- myWindow:handleEvents() - --- local myWindow = windows.empty(10, 5, 60, 20, 60, 20) --- myWindow:addPanel(1, 1, myWindow.width, myWindow.height, 0xEEEEEE) --- myWindow:addLabel(2, 5, 20, 1, 0x000000, tostring(10)):setAlignment(GUI.alignment.horizontal.center, GUI.alignment.vertical.top) --- myWindow:addHorizontalSlider(2, 4, 20, 0x880000, 0x000000, 0xFF4444, 0, 100, 10).onValueChanged = function(object) --- myWindow.counter.text = tostring(object.value) +-- local scrollBar = myWindow:addScrollBar(1, 1, 20, 1, 0x444444, 0x00DBFF, 1, 100, 50, 20, 4, true) +-- scrollBar.onTouch = function() +-- buffer.text(4, 1, 0xFFFFFF, "Value: " .. scrollBar.value) -- end - -- myWindow:draw() -- buffer.draw() -- myWindow:handleEvents()