Skip to content

Commit

Permalink
Added a slide guide to show the size of the actual slide in the prese…
Browse files Browse the repository at this point in the history
…ntation editor.

The slide guide scales with the user's browser window to give an accurate depiction
of the look of the slide in the real system.

Fixes #6
  • Loading branch information
tantaman committed Jun 20, 2012
1 parent b056ed1 commit 57b0426
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 14 deletions.
28 changes: 24 additions & 4 deletions client/src/ui/editor/OperatingTable.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ define(["vendor/backbone",
# re-render ourselves
@render(prevModel)

resized: () ->
slideSize = window.slideConfig.size
tableSize = width: @$el.width(), height: @$el.height()

xScale = (tableSize.width) / slideSize.width
yScale = (tableSize.height - 20) / slideSize.height

newHeight = slideSize.height * xScale
if newHeight > tableSize.height
scale = yScale
else
scale = xScale

@$slideContainer.css(window.browserPrefix + "transform", "scale(" + scale + ")")


clicked: (e) ->
if @model?
@model.get("components").forEach((component) ->
Expand Down Expand Up @@ -75,18 +91,22 @@ define(["vendor/backbone",

_componentAdded: (model, component) ->
view = ComponentViewFactory.createView(component)
@$el.append(view.render())
@$slideContainer.append(view.render())

render: (prevModel) ->
if prevModel?
prevModel.trigger("unrender", true)
#@$el.html("")
#@$el.html(Templates.OperatingTable(@model))

@$el.html("<div class='slideContainer'></div>")
@$slideContainer = @$el.find(".slideContainer")
@$slideContainer.css(width: window.slideConfig.size.width, height: window.slideConfig.size.height)
@resized()

if @model?
components = @model.get("components")
components.forEach((component) =>
view = ComponentViewFactory.createView(component)
@$el.append(view.render())
@$slideContainer.append(view.render())
)
@$el
)
Expand Down
2 changes: 2 additions & 0 deletions client/src/ui/editor/SlideEditor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ define(["vendor/backbone", "./Templates",

@$operatingTable.css(
height: window.innerHeight - 80
width: window.innerWidth - 150
)
@operatingTable.resized()
#window.slideConfig.size.height
#window.slideConfig.size.width

Expand Down
8 changes: 6 additions & 2 deletions client/src/ui/editor/components/ComponentView.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ define(["vendor/backbone",
mousedown: (e) ->
@model.set("selected", true)
@$el.css("zIndex", zTracker.next())
@dragScale = @$el.parent().css(window.browserPrefix + "transform")
@dragScale = parseFloat(@dragScale.substring(7, @dragScale.indexOf(","))) or 1
console.log @dragScale
@_dragging = true
@_prevPos = {
x: e.pageX
Expand Down Expand Up @@ -209,8 +212,9 @@ define(["vendor/backbone",
y = @model.get("y")
dx = e.pageX - @_prevPos.x
dy = e.pageY - @_prevPos.y
newX = x + dx
newY = y + dy
newX = x + dx / @dragScale
newY = y + dy / @dragScale

@model.set("x", newX)
@model.set("y", newY)
@$el.css({
Expand Down
2 changes: 1 addition & 1 deletion client/src/ui/editor/res/templates/Editor.bars
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="navbar navbar-fixed-top menuBar">
<div class="btn-inverse temp">
<div class="container">
<a class="brand" href="#">Strut 0.1</a>
<a class="brand" href="#">Strut 0.2</a>
<ul class="nav">
<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Expand Down
28 changes: 26 additions & 2 deletions client/web/scripts/ui/editor/OperatingTable.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions client/web/scripts/ui/editor/SlideEditor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/web/scripts/ui/editor/Templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions client/web/scripts/ui/editor/components/ComponentView.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions client/web/scripts/ui/editor/res/css/SlideEditor.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@
margin-top: 10px;
}

.slideEditor .slideContainer {
border: 1px solid rgba(0, 0, 0, 0.2);
transform-origin: 0 0;
-webkit-transform-origin: 0 0;
-moz-transform-origin: 0 0;
margin: 10px auto;
overflow: hidden;
-webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
}

.lato { font-family:'Lato', sans-serif; }
.ubuntu { font-family:'Ubuntu', sans-serif; }
.abril { font-family:'Abril Fatface', cursive; }
Expand Down

3 comments on commit 57b0426

@jancborchardt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m a bit torn on this one. Isn’t the magic of Impress.js that you are not really bound to a »slide«?

-snip-
I guess I’m just not happy with the way the slide is not really differentiated from the non-workspace. See Pull #14

@tantaman
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, you don't need a fixed slide size but impress.js still has some notion of size. If you make a slide (without any size) and fill it with a whole bunch of large elements, impress.js will cut elements out that don't fit into its viewport. I'm not sure how imress.js determines its viewport size though.

@tantaman
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I find myself with some extra time I'll experiment with removing the fixed slide sizes.

Please sign in to comment.