Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial lessons architecture

  • Loading branch information...
commit 9590fa900c414b590e0172adbc0959b51f13e9e0 1 parent 59758ae
Fela Winkelmolen fela authored
1  app/boot.rb
View
@@ -8,6 +8,7 @@ module ::HH end
require 'lib/all'
require 'app/web/all'
require 'app/syntax/markup'
+require 'app/lessons/lessons'
require 'app/db/sequel'
23 app/lessons/lessons.rb
View
@@ -0,0 +1,23 @@
+require 'thread'
+
+class HH::LessonSet
+ # returns only when close gets called
+ def execute_in container
+ original_thread = Thread.current
+ Thread.new do
+ container.app do
+ container.clear do
+ background gray(0.1)
+ para "lesson n. 1", :stroke => white
+ button "close" do
+ original_thread.wakeup
+ end
+ end
+ end
+ end
+ sleep
+ end
+ def on_close &blk
+ @on_close << blk
+ end
+end
4 app/ui/editor/editor.rb
View
@@ -125,13 +125,13 @@ def editor(script = {})
InsertionDeletionCommand.on_insert_text {|pos, str| insert_text(pos, str)}
InsertionDeletionCommand.on_delete_text {|pos, len| delete_text(pos, len)}
@editor =
- stack :margin_left => 50, :margin_top => 22, :width => 1.0, :height => 92 do
+ stack :margin_left => 10, :margin_top => 22, :width => 1.0, :height => 92 do
@sname = subtitle name, :font => "Lacuna Regular", :size => 22,
:margin => 0, :wrap => "trim"
@stale = para(script[:mtime] ? "Last saved #{script[:mtime].since} ago." :
"Not yet saved.", :margin => 0, :stroke => "#39C")
end
- stack :margin_left => 38, :width => 1.0, :height => -92 do
+ stack :margin_left => 0, :width => 1.0, :height => -92 do
background white(0.4), :width => 38
@scroll =
flow :width => 1.0, :height => 1.0, :margin => 2, :scroll => true do
41 app/ui/mainwindow.rb
View
@@ -2,7 +2,9 @@
require 'app/ui/tabs/home'
-window :title => "Hackety Hack", :width => 575, :height => 700 do
+#Thread.abort_on_exception = true
+
+window :title => "Hackety Hack", :width => 1000, :height => 700 do
HH::APP = self
extend HH::Widgets, HH::Home
style(Shoes::LinkHover, :fill => nil, :stroke => "#C66")
@@ -11,11 +13,6 @@
background "#e9efe0"
background "#e9efe0".."#c1c5d0", :height => 150, :bottom => 150
- @action =
- stack :top => 0, :left => 0, :width => 1.0, :height => 1.0 do
- home
- end
-
# auxiliary method to load the editor
def load_editor name = {}
# the editor methods are included the first time
@@ -26,7 +23,27 @@ def load_editor name = {}
@action.clear { editor(name) }
end
- stack :top => 0, :left => 0, :width => 40, :height => 1.0 do
+ # returns only once the lesson gets closed
+ def start_lessons # lessons_name
+ Thread.new do
+ @action.style(:width => -500)
+ @lesson.show
+ HH::LessonSet.new.execute_in @lesson
+ # after the lesson ends
+ @lesson.hide
+ @action.style(:width => 1.0)
+ end
+ end
+
+ @action = stack :margin_left => 38, :height => 1.0 do
+ home
+ end
+
+ @lesson = stack :hidden => true, :width => 500
+
+ # declared after the main content because that way hover text
+ # gets displayed on top
+ stack :top => 0, :left => 0, :width => 38, :height => 1.0 do
@tip = stack :top => 0, :left => 0, :width => 120, :margin => 4, :hidden => true do
background "#F7A", :curve => 6
para "HOME", :margin => 3, :margin_left => 40, :stroke => white
@@ -53,15 +70,18 @@ def load_editor name = {}
end
@action.clear { console }
end
- sidetab "#{HH::STATIC}/tab-help.png", 96, "HELP" do
+ sidetab "#{HH::STATIC}/tab-tour.png", 96, "LEARN" do
+ start_lessons
+ end
+ sidetab "#{HH::STATIC}/tab-help.png", 128, "HELP" do
Shoes.show_manual
end
- sidetab "#{HH::STATIC}/tab-cheat.png", 128, "CHEAT" do
+ sidetab "#{HH::STATIC}/tab-cheat.png", 160, "CHEAT" do
dialog :title => "Hackety Hack - Cheat Sheet", :width => 496 do
image "#{HH::STATIC}/hhcheat.png"
end
end
- sidetab "#{HH::STATIC}/tab-hand.png", 160, "ABOUT" do
+ sidetab "#{HH::STATIC}/tab-hand.png", 192, "ABOUT" do
about =
app.slot.stack :top => 0, :left => 0, :width => 1.0, :height => 1.0 do
background black(0.8)
@@ -85,6 +105,7 @@ def load_editor name = {}
end
end
+
@notice =
stack :bottom => 33, :left => 22, :width => 160, :height => 54, :hidden => true do
fill black(0.6)
22 app/ui/tabs/home.rb
View
@@ -2,25 +2,7 @@
# partly unfinished: some features have just started being implemented
module HH::Home
- # method to create a side tab (actually is just a stack with an image in it)
- # +icon_path+:: the icon displayed in the tab
- # +top+:: if > 0 indicates the distance from the top, else the distance from
- # the bottom
- # +name+:: text displayed on icon hover
- # +blk+:: the block passed is executed on click
- def sidetab(icon_path, top, name, &blk)
- v = top < 0 ? :bottom : :top
- stack v => top.abs, :left => 0, :width => 38, :margin => 4 do
- bg = background "#DFA", :height => 26, :curve => 6, :hidden => true
- image(icon_path, :margin => 4).
- hover { bg.show; @tip.parent.width = 122; @tip.top = nil; @tip.bottom = nil
- @tip.send("#{v}=", top.abs); @tip.contents[1].text = name; @tip.show }.
- leave { bg.hide; @tip.hide; @tip.parent.width = 40 }.
- click &blk
- end
- end
-
- # unfinished method that asks if the user wants to upgrade
+# unfinished method that asks if the user wants to upgrade
# def home_bulletin
# stack do
# background "#FF9".."#FFF"
@@ -129,7 +111,7 @@ def home
image "#{HH::STATIC}/hhhello.png", :bottom => -120, :right => 0
@tabs, @scripts, @tables = [], HH.scripts, HH::DB.tables
- stack :margin => 0, :margin_left => 38 do
+ stack :margin => 0, :margin_left => 0 do
stack do
background "#CDC", :height => 35
background black(0.05)..black(0.2), :height => 38
18 app/ui/widgets.rb
View
@@ -176,4 +176,22 @@ def britelink icon, name, time = nil, bg = "#8c9", &blk
end
end
end
+
+ # method to create a side tab (actually is just a stack with an image in it)
+ # +icon_path+:: the icon displayed in the tab
+ # +top+:: if > 0 indicates the distance from the top, else the distance from
+ # the bottom
+ # +name+:: text displayed on icon hover
+ # +blk+:: the block passed is executed on click
+ def sidetab(icon_path, top, name, &blk)
+ v = top < 0 ? :bottom : :top
+ stack v => top.abs, :left => 0, :width => 38, :margin => 4 do
+ bg = background "#DFA", :height => 26, :curve => 6, :hidden => true
+ image(icon_path, :margin => 4).
+ hover { bg.show; @tip.parent.width = 122; @tip.top = nil; @tip.bottom = nil
+ @tip.send("#{v}=", top.abs); @tip.contents[1].text = name; @tip.show }.
+ leave { bg.hide; @tip.hide; @tip.parent.width = 40 }.
+ click &blk
+ end
+ end
end
2  h-ety-h.rb
View
@@ -2,4 +2,4 @@
# the main application executable
-load 'app/ui/mainwindow.rb'
+load 'app/ui/mainwindow.rb'
Please sign in to comment.
Something went wrong with that request. Please try again.