Exemplo n.º 1
0
void
Layout::Initialize(PixelSize new_size)
{
  const unsigned width = new_size.cx, height = new_size.cy;

  landscape = width > height;
  const bool square = width == height;

  if (!ScaleSupported())
    return;

  const unsigned x_dpi = Display::GetXDPI();

  unsigned minsize = std::min(width, height);
  // always start w/ shortest dimension
  // square should be shrunk
  scale_1024 = std::max(1024U, minsize * 1024 / (square ? 320 : 240));
  scale = scale_1024 / 1024;

  small_scale = (scale_1024 - 1024) / 2 + 1024;

  pen_width_scale = std::max(1024u, x_dpi * 1024u / 80u);

  text_padding = Scale(2);

  minimum_control_height = Scale(20);

  if (HasTouchScreen()) {
    /* larger rows for touch screens */
    maximum_control_height = Display::GetYDPI() * 3 / 7;
    if (maximum_control_height < minimum_control_height)
      maximum_control_height = minimum_control_height;
  } else {
    maximum_control_height = minimum_control_height;
  }

  hit_radius = x_dpi / (HasTouchScreen() ? 3 : 12);
}
Exemplo n.º 2
0
ScreenGlobalInit::ScreenGlobalInit()
{
  Uint32 flags = SDL_INIT_VIDEO;
  if (!IsKobo())
    flags |= SDL_INIT_AUDIO;

  if (::SDL_Init(flags) != 0) {
    fprintf(stderr, "SDL_Init() has failed: %s\n", ::SDL_GetError());
    exit(EXIT_FAILURE);
  }

#if defined(HAVE_GLES) && SDL_MAJOR_VERSION >= 2
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
#ifdef HAVE_GLES2
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
  SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
#endif
#endif

#if SDL_MAJOR_VERSION >= 2
  // Keep screen on (works on iOS, and maybe for other platforms)
  SDL_SetHint(SDL_HINT_IDLE_TIMER_DISABLED, "1");
#endif

  if (HasTouchScreen())
    SDL_ShowCursor (SDL_FALSE);

#if SDL_MAJOR_VERSION < 2
  ::SDL_EnableKeyRepeat(250, 50);
  ::SDL_EnableUNICODE(true);
#endif

#if defined(ENABLE_OPENGL)
  ::SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  ::SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);

  OpenGL::Initialise();
#endif

  Font::Initialise();

  event_queue = new EventQueue();

  ScreenInitialized();
}
Exemplo n.º 3
0
ScreenGlobalInit::ScreenGlobalInit()
{
  Uint32 flags = SDL_INIT_VIDEO;
  if (!IsKobo())
    flags |= SDL_INIT_AUDIO;

  if (::SDL_Init(flags) != 0) {
    fprintf(stderr, "SDL_Init() has failed: %s\n", ::SDL_GetError());
    exit(EXIT_FAILURE);
  }

  if (HasTouchScreen())
    SDL_ShowCursor (SDL_FALSE);

#if SDL_MAJOR_VERSION < 2
  ::SDL_EnableKeyRepeat(250, 50);
  ::SDL_EnableUNICODE(true);
#endif

#if defined(ENABLE_OPENGL)
  ::SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  ::SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);

  OpenGL::Initialise();
#endif

#ifdef USE_FREETYPE
  FreeType::Initialise();
#endif

  Font::Initialise();

  event_queue = new EventQueue();

  ScreenInitialized();
}