FrameRateScrollbar < HorizontalScrollBar
  step: 1
  @onValueChange: Options.setOption(self:getId(), self:getValue())
  @onSetup: |
    UIScrollBar.onSetup(self)
    local value = Options.getOption(self:getId())
    if value == 0 then value = self:getMaximum() end
    self:setValue(value)

Panel
  Label
    !text: tr('Graphics Engine:')
    anchors.left: parent.left
    anchors.top: parent.top

  ButtonBox
    id: opengl1
    anchors.left: prev.right
    anchors.verticalCenter: prev.verticalCenter
    text: OpenGL 1
    size: 80 20
    margin-left: 6

  ButtonBox
    id: opengl2
    anchors.left: prev.right
    anchors.verticalCenter: prev.verticalCenter
    text: OpenGL 2
    size: 80 20
    margin-left: 4

  OptionCheckBox
    id: vsync
    !text: tr('Enable vertical synchronization')
    !tooltip: tr('Limits FPS to 60')

  OptionCheckBox
    id: showfps
    !text: tr('Show frame rate')

  OptionCheckBox
    id: fullscreen
    !text: tr('Fullscreen')

  Label
    id: backgroundFrameRateLabel
    !text: tr('Game framerate limit: %s', 'max')
    anchors.left: parent.left
    anchors.right: parent.right
    anchors.top: prev.bottom
    margin-top: 6
    @onSetup: |
      local value = Options.getOption('backgroundFrameRate')
      local text = value
      if value <= 0 or value >= 201 then
        text = 'max'
      end

      self:setText(tr('Game framerate limit: %s', text))

  FrameRateScrollbar
    id: backgroundFrameRate
    anchors.left: parent.left
    anchors.right: parent.right
    anchors.top: prev.bottom
    margin-top: 3
    minimum: 10
    maximum: 201

  Label
    id: foregroundFrameRateLabel
    anchors.left: parent.left
    anchors.right: parent.right
    anchors.top: prev.bottom
    margin-top: 6
    @onSetup: |
      local value = Options.getOption('foregroundFrameRate')
      local text = value
      if value <= 0 or value >= 61 then
        text = 'max'
      end

      self:setText(tr('Interface framerate limit: %s', text))

  FrameRateScrollbar
    id: foregroundFrameRate
    anchors.left: parent.left
    anchors.right: parent.right
    anchors.top: prev.bottom
    margin-top: 3
    minimum: 1
    maximum: 61