Properly set player width

Conflicts:

	app/assets/javascripts/player/renderers/pre.js.coffee
openid
Marcin Kulik 13 years ago
parent 49b7c39aac
commit d57f264f17

@ -20,6 +20,11 @@ class AsciiIo.Renderer.Base extends Backbone.View
throw '#renderLine not implemented'
afterInsertedToDom: ->
sample = $('<span class="font-sample">M</span>')
@$el.parent().append(sample)
@cellWidth = sample.width()
@cellHeight = sample.height()
sample.remove()
showCursor: (show) ->
throw '#showCursor not implemented'

@ -12,14 +12,17 @@ class AsciiIo.Renderer.Canvas extends AsciiIo.Renderer.Base
@cursorVisible = true
afterInsertedToDom: ->
sample = $('<span class="font-sample">M</span>')
@$el.parent().append(sample)
@cellWidth = sample.width()
@cellHeight = sample.height()
sample.remove()
@$el.attr('width', @cols * @cellWidth)
@$el.attr('height', @lines * @cellHeight)
super()
@fixSize()
fixSize: ->
width = @cols * @cellWidth
height = @lines * @cellHeight
@$el.attr('width', width)
@$el.attr('height', height)
@$el.parent('.player').css(width: width + 'px')
@setFont()

@ -19,23 +19,13 @@ class AsciiIo.Renderer.Pre extends AsciiIo.Renderer.Base
afterInsertedToDom: ->
super()
@initialRender()
@fixSize()
initialRender: ->
brush = AsciiIo.Brush.normal()
changes = {}
i = 0
while i < @lines
changes[i] = [[' '.times(@cols), brush]]
i += 1
@render(changes, 0, 0)
fixSize: ->
width = @$el.width()
height = @$el.height()
width = @cols * @cellWidth
height = @lines * @cellHeight
@$el.parent('.player').css(width: width + 'px')
@$el.css(width: width + 'px', height: height + 'px')
render: (changes, cursorX, cursorY) ->

Loading…
Cancel
Save