Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 466addb

Browse files
committed
[[ Compiler ]] Added widget module to bootstrap phase.
[[ Engine ]] Added 'widget' module. [[ Engine ]] Added 'redraw all' syntax.
1 parent 20b2c82 commit 466addb

File tree

6 files changed

+45
-21
lines changed

6 files changed

+45
-21
lines changed

engine/engine.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@
296296
4D79B8991A36050800DD750C /* sysunxthreads.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B8981A3604F200DD750C /* sysunxthreads.cpp */; };
297297
4D79B89B1A36055B00DD750C /* platform-recorder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B89A1A36054900DD750C /* platform-recorder.cpp */; };
298298
4D79B89D1A36058300DD750C /* image_rep_densitymapped.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B89C1A36057400DD750C /* image_rep_densitymapped.cpp */; };
299+
4D79B8AD1A37118900DD750C /* widget.mlc in Sources */ = {isa = PBXBuildFile; fileRef = 4D79B8AA1A37104800DD750C /* widget.mlc */; };
299300
4D7FA7BF1594E10500EEF440 /* libfoundation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D7FA7BB1594E0FA00EEF440 /* libfoundation.a */; };
300301
4D7FA7C71594E17500EEF440 /* exec-datetime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D7FA7C61594E17500EEF440 /* exec-datetime.cpp */; };
301302
4D81A4C411171F6B008AE3F1 /* objectprops.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D81A4C111171F6A008AE3F1 /* objectprops.cpp */; };
@@ -1901,6 +1902,7 @@
19011902
4D79B8981A3604F200DD750C /* sysunxthreads.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sysunxthreads.cpp; path = src/sysunxthreads.cpp; sourceTree = "<group>"; };
19021903
4D79B89A1A36054900DD750C /* platform-recorder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "platform-recorder.cpp"; path = "src/platform-recorder.cpp"; sourceTree = "<group>"; };
19031904
4D79B89C1A36057400DD750C /* image_rep_densitymapped.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = image_rep_densitymapped.cpp; path = src/image_rep_densitymapped.cpp; sourceTree = "<group>"; };
1905+
4D79B8AA1A37104800DD750C /* widget.mlc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = widget.mlc; path = src/widget.mlc; sourceTree = "<group>"; };
19041906
4D7FA7B61594E0FA00EEF440 /* libfoundation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = libfoundation.xcodeproj; path = ../libfoundation/libfoundation.xcodeproj; sourceTree = SOURCE_ROOT; };
19051907
4D7FA7C61594E17500EEF440 /* exec-datetime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "exec-datetime.cpp"; path = "src/exec-datetime.cpp"; sourceTree = "<group>"; };
19061908
4D81A4C111171F6A008AE3F1 /* objectprops.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = objectprops.cpp; path = src/objectprops.cpp; sourceTree = "<group>"; };
@@ -3022,6 +3024,7 @@
30223024
4D79B7291A275A7C00DD750C /* Modules */ = {
30233025
isa = PBXGroup;
30243026
children = (
3027+
4D79B8AA1A37104800DD750C /* widget.mlc */,
30253028
4D79B7301A275ADE00DD750C /* canvas.mlc */,
30263029
4D79B72E1A275AA500DD750C /* module-canvas.cpp */,
30273030
E8A1AD001A27799B0078F401 /* module-canvas.h */,
@@ -4969,6 +4972,7 @@
49694972
isa = PBXSourcesBuildPhase;
49704973
buildActionMask = 2147483647;
49714974
files = (
4975+
4D79B8AD1A37118900DD750C /* widget.mlc in Sources */,
49724976
4D79B89D1A36058300DD750C /* image_rep_densitymapped.cpp in Sources */,
49734977
4D79B89B1A36055B00DD750C /* platform-recorder.cpp in Sources */,
49744978
4D79B8991A36050800DD750C /* sysunxthreads.cpp in Sources */,

engine/library_test.livecode

-45 Bytes
Binary file not shown.

engine/src/widget.cpp

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@
4545

4646
#include "widget-events.h"
4747

48+
////////////////////////////////////////////////////////////////////////////////
49+
50+
void MCCanvasPush(MCGContextRef gcontext, uintptr_t& r_cookie);
51+
void MCCanvasPop(uintptr_t p_cookie);
4852

4953
////////////////////////////////////////////////////////////////////////////////
5054

51-
MCGContextRef MCwidgetcontext;
5255
MCWidget *MCwidgetobject;
5356

5457
////////////////////////////////////////////////////////////////////////////////
@@ -94,19 +97,6 @@ MCWidget::~MCWidget(void)
9497

9598
MCWidget* MCWidget::createInstanceOfKind(MCNameRef p_kind)
9699
{
97-
// Force-load the module
98-
static bool s_loaded = false;
99-
if (!s_loaded)
100-
{
101-
IO_handle h;
102-
MCStreamRef s;
103-
MCScriptModuleRef t_ignored;
104-
h = MCS_open(MCSTR("/Users/frasergordon/Workspace/LiveCode/livecode-8-priv/toolchain/lc-compile/foo.lcm"), kMCOpenFileModeRead, True, False, 0);
105-
MCMemoryInputStreamCreate(h->GetFilePointer(), h->GetFileSize(), s);
106-
MCScriptCreateModuleFromStream(s, t_ignored);
107-
s_loaded = true;
108-
}
109-
110100
// Attempt to look-up the module for the given kind and ensure that all of
111101
// its dependencies have been satisfied.
112102
MCScriptModuleRef t_module;
@@ -618,13 +608,19 @@ void MCWidget::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
618608
}
619609
}
620610

621-
MCwidgetcontext = ((MCGraphicsContext *)dc) -> getgcontextref();
622-
MCGContextSave(MCwidgetcontext);
623-
MCGContextSetShouldAntialias(MCwidgetcontext, true);
624-
MCGContextTranslateCTM(MCwidgetcontext, rect . x, rect . y);
611+
MCGContextRef t_gcontext;
612+
t_gcontext = ((MCGraphicsContext *)dc) -> getgcontextref();
613+
614+
MCGContextSave(t_gcontext);
615+
MCGContextSetShouldAntialias(t_gcontext, true);
616+
MCGContextTranslateCTM(t_gcontext, rect . x, rect . y);
617+
618+
uintptr_t t_cookie;
619+
MCCanvasPush(t_gcontext, t_cookie);
625620
MCwidgeteventmanager->event_draw(this, dc, dirty, p_isolated, p_sprite);
626-
MCGContextRestore(MCwidgetcontext);
627-
MCwidgetcontext = nil;
621+
MCCanvasPop(t_cookie);
622+
623+
MCGContextRestore(t_gcontext);
628624

629625
if (!p_isolated)
630626
{
@@ -750,6 +746,8 @@ void MCWidget::OnPaint(MCDC* p_dc, const MCRectangle& p_rect)
750746
{
751747
if (m_native_layer)
752748
m_native_layer->OnPaint(p_dc, p_rect);
749+
else
750+
CallHandler(MCNAME("OnPaint"), nil, 0);
753751

754752
fprintf(stderr, "MCWidget::OnPaint\n");
755753
}
@@ -1196,3 +1194,13 @@ void MCWidget::GetKind(MCExecContext& ctxt, MCNameRef& r_kind)
11961194
}
11971195

11981196
////////////////////////////////////////////////////////////////////////////////
1197+
1198+
extern "C" void MCWidgetExecRedrawAll(void)
1199+
{
1200+
if (MCwidgetobject == nil)
1201+
return; // TODO - throw an error.
1202+
1203+
MCwidgetobject -> layer_redrawall();
1204+
}
1205+
1206+
////////////////////////////////////////////////////////////////////////////////

engine/src/widget.mlc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module com.livecode.widget
2+
3+
public foreign handler MCWidgetExecRedrawAll() as undefined binds to "<builtin>"
4+
5+
syntax RedrawAll is statement
6+
"redraw" "all"
7+
begin
8+
MCWidgetExecRedrawAll()
9+
end syntax
10+
11+
end module

engine/widget_test.livecode

3.32 KB
Binary file not shown.

toolchain/lc-compile/lc-compile.xcodeproj/project.pbxproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,14 +844,15 @@
844844
"$(SRCROOT)/../../libscript/src/sort.mlc",
845845
"$(SRCROOT)/../../libscript/src/array.mlc",
846846
"$(SRCROOT)/../../engine/src/canvas.mlc",
847+
"$(SRCROOT)/../../engine/src/widget.mlc",
847848
);
848849
name = Bootstrap;
849850
outputPaths = (
850851
"$(SRCROOT)/src/grammar_full.g",
851852
);
852853
runOnlyForDeploymentPostprocessing = 0;
853854
shellPath = /bin/sh;
854-
shellScript = "cd src\nmkdir -p \"_G_\"\n\"${BUILT_PRODUCTS_DIR}/lc-bootstrap-compile\" -bootstrap -template \"${SRCROOT}/src/grammar.g\" -output \"${SRCROOT}/src/grammar_full.g\" \"${SRCROOT}/../../libscript/src/string.mlc\" \"${SRCROOT}/../../libscript/src/binary.mlc\" \"${SRCROOT}/../../libscript/src/arithmetic.mlc\" \"${SRCROOT}/../../libscript/src/bitwise.mlc\" \"${SRCROOT}/../../libscript/src/byte.mlc\" \"${SRCROOT}/../../libscript/src/char.mlc\" \"${SRCROOT}/../../libscript/src/list.mlc\" \"${SRCROOT}/../../libscript/src/type-convert.mlc\" \"${SRCROOT}/../../libscript/src/logic.mlc\" \"${SRCROOT}/../../libscript/src/sort.mlc\" \"${SRCROOT}/../../libscript/src/array.mlc\" \"${SRCROOT}/../../engine/src/canvas.mlc\"\nif [ \"$?\" != \"0\" ]; then exit 1; fi\n";
855+
shellScript = "cd src\nmkdir -p \"_G_\"\n\"${BUILT_PRODUCTS_DIR}/lc-bootstrap-compile\" -bootstrap -template \"${SRCROOT}/src/grammar.g\" -output \"${SRCROOT}/src/grammar_full.g\" \"${SRCROOT}/../../libscript/src/string.mlc\" \"${SRCROOT}/../../libscript/src/binary.mlc\" \"${SRCROOT}/../../libscript/src/arithmetic.mlc\" \"${SRCROOT}/../../libscript/src/bitwise.mlc\" \"${SRCROOT}/../../libscript/src/byte.mlc\" \"${SRCROOT}/../../libscript/src/char.mlc\" \"${SRCROOT}/../../libscript/src/list.mlc\" \"${SRCROOT}/../../libscript/src/type-convert.mlc\" \"${SRCROOT}/../../libscript/src/logic.mlc\" \"${SRCROOT}/../../libscript/src/sort.mlc\" \"${SRCROOT}/../../libscript/src/array.mlc\" \"${SRCROOT}/../../engine/src/widget.mlc\" \"${SRCROOT}/../../engine/src/canvas.mlc\"\nif [ \"$?\" != \"0\" ]; then exit 1; fi\n";
855856
showEnvVarsInLog = 0;
856857
};
857858
/* End PBXShellScriptBuildPhase section */

0 commit comments

Comments
 (0)