Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lists and grid widget #609

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/dlangui/widgets/grid.d
Original file line number Diff line number Diff line change
Expand Up @@ -1970,6 +1970,9 @@ class StringGridWidget : StringGridWidgetBase {

/// draw cell content
protected override void drawHeaderCell(DrawBuf buf, Rect rc, int col, int row) {
if (_customCellAdapter && _customCellAdapter.isCustomCell(col, row)) {
return _customCellAdapter.drawCell(buf, rc, col, row);
}
if (BACKEND_GUI)
rc.shrink(2, 1);
else
Expand Down
13 changes: 5 additions & 8 deletions src/dlangui/widgets/lists.d
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ class ListWidget : WidgetGroup, OnScrollHandler, OnAdapterChangeHandler {

/// item list is changed
override void onAdapterChange(ListAdapter source) {
_selectedItemIndex = -1;
requestLayout();
}

Expand Down Expand Up @@ -1403,6 +1404,7 @@ class ListWidget : WidgetGroup, OnScrollHandler, OnAdapterChangeHandler {
class StringListWidget : ListWidget {
import std.conv : to;
import std.datetime.stopwatch : StopWatch;

import core.time : dur;
private dstring _searchString;
private StopWatch _stopWatch;
Expand Down Expand Up @@ -1480,15 +1482,10 @@ class StringListWidget : ListWidget {
if (event.action == KeyAction.Text) {
if ( !_stopWatch.running) { _stopWatch.start; }

version(DigitalMars) {
auto timePassed = _stopWatch.peek; //.to!("seconds", float)(); // dtop is std.datetime.to
auto timePassed = _stopWatch.peek; //.to!("seconds", float)(); // dtop is std.datetime.to

if (timePassed > dur!"msecs"(500)) _searchString = ""d;
} else {
auto timePassed = _stopWatch.peek.dto!("seconds", float)(); // dtop is std.datetime.to

if (timePassed > 0.5) _searchString = ""d;
}
if (timePassed > dur!"msecs"(500))
_searchString = ""d;
_searchString ~= to!dchar(event.text.toUTF8);
_stopWatch.reset;

Expand Down