Skip to content

Commit

Permalink
Changed layout. Fixed bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
exerro committed Nov 15, 2015
1 parent 4e99e16 commit 3b1c607
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 28 deletions.
3 changes: 1 addition & 2 deletions src/Todo.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Not all Screens should get term events.
When a monitor is added to a screen, redraw entirely.
Dynamic values.
Fix events to Screens.
ColourSelector class.
Label class.
RadioButton class.
Expand Down
4 changes: 2 additions & 2 deletions src/Animation.lua → src/core/Animation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
-- @once

-- @ifndef __INCLUDE_sheets
-- @error 'sheets' must be included before including 'sheets.Animation'
-- @error 'sheets' must be included before including 'sheets.core.Animation'
-- @endif

-- @print Including sheets.Animation
-- @print Including sheets.core.Animation

local sin, cos = math.sin, math.cos
local halfpi = math.pi / 2
Expand Down
4 changes: 2 additions & 2 deletions src/Application.lua → src/core/Application.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
-- @once

-- @ifndef __INCLUDE_sheets
-- @error 'sheets' must be included before including 'sheets.Application'
-- @error 'sheets' must be included before including 'sheets.core.Application'
-- @endif

-- @print Including sheets.Application
-- @print Including sheets.core.Application

local function exceptionHandler( e )
return error( tostring( e ), 0 )
Expand Down
12 changes: 12 additions & 0 deletions src/core/DynamicValue.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

-- @once

-- @ifndef __INCLUDE_sheets
-- @error 'sheets' must be included before including 'sheets.core.DynamicValue'
-- @endif

-- @print Including sheets.core.DynamicValue

class "DynamicValue" {
instance = nil;
}
16 changes: 14 additions & 2 deletions src/Screen.lua → src/core/Screen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
-- @once

-- @ifndef __INCLUDE_sheets
-- @error 'sheets' must be included before including 'sheets.Screen'
-- @error 'sheets' must be included before including 'sheets.core.Screen'
-- @endif

-- @print Including sheets.Screen
-- @print Including sheets.core.Screen

class "Screen"
implements "IAnimation"
Expand All @@ -29,6 +29,15 @@ function Screen:Screen( application, width, height )
self.height = height
end

function Screen:getsTermEvents()
for i = 1, #self.terminals do
if self.terminals[i] == term then
return true
end
end
return false
end

function Screen:setChanged( state )
self.changed = state ~= false
if state ~= false then -- must have a parent Application
Expand Down Expand Up @@ -68,7 +77,10 @@ end

function Screen:addTerminal( t )
parameters.check( 1, "terminal", "table", t )

self.terminals[#self.terminals + 1] = t
self.canvas:reset()

return self:setChanged()
end

Expand Down
4 changes: 2 additions & 2 deletions src/Sheet.lua → src/core/Sheet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
-- @once

-- @ifndef __INCLUDE_sheets
-- @error 'sheets' must be included before including 'sheets.Sheet'
-- @error 'sheets' must be included before including 'sheets.core.Sheet'
-- @endif

-- @print Including sheets.Sheet
-- @print Including sheets.core.Sheet

class "Sheet"
implements "IAnimation"
Expand Down
4 changes: 2 additions & 2 deletions src/Style.lua → src/core/Style.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
-- @once

-- @ifndef __INCLUDE_sheets
-- @error 'sheets' must be included before including 'sheets.Style'
-- @error 'sheets' must be included before including 'sheets.core.Style'
-- @endif

-- @print Including sheets.Style
-- @print Including sheets.core.Style

local function formatFieldName( name )
if not name:find "%." then
Expand Down
4 changes: 2 additions & 2 deletions src/Thread.lua → src/core/Thread.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
-- @once

-- @ifndef __INCLUDE_sheets
-- @error 'sheets' must be included before including 'sheets.Thread'
-- @error 'sheets' must be included before including 'sheets.core.Thread'
-- @endif

-- @print Including sheets.Thread
-- @print Including sheets.core.Thread

class "Thread" {
running = true;
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/ScreenCanvas.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ end

function ScreenCanvas:reset()
local t = {}
for i = 1, width * height do
for i = 1, self.width * self.height do
self.last[i] = t
end
end
Expand Down
5 changes: 3 additions & 2 deletions src/interfaces/IAttributeAnimator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ local function animateElementInOrOut( self, mode, vertical, current, to, time )
else
self:addAnimation( "x", self.setX, a )
end

if mode == "exit" then
function a.onFinish() self:remove() end
end
Expand Down Expand Up @@ -85,7 +86,7 @@ function IAttributeAnimator:animateIn( side, to, time )
elseif side == "bottom" then
return animateElementInOrOut( self, "in", true, self.y, to or self.parent.height - self.height, time )
else
throw( IncorrectParameterException( "invalid side '" .. side .. "'", 2 ) )
Exception.throw( IncorrectParameterException, "invalid side '" .. side .. "'", 2 )
end
end

Expand All @@ -104,6 +105,6 @@ function IAttributeAnimator:animateOut( side, to, time )
elseif side == "bottom" then
return animateElementInOrOut( self, "out", true, self.y, to or self.parent.height, time )
else
throw( IncorrectParameterException( "invalid side '" .. side .. "'", 2 ) )
Exception.throw( IncorrectParameterException, "invalid side '" .. side .. "'", 2 )
end
end
3 changes: 3 additions & 0 deletions src/interfaces/ISize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function ISize:setWidth( width )
self.width = width
self.canvas:setWidth( width )
self:setChanged()

for i = 1, #self.children do
self.children[i]:onParentResized()
end
Expand All @@ -32,6 +33,8 @@ function ISize:setHeight( height )
if self.height ~= height then
self.height = height
self.canvas:setHeight( height )
self:setChanged()

for i = 1, #self.children do
self.children[i]:onParentResized()
end
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 10 additions & 11 deletions src/sheets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ colour = {
black = BLACK;
}

-- @require sheets.class
-- @require sheets.timer
-- @require sheets.clipboard
-- @require sheets.lib.class
-- @require sheets.lib.timer
-- @require sheets.lib.clipboard
-- @require sheets.lib.parameters

-- @ifn SHEETS_LOWRES
-- @define GRAPHICS_DEFAULT_FONT _graphics_default_font
Expand All @@ -179,14 +180,11 @@ colour = {
-- @require sheets.graphics.ScreenCanvas
-- @require sheets.graphics.image

-- @require sheets.Thread

-- @require sheets.exceptions.Exception
-- @require sheets.exceptions.IncorrectParameterException
-- @require sheets.exceptions.IncorrectConstructorException
-- @require sheets.exceptions.ResourceLoadException
-- @require sheets.exceptions.ThreadRuntimeException
-- @require sheets.parameters

-- @require sheets.interfaces.IAnimation
-- @require sheets.interfaces.IAttributeAnimator
Expand All @@ -200,11 +198,12 @@ colour = {
-- @require sheets.events.MouseEvent
-- @require sheets.events.TextEvent

-- @require sheets.Animation
-- @require sheets.Application
-- @require sheets.Screen
-- @require sheets.Sheet
-- @require sheets.Style
-- @require sheets.core.Animation
-- @require sheets.core.Application
-- @require sheets.core.Screen
-- @require sheets.core.Sheet
-- @require sheets.core.Style
-- @require sheets.core.Thread

-- @if SHEETS_BUTTON
-- @require sheets.elements.Button
Expand Down

0 comments on commit 3b1c607

Please sign in to comment.