ModraUp Ruby API Documentation Ruby API Reference

Class: ModraUp::ViewObserver

Inherits:
Object
  • Object
show all

Overview

Base class for View Observers. Subclasses implement onViewChanged and onScaleFactorChange.

Registered with ModraUp::View#add_observer, onViewChanged is called on pan/rotate/scale and viewport size changes. onScaleFactorChange is called on display DPI or UI.scale_factor(view) changes.

Examples:

class MyView < ModraUp::ViewObserver
  def onViewChanged(view)
    puts view.camera.eye
  end
  def onScaleFactorChange(view)
    puts UI.scale_factor(view)
  end
end
ModraUp.active_model.active_view.add_observer(MyView.new)

Instance Method Summary # collapse

  • #onViewChanged(view) ⇒ nil
    Called when the camera is translated, rotated, scaled, or when the viewport pixel size changes (includes dimensions since SketchUp 2019.2).
  • #onScaleFactorChange(view) ⇒ nil
    Called when the DPI of the screen containing the viewport changes, synchronizing with UI.scale_factor(view).

Instance Method Details

observer.onViewChanged(view) ⇒ nil

Called when the camera is translated, rotated, scaled, or when the viewport pixel size changes (includes dimensions since SketchUp 2019.2).

Parameters:

  • view (ModraUp::View)

Returns:

  • (nil)

Examples:

class MyView < ModraUp::ViewObserver
  def onViewChanged(view)
    view.invalidate
  end
end
ModraUp.active_model.active_view.add_observer(MyView.new)

observer.onScaleFactorChange(view) ⇒ nil

Called when the DPI of the screen containing the viewport changes, synchronizing with UI.scale_factor(view).

Parameters:

  • view (ModraUp::View)

Returns:

  • (nil)

Examples:

class MyView < ModraUp::ViewObserver
  def onScaleFactorChange(view)
    UI.scale_factor(view)
  end
end
ModraUp.active_model.active_view.add_observer(MyView.new)