Merge branch 'master' of github.com:adamdruppe/arsd

This commit is contained in:
Adam D. Ruppe 2018-11-10 21:33:53 -05:00
commit 1ef9c79f69
2 changed files with 77 additions and 42 deletions

View File

@ -531,8 +531,18 @@ class DataView : Widget {
//static if(UsingSimpledisplayX11) //static if(UsingSimpledisplayX11)
version(win32_widgets) {} version(win32_widgets) {}
else version(custom_widgets) else version(custom_widgets) {
enum windowBackgroundColor = Color(192, 192, 192); enum windowBackgroundColor = Color(212, 212, 212); // used to be 192
enum darkAccentColor = Color(172, 172, 172);
enum lightAccentColor = Color(223, 223, 223); // used to be 223
enum activeTabColor = lightAccentColor;
enum activeListXorColor = Color(255, 255, 0);
enum hoveringColor = Color(215, 215, 215);
enum buttonColor = windowBackgroundColor;
enum depressedButtonColor = darkAccentColor;
enum progressBarColor = Color.blue;
enum activeMenuItemColor = Color.blue;
}
else static assert(false); else static assert(false);
private const(wchar)* toWstringzInternal(in char[] s) { private const(wchar)* toWstringzInternal(in char[] s) {
@ -561,13 +571,13 @@ void draw3dFrame(int x, int y, int width, int height, ScreenPainter painter, Fra
painter.fillColor = background; painter.fillColor = background;
painter.drawRectangle(Point(x + 0, y + 0), width, height); painter.drawRectangle(Point(x + 0, y + 0), width, height);
painter.outlineColor = (style == FrameStyle.sunk) ? Color(128, 128, 128) : Color(223, 223, 223); painter.outlineColor = (style == FrameStyle.sunk) ? darkAccentColor : lightAccentColor;
painter.drawLine(Point(x + 0, y + 0), Point(x + width, y + 0)); painter.drawLine(Point(x + 0, y + 0), Point(x + width, y + 0));
painter.drawLine(Point(x + 0, y + 0), Point(x + 0, y + height - 1)); painter.drawLine(Point(x + 0, y + 0), Point(x + 0, y + height - 1));
// inner layer // inner layer
//right, bottom //right, bottom
painter.outlineColor = (style == FrameStyle.sunk) ? Color(223, 223, 223) : Color(128, 128, 128); painter.outlineColor = (style == FrameStyle.sunk) ? lightAccentColor : darkAccentColor;
painter.drawLine(Point(x + width - 2, y + 2), Point(x + width - 2, y + height - 2)); painter.drawLine(Point(x + width - 2, y + 2), Point(x + width - 2, y + height - 2));
painter.drawLine(Point(x + 2, y + height - 2), Point(x + width - 2, y + height - 2)); painter.drawLine(Point(x + 2, y + height - 2), Point(x + width - 2, y + height - 2));
// left, top // left, top
@ -1673,7 +1683,7 @@ class ListWidget : ScrollableWidget {
if(option.selected) { if(option.selected) {
painter.rasterOp = RasterOp.xor; painter.rasterOp = RasterOp.xor;
painter.outlineColor = Color.white; painter.outlineColor = Color.white;
painter.fillColor = Color(255, 255, 0); painter.fillColor = activeListXorColor;
painter.drawRectangle(pos, width - 8, Window.lineHeight); painter.drawRectangle(pos, width - 8, Window.lineHeight);
painter.rasterOp = RasterOp.normal; painter.rasterOp = RasterOp.normal;
} }
@ -2389,7 +2399,7 @@ class MouseTrackingWidget : Widget {
painter.fillColor = c; painter.fillColor = c;
painter.drawRectangle(Point(0, 0), this.width, this.height); painter.drawRectangle(Point(0, 0), this.width, this.height);
auto color = hovering ? Color(215, 215, 215) : windowBackgroundColor; auto color = hovering ? hoveringColor : windowBackgroundColor;
draw3dFrame(positionX, positionY, thumbWidth, thumbHeight, painter, FrameStyle.risen, color); draw3dFrame(positionX, positionY, thumbWidth, thumbHeight, painter, FrameStyle.risen, color);
} }
} }
@ -2825,8 +2835,7 @@ class TabWidget : Widget {
painter.outlineColor = Color.white; painter.outlineColor = Color.white;
painter.drawPixel(Point(posX + 1, tabBarHeight - 1)); painter.drawPixel(Point(posX + 1, tabBarHeight - 1));
painter.drawPixel(Point(posX + 1, tabBarHeight - 2)); painter.drawPixel(Point(posX + 1, tabBarHeight - 2));
painter.outlineColor = Color(233, 233, 233); painter.outlineColor = activeTabColor;
//painter.outlineColor = (style == FrameStyle.sunk) ? Color(128, 128, 128) : Color(223, 223, 223);
painter.drawPixel(Point(posX, tabBarHeight - 1)); painter.drawPixel(Point(posX, tabBarHeight - 1));
} }
@ -4016,29 +4025,31 @@ class ToolButton : Button {
); );
break; break;
case GenericIcons.Save: case GenericIcons.Save:
painter.fillColor = Color.black; painter.fillColor = Color.white;
painter.outlineColor = Color.black;
painter.drawRectangle(Point(2, 2) * multiplier / divisor, Point(13, 13) * multiplier / divisor); painter.drawRectangle(Point(2, 2) * multiplier / divisor, Point(13, 13) * multiplier / divisor);
// the label
painter.drawRectangle(Point(4, 8) * multiplier / divisor, Point(11, 13) * multiplier / divisor);
// the slider
painter.fillColor = Color.black;
painter.outlineColor = Color.black;
painter.drawRectangle(Point(4, 3) * multiplier / divisor, Point(10, 6) * multiplier / divisor);
painter.fillColor = Color.white; painter.fillColor = Color.white;
painter.outlineColor = Color.white; painter.outlineColor = Color.white;
// the slider
painter.drawRectangle(Point(5, 2) * multiplier / divisor, Point(10, 5) * multiplier / divisor);
// the label
painter.drawRectangle(Point(4, 8) * multiplier / divisor, Point(11, 12) * multiplier / divisor);
painter.fillColor = Color.black;
painter.outlineColor = Color.black;
// the disc window // the disc window
painter.drawRectangle(Point(8, 3) * multiplier / divisor, Point(9, 4) * multiplier / divisor); painter.drawRectangle(Point(5, 3) * multiplier / divisor, Point(6, 5) * multiplier / divisor);
break; break;
case GenericIcons.Open: case GenericIcons.Open:
painter.fillColor = Color.white; painter.fillColor = Color.white;
painter.drawPolygon( painter.drawPolygon(
Point(3, 4) * multiplier / divisor, Point(3, 12) * multiplier / divisor, Point(14, 12) * multiplier / divisor, Point(14, 3) * multiplier / divisor, Point(3, 4) * multiplier / divisor, Point(3, 12) * multiplier / divisor, Point(13, 12) * multiplier / divisor, Point(13, 3) * multiplier / divisor,
Point(10, 3) * multiplier / divisor, Point(10, 4) * multiplier / divisor, Point(3, 4) * multiplier / divisor); Point(9, 3) * multiplier / divisor, Point(9, 4) * multiplier / divisor, Point(3, 4) * multiplier / divisor);
painter.drawPolygon( painter.drawPolygon(
Point(1, 6) * multiplier / divisor, Point(12, 6) * multiplier / divisor, Point(1, 6) * multiplier / divisor, Point(11, 6) * multiplier / divisor,
Point(14, 12) * multiplier / divisor, Point(3, 12) * multiplier / divisor); Point(13, 12) * multiplier / divisor, Point(3, 12) * multiplier / divisor);
//painter.drawLine(Point(9, 6) * multiplier / divisor, Point(13, 7) * multiplier / divisor); //painter.drawLine(Point(9, 6) * multiplier / divisor, Point(13, 7) * multiplier / divisor);
break; break;
case GenericIcons.Copy: case GenericIcons.Copy:
@ -4308,7 +4319,7 @@ class ProgressBar : Widget {
version(custom_widgets) version(custom_widgets)
override void paint(ScreenPainter painter) { override void paint(ScreenPainter painter) {
this.draw3dFrame(painter, FrameStyle.sunk); this.draw3dFrame(painter, FrameStyle.sunk);
painter.fillColor = Color.blue; painter.fillColor = progressBarColor;
painter.drawRectangle(Point(0, 0), width * current / max, height); painter.drawRectangle(Point(0, 0), width * current / max, height);
} }
@ -4461,9 +4472,9 @@ class HorizontalRule : Widget {
} }
override void paint(ScreenPainter painter) { override void paint(ScreenPainter painter) {
painter.outlineColor = Color(128, 128, 128); painter.outlineColor = darkAccentColor;
painter.drawLine(Point(0, 0), Point(width, 0)); painter.drawLine(Point(0, 0), Point(width, 0));
painter.outlineColor = Color(223, 223, 223); painter.outlineColor = lightAccentColor;
painter.drawLine(Point(0, 1), Point(width, 1)); painter.drawLine(Point(0, 1), Point(width, 1));
} }
} }
@ -4480,9 +4491,9 @@ class VerticalRule : Widget {
} }
override void paint(ScreenPainter painter) { override void paint(ScreenPainter painter) {
painter.outlineColor = Color(128, 128, 128); painter.outlineColor = darkAccentColor;
painter.drawLine(Point(0, 0), Point(0, height)); painter.drawLine(Point(0, 0), Point(0, height));
painter.outlineColor = Color(223, 223, 223); painter.outlineColor = lightAccentColor;
painter.drawLine(Point(1, 0), Point(1, height)); painter.drawLine(Point(1, 0), Point(1, height));
} }
} }
@ -4668,7 +4679,7 @@ class MenuItem : MouseActivatedWidget {
if(isDepressed) if(isDepressed)
this.draw3dFrame(painter, FrameStyle.sunk); this.draw3dFrame(painter, FrameStyle.sunk);
if(isHovering) if(isHovering)
painter.outlineColor = Color.blue; painter.outlineColor = activeMenuItemColor;
else else
painter.outlineColor = Color.black; painter.outlineColor = Color.black;
painter.fillColor = Color.transparent; painter.fillColor = Color.transparent;
@ -5019,9 +5030,9 @@ class Button : MouseActivatedWidget {
width = 50; width = 50;
height = 30; height = 30;
super(parent); super(parent);
normalBgColor = Color(192, 192, 192); normalBgColor = buttonColor;
hoverBgColor = Color(215, 215, 215); hoverBgColor = hoveringColor;
depressedBgColor = Color(160, 160, 160); depressedBgColor = depressedButtonColor;
this.label = label; this.label = label;
} }
@ -5787,7 +5798,7 @@ enum EventType : string {
/// ///
class Event { class Event {
/// /// Creates an event without populating any members and without sending it. See [dispatch]
this(string eventName, Widget target) { this(string eventName, Widget target) {
this.eventName = eventName; this.eventName = eventName;
this.srcElement = target; this.srcElement = target;
@ -5809,19 +5820,19 @@ class Event {
private string eventName; private string eventName;
Widget srcElement; /// Widget srcElement; ///
alias srcElement target; alias srcElement target; ///
Widget relatedTarget; /// Widget relatedTarget; ///
// for mouse events // for mouse events
int clientX; /// int clientX; /// The mouse event location relative to the target widget
int clientY; /// int clientY; /// ditto
int viewportX; /// int viewportX; /// The mouse event location relative to the window origin
int viewportY; /// int viewportY; /// ditto
int button; /// int button; /// [MouseEvent.button]
int buttonLinear; /// int buttonLinear; /// [MouseEvent.buttonLinear]
// for key events // for key events
Key key; /// Key key; ///
@ -6388,17 +6399,23 @@ http://msdn.microsoft.com/en-us/library/windows/desktop/bb760476%28v=vs.85%29.as
// These are all for setMenuAndToolbarFromAnnotatedCode // These are all for setMenuAndToolbarFromAnnotatedCode
/// This item in the menu will be preceded by a separator line /// This item in the menu will be preceded by a separator line
/// Group: generating_from_code
struct separator {} struct separator {}
deprecated("It was misspelled, use separator instead") alias seperator = separator; deprecated("It was misspelled, use separator instead") alias seperator = separator;
/// Program-wide keyboard shortcut to trigger the action /// Program-wide keyboard shortcut to trigger the action
/// Group: generating_from_code
struct accelerator { string keyString; } struct accelerator { string keyString; }
/// tells which menu the action will be on /// tells which menu the action will be on
/// Group: generating_from_code
struct menu { string name; } struct menu { string name; }
/// Describes which toolbar section the action appears on /// Describes which toolbar section the action appears on
/// Group: generating_from_code
struct toolbar { string groupName; } struct toolbar { string groupName; }
/// ///
/// Group: generating_from_code
struct icon { ushort id; } struct icon { ushort id; }
/// ///
/// Group: generating_from_code
struct label { string label; } struct label { string label; }
@ -6406,11 +6423,14 @@ struct label { string label; }
/++ /++
Creates a dialog based on a data structure. Creates a dialog based on a data structure.
---
dialog((YourStructure value) { dialog((YourStructure value) {
// the user filled in the struct and clicked OK, // the user filled in the struct and clicked OK,
// you can check the members now // you can check the members now
}); });
---
+/ +/
/// Group: generating_from_code
void dialog(T)(void delegate(T) onOK, void delegate() onCancel = null) { void dialog(T)(void delegate(T) onOK, void delegate() onCancel = null) {
auto dg = new AutomaticDialog!T(onOK, onCancel); auto dg = new AutomaticDialog!T(onOK, onCancel);
dg.show(); dg.show();

View File

@ -794,6 +794,14 @@ http://msdn.microsoft.com/en-us/library/windows/desktop/ms683193%28v=vs.85%29.as
if(GetConsoleScreenBufferInfo(hConsole, &originalSbi) == 0) if(GetConsoleScreenBufferInfo(hConsole, &originalSbi) == 0)
throw new Exception("not a user-interactive terminal"); throw new Exception("not a user-interactive terminal");
defaultForegroundColor = cast(Color) (originalSbi.wAttributes & 0x0f);
defaultBackgroundColor = cast(Color) ((originalSbi.wAttributes >> 4) & 0x0f);
}
version(Windows) {
private Color defaultBackgroundColor = Color.black;
private Color defaultForegroundColor = Color.white;
} }
// only use this if you are sure you know what you want, since the terminal is a shared resource you generally really want to reset it to normal when you leave... // only use this if you are sure you know what you want, since the terminal is a shared resource you generally really want to reset it to normal when you leave...
@ -930,20 +938,20 @@ http://msdn.microsoft.com/en-us/library/windows/desktop/ms683193%28v=vs.85%29.as
// this isn't necessarily right but meh // this isn't necessarily right but meh
if(background == Color.DEFAULT) if(background == Color.DEFAULT)
setTob = Color.black; setTob = defaultBackgroundColor;
if(foreground == Color.DEFAULT) if(foreground == Color.DEFAULT)
setTof = Color.white; setTof = defaultForegroundColor;
if(force == ForceOption.alwaysSend || reverseVideo != this.reverseVideo || foreground != _currentForeground || background != _currentBackground) { if(force == ForceOption.alwaysSend || reverseVideo != this.reverseVideo || foreground != _currentForeground || background != _currentBackground) {
flush(); // if we don't do this now, the buffering can screw up the colors... flush(); // if we don't do this now, the buffering can screw up the colors...
if(reverseVideo) { if(reverseVideo) {
if(background == Color.DEFAULT) if(background == Color.DEFAULT)
setTof = Color.black; setTof = defaultBackgroundColor;
else else
setTof = cast(ushort) background | (foreground & Bright); setTof = cast(ushort) background | (foreground & Bright);
if(background == Color.DEFAULT) if(background == Color.DEFAULT)
setTob = Color.white; setTob = defaultForegroundColor;
else else
setTob = cast(ushort) (foreground & ~Bright); setTob = cast(ushort) (foreground & ~Bright);
} }
@ -2704,6 +2712,8 @@ void main() {
terminal.write("test some long string to see if it wraps or what because i dont really know what it is going to do so i just want to test i think it will wrap but gotta be sure lolololololololol"); terminal.write("test some long string to see if it wraps or what because i dont really know what it is going to do so i just want to test i think it will wrap but gotta be sure lolololololololol");
terminal.writefln("%d %d", terminal.cursorX, terminal.cursorY); terminal.writefln("%d %d", terminal.cursorX, terminal.cursorY);
terminal.color(Color.DEFAULT, Color.DEFAULT);
int centerX = terminal.width / 2; int centerX = terminal.width / 2;
int centerY = terminal.height / 2; int centerY = terminal.height / 2;
@ -3132,6 +3142,11 @@ class LineGetter {
private int lastDrawLength = 0; private int lastDrawLength = 0;
void redraw() { void redraw() {
terminal.hideCursor();
scope(exit) {
terminal.flush();
terminal.showCursor();
}
terminal.moveTo(startOfLineX, startOfLineY); terminal.moveTo(startOfLineX, startOfLineY);
auto lineLength = availableLineLength(); auto lineLength = availableLineLength();