mirror of https://github.com/adamdruppe/arsd.git
more osx foundation
This commit is contained in:
parent
4bb8a042a0
commit
354c2ccc8c
28
minigui.d
28
minigui.d
|
@ -1,11 +1,15 @@
|
||||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb775498%28v=vs.85%29.aspx
|
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb775498%28v=vs.85%29.aspx
|
||||||
|
|
||||||
|
// FIXME: clear the corner of scrollbars if they pop up
|
||||||
|
|
||||||
// minigui needs to have a stdout redirection for gui mode on windows writeln
|
// minigui needs to have a stdout redirection for gui mode on windows writeln
|
||||||
|
|
||||||
// I kinda wanna do state reacting. sort of. idk tho
|
// I kinda wanna do state reacting. sort of. idk tho
|
||||||
|
|
||||||
// need a viewer widget that works like a web page - arrows scroll down consistently
|
// need a viewer widget that works like a web page - arrows scroll down consistently
|
||||||
|
|
||||||
|
// I want a nanovega widget, and a svg widget with some kind of event handlers attached to the inside.
|
||||||
|
|
||||||
// FIXME: the menus should be a bit more discoverable, at least a single click to open the others instead of two.
|
// FIXME: the menus should be a bit more discoverable, at least a single click to open the others instead of two.
|
||||||
// and help info about menu items.
|
// and help info about menu items.
|
||||||
// and search in menus?
|
// and search in menus?
|
||||||
|
@ -47,7 +51,7 @@
|
||||||
on Windows and does its own thing on Linux (Mac is not currently supported but
|
on Windows and does its own thing on Linux (Mac is not currently supported but
|
||||||
may be later, and should use native controls) to keep size down. The Linux
|
may be later, and should use native controls) to keep size down. The Linux
|
||||||
appearance is similar to Windows 95 and avoids using images to maintain network
|
appearance is similar to Windows 95 and avoids using images to maintain network
|
||||||
efficiency on remote X connections.
|
efficiency on remote X connections, though you can customize that.
|
||||||
|
|
||||||
minigui's only required dependencies are [arsd.simpledisplay] and [arsd.color].
|
minigui's only required dependencies are [arsd.simpledisplay] and [arsd.color].
|
||||||
|
|
||||||
|
@ -2024,7 +2028,7 @@ class ScrollableWidget : Widget {
|
||||||
///
|
///
|
||||||
void verticalScrollTo(int pos) {
|
void verticalScrollTo(int pos) {
|
||||||
scrollOrigin_.y = pos;
|
scrollOrigin_.y = pos;
|
||||||
if(scrollOrigin_.y + viewportHeight > contentHeight)
|
if(pos == int.max || (scrollOrigin_.y + viewportHeight > contentHeight))
|
||||||
scrollOrigin_.y = contentHeight - viewportHeight;
|
scrollOrigin_.y = contentHeight - viewportHeight;
|
||||||
|
|
||||||
if(scrollOrigin_.y < 0)
|
if(scrollOrigin_.y < 0)
|
||||||
|
@ -2050,7 +2054,7 @@ class ScrollableWidget : Widget {
|
||||||
///
|
///
|
||||||
void horizontalScrollTo(int pos) {
|
void horizontalScrollTo(int pos) {
|
||||||
scrollOrigin_.x = pos;
|
scrollOrigin_.x = pos;
|
||||||
if(scrollOrigin_.x + viewportWidth > contentWidth)
|
if(pos == int.max || (scrollOrigin_.x + viewportWidth > contentWidth))
|
||||||
scrollOrigin_.x = contentWidth - viewportWidth;
|
scrollOrigin_.x = contentWidth - viewportWidth;
|
||||||
|
|
||||||
if(scrollOrigin_.x < 0)
|
if(scrollOrigin_.x < 0)
|
||||||
|
@ -5562,8 +5566,22 @@ abstract class EditableTextWidget : EditableTextWidgetParent {
|
||||||
auto cbb = textLayout.contentBoundingBox();
|
auto cbb = textLayout.contentBoundingBox();
|
||||||
setContentSize(cbb.width, cbb.height);
|
setContentSize(cbb.width, cbb.height);
|
||||||
|
|
||||||
} else
|
} else version(win32_widgets) {
|
||||||
content = content ~ txt;
|
// get the current selection
|
||||||
|
DWORD StartPos, EndPos;
|
||||||
|
SendMessageW( hwnd, EM_GETSEL, cast(WPARAM)(&StartPos), cast(WPARAM)(&EndPos) );
|
||||||
|
|
||||||
|
// move the caret to the end of the text
|
||||||
|
int outLength = GetWindowTextLengthW( hwndOutput );
|
||||||
|
SendMessageW( hwnd, EM_SETSEL, outLength, outLength );
|
||||||
|
|
||||||
|
// insert the text at the new caret position
|
||||||
|
WCharzBuffer bfr = WCharzBuffer(txt, WindowsStringConversionFlags.convertNewLines);
|
||||||
|
SendMessageW( hwnd, EM_REPLACESEL, TRUE, txt );
|
||||||
|
|
||||||
|
// restore the previous selection
|
||||||
|
SendMessageW( hwnd, EM_SETSEL, StartPos, EndPos );
|
||||||
|
} else static assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
version(custom_widgets)
|
version(custom_widgets)
|
||||||
|
|
|
@ -979,6 +979,14 @@ version(FreeBSD)
|
||||||
version(Solaris)
|
version(Solaris)
|
||||||
version = X11;
|
version = X11;
|
||||||
|
|
||||||
|
|
||||||
|
void featureNotImplemented()() {
|
||||||
|
version(allow_unimplemented_features)
|
||||||
|
throw new NotYetImplementedException();
|
||||||
|
else
|
||||||
|
static assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
// these are so the static asserts don't trigger unless you want to
|
// these are so the static asserts don't trigger unless you want to
|
||||||
// add support to it for an OS
|
// add support to it for an OS
|
||||||
version(Windows)
|
version(Windows)
|
||||||
|
@ -1163,7 +1171,7 @@ TrueColorImage trueColorImageFromNativeHandle(NativeWindowHandle handle, int wid
|
||||||
} else version(Windows) {
|
} else version(Windows) {
|
||||||
// I just need to BitBlt that shit... BUT WAIT IT IS ALREADY IN A DIB!!!!!!!
|
// I just need to BitBlt that shit... BUT WAIT IT IS ALREADY IN A DIB!!!!!!!
|
||||||
|
|
||||||
} else static assert(0);
|
} else featureNotImplemented();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1303,7 +1311,7 @@ class SimpleWindow : CapableOfHandlingNativeEvent, CapableOfBeingDrawnUpon {
|
||||||
display = XDisplayConnection.get(); // get initial display to not segfault
|
display = XDisplayConnection.get(); // get initial display to not segfault
|
||||||
} else version(OSXCocoa)
|
} else version(OSXCocoa)
|
||||||
throw new NotYetImplementedException();
|
throw new NotYetImplementedException();
|
||||||
else static assert(0);
|
else featureNotImplemented();
|
||||||
// FIXME: set the size correctly
|
// FIXME: set the size correctly
|
||||||
_width = 1;
|
_width = 1;
|
||||||
_height = 1;
|
_height = 1;
|
||||||
|
@ -1989,7 +1997,7 @@ class SimpleWindow : CapableOfHandlingNativeEvent, CapableOfBeingDrawnUpon {
|
||||||
} else version(Windows) {
|
} else version(Windows) {
|
||||||
impl.currentCursor = ch;
|
impl.currentCursor = ch;
|
||||||
SetCursor(ch); // redraw without waiting for mouse movement to update
|
SetCursor(ch); // redraw without waiting for mouse movement to update
|
||||||
} else static assert(0);
|
} else featureNotImplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2577,7 +2585,7 @@ static struct GenericCursor {
|
||||||
case GenericCursorType.SizeWe: osId = 108 /* XC_sb_h_double_arrow */; break;
|
case GenericCursorType.SizeWe: osId = 108 /* XC_sb_h_double_arrow */; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else static assert(0);
|
} else featureNotImplemented();
|
||||||
|
|
||||||
mc = new MouseCursor(osId);
|
mc = new MouseCursor(osId);
|
||||||
}
|
}
|
||||||
|
@ -3975,7 +3983,7 @@ class Timer {
|
||||||
ev.data.fd = fd;
|
ev.data.fd = fd;
|
||||||
ep.epoll_ctl(epollFd, ep.EPOLL_CTL_ADD, fd, &ev);
|
ep.epoll_ctl(epollFd, ep.EPOLL_CTL_ADD, fd, &ev);
|
||||||
}
|
}
|
||||||
} else static assert(0);
|
} else featureNotImplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stop and destroy the timer object.
|
/// Stop and destroy the timer object.
|
||||||
|
@ -4007,7 +4015,7 @@ class Timer {
|
||||||
mapping.remove(fd);
|
mapping.remove(fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
}
|
}
|
||||||
} else static assert(0);
|
} else featureNotImplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
~this() {
|
~this() {
|
||||||
|
@ -4041,7 +4049,7 @@ class Timer {
|
||||||
unix.read(fd, &val, val.sizeof); // gotta clear the pipe
|
unix.read(fd, &val, val.sizeof); // gotta clear the pipe
|
||||||
} else version(Windows) {
|
} else version(Windows) {
|
||||||
|
|
||||||
} else static assert(0);
|
} else featureNotImplemented();
|
||||||
|
|
||||||
onPulse();
|
onPulse();
|
||||||
}
|
}
|
||||||
|
@ -13605,6 +13613,9 @@ mixin template ExperimentalTextComponent() {
|
||||||
if(selectionStart is selectionEnd)
|
if(selectionStart is selectionEnd)
|
||||||
return; // no selection
|
return; // no selection
|
||||||
|
|
||||||
|
if(selectionStart.inlineElement is null) return;
|
||||||
|
if(selectionEnd.inlineElement is null) return;
|
||||||
|
|
||||||
assert(selectionStart.inlineElement !is null);
|
assert(selectionStart.inlineElement !is null);
|
||||||
assert(selectionEnd.inlineElement !is null);
|
assert(selectionEnd.inlineElement !is null);
|
||||||
|
|
||||||
|
@ -13809,6 +13820,9 @@ mixin template ExperimentalTextComponent() {
|
||||||
if(selectionStart is selectionEnd)
|
if(selectionStart is selectionEnd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(selectionStart.inlineElement is null) return;
|
||||||
|
if(selectionEnd.inlineElement is null) return;
|
||||||
|
|
||||||
assert(selectionStart.inlineElement !is null);
|
assert(selectionStart.inlineElement !is null);
|
||||||
assert(selectionEnd.inlineElement !is null);
|
assert(selectionEnd.inlineElement !is null);
|
||||||
|
|
||||||
|
@ -14081,7 +14095,7 @@ enum _NET_WM_STATE_ADD = 1;
|
||||||
enum _NET_WM_STATE_REMOVE = 0;
|
enum _NET_WM_STATE_REMOVE = 0;
|
||||||
enum _NET_WM_STATE_TOGGLE = 2;
|
enum _NET_WM_STATE_TOGGLE = 2;
|
||||||
|
|
||||||
/// X-specific
|
/// X-specific. Use [SimpleWindow.requestAttention] instead for most casesl
|
||||||
void demandAttention(SimpleWindow window, bool needs = true) {
|
void demandAttention(SimpleWindow window, bool needs = true) {
|
||||||
auto display = XDisplayConnection.get();
|
auto display = XDisplayConnection.get();
|
||||||
auto atom = XInternAtom(display, "_NET_WM_STATE_DEMANDS_ATTENTION", true);
|
auto atom = XInternAtom(display, "_NET_WM_STATE_DEMANDS_ATTENTION", true);
|
||||||
|
|
Loading…
Reference in New Issue