mirror of https://github.com/buggins/dlangui.git
fix DrawBuf.fill behavior - apply clipping rectangle
This commit is contained in:
parent
a147dd2fee
commit
a6a818a884
|
@ -70,11 +70,11 @@
|
||||||
<doXGeneration>1</doXGeneration>
|
<doXGeneration>1</doXGeneration>
|
||||||
<xfilename>$(IntDir)\$(TargetName).json</xfilename>
|
<xfilename>$(IntDir)\$(TargetName).json</xfilename>
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids />
|
<debugids>DebugFocus FontResources</debugids>
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>EmbedStandardResources Unicode USE_FREETYPE</versionids>
|
<versionids>EmbedStandardResources Unicode USE_FREETYPE</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
<mapverbosity>3</mapverbosity>
|
<mapverbosity>0</mapverbosity>
|
||||||
<createImplib>0</createImplib>
|
<createImplib>0</createImplib>
|
||||||
<defaultlibname />
|
<defaultlibname />
|
||||||
<debuglibname />
|
<debuglibname />
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
<objfiles />
|
<objfiles />
|
||||||
<linkswitches />
|
<linkswitches />
|
||||||
<libfiles>dlangui.lib phobos.lib ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib shell32.lib</libfiles>
|
<libfiles>dlangui.lib phobos.lib ole32.lib kernel32.lib user32.lib comctl32.lib comdlg32.lib shell32.lib</libfiles>
|
||||||
<libpaths>../../Debug ../../../DerelictOpenGL3/source</libpaths>
|
<libpaths>../../Debug</libpaths>
|
||||||
<deffile />
|
<deffile />
|
||||||
<resfile />
|
<resfile />
|
||||||
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
<exefile>$(OutDir)\$(ProjectName).exe</exefile>
|
||||||
|
|
|
@ -190,6 +190,7 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
|
|
||||||
// always use trace, even for release builds
|
// always use trace, even for release builds
|
||||||
Log.setLogLevel(LogLevel.Trace);
|
Log.setLogLevel(LogLevel.Trace);
|
||||||
|
Log.setFileLogger(std.stdio.File("ui.log", "w"));
|
||||||
|
|
||||||
// resource directory search paths
|
// resource directory search paths
|
||||||
// not required if only embedded resources are used
|
// not required if only embedded resources are used
|
||||||
|
@ -875,6 +876,7 @@ void main()
|
||||||
CanvasWidget canvas = new CanvasWidget("canvas");
|
CanvasWidget canvas = new CanvasWidget("canvas");
|
||||||
canvas.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
canvas.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
||||||
canvas.onDrawListener = delegate(CanvasWidget canvas, DrawBuf buf, Rect rc) {
|
canvas.onDrawListener = delegate(CanvasWidget canvas, DrawBuf buf, Rect rc) {
|
||||||
|
Log.w("canvas.onDrawListener clipRect=" ~ to!string(buf.clipRect));
|
||||||
buf.fill(0xFFFFFF);
|
buf.fill(0xFFFFFF);
|
||||||
int x = rc.left;
|
int x = rc.left;
|
||||||
int y = rc.top;
|
int y = rc.top;
|
||||||
|
|
|
@ -21,7 +21,6 @@ public import dlangui.core.types;
|
||||||
import dlangui.core.logger;
|
import dlangui.core.logger;
|
||||||
import dlangui.graphics.colors;
|
import dlangui.graphics.colors;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 9-patch image scaling information (see Android documentation).
|
* 9-patch image scaling information (see Android documentation).
|
||||||
*
|
*
|
||||||
|
@ -120,6 +119,9 @@ class DrawBuf : RefCountedObject {
|
||||||
void resetClipping() {
|
void resetClipping() {
|
||||||
_clipRect = Rect(0, 0, width, height);
|
_clipRect = Rect(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
@property bool hasClipping() {
|
||||||
|
return _clipRect.left != 0 || _clipRect.top != 0 || _clipRect.right != width || _clipRect.bottom != height;
|
||||||
|
}
|
||||||
/// returns clipping rectangle, when clipRect.isEmpty == true -- means no clipping.
|
/// returns clipping rectangle, when clipRect.isEmpty == true -- means no clipping.
|
||||||
@property ref Rect clipRect() { return _clipRect; }
|
@property ref Rect clipRect() { return _clipRect; }
|
||||||
/// returns clipping rectangle, or (0,0,dx,dy) when no clipping.
|
/// returns clipping rectangle, or (0,0,dx,dy) when no clipping.
|
||||||
|
@ -736,6 +738,10 @@ class GrayDrawBuf : DrawBuf {
|
||||||
resetClipping();
|
resetClipping();
|
||||||
}
|
}
|
||||||
override void fill(uint color) {
|
override void fill(uint color) {
|
||||||
|
if (hasClipping) {
|
||||||
|
fillRect(_clipRect, color);
|
||||||
|
return;
|
||||||
|
}
|
||||||
int len = _dx * _dy;
|
int len = _dx * _dy;
|
||||||
ubyte * p = _buf.ptr;
|
ubyte * p = _buf.ptr;
|
||||||
ubyte cl = rgbToGray(color);
|
ubyte cl = rgbToGray(color);
|
||||||
|
@ -961,6 +967,10 @@ class ColorDrawBuf : ColorDrawBufBase {
|
||||||
resetClipping();
|
resetClipping();
|
||||||
}
|
}
|
||||||
override void fill(uint color) {
|
override void fill(uint color) {
|
||||||
|
if (hasClipping) {
|
||||||
|
fillRect(_clipRect, color);
|
||||||
|
return;
|
||||||
|
}
|
||||||
int len = _dx * _dy;
|
int len = _dx * _dy;
|
||||||
uint * p = _buf.ptr;
|
uint * p = _buf.ptr;
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
|
|
|
@ -90,6 +90,10 @@ class GLDrawBuf : DrawBuf, GLConfigCallback {
|
||||||
|
|
||||||
/// fill the whole buffer with solid color (no clipping applied)
|
/// fill the whole buffer with solid color (no clipping applied)
|
||||||
override void fill(uint color) {
|
override void fill(uint color) {
|
||||||
|
if (hasClipping) {
|
||||||
|
fillRect(_clipRect, color);
|
||||||
|
return;
|
||||||
|
}
|
||||||
assert(_scene !is null);
|
assert(_scene !is null);
|
||||||
_scene.add(new SolidRectSceneItem(Rect(0, 0, _dx, _dy), applyAlpha(color)));
|
_scene.add(new SolidRectSceneItem(Rect(0, 0, _dx, _dy), applyAlpha(color)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,6 +149,10 @@ class Win32ColorDrawBuf : ColorDrawBufBase {
|
||||||
}
|
}
|
||||||
/// fill with solid color
|
/// fill with solid color
|
||||||
override void fill(uint color) {
|
override void fill(uint color) {
|
||||||
|
if (hasClipping) {
|
||||||
|
fillRect(_clipRect, color);
|
||||||
|
return;
|
||||||
|
}
|
||||||
int len = _dx * _dy;
|
int len = _dx * _dy;
|
||||||
//for (int i = 0; i < len; i++)
|
//for (int i = 0; i < len; i++)
|
||||||
// _pixels[i] = color;
|
// _pixels[i] = color;
|
||||||
|
|
Loading…
Reference in New Issue