mirror of https://github.com/adamdruppe/arsd.git
stuff
This commit is contained in:
parent
756d775d89
commit
fcdd3123c0
7
color.d
7
color.d
|
@ -1127,3 +1127,10 @@ struct Size {
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Rectangle {
|
||||||
|
int left;
|
||||||
|
int top;
|
||||||
|
int right;
|
||||||
|
int bottom;
|
||||||
|
}
|
||||||
|
|
2
dom.d
2
dom.d
|
@ -75,8 +75,6 @@ import std.string;
|
||||||
|
|
||||||
// the reason this is separated is so I can plug it into D->JS as well, which uses a different base Element class
|
// the reason this is separated is so I can plug it into D->JS as well, which uses a different base Element class
|
||||||
|
|
||||||
import arsd.dom;
|
|
||||||
|
|
||||||
mixin template DomConvenienceFunctions() {
|
mixin template DomConvenienceFunctions() {
|
||||||
|
|
||||||
/// Calls getElementById, but throws instead of returning null if the element is not found. You can also ask for a specific subclass of Element to dynamically cast to, which also throws if it cannot be done.
|
/// Calls getElementById, but throws instead of returning null if the element is not found. You can also ask for a specific subclass of Element to dynamically cast to, which also throws if it cannot be done.
|
||||||
|
|
45
minigui.d
45
minigui.d
|
@ -147,6 +147,9 @@ class DataView : Widget {
|
||||||
|
|
||||||
public import simpledisplay;
|
public import simpledisplay;
|
||||||
|
|
||||||
|
version(Windows)
|
||||||
|
import core.sys.windows.windows;
|
||||||
|
|
||||||
// this is a hack to call the original window procedure on native win32 widgets if our event listener thing prevents default.
|
// this is a hack to call the original window procedure on native win32 widgets if our event listener thing prevents default.
|
||||||
private bool lastDefaultPrevented;
|
private bool lastDefaultPrevented;
|
||||||
|
|
||||||
|
@ -188,7 +191,9 @@ version(Windows) {
|
||||||
Single select, multi select, organization, drag+drop
|
Single select, multi select, organization, drag+drop
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static if(UsingSimpledisplayX11)
|
//static if(UsingSimpledisplayX11)
|
||||||
|
version(win32_widgets) {}
|
||||||
|
else
|
||||||
enum windowBackgroundColor = Color(220, 220, 220);
|
enum windowBackgroundColor = Color(220, 220, 220);
|
||||||
|
|
||||||
private const(char)* toStringzInternal(string s) { return (s ~ '\0').ptr; }
|
private const(char)* toStringzInternal(string s) { return (s ~ '\0').ptr; }
|
||||||
|
@ -483,6 +488,17 @@ version(win32_widgets) {
|
||||||
(*te).parentWindow.focusedWidget = lol;
|
(*te).parentWindow.focusedWidget = lol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(iMessage == WM_CTLCOLORBTN || iMessage == WM_CTLCOLORSTATIC) {
|
||||||
|
SetBkMode(cast(HDC) wParam, TRANSPARENT);
|
||||||
|
return cast(typeof(return))
|
||||||
|
//GetStockObject(NULL_BRUSH);
|
||||||
|
// this is the window background color...
|
||||||
|
GetSysColorBrush(COLOR_3DFACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
auto pos = getChildPositionRelativeToParentOrigin(*te);
|
auto pos = getChildPositionRelativeToParentOrigin(*te);
|
||||||
lastDefaultPrevented = false;
|
lastDefaultPrevented = false;
|
||||||
// try {import std.stdio; writeln(typeid(*te)); } catch(Exception e) {}
|
// try {import std.stdio; writeln(typeid(*te)); } catch(Exception e) {}
|
||||||
|
@ -525,7 +541,7 @@ version(win32_widgets) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
version(Windows)
|
version(win32_widgets)
|
||||||
extern(Windows) BOOL childHandler(HWND hwnd, LPARAM lparam) {
|
extern(Windows) BOOL childHandler(HWND hwnd, LPARAM lparam) {
|
||||||
if(hwnd is null || hwnd in Widget.nativeMapping)
|
if(hwnd is null || hwnd in Widget.nativeMapping)
|
||||||
return true;
|
return true;
|
||||||
|
@ -702,6 +718,14 @@ class Widget {
|
||||||
void delegate(ScreenPainter painter) paint;
|
void delegate(ScreenPainter painter) paint;
|
||||||
|
|
||||||
ScreenPainter draw() {
|
ScreenPainter draw() {
|
||||||
|
int x = this.x, y = this.y;
|
||||||
|
auto parent = this.parent;
|
||||||
|
while(parent) {
|
||||||
|
x += parent.x;
|
||||||
|
y += parent.y;
|
||||||
|
parent = parent.parent;
|
||||||
|
}
|
||||||
|
|
||||||
auto painter = parentWindow.win.draw();
|
auto painter = parentWindow.win.draw();
|
||||||
painter.originX = x;
|
painter.originX = x;
|
||||||
painter.originY = y;
|
painter.originY = y;
|
||||||
|
@ -914,7 +938,7 @@ class Window : Widget {
|
||||||
|
|
||||||
if(recipient !is null) {
|
if(recipient !is null) {
|
||||||
// import std.stdio; writeln(typeid(recipient));
|
// import std.stdio; writeln(typeid(recipient));
|
||||||
version(Windows) {
|
version(win32_widgets) {
|
||||||
if(recipient.hwnd !is null)
|
if(recipient.hwnd !is null)
|
||||||
SetFocus(recipient.hwnd);
|
SetFocus(recipient.hwnd);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1530,6 +1554,8 @@ class ProgressBar : Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Fieldset : Widget {
|
class Fieldset : Widget {
|
||||||
|
// FIXME: on Windows,it doesn't draw the background on the label
|
||||||
|
// on X, it doesn't fix the clipping rectangle for it
|
||||||
version(win32_widgets)
|
version(win32_widgets)
|
||||||
override int paddingTop() { return Window.lineHeight; }
|
override int paddingTop() { return Window.lineHeight; }
|
||||||
else
|
else
|
||||||
|
@ -2089,6 +2115,13 @@ class TextEdit : Widget {
|
||||||
painter.drawText(Point(4, 4), content, Point(width - 4, height - 4));
|
painter.drawText(Point(4, 4), content, Point(width - 4, height - 4));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
caratTimer = new Timer(500, {
|
||||||
|
auto painter = this.draw();
|
||||||
|
painter.pen = Pen(Color.white, 1);
|
||||||
|
painter.rasterOp = RasterOp.xor;
|
||||||
|
painter.drawLine(Point(16, 0), Point(16, 16));
|
||||||
|
});
|
||||||
|
|
||||||
defaultEventHandlers["click"] = delegate (Widget _this, Event ev) {
|
defaultEventHandlers["click"] = delegate (Widget _this, Event ev) {
|
||||||
this.focus();
|
this.focus();
|
||||||
};
|
};
|
||||||
|
@ -2127,6 +2160,12 @@ class TextEdit : Widget {
|
||||||
assert(parentWindow !is null);
|
assert(parentWindow !is null);
|
||||||
parentWindow.focusedWidget = this;
|
parentWindow.focusedWidget = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version(win32_widgets) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Timer caratTimer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,20 @@
|
||||||
// subsystem too, use `-L/subsystem:windows -L/entry:mainCRTStartup`
|
// subsystem too, use `-L/subsystem:windows -L/entry:mainCRTStartup`
|
||||||
/*
|
/*
|
||||||
FIXME:
|
FIXME:
|
||||||
|
|
||||||
|
Text layout needs a lot of work. Plain drawText is useful but too
|
||||||
|
limited. It will need some kind of text context thing which it will
|
||||||
|
update and you can pass it on and get more details out of it.
|
||||||
|
|
||||||
|
It will need a bounding box, a current cursor location that is updated
|
||||||
|
as drawing continues, and various changable facts (which can also be
|
||||||
|
changed on the painter i guess) like font, color, size, background,
|
||||||
|
etc.
|
||||||
|
|
||||||
|
We can also fetch the carat location from it somehow.
|
||||||
|
|
||||||
|
Should prolly be an overload of drawText
|
||||||
|
|
||||||
blink taskbar / demand attention cross platform. FlashWindow and demandAttention
|
blink taskbar / demand attention cross platform. FlashWindow and demandAttention
|
||||||
|
|
||||||
WS_EX_NOACTIVATE
|
WS_EX_NOACTIVATE
|
||||||
|
@ -2224,6 +2238,41 @@ struct ScreenPainter {
|
||||||
impl.drawText(upperLeft.x, upperLeft.y, lowerRight.x, lowerRight.y, text, alignment);
|
impl.drawText(upperLeft.x, upperLeft.y, lowerRight.x, lowerRight.y, text, alignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct TextDrawingContext {
|
||||||
|
Point boundingBoxUpperLeft;
|
||||||
|
Point boundingBoxLowerRight;
|
||||||
|
|
||||||
|
Point currentLocation;
|
||||||
|
|
||||||
|
Point lastDrewUpperLeft;
|
||||||
|
Point lastDrewLowerRight;
|
||||||
|
|
||||||
|
// how do i do right aligned rich text?
|
||||||
|
// i kinda want to do a pre-made drawing then right align
|
||||||
|
// draw the whole block.
|
||||||
|
//
|
||||||
|
// That's exactly the diff: inline vs block stuff.
|
||||||
|
|
||||||
|
// I need to get coordinates of an inline section out too,
|
||||||
|
// not just a bounding box, but a series of bounding boxes
|
||||||
|
// should be ok. Consider what's needed to detect a click
|
||||||
|
// on a link in the middle of a paragraph breaking a line.
|
||||||
|
//
|
||||||
|
// Generally, we should be able to get the rectangles of
|
||||||
|
// any portion we draw.
|
||||||
|
//
|
||||||
|
// It also needs to tell what text is left if it overflows
|
||||||
|
// out of the box, so we can do stuff like float images around
|
||||||
|
// it. It should not attempt to draw a letter that would be
|
||||||
|
// clipped.
|
||||||
|
//
|
||||||
|
// I might also turn off word wrap stuff.
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawText(TextDrawingContext context, string text, uint alignment = 0) {
|
||||||
|
// FIXME
|
||||||
|
}
|
||||||
|
|
||||||
/// Drawing an individual pixel is slow. Avoid it if possible.
|
/// Drawing an individual pixel is slow. Avoid it if possible.
|
||||||
void drawPixel(Point where) {
|
void drawPixel(Point where) {
|
||||||
transform(where);
|
transform(where);
|
||||||
|
@ -3622,6 +3671,12 @@ version(Windows) {
|
||||||
//case WM_ERASEBKGND:
|
//case WM_ERASEBKGND:
|
||||||
// no need since we double buffer
|
// no need since we double buffer
|
||||||
//break;
|
//break;
|
||||||
|
case WM_CTLCOLORBTN:
|
||||||
|
case WM_CTLCOLORSTATIC:
|
||||||
|
SetBkMode(cast(HDC) wParam, TRANSPARENT);
|
||||||
|
return cast(typeof(return)) //GetStockObject(NULL_BRUSH);
|
||||||
|
GetSysColorBrush(COLOR_3DFACE);
|
||||||
|
break;
|
||||||
case WM_PAINT: {
|
case WM_PAINT: {
|
||||||
BITMAP bm;
|
BITMAP bm;
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
|
@ -3860,6 +3915,8 @@ version(X11) {
|
||||||
void dispose() {
|
void dispose() {
|
||||||
auto buffer = this.window.impl.buffer;
|
auto buffer = this.window.impl.buffer;
|
||||||
|
|
||||||
|
this.rasterOp = RasterOp.normal;
|
||||||
|
|
||||||
// FIXME: this.window.width/height is probably wrong
|
// FIXME: this.window.width/height is probably wrong
|
||||||
|
|
||||||
// src x,y then dest x, y
|
// src x,y then dest x, y
|
||||||
|
@ -4361,6 +4418,7 @@ version(X11) {
|
||||||
|
|
||||||
// FIXME: windowType and customizationFlags
|
// FIXME: windowType and customizationFlags
|
||||||
|
|
||||||
|
try
|
||||||
final switch(windowType) {
|
final switch(windowType) {
|
||||||
case WindowTypes.normal:
|
case WindowTypes.normal:
|
||||||
setNetWMWindowType(GetAtom!"_NET_WM_WINDOW_TYPE_NORMAL"(display));
|
setNetWMWindowType(GetAtom!"_NET_WM_WINDOW_TYPE_NORMAL"(display));
|
||||||
|
@ -4411,6 +4469,10 @@ version(X11) {
|
||||||
break;
|
break;
|
||||||
+/
|
+/
|
||||||
}
|
}
|
||||||
|
catch(Exception e) {
|
||||||
|
// XInternAtom failed, prolly a WM
|
||||||
|
// that doesn't support these things
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue