mirror of https://github.com/buggins/dlangui.git
commit
2184396216
|
@ -103,7 +103,6 @@ ubyte tokenCategory(ubyte t) {
|
|||
dstring[] splitDString(dstring source, dchar delimiter = EOL) {
|
||||
int start = 0;
|
||||
dstring[] res;
|
||||
dchar lastchar;
|
||||
for (int i = 0; i <= source.length; i++) {
|
||||
if (i == source.length || source[i] == delimiter) {
|
||||
if (i >= start) {
|
||||
|
@ -173,10 +172,10 @@ struct TextPosition {
|
|||
return 1;
|
||||
return 0;
|
||||
}
|
||||
inout bool opEquals(ref inout TextPosition v) {
|
||||
bool opEquals(ref inout TextPosition v) inout {
|
||||
return line == v.line && pos == v.pos;
|
||||
}
|
||||
@property string toString() {
|
||||
@property string toString() const {
|
||||
return to!string(line) ~ ":" ~ to!string(pos);
|
||||
}
|
||||
/// adds deltaPos to position and returns result
|
||||
|
@ -212,7 +211,7 @@ struct TextRange {
|
|||
@property int lines() const {
|
||||
return end.line - start.line + 1;
|
||||
}
|
||||
@property string toString() {
|
||||
@property string toString() const {
|
||||
return "[" ~ start.toString ~ ":" ~ end.toString ~ "]";
|
||||
}
|
||||
}
|
||||
|
@ -856,7 +855,7 @@ class EditableContent {
|
|||
|
||||
/// returns text range for whole line lineIndex
|
||||
TextRange lineRange(int lineIndex) {
|
||||
return TextRange(TextPosition(lineIndex, 0), lineIndex < _lines.length - 1 ? lineBegin(lineIndex + 1) : lineEnd(lineIndex));
|
||||
return TextRange(TextPosition(lineIndex, 0), lineIndex < cast(int)_lines.length - 1 ? lineBegin(lineIndex + 1) : lineEnd(lineIndex));
|
||||
}
|
||||
|
||||
/// find nearest next tab position
|
||||
|
|
|
@ -359,8 +359,7 @@ string[] splitPath(string path) {
|
|||
|
||||
/// for executable name w/o path, find absolute path to executable
|
||||
string findExecutablePath(string executableName) {
|
||||
import std.algorithm;
|
||||
import std.string;
|
||||
import std.string : split;
|
||||
version (Windows) {
|
||||
if (!executableName.endsWith(".exe"))
|
||||
executableName = executableName ~ ".exe";
|
||||
|
|
|
@ -280,7 +280,6 @@ synchronized class UIStringTranslator {
|
|||
/** Looks for i18n directory inside one of passed dirs, and uses first found as directory to read i18n files from */
|
||||
void findTranslationsDir(string[] dirs ...) {
|
||||
_resourceDirs.length = 0;
|
||||
import std.file;
|
||||
foreach(dir; dirs) {
|
||||
string path = appendPath(dir, "i18n/");
|
||||
if (exists(path) && isDir(path)) {
|
||||
|
|
|
@ -72,7 +72,7 @@ public enum EncodingType : int {
|
|||
ASCII,
|
||||
/// encoding is unknown
|
||||
UNKNOWN
|
||||
};
|
||||
}
|
||||
/// Line ending style
|
||||
public enum LineEnding : int {
|
||||
/// LF (0x0A) - unix style
|
||||
|
@ -95,7 +95,7 @@ struct TextFileFormat {
|
|||
LineEnding lineEnding;
|
||||
/// byte order mark character flag
|
||||
bool bom;
|
||||
string toString() {
|
||||
string toString() const {
|
||||
return to!string(encoding) ~ " " ~ to!string(lineEnding) ~ (bom ? " bom" : "");
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ class LineStream {
|
|||
public enum ErrorCodes {
|
||||
/// invalid character for current encoding
|
||||
INVALID_CHARACTER
|
||||
};
|
||||
}
|
||||
|
||||
private InputStream _stream;
|
||||
private string _filename;
|
||||
|
@ -596,7 +596,7 @@ private class Utf8LineStream : LineStream {
|
|||
invalidCharFlag = true;
|
||||
break;
|
||||
}
|
||||
ch = ((ch0 & 0x1F) << 6) | ((ch1 & 0x3F));
|
||||
ch = ((ch0 & 0x1F) << 6) | (ch1 & 0x3F);
|
||||
bread = 2;
|
||||
} if ((ch0 & 0xF0) == 0xE0) {
|
||||
// three bytes 1110xxxx 10xxxxxx 10xxxxxx
|
||||
|
@ -608,7 +608,7 @@ private class Utf8LineStream : LineStream {
|
|||
invalidCharFlag = true;
|
||||
break;
|
||||
}
|
||||
ch = ((ch0 & 0x0F) << 12) | ((ch1 & 0x1F) << 6) | ((ch2 & 0x3F));
|
||||
ch = ((ch0 & 0x0F) << 12) | ((ch1 & 0x1F) << 6) | (ch2 & 0x3F);
|
||||
bread = 3;
|
||||
} if ((ch0 & 0xF8) == 0xF0) {
|
||||
// four bytes 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
|
@ -621,7 +621,7 @@ private class Utf8LineStream : LineStream {
|
|||
invalidCharFlag = true;
|
||||
break;
|
||||
}
|
||||
ch = ((ch0 & 0x07) << 18) | ((ch1 & 0x3F) << 12) | ((ch2 & 0x3F) << 6) | ((ch3 & 0x3F));
|
||||
ch = ((ch0 & 0x07) << 18) | ((ch1 & 0x3F) << 12) | ((ch2 & 0x3F) << 6) | (ch3 & 0x3F);
|
||||
bread = 4;
|
||||
} if ((ch0 & 0xFC) == 0xF8) {
|
||||
// five bytes 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
|
@ -635,7 +635,7 @@ private class Utf8LineStream : LineStream {
|
|||
invalidCharFlag = true;
|
||||
break;
|
||||
}
|
||||
ch = ((ch0 & 0x03) << 24) | ((ch1 & 0x3F) << 18) | ((ch2 & 0x3F) << 12) | ((ch3 & 0x3F) << 6) | ((ch4 & 0x3F));
|
||||
ch = ((ch0 & 0x03) << 24) | ((ch1 & 0x3F) << 18) | ((ch2 & 0x3F) << 12) | ((ch3 & 0x3F) << 6) | (ch4 & 0x3F);
|
||||
bread = 5;
|
||||
} if ((ch0 & 0xFE) == 0xFC) {
|
||||
// six bytes 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
|
@ -650,7 +650,7 @@ private class Utf8LineStream : LineStream {
|
|||
invalidCharFlag = true;
|
||||
break;
|
||||
}
|
||||
ch = ((ch0 & 0x01) << 30) | ((ch1 & 0x3F) << 24) | ((ch2 & 0x3F) << 18) | ((ch3 & 0x3F) << 12) | ((ch4 & 0x3F) << 6) | ((ch5 & 0x3F));
|
||||
ch = ((ch0 & 0x01) << 30) | ((ch1 & 0x3F) << 24) | ((ch2 & 0x3F) << 18) | ((ch3 & 0x3F) << 12) | ((ch4 & 0x3F) << 6) | (ch5 & 0x3F);
|
||||
bread = 5;
|
||||
}
|
||||
if ((ch >= 0xd800 && ch < 0xe000) || (ch > 0x10FFFF)) {
|
||||
|
|
|
@ -13,7 +13,7 @@ class SourceFile {
|
|||
public this(string filename) {
|
||||
_filename = filename;
|
||||
}
|
||||
override @property string toString() {
|
||||
override @property string toString() const {
|
||||
return _filename;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ struct Rect {
|
|||
return left >= rc.left && right <= rc.right && top >= rc.top && bottom <= rc.bottom;
|
||||
}
|
||||
|
||||
bool opEquals(Rect rc) {
|
||||
bool opEquals(Rect rc) const {
|
||||
return left == rc.left && right == rc.right && top == rc.top && bottom == rc.bottom;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ class DMLSyntaxSupport : SyntaxSupport {
|
|||
static struct TokenWithRange {
|
||||
Token token;
|
||||
TextRange range;
|
||||
@property string toString() {
|
||||
@property string toString() const {
|
||||
return token.toString ~ range.toString;
|
||||
}
|
||||
}
|
||||
|
@ -431,7 +431,6 @@ class DMLSyntaxSupport : SyntaxSupport {
|
|||
for (int i = range.start.line; i <= range.end.line; i++) {
|
||||
dstring s = content.line(i);
|
||||
int charsRemoved = 0;
|
||||
int minp = 0;
|
||||
if (i == range.start.line) {
|
||||
int maxp = content.lineLength(range.start.line);
|
||||
if (i == range.end.line)
|
||||
|
@ -594,7 +593,6 @@ class DMLSyntaxSupport : SyntaxSupport {
|
|||
if (line == 0)
|
||||
return; // not for first line
|
||||
int prevLine = line - 1;
|
||||
dstring lineText = _content.line(line);
|
||||
TextLineMeasure lineMeasurement = _content.measureLine(line);
|
||||
TextLineMeasure prevLineMeasurement = _content.measureLine(prevLine);
|
||||
while (prevLineMeasurement.empty && prevLine > 0) {
|
||||
|
@ -636,8 +634,6 @@ class DMLSyntaxSupport : SyntaxSupport {
|
|||
if (lineMeasurement.firstNonSpace != op.newRange.start.pos)
|
||||
return; // not in beginning of line
|
||||
if (lineMeasurement.firstNonSpaceX >= 0 && lineMeasurement.firstNonSpaceX != prevLineMeasurement.firstNonSpaceX) {
|
||||
dstring prevLineText = _content.line(prevLine);
|
||||
TokenPropString prevLineTokenProps = _content.lineTokenProps(prevLine);
|
||||
int spacex = prevLineMeasurement.firstNonSpaceX;
|
||||
if (spacex != lineMeasurement.firstNonSpaceX) {
|
||||
dstring txt = _content.fillSpace(spacex);
|
||||
|
|
|
@ -134,7 +134,7 @@ struct Token {
|
|||
int intvalue;
|
||||
double floatvalue;
|
||||
}
|
||||
public @property string toString() {
|
||||
public @property string toString() const {
|
||||
if (type == TokenType.integer)
|
||||
return "" ~ to!string(line) ~ ":" ~ to!string(pos) ~ " " ~ to!string(type) ~ " " ~ to!string(intvalue);
|
||||
else if (type == TokenType.floating)
|
||||
|
@ -163,7 +163,7 @@ class Tokenizer {
|
|||
enum : int {
|
||||
EOF_CHAR = 0x001A,
|
||||
EOL_CHAR = 0x000A
|
||||
};
|
||||
}
|
||||
|
||||
this(string source, string filename = "") {
|
||||
_filename = filename;
|
||||
|
|
|
@ -871,7 +871,6 @@ class GrayDrawBuf : DrawBuf {
|
|||
int srcdx = glyph.blackBoxX;
|
||||
int srcdy = glyph.blackBoxY;
|
||||
bool clipping = true; //!_clipRect.empty();
|
||||
ubyte cl = cast(ubyte)(color & 255);
|
||||
for (int yy = 0; yy < srcdy; yy++) {
|
||||
int liney = y + yy;
|
||||
if (clipping && (liney < _clipRect.top || liney >= _clipRect.bottom))
|
||||
|
@ -1115,4 +1114,4 @@ private bool CohenSutherlandLineClipAndDraw(ref Rect clipRect, ref double x0, re
|
|||
}
|
||||
}
|
||||
return accept;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -886,7 +886,7 @@ struct glyph_gamma_table(int maxv = 65)
|
|||
private:
|
||||
ubyte[maxv] _map;
|
||||
double _gamma = 1.0;
|
||||
};
|
||||
}
|
||||
|
||||
__gshared glyph_gamma_table!65 _gamma65;
|
||||
__gshared glyph_gamma_table!256 _gamma256;
|
||||
|
|
|
@ -554,7 +554,7 @@ class FreeTypeFontManager : FontManager {
|
|||
Log.v("DerelictFT: Missing symbols callback is registered");
|
||||
DerelictFT.load();
|
||||
Log.v("DerelictFT: Loaded");
|
||||
} catch (Throwable e) {
|
||||
} catch (Exception e) {
|
||||
Log.e("Derelict: cannot load freetype shared library: ", e.msg);
|
||||
throw new Exception("Cannot load freetype library");
|
||||
}
|
||||
|
|
|
@ -554,7 +554,7 @@ private class GLImageCache {
|
|||
removePage(item.page);
|
||||
}
|
||||
_map.remove(objectId);
|
||||
delete item;
|
||||
destroy(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -659,7 +659,6 @@ private class GLGlyphCache {
|
|||
return;
|
||||
}
|
||||
//Log.d("updateTexture for font glyph page - setting image ", _drawbuf.width, "x", _drawbuf.height, " tx=", _texture.ID);
|
||||
int len = _drawbuf.width * _drawbuf.height;
|
||||
if (!glSupport.setTextureImage(_texture, _drawbuf.width, _drawbuf.height, cast(ubyte *)_drawbuf.scanLine(0))) {
|
||||
destroy(_texture);
|
||||
_texture = null;
|
||||
|
@ -839,7 +838,7 @@ private class GLGlyphCache {
|
|||
removePage(item.page);
|
||||
}
|
||||
_map.remove(objectId);
|
||||
delete item;
|
||||
destroy(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -924,8 +923,7 @@ public:
|
|||
}
|
||||
override void draw() {
|
||||
if (_handler) {
|
||||
import derelict.opengl3.gl3;
|
||||
import derelict.opengl3.gl;
|
||||
import derelict.opengl3.gl3 : glViewport;
|
||||
glViewport(_rc.left, _rc.top, _rc.right, _rc.bottom);
|
||||
_handler(_buf, _rc);
|
||||
glSupport.setOrthoProjection(Rect(0, 0, _buf.width, _buf.height));
|
||||
|
|
|
@ -103,14 +103,19 @@ class GLProgram {
|
|||
private void compatibilityFixes(ref char[] code, GLuint type) {
|
||||
if (glslversionInt < 150) {
|
||||
code = replace(code, " texture(", " texture2D(");
|
||||
code = replace(code, "in ", "");
|
||||
code = replace(code, "out ", "");
|
||||
}
|
||||
if(type == GL_VERTEX_SHADER)
|
||||
{
|
||||
code = replace(code, "in ", "attribute ");
|
||||
code = replace(code, "out ", "varying ");
|
||||
} else
|
||||
{
|
||||
code = replace(code, "in ", "varying ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GLuint compileShader(string src, GLuint type) {
|
||||
import core.stdc.stdlib;
|
||||
import std.string;
|
||||
import std.string : toStringz, fromStringz;
|
||||
|
||||
char[] sourceCode;
|
||||
sourceCode ~= "#version ";
|
||||
|
@ -202,10 +207,6 @@ class GLProgram {
|
|||
}
|
||||
}
|
||||
|
||||
immutable string HIGHP = "";
|
||||
immutable string LOWP = "";
|
||||
immutable string MEDIUMP = "";
|
||||
|
||||
class SolidFillProgram : GLProgram {
|
||||
@property override string vertexSource() {
|
||||
return q{
|
||||
|
@ -698,8 +699,8 @@ class GLSupport {
|
|||
|
||||
// don't flip for framebuffer
|
||||
if (currentFBO) {
|
||||
dsty0 = cast(float)((yy));
|
||||
dsty1 = cast(float)((yy + dy));
|
||||
dsty0 = cast(float)(yy);
|
||||
dsty1 = cast(float)(yy + dy);
|
||||
}
|
||||
|
||||
float srcx0 = srcx / cast(float)tdx;
|
||||
|
@ -763,8 +764,8 @@ class GLSupport {
|
|||
|
||||
// don't flip for framebuffer
|
||||
if (currentFBO) {
|
||||
dsty0 = cast(float)((yy));
|
||||
dsty1 = cast(float)((yy + dy));
|
||||
dsty0 = cast(float)(yy);
|
||||
dsty1 = cast(float)(yy + dy);
|
||||
}
|
||||
|
||||
float srcx0 = srcx / cast(float)tdx;
|
||||
|
|
|
@ -69,7 +69,7 @@ ColorDrawBuf loadImage(immutable ubyte[] data, string filename) {
|
|||
|
||||
import std.algorithm : endsWith;
|
||||
if (filename.endsWith(".xpm")) {
|
||||
import dlangui.graphics.xpm.reader;
|
||||
import dlangui.graphics.xpm.reader : parseXPM;
|
||||
try {
|
||||
return parseXPM(data);
|
||||
}
|
||||
|
@ -104,7 +104,6 @@ ColorDrawBuf loadImage(immutable ubyte[] data, string filename) {
|
|||
return null;
|
||||
}
|
||||
} else version (USE_DLIBIMAGE) {
|
||||
import std.algorithm;
|
||||
static import dlib.core.stream;
|
||||
try {
|
||||
version (ENABLE_DLIBIMAGE_JPEG) {
|
||||
|
@ -138,7 +137,6 @@ ColorDrawBuf loadImage(immutable ubyte[] data, string filename) {
|
|||
return null;
|
||||
}
|
||||
} else version (USE_DIMAGE) {
|
||||
import std.algorithm;
|
||||
static import dimage.stream;
|
||||
try {
|
||||
SuperImage image = null;
|
||||
|
|
|
@ -458,7 +458,6 @@ class ImageDrawable : Drawable {
|
|||
//Log.d("drawing nine patch image with frame ", p.frame, " padding ", p.padding);
|
||||
int w = width;
|
||||
int h = height;
|
||||
Rect dstrect = rc;
|
||||
Rect srcrect = Rect(1, 1, w + 1, h + 1);
|
||||
if (true) { //buf.applyClipping(dstrect, srcrect)) {
|
||||
int x0 = srcrect.left;
|
||||
|
@ -737,9 +736,6 @@ class StateDrawable : Drawable {
|
|||
|
||||
/// load from XML file
|
||||
bool load(string filename) {
|
||||
import std.file;
|
||||
import std.string;
|
||||
|
||||
try {
|
||||
string s = cast(string)loadResourceBytes(filename);
|
||||
if (!s) {
|
||||
|
|
|
@ -19,7 +19,8 @@ struct XPMPredefinedColor
|
|||
return cmp(name, str);
|
||||
}
|
||||
///ditto
|
||||
const int opBinaryRight(string op)(in char[] str) if (op == "<") {
|
||||
int opBinaryRight(string op)(in char[] str) const
|
||||
if (op == "<") {
|
||||
return cmp(str, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ class TimerInfo {
|
|||
protected long _nextTimestamp;
|
||||
protected Widget _targetWidget;
|
||||
|
||||
override bool opEquals(Object obj) {
|
||||
override bool opEquals(Object obj) const {
|
||||
TimerInfo b = cast(TimerInfo)obj;
|
||||
if (!b)
|
||||
return false;
|
||||
|
@ -653,7 +653,6 @@ class Window {
|
|||
//Log.d("addTracking ", w.id, " items after: ", _mouseTrackingWidgets.length);
|
||||
}
|
||||
private bool checkRemoveTracking(MouseEvent event) {
|
||||
import std.algorithm;
|
||||
bool res = false;
|
||||
for(int i = cast(int)_mouseTrackingWidgets.length - 1; i >=0; i--) {
|
||||
Widget w = _mouseTrackingWidgets[i];
|
||||
|
|
|
@ -1548,7 +1548,6 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
|||
Log.d("text entered: ", event.text);
|
||||
if (readOnly)
|
||||
return true;
|
||||
dchar ch = event.text[0];
|
||||
if (replaceMode && _selectionRange.empty && _content[_caretPos.line].length >= _caretPos.pos + event.text.length) {
|
||||
// replace next char(s)
|
||||
TextRange range = _selectionRange;
|
||||
|
|
|
@ -909,7 +909,7 @@ class ListWidget : WidgetGroup, OnScrollHandler, OnAdapterChangeHandler {
|
|||
if (_scrollPosition < 0)
|
||||
_scrollPosition = 0;
|
||||
if (_needScrollbar) {
|
||||
if (_orientation == Orientation.Vertical) {
|
||||
if (_orientation == Orientation.Vertical) { // FIXME:
|
||||
_scrollbar.position = _scrollPosition;
|
||||
} else {
|
||||
_scrollbar.position = _scrollPosition;
|
||||
|
@ -1105,7 +1105,7 @@ class ListWidget : WidgetGroup, OnScrollHandler, OnAdapterChangeHandler {
|
|||
if (itemEnabled(i))
|
||||
setHoverItem(i);
|
||||
}
|
||||
if ((event.button == MouseFlag.LButton || event.button == MouseFlag.RButton)) {
|
||||
if (event.button == MouseFlag.LButton || event.button == MouseFlag.RButton) {
|
||||
if ((_clickOnButtonDown && event.action == MouseAction.ButtonDown) || (!_clickOnButtonDown && event.action == MouseAction.ButtonUp)) {
|
||||
if (itemEnabled(i)) {
|
||||
itemClicked(i);
|
||||
|
|
|
@ -39,7 +39,7 @@ WidgetSignalMetadata[] getSignalList(alias T)() {
|
|||
// skip non-public members
|
||||
static if (__traits(getProtection, __traits(getMember, T, m)) == "public") {
|
||||
static if (__traits(compiles, __traits(getMember, T, m).params_t ) && __traits(compiles, __traits(getMember, T, m).return_t)) {
|
||||
alias typeof(__traits(getMember, T, m)) ti;
|
||||
alias ti = typeof(__traits(getMember, T, m));
|
||||
res ~= WidgetSignalMetadata(m,
|
||||
__traits(getMember, T, m).return_t.stringof ~ __traits(getMember, T, m).params_t.stringof,
|
||||
typeid(__traits(getMember, T, m).return_t),
|
||||
|
|
|
@ -1354,9 +1354,6 @@ bool loadTheme(Theme theme, Element doc, int level = 0) {
|
|||
/// load theme from file
|
||||
bool loadTheme(Theme theme, string resourceId, int level = 0) {
|
||||
|
||||
import std.file;
|
||||
import std.string;
|
||||
|
||||
string filename;
|
||||
try {
|
||||
filename = drawableCache.findResource(resourceId);
|
||||
|
|
|
@ -222,7 +222,6 @@ class TabItemList {
|
|||
}
|
||||
/// find tab index by id
|
||||
int indexById(string id) const {
|
||||
import std.algorithm;
|
||||
for (int i = 0; i < _len; i++) {
|
||||
if (_list[i].id.equal(id))
|
||||
return i;
|
||||
|
|
|
@ -799,7 +799,7 @@ class Widget {
|
|||
bool nearY(TabOrderInfo v) {
|
||||
return v.rect.top >= rect.top - NEAR_THRESHOLD && v.rect.top <= rect.top + NEAR_THRESHOLD;
|
||||
}
|
||||
override int opCmp(Object obj) {
|
||||
override int opCmp(Object obj) const {
|
||||
TabOrderInfo v = cast(TabOrderInfo)obj;
|
||||
if (tabOrder != 0 && v.tabOrder !=0) {
|
||||
if (tabOrder < v.tabOrder)
|
||||
|
@ -832,7 +832,7 @@ class Widget {
|
|||
}
|
||||
return obj1.rect.left < obj2.rect.left;
|
||||
}
|
||||
override string toString() {
|
||||
override string toString() const {
|
||||
return widget.id;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue