mirror of https://github.com/buggins/dlangui.git
update ddocs
This commit is contained in:
parent
faeac55f4b
commit
5a1bd36652
|
@ -44,8 +44,8 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.all;
|
module dlangui.all;
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ writeln(widgets[0].id);
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.core.collections;
|
module dlangui.core.collections;
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ import dlangui.core.events;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.core.events;
|
module dlangui.core.events;
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@ dstring translated = text;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.core.i18n;
|
module dlangui.core.i18n;
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ try {
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.core.linestream;
|
module dlangui.core.linestream;
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ Log.d("exception while reading file", e);
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.core.logger;
|
module dlangui.core.logger;
|
||||||
|
|
||||||
|
|
|
@ -94,8 +94,8 @@ signal4 -= f;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.core.signals;
|
module dlangui.core.signals;
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ class Foo : RefCountedObject {
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.core.types;
|
module dlangui.core.types;
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ import dlangui.graphics.drawbuf;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.graphics.drawbuf;
|
module dlangui.graphics.drawbuf;
|
||||||
|
|
||||||
|
|
|
@ -3,20 +3,45 @@
|
||||||
/**
|
/**
|
||||||
DLANGUI library.
|
DLANGUI library.
|
||||||
|
|
||||||
This module contains base fonts access implementation.
|
This module contains base fonts access interface and common implementation.
|
||||||
|
|
||||||
|
Font - base class for fonts.
|
||||||
|
|
||||||
|
FontManager - base class for font managers - provides access to available fonts.
|
||||||
|
|
||||||
|
|
||||||
|
Actual implementation is:
|
||||||
|
|
||||||
|
dlangui.graphics.ftfonts - FreeType based font manager.
|
||||||
|
|
||||||
|
dlangui.platforms.windows.w32fonts - Win32 API based font manager.
|
||||||
|
|
||||||
|
|
||||||
To enable OpenGL support, build with version(USE_OPENGL);
|
To enable OpenGL support, build with version(USE_OPENGL);
|
||||||
|
|
||||||
|
See_Also: dlangui.graphics.drawbuf, DrawBuf, drawbuf, drawbuf.html
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Synopsis:
|
Synopsis:
|
||||||
|
|
||||||
----
|
----
|
||||||
import dlangui.graphics.glsupport;
|
import dlangui.graphics.fonts;
|
||||||
|
|
||||||
|
// find suitable font of size 25, normal, preferrable Arial, or, if not available, any SansSerif font
|
||||||
|
FontRef font = FontManager.instance.getFont(25, FontWeight.Normal, false, FontFamily.SansSerif, "Arial");
|
||||||
|
|
||||||
|
dstring sampleText = "Sample text to draw"d;
|
||||||
|
// measure text string width and height (one line)
|
||||||
|
Point sz = font.textSize(sampleText);
|
||||||
|
// draw red text at center of DrawBuf buf
|
||||||
|
font.drawText(buf, buf.width / 2 - sz.x/2, buf.height / 2 - sz.y / 2, sampleText, 0xFF0000);
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.graphics.fonts;
|
module dlangui.graphics.fonts;
|
||||||
public import dlangui.graphics.drawbuf;
|
public import dlangui.graphics.drawbuf;
|
||||||
|
@ -25,7 +50,7 @@ public import dlangui.core.logger;
|
||||||
private import dlangui.widgets.styles;
|
private import dlangui.widgets.styles;
|
||||||
import std.algorithm;
|
import std.algorithm;
|
||||||
|
|
||||||
/// font family
|
/// font families enum
|
||||||
enum FontFamily : ubyte {
|
enum FontFamily : ubyte {
|
||||||
/// Unknown / not set / does not matter
|
/// Unknown / not set / does not matter
|
||||||
Unspecified,
|
Unspecified,
|
||||||
|
@ -41,9 +66,11 @@ enum FontFamily : ubyte {
|
||||||
MonoSpace
|
MonoSpace
|
||||||
}
|
}
|
||||||
|
|
||||||
/// useful font weight constants
|
/// font weight constants (0..1000)
|
||||||
enum FontWeight : int {
|
enum FontWeight : int {
|
||||||
|
/// normal font weight
|
||||||
Normal = 400,
|
Normal = 400,
|
||||||
|
/// bold font
|
||||||
Bold = 800
|
Bold = 800
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,117 +82,42 @@ immutable dchar UNICODE_NB_HYPHEN = 0x2011;
|
||||||
|
|
||||||
|
|
||||||
version (USE_OPENGL) {
|
version (USE_OPENGL) {
|
||||||
|
|
||||||
private __gshared void function(uint id) _glyphDestroyCallback;
|
private __gshared void function(uint id) _glyphDestroyCallback;
|
||||||
/// get glyph destroy callback (to cleanup OpenGL caches)
|
/**
|
||||||
|
* get glyph destroy callback (to cleanup OpenGL caches)
|
||||||
|
*
|
||||||
|
* Used for resource management. Usually you don't have to call it manually.
|
||||||
|
*/
|
||||||
@property void function(uint id) glyphDestroyCallback() { return _glyphDestroyCallback; }
|
@property void function(uint id) glyphDestroyCallback() { return _glyphDestroyCallback; }
|
||||||
/// set glyph destroy callback (to cleanup OpenGL caches)
|
/**
|
||||||
@property void glyphDestroyCallback(void function(uint id) callback) { _glyphDestroyCallback = callback; }
|
* Set glyph destroy callback (to cleanup OpenGL caches)
|
||||||
|
* This callback is used to tell OpenGL glyph cache that glyph is not more used - to let OpenGL glyph cache delete texture if all glyphs in it are no longer used.
|
||||||
|
*
|
||||||
|
* Used for resource management. Usually you don't have to call it manually.
|
||||||
|
*/
|
||||||
|
@property void glyphDestroyCallback(void function(uint id) callback) { _glyphDestroyCallback = callback; }
|
||||||
|
|
||||||
private __gshared uint _nextGlyphId;
|
private __gshared uint _nextGlyphId;
|
||||||
/// ID generator for glyphs
|
/**
|
||||||
uint nextGlyphId() { return _nextGlyphId++; }
|
* ID generator for glyphs
|
||||||
}
|
*
|
||||||
|
* Generates next glyph ID. Unique IDs are being used to control OpenGL glyph cache items lifetime.
|
||||||
/***************************************
|
*
|
||||||
* Glyph image cache
|
* Used for resource management. Usually you don't have to call it manually.
|
||||||
*
|
*/
|
||||||
*
|
uint nextGlyphId() { return _nextGlyphId++; }
|
||||||
* Recently used glyphs are marked with glyph.lastUsage = 1
|
|
||||||
*
|
|
||||||
* checkpoint() call clears usage marks
|
|
||||||
*
|
|
||||||
* cleanup() removes all items not accessed since last checkpoint()
|
|
||||||
*
|
|
||||||
***************************************/
|
|
||||||
struct GlyphCache
|
|
||||||
{
|
|
||||||
alias glyph_ptr = Glyph*;
|
|
||||||
private glyph_ptr[][1024] _glyphs;
|
|
||||||
|
|
||||||
/// try to find glyph for character in cache, returns null if not found
|
|
||||||
Glyph * find(dchar ch) {
|
|
||||||
ch = ch & 0xF_FFFF;
|
|
||||||
//if (_array is null)
|
|
||||||
// _array = new Glyph[0x10000];
|
|
||||||
uint p = ch >> 8;
|
|
||||||
glyph_ptr[] row = _glyphs[p];
|
|
||||||
if (row is null)
|
|
||||||
return null;
|
|
||||||
uint i = ch & 0xFF;
|
|
||||||
Glyph * res = row[i];
|
|
||||||
if (!res)
|
|
||||||
return null;
|
|
||||||
res.lastUsage = 1;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// put character glyph to cache
|
|
||||||
Glyph * put(dchar ch, Glyph * glyph) {
|
|
||||||
ch = ch & 0xF_FFFF;
|
|
||||||
uint p = ch >> 8;
|
|
||||||
uint i = ch & 0xFF;
|
|
||||||
if (_glyphs[p] is null)
|
|
||||||
_glyphs[p] = new glyph_ptr[256];
|
|
||||||
_glyphs[p][i] = glyph;
|
|
||||||
glyph.lastUsage = 1;
|
|
||||||
return glyph;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// removes entries not used after last call of checkpoint() or cleanup()
|
|
||||||
void cleanup() {
|
|
||||||
foreach(part; _glyphs) {
|
|
||||||
if (part !is null)
|
|
||||||
foreach(item; part) {
|
|
||||||
if (item && !item.lastUsage) {
|
|
||||||
version (USE_OPENGL) {
|
|
||||||
// notify about destroyed glyphs
|
|
||||||
if (_glyphDestroyCallback !is null) {
|
|
||||||
_glyphDestroyCallback(item.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
destroy(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// clear usage flags for all entries
|
|
||||||
void checkpoint() {
|
|
||||||
foreach(part; _glyphs) {
|
|
||||||
if (part !is null)
|
|
||||||
foreach(item; part) {
|
|
||||||
if (item)
|
|
||||||
item.lastUsage = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// removes all entries (notify OpenGL cache about removed glyphs)
|
|
||||||
void clear() {
|
|
||||||
foreach(part; _glyphs) {
|
|
||||||
if (part !is null)
|
|
||||||
foreach(item; part) {
|
|
||||||
if (item) {
|
|
||||||
version (USE_OPENGL) {
|
|
||||||
// notify about destroyed glyphs
|
|
||||||
if (_glyphDestroyCallback !is null) {
|
|
||||||
_glyphDestroyCallback(item.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
destroy(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// on destroy, destroy all items (notify OpenGL cache about removed glyphs)
|
|
||||||
~this() {
|
|
||||||
clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// constant for measureText maxWidth paramenter - to tell that all characters of text string should be measured.
|
||||||
immutable int MAX_WIDTH_UNSPECIFIED = int.max;
|
immutable int MAX_WIDTH_UNSPECIFIED = int.max;
|
||||||
|
|
||||||
/// Font object
|
/** Instance of font with specific size, weight, face, etc.
|
||||||
|
*
|
||||||
|
* Allows to measure text string and draw it on DrawBuf
|
||||||
|
*
|
||||||
|
* Use FontManager.instance.getFont() to retrieve font instance.
|
||||||
|
*/
|
||||||
class Font : RefCountedObject {
|
class Font : RefCountedObject {
|
||||||
/// returns font size (as requested from font engine)
|
/// returns font size (as requested from font engine)
|
||||||
abstract @property int size();
|
abstract @property int size();
|
||||||
|
@ -198,12 +150,14 @@ class Font : RefCountedObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _spaceWidth = -1;
|
private int _spaceWidth = -1;
|
||||||
|
|
||||||
/// returns true if font is fixed
|
/// returns true if font is fixed
|
||||||
@property int spaceWidth() {
|
@property int spaceWidth() {
|
||||||
if (_spaceWidth < 0)
|
if (_spaceWidth < 0)
|
||||||
_spaceWidth = charWidth(' ');
|
_spaceWidth = charWidth(' ');
|
||||||
return _spaceWidth;
|
return _spaceWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// returns character width
|
/// returns character width
|
||||||
int charWidth(dchar ch) {
|
int charWidth(dchar ch) {
|
||||||
Glyph * g = getCharGlyph(ch);
|
Glyph * g = getCharGlyph(ch);
|
||||||
|
@ -213,14 +167,19 @@ class Font : RefCountedObject {
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
* Measure text string, return accumulated widths[] (distance to end of n-th character), returns number of measured chars.
|
* Measure text string, return accumulated widths[] (distance to end of n-th character), returns number of measured chars.
|
||||||
*
|
*
|
||||||
|
* Supports Tab character processing and processing of menu item labels like '&File'.
|
||||||
|
*
|
||||||
* Params:
|
* Params:
|
||||||
* text = text string to measure
|
* text = text string to measure
|
||||||
* widths = output buffer to put measured widths (widths[i] will be set to cumulative widths text[0..i])
|
* widths = output buffer to put measured widths (widths[i] will be set to cumulative widths text[0..i])
|
||||||
* maxWidth = maximum width - measure is stopping if max width is reached
|
* maxWidth = maximum width to measure - measure is stopping if max width is reached (pass MAX_WIDTH_UNSPECIFIED to measure all characters)
|
||||||
* tabSize = tabulation size, in number of spaces
|
* tabSize = tabulation size, in number of spaces
|
||||||
* tabOffset = when string is drawn not from left position, use to move tab stops left/right
|
* tabOffset = when string is drawn not from left position, use to move tab stops left/right
|
||||||
|
* textFlags = TextFlag bit set - to control underline, hotkey label processing, etc...
|
||||||
|
* Returns:
|
||||||
|
* number of characters measured (may be less than text.length if maxWidth is reached)
|
||||||
******************************************************************************************/
|
******************************************************************************************/
|
||||||
int measureText(const dchar[] text, ref int[] widths, int maxWidth=MAX_WIDTH_UNSPECIFIED, int tabSize = 4, int tabOffset = 0, uint textFlags = 0) {
|
int measureText(const dchar[] text, ref int[] widths, int maxWidth = MAX_WIDTH_UNSPECIFIED, int tabSize = 4, int tabOffset = 0, uint textFlags = 0) {
|
||||||
if (text.length == 0)
|
if (text.length == 0)
|
||||||
return 0;
|
return 0;
|
||||||
const dchar * pstr = text.ptr;
|
const dchar * pstr = text.ptr;
|
||||||
|
@ -279,6 +238,9 @@ class Font : RefCountedObject {
|
||||||
* Params:
|
* Params:
|
||||||
* text = text string to measure
|
* text = text string to measure
|
||||||
* maxWidth = maximum width - measure is stopping if max width is reached
|
* maxWidth = maximum width - measure is stopping if max width is reached
|
||||||
|
* tabSize = tabulation size, in number of spaces
|
||||||
|
* tabOffset = when string is drawn not from left position, use to move tab stops left/right
|
||||||
|
* textFlags = TextFlag bit set - to control underline, hotkey label processing, etc...
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
Point textSize(const dchar[] text, int maxWidth = MAX_WIDTH_UNSPECIFIED, int tabSize = 4, int tabOffset = 0, uint textFlags = 0) {
|
Point textSize(const dchar[] text, int maxWidth = MAX_WIDTH_UNSPECIFIED, int tabSize = 4, int tabOffset = 0, uint textFlags = 0) {
|
||||||
if (_textSizeBuffer.length < text.length + 1)
|
if (_textSizeBuffer.length < text.length + 1)
|
||||||
|
@ -482,3 +444,103 @@ class FontManager {
|
||||||
Log.d("Destroying font manager");
|
Log.d("Destroying font manager");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************
|
||||||
|
* Glyph image cache
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Recently used glyphs are marked with glyph.lastUsage = 1
|
||||||
|
*
|
||||||
|
* checkpoint() call clears usage marks
|
||||||
|
*
|
||||||
|
* cleanup() removes all items not accessed since last checkpoint()
|
||||||
|
*
|
||||||
|
***************************************/
|
||||||
|
struct GlyphCache
|
||||||
|
{
|
||||||
|
alias glyph_ptr = Glyph*;
|
||||||
|
private glyph_ptr[][1024] _glyphs;
|
||||||
|
|
||||||
|
/// try to find glyph for character in cache, returns null if not found
|
||||||
|
Glyph * find(dchar ch) {
|
||||||
|
ch = ch & 0xF_FFFF;
|
||||||
|
//if (_array is null)
|
||||||
|
// _array = new Glyph[0x10000];
|
||||||
|
uint p = ch >> 8;
|
||||||
|
glyph_ptr[] row = _glyphs[p];
|
||||||
|
if (row is null)
|
||||||
|
return null;
|
||||||
|
uint i = ch & 0xFF;
|
||||||
|
Glyph * res = row[i];
|
||||||
|
if (!res)
|
||||||
|
return null;
|
||||||
|
res.lastUsage = 1;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// put character glyph to cache
|
||||||
|
Glyph * put(dchar ch, Glyph * glyph) {
|
||||||
|
ch = ch & 0xF_FFFF;
|
||||||
|
uint p = ch >> 8;
|
||||||
|
uint i = ch & 0xFF;
|
||||||
|
if (_glyphs[p] is null)
|
||||||
|
_glyphs[p] = new glyph_ptr[256];
|
||||||
|
_glyphs[p][i] = glyph;
|
||||||
|
glyph.lastUsage = 1;
|
||||||
|
return glyph;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// removes entries not used after last call of checkpoint() or cleanup()
|
||||||
|
void cleanup() {
|
||||||
|
foreach(part; _glyphs) {
|
||||||
|
if (part !is null)
|
||||||
|
foreach(item; part) {
|
||||||
|
if (item && !item.lastUsage) {
|
||||||
|
version (USE_OPENGL) {
|
||||||
|
// notify about destroyed glyphs
|
||||||
|
if (_glyphDestroyCallback !is null) {
|
||||||
|
_glyphDestroyCallback(item.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
destroy(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// clear usage flags for all entries
|
||||||
|
void checkpoint() {
|
||||||
|
foreach(part; _glyphs) {
|
||||||
|
if (part !is null)
|
||||||
|
foreach(item; part) {
|
||||||
|
if (item)
|
||||||
|
item.lastUsage = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// removes all entries (when built with USE_OPENGL version, notify OpenGL cache about removed glyphs)
|
||||||
|
void clear() {
|
||||||
|
foreach(part; _glyphs) {
|
||||||
|
if (part !is null)
|
||||||
|
foreach(item; part) {
|
||||||
|
if (item) {
|
||||||
|
version (USE_OPENGL) {
|
||||||
|
// notify about destroyed glyphs
|
||||||
|
if (_glyphDestroyCallback !is null) {
|
||||||
|
_glyphDestroyCallback(item.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
destroy(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// on destroy, destroy all items (when built with USE_OPENGL version, notify OpenGL cache about removed glyphs)
|
||||||
|
~this() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,17 @@
|
||||||
/// freetype fonts support
|
// Written in the D programming language.
|
||||||
|
|
||||||
|
/**
|
||||||
|
DLANGUI library.
|
||||||
|
|
||||||
|
This file contains FontManager implementation based on FreeType library.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Copyright: Vadim Lopatin, 2014
|
||||||
|
License: Boost License 1.0
|
||||||
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
|
*/
|
||||||
module dlangui.graphics.ftfonts;
|
module dlangui.graphics.ftfonts;
|
||||||
|
|
||||||
import dlangui.graphics.fonts;
|
import dlangui.graphics.fonts;
|
||||||
|
|
|
@ -15,8 +15,8 @@ import dlangui.graphics.gldrawbuf;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.graphics.gldrawbuf;
|
module dlangui.graphics.gldrawbuf;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class GLDrawBuf : DrawBuf {
|
||||||
protected uint _framebufferId; // not yet supported
|
protected uint _framebufferId; // not yet supported
|
||||||
protected Scene _scene;
|
protected Scene _scene;
|
||||||
|
|
||||||
/// get current scene (exists only between beforeDrawing() and afterDrawing() calls
|
/// get current scene (exists only between beforeDrawing() and afterDrawing() calls)
|
||||||
@property Scene scene() { return _scene; }
|
@property Scene scene() { return _scene; }
|
||||||
|
|
||||||
this(int dx, int dy, bool framebuffer = false) {
|
this(int dx, int dy, bool framebuffer = false) {
|
||||||
|
|
|
@ -15,8 +15,8 @@ import dlangui.graphics.glsupport;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.graphics.glsupport;
|
module dlangui.graphics.glsupport;
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ import dlangui.graphics.images;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.graphics.images;
|
module dlangui.graphics.images;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ drawableCache is cache of Drawables.
|
||||||
|
|
||||||
Supports nine-patch PNG images in .9.png files (like in Android).
|
Supports nine-patch PNG images in .9.png files (like in Android).
|
||||||
|
|
||||||
Supports state drawables using XML files similar to ones in Android).
|
Supports state drawables using XML files similar to ones in Android.
|
||||||
|
|
||||||
Synopsis:
|
Synopsis:
|
||||||
|
|
||||||
|
@ -21,9 +21,11 @@ import dlangui.graphics.resources;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module dlangui.graphics.resources;
|
module dlangui.graphics.resources;
|
||||||
|
|
||||||
import dlangui.graphics.images;
|
import dlangui.graphics.images;
|
||||||
|
@ -127,7 +129,7 @@ static uint decodeDimension(string s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// decode solid color / gradient / frame drawable from string like #AARRGGBB, e.g. #5599AA
|
/// decode solid color / gradient / frame drawable from string like #AARRGGBB, e.g. #5599AA
|
||||||
/// ---
|
///
|
||||||
/// SolidFillDrawable: #AARRGGBB - e.g. #8090A0 or #80ffffff
|
/// SolidFillDrawable: #AARRGGBB - e.g. #8090A0 or #80ffffff
|
||||||
/// FrameDrawable: #frameColor,frameWidth[,#middleColor]
|
/// FrameDrawable: #frameColor,frameWidth[,#middleColor]
|
||||||
/// or #frameColor,leftBorderWidth,topBorderWidth,rightBorderWidth,bottomBorderWidth[,#middleColor]
|
/// or #frameColor,leftBorderWidth,topBorderWidth,rightBorderWidth,bottomBorderWidth[,#middleColor]
|
||||||
|
|
|
@ -16,8 +16,8 @@ import dlangui.platforms.common.platform;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.platforms.common.platform;
|
module dlangui.platforms.common.platform;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
// Written in the D programming language.
|
||||||
|
|
||||||
|
/**
|
||||||
|
DLANGUI library.
|
||||||
|
|
||||||
|
This module contains implementation of SDL2 based backend for dlang library.
|
||||||
|
|
||||||
|
|
||||||
|
Synopsis:
|
||||||
|
|
||||||
|
----
|
||||||
|
import dlangui.platforms.sdl.sdlapp;
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
Copyright: Vadim Lopatin, 2014
|
||||||
|
License: Boost License 1.0
|
||||||
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
|
*/
|
||||||
module src.dlangui.platforms.sdl.sdlapp;
|
module src.dlangui.platforms.sdl.sdlapp;
|
||||||
|
|
||||||
version(USE_SDL) {
|
version(USE_SDL) {
|
||||||
|
|
|
@ -24,8 +24,8 @@ import dlangui.widgets.controls;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.widgets.controls;
|
module dlangui.widgets.controls;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,11 @@ DLANGUI library.
|
||||||
|
|
||||||
This module contains implementation of editors.
|
This module contains implementation of editors.
|
||||||
|
|
||||||
EditLine single line editor.
|
|
||||||
|
EditLine - single line editor.
|
||||||
|
|
||||||
|
EditBox - multiline editor
|
||||||
|
|
||||||
|
|
||||||
Synopsis:
|
Synopsis:
|
||||||
|
|
||||||
|
@ -15,8 +19,8 @@ import dlangui.widgets.editors;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.widgets.editors;
|
module dlangui.widgets.editors;
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@ import dlangui.widgets.layouts;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.widgets.layouts;
|
module dlangui.widgets.layouts;
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ import dlangui.widgets.lists;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.widgets.lists;
|
module dlangui.widgets.lists;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,9 @@ DLANGUI library.
|
||||||
|
|
||||||
This module contains menu widgets implementation.
|
This module contains menu widgets implementation.
|
||||||
|
|
||||||
|
MenuItem - menu item properties container - to hold hierarchy of menu.
|
||||||
|
MainMenu - main menu widget
|
||||||
|
PopupMenu - popup menu widget
|
||||||
|
|
||||||
Synopsis:
|
Synopsis:
|
||||||
|
|
||||||
|
@ -15,8 +17,8 @@ import dlangui.widgets.popup;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.widgets.menu;
|
module dlangui.widgets.menu;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,9 @@ DLANGUI library.
|
||||||
|
|
||||||
This module contains popup widgets implementation.
|
This module contains popup widgets implementation.
|
||||||
|
|
||||||
|
Popups appear above other widgets inside window.
|
||||||
|
|
||||||
|
Useful for popup menus, notification popups, etc.
|
||||||
|
|
||||||
Synopsis:
|
Synopsis:
|
||||||
|
|
||||||
|
@ -15,8 +17,8 @@ import dlangui.widgets.popup;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.widgets.popup;
|
module dlangui.widgets.popup;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ DLANGUI library.
|
||||||
|
|
||||||
This module contains declaration of themes and styles implementation.
|
This module contains declaration of themes and styles implementation.
|
||||||
|
|
||||||
|
Style - style container
|
||||||
|
Theme - parent for all styles
|
||||||
|
|
||||||
|
|
||||||
Synopsis:
|
Synopsis:
|
||||||
|
@ -15,43 +17,63 @@ import dlangui.widgets.styles;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.widgets.styles;
|
module dlangui.widgets.styles;
|
||||||
|
|
||||||
import dlangui.core.types;
|
import dlangui.core.types;
|
||||||
import dlangui.graphics.fonts;
|
import dlangui.graphics.fonts;
|
||||||
import dlangui.graphics.drawbuf;
|
import dlangui.graphics.drawbuf;
|
||||||
//import dlangui.graphics.images;
|
|
||||||
import dlangui.graphics.resources;
|
import dlangui.graphics.resources;
|
||||||
|
|
||||||
immutable ubyte ALIGN_UNSPECIFIED = 0;
|
immutable ubyte ALIGN_UNSPECIFIED = 0;
|
||||||
immutable uint COLOR_UNSPECIFIED = 0xFFDEADFF;
|
immutable uint COLOR_UNSPECIFIED = 0xFFDEADFF;
|
||||||
|
/// transparent color constant
|
||||||
immutable uint COLOR_TRANSPARENT = 0xFFFFFFFF;
|
immutable uint COLOR_TRANSPARENT = 0xFFFFFFFF;
|
||||||
|
/// unspecified font size constant - to take parent style property value
|
||||||
immutable ushort FONT_SIZE_UNSPECIFIED = 0xFFFF;
|
immutable ushort FONT_SIZE_UNSPECIFIED = 0xFFFF;
|
||||||
|
/// unspecified font weight constant - to take parent style property value
|
||||||
immutable ushort FONT_WEIGHT_UNSPECIFIED = 0x0000;
|
immutable ushort FONT_WEIGHT_UNSPECIFIED = 0x0000;
|
||||||
|
/// unspecified font style constant - to take parent style property value
|
||||||
immutable ubyte FONT_STYLE_UNSPECIFIED = 0xFF;
|
immutable ubyte FONT_STYLE_UNSPECIFIED = 0xFF;
|
||||||
|
/// normal font style constant
|
||||||
immutable ubyte FONT_STYLE_NORMAL = 0x00;
|
immutable ubyte FONT_STYLE_NORMAL = 0x00;
|
||||||
|
/// italic font style constant
|
||||||
immutable ubyte FONT_STYLE_ITALIC = 0x01;
|
immutable ubyte FONT_STYLE_ITALIC = 0x01;
|
||||||
/// use as widget.layout() param to avoid applying of parent size
|
/// use as widget.layout() param to avoid applying of parent size
|
||||||
immutable int SIZE_UNSPECIFIED = int.max;
|
immutable int SIZE_UNSPECIFIED = int.max;
|
||||||
|
/// use text flags from parent style
|
||||||
immutable uint TEXT_FLAGS_UNSPECIFIED = uint.max;
|
immutable uint TEXT_FLAGS_UNSPECIFIED = uint.max;
|
||||||
|
/// use text flags from parent widget
|
||||||
immutable uint TEXT_FLAGS_USE_PARENT = uint.max - 1;
|
immutable uint TEXT_FLAGS_USE_PARENT = uint.max - 1;
|
||||||
|
|
||||||
|
/// layout option, to occupy all available place
|
||||||
immutable int FILL_PARENT = int.max - 1;
|
immutable int FILL_PARENT = int.max - 1;
|
||||||
|
/// layout option, for size based on content
|
||||||
immutable int WRAP_CONTENT = int.max - 2;
|
immutable int WRAP_CONTENT = int.max - 2;
|
||||||
|
/// to take layout weight from parent
|
||||||
immutable int WEIGHT_UNSPECIFIED = -1;
|
immutable int WEIGHT_UNSPECIFIED = -1;
|
||||||
|
|
||||||
|
/// Align option bit constants
|
||||||
enum Align : ubyte {
|
enum Align : ubyte {
|
||||||
|
/// alignment is not specified
|
||||||
Unspecified = ALIGN_UNSPECIFIED,
|
Unspecified = ALIGN_UNSPECIFIED,
|
||||||
|
/// horizontally align to the left of box
|
||||||
Left = 1,
|
Left = 1,
|
||||||
Right = 2,
|
/// horizontally align to the right of box
|
||||||
HCenter = 1 | 2,
|
Right = 2,
|
||||||
Top = 4,
|
/// horizontally align to the center of box
|
||||||
Bottom = 8,
|
HCenter = 1 | 2,
|
||||||
VCenter = 4 | 8,
|
/// vertically align to the top of box
|
||||||
Center = VCenter | HCenter,
|
Top = 4,
|
||||||
|
/// vertically align to the bottom of box
|
||||||
|
Bottom = 8,
|
||||||
|
/// vertically align to the center of box
|
||||||
|
VCenter = 4 | 8,
|
||||||
|
/// align to the center of box (VCenter | HCenter)
|
||||||
|
Center = VCenter | HCenter,
|
||||||
|
/// align to the top left corner of box (Left | Top)
|
||||||
TopLeft = Left | Top,
|
TopLeft = Left | Top,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +89,7 @@ enum TextFlag : uint {
|
||||||
Underline = 8
|
Underline = 8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// custom drawable attribute container for styles
|
||||||
class DrawableAttribute {
|
class DrawableAttribute {
|
||||||
protected string _id;
|
protected string _id;
|
||||||
protected string _drawableId;
|
protected string _drawableId;
|
||||||
|
@ -143,6 +166,7 @@ class Style {
|
||||||
|
|
||||||
@property string id() const { return _id; }
|
@property string id() const { return _id; }
|
||||||
|
|
||||||
|
/// access to parent style for this style
|
||||||
@property const(Style) parentStyle() const {
|
@property const(Style) parentStyle() const {
|
||||||
if (_parentStyle !is null)
|
if (_parentStyle !is null)
|
||||||
return _parentStyle;
|
return _parentStyle;
|
||||||
|
@ -151,6 +175,7 @@ class Style {
|
||||||
return currentTheme;
|
return currentTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// access to parent style for this style
|
||||||
@property Style parentStyle() {
|
@property Style parentStyle() {
|
||||||
if (_parentStyle !is null)
|
if (_parentStyle !is null)
|
||||||
return _parentStyle;
|
return _parentStyle;
|
||||||
|
@ -686,7 +711,9 @@ class Theme : Style {
|
||||||
|
|
||||||
/// to access current theme
|
/// to access current theme
|
||||||
private __gshared Theme _currentTheme;
|
private __gshared Theme _currentTheme;
|
||||||
|
/// current theme accessor
|
||||||
@property Theme currentTheme() { return _currentTheme; }
|
@property Theme currentTheme() { return _currentTheme; }
|
||||||
|
/// set new current theme
|
||||||
@property void currentTheme(Theme theme) {
|
@property void currentTheme(Theme theme) {
|
||||||
if (_currentTheme !is null) {
|
if (_currentTheme !is null) {
|
||||||
destroy(_currentTheme);
|
destroy(_currentTheme);
|
||||||
|
|
|
@ -5,6 +5,10 @@ DLANGUI library.
|
||||||
|
|
||||||
This module contains declaration of tabbed view controls.
|
This module contains declaration of tabbed view controls.
|
||||||
|
|
||||||
|
TabItemWidget - single tab header in tab control
|
||||||
|
TabWidget
|
||||||
|
TabHost
|
||||||
|
TabControl
|
||||||
|
|
||||||
|
|
||||||
Synopsis:
|
Synopsis:
|
||||||
|
@ -15,8 +19,8 @@ import dlangui.widgets.tabs;
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.widgets.tabs;
|
module dlangui.widgets.tabs;
|
||||||
|
|
||||||
|
@ -28,6 +32,7 @@ interface TabHandler {
|
||||||
void onTabChanged(string newActiveTabId, string previousTabId);
|
void onTabChanged(string newActiveTabId, string previousTabId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// tab item metadata
|
||||||
class TabItem {
|
class TabItem {
|
||||||
private string _iconRes;
|
private string _iconRes;
|
||||||
private string _id;
|
private string _id;
|
||||||
|
@ -54,6 +59,7 @@ class TabItem {
|
||||||
void updateAccessTs() { _lastAccessTs = std.datetime.Clock.currStdTime; }
|
void updateAccessTs() { _lastAccessTs = std.datetime.Clock.currStdTime; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// tab item widget - to show tab header
|
||||||
class TabItemWidget : HorizontalLayout {
|
class TabItemWidget : HorizontalLayout {
|
||||||
private ImageWidget _icon;
|
private ImageWidget _icon;
|
||||||
private TextWidget _label;
|
private TextWidget _label;
|
||||||
|
@ -162,6 +168,7 @@ class TabItemList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// tab header - tab labels, with optional More button
|
||||||
class TabControl : WidgetGroup {
|
class TabControl : WidgetGroup {
|
||||||
protected TabItemList _items;
|
protected TabItemList _items;
|
||||||
protected ImageButton _moreButton;
|
protected ImageButton _moreButton;
|
||||||
|
|
|
@ -5,6 +5,13 @@ DLANGUI library.
|
||||||
|
|
||||||
This module contains declaration of Widget class - base class for all widgets.
|
This module contains declaration of Widget class - base class for all widgets.
|
||||||
|
|
||||||
|
Widgets are styleable. Use styleId property to set style to use from current Theme.
|
||||||
|
|
||||||
|
When any of styleable attributes is being overriden, widget's own copy of style is being created to hold modified attributes (defaults to parent style).
|
||||||
|
|
||||||
|
Two phase layout model (like in Android UI) is used - measure() call is followed by layout() is used to measure and layout widget and its children.abstract
|
||||||
|
|
||||||
|
Method onDraw will be called to draw widget on some surface. Widget.onDraw() draws widget background (if any).
|
||||||
|
|
||||||
|
|
||||||
Synopsis:
|
Synopsis:
|
||||||
|
@ -12,11 +19,21 @@ Synopsis:
|
||||||
----
|
----
|
||||||
import dlangui.widgets.widget;
|
import dlangui.widgets.widget;
|
||||||
|
|
||||||
|
// access attributes as properties
|
||||||
|
auto w = new Widget("id1");
|
||||||
|
w.backgroundColor = 0xFFFF00;
|
||||||
|
w.layoutWidth = FILL_PARENT;
|
||||||
|
w.layoutHeight = FILL_PARENT;
|
||||||
|
w.padding(Rect(10,10,10,10));
|
||||||
|
// same, but using chained method call
|
||||||
|
auto w = new Widget("id1").backgroundColor(0xFFFF00).layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).padding(Rect(10,10,10,10));
|
||||||
|
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
Copyright: Vadim Lopatin, 2014
|
Copyright: Vadim Lopatin, 2014
|
||||||
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
|
License: Boost License 1.0
|
||||||
Authors: $(WEB coolreader.org, Vadim Lopatin)
|
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||||
*/
|
*/
|
||||||
module dlangui.widgets.widget;
|
module dlangui.widgets.widget;
|
||||||
|
|
||||||
|
@ -24,12 +41,10 @@ public import dlangui.core.types;
|
||||||
public import dlangui.core.events;
|
public import dlangui.core.events;
|
||||||
public import dlangui.widgets.styles;
|
public import dlangui.widgets.styles;
|
||||||
public import dlangui.graphics.drawbuf;
|
public import dlangui.graphics.drawbuf;
|
||||||
//public import dlangui.graphics.images;
|
|
||||||
public import dlangui.graphics.resources;
|
public import dlangui.graphics.resources;
|
||||||
public import dlangui.graphics.fonts;
|
public import dlangui.graphics.fonts;
|
||||||
public import dlangui.core.i18n;
|
public import dlangui.core.i18n;
|
||||||
|
|
||||||
//public import std.signals;
|
|
||||||
public import dlangui.core.signals;
|
public import dlangui.core.signals;
|
||||||
|
|
||||||
import dlangui.platforms.common.platform;
|
import dlangui.platforms.common.platform;
|
||||||
|
@ -334,11 +349,12 @@ class Widget {
|
||||||
/// get text flags (bit set of TextFlag enum values)
|
/// get text flags (bit set of TextFlag enum values)
|
||||||
@property uint textFlags() {
|
@property uint textFlags() {
|
||||||
uint res = stateStyle.textFlags;
|
uint res = stateStyle.textFlags;
|
||||||
if (res == TEXT_FLAGS_USE_PARENT)
|
if (res == TEXT_FLAGS_USE_PARENT) {
|
||||||
if (parent)
|
if (parent)
|
||||||
res = parent.textFlags;
|
res = parent.textFlags;
|
||||||
else
|
else
|
||||||
res = 0;
|
res = 0;
|
||||||
|
}
|
||||||
if (res & TextFlag.UnderlineHotKeysWhenAltPressed) {
|
if (res & TextFlag.UnderlineHotKeysWhenAltPressed) {
|
||||||
uint modifiers = 0;
|
uint modifiers = 0;
|
||||||
if (window !is null)
|
if (window !is null)
|
||||||
|
|
Loading…
Reference in New Issue