Skip to content

Commit

Permalink
- Initial attempt at displaying bars/meters for activity instead of just
Browse files Browse the repository at this point in the history
  blobs. Try adding something like 'activity_type: bars' to a block 
  definition in your config.
  • Loading branch information
erlends committed Oct 29, 2007
1 parent b6ecc45 commit ad546b5
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 34 deletions.
18 changes: 9 additions & 9 deletions lib/gl_tail/activity.rb
Expand Up @@ -11,14 +11,14 @@ class Activity
def initialize(message, x, y, z, color, size, type = 0)
@message = message
@x, @y, @z = x, y, z
@xi, @yi, @zi = 0.012 + (rand(100)/100.0 ) * 0.0012 , 0.002 + (rand(1000)/1000.0 ) * 0.002, 0
# @xi, @yi, @zi = 0.015 , 0.0025, 0
# @xi, @yi, @zi = 0.012 + (rand(100)/100.0 ) * 0.0012 , 0.002 + (rand(1000)/1000.0 ) * 0.002, 0
@xi, @yi, @zi = 0.006 , 0.0013, 0

if @x >= 0.0
@xi = -@xi
end

@xi = (rand(100)/100.0 * 0.02) - 0.01 if type == 2
@xi = (rand(100)/100.0 * 0.002) - 0.001 if type == 2

@color = color
@size = size
Expand All @@ -30,14 +30,14 @@ def initialize(message, x, y, z, color, size, type = 0)
def render(engine)
if @type != 5
if engine.screen.wanted_fps == 0
@x += @xi/2
@y += @yi/2
@yi = @yi - 0.0005/2
@x += @xi
@y += @yi
@yi = @yi - 0.00008
else
@fps_mod ||= (60.0 / engine.screen.wanted_fps)
@x += (@xi/2) * @fps_mod
@y += (@yi/2) * @fps_mod
@yi = @yi - (0.0005/2) * @fps_mod
@x += @xi * @fps_mod
@y += @yi * @fps_mod
@yi = @yi - 0.00008 * @fps_mod
end

# @yi = @yi * 1.01
Expand Down
12 changes: 8 additions & 4 deletions lib/gl_tail/block.rb
Expand Up @@ -12,26 +12,29 @@ class Block
config_attribute :color, "FIXME: add description", :type => :color
config_attribute :order, "FIXME"
config_attribute :size, "FIXME"
config_attribute :auto_clean
config_attribute :auto_clean, "FIXME"
config_attribute :activity_type, "FIXME"

attr_accessor :column
attr_reader :config

attr_reader :config
attr_reader :max_rate

def initialize(config, name)
@config = config
@name = name

@size = 10
@auto_clean = true
@activity_type = "blobs"
@order = 100
# @color = [1.0, 1.0, 1.0, 1.0]

@show = 0

@header = Element.new(self, @name.upcase, [1.0, 1.0, 1.0, 1.0])

@elements = { }
@bottom_position = -@config.screen.top
@max_rate = 1.0/599
end

def show=(value)
Expand Down Expand Up @@ -92,6 +95,7 @@ def render(engine, num)
@elements.delete(e.name)
end
num += 1
@max_rate = e.rate if e.rate > @max_rate
end

(@elements.values - sorted).each do |e|
Expand Down
120 changes: 99 additions & 21 deletions lib/gl_tail/element.rb
Expand Up @@ -11,6 +11,10 @@ class Element
def initialize(block, name, color, start_position = nil)
@block = block

if name.nil?
name = ''
end

if name =~ /^\d+.\d+.\d+.\d+$/
@name = Resolver.resolv(name, self)
else
Expand All @@ -31,6 +35,7 @@ def initialize(block, name, color, start_position = nil)
@step = 0, @updates = 0
@active = false
@color = color
@type = (@block.activity_type == "blobs" ? :blobs : :bars)
end

def add_activity(message, color, size, type)
Expand Down Expand Up @@ -157,31 +162,104 @@ def render(engine, options = { })

glPopMatrix()

t = glutGet(GLUT_ELAPSED_TIME)
while( (@queue.size > 0) && (@last_time < t ) )

@last_time += @step
item = @queue.pop
url = item.message
color = item.color
size = item.size
type = item.type

if type == 2
@activities.push Activity.new(url, 0.0 - (0.008 * url.length), engine.screen.top, 0.0, color, size, type)
elsif type == 5
a = Activity.new(url, 0.0, engine.screen.top, 0.0, color, size, type)
a.wx = @wx
a.wy = @wy + 0.05
@activities.push a
elsif type != 4
if @type == :bars
t = glutGet(GLUT_ELAPSED_TIME)
while( (@queue.size > 0) && (@last_time < t ) )
@last_time += @step
item = @queue.pop
url = item.message
color = item.color
size = item.size
type = item.type
if type == 2
@activities.push Activity.new(url, 0.0 - (0.008 * url.length), engine.screen.top, 0.0, color, size, type)
end
end

if( rate > 0.0 )
glBegin(GL_QUADS)

if @x >= 0
@activities.push Activity.new(url, (@block.alignment - (@block.width+8)*8.0 / (engine.screen.window_width / 2.0)), @y + engine.screen.line_size/2, @z, color, size, type)
x1 = 0.0
y1 = @y
@x2 = (@block.alignment - (@block.width+8)*8.0 / (engine.screen.window_width / 2.0))
y2 = @y + engine.screen.line_size * 0.9
x1 = @x2 - (@x2) * (rate / @block.max_rate)

@x1 ||= @x2
d = (@x1 - x1)
if d.abs < 0.001
@x1 = x1
else
@x1 -= d / 20
end
glColor([0.0, 0.0, 0.0, 0.0])
glVertex3f(@x1, y1, @z)
glColor(@color)
glVertex3f(@x2, y1, @z)
glColor(@color)
glVertex3f(@x2, y2, @z)
glColor(@color)
glVertex3f(@x1, y2, @z)

else
@activities.push Activity.new(url, (@block.alignment + (@block.width+8)*8.0 / (engine.screen.window_width / 2.0) ), @y + engine.screen.line_size/2, @z, color, size, type)
@x1 = (@block.alignment + (@block.width+8)*8.0 / (engine.screen.window_width / 2.0) )
y1 = @y
x2 = 0.0
y2 = @y + engine.screen.line_size * 0.9
x2 = @x1 - (@x1) * (rate / @block.max_rate)

@x2 ||= @x1
d = (@x2 - x2)
if d.abs < 0.001
@x2 = x2
else
@x2 -= d / 20
end

glColor(@color)
glVertex3f(@x1, y1, @z)
glColor([0.0, 0.0, 0.0, 0.0])
glVertex3f(@x2, y1, @z)
glColor(@color)
glVertex3f(@x2, y2, @z)
glColor(@color)
glVertex3f(@x1, y2, @z)

end


glEnd
end

else
t = glutGet(GLUT_ELAPSED_TIME)
while( (@queue.size > 0) && (@last_time < t ) )

@last_time += @step
item = @queue.pop
url = item.message
color = item.color
size = item.size
type = item.type

if type == 2
@activities.push Activity.new(url, 0.0 - (0.008 * url.length), engine.screen.top, 0.0, color, size, type)
elsif type == 5
a = Activity.new(url, 0.0, engine.screen.top, 0.0, color, size, type)
a.wx = @wx
a.wy = @wy + 0.05
@activities.push a
elsif type != 4
if @x >= 0
@activities.push Activity.new(url, (@block.alignment - (@block.width+8)*8.0 / (engine.screen.window_width / 2.0)), @y + engine.screen.line_size/2, @z, color, size, type)
else
@activities.push Activity.new(url, (@block.alignment + (@block.width+8)*8.0 / (engine.screen.window_width / 2.0) ), @y + engine.screen.line_size/2, @z, color, size, type)
end
end
end
end
end

@activities.each do |a|
if a.x > 1.0 || a.x < -1.0 || a.y < -(engine.screen.aspect*1.5)
Expand Down

0 comments on commit ad546b5

Please sign in to comment.