diff --git a/editor/gfxedit.fnl b/editor/gfxedit.fnl index 3febe48..c8d7428 100644 --- a/editor/gfxedit.fnl +++ b/editor/gfxedit.fnl @@ -13,7 +13,10 @@ (GraphicsEditView.super.new self) (set self.tilecache (tiledraw.TileCache (tiles.loadgfx (self:filename)) (self:spritegen))) (set self.itile 1) + (set self.scrollheight math.huge) + (set self.scrollable true) (attach-imstate self)) +(fn GraphicsEditView.get_scrollable_size [self] self.scrollheight) (fn GraphicsEditView.spritegen [self] tiledraw.tile-to-sprite) (fn GraphicsEditView.tilesize [self] (values 16 16)) (fn GraphicsEditView.tilebytelen [self] (let [(w h) (self:tilesize)] (/ (* w h) 8))) diff --git a/editor/mapedit.fnl b/editor/mapedit.fnl index 77c98d0..1b48680 100644 --- a/editor/mapedit.fnl +++ b/editor/mapedit.fnl @@ -170,9 +170,10 @@ (tset :map (self.level.map:tohex))))) (fn MapEditView.draw [self] - (var x (+ self.position.x 10)) - (var y (+ self.position.y 10)) + (var x (+ self.position.x style.padding.x (- self.scroll.x))) + (var y (+ self.position.y style.padding.y (- self.scroll.y))) (self:draw_background style.background) + (self:draw_scrollbar) (love.graphics.setColor 1 1 1 1) (self:draw-map-editor x y) (when self.iobject @@ -194,7 +195,8 @@ (set self.playerpos player)) (set y (+ y 30))) (set y (+ y 30)) - (self:draw-tile-selector x y (- self.size.x 20))) + (set y (+ y (self:draw-tile-selector x y (- self.size.x 20)))) + (set self.scrollheight (- y (+ self.position.y style.padding.y (- self.scroll.y))))) (fn MapEditView.get_name [self] (.. "Map: " self.mapfilename)) diff --git a/editor/tileedit.fnl b/editor/tileedit.fnl index b6cc4cd..14f4303 100644 --- a/editor/tileedit.fnl +++ b/editor/tileedit.fnl @@ -89,13 +89,16 @@ (fn TileView.draw [self] (self:draw_background style.background) - (local (x y) (values (+ self.position.x 10) (+ self.position.y 10))) + (self:draw_scrollbar) + (local (x y) (values (+ self.position.x style.padding.x (- self.scroll.x)) + (+ self.position.y style.padding.y (- self.scroll.y)))) (local (editor-w editor-h) (self:draw-tile-editor (self:tile) x y)) (self:draw-tile-flags (+ x editor-w pixel-size) y) (var selector-y (+ y editor-h pixel-size)) (each [_ key (ipairs (self:tilekeys))] (local selector-h (self:draw-tile-selector x selector-y (- self.size.x 20) key)) - (set selector-y (+ selector-y selector-h pixel-size)))) + (set selector-y (+ selector-y selector-h pixel-size))) + (set self.scrollheight (- selector-y y))) (fn TileView.get_name [self] "Tile Editor")