mirror of https://github.com/buggins/dlangui.git
tab widget
This commit is contained in:
parent
091a5b15ab
commit
48242a1af7
|
@ -328,6 +328,7 @@
|
||||||
<File path="src\dlangui\widgets\layouts.d" />
|
<File path="src\dlangui\widgets\layouts.d" />
|
||||||
<File path="src\dlangui\widgets\lists.d" />
|
<File path="src\dlangui\widgets\lists.d" />
|
||||||
<File path="src\dlangui\widgets\styles.d" />
|
<File path="src\dlangui\widgets\styles.d" />
|
||||||
|
<File path="src\dlangui\widgets\tabs.d" />
|
||||||
<File path="src\dlangui\widgets\widget.d" />
|
<File path="src\dlangui\widgets\widget.d" />
|
||||||
</Folder>
|
</Folder>
|
||||||
<File path="src\dlangui\all.d" />
|
<File path="src\dlangui\all.d" />
|
||||||
|
|
|
@ -48,6 +48,18 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
|
|
||||||
static if (true) {
|
static if (true) {
|
||||||
LinearLayout layout = new LinearLayout();
|
LinearLayout layout = new LinearLayout();
|
||||||
|
|
||||||
|
TabWidget tabs = new TabWidget("TABS");
|
||||||
|
tabs.addTab("id1", "Tab 1"d);
|
||||||
|
tabs.addTab("id2", "Tab 2 label"d);
|
||||||
|
tabs.addTab("id3", "Tab 3 label"d);
|
||||||
|
tabs.addTab("id4", "Tab 4 label"d);
|
||||||
|
tabs.addTab("id5", "Tab 5 label"d);
|
||||||
|
tabs.addTab("id6", "Tab 6 label"d);
|
||||||
|
tabs.addTab("id7", "Tab 7 label"d);
|
||||||
|
tabs.addTab("id8", "Tab 8 label"d);
|
||||||
|
layout.addChild(tabs);
|
||||||
|
|
||||||
layout.addChild((new TextWidget()).textColor(0x00802000).text("Text widget 0"));
|
layout.addChild((new TextWidget()).textColor(0x00802000).text("Text widget 0"));
|
||||||
layout.addChild((new TextWidget()).textColor(0x40FF4000).text("Text widget"));
|
layout.addChild((new TextWidget()).textColor(0x40FF4000).text("Text widget"));
|
||||||
layout.addChild((new Button("BTN1")).textResource("EXIT")); //.textColor(0x40FF4000)
|
layout.addChild((new Button("BTN1")).textResource("EXIT")); //.textColor(0x40FF4000)
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 347 B |
Binary file not shown.
After Width: | Height: | Size: 333 B |
|
@ -8,5 +8,6 @@ public import dlangui.widgets.widget;
|
||||||
public import dlangui.widgets.controls;
|
public import dlangui.widgets.controls;
|
||||||
public import dlangui.widgets.layouts;
|
public import dlangui.widgets.layouts;
|
||||||
public import dlangui.widgets.lists;
|
public import dlangui.widgets.lists;
|
||||||
|
public import dlangui.widgets.tabs;
|
||||||
public import dlangui.graphics.fonts;
|
public import dlangui.graphics.fonts;
|
||||||
public import dlangui.core.i18n;
|
public import dlangui.core.i18n;
|
||||||
|
|
|
@ -6,9 +6,21 @@ import std.utf;
|
||||||
/// container for UI string - either raw value or string resource ID
|
/// container for UI string - either raw value or string resource ID
|
||||||
struct UIString {
|
struct UIString {
|
||||||
/// if not null, use it, otherwise lookup by id
|
/// if not null, use it, otherwise lookup by id
|
||||||
dstring _value;
|
private dstring _value;
|
||||||
/// id to find value in translator
|
/// id to find value in translator
|
||||||
string _id;
|
private string _id;
|
||||||
|
|
||||||
|
/// create string with i18n resource id
|
||||||
|
this(string id) {
|
||||||
|
_id = id;
|
||||||
|
}
|
||||||
|
/// create string with raw value
|
||||||
|
this(dstring value) {
|
||||||
|
_value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@property string id() const { return _id; }
|
@property string id() const { return _id; }
|
||||||
@property void id(string ID) {
|
@property void id(string ID) {
|
||||||
_id = ID;
|
_id = ID;
|
||||||
|
@ -145,13 +157,14 @@ class UIStringList {
|
||||||
}
|
}
|
||||||
return count > 0;
|
return count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// load strings from file (utf8, id=value lines)
|
/// load strings from file (utf8, id=value lines)
|
||||||
bool load(string filename) {
|
bool load(string filename) {
|
||||||
import std.stream;
|
import std.stream;
|
||||||
import std.file;
|
import std.file;
|
||||||
try {
|
try {
|
||||||
Log.d("Loading string resources from file ", filename);
|
Log.d("Loading string resources from file ", filename);
|
||||||
if (!exists(filename) && isFile(filename)) {
|
if (!exists(filename) || !isFile(filename)) {
|
||||||
Log.e("File does not exist: ", filename);
|
Log.e("File does not exist: ", filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,12 @@ class TextWidget : Widget {
|
||||||
requestLayout();
|
requestLayout();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
/// set text to show
|
||||||
|
@property Widget text(ref UIString s) {
|
||||||
|
_text = s;
|
||||||
|
requestLayout();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
/// set text resource ID to show
|
/// set text resource ID to show
|
||||||
@property Widget textResource(string s) {
|
@property Widget textResource(string s) {
|
||||||
_text = s;
|
_text = s;
|
||||||
|
@ -575,9 +581,3 @@ class ScrollBar : AbstractSlider, OnClickHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TabItem {
|
|
||||||
}
|
|
||||||
|
|
||||||
class TabWidget {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module dlangui.widgets.layouts;
|
module dlangui.widgets.layouts;
|
||||||
|
|
||||||
import dlangui.widgets.widget;
|
public import dlangui.widgets.widget;
|
||||||
|
|
||||||
/// helper for layouts
|
/// helper for layouts
|
||||||
struct LayoutItem {
|
struct LayoutItem {
|
||||||
|
|
|
@ -536,7 +536,7 @@ struct WidgetList {
|
||||||
protected Widget[] _list;
|
protected Widget[] _list;
|
||||||
protected int _count;
|
protected int _count;
|
||||||
/// returns count of items
|
/// returns count of items
|
||||||
@property int count() { return _count; }
|
@property int count() const { return _count; }
|
||||||
/// get item by index
|
/// get item by index
|
||||||
Widget get(int index) {
|
Widget get(int index) {
|
||||||
assert(index >= 0 && index < _count, "child index out of range");
|
assert(index >= 0 && index < _count, "child index out of range");
|
||||||
|
@ -549,6 +549,18 @@ struct WidgetList {
|
||||||
_list[_count++] = item;
|
_list[_count++] = item;
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
/// add item to list
|
||||||
|
Widget insert(Widget item, int index = -1) {
|
||||||
|
if (index > _count || index < 0)
|
||||||
|
index = _count;
|
||||||
|
if (_list.length <= _count) // resize
|
||||||
|
_list.length = _list.length < 4 ? 4 : _list.length * 2;
|
||||||
|
for (int i = _count; i > index; i--)
|
||||||
|
_list[i] = _list[i - 1];
|
||||||
|
_list[index] = item;
|
||||||
|
_count++;
|
||||||
|
return item;
|
||||||
|
}
|
||||||
/// find child index for item, return -1 if not found
|
/// find child index for item, return -1 if not found
|
||||||
int indexOf(Widget item) {
|
int indexOf(Widget item) {
|
||||||
for (int i = 0; i < _count; i++)
|
for (int i = 0; i < _count; i++)
|
||||||
|
|
Loading…
Reference in New Issue