# HG changeset patch # User John Tsiombikas # Date 1442976298 -10800 # Node ID 3bccfc7d10fe1e08f5f8eae7e5634a30ee46b7bf # Parent 6a39b89127520721fb39dcdf91c64e3cdcb2609e goatkit is drawing diff -r 6a39b8912752 -r 3bccfc7d10fe istereo.xcodeproj/project.pbxproj --- a/istereo.xcodeproj/project.pbxproj Tue Sep 22 07:13:47 2015 +0300 +++ b/istereo.xcodeproj/project.pbxproj Wed Sep 23 05:44:58 2015 +0300 @@ -7,6 +7,21 @@ objects = { /* Begin PBXBuildFile section */ + 060ECAD41BB1A9CC00CE9B80 /* boolanm.cc in Sources */ = {isa = PBXBuildFile; fileRef = 060ECAC91BB1A9CC00CE9B80 /* boolanm.cc */; settings = {ASSET_TAGS = (); }; }; + 060ECAD51BB1A9CC00CE9B80 /* button.cc in Sources */ = {isa = PBXBuildFile; fileRef = 060ECACB1BB1A9CC00CE9B80 /* button.cc */; settings = {ASSET_TAGS = (); }; }; + 060ECAD71BB1A9CC00CE9B80 /* event.cc in Sources */ = {isa = PBXBuildFile; fileRef = 060ECACD1BB1A9CC00CE9B80 /* event.cc */; settings = {ASSET_TAGS = (); }; }; + 060ECAD91BB1A9CC00CE9B80 /* screen.cc in Sources */ = {isa = PBXBuildFile; fileRef = 060ECACF1BB1A9CC00CE9B80 /* screen.cc */; settings = {ASSET_TAGS = (); }; }; + 060ECADA1BB1A9CC00CE9B80 /* slider.cc in Sources */ = {isa = PBXBuildFile; fileRef = 060ECAD01BB1A9CC00CE9B80 /* slider.cc */; settings = {ASSET_TAGS = (); }; }; + 060ECADB1BB1A9CC00CE9B80 /* textbox.cc in Sources */ = {isa = PBXBuildFile; fileRef = 060ECAD11BB1A9CC00CE9B80 /* textbox.cc */; settings = {ASSET_TAGS = (); }; }; + 060ECADC1BB1A9CC00CE9B80 /* theme.cc in Sources */ = {isa = PBXBuildFile; fileRef = 060ECAD21BB1A9CC00CE9B80 /* theme.cc */; settings = {ASSET_TAGS = (); }; }; + 060ECADD1BB1A9CC00CE9B80 /* widget.cc in Sources */ = {isa = PBXBuildFile; fileRef = 060ECAD31BB1A9CC00CE9B80 /* widget.cc */; settings = {ASSET_TAGS = (); }; }; + 060ECAEB1BB1AA5200CE9B80 /* checkbox.cc in Sources */ = {isa = PBXBuildFile; fileRef = 060ECADF1BB1AA5200CE9B80 /* checkbox.cc */; settings = {ASSET_TAGS = (); }; }; + 060ECAEC1BB1AA5200CE9B80 /* label.cc in Sources */ = {isa = PBXBuildFile; fileRef = 060ECAE31BB1AA5200CE9B80 /* label.cc */; settings = {ASSET_TAGS = (); }; }; + 060ECAEF1BB22A4400CE9B80 /* ui.cc in Sources */ = {isa = PBXBuildFile; fileRef = 060ECAED1BB22A4400CE9B80 /* ui.cc */; settings = {ASSET_TAGS = (); }; }; + 060ECAF11BB243B000CE9B80 /* color.v.glsl in Resources */ = {isa = PBXBuildFile; fileRef = 060ECAF01BB243B000CE9B80 /* color.v.glsl */; settings = {ASSET_TAGS = (); }; }; + 060ECAF31BB2441600CE9B80 /* color.p.glsl in Resources */ = {isa = PBXBuildFile; fileRef = 060ECAF21BB2441600CE9B80 /* color.p.glsl */; settings = {ASSET_TAGS = (); }; }; + 060ECAF61BB2496100CE9B80 /* ui.p.glsl in Resources */ = {isa = PBXBuildFile; fileRef = 060ECAF41BB2496100CE9B80 /* ui.p.glsl */; settings = {ASSET_TAGS = (); }; }; + 060ECAF71BB2496100CE9B80 /* ui.v.glsl in Resources */ = {isa = PBXBuildFile; fileRef = 060ECAF51BB2496100CE9B80 /* ui.v.glsl */; settings = {ASSET_TAGS = (); }; }; 0669D67F1BA85DDE00611CFA /* app_delegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0669D67B1BA85DDE00611CFA /* app_delegate.m */; }; 0669D6801BA85DDE00611CFA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 0669D67C1BA85DDE00611CFA /* main.m */; }; 0669D6811BA85DDE00611CFA /* viewctl.m in Sources */ = {isa = PBXBuildFile; fileRef = 0669D67E1BA85DDE00611CFA /* viewctl.m */; }; @@ -118,6 +133,34 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 060ECAC91BB1A9CC00CE9B80 /* boolanm.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = boolanm.cc; path = libs/goatkit/boolanm.cc; sourceTree = ""; }; + 060ECACA1BB1A9CC00CE9B80 /* boolanm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = boolanm.h; path = libs/goatkit/boolanm.h; sourceTree = ""; }; + 060ECACB1BB1A9CC00CE9B80 /* button.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = button.cc; path = libs/goatkit/button.cc; sourceTree = ""; }; + 060ECACD1BB1A9CC00CE9B80 /* event.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = event.cc; path = libs/goatkit/event.cc; sourceTree = ""; }; + 060ECACF1BB1A9CC00CE9B80 /* screen.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = screen.cc; path = libs/goatkit/screen.cc; sourceTree = ""; }; + 060ECAD01BB1A9CC00CE9B80 /* slider.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = slider.cc; path = libs/goatkit/slider.cc; sourceTree = ""; }; + 060ECAD11BB1A9CC00CE9B80 /* textbox.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = textbox.cc; path = libs/goatkit/textbox.cc; sourceTree = ""; }; + 060ECAD21BB1A9CC00CE9B80 /* theme.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = theme.cc; path = libs/goatkit/theme.cc; sourceTree = ""; }; + 060ECAD31BB1A9CC00CE9B80 /* widget.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = widget.cc; path = libs/goatkit/widget.cc; sourceTree = ""; }; + 060ECADE1BB1AA5200CE9B80 /* button.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = button.h; path = libs/goatkit/button.h; sourceTree = ""; }; + 060ECADF1BB1AA5200CE9B80 /* checkbox.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = checkbox.cc; path = libs/goatkit/checkbox.cc; sourceTree = ""; }; + 060ECAE01BB1AA5200CE9B80 /* checkbox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = checkbox.h; path = libs/goatkit/checkbox.h; sourceTree = ""; }; + 060ECAE11BB1AA5200CE9B80 /* event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = event.h; path = libs/goatkit/event.h; sourceTree = ""; }; + 060ECAE21BB1AA5200CE9B80 /* goatkit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = goatkit.h; path = libs/goatkit/goatkit.h; sourceTree = ""; }; + 060ECAE31BB1AA5200CE9B80 /* label.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = label.cc; path = libs/goatkit/label.cc; sourceTree = ""; }; + 060ECAE41BB1AA5200CE9B80 /* label.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = label.h; path = libs/goatkit/label.h; sourceTree = ""; }; + 060ECAE51BB1AA5200CE9B80 /* screen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = screen.h; path = libs/goatkit/screen.h; sourceTree = ""; }; + 060ECAE61BB1AA5200CE9B80 /* slider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = slider.h; path = libs/goatkit/slider.h; sourceTree = ""; }; + 060ECAE71BB1AA5200CE9B80 /* textbox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = textbox.h; path = libs/goatkit/textbox.h; sourceTree = ""; }; + 060ECAE81BB1AA5200CE9B80 /* theme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = theme.h; path = libs/goatkit/theme.h; sourceTree = ""; }; + 060ECAE91BB1AA5200CE9B80 /* vec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vec.h; path = libs/goatkit/vec.h; sourceTree = ""; }; + 060ECAEA1BB1AA5200CE9B80 /* widget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = widget.h; path = libs/goatkit/widget.h; sourceTree = ""; }; + 060ECAED1BB22A4400CE9B80 /* ui.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ui.cc; path = src/ui.cc; sourceTree = ""; }; + 060ECAEE1BB22A4400CE9B80 /* ui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ui.h; path = src/ui.h; sourceTree = ""; }; + 060ECAF01BB243B000CE9B80 /* color.v.glsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = color.v.glsl; path = sdr/color.v.glsl; sourceTree = ""; }; + 060ECAF21BB2441600CE9B80 /* color.p.glsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = color.p.glsl; path = sdr/color.p.glsl; sourceTree = ""; }; + 060ECAF41BB2496100CE9B80 /* ui.p.glsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = ui.p.glsl; path = sdr/ui.p.glsl; sourceTree = ""; }; + 060ECAF51BB2496100CE9B80 /* ui.v.glsl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = ui.v.glsl; path = sdr/ui.v.glsl; sourceTree = ""; }; 0669D6471BA851BE00611CFA /* istereo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = istereo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 0669D6741BA858BF00611CFA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ios/Info.plist; sourceTree = ""; }; 0669D67A1BA85DDE00611CFA /* app_delegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = app_delegate.h; path = src/ios/app_delegate.h; sourceTree = ""; }; @@ -139,7 +182,6 @@ 0669D68D1BACDF6C00611CFA /* sdr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sdr.h; path = src/sdr.h; sourceTree = ""; }; 0669D68E1BACDF6C00611CFA /* tex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = tex.c; path = src/tex.c; sourceTree = ""; }; 0669D68F1BACDF6C00611CFA /* tex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tex.h; path = src/tex.h; sourceTree = ""; }; - 0669D6901BACDF6C00611CFA /* ui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ui.h; path = src/ui.h; sourceTree = ""; }; 0669D69D1BAD020B00611CFA /* basis_c.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = basis_c.c; path = libs/vmath/basis_c.c; sourceTree = ""; }; 0669D69E1BAD020B00611CFA /* basis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = basis.h; path = libs/vmath/basis.h; sourceTree = ""; }; 0669D69F1BAD020B00611CFA /* geom.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = geom.c; path = libs/vmath/geom.c; sourceTree = ""; }; @@ -293,6 +335,35 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 060ECAC81BB1A9BA00CE9B80 /* goatkit */ = { + isa = PBXGroup; + children = ( + 060ECADE1BB1AA5200CE9B80 /* button.h */, + 060ECADF1BB1AA5200CE9B80 /* checkbox.cc */, + 060ECAE01BB1AA5200CE9B80 /* checkbox.h */, + 060ECAE11BB1AA5200CE9B80 /* event.h */, + 060ECAE21BB1AA5200CE9B80 /* goatkit.h */, + 060ECAE31BB1AA5200CE9B80 /* label.cc */, + 060ECAE41BB1AA5200CE9B80 /* label.h */, + 060ECAE51BB1AA5200CE9B80 /* screen.h */, + 060ECAE61BB1AA5200CE9B80 /* slider.h */, + 060ECAE71BB1AA5200CE9B80 /* textbox.h */, + 060ECAE81BB1AA5200CE9B80 /* theme.h */, + 060ECAE91BB1AA5200CE9B80 /* vec.h */, + 060ECAEA1BB1AA5200CE9B80 /* widget.h */, + 060ECAC91BB1A9CC00CE9B80 /* boolanm.cc */, + 060ECACA1BB1A9CC00CE9B80 /* boolanm.h */, + 060ECACB1BB1A9CC00CE9B80 /* button.cc */, + 060ECACD1BB1A9CC00CE9B80 /* event.cc */, + 060ECACF1BB1A9CC00CE9B80 /* screen.cc */, + 060ECAD01BB1A9CC00CE9B80 /* slider.cc */, + 060ECAD11BB1A9CC00CE9B80 /* textbox.cc */, + 060ECAD21BB1A9CC00CE9B80 /* theme.cc */, + 060ECAD31BB1A9CC00CE9B80 /* widget.cc */, + ); + name = goatkit; + sourceTree = ""; + }; 0669D63E1BA851BE00611CFA = { isa = PBXGroup; children = ( @@ -317,6 +388,8 @@ 0669D6761BA858D600611CFA /* src */ = { isa = PBXGroup; children = ( + 060ECAED1BB22A4400CE9B80 /* ui.cc */, + 060ECAEE1BB22A4400CE9B80 /* ui.h */, 0669D6821BACDF6C00611CFA /* cam.c */, 0669D6831BACDF6C00611CFA /* cam.h */, 0669D6841BACDF6C00611CFA /* config.h */, @@ -331,7 +404,6 @@ 0669D68D1BACDF6C00611CFA /* sdr.h */, 0669D68E1BACDF6C00611CFA /* tex.c */, 0669D68F1BACDF6C00611CFA /* tex.h */, - 0669D6901BACDF6C00611CFA /* ui.h */, 0669D6791BA85DCC00611CFA /* ios */, ); name = src; @@ -352,6 +424,7 @@ 0669D6971BAD01C200611CFA /* libs */ = { isa = PBXGroup; children = ( + 060ECAC81BB1A9BA00CE9B80 /* goatkit */, 0669D69C1BAD01EA00611CFA /* vmath */, 0669D69B1BAD01E300611CFA /* imago2 */, 0669D69A1BAD01DD00611CFA /* jpeglib */, @@ -528,12 +601,16 @@ 0669D77B1BAD028300611CFA /* sdr */ = { isa = PBXGroup; children = ( + 060ECAF41BB2496100CE9B80 /* ui.p.glsl */, + 060ECAF51BB2496100CE9B80 /* ui.v.glsl */, 0669D77C1BAD02A200611CFA /* test.p.glsl */, 0669D77D1BAD02A200611CFA /* test.v.glsl */, 0669D77E1BAD02A200611CFA /* text.p.glsl */, 0669D77F1BAD02A200611CFA /* text.v.glsl */, 0669D7801BAD02A200611CFA /* tunnel.p.glsl */, 0669D7811BAD02A200611CFA /* tunnel.v.glsl */, + 060ECAF01BB243B000CE9B80 /* color.v.glsl */, + 060ECAF21BB2441600CE9B80 /* color.p.glsl */, ); name = sdr; sourceTree = ""; @@ -610,8 +687,12 @@ 0669D7861BAD02A200611CFA /* tunnel.p.glsl in Resources */, 0669D7821BAD02A200611CFA /* test.p.glsl in Resources */, 0669D78D1BAD02DC00611CFA /* stonewall_normal.jpg in Resources */, + 060ECAF11BB243B000CE9B80 /* color.v.glsl in Resources */, 0669D78E1BAD02DC00611CFA /* stonewall.jpg in Resources */, + 060ECAF61BB2496100CE9B80 /* ui.p.glsl in Resources */, + 060ECAF71BB2496100CE9B80 /* ui.v.glsl in Resources */, 0669D7841BAD02A200611CFA /* text.p.glsl in Resources */, + 060ECAF31BB2441600CE9B80 /* color.p.glsl in Resources */, 06ED084A1BAF9A2E00C1211D /* icons.xcassets in Resources */, 0669D7901BAD02DC00611CFA /* tiles.jpg in Resources */, 0669D7871BAD02A200611CFA /* tunnel.v.glsl in Resources */, @@ -644,11 +725,13 @@ 0669D6CC1BAD022C00611CFA /* modules.c in Sources */, 0669D7301BAD024700611CFA /* jmemmgr.c in Sources */, 0669D72E1BAD024700611CFA /* jidctint.c in Sources */, + 060ECAD41BB1A9CC00CE9B80 /* boolanm.cc in Sources */, 0669D6B81BAD020B00611CFA /* ray_c.c in Sources */, 0669D71D1BAD024700611CFA /* jddctmgr.c in Sources */, 0669D7571BAD025B00611CFA /* pngwtran.c in Sources */, 0669D7081BAD024700611CFA /* jcapistd.c in Sources */, 0669D72C1BAD024700611CFA /* jidctflt.c in Sources */, + 060ECADB1BB1A9CC00CE9B80 /* textbox.cc in Sources */, 0669D7511BAD025B00611CFA /* pngrutil.c in Sources */, 0669D6BB1BAD020B00611CFA /* vmath.c in Sources */, 0669D7341BAD024700611CFA /* jutils.c in Sources */, @@ -670,19 +753,25 @@ 0669D7521BAD025B00611CFA /* pngset.c in Sources */, 0669D7561BAD025B00611CFA /* pngwrite.c in Sources */, 0669D7131BAD024700611CFA /* jcphuff.c in Sources */, + 060ECAD91BB1A9CC00CE9B80 /* screen.cc in Sources */, 0669D70A1BAD024700611CFA /* jccolor.c in Sources */, + 060ECADD1BB1A9CC00CE9B80 /* widget.cc in Sources */, 0669D74F1BAD025B00611CFA /* pngrio.c in Sources */, 0669D6C81BAD022C00611CFA /* file_png.c in Sources */, 0669D7231BAD024700611CFA /* jdmerge.c in Sources */, 0669D77A1BAD027000611CFA /* zutil.c in Sources */, 0669D7721BAD027000611CFA /* deflate.c in Sources */, + 060ECAEB1BB1AA5200CE9B80 /* checkbox.cc in Sources */, 0669D71F1BAD024700611CFA /* jdinput.c in Sources */, 0669D7581BAD025B00611CFA /* pngwutil.c in Sources */, 0669D7261BAD024700611CFA /* jdsample.c in Sources */, 0669D7701BAD027000611CFA /* compress.c in Sources */, 0669D7111BAD024700611CFA /* jcomapi.c in Sources */, 0669D71A1BAD024700611CFA /* jdatasrc.c in Sources */, + 060ECADC1BB1A9CC00CE9B80 /* theme.cc in Sources */, 0669D74B1BAD025B00611CFA /* pngget.c in Sources */, + 060ECAD71BB1A9CC00CE9B80 /* event.cc in Sources */, + 060ECAD51BB1A9CC00CE9B80 /* button.cc in Sources */, 0669D7211BAD024700611CFA /* jdmarker.c in Sources */, 0669D7251BAD024700611CFA /* jdpostct.c in Sources */, 0669D6811BA85DDE00611CFA /* viewctl.m in Sources */, @@ -702,10 +791,12 @@ 0669D7271BAD024700611CFA /* jdtrans.c in Sources */, 0669D6B21BAD020B00611CFA /* basis_c.c in Sources */, 0669D7161BAD024700611CFA /* jctrans.c in Sources */, + 060ECADA1BB1A9CC00CE9B80 /* slider.cc in Sources */, 0669D7311BAD024700611CFA /* jmemnobs.c in Sources */, 0669D74E1BAD025B00611CFA /* pngread.c in Sources */, 0669D71E1BAD024700611CFA /* jdhuff.c in Sources */, 0669D74A1BAD025B00611CFA /* pnggccrd.c in Sources */, + 060ECAEF1BB22A4400CE9B80 /* ui.cc in Sources */, 0669D70E1BAD024700611CFA /* jcmainct.c in Sources */, 0669D7151BAD024700611CFA /* jcsample.c in Sources */, 0669D7141BAD024700611CFA /* jcprepct.c in Sources */, @@ -717,6 +808,7 @@ 0669D7071BAD024700611CFA /* jcapimin.c in Sources */, 0669D6C61BAD022C00611CFA /* conv.c in Sources */, 0669D6B41BAD020B00611CFA /* matrix_c.c in Sources */, + 060ECAEC1BB1AA5200CE9B80 /* label.cc in Sources */, 0669D7321BAD024700611CFA /* jquant1.c in Sources */, 0669D6C91BAD022C00611CFA /* file_ppm.c in Sources */, 0669D72D1BAD024700611CFA /* jidctfst.c in Sources */, @@ -820,6 +912,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CODE_SIGN_IDENTITY = "iPhone Developer"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + HAVE_OPENGL_H, + ); + HEADER_SEARCH_PATHS = libs; INFOPLIST_FILE = "$(SRCROOT)/ios/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -834,6 +931,8 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CODE_SIGN_IDENTITY = "iPhone Developer"; + GCC_PREPROCESSOR_DEFINITIONS = HAVE_OPENGL_H; + HEADER_SEARCH_PATHS = libs; INFOPLIST_FILE = "$(SRCROOT)/ios/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 6.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/boolanm.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/boolanm.cc Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,151 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#include "boolanm.h" + +static long default_get_msec(); + +BoolAnim::BoolAnim(bool st) +{ + set(st); + trans_start = 0; + trans_dur = 500; + get_msec = default_get_msec; +} + +void BoolAnim::update(long tm) const +{ + if(trans_dir == 0.0) return; + + float dt = (tm - trans_start) / 1000.0; + float t = dt / (trans_dur / 1000.0); + + if(trans_dir > 0.0) { + value = t; + } else { + value = 1.0 - t; + } + + if(value < 0.0) { + value = 0.0; + trans_dir = 0.0; + } else if(value > 1.0) { + value = 1.0; + trans_dir = 0.0; + } +} + +void BoolAnim::set_transition_duration(long dur) +{ + trans_dur = dur; +} + +void BoolAnim::set_time_callback(long (*time_func)()) +{ + get_msec = time_func; +} + +void BoolAnim::set(bool st) +{ + value = st ? 1.0 : 0.0; + trans_dir = 0.0; +} + +void BoolAnim::change(bool st) +{ + change(st, get_msec()); +} + +void BoolAnim::change(bool st, long tm) +{ + trans_dir = st ? 1.0 : -1.0; + trans_start = tm; +} + +bool BoolAnim::get_state() const +{ + return get_state(get_msec()); +} + +bool BoolAnim::get_state(long tm) const +{ + update(tm); + + // if we're not in transition use the value (should be 0 or 1) + if(trans_dir == 0.0) { + return value > 0.5; + } + + // if we're in transition base it on the direction of the transition + return trans_dir > 0.0; +} + +float BoolAnim::get_value() const +{ + return get_value(get_msec()); +} + +float BoolAnim::get_value(long tm) const +{ + update(tm); + return value; +} + +float BoolAnim::get_dir() const +{ + return get_dir(get_msec()); +} + +float BoolAnim::get_dir(long tm) const +{ + update(tm); + return trans_dir; +} + +BoolAnim::operator bool() const +{ + return get_state(); +} + +BoolAnim::operator float() const +{ + return get_value(); +} + +#ifdef WIN32 +#include + +static long default_get_msec() +{ + return GetTickCount(); +} +#else +#include + +static long default_get_msec() +{ + static struct timeval tv0; + struct timeval tv; + + gettimeofday(&tv, 0); + if(tv0.tv_sec == 0 && tv0.tv_usec == 0) { + tv0 = tv; + return 0; + } + return (tv.tv_sec - tv0.tv_sec) * 1000 + (tv.tv_usec - tv0.tv_usec) / 1000; +} +#endif diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/boolanm.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/boolanm.h Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,57 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef BOOLANIM_H_ +#define BOOLANIM_H_ + +class BoolAnim { +private: + mutable float value; + mutable float trans_dir; // transition direction (sign) + long trans_start; // transition start time + long trans_dur; + + long (*get_msec)(); + + void update(long tm) const; + +public: + BoolAnim(bool st = false); + + void set_transition_duration(long dur); + void set_time_callback(long (*time_func)()); + + void set(bool st); + + void change(bool st); + void change(bool st, long trans_start); + + bool get_state() const; + bool get_state(long tm) const; + + float get_value() const; + float get_value(long tm) const; + + // transition direction (-1, 0, 1) + float get_dir() const; + float get_dir(long tm) const; + + operator bool() const; // equivalent to get_state + operator float() const; // equivalent to get_value +}; + +#endif // BOOLANIM_H_ diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/button.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/button.cc Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,40 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#include "button.h" + +namespace goatkit { + +struct ButtonImpl { +}; + +Button::Button() +{ + button = new ButtonImpl; +} + +Button::~Button() +{ + delete button; +} + +const char *Button::get_type_name() const +{ + return "button"; +} + +} // namespace goatkit diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/button.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/button.h Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,40 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef GOATKIT_BUTTON_H_ +#define GOATKIT_BUTTON_H_ + +#include "widget.h" + +namespace goatkit { + +struct ButtonImpl; + +class Button : public Widget { +private: + ButtonImpl *button; + +public: + Button(); + virtual ~Button(); + + virtual const char *get_type_name() const; +}; + +} // namespace goatkit + +#endif // GOATKIT_BUTTON_H_ diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/checkbox.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/checkbox.cc Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,83 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#include "checkbox.h" +#include "boolanm.h" + +namespace goatkit { + +struct CheckBoxImpl { + BoolAnim checked; +}; + +CheckBox::CheckBox() +{ + cbox = new CheckBoxImpl; + cbox->checked = false; + cbox->checked.set_transition_duration(60); +} + +CheckBox::~CheckBox() +{ + delete cbox; +} + +const char *CheckBox::get_type_name() const +{ + return "checkbox"; +} + + +void CheckBox::check() +{ + cbox->checked.change(true); +} + +void CheckBox::uncheck() +{ + cbox->checked.change(false); +} + +float CheckBox::get_checked() const +{ + return cbox->checked.get_value(); +} + +bool CheckBox::is_checked() const +{ + return cbox->checked.get_state(); +} + +void CheckBox::toggle() +{ + if(is_checked()) { + uncheck(); + } else { + check(); + } +} + +void CheckBox::on_click() +{ + toggle(); + + Event ev; + ev.type = EV_CHANGE; + handle_event(ev); +} + +} // namespace goatkit diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/checkbox.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/checkbox.h Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,48 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef CHECKBOX_H_ +#define CHECKBOX_H_ + +#include "widget.h" + +namespace goatkit { + +struct CheckBoxImpl; + +class CheckBox : public Widget { +private: + CheckBoxImpl *cbox; + +public: + CheckBox(); + virtual ~CheckBox(); + + virtual const char *get_type_name() const; + + virtual void check(); + virtual void uncheck(); + virtual float get_checked() const; + virtual bool is_checked() const; + virtual void toggle(); + + virtual void on_click(); +}; + +} // namespace goatkit + +#endif // CHECKBOX_H_ diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/event.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/event.cc Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,35 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#include "event.h" + + +const char *goatkit::event_type_name(EventType type) +{ + // XXX keep this array synchronized with enum EventType + static const char *names[NUM_EVENTS] = { + "mouse button", + "mouse motion", + "focus", + "keyboard", + "click", + "double click", + "change" + }; + + return names[type]; +} diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/event.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/event.h Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,83 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef EVENT_H_ +#define EVENT_H_ + +#include "vec.h" + +namespace goatkit { + +enum EventType { + // primary events + EV_MOUSE_BUTTON, + EV_MOUSE_MOTION, + EV_MOUSE_FOCUS, + EV_KEY, + + // derived events + EV_CLICK, + EV_DOUBLE_CLICK, + EV_CHANGE, + + NUM_EVENTS +}; + +enum SpecialKeys { + KEY_ESCAPE = 27, + KEY_DELETE = 127, + + KEY_F1 = 256, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, + KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, + KEY_LEFT, KEY_RIGHT, KEY_UP, KEY_DOWN, + KEY_HOME, KEY_END, KEY_PGUP, KEY_PGDOWN, + KEY_INSERT +}; + +struct ButtonEvent { + Vec2 pos; + int button; + bool press; +}; + +struct MotionEvent { + Vec2 pos; +}; + +struct FocusEvent { + bool enter; +}; + +struct KeyEvent { + int key; + bool press; +}; + +struct Event { + EventType type; + + ButtonEvent button; + MotionEvent motion; + FocusEvent focus; + KeyEvent key; +}; + +const char *event_type_name(EventType type); + +} // namespace goatkit + +#endif // EVENT_H_ diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/goatkit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/goatkit.h Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,31 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef GOATKIT_H_ +#define GOATKIT_H_ + +#include "screen.h" +#include "widget.h" +#include "button.h" +#include "checkbox.h" +#include "label.h" +#include "textbox.h" +#include "slider.h" +#include "event.h" +#include "theme.h" + +#endif // GOATKIT_H_ diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/label.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/label.cc Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,40 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#include "label.h" + +namespace goatkit { + +struct LabelImpl { +}; + +Label::Label() +{ + label = new LabelImpl; +} + +Label::~Label() +{ + delete label; +} + +const char *Label::get_type_name() const +{ + return "label"; +} + +} // namespace goatkit diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/label.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/label.h Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,40 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef GOATKIT_LABEL_H_ +#define GOATKIT_LABEL_H_ + +#include "widget.h" + +namespace goatkit { + +struct LabelImpl; + +class Label : public Widget { +private: + LabelImpl *label; + +public: + Label(); + virtual ~Label(); + + virtual const char *get_type_name() const; +}; + +} // namespace goatkit + +#endif // GOATKIT_LABEL_H_ diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/screen.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/screen.cc Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,299 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#include +#include +#include +#include +#include "screen.h" +#include "widget.h" + +#define MAX_BUTTONS 16 + +namespace goatkit { + +struct ScreenImpl { + bool visible; + std::vector widgets; + BBox box; + + Widget *inp_focused, *over, *pressed[MAX_BUTTONS]; + Widget *mgrab; +}; + +static Vec2 world_to_scr(const ScreenImpl *scr, const Vec2 &v); +//static Vec2 scr_to_world(const ScreenImpl *scr, const Vec2 &v) + +Screen::Screen() +{ + scr = new ScreenImpl; + + scr->box.bmin = Vec2(0, 0); + scr->box.bmax = Vec2(1, 1); + + scr->inp_focused = scr->over = 0; + for(int i=0; ipressed[i] = 0; + } + + scr->visible = true; + scr->mgrab = 0; +} + +Screen::~Screen() +{ + delete scr; +} + +void Screen::set_position(float x, float y) +{ + set_position(Vec2(x, y)); +} + +void Screen::set_position(const Vec2 &pos) +{ + Vec2 sz = get_size(); + + scr->box.bmin = pos; + scr->box.bmax.x = pos.x + sz.x; + scr->box.bmax.y = pos.y + sz.y; +} + +const Vec2 &Screen::get_position() const +{ + return scr->box.bmin; +} + +void Screen::set_size(float x, float y) +{ + set_size(Vec2(x, y)); +} + +void Screen::set_size(const Vec2 &sz) +{ + scr->box.bmax.x = scr->box.bmin.x + sz.x; + scr->box.bmax.y = scr->box.bmin.y + sz.y; +} + +const Vec2 Screen::get_size() const +{ + return Vec2(scr->box.bmax.x - scr->box.bmin.x, + scr->box.bmax.y - scr->box.bmin.y); +} + +const BBox &Screen::get_box() const +{ + return scr->box; +} + +void Screen::add_widget(Widget *w) +{ + scr->widgets.push_back(w); + if(scr->visible) { + w->show(); + } else { + w->hide(); + } + + w->set_screen(this); +} + +int Screen::get_widget_count() const +{ + return (int)scr->widgets.size(); +} + +Widget *Screen::get_widget(int idx) const +{ + if(idx < 0 || idx >= (int)scr->widgets.size()) { + return 0; + } + return scr->widgets[idx]; +} + +Widget *Screen::get_widget(const char *name) const +{ + for(size_t i=0; iwidgets.size(); i++) { + if(strcmp(scr->widgets[i]->get_name(), name) == 0) { + return scr->widgets[i]; + } + } + return 0; +} + +void Screen::show() +{ + scr->visible = true; + + for(size_t i=0; iwidgets.size(); i++) { + scr->widgets[i]->show(); + } +} + +void Screen::hide() +{ + scr->visible = false; + + for(size_t i=0; iwidgets.size(); i++) { + scr->widgets[i]->hide(); + } +} + +bool Screen::is_visible() const +{ + return scr->visible; +} + +bool Screen::grab_mouse(Widget *w) +{ + if(!scr->mgrab || !w) { + scr->mgrab = w; + return true; + } + return false; +} + +void Screen::draw() const +{ + for(size_t i=0; iwidgets.size(); i++) { + scr->widgets[i]->draw(); + } +} + +static Widget *find_widget_at(const ScreenImpl *scr, const Vec2 &pt) +{ + for(size_t i=0; iwidgets.size(); i++) { + Widget *w = scr->widgets[i]; + + if(w->hit_test(pt)) { + return w; + } + } + return 0; +} + +void Screen::sysev_keyboard(int key, bool press) +{ + Event ev; + + if(scr->inp_focused) { + ev.type = EV_KEY; + ev.key.key = key; + ev.key.press = press; + scr->inp_focused->handle_event(ev); + } +} + +void Screen::sysev_mouse_button(int bn, bool press, float x, float y) +{ + Event ev; + Vec2 pt = world_to_scr(scr, Vec2(x, y)); + Widget *new_over = scr->mgrab ? scr->mgrab : find_widget_at(scr, pt); + + ev.type = EV_MOUSE_BUTTON; + ev.button.button = bn; + ev.button.pos = pt; + ev.button.press = press; + + if(press) { + if(bn == 0) { + // left click gives input focus + // TODO: add input focus event in widget + if(new_over && new_over != scr->inp_focused && new_over->can_focus()) { + printf("input focus %p -> %p\n", (void*)scr->inp_focused, (void*)new_over); + new_over->focusin(); + + if(scr->inp_focused) { + scr->inp_focused->focusout(); + } + scr->inp_focused = new_over; + } + } + + scr->pressed[bn] = new_over; + scr->over = new_over; + + if(new_over) { + new_over->handle_event(ev); + } + + } else { + // send the mouse release event to the widget that got the matching press + if(scr->pressed[bn]) { + scr->pressed[bn]->handle_event(ev); + scr->pressed[bn] = 0; + } + } + + // if we're not over the same widget any more send the leave/enter events + // TODO also add drag/drop events + if(scr->over != new_over) { + ev.type = EV_MOUSE_FOCUS; + if(scr->over) { + ev.focus.enter = false; + scr->over->handle_event(ev); + } + if(new_over) { + ev.focus.enter = true; + new_over->handle_event(ev); + } + scr->over = new_over; + } +} + +void Screen::sysev_mouse_motion(float x, float y) +{ + Event ev; + Vec2 pt = world_to_scr(scr, Vec2(x, y)); + Widget *new_over = scr->mgrab ? scr->mgrab : find_widget_at(scr, pt); + + // if we're not over the same widget any more send the leave/enter events + if(scr->over != new_over) { + ev.type = EV_MOUSE_FOCUS; + if(scr->over) { + ev.focus.enter = false; + scr->over->handle_event(ev); + } + if(new_over) { + ev.focus.enter = true; + new_over->handle_event(ev); + } + scr->over = new_over; + } + + if(new_over) { + // send motion event + ev.type = EV_MOUSE_MOTION; + ev.motion.pos = pt; + new_over->handle_event(ev); + } +} + +static Vec2 world_to_scr(const ScreenImpl *scr, const Vec2 &v) +{ + return Vec2(v.x - scr->box.bmin.x, v.y - scr->box.bmin.y); +} + +/* +static Vec2 scr_to_world(const ScreenImpl *scr, const Vec2 &v) +{ + return Vec2(v.x + scr->box.bmin.x, v.y + scr->box.bmin.y); +} +*/ + + +} // namespace goatkit diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/screen.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/screen.h Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,66 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef SCREEN_H_ +#define SCREEN_H_ + +#include "vec.h" +#include "widget.h" + +namespace goatkit { + +class ScreenImpl; + +class Screen { +private: + ScreenImpl *scr; + +public: + Screen(); + ~Screen(); + + void set_position(float x, float y); + void set_position(const Vec2 &pos); + const Vec2 &get_position() const; + void set_size(float x, float y); + void set_size(const Vec2 &sz); + const Vec2 get_size() const; + const BBox &get_box() const; + + void add_widget(Widget *w); + int get_widget_count() const; + Widget *get_widget(int idx) const; + Widget *get_widget(const char *name) const; + + void show(); + void hide(); + bool is_visible() const; + + bool grab_mouse(Widget *w); + + void draw() const; + + // window system events used to generate widget events (see event.h) + void sysev_keyboard(int key, bool press); + // mouse position as reported by the window system. might fall outside + void sysev_mouse_button(int bn, bool press, float x, float y); + void sysev_mouse_motion(float x, float y); +}; + +} // namespace goatkit + +#endif /* SCREEN_H_ */ diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/slider.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/slider.cc Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,196 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#include +#include +#include "slider.h" +#include "screen.h" + +namespace goatkit { + +struct SliderImpl { + float value, prev_value; + float range_min, range_max; + float padding; + float step; + bool dragging; + bool cont_change; +}; + +static float remap(float val, float inlow, float inhigh, float outlow, float outhigh); + +Slider::Slider() +{ + slider = new SliderImpl; + slider->value = slider->prev_value = 0.0f; + slider->dragging = false; + slider->cont_change = true; + + slider->range_min = 0.0; + slider->range_max = 1.0; + slider->step = 0.0; + + slider->padding = -1.0; +} + +Slider::~Slider() +{ + delete slider; +} + +const char *Slider::get_type_name() const +{ + return "slider"; +} + +void Slider::set_value(float val) +{ + slider->value = remap(val, slider->range_min, slider->range_max, 0, 1); +} + +float Slider::get_value() const +{ + return remap(slider->value, 0, 1, slider->range_min, slider->range_max); +} + +void Slider::set_value_norm(float val) +{ + slider->value = val < 0.0 ? 0.0 : (val > 1.0 ? 1.0 : val); +} + +float Slider::get_value_norm() const +{ + return slider->value; +} + +void Slider::set_padding(float pad) +{ + slider->padding = pad; +} + +float Slider::get_padding() const +{ + if(slider->padding < 0.0) { + BBox box = get_box(); + return (box.bmax.y - box.bmin.y) * 0.25; + } + return slider->padding; +} + +void Slider::set_continuous_change(bool cont) +{ + slider->cont_change = cont; +} + +bool Slider::get_continuous_change() const +{ + return slider->cont_change; +} + +void Slider::set_range(float min, float max) +{ + slider->range_min = min; + slider->range_max = max; +} + +float Slider::get_range_min() const +{ + return slider->range_min; +} + +float Slider::get_range_max() const +{ + return slider->range_max; +} + +void Slider::set_step(float step) +{ + slider->step = step; +} + +float Slider::get_step() const +{ + return slider->step; +} + +void Slider::on_mouse_button(const ButtonEvent &ev) +{ + if(ev.button == 0) { + Screen *scr = get_screen(); + + slider->dragging = ev.press; + if(ev.press) { + if(scr) scr->grab_mouse(this); + } else { + if(scr) scr->grab_mouse(0); + + // on release, if the value has changed send the appropriate event + if(slider->prev_value != slider->value) { + Event ev; + ev.type = EV_CHANGE; + handle_event(ev); + slider->prev_value = slider->value; + } + } + } +} + +#define ROUND(x) floor((x) + 0.5) + +void Slider::on_mouse_motion(const MotionEvent &ev) +{ + if(!slider->dragging) { + return; + } + + BBox box = get_box(); + + float padding = get_padding(); + float start = box.bmin.x + padding; + float end = box.bmax.x - padding; + float new_val = (ev.pos.x - start) / (end - start); + + // if we have a non-zero step, snap to the nearest value + if(slider->step > 0.0) { + float range = slider->range_max - slider->range_min; + float st = slider->step / range; + + new_val = ROUND(new_val / st) * st; + } + + if(new_val < 0.0) new_val = 0.0; + if(new_val > 1.0) new_val = 1.0; + + if(new_val != slider->value) { + slider->value = new_val; + if(slider->cont_change) { + Event cev; + cev.type = EV_CHANGE; + handle_event(cev); + } + } +} + +static float remap(float val, float inlow, float inhigh, float outlow, float outhigh) +{ + float t = (val - inlow) / (inhigh - inlow); + if(t < 0.0) t = 0.0; + if(t > 1.0) t = 1.0; + return t * (outhigh - outlow) + outlow; +} + +} // namespace goatkit diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/slider.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/slider.h Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,62 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef SLIDER_H_ +#define SLIDER_H_ + +#include "widget.h" + +namespace goatkit { + +struct SliderImpl; + +class Slider : public Widget { +private: + SliderImpl *slider; + +public: + Slider(); + virtual ~Slider(); + + virtual const char *get_type_name() const; + + virtual void set_value(float val); + virtual float get_value() const; + + virtual void set_value_norm(float val); + virtual float get_value_norm() const; + + virtual void set_padding(float pad); + virtual float get_padding() const; + + virtual void set_continuous_change(bool cont); + virtual bool get_continuous_change() const; + + virtual void set_range(float min, float max); + virtual float get_range_min() const; + virtual float get_range_max() const; + + virtual void set_step(float step); + virtual float get_step() const; + + virtual void on_mouse_button(const ButtonEvent &ev); + virtual void on_mouse_motion(const MotionEvent &ev); +}; + +} // namespace goatkit + +#endif // SLIDER_H_ diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/textbox.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/textbox.cc Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,168 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#include +#include +#include +#include "textbox.h" + +namespace goatkit { + +struct TextBoxImpl { + std::string text; + int cursor; +}; + +TextBox::TextBox() +{ + tbox = new TextBoxImpl; + tbox->cursor = 0; +} + +TextBox::~TextBox() +{ + delete tbox; +} + +const char *TextBox::get_type_name() const +{ + return "textbox"; +} + +bool TextBox::can_focus() const +{ + return true; +} + +void TextBox::clear() +{ + tbox->text.clear(); +} + +void TextBox::set_text(const char *t) +{ + tbox->text = std::string(t); +} + +const char *TextBox::get_text() const +{ + return tbox->text.c_str(); +} + +int TextBox::set_cursor(int idx) +{ + int len = tbox->text.size(); + + if(idx < 0) { + tbox->cursor = 0; + } else if(idx > len) { + tbox->cursor = len; + } else { + tbox->cursor = idx; + } + return tbox->cursor; +} + +int TextBox::get_cursor() const +{ + return tbox->cursor; +} + +int TextBox::cursor_begin() +{ + return tbox->cursor = 0; +} + +int TextBox::cursor_end() +{ + return set_cursor(INT_MAX); +} + +int TextBox::cursor_prev() +{ + return set_cursor(tbox->cursor - 1); +} + +int TextBox::cursor_next() +{ + return set_cursor(tbox->cursor + 1); +} + +void TextBox::insert(char c) +{ + int len = tbox->text.size(); + if(tbox->cursor >= len) { + tbox->text.push_back(c); + tbox->cursor++; + } else { + tbox->text.insert(tbox->cursor++, 1, c); + } +} + +void TextBox::on_key(const KeyEvent &ev) +{ + if(!ev.press) return; // ignore key release events + + switch(ev.key) { + case KEY_LEFT: + cursor_prev(); + break; + + case KEY_RIGHT: + cursor_next(); + break; + + case KEY_HOME: + cursor_begin(); + break; + + case KEY_END: + cursor_end(); + break; + + case KEY_DELETE: + tbox->text.erase(tbox->cursor, 1); + break; + + case '\b': + if(tbox->cursor > 0) { + tbox->text.erase(--tbox->cursor, 1); + } + break; + + case '\n': + case '\t': + { + Event ev; + ev.type = EV_CHANGE; + handle_event(ev); + } + break; + + default: + if(isprint(ev.key)) { + insert(ev.key); + } + } +} + +void TextBox::on_click() +{ + // TODO place cursor +} + +} // namespace goatkit diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/textbox.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/textbox.h Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,59 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef TEXTBOX_H_ +#define TEXTBOX_H_ + +#include "widget.h" + +namespace goatkit { + +struct TextBoxImpl; + +class TextBox : public Widget { +private: + TextBoxImpl *tbox; + +public: + TextBox(); + virtual ~TextBox(); + + virtual const char *get_type_name() const; + virtual bool can_focus() const; + + virtual void clear(); + + virtual void set_text(const char *t); + virtual const char *get_text() const; + + virtual int set_cursor(int idx); + virtual int get_cursor() const; + + virtual int cursor_begin(); + virtual int cursor_end(); + virtual int cursor_prev(); + virtual int cursor_next(); + + virtual void insert(char c); + + virtual void on_key(const KeyEvent &ev); + virtual void on_click(); +}; + +} // namespace goatkit + +#endif // TEXTBOX_H_ diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/theme.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/theme.cc Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,253 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#include "config.h" +#include +#include +#include +#include +#include +#include "theme.h" +#include "widget.h" + +#ifdef WIN32 +#include + +static void *dlopen(const char *name, int flags); +static void dlclose(void *so); +static void *dlsym(void *so, const char *symbol); +#else +#include +#include +#endif + +#ifdef HAVE_OPENGL_H +#include "opengl.h" + +#else + +#ifdef __APPLE__ +#include +#else +#include +#endif + +#endif /* HAVE_OPENGL_H_ */ + +#ifndef PREFIX +#define PREFIX "/usr/local" +#endif + +namespace goatkit { + +struct ThemeImpl { + void *so; + WidgetDrawFunc (*lookup_theme_draw_func)(const char*); + mutable std::map func_cache; +}; + +Theme *theme; +static std::vector search_paths; +static const char *fallback_paths[] = { + PREFIX "/share/goatkit", + 0 +}; + +void add_theme_path(const char *path) +{ + if(!path || !*path) return; + + std::string s = path; + int last = s.length() - 1; + if(s[last] == '/' || s[last] == '\\') { + s.erase(last); + } + + if(std::find(search_paths.begin(), search_paths.end(), s) != search_paths.end()) { + return; + } + + search_paths.push_back(s); +} + +Theme::Theme() +{ + impl = new ThemeImpl; + impl->so = 0; + impl->lookup_theme_draw_func = 0; +} + +Theme::~Theme() +{ + unload(); + delete impl; +} + +typedef WidgetDrawFunc (*LookupFunc)(const char*); + +bool Theme::load(const char *name) +{ + unload(); + + std::string fname = std::string(name) + ".gtheme"; + if(!(impl->so = dlopen(fname.c_str(), RTLD_LAZY))) { + for(size_t i=0; iso = dlopen(path.c_str(), RTLD_LAZY))) { + break; + } + } + + // try the fallback paths + if(!impl->so) { + for(int i=0; fallback_paths[i]; i++) { + std::string path = std::string(fallback_paths[i]) + "/" + fname; + + if((impl->so = dlopen(path.c_str(), RTLD_LAZY))) { + break; + } + } + } + + if(!impl->so) { + fprintf(stderr, "%s: failed to load theme plugin: %s\n", __func__, name); + return false; + } + } + + // loaded the shared object, now get the lookup function + impl->lookup_theme_draw_func = (LookupFunc)dlsym(impl->so, "get_widget_func"); + if(!impl->lookup_theme_draw_func) { + fprintf(stderr, "%s: invalid theme plugin %s\n", __func__, name); + unload(); + return false; + } + + return true; +} + +void Theme::unload() +{ + if(impl->so) { + dlclose(impl->so); + impl->so = 0; + } + impl->func_cache.clear(); +} + +WidgetDrawFunc Theme::get_draw_func(const char *type) const +{ + std::map::const_iterator it = impl->func_cache.find(type); + if(it == impl->func_cache.end()) { + // don't have it cached, try to look it up + WidgetDrawFunc func; + if(impl->lookup_theme_draw_func && (func = impl->lookup_theme_draw_func(type))) { + impl->func_cache[type] = func; + return func; + } + + // can't look it up, return the default + return default_draw_func; + } + return it->second; +} + +#define LERP(a, b, t) ((a) + ((b) - (a)) * t) +#define DEF_TEX_SZ 32 +void default_draw_func(const Widget *w) +{ + static unsigned int tex; + + if(!tex) { + unsigned char *pixels = new unsigned char[DEF_TEX_SZ * DEF_TEX_SZ * 3]; + unsigned char *ptr = pixels; + for(int i=0; iget_position(); + Vec2 sz = w->get_size(); + float aspect = sz.x / sz.y; + +#if !defined(GL_ES_VERSION_2_0) + glPushAttrib(GL_ENABLE_BIT); + glEnable(GL_TEXTURE_2D); +#endif + glBindTexture(GL_TEXTURE_2D, tex); + + float offs = w->get_pressed() * 0.1 * sz.y; + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glTranslatef(offs, -offs, 0); + + float active = w->get_active(); + float hover = w->get_under_mouse(); + + float rg = LERP(0.4, 1.0, hover); + float b = LERP(rg, 0, active); + glColor3f(rg, rg, b); + + glBegin(GL_QUADS); + glTexCoord2f(0, 1); + glVertex2f(pos.x, pos.y); + glTexCoord2f(aspect, 1); + glVertex2f(pos.x + sz.x, pos.y); + glTexCoord2f(aspect, 0); + glVertex2f(pos.x + sz.x, pos.y + sz.y); + glTexCoord2f(0, 0); + glVertex2f(pos.x, pos.y + sz.y); + glEnd(); + + glPopMatrix(); + +#ifndef GL_ES_VERSION_2_0 + glPopAttrib(); +#endif +} + +} // namespace goatkit + +#ifdef WIN32 +// XXX untested +static void *dlopen(const char *name, int flags) +{ + return LoadLibrary(name); +} + +static void dlclose(void *so) +{ + FreeLibrary(so); +} + +static void *dlsym(void *so, const char *symbol) +{ + return (void*)GetProcAddress(so, symbol); +} +#endif diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/theme.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/theme.h Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,50 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef THEME_H_ +#define THEME_H_ + +namespace goatkit { + +class Widget; + +typedef void (*WidgetDrawFunc)(const Widget*); + +void add_theme_path(const char *path); +void default_draw_func(const Widget *w); + +struct ThemeImpl; + +class Theme { +private: + ThemeImpl *impl; + +public: + Theme(); + ~Theme(); + + bool load(const char *name); + void unload(); + + WidgetDrawFunc get_draw_func(const char *type) const; +}; + +extern Theme *theme; // the current theme + +} // namespace goatkit + +#endif // THEME_H_ diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/vec.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/vec.h Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,33 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef VEC_H_ +#define VEC_H_ + +namespace goatkit { + +class Vec2 { +public: + float x, y; + + Vec2() : x(0), y(0) {} + Vec2(float xx, float yy) : x(xx), y(yy) {} +}; + +} // namespace goatkit + +#endif // VEC_H_ diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/widget.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/widget.cc Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,379 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#include +#include +#include +#include +#include +#include "widget.h" +#include "boolanm.h" +#include "theme.h" +#include "screen.h" + +namespace goatkit { + +struct WidgetImpl { + Screen *scr; + std::string name, text; + BBox box; + + BoolAnim visible, active, press, hover, focus; + + struct { + EventCallback func; + void *cls; + } cb[NUM_EVENTS]; +}; + + +Widget::Widget() +{ + static int widget_count; + + widget = new WidgetImpl; + widget->scr = 0; + + std::stringstream sstr; + sstr << get_type_name() << widget_count++; + widget->name = sstr.str(); + + widget->box.bmin = Vec2(0, 0); + widget->box.bmax = Vec2(1, 1); + + widget->visible.set(true); + widget->active.set(true); + + widget->hover.set_transition_duration(250); + widget->press.set_transition_duration(50); + + memset(widget->cb, 0, sizeof widget->cb); +} + +Widget::~Widget() +{ + delete widget; +} + +void Widget::set_screen(Screen *scr) +{ + widget->scr = scr; +} + +Screen *Widget::get_screen() const +{ + return widget->scr; +} + +const char *Widget::get_type_name() const +{ + return "widget"; +} + +void Widget::set_name(const char *name) +{ + widget->name = std::string(name); +} + +const char *Widget::get_name() const +{ + return widget->name.c_str(); +} + +void Widget::set_text(const char *text) +{ + widget->text = std::string(text); +} + +const char *Widget::get_text() const +{ + return widget->text.c_str(); +} + +void Widget::show() +{ + widget->visible.change(true); +} + +void Widget::hide() +{ + widget->visible.change(false); +} + +float Widget::get_visibility() const +{ + return widget->visible.get_value(); +} + +bool Widget::is_visible() const +{ + return widget->visible.get_state(); +} + +void Widget::activate() +{ + widget->active.change(true); +} + +void Widget::deactivate() +{ + widget->active.change(false); +} + +float Widget::get_active() const +{ + return widget->active.get_value(); +} + +bool Widget::is_active() const +{ + return widget->active.get_state(); +} + +void Widget::press() +{ + widget->press.change(true); +} + +void Widget::release() +{ + widget->press.change(false); +} + +float Widget::get_pressed() const +{ + return widget->press.get_value(); +} + +bool Widget::is_pressed() const +{ + return widget->press.get_state(); +} + +void Widget::mousein() +{ + widget->hover.change(true); +} + +void Widget::mouseout() +{ + widget->hover.change(false); + if(widget->press) { + widget->press.change(false); + } +} + +float Widget::get_under_mouse() const +{ + return widget->hover.get_value(); +} + +bool Widget::is_under_mouse() const +{ + return widget->hover.get_state(); +} + +bool Widget::can_focus() const +{ + return false; +} + +void Widget::focusin() +{ + widget->focus.change(true); +} + +void Widget::focusout() +{ + widget->focus.change(false); +} + +float Widget::get_focus() const +{ + return widget->focus.get_value(); +} + +bool Widget::is_focused() const +{ + return widget->focus.get_state(); +} + +void Widget::set_position(float x, float y) +{ + set_position(Vec2(x, y)); +} + +void Widget::set_position(const Vec2 &pos) +{ + Vec2 sz = get_size(); + + widget->box.bmin = pos; + widget->box.bmax.x = pos.x + sz.x; + widget->box.bmax.y = pos.y + sz.y; +} + +const Vec2 &Widget::get_position() const +{ + return widget->box.bmin; +} + +void Widget::set_size(float x, float y) +{ + set_size(Vec2(x, y)); +} + +void Widget::set_size(const Vec2 &sz) +{ + widget->box.bmax.x = widget->box.bmin.x + sz.x; + widget->box.bmax.y = widget->box.bmin.y + sz.y; +} + +const Vec2 Widget::get_size() const +{ + return Vec2(widget->box.bmax.x - widget->box.bmin.x, + widget->box.bmax.y - widget->box.bmin.y); +} + + +const BBox &Widget::get_box() const +{ + return widget->box; +} + +bool Widget::hit_test(const Vec2 &pt) const +{ + return pt.x >= widget->box.bmin.x && pt.x < widget->box.bmax.x && + pt.y >= widget->box.bmin.y && pt.y < widget->box.bmax.y; +} + +void Widget::draw() const +{ + WidgetDrawFunc draw_func = default_draw_func; + + if(theme) { + draw_func = theme->get_draw_func(get_type_name()); + } + + draw_func(this); +} + +// dummy event handlers +void Widget::on_mouse_button(const ButtonEvent &ev) +{ +} + +void Widget::on_mouse_motion(const MotionEvent &ev) +{ +} + +void Widget::on_mouse_focus(const FocusEvent &ev) +{ +} + +void Widget::on_key(const KeyEvent &ev) +{ +} + +void Widget::on_click() +{ +} + +void Widget::on_double_click() +{ +} + +void Widget::on_change() +{ +} + + +#define CALL_CB(w, ev) \ + do { \ + if((w)->widget->cb[ev.type].func) { \ + (w)->widget->cb[ev.type].func((w), ev, (w)->widget->cb[ev.type].cls); \ + } \ + } while(0) + +#define CALL_CB_TYPE(w, t) \ + do { \ + Event ev; \ + ev.type = (t); \ + CALL_CB(w, ev); \ + } while(0) + +/* the event dispatcher generates high-level events (click, etc) + * and calls the on_whatever() functions for both low and high-level + * events. + * The on_whatever functions are called *after* any other actions performed + * here, to give subclasses the opportunity to override them easily, by + * overriding the on_ functions, without having to override handle_event itself + */ +// TODO also call callbacks here I guess... +void Widget::handle_event(const Event &ev) +{ + switch(ev.type) { + case EV_MOUSE_BUTTON: + if(ev.button.press) { + press(); + } else { + if(is_pressed()) { + CALL_CB_TYPE(this, EV_CLICK); + on_click(); + } + release(); + } + + on_mouse_button(ev.button); + break; + + case EV_MOUSE_MOTION: + on_mouse_motion(ev.motion); + break; + + case EV_MOUSE_FOCUS: + if(ev.focus.enter) { + mousein(); + } else { + mouseout(); + } + on_mouse_focus(ev.focus); + break; + + case EV_KEY: + on_key(ev.key); + break; + + case EV_CHANGE: + on_change(); + break; + + default: + break; + } + + CALL_CB(this, ev); +} + + +void Widget::set_callback(EventType evtype, EventCallback func, void *cls) +{ + widget->cb[evtype].func = func; + widget->cb[evtype].cls = cls; +} + + +} // namespace goatkit diff -r 6a39b8912752 -r 3bccfc7d10fe libs/goatkit/widget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libs/goatkit/widget.h Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,120 @@ +/* +GoatKit - a themable/animated widget toolkit for games +Copyright (C) 2014 John Tsiombikas + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . +*/ +#ifndef GOATKIT_WIDGET_H_ +#define GOATKIT_WIDGET_H_ + +#include "vec.h" +#include "event.h" + +namespace goatkit { + +struct BBox { + Vec2 bmin, bmax; +}; + +class Screen; +class Widget; +struct WidgetImpl; + +typedef void (*EventCallback)(Widget*, const Event &ev, void *cls); + +class Widget { +protected: + WidgetImpl *widget; + + virtual void set_screen(Screen *scr); + Screen *get_screen() const; + +public: + Widget(); + virtual ~Widget(); + + virtual const char *get_type_name() const; + + virtual void set_name(const char *name); + virtual const char *get_name() const; + + virtual void set_text(const char *text); + virtual const char *get_text() const; + + virtual void show(); + virtual void hide(); + virtual float get_visibility() const; + virtual bool is_visible() const; + + virtual void activate(); + virtual void deactivate(); + virtual float get_active() const; + virtual bool is_active() const; + + virtual void press(); + virtual void release(); + virtual float get_pressed() const; + virtual bool is_pressed() const; + + virtual void mousein(); + virtual void mouseout(); + virtual float get_under_mouse() const; + virtual bool is_under_mouse() const; + + // input focus, managed by the screen + virtual bool can_focus() const; + virtual void focusin(); + virtual void focusout(); + virtual float get_focus() const; + virtual bool is_focused() const; + + virtual void set_position(float x, float y); + virtual void set_position(const Vec2 &pos); + virtual const Vec2 &get_position() const; + + virtual void set_size(float x, float y); + virtual void set_size(const Vec2 &size); + virtual const Vec2 get_size() const; + + virtual const BBox &get_box() const; + + virtual bool hit_test(const Vec2 &pt) const; + + virtual void draw() const; + + // low level events + virtual void on_mouse_button(const ButtonEvent &ev); + virtual void on_mouse_motion(const MotionEvent &ev); + virtual void on_mouse_focus(const FocusEvent &ev); + virtual void on_key(const KeyEvent &ev); + + // high level events + virtual void on_click(); + virtual void on_double_click(); + virtual void on_change(); + //virtual void on_drag_move(int bn, const Vec2 &pt); + //virtual void on_drag_release(int bn, const Vec2 &pt); + + // event dispatcher + virtual void handle_event(const Event &ev); + + // external callback setting + virtual void set_callback(EventType evtype, EventCallback func, void *cls = 0); + + friend class Screen; +}; + +} + +#endif // GOATKIT_WIDGET_H_ diff -r 6a39b8912752 -r 3bccfc7d10fe sdr/color.p.glsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sdr/color.p.glsl Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,10 @@ +#ifdef GL_ES +precision mediump float; +#endif + +varying vec4 vcolor; + +void main() +{ + gl_FragColor = vcolor; +} \ No newline at end of file diff -r 6a39b8912752 -r 3bccfc7d10fe sdr/color.v.glsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sdr/color.v.glsl Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,12 @@ +attribute vec4 attr_vertex, attr_color; + +uniform mat4 matrix_modelview, matrix_projection; + +varying vec4 vcolor; + +void main() +{ + mat4 mvp = matrix_projection * matrix_modelview; + gl_Position = mvp * attr_vertex; + vcolor = attr_color; +} diff -r 6a39b8912752 -r 3bccfc7d10fe sdr/ui.p.glsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sdr/ui.p.glsl Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,14 @@ +#ifdef GL_ES +precision mediump float; +#endif + +uniform sampler2D tex; + +varying vec4 vcolor; +varying vec2 vtexcoord; + +void main() +{ + vec4 texel = texture2D(tex, vtexcoord); + gl_FragColor = vcolor * texel; +} diff -r 6a39b8912752 -r 3bccfc7d10fe sdr/ui.v.glsl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sdr/ui.v.glsl Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,15 @@ +attribute vec4 attr_vertex, attr_color; +attribute vec2 attr_texcoord; + +uniform mat4 matrix_modelview, matrix_projection; + +varying vec4 vcolor; +varying vec2 vtexcoord; + +void main() +{ + mat4 mvp = matrix_projection * matrix_modelview; + gl_Position = mvp * attr_vertex; + vcolor = attr_color; + vtexcoord = attr_texcoord; +} diff -r 6a39b8912752 -r 3bccfc7d10fe src/config.h --- a/src/config.h Tue Sep 22 07:13:47 2015 +0300 +++ b/src/config.h Wed Sep 23 05:44:58 2015 +0300 @@ -1,10 +1,13 @@ #ifndef CONFIG_H_ #define CONFIG_H_ -#if defined(__IPHONE_3_0) || defined(__IPHONE_3_2) || defined(__IPHONE_4_0) +#ifdef __APPLE__ +#include + +#if defined(TARGET_IPHONE_SIMULATOR) || defined(TARGET_OS_IPHONE) #define IPHONE - -#define glClearDepth glClearDepthf #endif +#endif /* __APPLE__ */ + #endif /* CONFIG_H_ */ diff -r 6a39b8912752 -r 3bccfc7d10fe src/ios/viewctl.m --- a/src/ios/viewctl.m Tue Sep 22 07:13:47 2015 +0300 +++ b/src/ios/viewctl.m Wed Sep 23 05:44:58 2015 +0300 @@ -152,6 +152,34 @@ printf("viewport %dx%d (scale: %g)\n", xsz, ysz, pixel_scale); } +- (void)touchesBegan: (NSSet*)touches withEvent: (UIEvent*)event +{ + UITouch *touch = [touches anyObject]; + CGPoint pt = [touch locationInView: nil]; + mouse_button(0, 1, pt.x, pt.y); +} + +- (void)touchesMoved: (NSSet*)touches withEvent: (UIEvent*)event +{ + UITouch *touch = [touches anyObject]; + CGPoint pt = [touch locationInView: nil]; + mouse_motion(pt.x, pt.y); +} + +- (void)touchesEnded: (NSSet*)touches withEvent: (UIEvent*)event +{ + UITouch *touch = [touches anyObject]; + CGPoint pt = [touch locationInView: nil]; + mouse_button(0, 0, pt.x, pt.y); +} + +- (void)touchesCancelled: (NSSet*)touches withEvent: (UIEvent*)event +{ + UITouch *touch = [touches anyObject]; + CGPoint pt = [touch locationInView: nil]; + mouse_button(0, 0, pt.x, pt.y); +} + // ADBannerDelegate functions - (void)bannerViewDidLoadAd: (ADBannerView*)banner diff -r 6a39b8912752 -r 3bccfc7d10fe src/istereo.c --- a/src/istereo.c Tue Sep 22 07:13:47 2015 +0300 +++ b/src/istereo.c Wed Sep 23 05:44:58 2015 +0300 @@ -1,6 +1,6 @@ /* Stereoscopic tunnel for iOS. -Copyright (C) 2011 John Tsiombikas +Copyright (C) 2011-2015 John Tsiombikas This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,6 +30,7 @@ #include "cam.h" #include "vmath.h" #include "config.h" +#include "ui.h" static void render(float t); static void draw_tunnel(float t); @@ -40,13 +41,14 @@ static unsigned int get_shader_program(const char *vfile, const char *pfile); static float get_sec(void); -unsigned int prog, prog_simple, prog_tunnel, prog_text; +unsigned int prog, prog_simple, prog_tunnel, prog_text, prog_color, prog_ui; unsigned int tex, tex_stones, tex_normal, tex_text; int view_xsz, view_ysz; int stereo = 0; int use_bump = 0; +int show_opt = 1; /* construction parameters */ int sides = 24; @@ -72,6 +74,12 @@ if(!(prog_text = get_shader_program("text.v.glsl", "text.p.glsl"))) { return -1; } + if(!(prog_color = get_shader_program("color.v.glsl", "color.p.glsl"))) { + return -1; + } + if(!(prog_ui = get_shader_program("ui.v.glsl", "ui.p.glsl"))) { + return -1; + } if(!(tex = load_texture(find_resource("tiles.jpg", 0, 0)))) { return -1; @@ -89,6 +97,10 @@ glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); + if(ui_init() == -1) { + return -1; + } + cam_fov(42.5); cam_clip(0.5, 250.0); @@ -97,7 +109,11 @@ void cleanup(void) { - free_program(prog); + ui_shutdown(); + free_program(prog_simple); + free_program(prog_tunnel); + free_program(prog_color); + free_program(prog_ui); } void redraw(void) @@ -187,6 +203,10 @@ } glDepthMask(1); } + + if(show_opt) { + ui_draw(); + } } static void draw_tunnel(float t) @@ -360,6 +380,22 @@ view_xsz = x; view_ysz = y; + + ui_reshape(x, y); +} + +void mouse_button(int bn, int press, int x, int y) +{ + if(show_opt) { + ui_button(bn, press, x, y); + } +} + +void mouse_motion(int x, int y) +{ + if(show_opt) { + ui_motion(x, y); + } } static unsigned int get_shader_program(const char *vfile, const char *pfile) diff -r 6a39b8912752 -r 3bccfc7d10fe src/istereo.h --- a/src/istereo.h Tue Sep 22 07:13:47 2015 +0300 +++ b/src/istereo.h Wed Sep 23 05:44:58 2015 +0300 @@ -24,5 +24,7 @@ void cleanup(void); void redraw(void); void reshape(int x, int y); +void mouse_button(int bn, int press, int x, int y); +void mouse_motion(int x, int y); #endif /* ISTEREO_H_ */ diff -r 6a39b8912752 -r 3bccfc7d10fe src/opengl.h --- a/src/opengl.h Tue Sep 22 07:13:47 2015 +0300 +++ b/src/opengl.h Wed Sep 23 05:44:58 2015 +0300 @@ -22,8 +22,12 @@ #include "config.h" -#ifdef IPHONE +#if defined(IPHONE) || defined(__IPHONE__) #include + +#define glClearDepth glClearDepthf +#define GLDEF +#include "sanegl.h" #else #include diff -r 6a39b8912752 -r 3bccfc7d10fe src/sanegl.c --- a/src/sanegl.c Tue Sep 22 07:13:47 2015 +0300 +++ b/src/sanegl.c Wed Sep 23 05:44:58 2015 +0300 @@ -21,6 +21,12 @@ #include #include #include + +#include "opengl.h" + +#ifdef GLDEF +#undef GLDEF +#endif #include "sanegl.h" #define MMODE_IDX(x) ((x) - GL_MODELVIEW) diff -r 6a39b8912752 -r 3bccfc7d10fe src/sanegl.h --- a/src/sanegl.h Tue Sep 22 07:13:47 2015 +0300 +++ b/src/sanegl.h Wed Sep 23 05:44:58 2015 +0300 @@ -74,6 +74,10 @@ #define glVertexAttrib4f gl_vertex_attrib4f #endif +#ifdef __cplusplus +extern "C" { +#endif + /* matrix stuff */ void gl_matrix_mode(int mmode); void gl_push_matrix(void); @@ -111,4 +115,8 @@ void gl_vertex_attrib3f(int loc, float x, float y, float z); void gl_vertex_attrib4f(int loc, float x, float y, float z, float w); +#ifdef __cplusplus +} +#endif + #endif /* SANEGL_H_ */ diff -r 6a39b8912752 -r 3bccfc7d10fe src/ui.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui.cc Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,131 @@ +#include "ui.h" +#include "goatkit/goatkit.h" +#include "opengl.h" +#include "sdr.h" + +static goatkit::Screen scr; +static int width, height; + +extern unsigned int prog_color, prog_ui; + +int ui_init(void) +{ + float ypos = 0; + float vsep = 0.1; + + goatkit::Label *label = new goatkit::Label; + label->set_position(0.5, ypos += vsep); + label->set_size(0.1, 0.1); + label->set_text("Stereoscopic rendering"); + scr.add_widget(label); + + /* + goatkit::Button *button = new goatkit::Button; + button->set_position(300, ypos += vsep); + button->set_size(200, 40); + button->set_text("a button!"); + button->set_callback(goatkit::EV_CLICK, callback); + scr.add_widget(button); + + goatkit::TextBox *text = new goatkit::TextBox; + text->set_position(300, ypos += vsep); + text->set_size(200, 30); + text->set_text("foo"); + text->set_callback(goatkit::EV_CHANGE, callback); + scr.add_widget(text); + + goatkit::CheckBox *cbox = new goatkit::CheckBox; + cbox->set_position(300, ypos += vsep); + cbox->set_size(200, 20); + cbox->set_text("a checkbox!"); + cbox->set_callback(goatkit::EV_CHANGE, callback); + scr.add_widget(cbox); + + goatkit::Slider *slider = new goatkit::Slider; + slider->set_position(300, ypos += vsep); + slider->set_size(200, 40); + slider->set_callback(goatkit::EV_CHANGE, callback); + slider->set_continuous_change(false); + slider->set_range(0, 100.0); + scr.add_widget(slider); + + goatkit::Slider *intslider = new goatkit::Slider; + intslider->set_position(300, ypos += vsep); + intslider->set_size(200, 40); + intslider->set_callback(goatkit::EV_CHANGE, callback); + intslider->set_continuous_change(false); + intslider->set_range(0, 100.0); + intslider->set_step(10); + scr.add_widget(intslider); + */ + + scr.show(); + + // load the theme + //goatkit::add_theme_path("themes/simple"); + + //goatkit::theme = new goatkit::Theme; + //goatkit::theme->load("simple"); + + return 0; +} + +void ui_shutdown(void) +{ +} + +void ui_reshape(int x, int y) +{ + width = x; + height = y; +} + +void ui_draw(void) +{ + float aspect = (float)width / (float)height; + + bind_program(prog_ui); + + gl_matrix_mode(GL_PROJECTION); + gl_push_matrix(); + gl_load_identity(); + gl_scalef(2.0 / aspect, 2.0, 1); + gl_translatef(-1, -1, 0); + gl_scalef(1, -1, 1); + gl_matrix_mode(GL_MODELVIEW); + gl_push_matrix(); + gl_load_identity(); + + glDisable(GL_CULL_FACE); + glDisable(GL_DEPTH_TEST); + + /*gl_begin(GL_QUADS); + gl_color3f(1, 0, 0); + gl_vertex3f(0, 0, 0); + gl_vertex3f(0, 0.5, 0); + gl_vertex3f(0.5 * aspect, 0.5, 0); + gl_vertex3f(0.5 * aspect, 0, 0); + gl_end(); + */ + + scr.draw(); + + glEnable(GL_CULL_FACE); + glEnable(GL_DEPTH_TEST); + + + gl_matrix_mode(GL_PROJECTION); + gl_pop_matrix(); + gl_matrix_mode(GL_MODELVIEW); + gl_pop_matrix(); +} + +void ui_button(int bn, int press, int x, int y) +{ + scr.sysev_mouse_button(bn, press != 0, (float)x / (float)width, 1.0 - (float)y / (float)height); +} + +void ui_motion(int x, int y) +{ + scr.sysev_mouse_motion((float)x / (float)width, 1.0 - (float)y / (float)height); +} \ No newline at end of file diff -r 6a39b8912752 -r 3bccfc7d10fe src/ui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui.h Wed Sep 23 05:44:58 2015 +0300 @@ -0,0 +1,21 @@ +#ifndef UI_H_ +#define UI_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +int ui_init(void); +void ui_shutdown(void); + +void ui_reshape(int x, int y); +void ui_draw(void); + +void ui_button(int bn, int press, int x, int y); +void ui_motion(int x, int y); + +#ifdef __cplusplus +} +#endif + +#endif /* UI_H_ */