The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CVideo Class Reference

#include <video.hpp>

Classes

struct  error
 
class  quit
 
class  video_event_handler
 

Public Types

enum  FAKE_TYPES { NO_FAKE, FAKE, FAKE_TEST }
 
enum  MODE_EVENT { TO_RES, TO_FULLSCREEN, TO_WINDOWED, TO_MAXIMIZED_WINDOW }
 

Public Member Functions

 CVideo (const CVideo &)=delete
 
CVideooperator= (const CVideo &)=delete
 
 CVideo (FAKE_TYPES type=NO_FAKE)
 
 ~CVideo ()
 
bool non_interactive () const
 
void init_window ()
 Initializes a new window, taking into account any preiously saved states. More...
 
void setMode (int x, int y, const MODE_EVENT mode)
 
void set_fullscreen (bool ison)
 
void set_resolution (const std::pair< int, int > &res)
 
void set_resolution (const unsigned width, const unsigned height)
 Set the resolution. More...
 
std::pair< int, int > current_resolution ()
 
int current_refresh_rate () const
 
int getx () const
 
int gety () const
 
std::pair< float, float > get_dpi_scale_factor () const
 
void blit_surface (int x, int y, surface surf, SDL_Rect *srcrect=nullptr, SDL_Rect *clip_rect=nullptr)
 
void flip ()
 
surfacegetSurface ()
 
bool isFullScreen () const
 
void make_fake ()
 
void make_test_fake (const unsigned width=1024, const unsigned height=768, const unsigned bpp=DefaultBpp)
 Creates a fake frame buffer for the unit tests. More...
 
bool faked () const
 
int set_help_string (const std::string &str)
 
void clear_help_string (int handle)
 
void clear_all_help_strings ()
 
void lock_updates (bool value)
 
bool update_locked () const
 
void update_framebuffer ()
 
void set_window_title (const std::string &title)
 Sets the title of the main window. More...
 
void set_window_icon (surface &icon)
 Sets the icon of the main window. More...
 
void clear_screen ()
 Clear the screen contents. More...
 
sdl::windowget_window ()
 
std::vector< std::pair< int,
int > > 
get_available_resolutions (const bool include_current=false)
 Returns the list of available screen resolutions. More...
 
void lock_flips (bool)
 

Static Public Member Functions

static CVideoget_singleton ()
 
static void delay (unsigned int milliseconds)
 

Static Public Attributes

static const int DefaultBpp = 32
 

Private Member Functions

void initSDL ()
 

Private Attributes

std::unique_ptr< sdl::windowwindow
 
bool fake_screen_
 
video_event_handler event_handler_
 
int help_string_
 
int updatesLocked_
 
int flip_locked_
 
int refresh_rate_
 

Static Private Attributes

static CVideosingleton_ = nullptr
 

Detailed Description

Definition at line 29 of file video.hpp.

Member Enumeration Documentation

Enumerator
NO_FAKE 
FAKE 
FAKE_TEST 

Definition at line 34 of file video.hpp.

Enumerator
TO_RES 
TO_FULLSCREEN 
TO_WINDOWED 
TO_MAXIMIZED_WINDOW 

Definition at line 40 of file video.hpp.

Constructor & Destructor Documentation

CVideo::CVideo ( const CVideo )
delete
CVideo::CVideo ( FAKE_TYPES  type = NO_FAKE)

Definition at line 81 of file video.cpp.

References FAKE, FAKE_TEST, initSDL(), make_fake(), make_test_fake(), NO_FAKE, and singleton_.

CVideo::~CVideo ( )

Definition at line 116 of file video.cpp.

References LOG_DP, sdl_get_version(), and singleton_.

Member Function Documentation

void CVideo::blit_surface ( int  x,
int  y,
surface  surf,
SDL_Rect *  srcrect = nullptr,
SDL_Rect *  clip_rect = nullptr 
)
void CVideo::clear_all_help_strings ( )

Definition at line 509 of file video.cpp.

References clear_help_string(), and help_string_.

void CVideo::clear_help_string ( int  handle)
void CVideo::clear_screen ( )

Clear the screen contents.

Definition at line 358 of file video.cpp.

References window.

Referenced by editor::editor_display::editor_display(), and game_display::game_display().

int CVideo::current_refresh_rate ( ) const
inline

Definition at line 76 of file video.hpp.

References refresh_rate_.

Referenced by display::draw_wrap().

std::pair< int, int > CVideo::current_resolution ( )
void CVideo::delay ( unsigned int  milliseconds)
static
bool CVideo::faked ( ) const
inline
void CVideo::flip ( )

Definition at line 321 of file video.cpp.

References fake_screen_, flip_locked_, and window.

Referenced by gui2::event::sdl_event_handler::draw(), display::flip(), and help::show_help().

std::vector< std::pair< int, int > > CVideo::get_available_resolutions ( const bool  include_current = false)
std::pair< float, float > CVideo::get_dpi_scale_factor ( ) const

Definition at line 372 of file video.cpp.

References MAGIC_DPI_SCALE_NUMBER, and window.

Referenced by get_available_resolutions().

static CVideo& CVideo::get_singleton ( )
inlinestatic
sdl::window * CVideo::get_window ( )
surface & CVideo::getSurface ( )
int CVideo::getx ( ) const
int CVideo::gety ( ) const

Definition at line 305 of file video.cpp.

References window.

Referenced by gui::menu::max_items_onscreen(), events::raise_resize_event(), and set_help_string().

void CVideo::init_window ( )

Initializes a new window, taking into account any preiously saved states.

Creates a new window instance.

Definition at line 219 of file video.cpp.

References event_handler_, preferences::fullscreen(), h, events::sdl_handler::join_global(), preferences::maximized(), preferences::min_window_height, preferences::min_window_width, refresh_rate_, preferences::resolution(), image::set_pixel_format(), update_framebuffer(), w, and window.

Referenced by game_launcher::init_video().

void CVideo::initSDL ( )
private

Definition at line 106 of file video.cpp.

References ERR_DP, and error().

Referenced by CVideo().

bool CVideo::isFullScreen ( ) const

Definition at line 466 of file video.cpp.

References window.

Referenced by set_fullscreen().

void CVideo::lock_flips ( bool  lock)

Definition at line 564 of file video.cpp.

References flip_locked_.

Referenced by flip_locker::flip_locker(), and flip_locker::~flip_locker().

void CVideo::lock_updates ( bool  value)
void CVideo::make_fake ( )

Definition at line 179 of file video.cpp.

References fake_screen_, refresh_rate_, and image::set_pixel_format().

Referenced by CVideo(), and game_launcher::init_video().

void CVideo::make_test_fake ( const unsigned  width = 1024,
const unsigned  height = 768,
const unsigned  bpp = DefaultBpp 
)

Creates a fake frame buffer for the unit tests.

Parameters
widthThe width of the buffer.
heightThe height of the buffer.
bppThe bpp of the buffer.

Definition at line 187 of file video.cpp.

References refresh_rate_, and image::set_pixel_format().

Referenced by CVideo(), and test_utils::get_fake_display().

bool CVideo::non_interactive ( ) const

Definition at line 131 of file video.cpp.

References window.

Referenced by display::display().

CVideo& CVideo::operator= ( const CVideo )
delete
void CVideo::set_fullscreen ( bool  ison)
int CVideo::set_help_string ( const std::string &  str)
void CVideo::set_resolution ( const std::pair< int, int > &  res)

Definition at line 540 of file video.cpp.

void CVideo::set_resolution ( const unsigned  width,
const unsigned  height 
)

Set the resolution.

Parameters
widthThe new width.
heightThe new height.

Definition at line 545 of file video.cpp.

References preferences::_set_maximized(), preferences::_set_resolution(), current_resolution(), display::get_singleton(), display::redraw_everything(), setMode(), and TO_RES.

void CVideo::set_window_icon ( surface icon)

Sets the icon of the main window.

Parameters
iconThe new icon for the window.

Definition at line 352 of file video.cpp.

References window.

Referenced by game_launcher::init_video().

void CVideo::set_window_title ( const std::string &  title)

Sets the title of the main window.

Parameters
titleThe new title for the window.

Definition at line 346 of file video.cpp.

References window.

Referenced by game_launcher::change_language(), game_launcher::init_video(), editor::context_manager::set_window_title(), and editor::context_manager::~context_manager().

void CVideo::setMode ( int  x,
int  y,
const MODE_EVENT  mode 
)
void CVideo::update_framebuffer ( )

Definition at line 196 of file video.cpp.

References surface::clear_without_free(), sdl_get_version(), and window.

Referenced by init_window(), events::peek_for_resize(), and setMode().

bool CVideo::update_locked ( ) const

Member Data Documentation

const int CVideo::DefaultBpp = 32
static

Definition at line 54 of file video.hpp.

video_event_handler CVideo::event_handler_
private

Definition at line 189 of file video.hpp.

Referenced by init_window().

bool CVideo::fake_screen_
private

Definition at line 187 of file video.hpp.

Referenced by faked(), flip(), make_fake(), and setMode().

int CVideo::flip_locked_
private

Definition at line 195 of file video.hpp.

Referenced by flip(), and lock_flips().

int CVideo::help_string_
private

Definition at line 192 of file video.hpp.

Referenced by clear_all_help_strings(), clear_help_string(), and set_help_string().

int CVideo::refresh_rate_
private

Definition at line 196 of file video.hpp.

Referenced by current_refresh_rate(), init_window(), make_fake(), and make_test_fake().

CVideo * CVideo::singleton_ = nullptr
staticprivate

Definition at line 172 of file video.hpp.

Referenced by CVideo(), get_singleton(), and ~CVideo().

int CVideo::updatesLocked_
private

Definition at line 194 of file video.hpp.

Referenced by lock_updates(), and update_locked().

std::unique_ptr<sdl::window> CVideo::window
private

The documentation for this class was generated from the following files: