update ddocs

This commit is contained in:
Vadim Lopatin 2014-05-15 10:58:32 +04:00
parent faeac55f4b
commit 5a1bd36652
26 changed files with 331 additions and 177 deletions

View File

@ -44,8 +44,8 @@ extern (C) int UIAppMain(string[] args) {
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.all;

View File

@ -32,8 +32,8 @@ writeln(widgets[0].id);
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.core.collections;

View File

@ -14,8 +14,8 @@ import dlangui.core.events;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.core.events;

View File

@ -35,8 +35,8 @@ dstring translated = text;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.core.i18n;

View File

@ -44,8 +44,8 @@ try {
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.core.linestream;

View File

@ -24,8 +24,8 @@ Log.d("exception while reading file", e);
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.core.logger;

View File

@ -94,8 +94,8 @@ signal4 -= f;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.core.signals;

View File

@ -36,8 +36,8 @@ class Foo : RefCountedObject {
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.core.types;

View File

@ -14,8 +14,8 @@ import dlangui.graphics.drawbuf;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.graphics.drawbuf;

View File

@ -3,20 +3,45 @@
/**
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);
See_Also: dlangui.graphics.drawbuf, DrawBuf, drawbuf, drawbuf.html
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
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.graphics.fonts;
public import dlangui.graphics.drawbuf;
@ -25,7 +50,7 @@ public import dlangui.core.logger;
private import dlangui.widgets.styles;
import std.algorithm;
/// font family
/// font families enum
enum FontFamily : ubyte {
/// Unknown / not set / does not matter
Unspecified,
@ -41,9 +66,11 @@ enum FontFamily : ubyte {
MonoSpace
}
/// useful font weight constants
/// font weight constants (0..1000)
enum FontWeight : int {
/// normal font weight
Normal = 400,
/// bold font
Bold = 800
}
@ -55,117 +82,42 @@ immutable dchar UNICODE_NB_HYPHEN = 0x2011;
version (USE_OPENGL) {
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; }
/// 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;
/// ID generator for glyphs
uint nextGlyphId() { return _nextGlyphId++; }
}
/***************************************
* 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 (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();
}
/**
* ID generator for glyphs
*
* Generates next glyph ID. Unique IDs are being used to control OpenGL glyph cache items lifetime.
*
* Used for resource management. Usually you don't have to call it manually.
*/
uint nextGlyphId() { return _nextGlyphId++; }
}
/// constant for measureText maxWidth paramenter - to tell that all characters of text string should be measured.
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 {
/// returns font size (as requested from font engine)
abstract @property int size();
@ -198,12 +150,14 @@ class Font : RefCountedObject {
}
private int _spaceWidth = -1;
/// returns true if font is fixed
@property int spaceWidth() {
if (_spaceWidth < 0)
_spaceWidth = charWidth(' ');
return _spaceWidth;
}
/// returns character width
int charWidth(dchar 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.
*
* Supports Tab character processing and processing of menu item labels like '&File'.
*
* Params:
* text = text string to measure
* 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
* tabSize = tabulation size, in number of spaces
* tabOffset = when string is drawn not from left position, use to move tab stops left/right
* text = text string to measure
* widths = output buffer to put measured widths (widths[i] will be set to cumulative widths text[0..i])
* 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
* 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)
return 0;
const dchar * pstr = text.ptr;
@ -279,6 +238,9 @@ class Font : RefCountedObject {
* Params:
* text = text string to measure
* 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) {
if (_textSizeBuffer.length < text.length + 1)
@ -482,3 +444,103 @@ class FontManager {
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();
}
}

View File

@ -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;
import dlangui.graphics.fonts;

View File

@ -15,8 +15,8 @@ import dlangui.graphics.gldrawbuf;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.graphics.gldrawbuf;
@ -37,7 +37,7 @@ class GLDrawBuf : DrawBuf {
protected uint _framebufferId; // not yet supported
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; }
this(int dx, int dy, bool framebuffer = false) {

View File

@ -15,8 +15,8 @@ import dlangui.graphics.glsupport;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.graphics.glsupport;

View File

@ -17,8 +17,8 @@ import dlangui.graphics.images;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.graphics.images;

View File

@ -11,7 +11,7 @@ drawableCache is cache of Drawables.
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:
@ -21,9 +21,11 @@ import dlangui.graphics.resources;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.graphics.resources;
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
/// ---
///
/// SolidFillDrawable: #AARRGGBB - e.g. #8090A0 or #80ffffff
/// FrameDrawable: #frameColor,frameWidth[,#middleColor]
/// or #frameColor,leftBorderWidth,topBorderWidth,rightBorderWidth,bottomBorderWidth[,#middleColor]

View File

@ -16,8 +16,8 @@ import dlangui.platforms.common.platform;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.platforms.common.platform;

View File

@ -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;
version(USE_SDL) {

View File

@ -24,8 +24,8 @@ import dlangui.widgets.controls;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.widgets.controls;

View File

@ -5,7 +5,11 @@ DLANGUI library.
This module contains implementation of editors.
EditLine single line editor.
EditLine - single line editor.
EditBox - multiline editor
Synopsis:
@ -15,8 +19,8 @@ import dlangui.widgets.editors;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.widgets.editors;

View File

@ -22,8 +22,8 @@ import dlangui.widgets.layouts;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.widgets.layouts;

View File

@ -15,8 +15,8 @@ import dlangui.widgets.lists;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.widgets.lists;

View File

@ -5,7 +5,9 @@ DLANGUI library.
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:
@ -15,8 +17,8 @@ import dlangui.widgets.popup;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.widgets.menu;

View File

@ -5,7 +5,9 @@ DLANGUI library.
This module contains popup widgets implementation.
Popups appear above other widgets inside window.
Useful for popup menus, notification popups, etc.
Synopsis:
@ -15,8 +17,8 @@ import dlangui.widgets.popup;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.widgets.popup;

View File

@ -5,6 +5,8 @@ DLANGUI library.
This module contains declaration of themes and styles implementation.
Style - style container
Theme - parent for all styles
Synopsis:
@ -15,43 +17,63 @@ import dlangui.widgets.styles;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.widgets.styles;
import dlangui.core.types;
import dlangui.graphics.fonts;
import dlangui.graphics.drawbuf;
//import dlangui.graphics.images;
import dlangui.graphics.resources;
immutable ubyte ALIGN_UNSPECIFIED = 0;
immutable uint COLOR_UNSPECIFIED = 0xFFDEADFF;
/// transparent color constant
immutable uint COLOR_TRANSPARENT = 0xFFFFFFFF;
/// unspecified font size constant - to take parent style property value
immutable ushort FONT_SIZE_UNSPECIFIED = 0xFFFF;
/// unspecified font weight constant - to take parent style property value
immutable ushort FONT_WEIGHT_UNSPECIFIED = 0x0000;
/// unspecified font style constant - to take parent style property value
immutable ubyte FONT_STYLE_UNSPECIFIED = 0xFF;
/// normal font style constant
immutable ubyte FONT_STYLE_NORMAL = 0x00;
/// italic font style constant
immutable ubyte FONT_STYLE_ITALIC = 0x01;
/// use as widget.layout() param to avoid applying of parent size
immutable int SIZE_UNSPECIFIED = int.max;
/// use text flags from parent style
immutable uint TEXT_FLAGS_UNSPECIFIED = uint.max;
/// use text flags from parent widget
immutable uint TEXT_FLAGS_USE_PARENT = uint.max - 1;
/// layout option, to occupy all available place
immutable int FILL_PARENT = int.max - 1;
/// layout option, for size based on content
immutable int WRAP_CONTENT = int.max - 2;
/// to take layout weight from parent
immutable int WEIGHT_UNSPECIFIED = -1;
/// Align option bit constants
enum Align : ubyte {
/// alignment is not specified
Unspecified = ALIGN_UNSPECIFIED,
/// horizontally align to the left of box
Left = 1,
Right = 2,
HCenter = 1 | 2,
Top = 4,
Bottom = 8,
VCenter = 4 | 8,
Center = VCenter | HCenter,
/// horizontally align to the right of box
Right = 2,
/// horizontally align to the center of box
HCenter = 1 | 2,
/// vertically align to the top of box
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,
}
@ -67,6 +89,7 @@ enum TextFlag : uint {
Underline = 8
}
/// custom drawable attribute container for styles
class DrawableAttribute {
protected string _id;
protected string _drawableId;
@ -143,6 +166,7 @@ class Style {
@property string id() const { return _id; }
/// access to parent style for this style
@property const(Style) parentStyle() const {
if (_parentStyle !is null)
return _parentStyle;
@ -151,6 +175,7 @@ class Style {
return currentTheme;
}
/// access to parent style for this style
@property Style parentStyle() {
if (_parentStyle !is null)
return _parentStyle;
@ -686,7 +711,9 @@ class Theme : Style {
/// to access current theme
private __gshared Theme _currentTheme;
/// current theme accessor
@property Theme currentTheme() { return _currentTheme; }
/// set new current theme
@property void currentTheme(Theme theme) {
if (_currentTheme !is null) {
destroy(_currentTheme);

View File

@ -5,6 +5,10 @@ DLANGUI library.
This module contains declaration of tabbed view controls.
TabItemWidget - single tab header in tab control
TabWidget
TabHost
TabControl
Synopsis:
@ -15,8 +19,8 @@ import dlangui.widgets.tabs;
----
Copyright: Vadim Lopatin, 2014
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.widgets.tabs;
@ -28,6 +32,7 @@ interface TabHandler {
void onTabChanged(string newActiveTabId, string previousTabId);
}
/// tab item metadata
class TabItem {
private string _iconRes;
private string _id;
@ -54,6 +59,7 @@ class TabItem {
void updateAccessTs() { _lastAccessTs = std.datetime.Clock.currStdTime; }
}
/// tab item widget - to show tab header
class TabItemWidget : HorizontalLayout {
private ImageWidget _icon;
private TextWidget _label;
@ -162,6 +168,7 @@ class TabItemList {
}
}
/// tab header - tab labels, with optional More button
class TabControl : WidgetGroup {
protected TabItemList _items;
protected ImageButton _moreButton;

View File

@ -5,6 +5,13 @@ DLANGUI library.
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:
@ -12,11 +19,21 @@ Synopsis:
----
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
License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
Authors: $(WEB coolreader.org, Vadim Lopatin)
License: Boost License 1.0
Authors: Vadim Lopatin, coolreader.org@gmail.com
*/
module dlangui.widgets.widget;
@ -24,12 +41,10 @@ public import dlangui.core.types;
public import dlangui.core.events;
public import dlangui.widgets.styles;
public import dlangui.graphics.drawbuf;
//public import dlangui.graphics.images;
public import dlangui.graphics.resources;
public import dlangui.graphics.fonts;
public import dlangui.core.i18n;
//public import std.signals;
public import dlangui.core.signals;
import dlangui.platforms.common.platform;
@ -334,11 +349,12 @@ class Widget {
/// get text flags (bit set of TextFlag enum values)
@property uint textFlags() {
uint res = stateStyle.textFlags;
if (res == TEXT_FLAGS_USE_PARENT)
if (res == TEXT_FLAGS_USE_PARENT) {
if (parent)
res = parent.textFlags;
else
res = 0;
}
if (res & TextFlag.UnderlineHotKeysWhenAltPressed) {
uint modifiers = 0;
if (window !is null)