Definition of a line. More...
#include <canvas_private.hpp>
Public Member Functions | |
line_shape (const config &cfg) | |
Constructor. More... | |
void | draw (wfl::map_formula_callable &variables) override |
Draws the canvas. More... | |
![]() | |
shape (const config &cfg) | |
virtual | ~shape () |
bool | immutable () const |
Private Attributes | |
typed_formula< unsigned > | x1_ |
The start x coordinate of the line. More... | |
typed_formula< unsigned > | y1_ |
The start y coordinate of the line. More... | |
typed_formula< unsigned > | x2_ |
The end x coordinate of the line. More... | |
typed_formula< unsigned > | y2_ |
The end y coordinate of the line. More... | |
typed_formula< color_t > | color_ |
The color of the line. More... | |
unsigned | thickness_ |
The thickness of the line. More... | |
Definition of a line.
When drawing a line it doesn't get blended on the surface but replaces the pixels instead. A blitting flag might be added later if needed.
Keys:
Key | Type | Default | Description |
---|---|---|---|
x1 | f_unsigned | 0 | The x coordinate of the startpoint. |
y1 | f_unsigned | 0 | The y coordinate of the startpoint. |
x2 | f_unsigned | 0 | The x coordinate of the endpoint. |
y2 | f_unsigned | 0 | The y coordinate of the endpoint. |
color | color | "" | The color of the line. |
thickness | unsigned | 0 | The thickness of the line; if 0 nothing is drawn. |
debug | string | "" | Debug message to show upon creation this message is not stored. |
Variables:
Key | Type | Description |
---|---|---|
width | unsigned | The width of the canvas. |
height | unsigned | The height of the canvas. |
text | t_string | The text to render on the widget. |
text_maximum_width | unsigned | The maximum width available for the text on the widget. |
text_maximum_height | unsigned | The maximum height available for the text on the widget. |
text_wrap_mode | int | When the text doesn't fit in the available width there are several ways to fix that. This variable holds the best method. (NOTE this is a 'hidden' variable meant to copy state from a widget to its canvas so there's no reason to use this variable and thus its values are not listed and might change without further notice.) |
text_alignment | h_align | The way the text is aligned inside the canvas. |
The size variables are copied to the window and will be determined at runtime. This is needed since the main window can be resized and the dialog needs to resize accordingly. The following variables are available:
Key | Type | Description |
---|---|---|
screen_width | unsigned | The usable width of the Wesnoth main window. |
screen_height | unsigned | The usable height of the Wesnoth main window. |
gamemapx_offset | unsigned | The distance between left edge of the screen and the game map. |
gamemap_width | unsigned | The usable width of the Wesnoth gamemap, if no gamemap shown it's the same value as screen_width. |
gamemap_height | unsigned | The usable height of the Wesnoth gamemap, if no gamemap shown it's the same value as screen_height. |
mouse_x | unsigned | The x coordinate of the mouse pointer. |
mouse_y | unsigned | The y coordinate of the mouse pointer. |
window_width | unsigned | The window width. This value has two meanings during the layout phase. This only applies if automatic placement is not enabled. - When set to 0 it should return the wanted maximum width. If no maximum is wanted it should be set to the '"(screen_width)"'. - When not equal to 0 its value is the best width for the window. When the size should remain unchanged it should be set to '"(window_width)"'. |
window_height | unsigned | The window height. This value has two meanings during the layout phase. This only applies if automatic placement is not enabled. - When set to 0 it should return the wanted maximum height. If no maximum is wanted it should be set to the '"(screen_height)"'. - When not equal to 0 its value is the best height for the window. When the size should remain unchanged it should be set to '"(window_height)"'. |
Note when drawing the valid coordinates are:
Drawing outside this area will result in unpredictable results including crashing. (That should be fixed, when encountered.)
Definition at line 71 of file canvas_private.hpp.
|
explicit |
Constructor.
cfg | The config object to define the line. |
Definition at line 46 of file canvas.cpp.
|
overridevirtual |
Draws the canvas.
variables | The canvas can have formulas in it's definition, this parameter contains the values for these formulas. |
Implements gui2::canvas::shape.
Definition at line 61 of file canvas.cpp.
References color_, DBG_GUI_D, draw::line(), x1_, x2_, y1_, and y2_.
|
private |
|
private |
The thickness of the line.
if the value is odd the x and y are the middle of the line. if the value is even the x and y are the middle of a line with width - 1. (0 is special case, does nothing.)
Definition at line 99 of file canvas_private.hpp.
|
private |
The start x coordinate of the line.
Definition at line 84 of file canvas_private.hpp.
Referenced by draw().
|
private |
The end x coordinate of the line.
Definition at line 86 of file canvas_private.hpp.
Referenced by draw().
|
private |
The start y coordinate of the line.
Definition at line 85 of file canvas_private.hpp.
Referenced by draw().
|
private |
The end y coordinate of the line.
Definition at line 87 of file canvas_private.hpp.
Referenced by draw().