source-code/screens/momentum-impulse-screens/momentum_screen.rb
# Draws the momentum screen on the Shoes app window.
Draws the momentum screen on the Shoes app window.
Draws the momentum screen on the Shoes app window .
def momentum_screen
    @heading = 'Momentum = mass x velocity'
    background('images/momentum_impulse_large.png')
    ScreenHeader.new(self, '/title_screen/momentum_impulse_screen', @@font, @heading)
    flow(:height => 640, :width => 1080, :scroll => true) do
      stack(:height => 640, :width => 80) do
      end
      stack(:height => 640, :width => 1000) do
        ScreenLabel.new(self, @@font, @heading, 'Mass')
        flow do
          @mass = ScreenEditLine.new(self, @@font, @heading)
          @mass_unit = para(strong(' kg'))
          @mass_unit.style(@@screen_unit_text_styles)
        end
        ScreenLabel.new(self, @@font, @heading, 'Velocity')
        flow do
          @velocity = ScreenEditLine.new(self, @@font, @heading)
          @velocity_unit = para(strong(' ms'), strong(sup('-1')))
          @velocity_unit.style(@@screen_unit_text_styles)
        end
        @calculate = button('Calculate')
        @result_display = flow
        @error_display = flow
        @calculate.click do
          @result_display.clear do
            @result = Joules.momentum(@mass.text.to_f,
                                      @velocity.text.to_f)
            @momentum = para(@result.to_s)
            @momentum_unit = para(' Ns')
            @momentum.style(@@screen_result_text_styles)
            @momentum_unit.style(@@screen_result_text_styles)
          end
        end
      end
    end
  end
def momentum_screen @heading = 'Momentum = mass x velocity' background ( 'images/momentum_impulse_large.png' ) ScreenHeader . new ( self , '/title_screen/momentum_impulse_screen' , @@font , @heading ) flow ( :height => 640 , :width => 1080 , :scroll => true ) do stack ( :height => 640 , :width => 80 ) do end stack ( :height => 640 , :width => 1000 ) do ScreenLabel . new ( self , @@font , @heading , 'Mass' ) flow do @mass = ScreenEditLine . new ( self , @@font , @heading ) @mass_unit = para ( strong ( ' kg' ) ) @mass_unit . style ( @@screen_unit_text_styles ) end ScreenLabel . new ( self , @@font , @heading , 'Velocity' ) flow do @velocity = ScreenEditLine . new ( self , @@font , @heading ) @velocity_unit = para ( strong ( ' ms' ) , strong ( sup ( '-1' ) ) ) @velocity_unit . style ( @@screen_unit_text_styles ) end @calculate = button ( 'Calculate' ) @result_display = flow @error_display = flow @calculate . click do @result_display . clear do @result = Joules . momentum ( @mass . text . to_f , @velocity . text . to_f ) @momentum = para ( @result . to_s ) @momentum_unit = para ( ' Ns' ) @momentum . style ( @@screen_result_text_styles ) @momentum_unit . style ( @@screen_result_text_styles ) end end end end end
Draws the momentum screen on the Shoes app window.
Draws the momentum screen on the Shoes app window .
# Momentum screen header # Momentum screen content # Left margin offset # Content column