librelist archives

« back to archive

Works in red, not in purple

Works in red, not in purple

From:
David Eastman
Date:
2012-05-15 @ 16:12
Ash,

This is just a simple app to display the use of content within a text
element:

Being ablt to manipulate the content dynamically is pretty useful, though
isn't a rock solid feature.

---------

class Myline

  attr_accessor :line

  def alterLeft w
    @line.contents[0].replace(w)
    info "alterLeft with #{w} makes #{@line}"
  end

  def alterRight w
    @line.contents[1].replace w
    info "alterRight with #{w} makes #{@line}"
  end
end

Shoes.app(:title => "The Owner", :width => 1024, :height => 600) do

  poop =  window(:title => "Welcome to Project-X", :width => 512, :height
=> 250)  do
    @myline = Myline.new
    @p = nil
    background black
    stack do

      flow {
        caption "You are in control of the small vessel,
project-x.\nWhatever you are looking for, it isn't in this solar system.",
:stroke => white, :align => "center"
      }
      flow {
        para "You start docked in an old space station.", :stroke => white,
:align => "center"
      }
      flow {
        para "- The first command to try is probably 'launch'\n", :stroke
=> azure
        para "- Try 'summarize' and 'help' to find out more commands\n",
:stroke => azure
        para "- Type space or tab to complete any command\n", :stroke =>
azure
        @p = para strong("para1"),"weak", :stroke => azure
      }
      #@p1.contents[1].replace("strong")
      flow{
        #@p1.contents[1].replace("strong")
        button("Right", :right => 10) do
          #info "push"
          @p.contents[1].replace "strong"
          @p.contents[0].replace "mega"
        end
        button("Left",:right => 100) do
          #info "push"
          @p.contents[0].replace "mega"
        end
      }
    end
  end
end

Re: [shoes] Works in red, not in purple

From:
ashbb
Date:
2012-05-16 @ 12:51
Hi David,

Thank you for pointing out the problem of Purple Shoes. :)

Try out the latest Purple Shoes 0.7.166.
I've tried to implement TextBlock#contents.

Now it works as same as Red Shoes.

But,... there are two problems both in Red and Purple.
Try out the following snippet:

Shoes.app do
  t = tagline strong(em 'aaa'), ' ', 'bbb'
  button 'change a' do
    t.contents[0].replace 'aaaaaa'
  end
    button 'change b' do
    t.contents[2].replace 'BBBBB'
  end
end

Issue#1 :
Click 'change a' button. Nested effects are gone. No Italic style now.

Issue#2 :
At first click 'change b' button. Nothing will happen.
Then click 'change a' button. Both 'aaa' and 'bbb' will change at once.

I know the reason. Because the 'bbb' is just a Ruby String Class object,
not a specific Shoes object. It has no parent pointer. So, Shoes can't know
when the parent object, i.e. the TextBlock object, was changed...

There is a solution for issue#2 in only Purple Shoes.
Use fg('bbb', black) instead of 'bbb'.
An ugly workaround, though... :-P

ashbb

Re: [shoes] Works in red, not in purple

From:
David Eastman
Date:
2012-05-16 @ 21:25
Wow, purple shoes is pretty easy to use now with the gems and stuff!

Excellent!

I agree that TextBlock was odd in red shoes, I just managed to abuse it
when needed.



On Wed, May 16, 2012 at 1:51 PM, ashbb <ashbbb@gmail.com> wrote:

> Hi David,
>
> Thank you for pointing out the problem of Purple Shoes. :)
>
> Try out the latest Purple Shoes 0.7.166.
> I've tried to implement TextBlock#contents.
>
> Now it works as same as Red Shoes.
>
> But,... there are two problems both in Red and Purple.
> Try out the following snippet:
>
> Shoes.app do
>   t = tagline strong(em 'aaa'), ' ', 'bbb'
>   button 'change a' do
>     t.contents[0].replace 'aaaaaa'
>   end
>     button 'change b' do
>     t.contents[2].replace 'BBBBB'
>   end
> end
>
> Issue#1 :
> Click 'change a' button. Nested effects are gone. No Italic style now.
>
> Issue#2 :
> At first click 'change b' button. Nothing will happen.
> Then click 'change a' button. Both 'aaa' and 'bbb' will change at once.
>
> I know the reason. Because the 'bbb' is just a Ruby String Class object,
> not a specific Shoes object. It has no parent pointer. So, Shoes can't know
> when the parent object, i.e. the TextBlock object, was changed...
>
> There is a solution for issue#2 in only Purple Shoes.
> Use fg('bbb', black) instead of 'bbb'.
> An ugly workaround, though... :-P
>
> ashbb
>
>