The Battle for Wesnoth  1.19.4+dev
Public Member Functions | Protected Member Functions | List of all members
gui2::top_level_drawable Class Referenceabstract

A top-level drawable item (TLD), such as a window. More...

#include <top_level_drawable.hpp>

Inheritance diagram for gui2::top_level_drawable:

Public Member Functions

virtual void update ()
 Update state and any parameters that may effect layout, or any of the later stages. More...
 
virtual void layout ()
 Finalize the size and position of the drawable and its children, and invalidate any regions requiring redraw. More...
 
virtual void render ()
 Perform any internal rendering necessary to prepare the drawable. More...
 
virtual bool expose (const rect &region)=0
 Draw the portion of the drawable intersecting region to the screen. More...
 
virtual rect screen_location ()=0
 The location of the TLD on the screen, in drawing coordinates. More...
 

Protected Member Functions

 top_level_drawable ()
 
virtual ~top_level_drawable ()
 
 top_level_drawable (const top_level_drawable &)
 
top_level_drawableoperator= (const top_level_drawable &)
 
 top_level_drawable (top_level_drawable &&)
 
top_level_drawableoperator= (top_level_drawable &&)
 

Detailed Description

A top-level drawable item (TLD), such as a window.

For now, TLDs keep track of where they are on the screen on their own. They must draw themselves when requested via expose().

The TLD interface will be called in the following order:

It can be assumed that events will have been processed before TLD interface calls commence, and that no more events will be processed until all TLD interfaces have been called. As such the main program loop will usually be:

  1. process events
  2. call update() on all TLDs
  3. call layout() on all TLDs
  4. call render() on all TLDs
  5. call expose() on TLDs as appropriate

TLDs are responsible for propagating these calls to their children.

This process is loosely based on the GTK drawing model. Ref:

Definition at line 51 of file top_level_drawable.hpp.

Constructor & Destructor Documentation

◆ top_level_drawable() [1/3]

gui2::top_level_drawable::top_level_drawable ( )
protected

Definition at line 22 of file top_level_drawable.cpp.

References draw_manager::register_drawable().

◆ ~top_level_drawable()

gui2::top_level_drawable::~top_level_drawable ( )
protectedvirtual

Definition at line 27 of file top_level_drawable.cpp.

References draw_manager::deregister_drawable().

◆ top_level_drawable() [2/3]

gui2::top_level_drawable::top_level_drawable ( const top_level_drawable )
protected

Definition at line 32 of file top_level_drawable.cpp.

References draw_manager::register_drawable().

◆ top_level_drawable() [3/3]

gui2::top_level_drawable::top_level_drawable ( top_level_drawable &&  )
protected

Definition at line 43 of file top_level_drawable.cpp.

References draw_manager::register_drawable().

Member Function Documentation

◆ expose()

virtual bool gui2::top_level_drawable::expose ( const rect region)
pure virtual

Draw the portion of the drawable intersecting region to the screen.

TLDs must not invalidate regions during expose. Only drawing must occur, with no modification of layout.

Implementation of this interface is mandatory.

Parameters
regionThe region to expose, in absolute draw-space coordinates.
Returns
True if anything was drawn, false otherwise.

Implemented in gui::widget, tooltips::manager, gui2::window, and display.

◆ layout()

virtual void gui2::top_level_drawable::layout ( )
inlinevirtual

Finalize the size and position of the drawable and its children, and invalidate any regions requiring redraw.

Visibly changed screen locations should be invalidated using draw_manager::invalidate_region(), both in the previous location and in the new location if different.

TLDs must not perform any actual drawing during layout.

This interface is optional.

Reimplemented in gui::widget, gui::textbox, tooltips::manager, gui2::window, gui2::dialogs::loading_screen, game_display, editor::palette_manager, editor::location_palette, editor::editor_palette< Item >, editor::editor_palette< t_translation::terrain_code >, editor::editor_palette< const unit_type & >, editor::editor_palette< overlay >, editor::editor_display, and display.

Definition at line 90 of file top_level_drawable.hpp.

Referenced by draw_manager::layout().

◆ operator=() [1/2]

top_level_drawable & gui2::top_level_drawable::operator= ( const top_level_drawable )
protected

Definition at line 37 of file top_level_drawable.cpp.

References draw_manager::register_drawable().

◆ operator=() [2/2]

top_level_drawable & gui2::top_level_drawable::operator= ( top_level_drawable &&  )
protected

Definition at line 48 of file top_level_drawable.cpp.

References draw_manager::register_drawable().

◆ render()

virtual void gui2::top_level_drawable::render ( )
inlinevirtual

Perform any internal rendering necessary to prepare the drawable.

For example if the drawable has an offscreen buffer it manages, it should ensure this buffer is up to date.

TLDs should also invalidate any regions visibly changed by this call.

This interface is optional.

Reimplemented in gui2::window, game_display, and display.

Definition at line 102 of file top_level_drawable.hpp.

Referenced by draw_manager::render().

◆ screen_location()

virtual rect gui2::top_level_drawable::screen_location ( )
pure virtual

The location of the TLD on the screen, in drawing coordinates.

This will be used to determine the region (if any) to expose.

Implementation of this interface is mandatory.

Implemented in gui::widget, tooltips::manager, gui2::window, and display.

◆ update()

virtual void gui2::top_level_drawable::update ( )
inlinevirtual

Update state and any parameters that may effect layout, or any of the later stages.

In general this should be used to make changes to things that will affect the visible state of the drawable. This can include changing the drawable's size or position, or updating animation frames to show the appropriate image for the current time. Exact usage is up to the drawable to decide.

This interface is optional.

Reimplemented in gui2::dialogs::story_viewer, gui2::dialogs::outro, gui2::dialogs::end_credits, gui2::dialogs::debug_clock, game_display, and display.

Definition at line 76 of file top_level_drawable.hpp.

Referenced by draw_manager::update(), gui2::dialogs::debug_clock::update(), and gui2::dialogs::story_viewer::update().


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