├── docs ├── layout │ ├── guide.css │ ├── guide.pug │ ├── page.pug │ ├── style.css │ ├── api.css │ └── index.pug ├── development │ ├── README.md │ └── roadmap.md ├── api │ ├── textmetrics.yaml │ ├── keyevent.yaml │ ├── filedialog_option.yaml │ ├── keyboardmodifier.yaml │ ├── font_style.yaml │ ├── entry_type.yaml │ ├── filesavedialog.yaml │ ├── textalign.yaml │ ├── app_themecolor.yaml │ ├── eventtype.yaml │ ├── button_type.yaml │ ├── scroll_policy.yaml │ ├── menubar.yaml │ ├── vibrant_blendingmode.yaml │ ├── mouseevent.yaml │ ├── protocolfilejob.yaml │ ├── fileopendialog.yaml │ ├── toolbar_displaymode.yaml │ ├── vibrant_material.yaml │ ├── protocolstringjob.yaml │ ├── menuitem_type.yaml │ ├── textattributes.yaml │ ├── menu.yaml │ ├── toolbar_item.yaml │ ├── filedialog_filter.yaml │ ├── window_options.yaml │ ├── font_weight.yaml │ ├── browser_options.yaml │ ├── menubase.yaml │ ├── state.yaml │ ├── label.yaml │ ├── group.yaml │ ├── buffer.yaml │ ├── progressbar.yaml │ ├── lifetime.yaml │ ├── image.yaml │ ├── entry.yaml │ └── canvas.yaml ├── paid_plans │ ├── README.md │ └── ALTERNATIVE_LICENSE └── guides │ └── lua │ └── getting_started.md ├── third_party ├── libxml │ ├── DEPS │ ├── src │ │ ├── macos │ │ │ ├── src │ │ │ │ ├── macos_main.c │ │ │ │ ├── XMLTestPrefix.h │ │ │ │ ├── XMLTestPrefix2.h │ │ │ │ └── libxml2_GUSIConfig.cp │ │ │ └── README │ │ ├── win32 │ │ │ └── VC10 │ │ │ │ ├── RuleSet1.ruleset │ │ │ │ └── README.vc10 │ │ ├── include │ │ │ ├── Makefile.am │ │ │ └── libxml │ │ │ │ └── Makefile.am │ │ ├── AUTHORS │ │ ├── testdso.c │ │ ├── xml2Conf.sh.in │ │ ├── libxml-2.0-uninstalled.pc.in │ │ ├── bakefile │ │ │ └── Bakefiles.bkgen │ │ ├── libxml-2.0.pc.in │ │ ├── xzlib.h │ │ ├── m4 │ │ │ └── ltversion.m4 │ │ ├── acinclude.m4 │ │ ├── enc.h │ │ ├── TODO_SCHEMAS │ │ ├── Makefile.tests │ │ ├── save.h │ │ ├── xml2-config.1 │ │ ├── README │ │ ├── COPYING │ │ └── Copyright │ └── OWNERS ├── apple_apsl │ └── OWNERS └── ced │ ├── OWNERS │ └── README.chromium ├── sample_app ├── README ├── BUILD.gn └── main.cc ├── tools └── win │ ├── tar.exe │ └── DebugVisualizers │ └── skia.natvis ├── nativeui ├── test │ ├── fixtures │ │ ├── static.png │ │ └── animated.gif │ ├── run_all_unittests.cc │ └── gfx_util.h ├── gtk │ ├── state_gtk.cc │ ├── menu_bar_gtk.cc │ ├── lifetime_gtk.cc │ ├── undoable_text_buffer.h │ ├── file_save_dialog_gtk.cc │ ├── menu_gtk.cc │ ├── nu_image.h │ ├── file_open_dialog_gtk.cc │ ├── nu_container.h │ └── accelerator_manager_gtk.cc ├── gfx │ ├── gtk │ │ ├── color_gtk.cc │ │ ├── screen_gtk.cc │ │ └── canvas_gtk.cc │ ├── painter.cc │ ├── win │ │ ├── color_win.cc │ │ ├── screen_win.h │ │ ├── text_win.h │ │ ├── text_win.cc │ │ ├── scoped_set_map_mode.h │ │ ├── double_buffer.h │ │ ├── canvas_win.cc │ │ └── image_win.cc │ ├── font.cc │ ├── screen.h │ ├── mac │ │ ├── screen_mac.mm │ │ ├── color_mac.mm │ │ ├── text_mac.h │ │ └── text_mac.mm │ ├── canvas.cc │ ├── text.cc │ ├── geometry │ │ ├── point_conversions.cc │ │ ├── size_conversions.cc │ │ ├── size_conversions.h │ │ ├── insets.cc │ │ ├── point_conversions.h │ │ ├── vector2d_conversions.cc │ │ ├── insets_f.cc │ │ ├── vector2d_conversions.h │ │ ├── vector2d.cc │ │ └── point_f.cc │ └── text.h ├── win │ ├── menu_bar_win.cc │ ├── lifetime_win.cc │ ├── browser │ │ ├── browser_util.h │ │ └── browser_protocol_factory.h │ ├── menu_base_win.h │ ├── app_win.cc │ ├── menu_item_win.h │ ├── file_save_dialog_win.h │ ├── file_open_dialog_win.h │ ├── util │ │ ├── gdiplus_holder.h │ │ ├── subwin_holder.cc │ │ ├── scoped_ole_initializer.h │ │ ├── scoped_ole_initializer.cc │ │ └── subwin_holder.h │ ├── menu_win.cc │ ├── edit_view.h │ ├── file_save_dialog_win.cc │ ├── clickable.h │ ├── tray_win.h │ ├── focus_manager.h │ └── scrollbar │ │ ├── scrollbar_thumb.h │ │ └── repeat_controller.h ├── mac │ ├── menu_bar_mac.mm │ ├── nu_private.mm │ ├── file_save_dialog_mac.mm │ ├── browser │ │ ├── nu_web_ui_delegate.h │ │ └── nu_custom_protocol.h │ ├── buffer_mac.mm │ ├── menu_mac.mm │ ├── container_mac.h │ ├── nu_application_delegate.h │ ├── nu_window.h │ ├── events_handler.h │ ├── lifetime_mac.mm │ ├── menu_base_mac.mm │ ├── mouse_capture.h │ ├── file_open_dialog_mac.mm │ ├── nu_application_delegate.mm │ ├── state_mac.mm │ ├── tray_mac.mm │ ├── nu_private.h │ ├── group_mac.mm │ └── nu_view.h ├── menu.cc ├── entry.cc ├── text_edit.cc ├── progress_bar.cc ├── label.cc ├── menu_bar.cc ├── events │ ├── gtk │ │ └── keyboard_code_conversion_gtk.h │ ├── keyboard_codes.h │ ├── win │ │ └── event_win.h │ └── keyboard_code_conversion.h ├── file_save_dialog.h ├── message_loop_unittests.cc ├── util │ ├── yoga_util.h │ └── aes.h ├── file_open_dialog.h ├── menu.h ├── button.cc ├── menu_unittests.cc ├── lifetime.cc ├── nativeui_export.h ├── progress_bar.h ├── group_unittest.cc ├── asar_archive.h ├── entry.h ├── label.h ├── protocol_file_job.h ├── scroll.cc ├── protocol_asar_job.h ├── app.cc ├── group.cc ├── label_unittest.cc ├── menu_bar.h ├── vibrant.h ├── group.h └── scroll.h ├── .gitattributes ├── v8binding ├── node.gni ├── v8binding.h ├── locker.cc ├── util.h ├── locker.h ├── ref_method.cc └── dict.cc ├── lua ├── test │ └── run_all_unittests.cc ├── lua.h ├── util.h ├── table.cc ├── state.h ├── stack_auto_reset.h ├── call_context.h └── ref_method.cc ├── lua_yue ├── test │ └── run_all_unittests.cc ├── binding_sys.h ├── binding_util.h ├── builtin_loader.h ├── binding_gui.h ├── binding_values.h ├── binding_sys.cc └── binding_values_unittest.cc ├── .gitignore ├── BUILD.gn ├── scripts ├── build.js ├── download_gn.js └── download_lua_libs.js ├── .gn ├── node_yue ├── node_integration_mac.h ├── node_integration_win.h ├── chrome_view_mac.h ├── delay_load_hook_win.cc ├── node_integration_linux.h ├── binding_values.h ├── node_integration_linux.cc ├── binding_values.cc ├── chrome_view_mac.mm ├── node_integration_mac.cc ├── BUILD.gn └── node_integration_win.cc ├── secondary └── third_party │ └── yoga │ └── BUILD.gn ├── .appveyor.yml ├── .gitmodules └── .travis.yml /docs/layout/guide.css: -------------------------------------------------------------------------------- 1 | #sidebar { 2 | display: none; 3 | } 4 | -------------------------------------------------------------------------------- /third_party/libxml/DEPS: -------------------------------------------------------------------------------- 1 | include_rules = [ 2 | '+libxml', 3 | ] 4 | -------------------------------------------------------------------------------- /third_party/apple_apsl/OWNERS: -------------------------------------------------------------------------------- 1 | avi@chromium.org 2 | mark@chromium.org 3 | -------------------------------------------------------------------------------- /third_party/ced/OWNERS: -------------------------------------------------------------------------------- 1 | jinsukkim@chromium.org 2 | jshin@chromium.org 3 | -------------------------------------------------------------------------------- /third_party/libxml/src/macos/src/macos_main.c: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /sample_app/README: -------------------------------------------------------------------------------- 1 | A C++ sample app showing how to build with libyue binaries. 2 | -------------------------------------------------------------------------------- /tools/win/tar.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyyd/yue/master/tools/win/tar.exe -------------------------------------------------------------------------------- /docs/layout/guide.pug: -------------------------------------------------------------------------------- 1 | extends page.pug 2 | 3 | block content 4 | != doc.content 5 | -------------------------------------------------------------------------------- /third_party/libxml/src/macos/src/XMLTestPrefix.h: -------------------------------------------------------------------------------- 1 | int test_main(int argc, char **argv); 2 | -------------------------------------------------------------------------------- /third_party/libxml/src/macos/src/XMLTestPrefix2.h: -------------------------------------------------------------------------------- 1 | int test_main(int argc, char* argv[]); 2 | -------------------------------------------------------------------------------- /nativeui/test/fixtures/static.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyyd/yue/master/nativeui/test/fixtures/static.png -------------------------------------------------------------------------------- /nativeui/test/fixtures/animated.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oyyd/yue/master/nativeui/test/fixtures/animated.gif -------------------------------------------------------------------------------- /third_party/libxml/src/macos/src/libxml2_GUSIConfig.cp: -------------------------------------------------------------------------------- 1 | /**************** BEGIN GUSI CONFIGURATION **************************** 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | build/* linguist-vendored 2 | tools/* linguist-vendored 3 | testing/* linguist-vendored 4 | third_party/* linguist-vendored 5 | -------------------------------------------------------------------------------- /third_party/libxml/src/win32/VC10/RuleSet1.ruleset: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /third_party/libxml/src/include/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | SUBDIRS=libxml 3 | 4 | EXTRA_DIST = win32config.h wsockcompat.h 5 | 6 | -------------------------------------------------------------------------------- /third_party/libxml/OWNERS: -------------------------------------------------------------------------------- 1 | # There's no real owners here. If you're familiar with the code please send 2 | # a CL to add yourself here. 3 | cpu@chromium.org 4 | dominicc@chromium.org 5 | scottmg@chromium.org 6 | -------------------------------------------------------------------------------- /docs/development/README.md: -------------------------------------------------------------------------------- 1 | # Development 2 | 3 | * [Roadmap](https://github.com/yue/yue/blob/master/docs/development/roadmap.md) 4 | * [Build instructions](https://github.com/yue/yue/blob/master/docs/development/build_instructions.md) 5 | -------------------------------------------------------------------------------- /third_party/libxml/src/AUTHORS: -------------------------------------------------------------------------------- 1 | Daniel Veillard 2 | Bjorn Reese 3 | William Brack 4 | Igor Zlatkovic for the Windows port 5 | Aleksey Sanin 6 | -------------------------------------------------------------------------------- /third_party/libxml/src/testdso.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define IN_LIBXML 4 | #include "libxml/xmlexports.h" 5 | 6 | XMLPUBFUN int hello_world(void); 7 | 8 | int hello_world(void) 9 | { 10 | printf("Success!\n"); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /third_party/libxml/src/xml2Conf.sh.in: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for using the XML library in GNOME applications 3 | # 4 | XML2_LIBDIR="@XML_LIBDIR@" 5 | XML2_LIBS="@XML_LIBS@" 6 | XML2_INCLUDEDIR="@XML_INCLUDEDIR@" 7 | MODULE_VERSION="xml2-@VERSION@" 8 | 9 | -------------------------------------------------------------------------------- /docs/api/textmetrics.yaml: -------------------------------------------------------------------------------- 1 | name: TextMetrics 2 | header: nativeui/gfx/text.h 3 | type: struct 4 | namespace: nu 5 | description: Text measurement. 6 | 7 | properties: 8 | - property: SizeF size 9 | description: Size needed for drawing the text. 10 | -------------------------------------------------------------------------------- /third_party/libxml/src/macos/README: -------------------------------------------------------------------------------- 1 | This is a MacOS port contribution (not to be used for MacOS-X) 2 | for the CodeWarrior environment. 3 | Please contact the author directly in case of problems: 4 | Eric 5 | 6 | thanks, 7 | 8 | Daniel 9 | -------------------------------------------------------------------------------- /docs/api/keyevent.yaml: -------------------------------------------------------------------------------- 1 | name: KeyEvent 2 | header: nativeui/events/event.h 3 | type: struct 4 | namespace: nu 5 | inherit: Event 6 | description: Keyboard event. 7 | 8 | properties: 9 | - property: KeyboardCode key 10 | description: The key associated with the event. 11 | -------------------------------------------------------------------------------- /nativeui/gtk/state_gtk.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/state.h" 6 | 7 | namespace nu { 8 | 9 | void State::PlatformInit() { 10 | } 11 | 12 | } // namespace nu 13 | -------------------------------------------------------------------------------- /v8binding/node.gni: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Cheng Zhao. All rights reserved. 2 | # Use of this source code is governed by the license that can be found in the 3 | # LICENSE file. 4 | 5 | declare_args() { 6 | # The version of Node to build against to. 7 | node_version = "v7.7.1" 8 | # The runtime used. 9 | node_runtime = "node" 10 | } 11 | -------------------------------------------------------------------------------- /sample_app/BUILD.gn: -------------------------------------------------------------------------------- 1 | # This file is published under public domain. 2 | 3 | executable("sample_app") { 4 | sources = [ "main.cc" ] 5 | 6 | deps = [ 7 | "//base", 8 | "//nativeui", 9 | ] 10 | 11 | if (is_win) { 12 | configs -= [ "//build/config/win:console" ] 13 | configs += [ "//build/config/win:windowed" ] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /nativeui/gfx/gtk/color_gtk.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | 3 | #include "nativeui/gfx/color.h" 4 | 5 | #include 6 | 7 | namespace nu { 8 | 9 | GdkRGBA Color::ToGdkRGBA() const { 10 | GdkRGBA rgba = { r() / 255., g() / 255., b() / 255., a() / 255. }; 11 | return rgba; 12 | } 13 | 14 | } // namespace nu 15 | -------------------------------------------------------------------------------- /nativeui/gfx/painter.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/gfx/painter.h" 6 | 7 | namespace nu { 8 | 9 | Painter::Painter() : weak_factory_(this) {} 10 | 11 | Painter::~Painter() {} 12 | 13 | } // namespace nu 14 | -------------------------------------------------------------------------------- /docs/api/filedialog_option.yaml: -------------------------------------------------------------------------------- 1 | name: FileDialog::Option 2 | lang: ['cpp'] 3 | header: nativeui/file_dialog.h 4 | type: enum 5 | namespace: nu 6 | description: The file dialog option masks. 7 | 8 | detail: | 9 | `FileDialog::Option` is an `enum` with following values: 10 | 11 | * `OPTION_PICK_FOLDERS` 12 | * `OPTION_MULTI_SELECT` 13 | * `OPTION_SHOW_HIDDEN` 14 | -------------------------------------------------------------------------------- /docs/api/keyboardmodifier.yaml: -------------------------------------------------------------------------------- 1 | name: KeyboardModifier 2 | lang: ['cpp'] 3 | header: nativeui/events/keyboard_codes.h 4 | type: enum 5 | namespace: nu 6 | description: The keyboard modifier masks. 7 | 8 | detail: | 9 | `KeyboardModifier` is an `enum` with following values: 10 | 11 | * `MASK_SHIFT` 12 | * `MASK_CONTROL` 13 | * `MASK_ALT` 14 | * `MASK_META` 15 | -------------------------------------------------------------------------------- /lua/test/run_all_unittests.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "testing/gtest/include/gtest/gtest.h" 6 | 7 | int main(int argc, char** argv) { 8 | ::testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } 11 | -------------------------------------------------------------------------------- /nativeui/gfx/win/color_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/gfx/color.h" 6 | 7 | namespace nu { 8 | 9 | COLORREF Color::ToCOLORREF() const { 10 | return RGB(r(), g(), b()); 11 | } 12 | 13 | } // namespace nu 14 | -------------------------------------------------------------------------------- /nativeui/win/menu_bar_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/menu_bar.h" 6 | 7 | namespace nu { 8 | 9 | NativeMenu MenuBar::PlatformCreate() const { 10 | return CreateMenu(); 11 | } 12 | 13 | } // namespace nu 14 | -------------------------------------------------------------------------------- /lua_yue/test/run_all_unittests.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "testing/gtest/include/gtest/gtest.h" 6 | 7 | int main(int argc, char** argv) { 8 | ::testing::InitGoogleTest(&argc, argv); 9 | return RUN_ALL_TESTS(); 10 | } 11 | -------------------------------------------------------------------------------- /nativeui/win/lifetime_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/lifetime.h" 6 | 7 | namespace nu { 8 | 9 | void Lifetime::PlatformInit() { 10 | } 11 | 12 | void Lifetime::PlatformDestroy() { 13 | } 14 | 15 | } // namespace nu 16 | -------------------------------------------------------------------------------- /lua_yue/binding_sys.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef LUA_YUE_BINDING_SYS_H_ 6 | #define LUA_YUE_BINDING_SYS_H_ 7 | 8 | #include "lua/lua.h" 9 | 10 | extern "C" int luaopen_yue_sys(lua::State* state); 11 | 12 | #endif // LUA_YUE_BINDING_SYS_H_ 13 | -------------------------------------------------------------------------------- /lua_yue/binding_util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef LUA_YUE_BINDING_UTIL_H_ 6 | #define LUA_YUE_BINDING_UTIL_H_ 7 | 8 | #include "lua/lua.h" 9 | 10 | extern "C" int luaopen_yue_util(lua::State* state); 11 | 12 | #endif // LUA_YUE_BINDING_UTIL_H_ 13 | -------------------------------------------------------------------------------- /lua/lua.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef LUA_LUA_H_ 6 | #define LUA_LUA_H_ 7 | 8 | #include "lua/index.h" 9 | #include "lua/metatable.h" 10 | #include "lua/pcall.h" 11 | #include "lua/ref_method.h" 12 | #include "lua/util.h" 13 | 14 | #endif // LUA_LUA_H_ 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .tags* 3 | /out/ 4 | /third_party/llvm-build/ 5 | /third_party/node-*/ 6 | /third_party/lua_binaries_*/ 7 | /third_party/debian_stretch_amd64-sysroot/ 8 | /third_party/debian_stretch_i386-sysroot/ 9 | /third_party/debian_stretch_arm-sysroot/ 10 | /third_party/debian_stretch_arm64-sysroot/ 11 | /tools/gn/ 12 | *.xcodeproj 13 | *.swp 14 | *.pyc 15 | debug.log 16 | npm-debug.log 17 | -------------------------------------------------------------------------------- /third_party/libxml/src/libxml-2.0-uninstalled.pc.in: -------------------------------------------------------------------------------- 1 | prefix= 2 | exec_prefix= 3 | libdir=${pcfiledir} 4 | includedir=${pcfiledir}/include 5 | 6 | 7 | Name: libXML 8 | Version: @VERSION@ 9 | Description: libXML library version2. 10 | Requires: 11 | Libs: -L${libdir} -lxml2 @ICU_LIBS@ @THREAD_LIBS@ @Z_LIBS@ @LZMA_LIBS@ @ICONV_LIBS@ @M_LIBS@ @LIBS@ 12 | Cflags: -I${includedir} @XML_INCLUDEDIR@ @XML_CFLAGS@ 13 | -------------------------------------------------------------------------------- /BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Cheng Zhao. All rights reserved. 2 | # Use of this source code is governed by the MIT license that can be 3 | # found in the LICENSE file. 4 | 5 | group("default") { 6 | deps = [ 7 | "//node_yue", 8 | "//lua_yue:yue", 9 | "//lua_yue:lua_yue", 10 | "//sample_app", 11 | ] 12 | 13 | if (!is_component_build) { 14 | deps += [ "//nativeui:libyue" ] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /nativeui/mac/menu_bar_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/menu_bar.h" 6 | 7 | #import 8 | 9 | namespace nu { 10 | 11 | NativeMenu MenuBar::PlatformCreate() const { 12 | return [[NSMenu alloc] init]; 13 | } 14 | 15 | } // namespace nu 16 | -------------------------------------------------------------------------------- /nativeui/menu.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/menu.h" 6 | 7 | namespace nu { 8 | 9 | // static 10 | const char Menu::kClassName[] = "Menu"; 11 | 12 | const char* Menu::GetClassName() const { 13 | return kClassName; 14 | } 15 | 16 | } // namespace nu 17 | -------------------------------------------------------------------------------- /nativeui/entry.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/entry.h" 6 | 7 | namespace nu { 8 | 9 | // static 10 | const char Entry::kClassName[] = "Entry"; 11 | 12 | const char* Entry::GetClassName() const { 13 | return kClassName; 14 | } 15 | 16 | } // namespace nu 17 | -------------------------------------------------------------------------------- /nativeui/mac/nu_private.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/mac/nu_private.h" 6 | 7 | #include "nativeui/mac/mouse_capture.h" 8 | 9 | namespace nu { 10 | 11 | NUPrivate::NUPrivate() { 12 | } 13 | 14 | NUPrivate::~NUPrivate() { 15 | } 16 | 17 | } // namespace nu 18 | -------------------------------------------------------------------------------- /docs/paid_plans/README.md: -------------------------------------------------------------------------------- 1 | # Paid plans of Yue 2 | 3 | By subscribing to the paid plan, you may use the source code of Yue under the 4 | [MIT License](./ALTERNATIVE_LICENSE), and get premium support from developers 5 | of Yue. 6 | 7 | You can send email to Cheng Zhao (zcbenz@gmail.com) to discuss the details of 8 | the deal, the number would depend on the size of your organization and what 9 | kind of support you want. 10 | -------------------------------------------------------------------------------- /nativeui/gtk/menu_bar_gtk.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/menu_bar.h" 6 | 7 | #include 8 | 9 | namespace nu { 10 | 11 | NativeMenu MenuBar::PlatformCreate() const { 12 | return GTK_MENU_SHELL(gtk_menu_bar_new()); 13 | } 14 | 15 | } // namespace nu 16 | -------------------------------------------------------------------------------- /nativeui/text_edit.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/text_edit.h" 6 | 7 | namespace nu { 8 | 9 | // static 10 | const char TextEdit::kClassName[] = "TextEdit"; 11 | 12 | const char* TextEdit::GetClassName() const { 13 | return kClassName; 14 | } 15 | 16 | } // namespace nu 17 | -------------------------------------------------------------------------------- /third_party/libxml/src/bakefile/Bakefiles.bkgen: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | gnu,dmars,cbx_unix,cbuilderx 7 | libxml2.bkl 8 | 9 | 10 | 11 | borland,dmars,mingw,msvc,msvc6prj,watcom,cbuilderx,cbx_unix,gnu 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /nativeui/gtk/lifetime_gtk.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/lifetime.h" 6 | 7 | #include 8 | 9 | namespace nu { 10 | 11 | void Lifetime::PlatformInit() { 12 | gtk_init(nullptr, nullptr); 13 | } 14 | 15 | void Lifetime::PlatformDestroy() { 16 | } 17 | 18 | } // namespace nu 19 | -------------------------------------------------------------------------------- /nativeui/progress_bar.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/progress_bar.h" 6 | 7 | namespace nu { 8 | 9 | // static 10 | const char ProgressBar::kClassName[] = "ProgressBar"; 11 | 12 | const char* ProgressBar::GetClassName() const { 13 | return kClassName; 14 | } 15 | 16 | } // namespace nu 17 | -------------------------------------------------------------------------------- /third_party/libxml/src/libxml-2.0.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | modules=@WITH_MODULES@ 6 | 7 | Name: libXML 8 | Version: @VERSION@ 9 | Description: libXML library version2. 10 | Requires: 11 | Libs: -L${libdir} -lxml2 12 | Libs.private: @ICU_LIBS@ @THREAD_LIBS@ @Z_LIBS@ @LZMA_LIBS@ @ICONV_LIBS@ @M_LIBS@ @WIN32_EXTRA_LIBADD@ @LIBS@ 13 | Cflags: @XML_INCLUDEDIR@ @XML_CFLAGS@ 14 | -------------------------------------------------------------------------------- /nativeui/test/run_all_unittests.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "base/debug/stack_trace.h" 6 | #include "testing/gtest/include/gtest/gtest.h" 7 | 8 | int main(int argc, char** argv) { 9 | ::testing::InitGoogleTest(&argc, argv); 10 | base::debug::EnableInProcessStackDumping(); 11 | return RUN_ALL_TESTS(); 12 | } 13 | -------------------------------------------------------------------------------- /nativeui/gfx/font.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/gfx/font.h" 6 | 7 | #include "nativeui/app.h" 8 | 9 | namespace nu { 10 | 11 | Font* Font::Derive(float size_delta, Weight weight, Style style) const { 12 | return new Font(GetName(), GetSize() + size_delta, weight, style); 13 | } 14 | 15 | } // namespace nu 16 | -------------------------------------------------------------------------------- /docs/api/font_style.yaml: -------------------------------------------------------------------------------- 1 | name: Font::Style 2 | header: nativeui/gfx/font.h 3 | type: enum class 4 | namespace: nu 5 | description: Represent font styles. 6 | 7 | lang_detail: 8 | cpp: | 9 | This type is an `enum class` with following values: 10 | * `Font::Style::Normal` 11 | * `Font::Style::Italic` 12 | 13 | lua: &ref | 14 | This type is a string with following possible values: 15 | * `"normal"` 16 | * `"italic"` 17 | 18 | js: *ref 19 | 20 | -------------------------------------------------------------------------------- /nativeui/mac/file_save_dialog_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/file_save_dialog.h" 6 | 7 | #import 8 | 9 | namespace nu { 10 | 11 | FileSaveDialog::FileSaveDialog() : FileDialog([NSSavePanel savePanel]) { 12 | } 13 | 14 | FileSaveDialog::~FileSaveDialog() { 15 | } 16 | 17 | } // namespace nu 18 | -------------------------------------------------------------------------------- /third_party/ced/README.chromium: -------------------------------------------------------------------------------- 1 | Name: Compact Encoding Detection 2 | Short Name: ced 3 | URL: https://github.com/google/compact_enc_det 4 | Version: 2f40a850bcc5d6f7c1bfa02dbf42ad19d8220dc0 5 | License: Apache 2.0 6 | License File: LICENSE 7 | Security Critical: yes 8 | 9 | Description: 10 | Compact Encoding Detection(CED for short) is a library written in C++ that 11 | scans given raw bytes and detect the most likely text encoding. 12 | 13 | Local Modifications: None 14 | -------------------------------------------------------------------------------- /v8binding/v8binding.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef V8BINDING_V8BINDING_H_ 6 | #define V8BINDING_V8BINDING_H_ 7 | 8 | #include "v8binding/dict.h" 9 | #include "v8binding/property.h" 10 | #include "v8binding/prototype.h" 11 | #include "v8binding/ref_method.h" 12 | #include "v8binding/util.h" 13 | 14 | #endif // V8BINDING_V8BINDING_H_ 15 | -------------------------------------------------------------------------------- /docs/api/entry_type.yaml: -------------------------------------------------------------------------------- 1 | name: Entry::Type 2 | header: nativeui/entry.h 3 | type: enum class 4 | namespace: nu 5 | description: Represent possible `Entry` types. 6 | 7 | lang_detail: 8 | cpp: | 9 | This type is an `enum class` with following values: 10 | * `Entry::Type::Normal` 11 | * `Entry::Type::Password` 12 | 13 | lua: &ref | 14 | This type is a string with following possible values: 15 | * `"normal"` 16 | * `"password"` 17 | 18 | js: *ref 19 | -------------------------------------------------------------------------------- /nativeui/mac/browser/nu_web_ui_delegate.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_MAC_BROWSER_NU_WEB_UI_DELEGATE_H_ 6 | #define NATIVEUI_MAC_BROWSER_NU_WEB_UI_DELEGATE_H_ 7 | 8 | #include 9 | 10 | @interface NUWebUIDelegate : NSObject 11 | @end 12 | 13 | #endif // NATIVEUI_MAC_BROWSER_NU_WEB_UI_DELEGATE_H_ 14 | -------------------------------------------------------------------------------- /docs/api/filesavedialog.yaml: -------------------------------------------------------------------------------- 1 | name: FileSaveDialog 2 | component: gui 3 | header: nativeui/file_save_dialog.h 4 | type: refcounted 5 | namespace: nu 6 | inherit: FileDialog 7 | description: Dialog used for saveing files. 8 | 9 | constructors: 10 | - signature: FileSaveDialog() 11 | lang: ['cpp'] 12 | description: Create a save dialog. 13 | 14 | class_methods: 15 | - signature: FileSaveDialog* Create() 16 | lang: ['lua', 'js'] 17 | description: Create an save dialog. 18 | -------------------------------------------------------------------------------- /nativeui/gfx/screen.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_GFX_SCREEN_H_ 6 | #define NATIVEUI_GFX_SCREEN_H_ 7 | 8 | #include "nativeui/nativeui_export.h" 9 | 10 | namespace nu { 11 | 12 | // Returns the default scale factor. 13 | float NATIVEUI_EXPORT GetScaleFactor(); 14 | 15 | } // namespace nu 16 | 17 | #endif // NATIVEUI_GFX_SCREEN_H_ 18 | -------------------------------------------------------------------------------- /docs/api/textalign.yaml: -------------------------------------------------------------------------------- 1 | name: TextAlign 2 | header: nativeui/gfx/text.h 3 | type: enum class 4 | namespace: nu 5 | description: Text alignment. 6 | 7 | lang_detail: 8 | cpp: | 9 | This type is an `enum class` with following values: 10 | * `TextAlign::Start` 11 | * `TextAlign::Center` 12 | * `TextAlign::End` 13 | 14 | lua: &ref | 15 | This type is a string with following possible values: 16 | * `"start"` 17 | * `"center"` 18 | * `"end"` 19 | 20 | js: *ref 21 | -------------------------------------------------------------------------------- /v8binding/locker.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "v8binding/locker.h" 6 | 7 | #include "v8.h" // NOLINT(build/include) 8 | 9 | namespace vb { 10 | 11 | Locker::Locker(v8::Isolate* isolate) { 12 | if (v8::Locker::IsActive()) 13 | locker_.reset(new v8::Locker(isolate)); 14 | } 15 | 16 | Locker::~Locker() { 17 | } 18 | 19 | } // namespace vb 20 | -------------------------------------------------------------------------------- /docs/api/app_themecolor.yaml: -------------------------------------------------------------------------------- 1 | name: App::ThemeColor 2 | header: nativeui/app.h 3 | type: enum class 4 | namespace: nu 5 | description: Represent possible theme colors. 6 | 7 | lang_detail: 8 | cpp: | 9 | This type is an `enum class` with following values: 10 | * `App::ThemeColor::Text` 11 | * `App::ThemeColor::DisabledText` 12 | 13 | lua: &ref | 14 | This type is a string with following possible values: 15 | * `"text"` 16 | * `"disabled-text"` 17 | 18 | js: *ref 19 | -------------------------------------------------------------------------------- /nativeui/mac/buffer_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/buffer.h" 6 | 7 | #import 8 | 9 | namespace nu { 10 | 11 | NSData* Buffer::ToNSData() const { 12 | return [NSData dataWithBytesNoCopy:content_ 13 | length:size_ 14 | freeWhenDone:NO]; 15 | } 16 | 17 | } // namespace nu 18 | -------------------------------------------------------------------------------- /nativeui/win/browser/browser_util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_BROWSER_BROWSER_UTIL_H_ 6 | #define NATIVEUI_WIN_BROWSER_BROWSER_UTIL_H_ 7 | 8 | namespace nu { 9 | 10 | // Set register key to prevent using compatible mode of IE. 11 | void FixIECompatibleMode(); 12 | 13 | } // namespace nu 14 | 15 | #endif // NATIVEUI_WIN_BROWSER_BROWSER_UTIL_H_ 16 | -------------------------------------------------------------------------------- /docs/api/eventtype.yaml: -------------------------------------------------------------------------------- 1 | name: EventType 2 | lang: ['cpp'] 3 | header: nativeui/events/event.h 4 | type: enum class 5 | namespace: nu 6 | description: Represent possible event types. 7 | 8 | detail: | 9 | `EventType` is an `enum class` with following values: 10 | 11 | * `EventType::Unknown` 12 | * `EventType::MouseDown` 13 | * `EventType::MouseUp` 14 | * `EventType::MouseMove` 15 | * `EventType::MouseEnter` 16 | * `EventType::MouseLeave` 17 | * `EventType::KeyDown` 18 | * `EventType::KeyUp` 19 | -------------------------------------------------------------------------------- /lua_yue/builtin_loader.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef LUA_YUE_BUILTIN_LOADER_H_ 6 | #define LUA_YUE_BUILTIN_LOADER_H_ 7 | 8 | #include "lua/lua.h" 9 | 10 | namespace yue { 11 | 12 | // Add a function to package.searchers to load builtin modules of yue. 13 | void InsertBuiltinModuleLoader(lua::State* state); 14 | 15 | } // namespace yue 16 | 17 | #endif // LUA_YUE_BUILTIN_LOADER_H_ 18 | -------------------------------------------------------------------------------- /nativeui/gfx/mac/screen_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/gfx/screen.h" 6 | 7 | #import 8 | 9 | namespace nu { 10 | 11 | float GetScaleFactor() { 12 | NSScreen* screen = [[NSScreen screens] firstObject]; 13 | if (!screen) // no screen, can it happen? 14 | return 1.f; 15 | return [screen backingScaleFactor]; 16 | } 17 | 18 | } // namespace nu 19 | -------------------------------------------------------------------------------- /nativeui/label.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/label.h" 6 | 7 | namespace nu { 8 | 9 | // static 10 | const char Label::kClassName[] = "Label"; 11 | 12 | const char* Label::GetClassName() const { 13 | return kClassName; 14 | } 15 | 16 | void Label::SetText(const std::string& text) { 17 | PlatformSetText(text); 18 | UpdateDefaultStyle(); 19 | } 20 | 21 | } // namespace nu 22 | -------------------------------------------------------------------------------- /docs/api/button_type.yaml: -------------------------------------------------------------------------------- 1 | name: Button::Type 2 | header: nativeui/button.h 3 | type: enum class 4 | namespace: nu 5 | description: Represent possible `Button` types. 6 | 7 | lang_detail: 8 | cpp: | 9 | This type is an `enum class` with following values: 10 | * `Button::Type::Normal` 11 | * `Button::Type::Checkbox` 12 | * `Button::Type::Radio` 13 | 14 | lua: &ref | 15 | This type is a string with following possible values: 16 | * `"normal"` 17 | * `"checkbox"` 18 | * `"radio"` 19 | 20 | js: *ref 21 | -------------------------------------------------------------------------------- /docs/api/scroll_policy.yaml: -------------------------------------------------------------------------------- 1 | name: Scroll::Policy 2 | header: nativeui/scroll.h 3 | type: enum class 4 | namespace: nu 5 | description: Scrollbar policy. 6 | 7 | lang_detail: 8 | cpp: | 9 | This type is an `enum class` with following values: 10 | * `Scroll::Policy::Always` 11 | * `Scroll::Policy::Never` 12 | * `Scroll::Policy::Automatic` 13 | 14 | lua: &ref | 15 | This type is a string with following possible values: 16 | * `"always"` 17 | * `"never"` 18 | * `"automatic"` 19 | 20 | js: *ref 21 | 22 | -------------------------------------------------------------------------------- /nativeui/menu_bar.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/menu_bar.h" 6 | 7 | namespace nu { 8 | 9 | // static 10 | const char MenuBar::kClassName[] = "MenuBar"; 11 | 12 | MenuBar::MenuBar() : MenuBase(PlatformCreate()) { 13 | SetAcceleratorManager(&accel_manager_); 14 | } 15 | 16 | const char* MenuBar::GetClassName() const { 17 | return kClassName; 18 | } 19 | 20 | } // namespace nu 21 | -------------------------------------------------------------------------------- /docs/api/menubar.yaml: -------------------------------------------------------------------------------- 1 | name: MenuBar 2 | component: gui 3 | header: nativeui/menu_bar.h 4 | type: refcounted 5 | namespace: nu 6 | inherit: MenuBase 7 | description: Menu bar. 8 | 9 | constructors: 10 | - signature: MenuBar() 11 | lang: ['cpp'] 12 | description: Create a menubar. 13 | 14 | class_methods: 15 | - signature: MenuBar create(Array items) 16 | lang: ['lua', 'js'] 17 | description: Create a menubar. 18 | parameters: 19 | items: 20 | description: An array of menu items to be inserted to the menu. 21 | -------------------------------------------------------------------------------- /scripts/build.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // Copyright 2016 Cheng Zhao. All rights reserved. 4 | // Use of this source code is governed by the license that can be found in the 5 | // LICENSE file. 6 | 7 | const {argv, verbose, execSync} = require('./common') 8 | 9 | let dir = 'out/Component' 10 | const args = argv.filter((arg) => { 11 | if (arg.startsWith('out')) { 12 | dir = arg 13 | return false; 14 | } else { 15 | return true; 16 | } 17 | }) 18 | 19 | execSync(`ninja ${verbose ? '-v' : ''} -C ${dir} ${args.join(' ')}`) 20 | -------------------------------------------------------------------------------- /lua/util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef LUA_UTIL_H_ 6 | #define LUA_UTIL_H_ 7 | 8 | namespace lua { 9 | 10 | template 11 | T* CreateOnHeap(ArgTypes... args) { 12 | return new T(args...); 13 | } 14 | 15 | template 16 | T CreateOnStack(ArgTypes... args) { 17 | return T(args...); 18 | } 19 | 20 | } // namespace lua 21 | 22 | #endif // LUA_UTIL_H_ 23 | -------------------------------------------------------------------------------- /nativeui/mac/menu_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/menu.h" 6 | 7 | #import 8 | 9 | namespace nu { 10 | 11 | Menu::Menu() : MenuBase([[NSMenu alloc] init]) { 12 | } 13 | 14 | void Menu::Popup() { 15 | [GetNative() popUpMenuPositioningItem:nil 16 | atLocation:[NSEvent mouseLocation] 17 | inView:nil]; 18 | } 19 | 20 | } // namespace nu 21 | -------------------------------------------------------------------------------- /docs/api/vibrant_blendingmode.yaml: -------------------------------------------------------------------------------- 1 | name: Vibrant::BlendingMode 2 | platform: ['macOS'] 3 | header: nativeui/vibrant.h 4 | type: enum class 5 | namespace: nu 6 | description: The blending mode of a `Vibrant` view. 7 | 8 | lang_detail: 9 | cpp: | 10 | This type is an `enum class` with following values: 11 | * `Vibrant::BlendingMode::BehindWindow` 12 | * `Vibrant::BlendingMode::WithinWindow` 13 | 14 | lua: &ref | 15 | This type is a string with following possible values: 16 | * `"behind-window"` 17 | * `"within-window"` 18 | 19 | js: *ref 20 | -------------------------------------------------------------------------------- /lua_yue/binding_gui.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef LUA_YUE_BINDING_GUI_H_ 6 | #define LUA_YUE_BINDING_GUI_H_ 7 | 8 | #include "lua/lua.h" 9 | 10 | #ifdef _WIN32 11 | # define LUA_MODULE_EXPORT __declspec(dllexport) 12 | #else 13 | # define LUA_MODULE_EXPORT __attribute__((visibility("default"))) 14 | #endif 15 | 16 | extern "C" LUA_MODULE_EXPORT int luaopen_yue_gui(lua::State* state); 17 | 18 | #endif // LUA_YUE_BINDING_GUI_H_ 19 | -------------------------------------------------------------------------------- /v8binding/util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef V8BINDING_UTIL_H_ 6 | #define V8BINDING_UTIL_H_ 7 | 8 | namespace vb { 9 | 10 | template 11 | T* CreateOnHeap(ArgTypes... args) { 12 | return new T(args...); 13 | } 14 | 15 | template 16 | T CreateOnStack(ArgTypes... args) { 17 | return T(args...); 18 | } 19 | 20 | } // namespace vb 21 | 22 | #endif // V8BINDING_UTIL_H_ 23 | -------------------------------------------------------------------------------- /nativeui/events/gtk/keyboard_code_conversion_gtk.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_EVENTS_GTK_KEYBOARD_CODE_CONVERSION_GTK_H_ 6 | #define NATIVEUI_EVENTS_GTK_KEYBOARD_CODE_CONVERSION_GTK_H_ 7 | 8 | #include "nativeui/events/gtk/keyboard_codes_gtk.h" 9 | 10 | namespace nu { 11 | 12 | KeyboardCode KeyboardCodeFromGdkKeyCode(int keyval); 13 | 14 | } // namespace nu 15 | 16 | #endif // NATIVEUI_EVENTS_GTK_KEYBOARD_CODE_CONVERSION_GTK_H_ 17 | -------------------------------------------------------------------------------- /nativeui/file_save_dialog.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_FILE_SAVE_DIALOG_H_ 6 | #define NATIVEUI_FILE_SAVE_DIALOG_H_ 7 | 8 | #include "nativeui/file_dialog.h" 9 | 10 | namespace nu { 11 | 12 | class NATIVEUI_EXPORT FileSaveDialog : public FileDialog { 13 | public: 14 | FileSaveDialog(); 15 | 16 | protected: 17 | ~FileSaveDialog() override; 18 | }; 19 | 20 | } // namespace nu 21 | 22 | #endif // NATIVEUI_FILE_SAVE_DIALOG_H_ 23 | -------------------------------------------------------------------------------- /nativeui/mac/container_mac.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_MAC_CONTAINER_MAC_H_ 6 | #define NATIVEUI_MAC_CONTAINER_MAC_H_ 7 | 8 | #include "nativeui/container.h" 9 | #include "nativeui/mac/nu_private.h" 10 | #include "nativeui/mac/nu_view.h" 11 | 12 | @interface NUContainer : NSView { 13 | @private 14 | nu::NUPrivate private_; 15 | nu::Color background_color_; 16 | } 17 | @end 18 | 19 | #endif // NATIVEUI_MAC_CONTAINER_MAC_H_ 20 | -------------------------------------------------------------------------------- /nativeui/gfx/mac/color_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/gfx/color.h" 6 | 7 | #import 8 | 9 | namespace nu { 10 | 11 | NSColor* Color::ToNSColor() const { 12 | return [NSColor colorWithCalibratedRed:r() / 255.0 13 | green:g() / 255.0 14 | blue:b() / 255.0 15 | alpha:a() / 255.0]; 16 | } 17 | 18 | } // namespace nu 19 | -------------------------------------------------------------------------------- /docs/api/mouseevent.yaml: -------------------------------------------------------------------------------- 1 | name: MouseEvent 2 | inherit: Event 3 | header: nativeui/events/event.h 4 | type: struct 5 | namespace: nu 6 | description: Mouse event. 7 | 8 | properties: 9 | - property: int button 10 | description: | 11 | The mouse button being pressed, `1` is for left button, `2` is for right 12 | button, `3` is for middle button. 13 | 14 | - property: PointF position_in_view 15 | description: Relative position inside the view where the event happened. 16 | 17 | - property: PointF position_in_window 18 | description: Relative position inside the window. 19 | -------------------------------------------------------------------------------- /docs/api/protocolfilejob.yaml: -------------------------------------------------------------------------------- 1 | name: ProtocolFileJob 2 | component: gui 3 | header: nativeui/protocol_file_job.h 4 | type: refcounted 5 | namespace: nu 6 | inherit: ProtocolJob 7 | description: Read file to serve custom protocol requests. 8 | 9 | constructors: 10 | - signature: ProtocolFileJob(const base::FilePath& path) 11 | lang: ['cpp'] 12 | description: &ref1 | 13 | Create a `ProtocolFileJob` with `path` to a local file. 14 | 15 | class_methods: 16 | - signature: ProtocolFileJob* Create(const base::FilePath& path) 17 | lang: ['lua', 'js'] 18 | description: *ref1 19 | 20 | -------------------------------------------------------------------------------- /nativeui/win/menu_base_win.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_MENU_BASE_WIN_H_ 6 | #define NATIVEUI_WIN_MENU_BASE_WIN_H_ 7 | 8 | #include "nativeui/menu_base.h" 9 | 10 | namespace nu { 11 | 12 | // Iterate the menu recursively to find the item with command id, and then emit 13 | // the click event for it. 14 | void DispatchCommandToItem(nu::MenuBase* menu, int command); 15 | 16 | } // namespace nu 17 | 18 | #endif // NATIVEUI_WIN_MENU_BASE_WIN_H_ 19 | -------------------------------------------------------------------------------- /.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Cheng Zhao. All rights reserved. 2 | # Use of this source code is governed by the MIT license that can be 3 | # found in the LICENSE file. 4 | 5 | # This file is used by the gn meta-buildsystem find the root of the source tree 6 | # and to set startup options. 7 | 8 | # Use preset Chromium build configurations. 9 | use_chromium_config = true 10 | 11 | # The secondary source root is a parallel directory tree where 12 | # GN build files are placed when they can not be placed directly 13 | # in the source tree, e.g. for third party source trees. 14 | secondary_source = "//secondary/" 15 | -------------------------------------------------------------------------------- /nativeui/gfx/win/screen_win.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_GFX_WIN_SCREEN_WIN_H_ 6 | #define NATIVEUI_GFX_WIN_SCREEN_WIN_H_ 7 | 8 | #include 9 | 10 | namespace nu { 11 | 12 | // Returns |hwnd|'s scale factor. 13 | float GetScaleFactorForHWND(HWND hwnd); 14 | 15 | // Returns the equivalent scaling factor for |dpi|. 16 | float GetScalingFactorFromDPI(int dpi); 17 | 18 | } // namespace nu 19 | 20 | #endif // NATIVEUI_GFX_WIN_SCREEN_WIN_H_ 21 | -------------------------------------------------------------------------------- /nativeui/gfx/mac/text_mac.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_GFX_MAC_TEXT_MAC_H_ 6 | #define NATIVEUI_GFX_MAC_TEXT_MAC_H_ 7 | 8 | #include 9 | 10 | #include "nativeui/gfx/text.h" 11 | 12 | namespace nu { 13 | 14 | // Calculate the size of text. 15 | TextMetrics MeasureText(const std::string& text, float width, 16 | const TextAttributes& attributes); 17 | 18 | } // namespace nu 19 | 20 | #endif // NATIVEUI_GFX_MAC_TEXT_MAC_H_ 21 | -------------------------------------------------------------------------------- /nativeui/win/app_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/app.h" 6 | 7 | namespace nu { 8 | 9 | Color App::PlatformGetColor(ThemeColor name) { 10 | int index = 0; 11 | if (name == ThemeColor::Text) 12 | index = COLOR_WINDOWTEXT; 13 | else if (name == ThemeColor::DisabledText) 14 | index = COLOR_GRAYTEXT; 15 | DWORD color = ::GetSysColor(index); 16 | return Color(GetRValue(color), GetGValue(color), GetBValue(color)); 17 | } 18 | 19 | } // namespace nu 20 | -------------------------------------------------------------------------------- /nativeui/message_loop_unittests.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/nativeui.h" 6 | #include "testing/gtest/include/gtest/gtest.h" 7 | 8 | class MessageLoopTest : public testing::Test { 9 | protected: 10 | void SetUp() override { 11 | } 12 | 13 | nu::Lifetime lifetime_; 14 | nu::State state_; 15 | }; 16 | 17 | TEST_F(MessageLoopTest, PostTask) { 18 | nu::MessageLoop::PostTask([]() { 19 | nu::MessageLoop::Quit(); 20 | }); 21 | nu::MessageLoop::Run(); 22 | } 23 | -------------------------------------------------------------------------------- /nativeui/mac/nu_application_delegate.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_MAC_NU_APPLICATION_DELEGATE_H_ 6 | #define NATIVEUI_MAC_NU_APPLICATION_DELEGATE_H_ 7 | 8 | #import 9 | 10 | namespace nu { 11 | class Lifetime; 12 | } 13 | 14 | @interface NUApplicationDelegate : NSObject { 15 | @private 16 | nu::Lifetime* shell_; 17 | } 18 | - (id)initWithShell:(nu::Lifetime*)shell; 19 | @end 20 | 21 | #endif // NATIVEUI_MAC_NU_APPLICATION_DELEGATE_H_ 22 | -------------------------------------------------------------------------------- /nativeui/win/menu_item_win.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_MENU_ITEM_WIN_H_ 6 | #define NATIVEUI_WIN_MENU_ITEM_WIN_H_ 7 | 8 | #include 9 | 10 | namespace nu { 11 | 12 | struct MenuItemData { 13 | int id = 0; 14 | std::string label; 15 | std::wstring accelerator; 16 | std::wstring actual_label; 17 | bool checked = false; 18 | bool enabled = true; 19 | bool visible = true; 20 | }; 21 | 22 | } // namespace nu 23 | 24 | #endif // NATIVEUI_WIN_MENU_ITEM_WIN_H_ 25 | -------------------------------------------------------------------------------- /docs/api/fileopendialog.yaml: -------------------------------------------------------------------------------- 1 | name: FileOpenDialog 2 | component: gui 3 | header: nativeui/file_open_dialog.h 4 | type: refcounted 5 | namespace: nu 6 | inherit: FileDialog 7 | description: Dialog used for opening files or folders. 8 | 9 | constructors: 10 | - signature: FileOpenDialog() 11 | lang: ['cpp'] 12 | description: Create an open dialog. 13 | 14 | class_methods: 15 | - signature: FileOpenDialog* Create() 16 | lang: ['lua', 'js'] 17 | description: Create an open dialog. 18 | 19 | methods: 20 | - signature: std::vector GetResults() const 21 | description: Return the chosen items in dialog. 22 | -------------------------------------------------------------------------------- /nativeui/mac/nu_window.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_MAC_NU_WINDOW_H_ 6 | #define NATIVEUI_MAC_NU_WINDOW_H_ 7 | 8 | #import 9 | 10 | namespace nu { 11 | class Window; 12 | } 13 | 14 | @interface NUWindow : NSWindow { 15 | @private 16 | nu::Window* shell_; 17 | bool can_resize_; 18 | } 19 | - (void)setShell:(nu::Window*)shell; 20 | - (nu::Window*)shell; 21 | - (void)setWindowStyle:(NSUInteger)style on:(bool)yes; 22 | @end 23 | 24 | #endif // NATIVEUI_MAC_NU_WINDOW_H_ 25 | -------------------------------------------------------------------------------- /nativeui/events/keyboard_codes.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_EVENTS_KEYBOARD_CODES_H_ 6 | #define NATIVEUI_EVENTS_KEYBOARD_CODES_H_ 7 | 8 | #include "build/build_config.h" 9 | 10 | #if defined(OS_MACOSX) 11 | #include "nativeui/events/mac/keyboard_codes_mac.h" 12 | #elif defined(OS_LINUX) 13 | #include "nativeui/events/gtk/keyboard_codes_gtk.h" 14 | #elif defined(OS_WIN) 15 | #include "nativeui/events/win/keyboard_codes_win.h" 16 | #endif 17 | 18 | #endif // NATIVEUI_EVENTS_KEYBOARD_CODES_H_ 19 | -------------------------------------------------------------------------------- /nativeui/events/win/event_win.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_EVENTS_WIN_EVENT_WIN_H_ 6 | #define NATIVEUI_EVENTS_WIN_EVENT_WIN_H_ 7 | 8 | #include 9 | 10 | namespace nu { 11 | 12 | // Windows does not have a native Event type, so we provide our own by wrapping 13 | // all MSG members in a struct. 14 | struct Win32Message { 15 | UINT message; 16 | WPARAM w_param; 17 | LPARAM l_param; 18 | }; 19 | 20 | } // namespace nu 21 | 22 | #endif // NATIVEUI_EVENTS_WIN_EVENT_WIN_H_ 23 | -------------------------------------------------------------------------------- /docs/api/toolbar_displaymode.yaml: -------------------------------------------------------------------------------- 1 | name: Toolbar::DisplayMode 2 | header: nativeui/toolbar.h 3 | type: enum class 4 | namespace: nu 5 | description: Possible display modes of `Toolbar`. 6 | 7 | lang_detail: 8 | cpp: | 9 | This type is an `enum class` with following values: 10 | * `Toolbar::DisplayMode::Default` 11 | * `Toolbar::DisplayMode::IconAndLabel` 12 | * `Toolbar::DisplayMode::Icon` 13 | * `Toolbar::DisplayMode::Label` 14 | 15 | lua: &ref | 16 | This type is a string with following possible values: 17 | * `"default"` 18 | * `"icon-and-label"` 19 | * `"icon"` 20 | * `"label"` 21 | 22 | js: *ref 23 | -------------------------------------------------------------------------------- /nativeui/gfx/win/text_win.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | // Calculate the size of text according to the view. 5 | 6 | #ifndef NATIVEUI_GFX_WIN_TEXT_WIN_H_ 7 | #define NATIVEUI_GFX_WIN_TEXT_WIN_H_ 8 | 9 | #include "nativeui/gfx/font.h" 10 | #include "nativeui/gfx/geometry/size_f.h" 11 | 12 | namespace nu { 13 | 14 | SizeF MeasureText(const base::string16& text, Font* font); 15 | SizeF MeasureText(HDC dc, const base::string16& text, Font* font); 16 | 17 | } // namespace nu 18 | 19 | #endif // NATIVEUI_GFX_WIN_TEXT_WIN_H_ 20 | -------------------------------------------------------------------------------- /docs/api/vibrant_material.yaml: -------------------------------------------------------------------------------- 1 | name: Vibrant::Material 2 | platform: ['macOS'] 3 | header: nativeui/vibrant.h 4 | type: enum class 5 | namespace: nu 6 | description: The material of a `Vibrant` view. 7 | 8 | lang_detail: 9 | cpp: | 10 | This type is an `enum class` with following values: 11 | * `Vibrant::Material::AppearanceBased` 12 | * `Vibrant::Material::Light` 13 | * `Vibrant::Material::Dark` 14 | * `Vibrant::Material::Titlebar` 15 | 16 | lua: &ref | 17 | This type is a string with following possible values: 18 | * `"appearance-based"` 19 | * `"light"` 20 | * `"dark"` 21 | * `"titlebar"` 22 | 23 | js: *ref 24 | -------------------------------------------------------------------------------- /docs/api/protocolstringjob.yaml: -------------------------------------------------------------------------------- 1 | name: ProtocolStringJob 2 | component: gui 3 | header: nativeui/protocol_job.h 4 | type: refcounted 5 | namespace: nu 6 | inherit: ProtocolJob 7 | description: Use string as response to custom protocol requests. 8 | 9 | constructors: 10 | - signature: ProtocolStringJob(const std::string& mimetype, const std::string& content) 11 | lang: ['cpp'] 12 | description: &ref1 | 13 | Create a `ProtocolStringJob` with `mimetype` and `content`. 14 | 15 | class_methods: 16 | - signature: ProtocolStringJob* Create(const std::string& mimetype, const std::string& content) 17 | lang: ['lua', 'js'] 18 | description: *ref1 19 | -------------------------------------------------------------------------------- /lua_yue/binding_values.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef LUA_YUE_BINDING_VALUES_H_ 6 | #define LUA_YUE_BINDING_VALUES_H_ 7 | 8 | #include "base/values.h" 9 | #include "lua/lua.h" 10 | 11 | namespace lua { 12 | 13 | template<> 14 | struct Type { 15 | static constexpr const char* name = "Value"; 16 | static void Push(State* state, const base::Value& value); 17 | static bool To(State* state, int index, base::Value* out); 18 | }; 19 | 20 | } // namespace lua 21 | 22 | #endif // LUA_YUE_BINDING_VALUES_H_ 23 | -------------------------------------------------------------------------------- /nativeui/util/yoga_util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_UTIL_YOGA_UTIL_H_ 6 | #define NATIVEUI_UTIL_YOGA_UTIL_H_ 7 | 8 | #include 9 | 10 | typedef struct YGNode *YGNodeRef; 11 | 12 | namespace nu { 13 | 14 | void SetYogaProperty(YGNodeRef node, const std::string& key, float value); 15 | void SetYogaProperty(YGNodeRef node, 16 | const std::string& key, 17 | const std::string& value); 18 | 19 | } // namespace nu 20 | 21 | #endif // NATIVEUI_UTIL_YOGA_UTIL_H_ 22 | -------------------------------------------------------------------------------- /docs/api/menuitem_type.yaml: -------------------------------------------------------------------------------- 1 | name: MenuItem::Type 2 | header: nativeui/menu_item.h 3 | type: enum class 4 | namespace: nu 5 | description: Represent possible `Menuitem` types. 6 | 7 | lang_detail: 8 | cpp: | 9 | This type is an `enum class` with following values: 10 | * `MenuItem::Type::Label` 11 | * `MenuItem::Type::Checkbox` 12 | * `MenuItem::Type::Radio` 13 | * `MenuItem::Type::Separator` 14 | * `MenuItem::Type::Submenu` 15 | 16 | lua: &ref | 17 | This type is a string with following possible values: 18 | * `"label"` 19 | * `"checkbox"` 20 | * `"radio"` 21 | * `"separator"` 22 | * `"submenu"` 23 | 24 | js: *ref 25 | 26 | -------------------------------------------------------------------------------- /nativeui/file_open_dialog.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_FILE_OPEN_DIALOG_H_ 6 | #define NATIVEUI_FILE_OPEN_DIALOG_H_ 7 | 8 | #include 9 | 10 | #include "nativeui/file_dialog.h" 11 | 12 | namespace nu { 13 | 14 | class NATIVEUI_EXPORT FileOpenDialog : public FileDialog { 15 | public: 16 | FileOpenDialog(); 17 | 18 | std::vector GetResults() const; 19 | 20 | protected: 21 | ~FileOpenDialog() override; 22 | }; 23 | 24 | } // namespace nu 25 | 26 | #endif // NATIVEUI_FILE_OPEN_DIALOG_H_ 27 | -------------------------------------------------------------------------------- /nativeui/mac/events_handler.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_MAC_EVENTS_HANDLER_H_ 6 | #define NATIVEUI_MAC_EVENTS_HANDLER_H_ 7 | 8 | #import 9 | 10 | namespace nu { 11 | 12 | class View; 13 | 14 | // Dynamically add event methods to a NSView. 15 | void AddMouseEventHandlerToClass(Class cl); 16 | void AddKeyEventHandlerToClass(Class cl); 17 | 18 | // Dispatch mouse events to a view. 19 | bool DispatchMouseEvent(View* view, NSEvent* event); 20 | 21 | } // namespace nu 22 | 23 | #endif // NATIVEUI_MAC_EVENTS_HANDLER_H_ 24 | -------------------------------------------------------------------------------- /nativeui/menu.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_MENU_H_ 6 | #define NATIVEUI_MENU_H_ 7 | 8 | #include "nativeui/menu_base.h" 9 | 10 | namespace nu { 11 | 12 | class NATIVEUI_EXPORT Menu : public MenuBase { 13 | public: 14 | Menu(); 15 | 16 | // View class name. 17 | static const char kClassName[]; 18 | 19 | // MenuBase: 20 | const char* GetClassName() const override; 21 | 22 | void Popup(); 23 | 24 | protected: 25 | ~Menu() override = default; 26 | }; 27 | 28 | } // namespace nu 29 | 30 | #endif // NATIVEUI_MENU_H_ 31 | -------------------------------------------------------------------------------- /tools/win/DebugVisualizers/skia.natvis: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | ({fX}, {fY}) 7 | 8 | 9 | ({fWidth}, {fHeight}) 10 | 11 | 12 | 13 | ({fLeft}, {fTop}), ({fRight}, {fBottom}) 14 | 15 | 16 | {fLogFont.lfFaceName,su} 17 | 18 | 19 | -------------------------------------------------------------------------------- /nativeui/win/file_save_dialog_win.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_FILE_SAVE_DIALOG_WIN_H_ 6 | #define NATIVEUI_WIN_FILE_SAVE_DIALOG_WIN_H_ 7 | 8 | #include "nativeui/file_save_dialog.h" 9 | #include "nativeui/win/file_dialog_win.h" 10 | 11 | namespace nu { 12 | 13 | class FileSaveDialogImpl : public FileDialogImpl { 14 | public: 15 | FileSaveDialogImpl(); 16 | ~FileSaveDialogImpl() override; 17 | 18 | private: 19 | ComPtr Initialize() const; 20 | }; 21 | 22 | } // namespace nu 23 | 24 | #endif // NATIVEUI_WIN_FILE_SAVE_DIALOG_WIN_H_ 25 | -------------------------------------------------------------------------------- /docs/api/textattributes.yaml: -------------------------------------------------------------------------------- 1 | name: TextAttributes 2 | header: nativeui/gfx/text.h 3 | type: struct 4 | namespace: nu 5 | description: Attributes for drawing text. 6 | 7 | detail: By default text is drew at top-left corner using system font and color. 8 | 9 | properties: 10 | - property: scoped_refptr font 11 | description: Font for drawing text, default is system UI font. 12 | 13 | - property: Color color 14 | description: Text color, default is system UI text color. 15 | 16 | - property: TextAlign align 17 | description: Horizontal text align, default is to the start of layout. 18 | 19 | - property: TextAlign valign 20 | description: Vertical text align, default is to the start of layout. 21 | -------------------------------------------------------------------------------- /nativeui/button.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/button.h" 6 | 7 | #include "nativeui/gfx/image.h" 8 | 9 | namespace nu { 10 | 11 | // static 12 | const char Button::kClassName[] = "Button"; 13 | 14 | void Button::SetImage(Image* image) { 15 | image_ = image; 16 | PlatformSetImage(image); 17 | UpdateDefaultStyle(); 18 | } 19 | 20 | void Button::SetTitle(const std::string& title) { 21 | PlatformSetTitle(title); 22 | UpdateDefaultStyle(); 23 | } 24 | 25 | const char* Button::GetClassName() const { 26 | return kClassName; 27 | } 28 | 29 | } // namespace nu 30 | -------------------------------------------------------------------------------- /third_party/libxml/src/xzlib.h: -------------------------------------------------------------------------------- 1 | /** 2 | * xzlib.h: header for the front end for the transparent suport of lzma 3 | * compression at the I/O layer 4 | * 5 | * See Copyright for the status of this software. 6 | * 7 | * Anders F Bjorklund 8 | */ 9 | 10 | #ifndef LIBXML2_XZLIB_H 11 | #define LIBXML2_XZLIB_H 12 | typedef void *xzFile; /* opaque lzma file descriptor */ 13 | 14 | xzFile __libxml2_xzopen(const char *path, const char *mode); 15 | xzFile __libxml2_xzdopen(int fd, const char *mode); 16 | int __libxml2_xzread(xzFile file, void *buf, unsigned len); 17 | int __libxml2_xzclose(xzFile file); 18 | int __libxml2_xzcompressed(xzFile f); 19 | #endif /* LIBXML2_XZLIB_H */ 20 | -------------------------------------------------------------------------------- /docs/api/menu.yaml: -------------------------------------------------------------------------------- 1 | name: Menu 2 | component: gui 3 | header: nativeui/menu.h 4 | type: refcounted 5 | namespace: nu 6 | inherit: MenuBase 7 | description: Popup menu. 8 | 9 | constructors: 10 | - signature: Menu() 11 | lang: ['cpp'] 12 | description: Create a popup menu. 13 | 14 | class_methods: 15 | - signature: Menu create(Array items) 16 | lang: ['lua', 'js'] 17 | description: Create a popup menu. 18 | parameters: 19 | items: 20 | description: An array of menu items to be inserted to the menu. 21 | 22 | method: 23 | - signature: void Popup() 24 | description: | 25 | Show the popup menu at current mouse position, this method will block 26 | until the menu is dismissed. 27 | -------------------------------------------------------------------------------- /nativeui/mac/lifetime_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/lifetime.h" 6 | 7 | #include "nativeui/mac/nu_application_delegate.h" 8 | 9 | namespace nu { 10 | 11 | void Lifetime::PlatformInit() { 12 | DCHECK(![NSApp delegate]) 13 | << "Lifetime should not be used in apps with their own message loop."; 14 | app_delegate_ = [[NUApplicationDelegate alloc] initWithShell:this]; 15 | [NSApp setDelegate:app_delegate_]; 16 | } 17 | 18 | void Lifetime::PlatformDestroy() { 19 | [NSApp setDelegate:nil]; 20 | [app_delegate_ release]; 21 | } 22 | 23 | } // namespace nu 24 | -------------------------------------------------------------------------------- /docs/api/toolbar_item.yaml: -------------------------------------------------------------------------------- 1 | name: Toolbar::Item 2 | header: nativeui/toolbar.h 3 | type: struct 4 | namespace: nu 5 | description: Represent an item of `Toolbar`. 6 | 7 | properties: 8 | - property: std::string label 9 | description: Item's label. 10 | 11 | - property: SizeF min_size 12 | description: Item's minimum size. 13 | 14 | - property: SizeF max_size 15 | description: Item's maximum size. 16 | 17 | - property: scoped_refptr image 18 | description: Item's image. 19 | 20 | - property: scoped_refptr view 21 | description: Item's custom view. 22 | 23 | - property: std::function on_click 24 | description: Function called when item is clicked. 25 | -------------------------------------------------------------------------------- /docs/api/filedialog_filter.yaml: -------------------------------------------------------------------------------- 1 | name: FileDialog::Filter 2 | header: nativeui/file_dialog.h 3 | type: struct 4 | namespace: nu 5 | description: FileDialog filters. 6 | 7 | lang_detail: 8 | cpp: | 9 | `FileDialog::Filter` is a `tuple` type: 10 | 11 | ```cpp 12 | std::tuple> 13 | ``` 14 | 15 | The first element is the filter's description, the second element is a 16 | vector of possible extensions. 17 | 18 | properties: 19 | - property: std::string description 20 | lang: ['lua', 'js'] 21 | description: Filter's description. 22 | 23 | - property: Array extensions 24 | lang: ['lua', 'js'] 25 | description: An array of filename extensions for the filter. 26 | -------------------------------------------------------------------------------- /lua_yue/binding_sys.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "lua_yue/binding_sys.h" 6 | 7 | #include "build/build_config.h" 8 | 9 | namespace { 10 | 11 | // Determine current platform. 12 | #if defined(OS_WIN) 13 | #define PLATFORM "win32" 14 | #elif defined(OS_LINUX) 15 | #define PLATFORM "linux" 16 | #elif defined(OS_MACOSX) 17 | #define PLATFORM "macos" 18 | #else 19 | #define PLATFORM "other" 20 | #endif 21 | 22 | } // namespace 23 | 24 | extern "C" int luaopen_yue_sys(lua::State* state) { 25 | lua::NewTable(state); 26 | lua::RawSet(state, -1, "platform", PLATFORM); 27 | return 1; 28 | } 29 | -------------------------------------------------------------------------------- /nativeui/mac/browser/nu_custom_protocol.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_MAC_BROWSER_NU_CUSTOM_PROTOCOL_H_ 6 | #define NATIVEUI_MAC_BROWSER_NU_CUSTOM_PROTOCOL_H_ 7 | 8 | #import 9 | 10 | #include "nativeui/browser.h" 11 | 12 | @interface NUCustomProtocol : NSURLProtocol { 13 | @private 14 | scoped_refptr protocol_job_; 15 | } 16 | + (bool)registerProtocol:(NSString*)scheme 17 | withHandler:(nu::Browser::ProtocolHandler)handler; 18 | + (bool)unregisterProtocol:(NSString*)scheme; 19 | @end 20 | 21 | #endif // NATIVEUI_MAC_BROWSER_NU_CUSTOM_PROTOCOL_H_ 22 | -------------------------------------------------------------------------------- /node_yue/node_integration_mac.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 GitHub, Inc. 2 | // Copyright 2017 Cheng Zhao. All rights reserved. 3 | // Use of this source code is governed by the license that can be found in the 4 | // LICENSE file. 5 | 6 | #ifndef NODE_YUE_NODE_INTEGRATION_MAC_H_ 7 | #define NODE_YUE_NODE_INTEGRATION_MAC_H_ 8 | 9 | #include "node_yue/node_integration.h" 10 | 11 | namespace node_yue { 12 | 13 | class NodeIntegrationMac : public NodeIntegration { 14 | public: 15 | NodeIntegrationMac(); 16 | ~NodeIntegrationMac() override; 17 | 18 | private: 19 | void PollEvents() override; 20 | 21 | DISALLOW_COPY_AND_ASSIGN(NodeIntegrationMac); 22 | }; 23 | 24 | } // namespace node_yue 25 | 26 | #endif // NODE_YUE_NODE_INTEGRATION_MAC_H_ 27 | -------------------------------------------------------------------------------- /node_yue/node_integration_win.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 GitHub, Inc. 2 | // Copyright 2017 Cheng Zhao. All rights reserved. 3 | // Use of this source code is governed by the license that can be found in the 4 | // LICENSE file. 5 | 6 | #ifndef NODE_YUE_NODE_INTEGRATION_WIN_H_ 7 | #define NODE_YUE_NODE_INTEGRATION_WIN_H_ 8 | 9 | #include "node_yue/node_integration.h" 10 | 11 | namespace node_yue { 12 | 13 | class NodeIntegrationWin : public NodeIntegration { 14 | public: 15 | NodeIntegrationWin(); 16 | ~NodeIntegrationWin() override; 17 | 18 | private: 19 | void PollEvents() override; 20 | 21 | DISALLOW_COPY_AND_ASSIGN(NodeIntegrationWin); 22 | }; 23 | 24 | } // namespace node_yue 25 | 26 | #endif // NODE_YUE_NODE_INTEGRATION_WIN_H_ 27 | -------------------------------------------------------------------------------- /nativeui/mac/menu_base_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/menu_base.h" 6 | 7 | #import 8 | 9 | #include "nativeui/menu_item.h" 10 | 11 | namespace nu { 12 | 13 | void MenuBase::PlatformInit() { 14 | [menu_ setAutoenablesItems:NO]; 15 | } 16 | 17 | void MenuBase::PlatformDestroy() { 18 | [menu_ release]; 19 | } 20 | 21 | void MenuBase::PlatformInsert(MenuItem* item, int index) { 22 | [menu_ insertItem:item->GetNative() atIndex:index]; 23 | } 24 | 25 | void MenuBase::PlatformRemove(MenuItem* item) { 26 | [menu_ removeItem:item->GetNative()]; 27 | } 28 | 29 | } // namespace nu 30 | -------------------------------------------------------------------------------- /node_yue/chrome_view_mac.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NODE_YUE_CHROME_VIEW_MAC_H_ 6 | #define NODE_YUE_CHROME_VIEW_MAC_H_ 7 | 8 | #include 9 | 10 | #include "nativeui/nativeui.h" 11 | 12 | namespace node_yue { 13 | 14 | class ChromeView : public nu::View { 15 | public: 16 | explicit ChromeView(v8::Local buf); 17 | 18 | // View class name. 19 | static const char kClassName[]; 20 | 21 | // View: 22 | const char* GetClassName() const override; 23 | 24 | protected: 25 | ~ChromeView() override; 26 | }; 27 | 28 | } // namespace node_yue 29 | 30 | #endif // NODE_YUE_CHROME_VIEW_MAC_H_ 31 | -------------------------------------------------------------------------------- /nativeui/gfx/canvas.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/gfx/canvas.h" 6 | 7 | #include "nativeui/gfx/painter.h" 8 | #include "nativeui/gfx/screen.h" 9 | 10 | namespace nu { 11 | 12 | Canvas::Canvas(const SizeF& size) 13 | : Canvas(size, nu::GetScaleFactor()) { 14 | } 15 | 16 | Canvas::Canvas(const SizeF& size, float scale_factor) 17 | : scale_factor_(scale_factor), 18 | size_(size), 19 | bitmap_(PlatformCreateBitmap(size, scale_factor)), 20 | painter_(PlatformCreatePainter(bitmap_, scale_factor)) { 21 | } 22 | 23 | Canvas::~Canvas() { 24 | PlatformDestroyBitmap(bitmap_); 25 | } 26 | 27 | } // namespace nu 28 | -------------------------------------------------------------------------------- /docs/api/window_options.yaml: -------------------------------------------------------------------------------- 1 | name: Window::Options 2 | header: nativeui/window.h 3 | type: struct 4 | namespace: nu 5 | description: Options for creating window. 6 | 7 | properties: 8 | - property: bool frame 9 | description: | 10 | Whether window has native frame, default is `true`. 11 | 12 | - property: bool transparent 13 | description: | 14 | Whether window is transparent, default is `false`. 15 | 16 | Only frameless window can be transparent, the behavior of making a normal 17 | window transparent is undefined. 18 | 19 | - property: bool show_traffic_lights 20 | platform: ['macOS'] 21 | description: | 22 | Whether to show window buttons for frameless window, default is `false`. 23 | 24 | This property is ignored for normal windows. 25 | -------------------------------------------------------------------------------- /nativeui/win/file_open_dialog_win.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_FILE_OPEN_DIALOG_WIN_H_ 6 | #define NATIVEUI_WIN_FILE_OPEN_DIALOG_WIN_H_ 7 | 8 | #include 9 | 10 | #include "nativeui/file_open_dialog.h" 11 | #include "nativeui/win/file_dialog_win.h" 12 | 13 | namespace nu { 14 | 15 | class FileOpenDialogImpl : public FileDialogImpl { 16 | public: 17 | FileOpenDialogImpl(); 18 | ~FileOpenDialogImpl() override; 19 | 20 | std::vector GetResults() const; 21 | 22 | private: 23 | ComPtr Initialize() const; 24 | }; 25 | 26 | } // namespace nu 27 | 28 | #endif // NATIVEUI_WIN_FILE_OPEN_DIALOG_WIN_H_ 29 | -------------------------------------------------------------------------------- /lua/table.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "lua/table.h" 6 | 7 | namespace lua { 8 | 9 | namespace { 10 | 11 | const char* kCustomDataTableName = "yue.internal.customdatatable"; 12 | 13 | } // namespace 14 | 15 | void PushCustomDataTable(State* state, int key) { 16 | key = AbsIndex(state, key); 17 | PushWeakTable(state, kCustomDataTableName, "k"); 18 | RawGetOrCreateTable(state, -1, ValueOnStack(state, key)); 19 | lua_remove(state, -2); 20 | } 21 | 22 | void PushRefsTable(State* state, const char* name, int owner) { 23 | PushCustomDataTable(state, owner); 24 | RawGetOrCreateTable(state, -1, name); 25 | lua_remove(state, -2); 26 | } 27 | 28 | } // namespace lua 29 | -------------------------------------------------------------------------------- /nativeui/win/util/gdiplus_holder.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_UTIL_GDIPLUS_HOLDER_H_ 6 | #define NATIVEUI_WIN_UTIL_GDIPLUS_HOLDER_H_ 7 | 8 | #include "nativeui/gfx/win/gdiplus.h" 9 | 10 | namespace nu { 11 | 12 | class GdiplusHolder { 13 | public: 14 | GdiplusHolder() { 15 | Gdiplus::GdiplusStartupInput input; 16 | Gdiplus::GdiplusStartup(&token_, &input, nullptr); 17 | } 18 | 19 | ~GdiplusHolder() { 20 | Gdiplus::GdiplusShutdown(token_); 21 | } 22 | 23 | private: 24 | ULONG_PTR token_; 25 | 26 | DISALLOW_COPY_AND_ASSIGN(GdiplusHolder); 27 | }; 28 | 29 | 30 | } // namespace nu 31 | 32 | #endif // NATIVEUI_WIN_UTIL_GDIPLUS_HOLDER_H_ 33 | -------------------------------------------------------------------------------- /node_yue/delay_load_hook_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | namespace { 11 | 12 | FARPROC WINAPI LoadHook(unsigned int event, DelayLoadInfo* info) { 13 | HMODULE m; 14 | if (event != dliNotePreLoadLibrary) 15 | return NULL; 16 | 17 | if (_stricmp(info->szDll, "node.exe") != 0 && 18 | _stricmp(info->szDll, "yode.exe") != 0 && 19 | _stricmp(info->szDll, "node.dll") != 0) 20 | return NULL; 21 | 22 | m = ::GetModuleHandle(NULL); 23 | return reinterpret_cast(m); 24 | } 25 | 26 | } // namespace 27 | 28 | decltype(__pfnDliNotifyHook2) __pfnDliNotifyHook2 = LoadHook; 29 | -------------------------------------------------------------------------------- /nativeui/gfx/gtk/screen_gtk.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/gfx/screen.h" 6 | 7 | #include 8 | 9 | #include "nativeui/label.h" 10 | 11 | namespace nu { 12 | 13 | float GetScaleFactor() { 14 | static float scale_factor = -1.f; 15 | if (scale_factor <= 0) { 16 | // The gtk-xft-dpi GtkSetting does not return us correct value, the only 17 | // reliable way to get scale factor on Linux seems to be calling the 18 | // gtk_widget_get_scale_factor API. 19 | scoped_refptr label = new nu::Label; 20 | scale_factor = gtk_widget_get_scale_factor(label->GetNative()); 21 | } 22 | return scale_factor; 23 | } 24 | 25 | } // namespace nu 26 | -------------------------------------------------------------------------------- /third_party/libxml/src/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 4179 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.6]) 16 | m4_define([LT_PACKAGE_REVISION], [2.4.6]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.6' 20 | macro_revision='2.4.6' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /node_yue/node_integration_linux.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 GitHub, Inc. 2 | // Copyright 2017 Cheng Zhao. All rights reserved. 3 | // Use of this source code is governed by the license that can be found in the 4 | // LICENSE file. 5 | 6 | #ifndef NODE_YUE_NODE_INTEGRATION_LINUX_H_ 7 | #define NODE_YUE_NODE_INTEGRATION_LINUX_H_ 8 | 9 | #include "node_yue/node_integration.h" 10 | 11 | namespace node_yue { 12 | 13 | class NodeIntegrationLinux : public NodeIntegration { 14 | public: 15 | NodeIntegrationLinux(); 16 | ~NodeIntegrationLinux() override; 17 | 18 | private: 19 | void PollEvents() override; 20 | 21 | // Epoll to poll for uv's backend fd. 22 | int epoll_; 23 | 24 | DISALLOW_COPY_AND_ASSIGN(NodeIntegrationLinux); 25 | }; 26 | 27 | } // namespace node_yue 28 | 29 | #endif // NODE_YUE_NODE_INTEGRATION_LINUX_H_ 30 | -------------------------------------------------------------------------------- /nativeui/mac/mouse_capture.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_MAC_MOUSE_CAPTURE_H_ 6 | #define NATIVEUI_MAC_MOUSE_CAPTURE_H_ 7 | 8 | #import 9 | 10 | #include "base/macros.h" 11 | 12 | namespace nu { 13 | 14 | class View; 15 | 16 | // Simulating the SetCapture of Windows. 17 | class MouseCapture { 18 | public: 19 | explicit MouseCapture(View* view); 20 | ~MouseCapture(); 21 | 22 | private: 23 | void ProcessCapturedMouseEvent(NSEvent* event); 24 | 25 | View* view_; 26 | id local_monitor_; 27 | id global_monitor_; 28 | 29 | DISALLOW_COPY_AND_ASSIGN(MouseCapture); 30 | }; 31 | 32 | } // namespace nu 33 | 34 | #endif // NATIVEUI_MAC_MOUSE_CAPTURE_H_ 35 | -------------------------------------------------------------------------------- /node_yue/binding_values.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NODE_YUE_BINDING_VALUES_H_ 6 | #define NODE_YUE_BINDING_VALUES_H_ 7 | 8 | #include "base/values.h" 9 | #include "v8binding/v8binding.h" 10 | 11 | namespace vb { 12 | 13 | template<> 14 | struct Type { 15 | static constexpr const char* name = "Value"; 16 | static v8::Local ToV8(v8::Local context, 17 | const base::Value& value); 18 | static bool FromV8(v8::Local context, 19 | v8::Local value, 20 | base::Value* out); 21 | }; 22 | 23 | } // namespace vb 24 | 25 | #endif // NODE_YUE_BINDING_VALUES_H_ 26 | -------------------------------------------------------------------------------- /v8binding/locker.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef V8BINDING_LOCKER_H_ 6 | #define V8BINDING_LOCKER_H_ 7 | 8 | #include 9 | 10 | #include "base/macros.h" 11 | 12 | namespace v8 { 13 | class Isolate; 14 | class Locker; 15 | } 16 | 17 | namespace vb { 18 | 19 | // Only lock when lockers are used in current thread. 20 | class Locker { 21 | public: 22 | explicit Locker(v8::Isolate* isolate); 23 | ~Locker(); 24 | 25 | private: 26 | void* operator new(size_t size); 27 | void operator delete(void*, size_t); 28 | 29 | std::unique_ptr locker_; 30 | 31 | DISALLOW_COPY_AND_ASSIGN(Locker); 32 | }; 33 | 34 | } // namespace vb 35 | 36 | #endif // V8BINDING_LOCKER_H_ 37 | -------------------------------------------------------------------------------- /docs/api/font_weight.yaml: -------------------------------------------------------------------------------- 1 | name: Font::Weight 2 | header: nativeui/gfx/font.h 3 | type: enum 4 | namespace: nu 5 | description: Represent font weights. 6 | 7 | lang_detail: 8 | cpp: | 9 | This type is an `enum` with following values: 10 | * `Font::Style::Thin` 11 | * `Font::Style::ExtraLight` 12 | * `Font::Style::Light` 13 | * `Font::Style::Normal` 14 | * `Font::Style::Medium` 15 | * `Font::Style::SemiBold` 16 | * `Font::Style::Bold` 17 | * `Font::Style::ExtraBold` 18 | * `Font::Style::Black` 19 | 20 | lua: &ref | 21 | This type is a string with following possible values: 22 | * `"thin"` 23 | * `"extra-light"` 24 | * `"light"` 25 | * `"normal"` 26 | * `"medium"` 27 | * `"semi-bold"` 28 | * `"bold"` 29 | * `"extra-bold"` 30 | * `"black"` 31 | 32 | js: *ref 33 | -------------------------------------------------------------------------------- /secondary/third_party/yoga/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Cheng Zhao. All rights reserved. 2 | 3 | config("yoga_config") { 4 | include_dirs = [ "yoga" ] 5 | } 6 | 7 | source_set("yoga") { 8 | sources = [ 9 | "yoga/YGEnums.c", 10 | "yoga/YGEnums.h", 11 | "yoga/YGMacros.h", 12 | "yoga/YGNodeList.c", 13 | "yoga/YGNodeList.h", 14 | "yoga/Yoga-internal.h", 15 | "yoga/Yoga.c", 16 | "yoga/Yoga.h", 17 | ] 18 | 19 | if (is_win) { 20 | cflags = [ 21 | "/wd4005", # 'isnan': macro redefinition 22 | "/wd4028", # formal parameter 13 different from declaration 23 | "/wd4267", # conversion from 'size_t' to 'const unsigned long' 24 | "/wd4232", # address of dllimport 'free' is not static, identity not guaranteed 25 | ] 26 | } 27 | 28 | public_configs = [ ":yoga_config" ] 29 | } 30 | -------------------------------------------------------------------------------- /docs/api/browser_options.yaml: -------------------------------------------------------------------------------- 1 | name: Browser::Options 2 | header: nativeui/browser.h 3 | type: struct 4 | namespace: nu 5 | description: Options for creating browser. 6 | 7 | properties: 8 | - property: bool devtools 9 | description: Whether the browser can show devtools, default is `false`. 10 | detail: | 11 | Depending on platform, the option to show devtools is usually in the 12 | context menu, so you should also enable builtin context menu when using 13 | this option. 14 | 15 | Currently this option is not working on Windows. 16 | 17 | - property: bool context_menu 18 | description: Whether to use builtin context menu, default is `false`. 19 | detail: | 20 | On macOS due to the limitation of system APIs, right-clicking certain 21 | elements would still popup a menu with Services items. 22 | -------------------------------------------------------------------------------- /nativeui/gfx/text.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/gfx/text.h" 6 | 7 | #include "nativeui/app.h" 8 | #include "nativeui/gfx/font.h" 9 | 10 | namespace nu { 11 | 12 | TextAttributes::TextAttributes() 13 | : font(App::GetCurrent()->GetDefaultFont()), 14 | color(App::GetCurrent()->GetColor(App::ThemeColor::Text)), 15 | align(TextAlign::Start), 16 | valign(TextAlign::Start) { 17 | } 18 | 19 | TextAttributes::TextAttributes(Font* font, Color color, TextAlign align, 20 | TextAlign valign) 21 | : font(font), color(color), align(align), valign(valign) { 22 | } 23 | 24 | TextAttributes::~TextAttributes() { 25 | } 26 | 27 | } // namespace nu 28 | -------------------------------------------------------------------------------- /nativeui/gtk/undoable_text_buffer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_GTK_UNDOABLE_TEXT_BUFFER_H_ 6 | #define NATIVEUI_GTK_UNDOABLE_TEXT_BUFFER_H_ 7 | 8 | typedef struct _GtkTextBuffer GtkTextBuffer; 9 | 10 | namespace nu { 11 | 12 | // Attach undo/redo stacks to a text buffer. 13 | void TextBufferMakeUndoable(GtkTextBuffer* buffer); 14 | bool TextBufferIsUndoable(GtkTextBuffer* buffer); 15 | 16 | // Manipulate the undo/redo stacks. 17 | void TextBufferUndo(GtkTextBuffer* buffer); 18 | bool TextBufferCanUndo(GtkTextBuffer* buffer); 19 | void TextBufferRedo(GtkTextBuffer* buffer); 20 | bool TextBufferCanRedo(GtkTextBuffer* buffer); 21 | 22 | } // namespace nu 23 | 24 | #endif // NATIVEUI_GTK_UNDOABLE_TEXT_BUFFER_H_ 25 | -------------------------------------------------------------------------------- /nativeui/menu_unittests.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/nativeui.h" 6 | #include "testing/gtest/include/gtest/gtest.h" 7 | 8 | class MenuTest : public testing::Test { 9 | protected: 10 | void SetUp() override { 11 | menu_ = new nu::Menu; 12 | } 13 | 14 | nu::Lifetime lifetime_; 15 | nu::State state_; 16 | scoped_refptr menu_; 17 | }; 18 | 19 | TEST_F(MenuTest, ItemCount) { 20 | EXPECT_EQ(menu_->ItemCount(), 0); 21 | menu_->Append(new nu::MenuItem(nu::MenuItem::Type::Label)); 22 | EXPECT_EQ(menu_->ItemCount(), 1); 23 | menu_->Remove(menu_->ItemAt(1)); 24 | EXPECT_EQ(menu_->ItemCount(), 1); 25 | menu_->Remove(menu_->ItemAt(0)); 26 | EXPECT_EQ(menu_->ItemCount(), 0); 27 | } 28 | -------------------------------------------------------------------------------- /nativeui/lifetime.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/lifetime.h" 6 | 7 | #include "base/logging.h" 8 | #include "nativeui/state.h" 9 | 10 | namespace nu { 11 | 12 | namespace { 13 | 14 | Lifetime* g_lifetime = nullptr; 15 | 16 | } // namespace 17 | 18 | // static 19 | Lifetime* Lifetime::GetCurrent() { 20 | return g_lifetime; 21 | } 22 | 23 | Lifetime::Lifetime() : weak_factory_(this) { 24 | CHECK(!State::GetCurrent()) << "Lifetime must be initailized before State"; 25 | CHECK(!g_lifetime) << "Lifetime can not be created twice"; 26 | g_lifetime = this; 27 | PlatformInit(); 28 | } 29 | 30 | Lifetime::~Lifetime() { 31 | g_lifetime = nullptr; 32 | PlatformDestroy(); 33 | } 34 | 35 | } // namespace nu 36 | -------------------------------------------------------------------------------- /nativeui/nativeui_export.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_NATIVEUI_EXPORT_H_ 6 | #define NATIVEUI_NATIVEUI_EXPORT_H_ 7 | 8 | #if defined(COMPONENT_BUILD) 9 | #if defined(WIN32) 10 | 11 | #if defined(NATIVEUI_IMPLEMENTATION) 12 | #define NATIVEUI_EXPORT __declspec(dllexport) 13 | #else 14 | #define NATIVEUI_EXPORT __declspec(dllimport) 15 | #endif // defined(NATIVEUI_IMPLEMENTATION) 16 | 17 | #else // defined(WIN32) 18 | #if defined(NATIVEUI_IMPLEMENTATION) 19 | #define NATIVEUI_EXPORT __attribute__((visibility("default"))) 20 | #else 21 | #define NATIVEUI_EXPORT 22 | #endif 23 | #endif 24 | 25 | #else // defined(COMPONENT_BUILD) 26 | #define NATIVEUI_EXPORT 27 | #endif 28 | 29 | #endif // NATIVEUI_NATIVEUI_EXPORT_H_ 30 | -------------------------------------------------------------------------------- /nativeui/win/menu_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/menu.h" 6 | 7 | #include "nativeui/menu_item.h" 8 | #include "nativeui/state.h" 9 | #include "nativeui/win/menu_base_win.h" 10 | #include "nativeui/win/menu_item_win.h" 11 | 12 | namespace nu { 13 | 14 | Menu::Menu() : MenuBase(CreatePopupMenu()) { 15 | } 16 | 17 | void Menu::Popup() { 18 | POINT p; 19 | GetCursorPos(&p); 20 | UINT id = TrackPopupMenuEx(GetNative(), 21 | TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, 22 | p.x, p.y, State::GetCurrent()->GetSubwinHolder(), 23 | nullptr); 24 | if (id > 0) 25 | DispatchCommandToItem(this, id); 26 | } 27 | 28 | } // namespace nu 29 | -------------------------------------------------------------------------------- /nativeui/gtk/file_save_dialog_gtk.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/file_save_dialog.h" 6 | 7 | #include 8 | 9 | namespace nu { 10 | 11 | FileSaveDialog::FileSaveDialog() 12 | : FileDialog(GTK_FILE_CHOOSER(gtk_file_chooser_dialog_new( 13 | nullptr, nullptr, 14 | GTK_FILE_CHOOSER_ACTION_SAVE, 15 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 16 | GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, 17 | nullptr))) { 18 | gtk_file_chooser_set_do_overwrite_confirmation(GetNative(), true); 19 | gtk_file_chooser_set_create_folders(GetNative(), true); 20 | } 21 | 22 | FileSaveDialog::~FileSaveDialog() { 23 | } 24 | 25 | } // namespace nu 26 | -------------------------------------------------------------------------------- /nativeui/mac/file_open_dialog_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/file_open_dialog.h" 6 | 7 | #import 8 | 9 | #include "base/strings/sys_string_conversions.h" 10 | 11 | namespace nu { 12 | 13 | FileOpenDialog::FileOpenDialog() : FileDialog([NSOpenPanel openPanel]) { 14 | } 15 | 16 | FileOpenDialog::~FileOpenDialog() { 17 | } 18 | 19 | std::vector FileOpenDialog::GetResults() const { 20 | std::vector results; 21 | NSArray* urls = [static_cast(GetNative()) URLs]; 22 | for (NSURL* url in urls) { 23 | if ([url isFileURL]) 24 | results.push_back(base::FilePath(base::SysNSStringToUTF8([url path]))); 25 | } 26 | return results; 27 | } 28 | 29 | } // namespace nu 30 | -------------------------------------------------------------------------------- /nativeui/gfx/geometry/point_conversions.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "nativeui/gfx/geometry/point_conversions.h" 6 | 7 | #include "nativeui/gfx/geometry/safe_integer_conversions.h" 8 | 9 | namespace nu { 10 | 11 | Point ToFlooredPoint(const PointF& point) { 12 | int x = ToFlooredInt(point.x()); 13 | int y = ToFlooredInt(point.y()); 14 | return Point(x, y); 15 | } 16 | 17 | Point ToCeiledPoint(const PointF& point) { 18 | int x = ToCeiledInt(point.x()); 19 | int y = ToCeiledInt(point.y()); 20 | return Point(x, y); 21 | } 22 | 23 | Point ToRoundedPoint(const PointF& point) { 24 | int x = ToRoundedInt(point.x()); 25 | int y = ToRoundedInt(point.y()); 26 | return Point(x, y); 27 | } 28 | 29 | } // namespace nu 30 | 31 | -------------------------------------------------------------------------------- /nativeui/progress_bar.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_PROGRESS_BAR_H_ 6 | #define NATIVEUI_PROGRESS_BAR_H_ 7 | 8 | #include "nativeui/view.h" 9 | 10 | namespace nu { 11 | 12 | class NATIVEUI_EXPORT ProgressBar : public View { 13 | public: 14 | ProgressBar(); 15 | 16 | // View class name. 17 | static const char kClassName[]; 18 | 19 | void SetValue(float value); 20 | float GetValue() const; 21 | 22 | void SetIndeterminate(bool indeterminate); 23 | bool IsIndeterminate() const; 24 | 25 | // View: 26 | const char* GetClassName() const override; 27 | SizeF GetMinimumSize() const override; 28 | 29 | protected: 30 | ~ProgressBar() override; 31 | }; 32 | 33 | } // namespace nu 34 | 35 | #endif // NATIVEUI_PROGRESS_BAR_H_ 36 | -------------------------------------------------------------------------------- /nativeui/gfx/geometry/size_conversions.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "nativeui/gfx/geometry/size_conversions.h" 6 | 7 | #include "nativeui/gfx/geometry/safe_integer_conversions.h" 8 | 9 | namespace nu { 10 | 11 | Size ToFlooredSize(const SizeF& size) { 12 | int w = ToFlooredInt(size.width()); 13 | int h = ToFlooredInt(size.height()); 14 | return Size(w, h); 15 | } 16 | 17 | Size ToCeiledSize(const SizeF& size) { 18 | int w = ToCeiledInt(size.width()); 19 | int h = ToCeiledInt(size.height()); 20 | return Size(w, h); 21 | } 22 | 23 | Size ToRoundedSize(const SizeF& size) { 24 | int w = ToRoundedInt(size.width()); 25 | int h = ToRoundedInt(size.height()); 26 | return Size(w, h); 27 | } 28 | 29 | } // namespace nu 30 | 31 | -------------------------------------------------------------------------------- /nativeui/win/edit_view.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_EDIT_VIEW_H_ 6 | #define NATIVEUI_WIN_EDIT_VIEW_H_ 7 | 8 | #include 9 | 10 | #include "nativeui/win/subwin_view.h" 11 | 12 | namespace nu { 13 | 14 | class EditView : public SubwinView { 15 | public: 16 | EditView(View* delegate, DWORD styles); 17 | 18 | void SetPlainText(); 19 | 20 | void SetText(const std::string& text); 21 | std::string GetText() const; 22 | 23 | void Redo(); 24 | bool CanRedo() const; 25 | void Undo(); 26 | bool CanUndo() const; 27 | 28 | void Cut(); 29 | void Copy(); 30 | void Paste(); 31 | void SelectAll(); 32 | 33 | private: 34 | void LoadRichEdit(); 35 | }; 36 | 37 | } // namespace nu 38 | 39 | #endif // NATIVEUI_WIN_EDIT_VIEW_H_ 40 | -------------------------------------------------------------------------------- /nativeui/gtk/menu_gtk.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/menu.h" 6 | 7 | #include 8 | 9 | namespace nu { 10 | 11 | namespace { 12 | 13 | void OnMenuHidden(GtkWidget* widget, void*) { 14 | gtk_main_quit(); 15 | } 16 | 17 | } // namespace 18 | 19 | Menu::Menu() : MenuBase(GTK_MENU_SHELL(gtk_menu_new())) { 20 | } 21 | 22 | void Menu::Popup() { 23 | gtk_menu_popup(GTK_MENU(GetNative()), nullptr, nullptr, nullptr, nullptr, 24 | 0, gtk_get_current_event_time()); 25 | 26 | // Block until the menu is hidden. 27 | gint id = g_signal_connect(GetNative(), "hide", G_CALLBACK(OnMenuHidden), 28 | nullptr); 29 | gtk_main(); 30 | g_signal_handler_disconnect(GetNative(), id); 31 | } 32 | 33 | } // namespace nu 34 | -------------------------------------------------------------------------------- /nativeui/test/gfx_util.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef NATIVEUI_TEST_GFX_UTIL_H_ 6 | #define NATIVEUI_TEST_GFX_UTIL_H_ 7 | 8 | #include 9 | #include 10 | 11 | #include "nativeui/gfx/geometry/rect_f.h" 12 | #include "testing/gtest/include/gtest/gtest.h" 13 | 14 | namespace nu { 15 | 16 | #define EXPECT_RECTF_EQ(a, b) \ 17 | EXPECT_PRED_FORMAT2(::gfx::AssertRectFloatEqual, a, b) 18 | 19 | ::testing::AssertionResult AssertRectFloatEqual(const char* lhs_expr, 20 | const char* rhs_expr, 21 | const RectF& lhs, 22 | const RectF& rhs); 23 | 24 | } // namespace nu 25 | 26 | #endif // NATIVEUI_TEST_GFX_UTIL_H_ 27 | -------------------------------------------------------------------------------- /lua/state.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef LUA_STATE_H_ 6 | #define LUA_STATE_H_ 7 | 8 | #include "base/macros.h" 9 | 10 | extern "C" { 11 | #include "third_party/lua/src/lauxlib.h" 12 | #include "third_party/lua/src/lua.h" 13 | #include "third_party/lua/src/lualib.h" 14 | } 15 | 16 | namespace lua { 17 | 18 | // Avoid using lua_State directly. 19 | using State = lua_State; 20 | 21 | // Manages the created lua_State. 22 | class ManagedState { 23 | public: 24 | ManagedState() : state_(luaL_newstate()) { 25 | } 26 | 27 | ~ManagedState() { 28 | lua_close(state_); 29 | } 30 | 31 | operator State*() { return state_; } 32 | 33 | private: 34 | State* state_; 35 | 36 | DISALLOW_COPY_AND_ASSIGN(ManagedState); 37 | }; 38 | 39 | } // namespace lua 40 | 41 | #endif // LUA_STATE_H_ 42 | -------------------------------------------------------------------------------- /nativeui/gfx/geometry/size_conversions.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef NATIVEUI_GFX_GEOMETRY_SIZE_CONVERSIONS_H_ 6 | #define NATIVEUI_GFX_GEOMETRY_SIZE_CONVERSIONS_H_ 7 | 8 | #include "nativeui/gfx/geometry/size.h" 9 | #include "nativeui/gfx/geometry/size_f.h" 10 | 11 | namespace nu { 12 | 13 | // Returns a Size with each component from the input SizeF floored. 14 | NATIVEUI_EXPORT Size ToFlooredSize(const SizeF& size); 15 | 16 | // Returns a Size with each component from the input SizeF ceiled. 17 | NATIVEUI_EXPORT Size ToCeiledSize(const SizeF& size); 18 | 19 | // Returns a Size with each component from the input SizeF rounded. 20 | NATIVEUI_EXPORT Size ToRoundedSize(const SizeF& size); 21 | 22 | } // namespace nu 23 | 24 | #endif // NATIVEUI_GFX_GEOMETRY_SIZE_CONVERSIONS_H_ 25 | -------------------------------------------------------------------------------- /nativeui/win/util/subwin_holder.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/win/util/subwin_holder.h" 6 | 7 | #include "nativeui/win/subwin_view.h" 8 | #include "nativeui/win/util/hwnd_util.h" 9 | 10 | namespace nu { 11 | 12 | SubwinHolder::SubwinHolder() { 13 | } 14 | 15 | SubwinHolder::~SubwinHolder() { 16 | } 17 | 18 | void SubwinHolder::OnCommand(UINT code, int command, HWND window) { 19 | if (!window) 20 | return; 21 | auto* control = reinterpret_cast(GetWindowUserData(window)); 22 | control->OnCommand(code, command); 23 | } 24 | 25 | LRESULT SubwinHolder::OnNotify(int id, LPNMHDR pnmh) { 26 | HWND window = pnmh->hwndFrom; 27 | auto* control = reinterpret_cast(GetWindowUserData(window)); 28 | return control->OnNotify(id, pnmh); 29 | } 30 | 31 | } // namespace nu 32 | -------------------------------------------------------------------------------- /third_party/libxml/src/acinclude.m4: -------------------------------------------------------------------------------- 1 | dnl Like AC_TRY_EVAL but also errors out if the compiler generates 2 | dnl _any_ output. Some compilers might issue warnings which we want 3 | dnl to catch. 4 | AC_DEFUN([AC_TRY_EVAL2], 5 | [{ (eval echo configure:__oline__: \"[$]$1\") 1>&AS_MESSAGE_LOG_FD; dnl 6 | (eval [$]$1) 2>&AS_MESSAGE_LOG_FD; _out=`eval [$]$1 2>&1` && test "x$_out" = x; }]) 7 | 8 | dnl Like AC_TRY_COMPILE but calls AC_TRY_EVAL2 instead of AC_TRY_EVAL 9 | AC_DEFUN([AC_TRY_COMPILE2], 10 | [cat > conftest.$ac_ext <&AS_MESSAGE_LOG_FD 23 | cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD 24 | ifelse([$4], , , [ rm -rf conftest* 25 | $4 26 | ])dnl 27 | fi 28 | rm -f conftest*]) 29 | -------------------------------------------------------------------------------- /nativeui/gfx/geometry/insets.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "nativeui/gfx/geometry/insets.h" 6 | 7 | #include "base/strings/stringprintf.h" 8 | 9 | namespace nu { 10 | 11 | Insets::Insets() : Insets(0) {} 12 | 13 | Insets::Insets(int all) : Insets(all, all, all, all) {} 14 | 15 | Insets::Insets(int vertical, int horizontal) 16 | : Insets(vertical, horizontal, vertical, horizontal) {} 17 | 18 | Insets::Insets(int top, int left, int bottom, int right) 19 | : top_(top), left_(left), bottom_(bottom), right_(right) {} 20 | 21 | Insets::~Insets() {} 22 | 23 | std::string Insets::ToString() const { 24 | // Print members in the same order of the constructor parameters. 25 | return base::StringPrintf("%d,%d,%d,%d", top(), left(), bottom(), right()); 26 | } 27 | 28 | } // namespace nu 29 | -------------------------------------------------------------------------------- /docs/layout/page.pug: -------------------------------------------------------------------------------- 1 | doctype html 2 | html 3 | head 4 | title #{doc.name} - Yue 5 | style 6 | include:css-minimize style.css 7 | include:css-minimize markdown.css 8 | include:css-minimize highlight.css 9 | if page == 'api' || page == 'index' 10 | include:css-minimize api.css 11 | else if page == 'guide' 12 | include:css-minimize guide.css 13 | body 14 | #header 15 | if page == 'api' || page == 'guide' 16 | - var docslink = "../index.html" 17 | else 18 | - var docslink = "index.html" 19 | a.logo(href=`${docslink}`) Yue 20 | .nav 21 | a(href=`${docslink}`) Docs 22 | a(href="/") Versions 23 | a(href="https://github.com/yue/yue") GitHub 24 | #container 25 | #content.markdown-body 26 | block content 27 | #sidebar.markdown-body 28 | block sidebar 29 | #footer 30 | p Content of this page is in public domain. 31 | -------------------------------------------------------------------------------- /nativeui/gfx/geometry/point_conversions.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef NATIVEUI_GFX_GEOMETRY_POINT_CONVERSIONS_H_ 6 | #define NATIVEUI_GFX_GEOMETRY_POINT_CONVERSIONS_H_ 7 | 8 | #include "nativeui/gfx/geometry/point.h" 9 | #include "nativeui/gfx/geometry/point_f.h" 10 | 11 | namespace nu { 12 | 13 | // Returns a Point with each component from the input PointF floored. 14 | NATIVEUI_EXPORT Point ToFlooredPoint(const PointF& point); 15 | 16 | // Returns a Point with each component from the input PointF ceiled. 17 | NATIVEUI_EXPORT Point ToCeiledPoint(const PointF& point); 18 | 19 | // Returns a Point with each component from the input PointF rounded. 20 | NATIVEUI_EXPORT Point ToRoundedPoint(const PointF& point); 21 | 22 | } // namespace nu 23 | 24 | #endif // NATIVEUI_GFX_GEOMETRY_POINT_CONVERSIONS_H_ 25 | -------------------------------------------------------------------------------- /nativeui/gfx/geometry/vector2d_conversions.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "nativeui/gfx/geometry/vector2d_conversions.h" 6 | 7 | #include "nativeui/gfx/geometry/safe_integer_conversions.h" 8 | 9 | namespace nu { 10 | 11 | Vector2d ToFlooredVector2d(const Vector2dF& vector2d) { 12 | int x = ToFlooredInt(vector2d.x()); 13 | int y = ToFlooredInt(vector2d.y()); 14 | return Vector2d(x, y); 15 | } 16 | 17 | Vector2d ToCeiledVector2d(const Vector2dF& vector2d) { 18 | int x = ToCeiledInt(vector2d.x()); 19 | int y = ToCeiledInt(vector2d.y()); 20 | return Vector2d(x, y); 21 | } 22 | 23 | Vector2d ToRoundedVector2d(const Vector2dF& vector2d) { 24 | int x = ToRoundedInt(vector2d.x()); 25 | int y = ToRoundedInt(vector2d.y()); 26 | return Vector2d(x, y); 27 | } 28 | 29 | } // namespace nu 30 | 31 | -------------------------------------------------------------------------------- /nativeui/group_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/nativeui.h" 6 | #include "testing/gtest/include/gtest/gtest.h" 7 | 8 | class GroupTest : public testing::Test { 9 | protected: 10 | nu::Lifetime lifetime_; 11 | nu::State state_; 12 | }; 13 | 14 | TEST_F(GroupTest, ContentView) { 15 | scoped_refptr group(new nu::Group("title")); 16 | nu::Container* view = new nu::Container; 17 | group->SetContentView(view); 18 | EXPECT_EQ(group->GetContentView(), view); 19 | } 20 | 21 | TEST_F(GroupTest, Title) { 22 | scoped_refptr group(new nu::Group("title")); 23 | group->SetTitle("test"); 24 | EXPECT_EQ(group->GetTitle(), "test"); 25 | } 26 | 27 | TEST_F(GroupTest, EmbeddingScroll) { 28 | scoped_refptr group(new nu::Group("title")); 29 | group->SetContentView(new nu::Scroll); 30 | } 31 | -------------------------------------------------------------------------------- /third_party/libxml/src/enc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Summary: Internal Interfaces for encoding in libxml2 3 | * Description: this module describes a few interfaces which were 4 | * addded along with the API changes in 2.9.0 5 | * those are private routines at this point 6 | * 7 | * Copy: See Copyright for the status of this software. 8 | * 9 | * Author: Daniel Veillard 10 | */ 11 | 12 | #ifndef __XML_ENC_H__ 13 | #define __XML_ENC_H__ 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | int xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out, 22 | xmlBufferPtr in, int len); 23 | int xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len); 24 | int xmlCharEncInput(xmlParserInputBufferPtr input, int flush); 25 | int xmlCharEncOutput(xmlOutputBufferPtr output, int init); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | #endif /* __XML_ENC_H__ */ 31 | 32 | 33 | -------------------------------------------------------------------------------- /lua/stack_auto_reset.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef LUA_STACK_AUTO_RESET_H_ 6 | #define LUA_STACK_AUTO_RESET_H_ 7 | 8 | #include "lua/state.h" 9 | 10 | namespace lua { 11 | 12 | // Thin wrappers of settop. 13 | inline void SetTop(State* state, int index) { 14 | lua_settop(state, index); 15 | } 16 | 17 | inline int GetTop(State* state) { 18 | return lua_gettop(state); 19 | } 20 | 21 | // Automatically clear the values on stack. 22 | class StackAutoReset { 23 | public: 24 | explicit StackAutoReset(State* state) : state_(state), top_(GetTop(state)) {} 25 | ~StackAutoReset() { SetTop(state_, top_); } 26 | 27 | int top() const { return top_; } 28 | 29 | private: 30 | State* state_; 31 | int top_; 32 | 33 | DISALLOW_COPY_AND_ASSIGN(StackAutoReset); 34 | }; 35 | 36 | } // namespace lua 37 | 38 | #endif // LUA_STACK_AUTO_RESET_H_ 39 | -------------------------------------------------------------------------------- /nativeui/asar_archive.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_ASAR_ARCHIVE_H_ 6 | #define NATIVEUI_ASAR_ARCHIVE_H_ 7 | 8 | #include 9 | 10 | #include "base/files/file.h" 11 | #include "base/values.h" 12 | #include "nativeui/nativeui_export.h" 13 | 14 | namespace nu { 15 | 16 | class NATIVEUI_EXPORT AsarArchive { 17 | public: 18 | struct FileInfo { 19 | uint32_t size = 0; 20 | uint64_t offset = 0; 21 | }; 22 | 23 | AsarArchive(base::File file, bool extended_format); 24 | virtual ~AsarArchive(); 25 | 26 | bool IsValid() const; 27 | bool GetFileInfo(const std::string& path, FileInfo* info); 28 | 29 | private: 30 | bool ReadExtendedMeta(); 31 | 32 | base::File file_; 33 | base::Value header_; 34 | uint64_t content_offset_ = 0; 35 | }; 36 | 37 | } // namespace nu 38 | 39 | #endif // NATIVEUI_ASAR_ARCHIVE_H_ 40 | -------------------------------------------------------------------------------- /nativeui/gfx/geometry/insets_f.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "nativeui/gfx/geometry/insets_f.h" 6 | 7 | #include "base/strings/stringprintf.h" 8 | 9 | namespace nu { 10 | 11 | InsetsF::InsetsF() : InsetsF(0.f) {} 12 | 13 | InsetsF::InsetsF(float all) : InsetsF(all, all, all, all) {} 14 | 15 | InsetsF::InsetsF(float vertical, float horizontal) 16 | : InsetsF(vertical, horizontal, vertical, horizontal) {} 17 | 18 | InsetsF::InsetsF(float top, float left, float bottom, float right) 19 | : top_(top), left_(left), bottom_(bottom), right_(right) {} 20 | 21 | InsetsF::~InsetsF() {} 22 | 23 | std::string InsetsF::ToString() const { 24 | // Print members in the same order of the constructor parameters. 25 | return base::StringPrintf("%f,%f,%f,%f", top(), left(), bottom(), right()); 26 | } 27 | 28 | } // namespace nu 29 | -------------------------------------------------------------------------------- /scripts/download_gn.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // Copyright 2018 Cheng Zhao. All rights reserved. 4 | // Use of this source code is governed by the license that can be found in the 5 | // LICENSE file. 6 | 7 | const fs = require('fs') 8 | const path = require('path') 9 | const extract = require('./libs/extract-zip') 10 | 11 | const {targetOs, download} = require('./common') 12 | 13 | const version = 'v0.2.4' 14 | const url = `https://github.com/yue/build-gn/releases/download/${version}/gn_${version}_${targetOs}_x64.zip` 15 | 16 | const gnDir = path.resolve('tools', 'gn') 17 | const verFile = path.join(gnDir, '.version') 18 | if (fs.existsSync(verFile) && fs.readFileSync(verFile) == version) 19 | return 20 | 21 | download(url, (response) => { 22 | response.on('end', () => { 23 | extract('gn.zip', {dir: gnDir}, () => { 24 | fs.writeFileSync(verFile, version) 25 | fs.unlinkSync('gn.zip') 26 | }) 27 | }) 28 | response.pipe(fs.createWriteStream('gn.zip')) 29 | }) 30 | -------------------------------------------------------------------------------- /docs/api/menubase.yaml: -------------------------------------------------------------------------------- 1 | name: MenuBase 2 | component: gui 3 | header: nativeui/menu_base.h 4 | type: refcounted 5 | namespace: nu 6 | description: Base class of menu bar and popup menu. 7 | 8 | lang_detail: 9 | lua: | 10 | Note that the `index` counts from `1`, following lua's convention. 11 | 12 | methods: 13 | - signature: void Append(MenuItem* item) 14 | description: Append the `item` to the menu. 15 | 16 | - signature: void Insert(MenuItem* item, int index) 17 | description: Insert the `item` at `index` to the menu. 18 | 19 | - signature: void Remove(MenuItem* item) 20 | description: Remove the `item` from the menu. 21 | 22 | - signature: int ItemCount() const 23 | description: Return the count of items in the menu. 24 | 25 | - signature: MenuItem* ItemAt(int index) const 26 | description: Return the item at `index`. 27 | 28 | - signature: NativeMenu GetNative() const 29 | lang: ['cpp'] 30 | description: Return the native instance wrapped by the class. 31 | -------------------------------------------------------------------------------- /.appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | os: Visual Studio 2017 4 | 5 | init: 6 | - git config --global core.autocrlf input 7 | 8 | platform: x64 9 | environment: 10 | matrix: 11 | - TARGET_CPU: x64 12 | - TARGET_CPU: x86 13 | 14 | install: 15 | - ps: Install-Product node 8.2.1 16 | - cmd: SET PATH=C:\Program Files (x86)\MSBuild\14.0\bin\;%PATH% 17 | - cmd: SET PATH=C:\python27;%PATH% 18 | - cmd: node scripts/cibuild.js --target-cpu=%TARGET_CPU% 19 | 20 | artifacts: 21 | - path: 'out\Dist\*.zip' 22 | 23 | deploy: 24 | - provider: GitHub 25 | release: Yue $(APPVEYOR_REPO_TAG_NAME) 26 | tag: $(APPVEYOR_REPO_TAG_NAME) 27 | description: '(placeholder)' 28 | auth_token: 29 | secure: A6p8IoStnodPh/lGnc41E+ACsYdyfOV3Z7K6H3w0Xz2SsLpL06AKb6PTNmMtWp1F 30 | artifact: /.*\.zip/ 31 | draft: true 32 | force_update: true 33 | prerelease: false 34 | on: 35 | appveyor_repo_tag: true 36 | 37 | # disable build and test pahses 38 | build: off 39 | test: off 40 | -------------------------------------------------------------------------------- /docs/api/state.yaml: -------------------------------------------------------------------------------- 1 | name: State 2 | lang: ['cpp'] 3 | component: gui 4 | header: nativeui/state.h 5 | type: class 6 | namespace: nu 7 | description: Global state. 8 | 9 | detail: | 10 | This class manages the global state of Yue's GUI components, it should always 11 | be initialized before you call any GUI related API, and released after all 12 | instances of GUI components get destroyed. 13 | 14 | A common pattern is to create `State` on stack before entering message loop: 15 | 16 | ```cpp 17 | int main() { 18 | nu::State state; 19 | 20 | // Enter message loop. 21 | MessageLoop().Run(); 22 | 23 | return 0; 24 | } 25 | ``` 26 | 27 | It is safe to leak it if you can't or don't want to clean up resources on 28 | exit. 29 | 30 | constructors: 31 | - signature: State() 32 | description: Create global state, each thread can only have one `State`. 33 | 34 | class_methods: 35 | - signature: State* GetCurrent() 36 | description: Return the global state of current thread. 37 | -------------------------------------------------------------------------------- /lua/call_context.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef LUA_CALL_CONTEXT_H_ 6 | #define LUA_CALL_CONTEXT_H_ 7 | 8 | #include "lua/state.h" 9 | 10 | namespace lua { 11 | 12 | // A class used by PCall to provide information of current call. 13 | struct CallContext { 14 | explicit CallContext(State* state) : state(state) {} 15 | 16 | // The lua state. 17 | State* state; 18 | 19 | // How many return values we have. 20 | int return_values_count = 0; 21 | 22 | // Whether there is error on stack. 23 | bool has_error = false; 24 | 25 | // The index (1-based) of current arg. 26 | int current_arg = 1; 27 | 28 | // The index (1-based) of the arg that failed to convert. 29 | int invalid_arg = 0; 30 | 31 | // The name of the invalid arg. 32 | const char* invalid_arg_name = nullptr; 33 | }; 34 | 35 | } // namespace lua 36 | 37 | #endif // LUA_CALL_CONTEXT_H_ 38 | -------------------------------------------------------------------------------- /nativeui/entry.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_ENTRY_H_ 6 | #define NATIVEUI_ENTRY_H_ 7 | 8 | #include 9 | 10 | #include "nativeui/view.h" 11 | 12 | namespace nu { 13 | 14 | class NATIVEUI_EXPORT Entry : public View { 15 | public: 16 | enum class Type { 17 | Normal, 18 | Password, 19 | }; 20 | 21 | explicit Entry(Type type = Type::Normal); 22 | 23 | // View class name. 24 | static const char kClassName[]; 25 | 26 | void SetText(const std::string& text); 27 | std::string GetText() const; 28 | 29 | // View: 30 | const char* GetClassName() const override; 31 | SizeF GetMinimumSize() const override; 32 | 33 | // Events. 34 | Signal on_text_change; 35 | Signal on_activate; 36 | 37 | protected: 38 | ~Entry() override; 39 | }; 40 | 41 | } // namespace nu 42 | 43 | #endif // NATIVEUI_ENTRY_H_ 44 | -------------------------------------------------------------------------------- /nativeui/gfx/win/text_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/gfx/win/text_win.h" 6 | 7 | #include "base/win/scoped_hdc.h" 8 | #include "nativeui/gfx/win/gdiplus.h" 9 | 10 | namespace nu { 11 | 12 | SizeF MeasureText(const base::string16& text, Font* font) { 13 | base::win::ScopedGetDC dc(NULL); 14 | return MeasureText(dc, text, font); 15 | } 16 | 17 | SizeF MeasureText(HDC dc, const base::string16& text, Font* font) { 18 | Gdiplus::Graphics graphics(dc); 19 | Gdiplus::RectF rect; 20 | graphics.MeasureString(text.data(), static_cast(text.length()), 21 | font->GetNative(), Gdiplus::PointF(0., 0.), &rect); 22 | // The height returned by MeasureString is the bounding height, while we 23 | // usually want the exact height. 24 | return SizeF(rect.Width, font->GetNative()->GetHeight(&graphics)); 25 | } 26 | 27 | } // namespace nu 28 | -------------------------------------------------------------------------------- /nativeui/label.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_LABEL_H_ 6 | #define NATIVEUI_LABEL_H_ 7 | 8 | #include 9 | 10 | #include "nativeui/gfx/text.h" 11 | #include "nativeui/view.h" 12 | 13 | namespace nu { 14 | 15 | class NATIVEUI_EXPORT Label : public View { 16 | public: 17 | explicit Label(const std::string& text = ""); 18 | 19 | // View class name. 20 | static const char kClassName[]; 21 | 22 | void SetText(const std::string& text); 23 | std::string GetText() const; 24 | void SetAlign(TextAlign align); 25 | void SetVAlign(TextAlign align); 26 | 27 | // View: 28 | const char* GetClassName() const override; 29 | SizeF GetMinimumSize() const override; 30 | 31 | protected: 32 | ~Label() override; 33 | 34 | private: 35 | void PlatformSetText(const std::string& text); 36 | }; 37 | 38 | } // namespace nu 39 | 40 | #endif // NATIVEUI_LABEL_H_ 41 | -------------------------------------------------------------------------------- /nativeui/gfx/geometry/vector2d_conversions.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef NATIVEUI_GFX_GEOMETRY_VECTOR2D_CONVERSIONS_H_ 6 | #define NATIVEUI_GFX_GEOMETRY_VECTOR2D_CONVERSIONS_H_ 7 | 8 | #include "nativeui/gfx/geometry/vector2d.h" 9 | #include "nativeui/gfx/geometry/vector2d_f.h" 10 | 11 | namespace nu { 12 | 13 | // Returns a Vector2d with each component from the input Vector2dF floored. 14 | NATIVEUI_EXPORT Vector2d ToFlooredVector2d(const Vector2dF& vector2d); 15 | 16 | // Returns a Vector2d with each component from the input Vector2dF ceiled. 17 | NATIVEUI_EXPORT Vector2d ToCeiledVector2d(const Vector2dF& vector2d); 18 | 19 | // Returns a Vector2d with each component from the input Vector2dF rounded. 20 | NATIVEUI_EXPORT Vector2d ToRoundedVector2d(const Vector2dF& vector2d); 21 | 22 | } // namespace nu 23 | 24 | #endif // NATIVEUI_GFX_GEOMETRY_VECTOR2D_CONVERSIONS_H_ 25 | -------------------------------------------------------------------------------- /nativeui/gtk/nu_image.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_GTK_NU_IMAGE_H_ 6 | #define NATIVEUI_GTK_NU_IMAGE_H_ 7 | 8 | #include 9 | 10 | // Custom widget to show images, with high DPI supported. 11 | 12 | namespace nu { 13 | 14 | class Image; 15 | 16 | #define NU_TYPE_IMAGE (nu_image_get_type ()) 17 | #define NU_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \ 18 | NU_TYPE_IMAGE, NUImage)) 19 | 20 | typedef struct _NUImage NUImage; 21 | typedef struct _NUImagePrivate NUImagePrivate; 22 | typedef struct _NUImageClass NUImageClass; 23 | 24 | struct _NUImage { 25 | GtkWidget container; 26 | NUImagePrivate* priv; 27 | }; 28 | 29 | struct _NUImageClass { 30 | GtkWidgetClass parent_class; 31 | }; 32 | 33 | GType nu_image_get_type(); 34 | GtkWidget* nu_image_new(Image* image); 35 | 36 | } // namespace nu 37 | 38 | #endif // NATIVEUI_GTK_NU_IMAGE_H_ 39 | -------------------------------------------------------------------------------- /lua_yue/binding_values_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include 6 | #include 7 | 8 | #include "base/json/json_reader.h" 9 | #include "base/json/json_writer.h" 10 | #include "lua_yue/binding_values.h" 11 | #include "testing/gtest/include/gtest/gtest.h" 12 | 13 | class YueValuesTest : public testing::Test { 14 | protected: 15 | void SetUp() override { 16 | lua::SetTop(state_, 0); 17 | } 18 | 19 | lua::ManagedState state_; 20 | }; 21 | 22 | TEST_F(YueValuesTest, ValueConversions) { 23 | std::unique_ptr in = base::JSONReader::Read( 24 | "{ \"a\": 1.0, \"b\": { \"c\": [\"t\", \"e\"], \"d\": \"st\" } }"); 25 | lua::Push(state_, *in); 26 | base::Value out; 27 | ASSERT_TRUE(lua::To(state_, 1, &out)); 28 | std::string json; 29 | ASSERT_TRUE(base::JSONWriter::Write(out, &json)); 30 | ASSERT_EQ(json, "{\"a\":1.0,\"b\":{\"c\":[\"t\",\"e\"],\"d\":\"st\"}}"); 31 | } 32 | -------------------------------------------------------------------------------- /nativeui/gfx/text.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_GFX_TEXT_H_ 6 | #define NATIVEUI_GFX_TEXT_H_ 7 | 8 | #include "base/memory/ref_counted.h" 9 | #include "nativeui/gfx/color.h" 10 | #include "nativeui/gfx/font.h" 11 | #include "nativeui/gfx/geometry/size_f.h" 12 | 13 | namespace nu { 14 | 15 | // Text alignment when drawing text. 16 | enum class TextAlign { 17 | Start, 18 | Center, 19 | End, 20 | }; 21 | 22 | // Attributes used for drawing the text. 23 | struct NATIVEUI_EXPORT TextAttributes { 24 | TextAttributes(); 25 | TextAttributes(Font* font, Color color, TextAlign align, TextAlign valign); 26 | ~TextAttributes(); 27 | 28 | scoped_refptr font; 29 | Color color; 30 | TextAlign align; 31 | TextAlign valign; 32 | }; 33 | 34 | // Result of text measurement. 35 | struct TextMetrics { 36 | SizeF size; 37 | }; 38 | 39 | } // namespace nu 40 | 41 | #endif // NATIVEUI_GFX_TEXT_H_ 42 | -------------------------------------------------------------------------------- /docs/api/label.yaml: -------------------------------------------------------------------------------- 1 | name: Label 2 | component: gui 3 | header: nativeui/label.h 4 | type: refcounted 5 | namespace: nu 6 | inherit: View 7 | description: Display text. 8 | 9 | constructors: 10 | - signature: Label(const std::string& text) 11 | lang: ['cpp'] 12 | description: Create a new `Label` with `text`. 13 | 14 | class_methods: 15 | - signature: Label* Create(const std::string& text) 16 | lang: ['lua', 'js'] 17 | description: Create a new `Label` with `text`. 18 | 19 | class_properties: 20 | - property: const char* kClassName 21 | lang: ['cpp'] 22 | description: The class name of this view. 23 | 24 | methods: 25 | - signature: void SetText(const std::string& text) 26 | description: Set the text to display. 27 | 28 | - signature: std::string GetText() const 29 | description: Return the text displayed. 30 | 31 | - signature: void SetAlign(TextAlign align) 32 | description: Set horizontal text alignment. 33 | 34 | - signature: void SetVAlign(TextAlign align) 35 | description: Set vertical text alignment. 36 | -------------------------------------------------------------------------------- /nativeui/gfx/geometry/vector2d.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "nativeui/gfx/geometry/vector2d.h" 6 | 7 | #include 8 | 9 | #include "base/strings/stringprintf.h" 10 | 11 | namespace nu { 12 | 13 | bool Vector2d::IsZero() const { 14 | return x_ == 0 && y_ == 0; 15 | } 16 | 17 | void Vector2d::Add(const Vector2d& other) { 18 | x_ += other.x_; 19 | y_ += other.y_; 20 | } 21 | 22 | void Vector2d::Subtract(const Vector2d& other) { 23 | x_ -= other.x_; 24 | y_ -= other.y_; 25 | } 26 | 27 | int64_t Vector2d::LengthSquared() const { 28 | return static_cast(x_) * x_ + static_cast(y_) * y_; 29 | } 30 | 31 | float Vector2d::Length() const { 32 | return static_cast(std::sqrt(static_cast(LengthSquared()))); 33 | } 34 | 35 | std::string Vector2d::ToString() const { 36 | return base::StringPrintf("[%d %d]", x_, y_); 37 | } 38 | 39 | } // namespace nu 40 | -------------------------------------------------------------------------------- /nativeui/protocol_file_job.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_PROTOCOL_FILE_JOB_H_ 6 | #define NATIVEUI_PROTOCOL_FILE_JOB_H_ 7 | 8 | #include 9 | 10 | #include "base/files/file.h" 11 | #include "base/files/file_path.h" 12 | #include "nativeui/protocol_job.h" 13 | 14 | namespace nu { 15 | 16 | // Serve file for the protocol request. 17 | class NATIVEUI_EXPORT ProtocolFileJob : public ProtocolJob { 18 | public: 19 | explicit ProtocolFileJob(const base::FilePath& path); 20 | 21 | // ProtocolJob: 22 | bool Start() override; 23 | void Kill() override; 24 | bool GetMimeType(std::string* mime_type) override; 25 | size_t Read(void* buf, size_t buf_size) override; 26 | 27 | protected: 28 | ~ProtocolFileJob() override; 29 | 30 | base::FilePath path_; 31 | base::File file_; 32 | int64_t content_length_ = 0; 33 | }; 34 | 35 | } // namespace nu 36 | 37 | #endif // NATIVEUI_PROTOCOL_FILE_JOB_H_ 38 | -------------------------------------------------------------------------------- /nativeui/mac/nu_application_delegate.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/mac/nu_application_delegate.h" 6 | 7 | #include "nativeui/lifetime.h" 8 | 9 | @implementation NUApplicationDelegate 10 | 11 | - (id)initWithShell:(nu::Lifetime*)shell { 12 | if ((self = [super init])) 13 | shell_ = shell; 14 | return self; 15 | } 16 | 17 | - (void)applicationWillFinishLaunching:(NSNotification*)notify { 18 | // Don't add the "Enter Full Screen" menu item automatically. 19 | [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSFullScreenMenuItemEverywhere"]; 20 | } 21 | 22 | - (void)applicationDidFinishLaunching:(NSNotification*)notify { 23 | shell_->on_ready.Emit(); 24 | } 25 | 26 | - (BOOL)applicationShouldHandleReopen:(NSApplication*)sender 27 | hasVisibleWindows:(BOOL)flag { 28 | if (flag) 29 | return YES; 30 | shell_->on_activate.Emit(); 31 | return NO; 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /nativeui/scroll.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/scroll.h" 6 | 7 | #include "nativeui/container.h" 8 | #include "nativeui/gfx/geometry/size_conversions.h" 9 | 10 | namespace nu { 11 | 12 | // static 13 | const char Scroll::kClassName[] = "Scroll"; 14 | 15 | Scroll::Scroll() { 16 | PlatformInit(); 17 | SetContentView(new Container); 18 | } 19 | 20 | Scroll::~Scroll() { 21 | } 22 | 23 | void Scroll::SetContentView(View* view) { 24 | if (content_view_) 25 | content_view_->SetParent(nullptr); 26 | PlatformSetContentView(view); 27 | content_view_ = view; 28 | content_view_->SetParent(this); 29 | } 30 | 31 | View* Scroll::GetContentView() const { 32 | return content_view_.get(); 33 | } 34 | 35 | SizeF Scroll::GetContentSize() const { 36 | return GetContentView()->GetBounds().size(); 37 | } 38 | 39 | const char* Scroll::GetClassName() const { 40 | return kClassName; 41 | } 42 | 43 | } // namespace nu 44 | -------------------------------------------------------------------------------- /sample_app/main.cc: -------------------------------------------------------------------------------- 1 | // This file is published under public domain. 2 | 3 | #include "base/command_line.h" 4 | #include "nativeui/nativeui.h" 5 | 6 | #if defined(OS_WIN) 7 | int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { 8 | base::CommandLine::Init(0, nullptr); 9 | #else 10 | int main(int argc, const char *argv[]) { 11 | base::CommandLine::Init(argc, argv); 12 | #endif 13 | 14 | // Intialize GUI toolkit. 15 | nu::Lifetime lifetime; 16 | 17 | // Initialize the global instance of nativeui. 18 | nu::State state; 19 | 20 | // Create window with default options, and then show it. 21 | scoped_refptr window(new nu::Window(nu::Window::Options())); 22 | window->SetContentView(new nu::Label("Hello world")); 23 | window->SetContentSize(nu::SizeF(400, 400)); 24 | window->Center(); 25 | window->Activate(); 26 | 27 | // Quit when window is closed. 28 | window->on_close.Connect([&state](nu::Window*) { 29 | nu::MessageLoop::Quit(); 30 | }); 31 | 32 | // Enter message loop. 33 | nu::MessageLoop::Run(); 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /docs/api/group.yaml: -------------------------------------------------------------------------------- 1 | name: Group 2 | component: gui 3 | header: nativeui/group.h 4 | type: refcounted 5 | namespace: nu 6 | inherit: View 7 | description: Display a container view with title and border. 8 | 9 | constructors: 10 | - signature: Group(const std::string& title) 11 | lang: ['cpp'] 12 | description: Create a new `Group` with `title`. 13 | 14 | class_methods: 15 | - signature: Group* Create(const std::string& title) 16 | lang: ['lua', 'js'] 17 | description: Create a new `Group` with `title`. 18 | 19 | class_properties: 20 | - property: const char* kClassName 21 | lang: ['cpp'] 22 | description: The class name of this view. 23 | 24 | methods: 25 | - signature: void SetContentView(Container* view) 26 | description: Set the content view. 27 | 28 | - signature: Container* GetContentView() const 29 | description: Return the content view. 30 | 31 | - signature: void SetTitle(const std::string& title) 32 | description: Set the title. 33 | 34 | - signature: std::string GetTitle() const 35 | description: Return the title. 36 | -------------------------------------------------------------------------------- /nativeui/events/keyboard_code_conversion.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Copyright 2014 The Chromium Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style license that can be 4 | // found in the LICENSE.chromium file. 5 | 6 | #ifndef NATIVEUI_EVENTS_KEYBOARD_CODE_CONVERSION_H_ 7 | #define NATIVEUI_EVENTS_KEYBOARD_CODE_CONVERSION_H_ 8 | 9 | #include 10 | 11 | #include "nativeui/events/keyboard_codes.h" 12 | #include "nativeui/nativeui_export.h" 13 | 14 | namespace nu { 15 | 16 | // Convert a key code to string, using the values of KeyboardEvent.key: 17 | // https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values 18 | NATIVEUI_EXPORT const char* KeyboardCodeToStr(KeyboardCode code); 19 | 20 | // Convert a string to a key code represented by it. 21 | NATIVEUI_EXPORT KeyboardCode KeyboardCodeFromStr(const std::string& str, 22 | bool* shifted); 23 | 24 | } // namespace nu 25 | 26 | #endif // NATIVEUI_EVENTS_KEYBOARD_CODE_CONVERSION_H_ 27 | -------------------------------------------------------------------------------- /nativeui/protocol_asar_job.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_PROTOCOL_ASAR_JOB_H_ 6 | #define NATIVEUI_PROTOCOL_ASAR_JOB_H_ 7 | 8 | #include 9 | 10 | #include "nativeui/protocol_file_job.h" 11 | #include "nativeui/util/aes.h" 12 | 13 | namespace nu { 14 | 15 | class AES; 16 | 17 | class NATIVEUI_EXPORT ProtocolAsarJob : public ProtocolFileJob { 18 | public: 19 | ProtocolAsarJob(const base::FilePath& asar, const std::string& path); 20 | 21 | bool SetDecipher(const std::string& key, const std::string& iv); 22 | 23 | protected: 24 | ~ProtocolAsarJob() override; 25 | 26 | // ProtocolJob: 27 | bool Start() override; 28 | size_t Read(void* buf, size_t buf_size) override; 29 | 30 | AES aes_; 31 | 32 | // Buffer used to store remaining encrypted data. 33 | uint8_t buffer_[AES_BLOCKLEN]; 34 | size_t remaining_ = 0; 35 | }; 36 | 37 | } // namespace nu 38 | 39 | #endif // NATIVEUI_PROTOCOL_ASAR_JOB_H_ 40 | -------------------------------------------------------------------------------- /nativeui/win/file_save_dialog_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/win/file_save_dialog_win.h" 6 | 7 | #include 8 | 9 | namespace nu { 10 | 11 | FileSaveDialogImpl::FileSaveDialogImpl() : FileDialogImpl(Initialize()) { 12 | } 13 | 14 | FileSaveDialogImpl::~FileSaveDialogImpl() { 15 | } 16 | 17 | ComPtr FileSaveDialogImpl::Initialize() const { 18 | ComPtr ptr; 19 | ::CoCreateInstance(CLSID_FileSaveDialog, 20 | nullptr, 21 | CLSCTX_INPROC_SERVER, 22 | IID_PPV_ARGS(&ptr)); 23 | return std::move(ptr); 24 | } 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | // Public FileSaveDialog API implementation. 28 | 29 | FileSaveDialog::FileSaveDialog() : FileDialog(new FileSaveDialogImpl) { 30 | } 31 | 32 | FileSaveDialog::~FileSaveDialog() { 33 | } 34 | 35 | } // namespace nu 36 | -------------------------------------------------------------------------------- /third_party/libxml/src/TODO_SCHEMAS: -------------------------------------------------------------------------------- 1 | - implement counted transitions at the automata level 2 | 3 | - Unicode: 4 | + upgrade to 3.2 5 | + improve the python script to generate better test 6 | expressions to check the list of ranges. 7 | 8 | - Implement the interface at the SAX level 9 | 10 | - Implement the missing parts in the Structure part 11 | + all content model 12 | + enumerations 13 | + countless others c.f. the TODO scattered in the code 14 | 15 | - Complete the Built-In datatype collections and Facets implementations 16 | 17 | - Regression tests based on 18 | + the primer: 19 | http://www.w3.org/TR/xmlschema-0/ 20 | + the Schemas Test Collection: 21 | http://www.w3.org/2001/05/xmlschema-test-collection/ 22 | + archives of the schemas-dev list 23 | 24 | - Integrity constraints: 25 | + what's that ? How need to read about it 26 | 27 | - "formal" checking, i.e. go through the full Structure spec and 28 | bind code and associated parts of the Schemas spec 29 | 30 | - go though the erratas 31 | http://www.w3.org/2001/05/xmlschema-errata 32 | -------------------------------------------------------------------------------- /third_party/libxml/src/win32/VC10/README.vc10: -------------------------------------------------------------------------------- 1 | 2 | README file for VC10 project files for libxml2 3 | ---------------------------------------------- 4 | 5 | to clarify: This is not the readme file for the whole libxml2 project. 6 | Rather, it's a readme for the VC10 project files, attached to the libxml2 proejct. 7 | 8 | Quick Start 9 | ----------- 10 | 11 | 1) To use, load the libxml2.sln solution file into visual studio 12 | 2) check and correct paths for dependent "iconv" project which most certaily 13 | are wrong on your environment. 14 | 3) Compile all projects 15 | 16 | 17 | Background Info 18 | --------------- 19 | 20 | Running of "configure.sh" won't make sense since VS doesn't support 21 | this kind of build system and the environment is pretty much known already 22 | if you're using Visual Studio. Instead, a preconfigured "config.h" file 23 | is provided in the "win32\VC10" directory and referenced by the project 24 | files already. 25 | 26 | The compile process is not completely warning-free: Some warnings will 27 | appear during compile which can be ignored. 28 | -------------------------------------------------------------------------------- /nativeui/mac/state_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/state.h" 6 | 7 | #include "nativeui/mac/events_handler.h" 8 | #include "third_party/yoga/yoga/Yoga.h" 9 | 10 | namespace nu { 11 | 12 | void State::PlatformInit() { 13 | [NSApplication sharedApplication]; 14 | [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; 15 | 16 | // Disable TouchBar when the executable is not inside an app bundle, otherwise 17 | // Cocoa would just crash. 18 | if (![[NSBundle mainBundle] bundleIdentifier]) { 19 | NSDictionary* defaults = [NSDictionary 20 | dictionaryWithObject:[NSNumber numberWithBool:NO] 21 | forKey:@"NSFunctionBarAPIEnabled"]; 22 | [[NSUserDefaults standardUserDefaults] registerDefaults:defaults]; 23 | } 24 | 25 | YGConfigSetPointScaleFactor(yoga_config(), 26 | [NSScreen mainScreen].backingScaleFactor); 27 | } 28 | 29 | } // namespace nu 30 | -------------------------------------------------------------------------------- /nativeui/win/util/scoped_ole_initializer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_UTIL_SCOPED_OLE_INITIALIZER_H_ 6 | #define NATIVEUI_WIN_UTIL_SCOPED_OLE_INITIALIZER_H_ 7 | 8 | #include 9 | 10 | #include "base/macros.h" 11 | 12 | namespace nu { 13 | 14 | class ScopedOleInitializer { 15 | public: 16 | ScopedOleInitializer(); 17 | ~ScopedOleInitializer(); 18 | 19 | private: 20 | #ifndef NDEBUG 21 | // In debug builds we use this variable to catch a potential bug where a 22 | // ScopedOleInitializer instance is deleted on a different thread than it 23 | // was initially created on. If that ever happens it can have bad 24 | // consequences and the cause can be tricky to track down. 25 | DWORD thread_id_; 26 | #endif 27 | HRESULT hr_; 28 | 29 | DISALLOW_COPY_AND_ASSIGN(ScopedOleInitializer); 30 | }; 31 | 32 | } // namespace nu 33 | 34 | #endif // NATIVEUI_WIN_UTIL_SCOPED_OLE_INITIALIZER_H_ 35 | -------------------------------------------------------------------------------- /nativeui/gfx/gtk/canvas_gtk.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/gfx/canvas.h" 6 | 7 | #include "nativeui/gfx/gtk/painter_gtk.h" 8 | 9 | namespace nu { 10 | 11 | // static 12 | NativeBitmap Canvas::PlatformCreateBitmap(const SizeF& size, 13 | float scale_factor) { 14 | cairo_surface_t* surface = cairo_image_surface_create( 15 | CAIRO_FORMAT_ARGB32, 16 | size.width() * scale_factor, 17 | size.height() * scale_factor); 18 | cairo_surface_set_device_scale(surface, scale_factor, scale_factor); 19 | return surface; 20 | } 21 | 22 | // static 23 | void Canvas::PlatformDestroyBitmap(NativeBitmap bitmap) { 24 | cairo_surface_destroy(bitmap); 25 | } 26 | 27 | // static 28 | Painter* Canvas::PlatformCreatePainter(NativeBitmap bitmap, 29 | float scale_factor) { 30 | return new PainterGtk(bitmap, scale_factor); 31 | } 32 | 33 | } // namespace nu 34 | -------------------------------------------------------------------------------- /nativeui/app.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/app.h" 6 | 7 | #include "nativeui/gfx/font.h" 8 | #include "nativeui/menu_bar.h" 9 | #include "nativeui/state.h" 10 | 11 | namespace nu { 12 | 13 | // static 14 | App* App::GetCurrent() { 15 | return State::GetCurrent()->GetApp(); 16 | } 17 | 18 | App::App() : weak_factory_(this) { 19 | } 20 | 21 | App::~App() { 22 | // The GUI members must be destroyed before we shutdown GUI engine. 23 | default_font_ = nullptr; 24 | } 25 | 26 | Color App::GetColor(ThemeColor name) { 27 | int key = static_cast(name); 28 | auto it = theme_colors_.find(key); 29 | if (it != theme_colors_.end()) 30 | return it->second; 31 | Color color = PlatformGetColor(name); 32 | theme_colors_[key] = color; 33 | return color; 34 | } 35 | 36 | Font* App::GetDefaultFont() { 37 | if (!default_font_) 38 | default_font_ = new Font; 39 | return default_font_.get(); 40 | } 41 | 42 | } // namespace nu 43 | -------------------------------------------------------------------------------- /nativeui/gfx/win/scoped_set_map_mode.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_GFX_WIN_SCOPED_SET_MAP_MODE_H_ 6 | #define NATIVEUI_GFX_WIN_SCOPED_SET_MAP_MODE_H_ 7 | 8 | #include 9 | 10 | #include "base/logging.h" 11 | #include "base/macros.h" 12 | 13 | namespace nu { 14 | 15 | // Helper class for setting and restore the map mode on a DC. 16 | class ScopedSetMapMode { 17 | public: 18 | ScopedSetMapMode(HDC hdc, int map_mode) 19 | : hdc_(hdc), 20 | old_map_mode_(SetMapMode(hdc, map_mode)) { 21 | DCHECK(hdc_); 22 | DCHECK_NE(map_mode, 0); 23 | DCHECK_NE(old_map_mode_, 0); 24 | } 25 | 26 | ~ScopedSetMapMode() { 27 | const int mode = SetMapMode(hdc_, old_map_mode_); 28 | DCHECK_NE(mode, 0); 29 | } 30 | 31 | private: 32 | HDC hdc_; 33 | int old_map_mode_; 34 | 35 | DISALLOW_COPY_AND_ASSIGN(ScopedSetMapMode); 36 | }; 37 | 38 | } // namespace nu 39 | 40 | #endif // NATIVEUI_GFX_WIN_SCOPED_SET_MAP_MODE_H_ 41 | -------------------------------------------------------------------------------- /nativeui/group.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/group.h" 6 | 7 | #include "nativeui/container.h" 8 | #include "nativeui/gfx/geometry/insets.h" 9 | 10 | namespace nu { 11 | 12 | // static 13 | const char Group::kClassName[] = "Group"; 14 | 15 | Group::Group(const std::string& title) { 16 | PlatformInit(); 17 | SetContentView(new Container); 18 | SetTitle(title); 19 | UpdateDefaultStyle(); 20 | } 21 | 22 | Group::~Group() { 23 | } 24 | 25 | const char* Group::GetClassName() const { 26 | return kClassName; 27 | } 28 | 29 | SizeF Group::GetMinimumSize() const { 30 | return GetBorderSize(); 31 | } 32 | 33 | void Group::SetContentView(View* view) { 34 | if (content_view_) 35 | content_view_->SetParent(nullptr); 36 | content_view_ = view; 37 | content_view_->SetParent(this); 38 | PlatformSetContentView(view); 39 | } 40 | 41 | View* Group::GetContentView() const { 42 | return content_view_.get(); 43 | } 44 | 45 | } // namespace nu 46 | -------------------------------------------------------------------------------- /v8binding/ref_method.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "v8binding/ref_method.h" 6 | 7 | #include "v8binding/dict.h" 8 | 9 | namespace vb { 10 | 11 | namespace internal { 12 | 13 | void StoreArg(v8::Local context, 14 | v8::Local object, 15 | v8::Local ref_arg, 16 | RefType ref_type, 17 | const char* ref_key) { 18 | v8::Isolate* isolate = context->GetIsolate(); 19 | v8::Local refs = GetAttachedTable(context, object, "refs"); 20 | switch (ref_type) { 21 | case RefType::Reset: 22 | refs->Set(context, ToV8(context, ref_key), ref_arg).IsEmpty(); 23 | break; 24 | case RefType::Ref: 25 | refs->Set(context, ref_arg, v8::True(isolate)).IsEmpty(); 26 | break; 27 | case RefType::Deref: 28 | refs->Delete(context, ref_arg).IsNothing(); 29 | break; 30 | } 31 | } 32 | 33 | } // namespace internal 34 | 35 | } // namespace vb 36 | -------------------------------------------------------------------------------- /nativeui/gfx/mac/text_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/gfx/mac/text_mac.h" 6 | 7 | #import 8 | 9 | #include "base/mac/scoped_nsobject.h" 10 | #include "base/strings/sys_string_conversions.h" 11 | #include "nativeui/gfx/font.h" 12 | 13 | namespace nu { 14 | 15 | TextMetrics MeasureText(const std::string& text, float width, 16 | const TextAttributes& attributes) { 17 | NSDictionary* attrs_dict = @{ 18 | NSFontAttributeName: attributes.font->GetNative(), 19 | }; 20 | base::scoped_nsobject attributed_str( 21 | [[NSAttributedString alloc] initWithString:base::SysUTF8ToNSString(text) 22 | attributes:attrs_dict]); 23 | CGRect bounds = [attributed_str 24 | boundingRectWithSize:CGSizeMake(width, -1) 25 | options:NSStringDrawingUsesLineFragmentOrigin]; 26 | return { SizeF(bounds.size) }; 27 | } 28 | 29 | } // namespace nu 30 | -------------------------------------------------------------------------------- /nativeui/util/aes.h: -------------------------------------------------------------------------------- 1 | // This file is published under public domain. 2 | // Originially from https://github.com/kokke/tiny-AES-c. 3 | 4 | #ifndef NATIVEUI_UTIL_AES_H_ 5 | #define NATIVEUI_UTIL_AES_H_ 6 | 7 | #include 8 | 9 | #include 10 | 11 | #define AES128 1 12 | #define AES_BLOCKLEN 16 13 | 14 | #if defined(AES256) && (AES256 == 1) 15 | #define AES_KEYLEN 32 16 | #define AES_KEYEXPSIZE 240 17 | #elif defined(AES192) && (AES192 == 1) 18 | #define AES_KEYLEN 24 19 | #define AES_KEYEXPSIZE 208 20 | #else 21 | #define AES_KEYLEN 16 22 | #define AES_KEYEXPSIZE 176 23 | #endif 24 | 25 | namespace nu { 26 | 27 | class AES { 28 | public: 29 | bool Init(const std::string& key, const std::string& iv); 30 | bool IsValid() const { return is_valid_; } 31 | 32 | void CBCEncryptBuffer(uint8_t* buf, uint32_t len); 33 | void CBCDecryptBuffer(uint8_t* buf, uint32_t len); 34 | 35 | private: 36 | bool is_valid_ = false; 37 | 38 | uint8_t round_key_[AES_KEYEXPSIZE]; 39 | uint8_t iv_[AES_BLOCKLEN]; 40 | }; 41 | 42 | } // namespace nu 43 | 44 | #endif // NATIVEUI_UTIL_AES_H_ 45 | -------------------------------------------------------------------------------- /docs/api/buffer.yaml: -------------------------------------------------------------------------------- 1 | name: Buffer 2 | lang: ['cpp'] 3 | header: nativeui/buffer.h 4 | type: class 5 | namespace: nu 6 | description: A chunk of memory. 7 | detail: | 8 | This type is move-only, you should pass instances by value and use `std::move` 9 | when necessary. 10 | 11 | class_methods: 12 | - signature: Buffer Wrap(const void* content, size_t size) 13 | description: | 14 | Return a `Buffer` with `content` of `size`. The `content` is not managed 15 | by the returned `Buffer`, it is caller's reposnsibility to manage the 16 | lifetime of `content` and ensure `content` is valid during `Buffer`'s 17 | lifetime. 18 | 19 | - signature: Buffer TakeOver(void* content, size_t size, std::function free) 20 | description: | 21 | Return a `Buffer` with `content` of `size`, when destroyed the `content` 22 | would be released with `free`. 23 | 24 | methods: 25 | - signature: void* content() const 26 | description: Return the pointer to underlying memory. 27 | 28 | - signature: size_t size() const 29 | description: Return the size of pointed memory. 30 | -------------------------------------------------------------------------------- /nativeui/label_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/nativeui.h" 6 | #include "testing/gtest/include/gtest/gtest.h" 7 | 8 | class LabelTest : public testing::Test { 9 | protected: 10 | void SetUp() override { 11 | label_ = new nu::Label; 12 | } 13 | 14 | nu::Lifetime lifetime_; 15 | nu::State state_; 16 | scoped_refptr label_; 17 | }; 18 | 19 | TEST_F(LabelTest, SetText) { 20 | label_->SetText("test"); 21 | EXPECT_EQ(label_->GetText(), "test"); 22 | } 23 | 24 | // FIXME: Enable this test after we have View::GetStyle. 25 | #if 0 26 | TEST_F(LabelTest, UpdateStyle) { 27 | label_->SetText("test"); 28 | YGValue width = YGNodeStyleGetMinWidth(label_->node()); 29 | YGValue height = YGNodeStyleGetMinHeight(label_->node()); 30 | label_->SetText("longlongtest"); 31 | EXPECT_LT(width.value, YGNodeStyleGetMinWidth(label_->node()).value); 32 | EXPECT_EQ(height.value, YGNodeStyleGetMinHeight(label_->node()).value); 33 | } 34 | #endif 35 | -------------------------------------------------------------------------------- /third_party/libxml/src/Makefile.tests: -------------------------------------------------------------------------------- 1 | # 2 | # You may have to ajust to call the right compiler, or other oprions 3 | # for compiling and linking 4 | # 5 | 6 | CFLAGS=`xml2-config --cflags` 7 | LIBS=`xml2-config --libs` 8 | THREADLIB= -lpthread 9 | EXEEXT= 10 | 11 | all: runtest$(EXEEXT) runsuite$(EXEEXT) testapi$(EXEEXT) testchar$(EXEEXT) 12 | 13 | clean: 14 | $(RM) runtest$(EXEEXT) runsuite$(EXEEXT) testapi$(EXEEXT) 15 | 16 | check: do_runtest do_testchar do_testapi do_runsuite 17 | 18 | runtest$(EXEEXT): runtest.c 19 | $(CC) -o runtest$(EXEEXT) $(CFLAGS) runtest.c $(LIBS) $(THREADLIB) 20 | 21 | do_runtest: runtest$(EXEEXT) 22 | ./runtest 23 | 24 | runsuite$(EXEEXT): runsuite.c 25 | $(CC) -o runsuite$(EXEEXT) $(CFLAGS) runsuite.c $(LIBS) 26 | 27 | do_runsuite: runsuite$(EXEEXT) 28 | ./runsuite 29 | 30 | testapi$(EXEEXT): testapi.c 31 | $(CC) -o testapi$(EXEEXT) $(CFLAGS) testapi.c $(LIBS) 32 | 33 | do_testapi: testapi$(EXEEXT) 34 | ./testapi 35 | 36 | testchar$(EXEEXT): testchar.c 37 | $(CC) -o testchar$(EXEEXT) $(CFLAGS) testchar.c $(LIBS) 38 | 39 | do_testchar: testchar$(EXEEXT) 40 | ./testchar 41 | 42 | -------------------------------------------------------------------------------- /docs/api/progressbar.yaml: -------------------------------------------------------------------------------- 1 | name: ProgressBar 2 | component: gui 3 | header: nativeui/progress.h 4 | type: refcounted 5 | namespace: nu 6 | inherit: View 7 | description: Horizontal bar showing progress. 8 | 9 | constructors: 10 | - signature: ProgressBar() 11 | lang: ['cpp'] 12 | description: Create a new `ProgressBar`. 13 | 14 | class_methods: 15 | - signature: ProgressBar* Create() 16 | lang: ['lua', 'js'] 17 | description: Create a new `ProgressBar`. 18 | 19 | class_properties: 20 | - property: const char* kClassName 21 | lang: ['cpp'] 22 | description: The class name of this view. 23 | 24 | methods: 25 | - signature: void SetValue(float percent) 26 | description: Set the percent value between `0` and `100.0`. 27 | 28 | - signature: float GetValue() const 29 | description: Return the percent value between `0` and `100.0`. 30 | 31 | - signature: void SetIndeterminate(bool indeterminate) 32 | description: Set whether the progress bar is indeterminate. 33 | 34 | - signature: bool IsIndeterminate() const 35 | description: Return whether the progress bar is indeterminate. 36 | -------------------------------------------------------------------------------- /nativeui/win/clickable.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_CLICKABLE_H_ 6 | #define NATIVEUI_WIN_CLICKABLE_H_ 7 | 8 | #include "nativeui/win/view_win.h" 9 | 10 | namespace nu { 11 | 12 | // Implements common operations of a clickable view. 13 | class Clickable : public ViewImpl { 14 | public: 15 | Clickable(ControlType type, View* delegate); 16 | ~Clickable() override; 17 | 18 | virtual void OnClick() {} 19 | 20 | // ViewImpl: 21 | void OnMouseEnter(NativeEvent event) override; 22 | void OnMouseMove(NativeEvent event) override; 23 | void OnMouseLeave(NativeEvent event) override; 24 | bool OnMouseClick(NativeEvent event) override; 25 | void OnCaptureLost() override; 26 | 27 | bool is_hovering() const { return is_hovering_; } 28 | bool is_capturing() const { return is_capturing_; } 29 | 30 | private: 31 | bool is_hovering_ = false; 32 | bool is_capturing_ = false; 33 | }; 34 | 35 | } // namespace nu 36 | 37 | #endif // NATIVEUI_WIN_CLICKABLE_H_ 38 | -------------------------------------------------------------------------------- /nativeui/win/tray_win.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_TRAY_WIN_H_ 6 | #define NATIVEUI_WIN_TRAY_WIN_H_ 7 | 8 | #include "base/win/scoped_gdi_object.h" 9 | #include "nativeui/tray.h" 10 | 11 | namespace nu { 12 | 13 | class TrayHost; 14 | 15 | class TrayImpl { 16 | public: 17 | explicit TrayImpl(Tray* delegate); 18 | ~TrayImpl(); 19 | 20 | void HandleClickEvent(UINT message); 21 | void ResetIcon(); 22 | void SetImage(Image* icon); 23 | 24 | UINT icon_id() const { return icon_id_; } 25 | 26 | private: 27 | void InitIconData(NOTIFYICONDATA* icon_data); 28 | 29 | Tray* delegate_; 30 | 31 | // The host that manages the tray. 32 | TrayHost* host_; 33 | 34 | // The unique ID corresponding to this icon. 35 | UINT icon_id_; 36 | 37 | // The currently-displayed icon for the window. 38 | base::win::ScopedHICON icon_; 39 | 40 | DISALLOW_COPY_AND_ASSIGN(TrayImpl); 41 | }; 42 | 43 | } // namespace nu 44 | 45 | #endif // NATIVEUI_WIN_TRAY_WIN_H_ 46 | -------------------------------------------------------------------------------- /third_party/libxml/src/include/libxml/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to produce Makefile.in 2 | 3 | xmlincdir = $(includedir)/libxml2/libxml 4 | 5 | xmlinc_HEADERS = \ 6 | SAX.h \ 7 | entities.h \ 8 | encoding.h \ 9 | parser.h \ 10 | parserInternals.h \ 11 | xmlerror.h \ 12 | HTMLparser.h \ 13 | HTMLtree.h \ 14 | debugXML.h \ 15 | tree.h \ 16 | list.h \ 17 | hash.h \ 18 | xpath.h \ 19 | xpathInternals.h \ 20 | xpointer.h \ 21 | xinclude.h \ 22 | xmlIO.h \ 23 | xmlmemory.h \ 24 | nanohttp.h \ 25 | nanoftp.h \ 26 | uri.h \ 27 | valid.h \ 28 | xlink.h \ 29 | xmlversion.h \ 30 | DOCBparser.h \ 31 | catalog.h \ 32 | threads.h \ 33 | globals.h \ 34 | c14n.h \ 35 | xmlautomata.h \ 36 | xmlregexp.h \ 37 | xmlmodule.h \ 38 | xmlschemas.h \ 39 | schemasInternals.h \ 40 | xmlschemastypes.h \ 41 | xmlstring.h \ 42 | xmlunicode.h \ 43 | xmlreader.h \ 44 | relaxng.h \ 45 | dict.h \ 46 | SAX2.h \ 47 | xmlexports.h \ 48 | xmlwriter.h \ 49 | chvalid.h \ 50 | pattern.h \ 51 | xmlsave.h \ 52 | schematron.h 53 | 54 | EXTRA_DIST = xmlversion.h.in 55 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/modp_b64"] 2 | path = third_party/modp_b64 3 | url = https://chromium.googlesource.com/chromium/src/third_party/modp_b64 4 | [submodule "third_party/icu"] 5 | path = third_party/icu 6 | url = https://chromium.googlesource.com/chromium/deps/icu 7 | [submodule "third_party/zlib"] 8 | path = third_party/zlib 9 | url = https://chromium.googlesource.com/chromium/src/third_party/zlib 10 | [submodule "third_party/tcmalloc/chromium"] 11 | path = third_party/tcmalloc/chromium 12 | url = https://chromium.googlesource.com/chromium/src/third_party/tcmalloc/chromium 13 | [submodule "base"] 14 | path = base 15 | url = https://chromium.googlesource.com/chromium/src/base 16 | [submodule "third_party/yoga"] 17 | path = third_party/yoga 18 | url = https://github.com/facebook/yoga 19 | [submodule "third_party/yxml"] 20 | path = third_party/yxml 21 | url = git://g.blicky.net/yxml.git 22 | [submodule "third_party/ced/src"] 23 | path = third_party/ced/src 24 | url = https://github.com/google/compact_enc_det.git 25 | [submodule "third_party/lua"] 26 | path = third_party/lua 27 | url = https://github.com/ejoy/lua.git 28 | -------------------------------------------------------------------------------- /docs/development/roadmap.md: -------------------------------------------------------------------------------- 1 | # Yue Roadmap 2 | 3 | Please note that the items are __not__ prioritized. 4 | 5 | ## v1.0 6 | 7 | * Stable API 8 | 9 | ## v1.x 10 | 11 | * Drag and drop API 12 | * XML support 13 | * API to embed resources into executables/bundles 14 | * Develop a standalone version of `gn` to build Yue 15 | 16 | ### More widget types 17 | 18 | * Select 19 | * Slider 20 | * Date chooser 21 | * Rich edit 22 | * Tray 23 | * List view 24 | * Tree view 25 | * Image viewer with GIF support 26 | 27 | ### Drawing 28 | 29 | * Stock images 30 | * Bitmap support 31 | 32 | ### Improved widgets 33 | 34 | * Icon button 35 | * More Entry types 36 | * Transparent text input widgets 37 | 38 | ### macOS 39 | 40 | * More Button types 41 | 42 | ### Windows 43 | 44 | * Optional font rendering with DirectWrite 45 | * Custom draw all widgets 46 | * ICO file format support 47 | 48 | ### Lua 49 | 50 | * Add LuaRocks module 51 | * Improve our Yue-integrated lua runtime 52 | 53 | ## v2.0 54 | 55 | * Add a HTTP library 56 | 57 | ## v2.x 58 | 59 | * Animation support 60 | * Drawing on non-client area 61 | * Skia as alternative drawing backend 62 | -------------------------------------------------------------------------------- /node_yue/node_integration_linux.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 GitHub, Inc. 2 | // Copyright 2017 Cheng Zhao. All rights reserved. 3 | // Use of this source code is governed by the license that can be found in the 4 | // LICENSE file. 5 | 6 | #include "node_yue/node_integration_linux.h" 7 | 8 | #include 9 | 10 | namespace node_yue { 11 | 12 | NodeIntegrationLinux::NodeIntegrationLinux() : epoll_(epoll_create(1)) { 13 | int backend_fd = uv_backend_fd(uv_loop_); 14 | struct epoll_event ev = { 0 }; 15 | ev.events = EPOLLIN; 16 | ev.data.fd = backend_fd; 17 | epoll_ctl(epoll_, EPOLL_CTL_ADD, backend_fd, &ev); 18 | } 19 | 20 | NodeIntegrationLinux::~NodeIntegrationLinux() { 21 | } 22 | 23 | void NodeIntegrationLinux::PollEvents() { 24 | int timeout = uv_backend_timeout(uv_loop_); 25 | 26 | // Wait for new libuv events. 27 | int r; 28 | do { 29 | struct epoll_event ev; 30 | r = epoll_wait(epoll_, &ev, 1, timeout); 31 | } while (r == -1 && errno == EINTR); 32 | } 33 | 34 | // static 35 | NodeIntegration* NodeIntegration::Create() { 36 | return new NodeIntegrationLinux(); 37 | } 38 | 39 | } // namespace node_yue 40 | -------------------------------------------------------------------------------- /docs/api/lifetime.yaml: -------------------------------------------------------------------------------- 1 | name: Lifetime 2 | component: gui 3 | header: nativeui/lifetime.h 4 | type: class 5 | namespace: nu 6 | description: Application lifetime. 7 | detail: | 8 | This class does system GUI toolkit intializations, and provides APIs around 9 | native GUI toolkit's application lifetime APIs. You should not use this API 10 | when integrating Yue into existing GUI apps. 11 | 12 | When using this class, you must create `Lifetime` before creating `State`. 13 | 14 | constructor: 15 | - signature: Lifetime() 16 | lang: ['cpp'] 17 | description: | 18 | Create a `Lifetime` instance, you can only have one instance per thread. 19 | 20 | events: 21 | - callback: void on_ready() 22 | platform: ['macOS'] 23 | description: | 24 | Emitted when received `applicationDidFinishLaunching` notification. 25 | 26 | - callback: void on_activate() 27 | platform: ['macOS'] 28 | description: | 29 | Emitted when received `applicationShouldHandleReopen` notification and 30 | there is no visible windows. This usually happens when the app is 31 | activated by Finder, or user clicks on the dock icon. 32 | -------------------------------------------------------------------------------- /docs/paid_plans/ALTERNATIVE_LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Cheng Zhao 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /nativeui/win/util/scoped_ole_initializer.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "nativeui/win/util/scoped_ole_initializer.h" 6 | 7 | #include "base/logging.h" 8 | 9 | namespace nu { 10 | 11 | ScopedOleInitializer::ScopedOleInitializer() 12 | : 13 | #ifndef NDEBUG 14 | // Using the windows API directly to avoid dependency on platform_thread. 15 | thread_id_(GetCurrentThreadId()), 16 | #endif 17 | hr_(OleInitialize(NULL)) { 18 | #ifndef NDEBUG 19 | if (hr_ == S_FALSE) { 20 | LOG(ERROR) << "Multiple OleInitialize() calls for thread " << thread_id_; 21 | } else { 22 | DCHECK_NE(OLE_E_WRONGCOMPOBJ, hr_) << "Incompatible DLLs on machine"; 23 | DCHECK_NE(RPC_E_CHANGED_MODE, hr_) << "Invalid COM thread model change"; 24 | } 25 | #endif 26 | } 27 | 28 | ScopedOleInitializer::~ScopedOleInitializer() { 29 | #ifndef NDEBUG 30 | DCHECK_EQ(thread_id_, GetCurrentThreadId()); 31 | #endif 32 | if (SUCCEEDED(hr_)) 33 | OleUninitialize(); 34 | } 35 | 36 | } // namespace nu 37 | -------------------------------------------------------------------------------- /docs/api/image.yaml: -------------------------------------------------------------------------------- 1 | name: Image 2 | component: gui 3 | header: nativeui/gfx/image.h 4 | type: refcounted 5 | namespace: nu 6 | description: Native image. 7 | 8 | constructors: 9 | - signature: Image(const base::FilePath& path) 10 | lang: ['cpp'] 11 | description: &ref1 Create an image by reading from `path`. 12 | 13 | - signature: Image(const Buffer& buffer, float scale_factor) 14 | lang: ['cpp'] 15 | description: &ref2 | 16 | Create an image from `buffer` in memory, with `scale_factor`. 17 | 18 | class_methods: 19 | - signature: Image CreateFromPath(const base::FilePath& path) 20 | lang: ['lua', 'js'] 21 | description: *ref1 22 | 23 | - signature: Image CreateFromBuffer(const nu::Buffer& buffer, float scale_factor) 24 | lang: ['lua', 'js'] 25 | description: *ref2 26 | 27 | methods: 28 | - signature: SizeF GetSize() const 29 | description: Return image's size in DIP. 30 | 31 | - signature: float GetScaleFactor() const 32 | description: Return image's scale factor. 33 | 34 | - signature: NativeImage GetNative() const 35 | lang: ['cpp'] 36 | description: Return the native instance wrapped by the class. 37 | -------------------------------------------------------------------------------- /nativeui/gfx/win/double_buffer.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_GFX_WIN_DOUBLE_BUFFER_H_ 6 | #define NATIVEUI_GFX_WIN_DOUBLE_BUFFER_H_ 7 | 8 | #include "base/win/scoped_gdi_object.h" 9 | #include "base/win/scoped_hdc.h" 10 | #include "base/win/scoped_select_object.h" 11 | #include "nativeui/gfx/win/gdiplus.h" 12 | 13 | namespace nu { 14 | 15 | // Create a memory buffer for |dc| and copy the result back in destructor. 16 | class DoubleBuffer { 17 | public: 18 | DoubleBuffer(HDC dc, const Size& size, const Rect& src, const Point& dest); 19 | ~DoubleBuffer(); 20 | 21 | void SetNoCopy() { copy_on_destruction_ = false; } 22 | 23 | HDC dc() const { return mem_dc_.Get(); } 24 | 25 | private: 26 | HDC dc_; 27 | Rect src_; 28 | Point dest_; 29 | base::win::ScopedCreateDC mem_dc_; 30 | base::win::ScopedBitmap mem_bitmap_; 31 | base::win::ScopedSelectObject select_bitmap_; 32 | 33 | bool copy_on_destruction_ = true; 34 | }; 35 | 36 | } // namespace nu 37 | 38 | #endif // NATIVEUI_GFX_WIN_DOUBLE_BUFFER_H_ 39 | -------------------------------------------------------------------------------- /nativeui/menu_bar.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_MENU_BAR_H_ 6 | #define NATIVEUI_MENU_BAR_H_ 7 | 8 | #include "nativeui/accelerator_manager.h" 9 | #include "nativeui/menu_base.h" 10 | 11 | namespace nu { 12 | 13 | class Window; 14 | 15 | class NATIVEUI_EXPORT MenuBar : public MenuBase { 16 | public: 17 | MenuBar(); 18 | 19 | // View class name. 20 | static const char kClassName[]; 21 | 22 | // MenuBase: 23 | const char* GetClassName() const override; 24 | 25 | // Internal: Relationship with the window. 26 | void SetWindow(Window* window) { window_ = window; } 27 | Window* GetWindow() const { return window_; } 28 | 29 | // Internal: The AcceleratorManager managed by the MenuBar. 30 | AcceleratorManager* accel_manager() { return &accel_manager_; } 31 | 32 | private: 33 | ~MenuBar() override = default; 34 | 35 | NativeMenu PlatformCreate() const; 36 | 37 | Window* window_ = nullptr; 38 | AcceleratorManager accel_manager_; 39 | }; 40 | 41 | } // namespace nu 42 | 43 | #endif // NATIVEUI_MENU_BAR_H_ 44 | -------------------------------------------------------------------------------- /third_party/libxml/src/save.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Summary: Internal Interfaces for saving in libxml2 3 | * Description: this module describes a few interfaces which were 4 | * addded along with the API changes in 2.9.0 5 | * those are private routines at this point 6 | * 7 | * Copy: See Copyright for the status of this software. 8 | * 9 | * Author: Daniel Veillard 10 | */ 11 | 12 | #ifndef __XML_SAVE_H__ 13 | #define __XML_SAVE_H__ 14 | 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | #ifdef LIBXML_OUTPUT_ENABLED 22 | void xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc, 23 | xmlAttrPtr attr, const xmlChar * string); 24 | void xmlBufDumpNotationTable(xmlBufPtr buf, xmlNotationTablePtr table); 25 | void xmlBufDumpElementDecl(xmlBufPtr buf, xmlElementPtr elem); 26 | void xmlBufDumpAttributeDecl(xmlBufPtr buf, xmlAttributePtr attr); 27 | void xmlBufDumpEntityDecl(xmlBufPtr buf, xmlEntityPtr ent); 28 | xmlChar *xmlEncodeAttributeEntities(xmlDocPtr doc, const xmlChar *input); 29 | #endif 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | #endif /* __XML_SAVE_H__ */ 35 | 36 | -------------------------------------------------------------------------------- /nativeui/mac/tray_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/tray.h" 6 | 7 | #import 8 | 9 | #include "base/strings/sys_string_conversions.h" 10 | #include "nativeui/gfx/image.h" 11 | #include "nativeui/menu.h" 12 | 13 | namespace nu { 14 | 15 | Tray::Tray(Image* icon) 16 | : tray_([[[NSStatusBar systemStatusBar] 17 | statusItemWithLength:NSSquareStatusItemLength] retain]) { 18 | SetImage(icon); 19 | } 20 | 21 | Tray::Tray(const std::string& title) 22 | : tray_([[[NSStatusBar systemStatusBar] 23 | statusItemWithLength:NSVariableStatusItemLength] retain]) { 24 | SetTitle(title); 25 | } 26 | 27 | Tray::~Tray() { 28 | [tray_ release]; 29 | } 30 | 31 | void Tray::SetTitle(const std::string& title) { 32 | [tray_ setTitle:base::SysUTF8ToNSString(title)]; 33 | } 34 | 35 | void Tray::SetImage(Image* icon) { 36 | [tray_ setImage:icon->GetNative()]; 37 | } 38 | 39 | void Tray::SetMenu(Menu* menu) { 40 | menu_ = menu; 41 | [tray_ setMenu:menu->GetNative()]; 42 | } 43 | 44 | } // namespace nu 45 | -------------------------------------------------------------------------------- /nativeui/vibrant.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_VIBRANT_H_ 6 | #define NATIVEUI_VIBRANT_H_ 7 | 8 | #include "nativeui/container.h" 9 | 10 | namespace nu { 11 | 12 | class NATIVEUI_EXPORT Vibrant : public Container { 13 | public: 14 | Vibrant(); 15 | 16 | // Values here should match NSVisualEffectMaterial. 17 | enum class Material { 18 | AppearanceBased, 19 | Light, 20 | Dark, 21 | Titlebar, 22 | }; 23 | 24 | // Values here should match NSVisualEffectBlendingMode. 25 | enum class BlendingMode { 26 | BehindWindow, 27 | WithinWindow, 28 | }; 29 | 30 | // View class name. 31 | static const char kClassName[]; 32 | 33 | // View: 34 | const char* GetClassName() const override; 35 | 36 | void SetMaterial(Material material); 37 | Material GetMaterial() const; 38 | void SetBlendingMode(BlendingMode mode); 39 | BlendingMode GetBlendingMode() const; 40 | 41 | protected: 42 | ~Vibrant() override; 43 | 44 | void PlatformInit(); 45 | }; 46 | 47 | } // namespace nu 48 | 49 | #endif // NATIVEUI_VIBRANT_H_ 50 | -------------------------------------------------------------------------------- /docs/guides/lua/getting_started.md: -------------------------------------------------------------------------------- 1 | --- 2 | priority: 100 3 | description: How to use Yue with Lua. 4 | --- 5 | 6 | # Getting started 7 | 8 | Lua support in Yue is currently experimental, there are two modes provided: 9 | 10 | * A standalone runtime of Lua 5.3 that ships Yue as built-in module; 11 | * A loadable module built for Lua 5.3. 12 | 13 | They can be downloaded in the [Releases](https://github.com/yue/yue/releases) 14 | page, the standalone runtime is in the `yue_VERSION_PLATFORM_ARCH.zip` archive, 15 | the loadable module is in the `lua_yue_LUA-VERSION_VERSION_PLATFORM_ARCH.zip` 16 | archive. 17 | 18 | There are plans on making Yue available in LuaRocks. 19 | 20 | ## Using Yue 21 | 22 | Currently only the GUI part of Yue has been provided with Lua bindings, which 23 | can be loaded via `require('yue.gui')`. 24 | 25 | ```lua 26 | local gui = require('yue.gui') 27 | 28 | -- Create window and show it. 29 | local win = gui.Window.create{} 30 | win.onclose = function() gui.MessageLoop.quit() end 31 | win:setcontentview(gui.Label.create('Content View')) 32 | win:setcontentsize{width=400, height=400} 33 | win:center() 34 | win:activate() 35 | 36 | -- Enter message loop. 37 | gui.MessageLoop.run() 38 | ``` 39 | -------------------------------------------------------------------------------- /node_yue/binding_values.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "node_yue/binding_values.h" 6 | 7 | #include 8 | #include 9 | 10 | #include "node_yue/v8_value_converter.h" 11 | 12 | namespace vb { 13 | 14 | using node_yue::V8ValueConverter; 15 | 16 | // static 17 | v8::Local Type::ToV8(v8::Local context, 18 | const base::Value& value) { 19 | std::unique_ptr converter = V8ValueConverter::Create(); 20 | return converter->ToV8Value(&value, context); 21 | } 22 | 23 | // statc 24 | bool Type::FromV8(v8::Local context, 25 | v8::Local value, 26 | base::Value* out) { 27 | std::unique_ptr converter = V8ValueConverter::Create(); 28 | std::unique_ptr result = converter->FromV8Value(value, context); 29 | if (!result) 30 | return false; 31 | *out = std::move(*result.release()); 32 | return true; 33 | } 34 | 35 | } // namespace vb 36 | -------------------------------------------------------------------------------- /nativeui/win/focus_manager.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_FOCUS_MANAGER_H_ 6 | #define NATIVEUI_WIN_FOCUS_MANAGER_H_ 7 | 8 | #include "base/macros.h" 9 | #include "nativeui/nativeui_export.h" 10 | 11 | namespace nu { 12 | 13 | class ViewImpl; 14 | class ContainerImpl; 15 | 16 | // Moves focus between views. 17 | class FocusManager { 18 | public: 19 | FocusManager(); 20 | ~FocusManager(); 21 | 22 | // A view has taken the focus by clicking. 23 | void TakeFocus(ViewImpl* view); 24 | 25 | // Advances the focus inside a view (backward if reverse is true). 26 | // Returns whether a view has been focused. 27 | void AdvanceFocus(ViewImpl* view, bool reverse); 28 | 29 | ViewImpl* focused_view() const { return focused_view_; } 30 | 31 | private: 32 | bool DoAdvanceFocus(ContainerImpl* container, bool reverse, 33 | bool* focus_on_next_view); 34 | 35 | ViewImpl* focused_view_ = nullptr; 36 | 37 | DISALLOW_COPY_AND_ASSIGN(FocusManager); 38 | }; 39 | 40 | } // namespace nu 41 | 42 | #endif // NATIVEUI_WIN_FOCUS_MANAGER_H_ 43 | -------------------------------------------------------------------------------- /nativeui/gfx/win/canvas_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/gfx/canvas.h" 6 | 7 | #include "nativeui/gfx/win/painter_win.h" 8 | 9 | namespace nu { 10 | 11 | namespace { 12 | 13 | const float kDefaultDPI = 96.f; 14 | 15 | } // namespace 16 | 17 | // static 18 | NativeBitmap Canvas::PlatformCreateBitmap(const SizeF& size, 19 | float scale_factor) { 20 | NativeBitmap bitmap = new Gdiplus::Bitmap(size.width() * scale_factor, 21 | size.height() * scale_factor, 22 | PixelFormat32bppARGB); 23 | float dpi = kDefaultDPI * scale_factor; 24 | bitmap->SetResolution(dpi, dpi); 25 | return bitmap; 26 | } 27 | 28 | // static 29 | void Canvas::PlatformDestroyBitmap(NativeBitmap bitmap) { 30 | delete bitmap; 31 | } 32 | 33 | // static 34 | Painter* Canvas::PlatformCreatePainter(NativeBitmap bitmap, 35 | float scale_factor) { 36 | return new PainterWin(bitmap, scale_factor); 37 | } 38 | 39 | } // namespace nu 40 | -------------------------------------------------------------------------------- /node_yue/chrome_view_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "node_yue/chrome_view_mac.h" 6 | 7 | #include 8 | 9 | namespace node_yue { 10 | 11 | // static 12 | const char ChromeView::kClassName[] = "ChromeView"; 13 | 14 | ChromeView::ChromeView(v8::Local buf) { 15 | if (node::Buffer::HasInstance(buf) && 16 | node::Buffer::Length(buf) == sizeof(NSView*)) { 17 | NSView* view = *reinterpret_cast(node::Buffer::Data(buf)); 18 | TakeOverView(view); 19 | } else { 20 | // Show a warning text as fallback. 21 | scoped_refptr label(new nu::Label("Invalid WebContentsView")); 22 | label->SetColor(nu::Color(255, 255, 255)); 23 | label->SetBackgroundColor(nu::Color(255, 0, 0)); 24 | // Retain the view form nu::Label and use it as ChromeView. 25 | NSView* view = label->GetNative(); 26 | [view retain]; 27 | TakeOverView(view); 28 | } 29 | } 30 | 31 | ChromeView::~ChromeView() { 32 | } 33 | 34 | const char* ChromeView::GetClassName() const { 35 | return kClassName; 36 | } 37 | 38 | } // namespace node_yue 39 | -------------------------------------------------------------------------------- /nativeui/group.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_GROUP_H_ 6 | #define NATIVEUI_GROUP_H_ 7 | 8 | #include 9 | 10 | #include "nativeui/view.h" 11 | 12 | namespace nu { 13 | 14 | class NATIVEUI_EXPORT Group : public View { 15 | public: 16 | explicit Group(const std::string& title); 17 | 18 | // View class name. 19 | static const char kClassName[]; 20 | 21 | // View: 22 | const char* GetClassName() const override; 23 | SizeF GetMinimumSize() const override; 24 | 25 | void SetContentView(View* view); 26 | View* GetContentView() const; 27 | 28 | void SetTitle(const std::string& title); 29 | std::string GetTitle() const; 30 | 31 | protected: 32 | ~Group() override; 33 | 34 | // Get the spaces taken by the border of group. 35 | SizeF GetBorderSize() const; 36 | 37 | // Following platform implementations should only be called by wrappers. 38 | void PlatformInit(); 39 | void PlatformSetContentView(View* container); 40 | 41 | private: 42 | scoped_refptr content_view_; 43 | }; 44 | 45 | } // namespace nu 46 | 47 | #endif // NATIVEUI_GROUP_H_ 48 | -------------------------------------------------------------------------------- /lua/ref_method.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "lua/ref_method.h" 6 | 7 | namespace lua { 8 | 9 | namespace internal { 10 | 11 | void StoreArg(State* state, int arg, RefType ref_type, const char* ref_key) { 12 | // DO NOT USE ANY C++ STACK BEFORE THE UNSAFE CALLS. 13 | CHECK_EQ(GetType(state, 1), LuaType::UserData); 14 | // this.__yuerefs ?= {} 15 | PushRefsTable(state, "__yuerefs", 1); 16 | // if (reftype == "ref") 17 | // this.__yuerefs[arg] = true 18 | // else if (reftype == "deref") 19 | // this.__yuerefs[arg] = nil 20 | // else if (reftype == "reset") 21 | // this.__yuerefs[key] = arg 22 | switch (ref_type) { 23 | case RefType::Ref: 24 | RawSet(state, -1, ValueOnStack(state, arg), 1); 25 | break; 26 | case RefType::Deref: 27 | RawSet(state, -1, ValueOnStack(state, arg), nullptr); 28 | break; 29 | case RefType::Reset: 30 | RawSet(state, -1, ref_key, ValueOnStack(state, arg)); 31 | break; 32 | } 33 | // Cleanup stack. 34 | PopAndIgnore(state, 1); 35 | } 36 | 37 | } // namespace internal 38 | 39 | } // namespace lua 40 | -------------------------------------------------------------------------------- /nativeui/gtk/file_open_dialog_gtk.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Copyright 2014 GitHub, Inc. 3 | // Use of this source code is governed by the license that can be found in the 4 | // LICENSE file. 5 | 6 | #include "nativeui/file_open_dialog.h" 7 | 8 | #include 9 | 10 | namespace nu { 11 | 12 | FileOpenDialog::FileOpenDialog() 13 | : FileDialog(GTK_FILE_CHOOSER(gtk_file_chooser_dialog_new( 14 | nullptr, nullptr, 15 | GTK_FILE_CHOOSER_ACTION_OPEN, 16 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 17 | GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, 18 | nullptr))) { 19 | } 20 | 21 | FileOpenDialog::~FileOpenDialog() { 22 | } 23 | 24 | std::vector FileOpenDialog::GetResults() const { 25 | std::vector results; 26 | GSList* filenames = gtk_file_chooser_get_filenames(GetNative()); 27 | for (GSList* iter = filenames; iter; iter = g_slist_next(iter)) { 28 | auto path = AddExtensionForFilename(static_cast(iter->data)); 29 | g_free(iter->data); 30 | results.push_back(path); 31 | } 32 | g_slist_free(filenames); 33 | return results; 34 | } 35 | 36 | } // namespace nu 37 | -------------------------------------------------------------------------------- /nativeui/mac/nu_private.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_MAC_NU_PRIVATE_H_ 6 | #define NATIVEUI_MAC_NU_PRIVATE_H_ 7 | 8 | #include 9 | 10 | #include "base/mac/scoped_nsobject.h" 11 | 12 | @class NSTrackingArea; 13 | 14 | namespace nu { 15 | 16 | class MouseCapture; 17 | class View; 18 | 19 | // A private class that holds nativeui specific private data. 20 | // Object-C does not support multi-inheiritance, so it is impossible to add 21 | // common data members for UI elements. Our workaround is to manually add 22 | // this class as member for each view. 23 | struct NUPrivate { 24 | NUPrivate(); 25 | ~NUPrivate(); 26 | 27 | View* shell = nullptr; 28 | bool focusable = true; 29 | bool draggable = false; 30 | bool hovered = false; 31 | bool is_content_view = false; 32 | bool wants_layer = false; // default value for wantsLayer 33 | bool wants_layer_infected = false; // infects the wantsLayer property 34 | base::scoped_nsobject tracking_area; 35 | std::unique_ptr mouse_capture; 36 | }; 37 | 38 | } // namespace nu 39 | 40 | #endif // NATIVEUI_MAC_NU_PRIVATE_H_ 41 | -------------------------------------------------------------------------------- /v8binding/dict.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "v8binding/dict.h" 6 | 7 | #include "base/strings/string_number_conversions.h" 8 | 9 | namespace vb { 10 | 11 | v8::Local GetAttachedTable(v8::Local context, 12 | v8::Local object, 13 | const base::StringPiece& key_str) { 14 | v8::Isolate* isolate = context->GetIsolate(); 15 | auto key = v8::Private::ForApi(isolate, 16 | ToV8(context, key_str).As()); 17 | if (!object->HasPrivate(context, key).ToChecked()) 18 | object->SetPrivate(context, key, v8::Map::New(isolate)); 19 | return v8::Local::Cast( 20 | object->GetPrivate(context, key).ToLocalChecked()); 21 | } 22 | 23 | v8::Local GetAttachedTable(v8::Local context, 24 | v8::Local object, 25 | void* key) { 26 | return GetAttachedTable(context, object, 27 | base::HexEncode(&key, sizeof(void*))); 28 | } 29 | 30 | } // namespace vb 31 | -------------------------------------------------------------------------------- /docs/layout/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | -ms-text-size-adjust: 100%; 4 | -webkit-text-size-adjust: 100%; 5 | 6 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; 7 | font-size: 14px; 8 | word-wrap: break-word; 9 | line-height: 1.5; 10 | color: #24292e; 11 | } 12 | 13 | a { 14 | color: #0366d6; 15 | text-decoration: none; 16 | } 17 | 18 | a:hover { 19 | text-decoration: underline; 20 | } 21 | 22 | .markdown-body { 23 | padding: 45px; 24 | } 25 | 26 | #header { 27 | width: 100%; 28 | height: 50px; 29 | line-height: 50px; 30 | background-color: #3b73d4; 31 | } 32 | 33 | #header .logo { 34 | font-weight: 700; 35 | font-size: 30px; 36 | color: white; 37 | display: inline-block; 38 | padding-left: 45px; 39 | padding-right: 45px; 40 | margin: 0; 41 | } 42 | 43 | #header .nav { 44 | position: absolute; 45 | right: 45px; 46 | top: 0; 47 | } 48 | 49 | #header .nav a { 50 | margin-left: 30px; 51 | color: white; 52 | } 53 | 54 | #footer { 55 | height: 30px; 56 | width: 100%; 57 | background-color: #3b73d4; 58 | } 59 | 60 | #footer p { 61 | padding-left: 45px; 62 | line-height: 30px; 63 | color: white; 64 | } 65 | -------------------------------------------------------------------------------- /docs/api/entry.yaml: -------------------------------------------------------------------------------- 1 | name: Entry 2 | component: gui 3 | header: nativeui/entry.h 4 | type: refcounted 5 | namespace: nu 6 | inherit: View 7 | description: Single-line text input view. 8 | 9 | constructors: 10 | - signature: Entry(Entry::Type type) 11 | lang: ['cpp'] 12 | description: Create a new `Entry` with `type`. 13 | detail: By default `type` is `Normal`. 14 | 15 | class_methods: 16 | - signature: Entry* Create() 17 | lang: ['lua', 'js'] 18 | description: Create a normal `Entry`. 19 | 20 | - signature: Entry* CreateType(Entry::Type type) 21 | lang: ['lua', 'js'] 22 | description: Create an `Entry` with `type`. 23 | 24 | class_properties: 25 | - property: const char* kClassName 26 | lang: ['cpp'] 27 | description: The class name of this view. 28 | 29 | methods: 30 | - signature: void SetText(const std::string& text) 31 | description: Change the text in the view. 32 | 33 | - signature: std::string GetText() const 34 | description: Return currently displayed text. 35 | 36 | events: 37 | - callback: void on_text_change(Entry* self) 38 | description: Emitted when user has changed text. 39 | 40 | - callback: void on_activate(Entry* self) 41 | description: Emitted when user has pressed Enter in the view. 42 | -------------------------------------------------------------------------------- /nativeui/win/util/subwin_holder.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_UTIL_SUBWIN_HOLDER_H_ 6 | #define NATIVEUI_WIN_UTIL_SUBWIN_HOLDER_H_ 7 | 8 | #include "nativeui/win/util/win32_window.h" 9 | 10 | namespace nu { 11 | 12 | // Windows does not allow a child window to created without a parent, so this 13 | // window becomes the temporary parent for the SubwinView childs that are not 14 | // added to any parent yet. 15 | class SubwinHolder : public Win32Window { 16 | public: 17 | SubwinHolder(); 18 | ~SubwinHolder() override; 19 | 20 | protected: 21 | CR_BEGIN_MSG_MAP_EX(SubwinHolder, Win32Window) 22 | CR_MSG_WM_COMMAND(OnCommand) 23 | CR_MSG_WM_NOTIFY(OnNotify) 24 | CR_END_MSG_MAP() 25 | 26 | // Some controls cache their parents, so after we reparent some controls to 27 | // a new window, they would still send WM_COMMAND messages to this holder. 28 | // We need to redirect the messages just like the toplevel window. 29 | void OnCommand(UINT code, int command, HWND window); 30 | LRESULT OnNotify(int id, LPNMHDR pnmh); 31 | }; 32 | 33 | } // namespace nu 34 | 35 | #endif // NATIVEUI_WIN_UTIL_SUBWIN_HOLDER_H_ 36 | -------------------------------------------------------------------------------- /nativeui/mac/group_mac.mm: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/group.h" 6 | 7 | #import 8 | 9 | #include "base/strings/sys_string_conversions.h" 10 | 11 | namespace nu { 12 | 13 | void Group::PlatformInit() { 14 | // Give the box an initial size to calculate border size. 15 | NSBox* group = [[NSBox alloc] init]; 16 | [group setContentViewMargins:NSZeroSize]; 17 | [group sizeToFit]; 18 | TakeOverView(group); 19 | } 20 | 21 | void Group::PlatformSetContentView(View* view) { 22 | [static_cast(GetNative()) setContentView:view->GetNative()]; 23 | view->Layout(); 24 | } 25 | 26 | void Group::SetTitle(const std::string& title) { 27 | static_cast(GetNative()).title = base::SysUTF8ToNSString(title); 28 | } 29 | 30 | std::string Group::GetTitle() const { 31 | return base::SysNSStringToUTF8(static_cast(GetNative()).title); 32 | } 33 | 34 | SizeF Group::GetBorderSize() const { 35 | NSSize outer = [GetNative() frame].size; 36 | NSSize inner = [GetContentView()->GetNative() frame].size; 37 | return SizeF(outer.width - inner.width, outer.height - inner.height); 38 | } 39 | 40 | } // namespace nu 41 | -------------------------------------------------------------------------------- /nativeui/win/scrollbar/scrollbar_thumb.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_SCROLLBAR_SCROLLBAR_THUMB_H_ 6 | #define NATIVEUI_WIN_SCROLLBAR_SCROLLBAR_THUMB_H_ 7 | 8 | #include "nativeui/gfx/win/native_theme.h" 9 | #include "nativeui/win/clickable.h" 10 | 11 | namespace nu { 12 | 13 | class Scrollbar; 14 | 15 | class ScrollbarThumb : public Clickable { 16 | public: 17 | ScrollbarThumb(bool vertical, Scrollbar* scrollbar); 18 | ~ScrollbarThumb() override; 19 | 20 | int GetSize() const; 21 | 22 | // ViewImpl: 23 | void OnMouseMove(NativeEvent event) override; 24 | bool OnMouseClick(NativeEvent event) override; 25 | void Draw(PainterWin* painter, const Rect& dirty) override; 26 | 27 | NativeTheme::ScrollbarThumbExtraParams* params() { return ¶ms_; } 28 | 29 | private: 30 | NativeTheme::ScrollbarThumbExtraParams params_ = {0}; 31 | 32 | bool is_hovering_ = false; 33 | bool is_capturing_ = false; 34 | 35 | Point pressed_point_; 36 | int last_value_ = 0; 37 | 38 | bool vertical_; 39 | Scrollbar* scrollbar_; // weak ref 40 | }; 41 | 42 | } // namespace nu 43 | 44 | #endif // NATIVEUI_WIN_SCROLLBAR_SCROLLBAR_THUMB_H_ 45 | -------------------------------------------------------------------------------- /node_yue/node_integration_mac.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 GitHub, Inc. 2 | // Copyright 2017 Cheng Zhao. All rights reserved. 3 | // Use of this source code is governed by the license that can be found in the 4 | // LICENSE file. 5 | 6 | #include "node_yue/node_integration_mac.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace node_yue { 15 | 16 | NodeIntegrationMac::NodeIntegrationMac() { 17 | } 18 | 19 | NodeIntegrationMac::~NodeIntegrationMac() { 20 | } 21 | 22 | void NodeIntegrationMac::PollEvents() { 23 | struct timeval tv; 24 | int timeout = uv_backend_timeout(uv_loop_); 25 | if (timeout != -1) { 26 | tv.tv_sec = timeout / 1000; 27 | tv.tv_usec = (timeout % 1000) * 1000; 28 | } 29 | 30 | fd_set readset; 31 | int fd = uv_backend_fd(uv_loop_); 32 | FD_ZERO(&readset); 33 | FD_SET(fd, &readset); 34 | 35 | // Wait for new libuv events. 36 | int r; 37 | do { 38 | r = select(fd + 1, &readset, nullptr, nullptr, 39 | timeout == -1 ? nullptr : &tv); 40 | } while (r == -1 && errno == EINTR); 41 | } 42 | 43 | // static 44 | NodeIntegration* NodeIntegration::Create() { 45 | return new NodeIntegrationMac(); 46 | } 47 | 48 | } // namespace node_yue 49 | -------------------------------------------------------------------------------- /nativeui/gfx/geometry/point_f.cc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #include "nativeui/gfx/geometry/point_f.h" 6 | 7 | #if defined(OS_IOS) 8 | #include 9 | #elif defined(OS_MACOSX) 10 | #include 11 | #endif 12 | 13 | #include "base/strings/stringprintf.h" 14 | 15 | namespace nu { 16 | 17 | #if defined(OS_MACOSX) 18 | PointF::PointF(const CGPoint& r) : x_(r.x), y_(r.y) { 19 | } 20 | 21 | CGPoint PointF::ToCGPoint() const { 22 | return CGPointMake(x(), y()); 23 | } 24 | #endif 25 | 26 | void PointF::SetToMin(const PointF& other) { 27 | x_ = x_ <= other.x_ ? x_ : other.x_; 28 | y_ = y_ <= other.y_ ? y_ : other.y_; 29 | } 30 | 31 | void PointF::SetToMax(const PointF& other) { 32 | x_ = x_ >= other.x_ ? x_ : other.x_; 33 | y_ = y_ >= other.y_ ? y_ : other.y_; 34 | } 35 | 36 | std::string PointF::ToString() const { 37 | return base::StringPrintf("%f,%f", x(), y()); 38 | } 39 | 40 | PointF ScalePoint(const PointF& p, float x_scale, float y_scale) { 41 | PointF scaled_p(p); 42 | scaled_p.Scale(x_scale, y_scale); 43 | return scaled_p; 44 | } 45 | 46 | 47 | } // namespace nu 48 | -------------------------------------------------------------------------------- /nativeui/mac/nu_view.h: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_MAC_NU_VIEW_H_ 6 | #define NATIVEUI_MAC_NU_VIEW_H_ 7 | 8 | #import 9 | 10 | #include "nativeui/gfx/color.h" 11 | 12 | namespace nu { 13 | class Font; 14 | class View; 15 | struct NUPrivate; 16 | } 17 | 18 | // The methods that every View should implemented. 19 | @protocol NUView 20 | - (nu::NUPrivate*)nuPrivate; 21 | - (void)setNUFont:(nu::Font*)font; 22 | - (void)setNUColor:(nu::Color)color; 23 | - (void)setNUBackgroundColor:(nu::Color)color; 24 | - (void)setNUEnabled:(BOOL)enabled; 25 | - (BOOL)isNUEnabled; 26 | @end 27 | 28 | // Extended methods of NUView. 29 | @interface NSView (NUViewMethods) 30 | - (nu::View*)shell; 31 | - (void)enableTracking; 32 | - (void)disableTracking; 33 | @end 34 | 35 | namespace nu { 36 | 37 | // Return whether a class is part of nativeui system. 38 | bool IsNUView(id view); 39 | 40 | // Return whether a class has been installed with custom methods. 41 | bool NUViewMethodsInstalled(Class cl); 42 | 43 | // Add custom view methods to class. 44 | void InstallNUViewMethods(Class cl); 45 | 46 | } // namespace nu 47 | 48 | #endif // NATIVEUI_MAC_NU_VIEW_H_ 49 | -------------------------------------------------------------------------------- /nativeui/gtk/nu_container.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_GTK_NU_CONTAINER_H_ 6 | #define NATIVEUI_GTK_NU_CONTAINER_H_ 7 | 8 | #include 9 | 10 | // Custom GTK container type for nu::Container. 11 | 12 | namespace nu { 13 | 14 | class Container; 15 | 16 | #define NU_TYPE_CONTAINER (nu_container_get_type()) 17 | #define NU_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \ 18 | NU_TYPE_CONTAINER, NUContainer)) 19 | #define NU_IS_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ 20 | NU_TYPE_CONTAINER)) 21 | 22 | typedef struct _NUContainer NUContainer; 23 | typedef struct _NUContainerPrivate NUContainerPrivate; 24 | typedef struct _NUContainerClass NUContainerClass; 25 | 26 | struct _NUContainer { 27 | GtkContainer container; 28 | NUContainerPrivate* priv; 29 | }; 30 | 31 | struct _NUContainerClass { 32 | GtkContainerClass parent_class; 33 | }; 34 | 35 | GType nu_container_get_type(); 36 | GtkWidget* nu_container_new(Container* delegate); 37 | GdkWindow* nu_container_get_window(NUContainer* widget); 38 | 39 | } // namespace nu 40 | 41 | #endif // NATIVEUI_GTK_NU_CONTAINER_H_ 42 | -------------------------------------------------------------------------------- /third_party/libxml/src/xml2-config.1: -------------------------------------------------------------------------------- 1 | .TH GNOME-XML 1 "3 July 1999" Version 1.1.0 2 | .SH NAME 3 | xml-config - script to get information about the installed version of GNOME-XML 4 | .SH SYNOPSIS 5 | .B xml-config 6 | [\-\-prefix\fI[=DIR]\fP] [\-\-libs] [\-\-cflags] [\-\-version] [\-\-help] 7 | .SH DESCRIPTION 8 | \fIxml-config\fP is a tool that is used to determine the compile and 9 | linker flags that should be used to compile and link programs that use 10 | \fIGNOME-XML\fP. 11 | .SH OPTIONS 12 | \fIxml-config\fP accepts the following options: 13 | .TP 8 14 | .B \-\-version 15 | Print the currently installed version of \fIGNOME-XML\fP on the standard output. 16 | .TP 8 17 | .B \-\-libs 18 | Print the linker flags that are necessary to link a \fIGNOME-XML\fP program. 19 | .TP 8 20 | .B \-\-cflags 21 | Print the compiler flags that are necessary to compile a \fIGNOME-XML\fP program. 22 | .TP 8 23 | .B \-\-prefix=PREFIX 24 | If specified, use PREFIX instead of the installation prefix that 25 | \fIGNOME-XML\fP was built with when computing the output for the 26 | \-\-cflags and \-\-libs options. This option must be specified before 27 | any \-\-libs or \-\-cflags options. 28 | .SH AUTHOR 29 | This manual page was written by Fredrik Hallenberg , 30 | for the Debian GNU/linux system (but may be used by others). 31 | -------------------------------------------------------------------------------- /nativeui/win/scrollbar/repeat_controller.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_SCROLLBAR_REPEAT_CONTROLLER_H_ 6 | #define NATIVEUI_WIN_SCROLLBAR_REPEAT_CONTROLLER_H_ 7 | 8 | #include 9 | 10 | #include "base/macros.h" 11 | #include "base/memory/weak_ptr.h" 12 | 13 | namespace nu { 14 | 15 | // An object that handles auto-repeating UI actions. There is a longer initial 16 | // delay after which point repeats become constant. Users provide a callback 17 | // that is notified when each repeat occurs so that they can perform the 18 | // associated action. 19 | class RepeatController { 20 | public: 21 | explicit RepeatController(const std::function& callback); 22 | virtual ~RepeatController(); 23 | 24 | // Start repeating. 25 | void Start(); 26 | 27 | // Stop repeating. 28 | void Stop(); 29 | 30 | private: 31 | // Called when the timer expires. 32 | void Run(); 33 | 34 | bool running_; 35 | std::function callback_; 36 | 37 | base::WeakPtrFactory weak_factory_; 38 | 39 | DISALLOW_COPY_AND_ASSIGN(RepeatController); 40 | }; 41 | 42 | } // namespace nu 43 | 44 | #endif // NATIVEUI_WIN_SCROLLBAR_REPEAT_CONTROLLER_H_ 45 | -------------------------------------------------------------------------------- /docs/layout/api.css: -------------------------------------------------------------------------------- 1 | .markdown-body h3 { 2 | color: #e86850; 3 | } 4 | 5 | .markdown-body h4 { 6 | color: #587498; 7 | } 8 | 9 | .markdown-body a.type { 10 | color: #587058; 11 | } 12 | 13 | .markdown-body span.type { 14 | color: #24292e; 15 | } 16 | 17 | .markdown-body .code { 18 | font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; 19 | } 20 | 21 | .markdown-body .platform { 22 | padding: .1em .4em; 23 | font-size: .88em; 24 | font-weight: 300; 25 | border-radius: 3px; 26 | color: white; 27 | background-color: #ee9584 28 | } 29 | 30 | #container { 31 | display: flex; 32 | flex-direction: row; 33 | } 34 | 35 | #content { 36 | flex-grow: 1; 37 | } 38 | 39 | #sidebar { 40 | padding-left: 0; 41 | } 42 | 43 | #sidebar ul { 44 | padding: 0; 45 | list-style-type: none; 46 | } 47 | 48 | #sidebar .current { 49 | font-weight: 500; 50 | } 51 | 52 | #sidebar .disabled { 53 | color: #d3d4d5; 54 | } 55 | 56 | #sidebar .lang-switcher { 57 | white-space: nowrap; 58 | } 59 | 60 | #index { 61 | display: flex; 62 | flex-direction: row; 63 | } 64 | 65 | #index .column { 66 | flex: 1; 67 | padding-right: 45px; 68 | } 69 | 70 | #index>.column:last-child { 71 | padding-right: 0; 72 | } 73 | 74 | #index ul { 75 | padding: 0; 76 | list-style-type: none; 77 | } 78 | -------------------------------------------------------------------------------- /docs/layout/index.pug: -------------------------------------------------------------------------------- 1 | extends page.pug 2 | 3 | //- Display a link with chosen state. 4 | mixin switch(text, href, chosen) 5 | if chosen 6 | span.current #{text} 7 | else 8 | a(href=href) #{text} 9 | 10 | mixin item(dir, node) 11 | li 12 | h3 13 | a(href=`${dir}/${node.id}.html`) #{node.name} 14 | if node.description 15 | != ' ' + imarkdown(node.description) 16 | 17 | mixin items(filter) 18 | ul 19 | each type in types 20 | if type.component == filter 21 | +item('api', type) 22 | 23 | block content 24 | h1 Docs Index 25 | #index 26 | .column 27 | h2 Guides 28 | ul 29 | each guide in guides 30 | +item('guides', guide) 31 | 32 | .column 33 | h2 Components 34 | +items('gui') 35 | 36 | .column 37 | h2 Structures 38 | +items() 39 | 40 | block sidebar 41 | h4 Langauge: 42 | .lang-switcher 43 | +switch('C++', `../cpp/index.html`, lang == 'cpp', 44 | !doc.lang || doc.lang.includes('cpp')) 45 | | | 46 | +switch('Lua', `../lua/index.html`, lang == 'lua', 47 | !doc.lang || doc.lang.includes('lua')) 48 | | | 49 | +switch('JavaScript', `../js/index.html`, lang == 'js', 50 | !doc.lang || doc.lang.includes('js')) 51 | 52 | h4 Version: 53 | span.current #{version} 54 | -------------------------------------------------------------------------------- /nativeui/win/browser/browser_protocol_factory.h: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_WIN_BROWSER_BROWSER_PROTOCOL_FACTORY_H_ 6 | #define NATIVEUI_WIN_BROWSER_BROWSER_PROTOCOL_FACTORY_H_ 7 | 8 | #include 9 | 10 | #include "nativeui/browser.h" 11 | 12 | namespace nu { 13 | 14 | class BrowserProtocolFactory : public IClassFactory { 15 | public: 16 | static const GUID CLSID_BROWSER_PROTOCOL; 17 | 18 | explicit BrowserProtocolFactory(const Browser::ProtocolHandler& handler); 19 | ~BrowserProtocolFactory(); 20 | 21 | // IUnknown 22 | STDMETHOD(QueryInterface)(REFIID riid, void **ppvObject); 23 | STDMETHOD_(ULONG, AddRef)(); 24 | STDMETHOD_(ULONG, Release)(); 25 | 26 | // IClassFactory 27 | HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown *pUnkOuter, 28 | REFIID riid, 29 | void **ppvObject); 30 | HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock); 31 | 32 | private: 33 | ULONG ref_; 34 | Browser::ProtocolHandler handler_; 35 | 36 | DISALLOW_COPY_AND_ASSIGN(BrowserProtocolFactory); 37 | }; 38 | 39 | } // namespace nu 40 | 41 | #endif // NATIVEUI_WIN_BROWSER_BROWSER_PROTOCOL_FACTORY_H_ 42 | -------------------------------------------------------------------------------- /scripts/download_lua_libs.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // Copyright 2018 Cheng Zhao. All rights reserved. 4 | // Use of this source code is governed by the license that can be found in the 5 | // LICENSE file. 6 | 7 | const {argv, download, mkdir} = require('./common') 8 | 9 | const fs = require('fs') 10 | const path = require('path') 11 | const extract = require('./libs/extract-zip') 12 | 13 | if (argv.length != 2) { 14 | console.error('Usage: download_lua_libs version cpu') 15 | process.exit(1) 16 | } 17 | 18 | const version = argv[0] 19 | const targetCpu = argv[1] 20 | 21 | const arch = targetCpu == 'x64' ? 'Win64' : 'Win32' 22 | const lua_dir = path.resolve('third_party', `lua_binaries_${version}_${arch}`) 23 | if (fs.existsSync(lua_dir)) { 24 | process.exit(0) 25 | } 26 | 27 | const mirror = 'https://jaist.dl.sourceforge.net/project/luabinaries' 28 | const folder = 'Windows%20Libraries/Static' 29 | const zipname = `lua-${version}_${arch}_vc14_lib.zip` 30 | const url = `${mirror}/${version}/${folder}/${zipname}` 31 | 32 | download(url, (response) => { 33 | mkdir(lua_dir) 34 | const zippath = path.join(lua_dir, zipname) 35 | response.on('end', () => { 36 | extract(zippath, {dir: lua_dir}, (error) => { 37 | fs.unlinkSync(zippath) 38 | }) 39 | }) 40 | response.pipe(fs.createWriteStream(zippath)) 41 | }) 42 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | git: 2 | depth: 10 3 | notifications: 4 | email: false 5 | 6 | language: node_js 7 | node_js: 8 | - 8.2.1 9 | os: 10 | - osx 11 | osx_image: xcode8.3 12 | 13 | env: 14 | - TARGET_CPU=x64 15 | 16 | before_script: 17 | - export YUE_VERSION=$(git describe --always --tags) 18 | 19 | script: 20 | - node ./scripts/cibuild.js --target-cpu=$TARGET_CPU 21 | 22 | deploy: 23 | provider: releases 24 | api_key: 25 | secure: h2blB/R3MEtyB/ZdG6Z+kGduvBhPDmw4/tAweVVI/XfyI9kVa0clo497OUM6MUhFXP48CfNrj+5VVpLIryCQYObJ8raM47EPkTCYc/ikfICiNX6i7jIrPOM4otj4BshyAjPRYih20qXzxOMgT/e14UlPPY3t0rCYf0tmCkYoFO8ZjjG0h/JJe1TsVkNwV3MXCqFlRbFrnUeLGC/P9+cMlw8g5h67lEEWauazd1IVUAGKQrU7zw5IBwdoNFIIe1Z+3d9FcbpPeFwx8hxkLfP8/aysVDnTfg0H6bIDXsqpoAzGH3GBc1Tr67qgKgsgU8BP5iv2W03ZkHcfqKmwiDcHv2R1mOb199O19EuE2jb93R6dX4KrmkgRS/HQVcyyAdcYJ3nolwTgLwDtoXPGTBXunAoTWY6ZNf03nqSdHeN77HvKK2KkLt75+5ITh3KKnq7dbuiNbAG4gWWAtWh4CqpipOXqb0JUppwU5cA82vNAVeQPWhTg1YQu2ODNOzDpblyPurG1wvw9o1I62EW6QCxsmrfVPvMcrxIWv/wx37hbKxq+ptVwACmPOSpZIci8Azl2a3txy9EPYkSg+a+cYvuhsAyTOKCy2reuGoF16HaK9kfo/4obWdyKfHQObIgeAmT/3UQhc+d+GK1+1AMnysyDtaEJ14seHu4HdZQ/tdrK37k= 26 | file_glob: true 27 | file: out/Dist/*.zip 28 | skip_cleanup: true 29 | overwrite: true 30 | draft: true 31 | tag_name: ${YUE_VERSION} 32 | name: Yue ${YUE_VERSION} 33 | body: (placeholder) 34 | on: 35 | tags: true 36 | -------------------------------------------------------------------------------- /docs/api/canvas.yaml: -------------------------------------------------------------------------------- 1 | name: Canvas 2 | component: gui 3 | header: nativeui/gfx/canvas.h 4 | type: refcounted 5 | namespace: nu 6 | description: Offscreen drawing. 7 | 8 | constructors: 9 | - signature: Canvas(const SizeF& size, float scale_factor) 10 | lang: ['cpp'] 11 | description: &ref1 | 12 | Create a new canvas with specified size and scale factor. 13 | 14 | - signature: Canvas(const SizeF& size) 15 | lang: ['cpp'] 16 | description: &ref2 | 17 | Create a new canvas with `size` using default scale factor. 18 | 19 | This is strongly discouraged for using, since it does not work well with 20 | multi-monitor setup. Only use it when you do not care about per-monitor 21 | DPI. 22 | 23 | class_methods: 24 | - signature: Canvas* Create(const SizeF& size, float scale_factor) 25 | lang: ['lua', 'js'] 26 | description: *ref1 27 | 28 | - signature: Canvas* CreateForMainScreen(const SizeF& size) 29 | lang: ['lua', 'js'] 30 | description: *ref2 31 | 32 | methods: 33 | - signature: float GetScaleFactor() const 34 | description: Return the scale factor of the canvas. 35 | 36 | - signature: Painter* GetPainter() 37 | description: Return the Painter that can be used to draw on the canvas. 38 | 39 | - signature: SizeF GetSize() const 40 | description: Return the DIP size of canvas. 41 | -------------------------------------------------------------------------------- /third_party/libxml/src/README: -------------------------------------------------------------------------------- 1 | 2 | XML toolkit from the GNOME project 3 | 4 | Full documentation is available on-line at 5 | http://xmlsoft.org/ 6 | 7 | This code is released under the MIT Licence see the Copyright file. 8 | 9 | To build on an Unixised setup: 10 | ./configure ; make ; make install 11 | To build on Windows: 12 | see instructions on win32/Readme.txt 13 | 14 | To assert build quality: 15 | on an Unixised setup: 16 | run make tests 17 | otherwise: 18 | There is 3 standalone tools runtest.c runsuite.c testapi.c, which 19 | should compile as part of the build or as any application would. 20 | Launch them from this directory to get results, runtest checks 21 | the proper functionning of libxml2 main APIs while testapi does 22 | a full coverage check. Report failures to the list. 23 | 24 | To report bugs, follow the instructions at: 25 | http://xmlsoft.org/bugs.html 26 | 27 | A mailing-list xml@gnome.org is available, to subscribe: 28 | http://mail.gnome.org/mailman/listinfo/xml 29 | 30 | The list archive is at: 31 | http://mail.gnome.org/archives/xml/ 32 | 33 | All technical answers asked privately will be automatically answered on 34 | the list and archived for public access unless privacy is explicitly 35 | required and justified. 36 | 37 | Daniel Veillard 38 | 39 | $Id$ 40 | -------------------------------------------------------------------------------- /node_yue/BUILD.gn: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Cheng Zhao. All rights reserved. 2 | # Use of this source code is governed by the license that can be found in the 3 | # LICENSE file. 4 | 5 | import("//v8binding/node.gni") 6 | 7 | loadable_module("node_yue") { 8 | output_name = "gui" 9 | output_extension = "node" 10 | output_prefix_override = true # do not add "lib" prefix 11 | 12 | sources = [ 13 | "binding_gui.cc", 14 | "binding_signal.h", 15 | "binding_values.cc", 16 | "binding_values.h", 17 | "chrome_view_mac.mm", 18 | "chrome_view_mac.h", 19 | "delay_load_hook_win.cc", 20 | "node_integration.cc", 21 | "node_integration.h", 22 | "node_integration_linux.cc", 23 | "node_integration_linux.h", 24 | "node_integration_mac.cc", 25 | "node_integration_mac.h", 26 | "node_integration_win.cc", 27 | "node_integration_win.h", 28 | "v8_value_converter.h", 29 | "v8_value_converter_impl.cc", 30 | "v8_value_converter_impl.h", 31 | ] 32 | 33 | deps = [ 34 | "//base", 35 | "//nativeui", 36 | "//v8binding", 37 | ] 38 | 39 | if (is_linux && is_component_build) { 40 | configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ] 41 | } 42 | 43 | if (is_win) { 44 | ldflags = [ 45 | "/DELAYLOAD:node.exe", 46 | "/DELAYLOAD:node.dll", 47 | "/DELAYLOAD:yode.exe", 48 | ] 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /nativeui/gtk/accelerator_manager_gtk.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/accelerator_manager.h" 6 | 7 | #if defined(OS_LINUX) 8 | #include 9 | #endif 10 | 11 | #include "nativeui/menu_item.h" 12 | 13 | namespace nu { 14 | 15 | AcceleratorManager::AcceleratorManager() 16 | : accel_group_(gtk_accel_group_new()) { 17 | g_object_ref_sink(accel_group_); 18 | } 19 | 20 | AcceleratorManager::~AcceleratorManager() { 21 | g_object_unref(accel_group_); 22 | } 23 | 24 | void AcceleratorManager::RegisterAccelerator(MenuItem* item, 25 | const Accelerator& accelerator) { 26 | gtk_widget_add_accelerator( 27 | GTK_WIDGET(item->GetNative()), "activate", accel_group_, 28 | accelerator.GetKeyCode(), 29 | static_cast(accelerator.GetModifiers()), 30 | GTK_ACCEL_VISIBLE); 31 | } 32 | 33 | void AcceleratorManager::RemoveAccelerator(MenuItem* item, 34 | const Accelerator& accelerator) { 35 | gtk_widget_remove_accelerator( 36 | GTK_WIDGET(item->GetNative()), accel_group_, 37 | accelerator.GetKeyCode(), 38 | static_cast(accelerator.GetModifiers())); 39 | } 40 | 41 | } // namespace nu 42 | -------------------------------------------------------------------------------- /node_yue/node_integration_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 GitHub, Inc. 2 | // Copyright 2017 Cheng Zhao. All rights reserved. 3 | // Use of this source code is governed by the license that can be found in the 4 | // LICENSE file. 5 | 6 | #include "node_yue/node_integration_win.h" 7 | 8 | #include 9 | 10 | namespace node_yue { 11 | 12 | NodeIntegrationWin::NodeIntegrationWin() { 13 | } 14 | 15 | NodeIntegrationWin::~NodeIntegrationWin() { 16 | } 17 | 18 | void NodeIntegrationWin::PollEvents() { 19 | // If there are other kinds of events pending, uv_backend_timeout will 20 | // instruct us not to wait. 21 | DWORD bytes, timeout; 22 | ULONG_PTR key; 23 | OVERLAPPED* overlapped; 24 | 25 | timeout = uv_backend_timeout(uv_loop_); 26 | 27 | GetQueuedCompletionStatus(uv_loop_->iocp, 28 | &bytes, 29 | &key, 30 | &overlapped, 31 | timeout); 32 | 33 | // Give the event back so libuv can deal with it. 34 | if (overlapped != NULL) 35 | PostQueuedCompletionStatus(uv_loop_->iocp, 36 | bytes, 37 | key, 38 | overlapped); 39 | } 40 | 41 | // static 42 | NodeIntegration* NodeIntegration::Create() { 43 | return new NodeIntegrationWin(); 44 | } 45 | 46 | } // namespace node_yue 47 | -------------------------------------------------------------------------------- /third_party/libxml/src/COPYING: -------------------------------------------------------------------------------- 1 | Except where otherwise noted in the source code (e.g. the files hash.c, 2 | list.c and the trio files, which are covered by a similar licence but 3 | with different Copyright notices) all the files are: 4 | 5 | Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is fur- 12 | nished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- 19 | NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /third_party/libxml/src/Copyright: -------------------------------------------------------------------------------- 1 | Except where otherwise noted in the source code (e.g. the files hash.c, 2 | list.c and the trio files, which are covered by a similar licence but 3 | with different Copyright notices) all the files are: 4 | 5 | Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved. 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is fur- 12 | nished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- 19 | NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /nativeui/gfx/win/image_win.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #include "nativeui/gfx/image.h" 6 | 7 | #include 8 | #include 9 | 10 | #include "base/win/scoped_hglobal.h" 11 | #include "nativeui/gfx/win/gdiplus.h" 12 | 13 | namespace nu { 14 | 15 | Image::Image(const base::FilePath& path) 16 | : scale_factor_(GetScaleFactorFromFilePath(path)), 17 | image_(new Gdiplus::Image(path.value().c_str())) { 18 | } 19 | 20 | Image::Image(const Buffer& buffer, float scale_factor) 21 | : scale_factor_(scale_factor) { 22 | HGLOBAL glob = ::GlobalAlloc(GPTR, buffer.size()); 23 | { 24 | base::win::ScopedHGlobal global_lock(glob); 25 | memcpy(global_lock.get(), buffer.content(), buffer.size()); 26 | } 27 | Microsoft::WRL::ComPtr stream; 28 | ::CreateStreamOnHGlobal(glob, TRUE, &stream); 29 | image_ = new Gdiplus::Image(stream.Get()); 30 | } 31 | 32 | Image::~Image() { 33 | delete image_; 34 | } 35 | 36 | SizeF Image::GetSize() const { 37 | Gdiplus::Image* image = const_cast(image_); 38 | return ScaleSize(SizeF(image->GetWidth(), image->GetHeight()), 39 | 1.f / scale_factor_); 40 | } 41 | 42 | NativeImage Image::GetNative() const { 43 | return image_; 44 | } 45 | 46 | } // namespace nu 47 | -------------------------------------------------------------------------------- /nativeui/scroll.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Cheng Zhao. All rights reserved. 2 | // Use of this source code is governed by the license that can be found in the 3 | // LICENSE file. 4 | 5 | #ifndef NATIVEUI_SCROLL_H_ 6 | #define NATIVEUI_SCROLL_H_ 7 | 8 | #include 9 | 10 | #include "nativeui/view.h" 11 | 12 | namespace nu { 13 | 14 | class NATIVEUI_EXPORT Scroll : public View { 15 | public: 16 | Scroll(); 17 | 18 | // View class name. 19 | static const char kClassName[]; 20 | 21 | void SetContentView(View* view); 22 | View* GetContentView() const; 23 | 24 | void SetContentSize(const SizeF& size); 25 | SizeF GetContentSize() const; 26 | 27 | #if !defined(OS_WIN) 28 | void SetOverlayScrollbar(bool overlay); 29 | bool IsOverlayScrollbar() const; 30 | #endif 31 | 32 | enum class Policy { 33 | Always, 34 | Never, 35 | Automatic, 36 | }; 37 | void SetScrollbarPolicy(Policy h_policy, Policy v_policy); 38 | std::tuple GetScrollbarPolicy() const; 39 | 40 | // View: 41 | const char* GetClassName() const override; 42 | 43 | protected: 44 | ~Scroll() override; 45 | 46 | // Following platform implementations should only be called by wrappers. 47 | void PlatformInit(); 48 | void PlatformSetContentView(View* container); 49 | 50 | private: 51 | scoped_refptr content_view_; 52 | }; 53 | 54 | } // namespace nu 55 | 56 | #endif // NATIVEUI_SCROLL_H_ 57 | --------------------------------------------------------------------------------