source-code/screens/forces-screens/buoyant_force_screen.rb
def buoyant_force_screen
    @heading = 'Buoyant force = density x acceleration of free fall x volume of liquid displaced'
    background('images/forces_large.png')

    # Buoyant force screen header
    ScreenHeader.new(self, '/title_screen/forces_screen', @@font, @heading)

    # Buoyant force screen content
    flow(:height => 640, :width => 1080, :scroll => true) do
      # Left margin offset
      stack(:height => 640, :width => 80) do
      end
      # Content column
      stack(:height => 640, :width => 1000) do
        ScreenLabel.new(self, @@font, @heading, 'Density')
        flow do
          @density = ScreenEditLine.new(self, @@font, @heading)
          @density_unit = para(strong(' kgm'), strong(sup('-3')))
          @density_unit.style(@@screen_unit_text_styles)
        end

        ScreenLabel.new(self, @@font, @heading, 'Volume of liquid displaced')
        flow do
          @volume_of_liquid_displaced = ScreenEditLine.new(self, @@font, @heading)
          @volume_of_liquid_displaced_unit = para(strong(' m'), strong(sup('3')))
          @volume_of_liquid_displaced_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.buoyant_force(@density.text.to_f,
                                           @volume_of_liquid_displaced.text.to_f)
            @buoyant_force = para(@result.to_s)
            @buoyant_force_unit = para(' N')
            @buoyant_force.style(@@screen_result_text_styles)
            @buoyant_force_unit.style(@@screen_result_text_styles)
          end
        end
      end
    end
  end
# Draws the buoyant force screen on the Shoes app window.
Draws the buoyant force screen on the Shoes app window.
Draws the buoyant force screen on the Shoes app window .
def buoyant_force_screen
    @heading = 'Buoyant force = density x acceleration of free fall x volume of liquid displaced'
    background('images/forces_large.png')
    ScreenHeader.new(self, '/title_screen/forces_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, 'Density')
        flow do
          @density = ScreenEditLine.new(self, @@font, @heading)
          @density_unit = para(strong(' kgm'), strong(sup('-3')))
          @density_unit.style(@@screen_unit_text_styles)
        end
        ScreenLabel.new(self, @@font, @heading, 'Volume of liquid displaced')
        flow do
          @volume_of_liquid_displaced = ScreenEditLine.new(self, @@font, @heading)
          @volume_of_liquid_displaced_unit = para(strong(' m'), strong(sup('3')))
          @volume_of_liquid_displaced_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.buoyant_force(@density.text.to_f,
                                           @volume_of_liquid_displaced.text.to_f)
            @buoyant_force = para(@result.to_s)
            @buoyant_force_unit = para(' N')
            @buoyant_force.style(@@screen_result_text_styles)
            @buoyant_force_unit.style(@@screen_result_text_styles)
          end
        end
      end
    end
  end
def buoyant_force_screen @heading = 'Buoyant force = density x acceleration of free fall x volume of liquid displaced' background ( 'images/forces_large.png' ) ScreenHeader . new ( self , '/title_screen/forces_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 , 'Density' ) flow do @density = ScreenEditLine . new ( self , @@font , @heading ) @density_unit = para ( strong ( ' kgm' ) , strong ( sup ( '-3' ) ) ) @density_unit . style ( @@screen_unit_text_styles ) end ScreenLabel . new ( self , @@font , @heading , 'Volume of liquid displaced' ) flow do @volume_of_liquid_displaced = ScreenEditLine . new ( self , @@font , @heading ) @volume_of_liquid_displaced_unit = para ( strong ( ' m' ) , strong ( sup ( '3' ) ) ) @volume_of_liquid_displaced_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 . buoyant_force ( @density . text . to_f , @volume_of_liquid_displaced . text . to_f ) @buoyant_force = para ( @result . to_s ) @buoyant_force_unit = para ( ' N' ) @buoyant_force . style ( @@screen_result_text_styles ) @buoyant_force_unit . style ( @@screen_result_text_styles ) end end end end end
Draws the buoyant force screen on the Shoes app window.
Draws the buoyant force screen on the Shoes app window .
# Buoyant force screen header # Buoyant force screen content # Left margin offset # Content column