From ab16496c6d281e7f5c862d07670a5202f42ee326 Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Sun, 27 Jan 2019 08:34:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D0=B0=D1=8F=20=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D0=B0?= =?UTF-8?q?=20=D0=B0=D0=B2=D1=82=D0=BE=D1=85=D0=B0=D0=B9=D0=B4=D0=B0=20?= =?UTF-8?q?=D1=82=D0=BE=D0=B9=20=D0=B5=D0=B1=D0=B0=D0=BD=D0=B8=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Libraries/GUI.lua | 28 ++++++++++++++++------------ Libraries/System.lua | 34 +++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/Libraries/GUI.lua b/Libraries/GUI.lua index 289910cd..8c4c395b 100755 --- a/Libraries/GUI.lua +++ b/Libraries/GUI.lua @@ -3878,25 +3878,27 @@ local function dropDownMenuAddSeparator(menu) end local function dropDownMenuScrollDown(workspace, menu) - if menu.itemsContainer.children[1].localY < 1 then - for i = 1, #menu.itemsContainer.children do - menu.itemsContainer.children[i].localY = menu.itemsContainer.children[i].localY + 1 - end + local limit, first = 1, menu.itemsContainer.children[1] - dropDownMenuReposition(menu) - workspace:draw() + first.localY = first.localY + menu.scrollSpeed + if first.localY > limit then + first.localY = limit end + + dropDownMenuReposition(menu) + workspace:draw() end local function dropDownMenuScrollUp(workspace, menu) - if menu.itemsContainer.children[#menu.itemsContainer.children].localY + menu.itemsContainer.children[#menu.itemsContainer.children].height - 1 > menu.height then - for i = 1, #menu.itemsContainer.children do - menu.itemsContainer.children[i].localY = menu.itemsContainer.children[i].localY - 1 - end + local limit, first = -(#menu.itemsContainer.children * menu.itemHeight - menu.height - 1), menu.itemsContainer.children[1] - dropDownMenuReposition(menu) - workspace:draw() + first.localY = first.localY - menu.scrollSpeed + if first.localY < limit then + first.localY = limit end + + dropDownMenuReposition(menu) + workspace:draw() end local function dropDownMenuEventHandler(workspace, menu, e1, e2, e3, e4, e5) @@ -3965,6 +3967,8 @@ function GUI.dropDownMenu(x, y, width, maximumHeight, itemHeight, backgroundColo } } + menu.scrollSpeed = 1 + menu.itemsContainer = menu:addChild(GUI.container(1, 1, menu.width, menu.height)) menu.prevButton = menu:addChild(GUI.button(1, 1, menu.width, 1, backgroundColor, textColor, backgroundPressedColor, textPressedColor, "▲")) menu.nextButton = menu:addChild(GUI.button(1, 1, menu.width, 1, backgroundColor, textColor, backgroundPressedColor, textPressedColor, "▼")) diff --git a/Libraries/System.lua b/Libraries/System.lua index b6d7b50f..76ae6f15 100755 --- a/Libraries/System.lua +++ b/Libraries/System.lua @@ -29,7 +29,7 @@ local iconImageHorizontalOffset local bootRealTime local workspace -local windowsContainer +local desktopWindowsContainer local dockContainer local desktopMenu local desktopMenuLayout @@ -1481,14 +1481,18 @@ end -------------------------------------------------------------------------------- local function updateMenu() - local focusedWindow = windowsContainer.children[#windowsContainer.children] + local focusedWindow = desktopWindowsContainer.children[#desktopWindowsContainer.children] desktopMenu.children = focusedWindow and focusedWindow.menu.children or system.menuInitialChildren end local function setWorkspaceHidden(state) - dockContainer.hidden = state - desktopIconField.hidden = state - desktopBackground.hidden = state + local child + for i = 1, #workspace.children do + child = workspace.children[i] + if child ~= desktopWindowsContainer and child ~= desktopMenu then + child.hidden = state + end + end end local function windowMaximize(window, ...) @@ -1530,11 +1534,11 @@ end function system.addWindow(window, dontAddToDock, preserveCoordinates) -- Чекаем коорды if not preserveCoordinates then - window.x, window.y = math.floor(windowsContainer.width / 2 - window.width / 2), math.floor(windowsContainer.height / 2 - window.height / 2) + window.x, window.y = math.floor(desktopWindowsContainer.width / 2 - window.width / 2), math.floor(desktopWindowsContainer.height / 2 - window.height / 2) end -- Ебурим окно к окнам - windowsContainer:addChild(window) + desktopWindowsContainer:addChild(window) if not dontAddToDock then -- Получаем путь залупы @@ -1574,15 +1578,15 @@ function system.addWindow(window, dontAddToDock, preserveCoordinates) -- Смещаем окно правее и ниже, если уже есть открытые окна этой софтины local lastIndex - for i = #windowsContainer.children, 1, -1 do - if windowsContainer.children[i] ~= window and window.dockIcon.windows[windowsContainer.children[i]] then + for i = #desktopWindowsContainer.children, 1, -1 do + if desktopWindowsContainer.children[i] ~= window and window.dockIcon.windows[desktopWindowsContainer.children[i]] then lastIndex = i break end end if lastIndex then - window.localX, window.localY = windowsContainer.children[lastIndex].localX + 4, windowsContainer.children[lastIndex].localY + 2 + window.localX, window.localY = desktopWindowsContainer.children[lastIndex].localX + 4, desktopWindowsContainer.children[lastIndex].localY + 2 end -- Когда окно фокусицца, то главная ОСевая менюха заполницца ДЕТИШЕЧКАМИ оконной менюхи @@ -1930,7 +1934,7 @@ local function updateWallpaper(path, mode, brightness) end end else - GUI.alert("Failed to load wallpaper: " .. (reason or "image file is corrupted")) + GUI.alert(reason or "image file is corrupted") end end @@ -1966,7 +1970,7 @@ function system.updateResolution() desktopMenuLayout.width = workspace.width desktopBackground.width, desktopBackground.height = workspace.width, workspace.height - windowsContainer.width, windowsContainer.height = workspace.width, workspace.height - 1 + desktopWindowsContainer.width, desktopWindowsContainer.height = workspace.width, workspace.height - 1 end local function moveDockIcon(index, direction) @@ -2212,7 +2216,7 @@ function system.updateDesktop() overrideDockContainerDraw(dockContainer) end - windowsContainer = workspace:addChild(GUI.container(1, 2, 1, 1)) + desktopWindowsContainer = workspace:addChild(GUI.container(1, 2, 1, 1)) desktopMenu = workspace:addChild(GUI.menu(1, 1, workspace.width, 0x0, 0x696969, 0x3366CC, 0xFFFFFF)) @@ -2341,12 +2345,12 @@ function system.updateDesktop() local lastWindowHandled workspace.eventHandler = function(workspace, object, e1, e2, e3, e4) if e1 == "key_down" then - local windowCount = #windowsContainer.children + local windowCount = #desktopWindowsContainer.children -- Ctrl or CMD if windowCount > 0 and not lastWindowHandled and (keyboard.isKeyDown(29) or keyboard.isKeyDown(219)) then -- W if e4 == 17 then - windowsContainer.children[windowCount]:remove() + desktopWindowsContainer.children[windowCount]:remove() lastWindowHandled = true workspace:draw()