X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Ftheme.cpp;h=c6cf4515805ad83be506f783d26df92b30ebc103;hb=a60a2c892c08f6fab3a1e6b7cf4343cad8689058;hp=dc73c2ca2553f48c48601b8fd9e8f1fe1deba931;hpb=30ac87a04d17d7d7334113a98b97853a45a1d020;p=nageru diff --git a/nageru/theme.cpp b/nageru/theme.cpp index dc73c2c..c6cf451 100644 --- a/nageru/theme.cpp +++ b/nageru/theme.cpp @@ -636,6 +636,20 @@ int InputStateInfo_get_height(lua_State* L) return 1; } +int InputStateInfo_get_frame_height(lua_State* L) +{ + assert(lua_gettop(L) == 2); + InputStateInfo *input_state_info = get_input_state_info(L, 1); + Theme *theme = get_theme_updata(L); + int signal_num = theme->map_signal(luaL_checknumber(L, 2)); + unsigned height = input_state_info->last_height[signal_num]; + if (input_state_info->last_interlaced[signal_num]) { + height *= 2; + } + lua_pushnumber(L, height); + return 1; +} + int InputStateInfo_get_interlaced(lua_State* L) { assert(lua_gettop(L) == 2); @@ -745,10 +759,10 @@ int InputStateInfo_get_human_readable_resolution(lua_State* L) string str; if (!input_state_info->last_is_connected[signal_num]) { str = "disconnected"; - } else if (input_state_info->last_height[signal_num]) { + } else if (input_state_info->last_height[signal_num] <= 0) { str = "no signal"; } else if (!input_state_info->last_has_signal[signal_num]) { - if (input_state_info->last_height[signal_num]) { + if (input_state_info->last_height[signal_num] == 525) { // Special mode for the USB3 cards. str = "no signal"; } else { @@ -979,6 +993,8 @@ const luaL_Reg LiftGammaGainEffect_funcs[] = { const luaL_Reg InputStateInfo_funcs[] = { { "get_width", InputStateInfo_get_width }, { "get_height", InputStateInfo_get_height }, + { "get_frame_width", InputStateInfo_get_width }, // Same as get_width(). + { "get_frame_height", InputStateInfo_get_frame_height }, { "get_interlaced", InputStateInfo_get_interlaced }, { "get_has_signal", InputStateInfo_get_has_signal }, { "get_is_connected", InputStateInfo_get_is_connected }, @@ -1279,6 +1295,10 @@ int Nageru_set_supports_wb(lua_State *L) Theme::Theme(const string &filename, const vector &search_dirs, ResourcePool *resource_pool, unsigned num_cards) : resource_pool(resource_pool), num_cards(num_cards), signal_to_card_mapping(global_flags.default_stream_mapping) { + // Defaults. + channel_names[0] = "Live"; + channel_names[1] = "Preview"; + L = luaL_newstate(); luaL_openlibs(L); @@ -1396,6 +1416,8 @@ void Theme::register_globals() const vector> num_constants = { { "VIDEO_FORMAT_BGRA", bmusb::PixelFormat_8BitBGRA }, { "VIDEO_FORMAT_YCBCR", bmusb::PixelFormat_8BitYCbCrPlanar }, + { "CHECKABLE", MenuEntry::CHECKABLE }, + { "CHECKED", MenuEntry::CHECKED }, }; const vector> str_constants = { { "THEME_PATH", theme_path }, @@ -1551,6 +1573,12 @@ string Theme::get_channel_name(unsigned channel) { lock_guard lock(m); + // We never ask the legacy channel_name() about live and preview. + // The defaults are set in our constructor. + if (channel == 0 || channel == 1) { + return channel_names[channel]; + } + lua_getglobal(L, "channel_name"); if (lua_isnil(L, -1)) { lua_pop(L, 1); @@ -1768,9 +1796,9 @@ void destroy(T &ref) Theme::MenuEntry::~MenuEntry() { if (is_submenu) { - luaL_unref(entry.L, LUA_REGISTRYINDEX, entry.lua_ref); - } else { destroy(submenu); + } else { + luaL_unref(entry.L, LUA_REGISTRYINDEX, entry.lua_ref); } } @@ -1786,6 +1814,13 @@ unique_ptr create_theme_menu_entry(lua_State *L, int index) const string text = checkstdstring(L, -1); lua_pop(L, 1); + unsigned flags = 0; + if (lua_objlen(L, -1) > 2) { + lua_rawgeti(L, -1, 3); + flags = luaL_checknumber(L, -1); + lua_pop(L, 1); + } + lua_rawgeti(L, index, 2); if (lua_istable(L, -1)) { vector> submenu = create_recursive_theme_menu(L); @@ -1794,7 +1829,7 @@ unique_ptr create_theme_menu_entry(lua_State *L, int index) } else { luaL_checktype(L, -1, LUA_TFUNCTION); int ref = luaL_ref(L, LUA_REGISTRYINDEX); - entry.reset(new Theme::MenuEntry{ text, L, ref }); + entry.reset(new Theme::MenuEntry{ text, L, ref, flags }); } return entry; }