Merge remote-tracking branch 'origin/develop' into ryzomclassic-develop

ryzomclassic-develop
kaetemi 5 years ago
commit a86fb4e195

@ -1,57 +1,9 @@
# - Locate FMOD library INCLUDE(FindHelpers)
# This module defines
# FMOD_LIBRARY, the library to link against
# FMOD_FOUND, if false, do not try to link to FMOD
# FMOD_INCLUDE_DIR, where to find headers.
IF(FMOD_LIBRARY AND FMOD_INCLUDE_DIR)
# in cache already
SET(FMOD_FIND_QUIETLY TRUE)
ENDIF()
FIND_PATH(FMOD_INCLUDE_DIR
fmod.h
PATHS
$ENV{FMOD_DIR}/include
/usr/local/include
/usr/include
/sw/include
/opt/local/include
/opt/csw/include
/opt/include
PATH_SUFFIXES fmod fmod3
)
IF(TARGET_X64) IF(TARGET_X64)
SET(FMOD_LIBRARY_NAMES fmod64 fmod) SET(FMOD_BASE fmod64)
ELSE() ELSE()
SET(FMOD_LIBRARY_NAMES fmodvc fmod) SET(FMOD_BASE fmodvc)
ENDIF() ENDIF()
FIND_LIBRARY(FMOD_LIBRARY FIND_PACKAGE_HELPER(FMOD fmod.h RELEASE ${FMOD_BASE} DEBUG ${FMOD_BASE}d SUFFIXES fmod3)
NAMES
${FMOD_LIBRARY_NAMES}
PATHS
$ENV{FMOD_DIR}/lib
/usr/local/lib
/usr/lib
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
IF(FMOD_LIBRARY AND FMOD_INCLUDE_DIR)
SET(FMOD_FOUND "YES")
IF(NOT FMOD_FIND_QUIETLY)
MESSAGE(STATUS "Found FMOD: ${FMOD_LIBRARY}")
ENDIF()
ELSE()
IF(NOT FMOD_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find FMOD!")
ENDIF()
ENDIF()

@ -3,6 +3,7 @@
# LUABIND_LIBRARIES, the libraries to link against # LUABIND_LIBRARIES, the libraries to link against
# LUABIND_FOUND, if false, do not try to link to LUABIND # LUABIND_FOUND, if false, do not try to link to LUABIND
# LUABIND_INCLUDE_DIR, where to find headers. # LUABIND_INCLUDE_DIR, where to find headers.
INCLUDE(FindHelpers)
MACRO(FIND_CORRECT_LUA_VERSION) MACRO(FIND_CORRECT_LUA_VERSION)
# Check Lua version linked to Luabind under Linux # Check Lua version linked to Luabind under Linux
@ -85,18 +86,6 @@ IF(LUABIND_LIBRARIES AND LUABIND_INCLUDE_DIR)
SET(Luabind_FIND_QUIETLY TRUE) SET(Luabind_FIND_QUIETLY TRUE)
ENDIF() ENDIF()
FIND_PATH(LUABIND_INCLUDE_DIR
luabind/luabind.hpp
PATHS
$ENV{LUABIND_DIR}/include
/usr/local/include
/usr/include
/sw/include
/opt/local/include
/opt/csw/include
/opt/include
)
SET(LIBRARY_NAME_RELEASE) SET(LIBRARY_NAME_RELEASE)
SET(LIBRARY_NAME_DEBUG) SET(LIBRARY_NAME_DEBUG)
@ -149,35 +138,7 @@ ENDIF()
LIST(APPEND LIBRARY_NAME_RELEASE luabind libluabind) LIST(APPEND LIBRARY_NAME_RELEASE luabind libluabind)
LIST(APPEND LIBRARY_NAME_DEBUG luabind_d luabindd libluabind_d libluabindd) LIST(APPEND LIBRARY_NAME_DEBUG luabind_d luabindd libluabind_d libluabindd)
FIND_LIBRARY(LUABIND_LIBRARY_RELEASE FIND_PACKAGE_HELPER(Luabind luabind/luabind.hpp RELEASE ${LIBRARY_NAME_RELEASE} DEBUG ${LIBRARY_NAME_DEBUG})
NAMES ${LIBRARY_NAME_RELEASE}
PATHS
$ENV{LUABIND_DIR}/lib
/usr/local/lib
/usr/lib
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
FIND_LIBRARY(LUABIND_LIBRARY_DEBUG
NAMES ${LIBRARY_NAME_DEBUG}
PATHS
$ENV{LUABIND_DIR}/lib
/usr/local/lib
/usr/lib
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
FIND_PACKAGE(Boost REQUIRED) FIND_PACKAGE(Boost REQUIRED)

@ -1,89 +1,55 @@
# - Find MS Visual C++ # - Find MS Visual C++
# #
# VC_DIR - where to find Visual C++
# VC_INCLUDE_DIR - where to find headers # VC_INCLUDE_DIR - where to find headers
# VC_INCLUDE_DIRS - where to find headers # VC_INCLUDE_DIRS - where to find headers
# VC_LIBRARY_DIR - where to find libraries # VC_LIBRARY_DIR - where to find libraries
# VC_FOUND - True if MSVC found. # VC_FOUND - True if MSVC found
MACRO(ADD_TRAILING_SLASH _FILENAME_VAR)
# put content in a new variable
SET(_FILENAME ${${_FILENAME_VAR}})
# get length of the string
STRING(LENGTH ${_FILENAME} _LEN)
# convert length to last pos
MATH(EXPR _POS "${_LEN}-1")
# get last character of the string
STRING(SUBSTRING ${_FILENAME} ${_POS} 1 _FILENAME_END)
# compare it with a slash
IF(NOT _FILENAME_END STREQUAL "/")
# not a slash, append it
SET(${_FILENAME_VAR} "${_FILENAME}/")
ELSE()
# already a slash
ENDIF()
ENDMACRO()
MACRO(DETECT_VC_VERSION_HELPER _ROOT _VERSION)
# Software/Wow6432Node/...
GET_FILENAME_COMPONENT(VC${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7;${_VERSION}]" ABSOLUTE)
IF(VC${_VERSION}_DIR AND VC${_VERSION}_DIR STREQUAL "/registry")
SET(VC${_VERSION}_DIR)
GET_FILENAME_COMPONENT(VC${_VERSION}_DIR "[${_ROOT}\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;${_VERSION}]" ABSOLUTE)
IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
# be sure it's finishing by a /
ADD_TRAILING_SLASH(VC${_VERSION}_DIR)
SET(VC${_VERSION}_DIR "${VC${_VERSION}_DIR}VC/")
ENDIF()
ENDIF()
IF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry") IF(CMAKE_CXX_COMPILER)
SET(VC${_VERSION}_FOUND ON) SET(_COMPILER ${CMAKE_CXX_COMPILER})
DETECT_EXPRESS_VERSION(${_VERSION}) SET(_VERSION ${CMAKE_CXX_COMPILER_VERSION})
IF(NOT MSVC_FIND_QUIETLY) ELSEIF(CMAKE_C_COMPILER)
SET(_VERSION_STR ${_VERSION}) SET(_COMPILER ${CMAKE_C_COMPILER})
IF(MSVC_EXPRESS) SET(_VERSION ${CMAKE_C_COMPILER_VERSION})
SET(_VERSION_STR "${_VERSION_STR} Express") ELSE()
ENDIF() MESSAGE(FATAL_ERROR "No way to determine Visual C++ location")
MESSAGE(STATUS "Found Visual C++ ${_VERSION_STR} in ${VC${_VERSION}_DIR}")
ENDIF()
ELSEIF(VC${_VERSION}_DIR AND NOT VC${_VERSION}_DIR STREQUAL "/registry")
SET(VC${_VERSION}_FOUND OFF)
SET(VC${_VERSION}_DIR "")
ENDIF() ENDIF()
ENDMACRO()
MACRO(DETECT_VC_VERSION _VERSION) IF(MSVC_VERSION LESS 1910)
IF(NOT VC_FOUND) IF(MSVC_VERSION LESS 1500)
SET(VC${_VERSION}_FOUND OFF) MESSAGE(FATAL_ERROR "Unsupported version of Visual C++ (minimum version is 2008)")
DETECT_VC_VERSION_HELPER("HKEY_CURRENT_USER" ${_VERSION}) ELSEIF(MSVC_VERSION LESS 1600)
SET(MSVC_TOOLSET "90")
IF(NOT VC${_VERSION}_FOUND) SET(_NAME "2008")
DETECT_VC_VERSION_HELPER("HKEY_LOCAL_MACHINE" ${_VERSION}) ELSEIF(MSVC_VERSION LESS 1700)
SET(MSVC_TOOLSET "100")
SET(_NAME "2010")
ELSEIF(MSVC_VERSION LESS 1800)
SET(MSVC_TOOLSET "110")
SET(_NAME "2012")
ELSEIF(MSVC_VERSION LESS 1900)
SET(MSVC_TOOLSET "120")
SET(_NAME "2013")
ELSE()
SET(MSVC_TOOLSET "140")
SET(_NAME "2015")
ENDIF() ENDIF()
IF(VC${_VERSION}_FOUND) STRING(REGEX REPLACE "/bin/.+" "" VC_DIR ${_COMPILER})
SET(VC_FOUND ON)
SET(VC_DIR "${VC${_VERSION}_DIR}")
ENDIF()
ENDIF()
ENDMACRO()
MACRO(DETECT_EXPRESS_VERSION _VERSION) MESSAGE(STATUS "Found Visual C++ ${_NAME} (${_VERSION}) in ${VC_DIR}")
GET_FILENAME_COMPONENT(MSVC_EXPRESS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\${_VERSION}\\Setup\\VC;ProductDir]" ABSOLUTE) ELSE()
# Toolset = version of runtime DLLs
SET(MSVC_TOOLSET "140")
IF(MSVC_EXPRESS AND NOT MSVC_EXPRESS STREQUAL "/registry") IF(MSVC_VERSION LESS 1920)
SET(MSVC_EXPRESS ON) SET(_NAME "2017")
ELSE()
SET(_NAME "2019")
ENDIF() ENDIF()
ENDMACRO()
IF(MSVC_VERSION GREATER 1909) STRING(REGEX REPLACE "/MSVC/.+" "/MSVC" VC_DIR ${_COMPILER})
DETECT_VC_VERSION("15.0")
SET(MSVC_TOOLSET "140")
SET(VC_DIR "${VC_DIR}Tools/MSVC")
FILE(GLOB MSVC_TOOLCHAIN_VERSIONS RELATIVE ${VC_DIR} "${VC_DIR}/*") FILE(GLOB MSVC_TOOLCHAIN_VERSIONS RELATIVE ${VC_DIR} "${VC_DIR}/*")
@ -92,48 +58,15 @@ IF(MSVC_VERSION GREATER 1909)
LIST(REVERSE MSVC_TOOLCHAIN_VERSIONS) LIST(REVERSE MSVC_TOOLCHAIN_VERSIONS)
ENDIF() ENDIF()
IF(NOT MSVC_TOOLCHAIN_VERSIONS) IF(MSVC_TOOLCHAIN_VERSIONS)
MESSAGE(FATAL_ERROR "No MSVC version found in default search path ${VC_DIR}")
ENDIF()
LIST(GET MSVC_TOOLCHAIN_VERSIONS 0 MSVC_TOOLCHAIN_VERSION) LIST(GET MSVC_TOOLCHAIN_VERSIONS 0 MSVC_TOOLCHAIN_VERSION)
SET(VC_DIR "${VC_DIR}/${MSVC_TOOLCHAIN_VERSION}") SET(VC_DIR "${VC_DIR}/${MSVC_TOOLCHAIN_VERSION}")
SET(VC_INCLUDE_DIR "${VC_DIR}/include")
ELSEIF(MSVC14)
DETECT_VC_VERSION("14.0")
SET(MSVC_TOOLSET "140")
ELSEIF(MSVC12)
DETECT_VC_VERSION("12.0")
SET(MSVC_TOOLSET "120")
ELSEIF(MSVC11)
DETECT_VC_VERSION("11.0")
SET(MSVC_TOOLSET "110")
ELSEIF(MSVC10)
DETECT_VC_VERSION("10.0")
SET(MSVC_TOOLSET "100")
ELSEIF(MSVC90)
DETECT_VC_VERSION("9.0")
SET(MSVC_TOOLSET "90")
ELSEIF(MSVC80)
DETECT_VC_VERSION("8.0")
SET(MSVC_TOOLSET "80")
ENDIF()
# If you plan to use VC++ compilers with WINE, set VC_DIR environment variable
IF(NOT VC_DIR)
SET(VC_DIR $ENV{VC_DIR})
# Fix path
FILE(TO_CMAKE_PATH ${VC_DIR} VC_DIR)
ENDIF()
IF(NOT VC_DIR) MESSAGE(STATUS "Found Visual C++ ${_NAME} (${_VERSION} with toolchain ${MSVC_TOOLCHAIN_VERSION}) in ${VC_DIR}")
IF(CMAKE_CXX_COMPILER)
SET(_COMPILER ${CMAKE_CXX_COMPILER})
ELSE() ELSE()
SET(_COMPILER ${CMAKE_C_COMPILER}) MESSAGE(FATAL_ERROR "Unable to find Visual C++ in ${VC_DIR}")
ENDIF() ENDIF()
STRING(REGEX REPLACE "/(bin|BIN|Bin)/.+" "" VC_DIR ${_COMPILER})
ENDIF() ENDIF()
IF(NOT VC_INCLUDE_DIR AND VC_DIR AND EXISTS "${VC_DIR}") IF(NOT VC_INCLUDE_DIR AND VC_DIR AND EXISTS "${VC_DIR}")
@ -154,7 +87,7 @@ IF(NOT EXISTS "${MSVC_REDIST_DIR}")
ENDIF() ENDIF()
IF(MSVC_REDIST_DIR) IF(MSVC_REDIST_DIR)
IF(MSVC1411 OR MSVC1410) IF(MSVC_VERSION GREATER 1909)
# If you have VC++ 2017 Express, put x64/Microsoft.VC141.CRT/*.dll in ${EXTERNAL_PATH}/redist # If you have VC++ 2017 Express, put x64/Microsoft.VC141.CRT/*.dll in ${EXTERNAL_PATH}/redist
# original files whould be in ${VC_DIR}/Redist/MSVC/14.11.25325/x64/Microsoft.VC141.CRT # original files whould be in ${VC_DIR}/Redist/MSVC/14.11.25325/x64/Microsoft.VC141.CRT
SET(MSVC14_REDIST_DIR "${MSVC_REDIST_DIR}") SET(MSVC14_REDIST_DIR "${MSVC_REDIST_DIR}")
@ -176,7 +109,11 @@ IF(MSVC_REDIST_DIR)
ENDIF() ENDIF()
ENDIF() ENDIF()
MESSAGE(STATUS "Using headers from ${VC_INCLUDE_DIR}") IF(VC_INCLUDE_DIR)
MESSAGE(STATUS "Using VC++ headers from ${VC_INCLUDE_DIR}")
ELSE()
MESSAGE(FATAL_ERROR "Unable to find VC++ headers")
ENDIF()
SET(VC_INCLUDE_DIRS ${VC_INCLUDE_DIR}) SET(VC_INCLUDE_DIRS ${VC_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR})

@ -13,7 +13,6 @@
# NELXXX_FOUND # NELXXX_FOUND
# NELXXX_LIBRARIES # NELXXX_LIBRARIES
INCLUDE(FindHelpers) INCLUDE(FindHelpers)
# Init all variables we'll set # Init all variables we'll set
@ -209,6 +208,20 @@ IF(NELMISC_FOUND)
LIST(APPEND NELMISC_LIBRARIES ${LIBXML2_LIBRARIES}) LIST(APPEND NELMISC_LIBRARIES ${LIBXML2_LIBRARIES})
ENDIF() ENDIF()
IF(CMAKE_DL_LIBS)
LIST(APPEND NELMISC_LIBRARIES ${CMAKE_DL_LIBS})
ENDIF()
FIND_PACKAGE(Threads)
IF(Threads_FOUND)
LIST(APPEND NELMISC_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
ENDIF()
IF(UNIX AND NOT APPLE)
LIST(APPEND NELMISC_LIBRARIES rt)
ENDIF()
LIST(REMOVE_ITEM NeL_FIND_COMPONENTS misc) LIST(REMOVE_ITEM NeL_FIND_COMPONENTS misc)
LIST(APPEND NEL_MODULES_FOUND misc) LIST(APPEND NEL_MODULES_FOUND misc)
@ -262,11 +275,17 @@ FOREACH(COMPONENT ${NeL_FIND_COMPONENTS})
FIND_PACKAGE_HELPER(${_NAME} nel/${COMPONENT}/${HEADER_FILE} FIND_PACKAGE_HELPER(${_NAME} nel/${COMPONENT}/${HEADER_FILE}
RELEASE nel${COMPONENT}_r nel${COMPONENT} RELEASE nel${COMPONENT}_r nel${COMPONENT}
DEBUG nel${COMPONENT}_d DEBUG nel${COMPONENT}_d
DIR ${NEL_DIR}
QUIET) QUIET)
IF(${_UPNAME}_FOUND) IF(${_UPNAME}_FOUND)
LIST(APPEND NEL_MODULES_FOUND ${COMPONENT}) LIST(APPEND NEL_MODULES_FOUND ${COMPONENT})
# all NeL libraries depend on nelmisc in static
IF(NEL_STATIC)
LIST(APPEND ${_UPNAME}_LIBRARIES ${NELMISC_LIBRARIES})
ENDIF()
IF(COMPONENT STREQUAL "3d") IF(COMPONENT STREQUAL "3d")
IF(NEL_STATIC) IF(NEL_STATIC)
# 3rd party dependencies # 3rd party dependencies
@ -301,7 +320,9 @@ FOREACH(COMPONENT ${NeL_FIND_COMPONENTS})
ELSEIF(COMPONENT STREQUAL "gui") ELSEIF(COMPONENT STREQUAL "gui")
FIND_PACKAGE(Luabind REQUIRED) FIND_PACKAGE(Luabind REQUIRED)
IF(LUABIND_FOUND)
LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES}) LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES})
ENDIF()
FIND_LIBCURL() FIND_LIBCURL()
@ -323,7 +344,6 @@ FOREACH(COMPONENT ${NeL_FIND_COMPONENTS})
LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) LIST(APPEND CURL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES}) LIST(APPEND CURL_LIBRARIES ${OPENSSL_LIBRARIES})
LIST(APPEND ${_UPNAME}_LIBRARIES ${LUABIND_LIBRARIES} ${CURL_LIBRARIES})
LIST(APPEND NEL_DEFINITIONS ${${_UPNAME}_DEFINITIONS}) LIST(APPEND NEL_DEFINITIONS ${${_UPNAME}_DEFINITIONS})
ELSEIF(COMPONENT STREQUAL "sound") ELSEIF(COMPONENT STREQUAL "sound")
FIND_PACKAGE(Ogg REQUIRED) FIND_PACKAGE(Ogg REQUIRED)

@ -1,49 +1,3 @@
# - Locate Ogg library INCLUDE(FindHelpers)
# This module defines
# OGG_LIBRARY, the library to link against
# OGG_FOUND, if false, do not try to link to OGG
# OGG_INCLUDE_DIR, where to find headers.
IF(OGG_LIBRARY AND OGG_INCLUDE_DIR) FIND_PACKAGE_HELPER(Ogg ogg/ogg.h)
# in cache already
SET(OGG_FIND_QUIETLY TRUE)
ENDIF()
FIND_PATH(OGG_INCLUDE_DIR
ogg/ogg.h
PATHS
$ENV{OGG_DIR}/include
/usr/local/include
/usr/include
/sw/include
/opt/local/include
/opt/csw/include
/opt/include
)
FIND_LIBRARY(OGG_LIBRARY
NAMES ogg libogg
PATHS
$ENV{OGG_DIR}/lib
/usr/local/lib
/usr/lib
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
IF(OGG_LIBRARY AND OGG_INCLUDE_DIR)
SET(OGG_FOUND "YES")
IF(NOT OGG_FIND_QUIETLY)
MESSAGE(STATUS "Found Ogg: ${OGG_LIBRARY}")
ENDIF()
ELSE()
IF(NOT OGG_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find Ogg!")
ENDIF()
ENDIF()

@ -1,91 +1,5 @@
# Look for a directory containing STLport. INCLUDE(FindHelpers)
#
# The following values are defined
# STLPORT_INCLUDE_DIR - where to find vector, etc.
# STLPORT_LIBRARIES - link against these to use STLport
# STLPORT_FOUND - True if the STLport is available.
# also defined, but not for general use are FIND_PACKAGE_HELPER(STLport iostream
IF(STLPORT_LIBRARIES AND STLPORT_INCLUDE_DIR) RELEASE stlport_cygwin stlport_gcc stlport_x stlport_x.5.2 stlport_statix stlport_static
# in cache already DEBUG stlport_cygwin_debug stlport_cygwin_stldebug stlport_gcc_debug stlport_gcc_stldebug stlportstld_x stlportstld_x.5.2 stlportd_statix stlportd_static)
SET(STLPORT_FIND_QUIETLY TRUE)
ENDIF()
FIND_PATH(STLPORT_INCLUDE_DIR
iostream
PATHS
/usr/local/include
/usr/include
/sw/include
/opt/local/include
/opt/csw/include
/opt/include
PATH_SUFFIXES stlport
)
FIND_LIBRARY(STLPORT_LIBRARY_DEBUG
NAMES
stlport_cygwin_debug
stlport_cygwin_stldebug
stlport_gcc_debug
stlport_gcc_stldebug
stlportstld_x
stlportstld_x.5.2
stlportd
stlportd_statix
stlportd_static
PATHS
/usr/local/lib
/usr/lib
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
FIND_LIBRARY(STLPORT_LIBRARY_RELEASE
NAMES
stlport_cygwin
stlport_gcc
stlport
stlport_x
stlport_x.5.2
stlport_statix
stlport_static
PATHS
/usr/local/lib
/usr/lib
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
IF(STLPORT_INCLUDE_DIR)
IF(STLPORT_LIBRARY_RELEASE)
SET(STLPORT_FOUND TRUE)
SET(STLPORT_LIBRARIES ${STLPORT_LIBRARY_RELEASE})
IF(STLPORT_LIBRARY_DEBUG)
SET(STLPORT_LIBRARIES optimized ${STLPORT_LIBRARIES} debug ${STLPORT_LIBRARY_DEBUG})
ENDIF()
ENDIF()
ENDIF()
IF(STLPORT_FOUND)
IF(NOT STLPORT_FIND_QUIETLY)
MESSAGE(STATUS "Found STLport: ${STLPORT_LIBRARIES}")
ENDIF()
ELSE()
IF(NOT STLPORT_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find STLport!")
ENDIF()
ENDIF()
MARK_AS_ADVANCED(STLPORT_LIBRARY_RELEASE STLPORT_LIBRARY_DEBUG)

@ -1,69 +1,6 @@
# INCLUDE(FindHelpers)
# Find the LibSquish includes and library
#
# This module defines
# SQUISH_INCLUDE_DIR, where to find squish.h
# SQUISH_LIBRARIES, where to find the Squish libraries.
# SQUISH_FOUND, If false, do not try to use Squish.
# also defined, but not for general use are FIND_PACKAGE_HELPER(Squish squish.h)
IF(SQUISH_LIBRARIES AND SQUISH_INCLUDE_DIR)
# in cache already
SET(SQUISH_FIND_QUIETLY TRUE)
ENDIF()
FIND_PATH(SQUISH_INCLUDE_DIR
squish.h
PATHS
/usr/local/include
/usr/include
/sw/include
/opt/local/include
/opt/csw/include
/opt/include
PATH_SUFFIXES cppunit
)
FIND_LIBRARY(SQUISH_LIBRARY_RELEASE
squish
PATHS
/usr/local/lib
/usr/lib
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
FIND_LIBRARY(SQUISH_LIBRARY_DEBUG
squishd
PATHS
/usr/local/lib
/usr/lib
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
IF(SQUISH_INCLUDE_DIR)
IF(SQUISH_LIBRARY_RELEASE)
SET(SQUISH_FOUND "YES")
SET(SQUISH_LIBRARIES "optimized;${SQUISH_LIBRARY_RELEASE}")
IF(SQUISH_LIBRARY_DEBUG)
SET(SQUISH_LIBRARIES "${SQUISH_LIBRARIES};debug;${SQUISH_LIBRARY_DEBUG}")
ELSE()
SET(SQUISH_LIBRARIES "${SQUISH_LIBRARIES};debug;${SQUISH_LIBRARY_RELEASE}")
MESSAGE("Debug Squish NOT found, using the release version!")
ENDIF()
ENDIF()
ENDIF()
IF(SQUISH_FOUND) IF(SQUISH_FOUND)
IF(NOT SQUISH_FIND_QUIETLY) IF(NOT SQUISH_FIND_QUIETLY)
@ -74,10 +11,4 @@ IF(SQUISH_FOUND)
SET(SQUISH_COMPRESS_HAS_METRIC ON) SET(SQUISH_COMPRESS_HAS_METRIC ON)
SET(SQUISH_DEFINITIONS -DSQUISH_COMPRESS_HAS_METRIC) SET(SQUISH_DEFINITIONS -DSQUISH_COMPRESS_HAS_METRIC)
ENDIF() ENDIF()
ELSE()
IF(NOT SQUISH_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find Squish!")
ENDIF() ENDIF()
ENDIF()
MARK_AS_ADVANCED(SQUISH_LIBRARY_RELEASE SQUISH_LIBRARY_DEBUG)

@ -1,65 +1,8 @@
# - Locate Vorbis library INCLUDE(FindHelpers)
# This module defines
# VORBIS_LIBRARY, the library to link against
# VORBIS_FOUND, if false, do not try to link to VORBIS
# VORBIS_INCLUDE_DIR, where to find headers.
IF(VORBIS_LIBRARY AND VORBIS_INCLUDE_DIR) FIND_PACKAGE_HELPER(Vorbis vorbisenc.h)
# in cache already FIND_PACKAGE_HELPER(VorbisFile vorbisfile.h SUFFIXES vorbis)
SET(VORBIS_FIND_QUIETLY TRUE)
ENDIF()
FIND_PATH(VORBIS_INCLUDE_DIR
vorbis/vorbisfile.h
PATHS
$ENV{VORBIS_DIR}/include
/usr/local/include
/usr/include
/sw/include
/opt/local/include
/opt/csw/include
/opt/include
)
FIND_LIBRARY(VORBIS_LIBRARY
NAMES vorbis libvorbis
PATHS
$ENV{VORBIS_DIR}/lib
/usr/local/lib
/usr/lib
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
FIND_LIBRARY(VORBISFILE_LIBRARY IF(VORBISFILE_FOUND)
NAMES vorbisfile libvorbisfile SET(VORBIS_LIBRARIES ${VORBIS_LIBRARIES} ${VORBISFILE_LIBRARIES})
PATHS
$ENV{VORBIS_DIR}/lib
/usr/local/lib
/usr/lib
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
IF(VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBIS_INCLUDE_DIR)
SET(VORBIS_FOUND "YES")
SET(VORBIS_LIBRARIES ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY})
IF(NOT VORBIS_FIND_QUIETLY)
MESSAGE(STATUS "Found Vorbis: ${VORBIS_LIBRARY}")
ENDIF()
ELSE()
IF(NOT VORBIS_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find Vorbis!")
ENDIF()
ENDIF() ENDIF()

@ -20,6 +20,7 @@ MACRO(DETECT_WINSDK_VERSION_HELPER _ROOT _VERSION)
IF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry" AND EXISTS "${WINSDK${_VERSION}_DIR}/Include") IF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry" AND EXISTS "${WINSDK${_VERSION}_DIR}/Include")
SET(WINSDK${_VERSION}_FOUND ON) SET(WINSDK${_VERSION}_FOUND ON)
GET_FILENAME_COMPONENT(WINSDK${_VERSION}_VERSION_FULL "[${_ROOT}\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v${_VERSION};ProductVersion]" NAME) GET_FILENAME_COMPONENT(WINSDK${_VERSION}_VERSION_FULL "[${_ROOT}\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v${_VERSION};ProductVersion]" NAME)
IF(NOT WindowsSDK_FIND_QUIETLY) IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${_VERSION} in ${WINSDK${_VERSION}_DIR}") MESSAGE(STATUS "Found Windows SDK ${_VERSION} in ${WINSDK${_VERSION}_DIR}")
ENDIF() ENDIF()
@ -28,14 +29,14 @@ MACRO(DETECT_WINSDK_VERSION_HELPER _ROOT _VERSION)
ENDIF() ENDIF()
ENDMACRO() ENDMACRO()
MACRO(DETECT_WINKIT_VERSION _VERSION _SUFFIX) MACRO(DETECT_WINKIT_VERSION_HELPER _VERSION _SUFFIX _PREFIX _ARCH)
GET_FILENAME_COMPONENT(WINSDK${_VERSION}_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot${_SUFFIX}]" ABSOLUTE) GET_FILENAME_COMPONENT(WINSDK${_VERSION}_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\${_PREFIX}Microsoft\\Windows Kits\\Installed Roots;KitsRoot${_SUFFIX}]" ABSOLUTE)
IF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry") IF(WINSDK${_VERSION}_DIR AND NOT WINSDK${_VERSION}_DIR STREQUAL "/registry" AND EXISTS "${WINSDK${_VERSION}_DIR}/Include")
SET(WINSDK${_VERSION}_FOUND ON) SET(WINSDK${_VERSION}_FOUND ON)
SET(WINSDK${_VERSION}_VERSION_FULL "${_VERSION}") SET(WINSDK${_VERSION}_VERSION_FULL "${_VERSION}")
IF(NOT WindowsSDK_FIND_QUIETLY) IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows Kit ${_VERSION} in ${WINSDK${_VERSION}_DIR}") MESSAGE(STATUS "Found Windows Kit ${_VERSION} in ${WINSDK${_VERSION}_DIR} (registry ${_ARCH} bits)")
ENDIF() ENDIF()
LIST(APPEND WINSDK_DETECTED_VERSIONS ${_VERSION}) LIST(APPEND WINSDK_DETECTED_VERSIONS ${_VERSION})
ELSE() ELSE()
@ -52,6 +53,14 @@ MACRO(DETECT_WINSDK_VERSION _VERSION)
ENDIF() ENDIF()
ENDMACRO() ENDMACRO()
MACRO(DETECT_WINKIT_VERSION _VERSION _SUFFIX)
DETECT_WINKIT_VERSION_HELPER("${_VERSION}" "${_SUFFIX}" "WOW6432Node\\\\" "32")
IF(NOT WINSDK${_VERSION}_FOUND)
DETECT_WINKIT_VERSION_HELPER("${_VERSION}" "${_SUFFIX}" "" "64")
ENDIF()
ENDMACRO()
SET(WINSDK_DETECTED_VERSIONS) SET(WINSDK_DETECTED_VERSIONS)
# Fixed versions for Windows Kits (VC++ from 2012) # Fixed versions for Windows Kits (VC++ from 2012)
@ -378,7 +387,11 @@ FIND_PATH(WINSDK_INCLUDE_DIR Windows.h
NO_DEFAULT_PATH NO_DEFAULT_PATH
) )
IF(WINSDK_INCLUDE_DIR)
MESSAGE(STATUS "Found Windows.h in ${WINSDK_INCLUDE_DIR}") MESSAGE(STATUS "Found Windows.h in ${WINSDK_INCLUDE_DIR}")
ELSE()
MESSAGE(FATAL_ERROR "Unable to find Windows.h")
ENDIF()
# directory where WinRT headers are found # directory where WinRT headers are found
FIND_PATH(WINSDK_WINRT_INCLUDE_DIR winstring.h FIND_PATH(WINSDK_WINRT_INCLUDE_DIR winstring.h

@ -1,11 +1,11 @@
# Define OSX_SDK to force a specific version such as : -DOSX_SDK=10.11 # Define OSX_SDK to force a specific version such as : -DOSX_SDK=10.11
# #
# Example: # Example:
# cmake ../code -DCMAKE_TOOLCHAIN_FILE=../code/CMakeModules/OSXToolChain.cmake -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_SERVER=OFF -DWITH_NEL_TOOLS=OFF -DWITH_RYZOM_TOOLS=OFF -DWITH_LUA51=OFF -DWITH_LUA53=ON -DCMAKE_BUILD_TYPE=Release -DWITH_RYZOM_INSTALLER=OFF -DWITH_RYZOM_PATCH=ON -DWITH_NEL_TESTS=OFF -DWITH_NEL_TOOLS=OFF -DWITH_TOOLS=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_WARNINGS=OFF -DWITH_QT5=OFF -DWITH_STATIC=ON -DWITH_STATIC_DRIVERS=ON -DWITH_STATIC_EXTERNAL=ON -DWITH_UNIX_STRUCTURE=OFF -DWITH_INSTALL_LIBRARIES=OFF -DWITH_RYZOM_SANDBOX=OFF -DOSX_SDK=10.11 # cmake .. -DCMAKE_TOOLCHAIN_FILE=$CMAKE_MODULE_PATH/OSXToolChain.cmake -DOSX_SDK=10.14 <other flags>
# Don't forget to define environment variables: # Don't forget to define environment variables:
# #
# export MACOSX_DEPLOYMENT_TARGET=10.7 # export MACOSX_DEPLOYMENT_TARGET=10.8
# export OSXCROSS_GCC_NO_STATIC_RUNTIME=1 # export OSXCROSS_GCC_NO_STATIC_RUNTIME=1
# export PATH=$PATH:/home/src/osxcross/target/bin # export PATH=$PATH:/home/src/osxcross/target/bin
# #
@ -15,18 +15,22 @@
# ./osxcross-macports install libxml2 jpeg curl libogg libvorbis freetype boost openssl zlib lua-5.3 giflib # ./osxcross-macports install libxml2 jpeg curl libogg libvorbis freetype boost openssl zlib lua-5.3 giflib
# to compile Luabind # to compile Luabind
# export CMAKE_MODULE_PATH=$HOME/shard/tools/external/cmake/modules # cmake .. -DCMAKE_TOOLCHAIN_FILE=$CMAKE_MODULE_PATH/OSXToolChain.cmake -DWITH_SHARED=OFF -DWITH_STATIC=ON -DWITH_LUA51=OFF -DWITH_LUA53=ON -DCMAKE_INSTALL_PREFIX=$HOME/osxcross/target/external
# cmake .. -DCMAKE_TOOLCHAIN_FILE=$HOME/ryzomcore/code/CMakeModules/OSXToolChain.cmake -DWITH_SHARED=OFF -DWITH_STATIC=ON -DWITH_LUA51=OFF -DWITH_LUA53=ON -DCMAKE_INSTALL_PREFIX=$HOME/osxcross/target/external
IF(DEFINED CMAKE_CROSSCOMPILING) IF(DEFINED CMAKE_CROSSCOMPILING)
# subsequent toolchain loading is not really needed # subsequent toolchain loading is not really needed
RETURN() RETURN()
ENDIF() ENDIF()
# OSXCROSS_TARGET
# OSXCROSS_SDK
# Force the compilers to Clang for OS X # Force the compilers to Clang for OS X
SET(OSXCROSS_HOST "x86_64-apple-darwin18")
# C # C
SET(CMAKE_C_COMPILER x86_64-apple-darwin15-clang) SET(CMAKE_C_COMPILER ${OSXCROSS_HOST}-clang)
SET(CMAKE_C_STANDARD_COMPUTED_DEFAULT "11") SET(CMAKE_C_STANDARD_COMPUTED_DEFAULT "11")
SET(CMAKE_C_COMPILE_FEATURES "c_std_90;c_function_prototypes;c_std_99;c_restrict;c_variadic_macros;c_std_11;c_static_assert") SET(CMAKE_C_COMPILE_FEATURES "c_std_90;c_function_prototypes;c_std_99;c_restrict;c_variadic_macros;c_std_11;c_static_assert")
SET(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes") SET(CMAKE_C90_COMPILE_FEATURES "c_std_90;c_function_prototypes")
@ -34,7 +38,7 @@ SET(CMAKE_C99_COMPILE_FEATURES "c_std_99;c_restrict;c_variadic_macros")
SET(CMAKE_C11_COMPILE_FEATURES "c_std_11;c_static_assert") SET(CMAKE_C11_COMPILE_FEATURES "c_std_11;c_static_assert")
# C++ # C++
SET(CMAKE_CXX_COMPILER x86_64-apple-darwin15-clang++) SET(CMAKE_CXX_COMPILER ${OSXCROSS_HOST}-clang++)
SET(CMAKE_CXX_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters;cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates;cxx_std_17") SET(CMAKE_CXX_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters;cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_std_14;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates;cxx_std_17")
SET(CMAKE_CXX98_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters") SET(CMAKE_CXX98_COMPILE_FEATURES "cxx_std_98;cxx_template_template_parameters")
SET(CMAKE_CXX11_COMPILE_FEATURES "cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates") SET(CMAKE_CXX11_COMPILE_FEATURES "cxx_std_11;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates")
@ -102,8 +106,8 @@ SET(CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT}/MacOSX${OSX_SDK}.sdk)
# Standard settings # Standard settings
SET(CMAKE_SYSTEM_NAME Darwin) SET(CMAKE_SYSTEM_NAME Darwin)
SET(CMAKE_SYSTEM "Darwin-15.0.0") SET(CMAKE_SYSTEM "Darwin-18.0.0")
SET(CMAKE_SYSTEM_VERSION "15.0.0") SET(CMAKE_SYSTEM_VERSION "18.0.0")
SET(CMAKE_SYSTEM_PROCESSOR "x86_64") SET(CMAKE_SYSTEM_PROCESSOR "x86_64")
SET(UNIX ON) SET(UNIX ON)
@ -123,9 +127,17 @@ SET(CMAKE_SYSTEM_FRAMEWORK_PATH
) )
# only search the OS X sdks, not the remainder of the host filesystem # only search the OS X sdks, not the remainder of the host filesystem
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
# determinate location for bin utils based on CMAKE_FIND_ROOT_PATH # determinate location for bin utils based on CMAKE_FIND_ROOT_PATH
INCLUDE(CMakeFindBinUtils) INCLUDE(CMakeFindBinUtils)
set(CMAKE_AR "${OSXCROSS_HOST}-ar" CACHE FILEPATH "ar")
set(CMAKE_RANLIB "${OSXCROSS_HOST}-ranlib" CACHE FILEPATH "ranlib")
set(CMAKE_INSTALL_NAME_TOOL "${OSXCROSS_HOST}-install_name_tool" CACHE FILEPATH "install_name_tool")
set(ENV{PKG_CONFIG_LIBDIR} "${MACPORTS_ROOT_DIR}/lib/pkgconfig")
set(ENV{PKG_CONFIG_SYSROOT_DIR} "${CMAKE_OSX_TOOLCHAIN_ROOT}/macports/pkgs")

@ -137,23 +137,23 @@ SET(CMAKE_IOS_SIMULATOR_SYSROOT ${CMAKE_IOS_SIMULATOR_SDK_ROOT} CACHE PATH "Sysr
IF(CMAKE_GENERATOR MATCHES Xcode) IF(CMAKE_GENERATOR MATCHES Xcode)
IF(${IOS_PLATFORM} STREQUAL "OS") IF(${IOS_PLATFORM} STREQUAL "OS")
SET(CMAKE_SYSTEM_PROCESSOR "armv7") SET(CMAKE_SYSTEM_PROCESSOR "arm64")
ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR") ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR")
SET(CMAKE_SYSTEM_PROCESSOR "x86") SET(CMAKE_SYSTEM_PROCESSOR "x86_64")
ELSEIF(${IOS_PLATFORM} STREQUAL "ALL") ELSEIF(${IOS_PLATFORM} STREQUAL "ALL")
SET(CMAKE_SYSTEM_PROCESSOR "armv7") SET(CMAKE_SYSTEM_PROCESSOR "arm64")
ENDIF() ENDIF()
ELSE() ELSE()
IF(${IOS_PLATFORM} STREQUAL "OS") IF(${IOS_PLATFORM} STREQUAL "OS")
SET(ARCHS armv7 arm64) SET(ARCHS armv7 arm64)
SET(CMAKE_SYSTEM_PROCESSOR "armv7") SET(CMAKE_SYSTEM_PROCESSOR "arm64")
ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR") ELSEIF(${IOS_PLATFORM} STREQUAL "SIMULATOR")
# iPhone simulator targets i386 # iPhone simulator targets x86_64
SET(ARCHS "i386") SET(ARCHS "x86_64")
SET(CMAKE_SYSTEM_PROCESSOR "x86") SET(CMAKE_SYSTEM_PROCESSOR "x86")
ELSEIF(${IOS_PLATFORM} STREQUAL "ALL") ELSEIF(${IOS_PLATFORM} STREQUAL "ALL")
SET(ARCHS armv7 arm64 i386 x86_64) SET(ARCHS armv7 arm64 x86_64)
SET(CMAKE_SYSTEM_PROCESSOR "armv7") SET(CMAKE_SYSTEM_PROCESSOR "arm64")
ENDIF() ENDIF()
ENDIF() ENDIF()

@ -0,0 +1,94 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_CSS_BORDER_RENDERER_H
#define NL_CSS_BORDER_RENDERER_H
#include "nel/misc/types_nl.h"
#include "nel/misc/rgba.h"
#include "nel/misc/geom_ext.h"
#include "nel/gui/css_types.h"
namespace NLGUI
{
/**
* \brief Border renderer for GUI classes
* \date 2019-09-03 10:50 GMT
* \author Meelis Mägi (Nimetu)
*/
class CSSBorderRenderer
{
private:
// parent element screen coordinates
sint32 _XReal, _YReal;
sint32 _WReal, _HReal;
NLMISC::CQuadUV _QuadT;
NLMISC::CQuadUV _QuadR;
NLMISC::CQuadUV _QuadB;
NLMISC::CQuadUV _QuadL;
uint8 _RenderLayer;
bool _ModulateGlobalColor;
// if true, then updateCoords() is called from draw()
bool _Dirty;
// if true, then at least one border is set
bool _Border;
bool _BorderTop, _BorderRight, _BorderBottom, _BorderLeft;
public:
uint32 TopWidth, RightWidth, BottomWidth, LeftWidth;
NLMISC::CRGBA TopColor, RightColor, BottomColor, LeftColor;
CSSLineStyle TopStyle, RightStyle, BottomStyle, LeftStyle;
// alpha value from parent
uint8 CurrentAlpha;
public:
CSSBorderRenderer();
void setRenderLayer(sint layer);
void setModulateGlobalColor(bool m);
void setRect(sint32 x, sint32 y, sint32 w, sint32 h);
void setWidth(uint32 top, uint32 right, uint32 bottom, uint32 left);
void setStyle(CSSLineStyle top, CSSLineStyle right, CSSLineStyle bottom, CSSLineStyle left);
void setColor(const NLMISC::CRGBA &top, const NLMISC::CRGBA &right, const NLMISC::CRGBA &bottom, const NLMISC::CRGBA &left);
void updateCoords();
void invalidateCoords() { _Dirty = _Border = true; }
void invalidateContent() { _Dirty = _Border = true; };
uint32 getTopWidth() const;
uint32 getRightWidth() const;
uint32 getBottomWidth() const;
uint32 getLeftWidth() const;
uint32 getLeftRightWidth() const;
uint32 getTopBottomWidth() const;
void draw();
}; // CSSBorderRenderer
}//namespace
#endif // NL_CSS_BORDER_RENDERER_H

@ -31,7 +31,7 @@ namespace NLGUI
class CCssParser { class CCssParser {
public: public:
// parse style declaration, eg "color: red; font-size: 10px;" // parse style declaration, eg "color: red; font-size: 10px;"
static TStyle parseDecls(const std::string &styleString); static TStyleVec parseDecls(const std::string &styleString);
// parse css stylesheet // parse css stylesheet
void parseStylesheet(const std::string &cssString, std::vector<CCssStyle::SStyleRule> &rules); void parseStylesheet(const std::string &cssString, std::vector<CCssStyle::SStyleRule> &rules);

@ -20,12 +20,15 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/misc/rgba.h" #include "nel/misc/rgba.h"
#include "nel/gui/css_selector.h" #include "nel/gui/css_selector.h"
#include "nel/gui/css_types.h"
namespace NLGUI namespace NLGUI
{ {
class CHtmlElement; class CHtmlElement;
typedef std::map<std::string, std::string> TStyle; typedef std::map<std::string, std::string> TStyle;
typedef std::pair<std::string, std::string> TStylePair;
typedef std::vector<TStylePair> TStyleVec;
/** /**
* \brief CSS style rules * \brief CSS style rules
@ -62,9 +65,14 @@ namespace NLGUI
Height=-1; Height=-1;
MaxWidth=-1; MaxWidth=-1;
MaxHeight=-1; MaxHeight=-1;
BorderWidth=-1; // border style
BorderTopWidth = BorderRightWidth = BorderBottomWidth = BorderLeftWidth = CSSLineWidth::MEDIUM;
BorderTopStyle = BorderRightStyle = BorderBottomStyle = BorderLeftStyle = CSSLineStyle::NONE;
BorderTopColor = BorderRightColor = BorderBottomColor = BorderLeftColor = NLMISC::CRGBA::Transparent;
// background
BackgroundColor=NLMISC::CRGBA::Black; BackgroundColor=NLMISC::CRGBA::Black;
BackgroundColorOver=NLMISC::CRGBA::Black; BackgroundColorOver=NLMISC::CRGBA::Black;
PaddingTop = PaddingRight = PaddingBottom = PaddingLeft = 0;
} }
bool hasStyle(const std::string &key) const bool hasStyle(const std::string &key) const
@ -93,9 +101,12 @@ namespace NLGUI
sint32 Height; sint32 Height;
sint32 MaxWidth; sint32 MaxWidth;
sint32 MaxHeight; sint32 MaxHeight;
sint32 BorderWidth; uint32 BorderTopWidth, BorderRightWidth, BorderBottomWidth, BorderLeftWidth;
CSSLineStyle BorderTopStyle, BorderRightStyle, BorderBottomStyle, BorderLeftStyle;
NLMISC::CRGBA BorderTopColor, BorderRightColor, BorderBottomColor, BorderLeftColor;
NLMISC::CRGBA BackgroundColor; NLMISC::CRGBA BackgroundColor;
NLMISC::CRGBA BackgroundColorOver; NLMISC::CRGBA BackgroundColorOver;
uint32 PaddingTop, PaddingRight, PaddingBottom, PaddingLeft;
std::string WhiteSpace; std::string WhiteSpace;
std::string TextAlign; std::string TextAlign;
@ -106,9 +117,10 @@ namespace NLGUI
class CCssStyle { class CCssStyle {
public: public:
struct SStyleRule { struct SStyleRule {
std::vector<CCssSelector> Selector; std::vector<CCssSelector> Selector;
TStyle Properties; TStyleVec Properties;
// pseudo element like ':before' // pseudo element like ':before'
std::string PseudoElement; std::string PseudoElement;
@ -132,6 +144,9 @@ namespace NLGUI
// test if str is one of "thin/medium/thick" and return its pixel value // test if str is one of "thin/medium/thick" and return its pixel value
bool scanCssLength(const std::string& str, uint32 &px) const; bool scanCssLength(const std::string& str, uint32 &px) const;
// split css properties string, ie '1px solid rgb(100, 100, 100)' split by ' ' returns 3 parts.
void splitParams(const std::string &str, char sep, std::vector<std::string> &result) const;
// read style attribute // read style attribute
void getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams &current) const; void getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams &current) const;
void getStyleParams(const TStyle &styleRules, CStyleParams &style, const CStyleParams &current) const; void getStyleParams(const TStyle &styleRules, CStyleParams &style, const CStyleParams &current) const;
@ -143,13 +158,35 @@ namespace NLGUI
void apply(CStyleParams &style, const CStyleParams &current) const; void apply(CStyleParams &style, const CStyleParams &current) const;
// merge src into dest by overwriting key in dest // merge src into dest by overwriting key in dest
void merge(TStyle &dst, const TStyle &src) const; void merge(TStyle &dst, const TStyleVec &src) const;
// match selector to dom path // match selector to dom path
bool match(const std::vector<CCssSelector> &selector, const CHtmlElement &elm) const; bool match(const std::vector<CCssSelector> &selector, const CHtmlElement &elm) const;
// get shorthang 'top right bottom left' index values based size, ie 'padding' syntax
bool getShorthandIndices(const uint32 size, uint8 &t, uint8 &r, uint8 &b, uint8 &l) const;
// break 'border' into 'border-top-color', 'border-top-style', etc rules
bool tryBorderWidthShorthand(const std::string &prop, const std::string &value, TStyle &style) const;
bool tryBorderStyleShorthand(const std::string &prop, const std::string &value, TStyle &style) const;
bool tryBorderColorShorthand(const std::string &prop, const std::string &value, TStyle &style) const;
void expandBorderShorthand(const std::string &prop, const std::string &value, TStyle &style) const;
// parse 'background' into 'background-color', 'background-image', etc // parse 'background' into 'background-color', 'background-image', etc
void parseBackgroundShorthand(const std::string &value, CStyleParams &style) const; void expandBackgroundShorthand(const std::string &value, TStyle &style) const;
// parse 'padding' into 'padding-top', 'padding-left', etc
void expandPaddingShorthand(const std::string &value, TStyle &style) const;
// expand shorthand rule, ie "border", into longhand names, ie "border-top-width"
// if shorthand is present in style, then its removed
void expandShorthand(const std::string &prop, const std::string &value, TStyle &style) const;
// parse string value into corresponding value
void applyBorderWidth(const std::string &value, uint32 *dest, const uint32 currentWidth, const uint32 fontSize) const;
void applyBorderColor(const std::string &value, NLMISC::CRGBA *dest, const NLMISC::CRGBA &currentColor, const NLMISC::CRGBA &textColor) const;
void applyLineStyle(const std::string &value, CSSLineStyle *dest, const CSSLineStyle &currentStyle) const;
void applyPaddingWidth(const std::string &value, uint32 *dest, const uint32 currentPadding, uint32 fontSize) const;
public: public:
void reset(); void reset();
@ -171,12 +208,17 @@ namespace NLGUI
{ {
_StyleStack.push_back(Current); _StyleStack.push_back(Current);
Current.GlobalColor = false;
Current.DisplayBlock = false; Current.DisplayBlock = false;
Current.Width=-1; Current.Width=-1;
Current.Height=-1; Current.Height=-1;
Current.MaxWidth=-1; Current.MaxWidth=-1;
Current.MaxHeight=-1; Current.MaxHeight=-1;
Current.BorderWidth=-1;
Current.BorderTopWidth = Current.BorderRightWidth = Current.BorderBottomWidth = Current.BorderLeftWidth = CSSLineWidth::MEDIUM;
Current.BorderTopStyle = Current.BorderRightStyle = Current.BorderBottomStyle = Current.BorderLeftStyle = CSSLineStyle::NONE;
Current.BorderTopColor = Current.BorderRightColor = Current.BorderBottomColor = Current.BorderLeftColor = Current.TextColor;
Current.PaddingTop = Current.PaddingRight = Current.PaddingBottom = Current.PaddingLeft = 0;
Current.StyleRules.clear(); Current.StyleRules.clear();
} }

@ -0,0 +1,39 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_CSS_TYPES_H
#define CL_CSS_TYPES_H
#include "nel/misc/types_nl.h"
namespace NLGUI
{
/**
* \brief CSS types used in GUI classes
* \date 2019-09-03 10:50 GMT
* \author Meelis Mägi (Nimetu)
*/
// ie. border-style
enum CSSLineStyle { NONE = 0, HIDDEN, SOLID, INSET, OUTSET };
// ie, border-width (px)
enum CSSLineWidth { THIN = 1, MEDIUM = 3, THICK = 5 };
}//namespace
#endif // CL_CSS_TYPES_H

@ -124,7 +124,7 @@ namespace NLGUI
void endParagraph(); void endParagraph();
// add image download (used by view_bitmap.cpp to load web images) // add image download (used by view_bitmap.cpp to load web images)
void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage); void addImageDownload(const std::string &url, CViewBase *img, const CStyleParams &style = CStyleParams(), const TImageType type = NormalImage, const std::string &placeholder = "web_del.tga");
// remove image from download list if present // remove image from download list if present
void removeImageDownload(CViewBase *img); void removeImageDownload(CViewBase *img);
std::string localImageName(const std::string &url); std::string localImageName(const std::string &url);
@ -546,6 +546,11 @@ namespace NLGUI
// IL mode // IL mode
bool _LI; bool _LI;
// style from browser.css
CCssStyle _BrowserStyle;
// local file for browser.css
std::string _BrowserCssFile;
// Keep track of current element style // Keep track of current element style
CCssStyle _Style; CCssStyle _Style;
CHtmlElement _HtmlDOM; CHtmlElement _HtmlDOM;
@ -702,6 +707,7 @@ namespace NLGUI
VAlign = CGroupCell::Middle; VAlign = CGroupCell::Middle;
LeftMargin = 0; LeftMargin = 0;
NoWrap = false; NoWrap = false;
Height = 0;
} }
NLMISC::CRGBA BgColor; NLMISC::CRGBA BgColor;
std::string Style; std::string Style;
@ -709,6 +715,7 @@ namespace NLGUI
CGroupCell::TVAlign VAlign; CGroupCell::TVAlign VAlign;
sint32 LeftMargin; sint32 LeftMargin;
bool NoWrap; bool NoWrap;
sint32 Height;
}; };
std::vector<CCellParams> _CellParams; std::vector<CCellParams> _CellParams;

@ -136,9 +136,13 @@ namespace NLGUI
void removeLine(uint index); void removeLine(uint index);
const std::string getActionHandler(uint lineIndex) const; const std::string getActionHandler(uint lineIndex) const;
const std::string getActionHandlerParam(uint lineIndex) const; const std::string getActionHandlerParam(uint lineIndex) const;
const std::string getRightClickHandler(uint lineIndex) const;
const std::string getRightClickHandlerParam(uint lineIndex) const;
void setActionHandler(uint lineIndex, const std::string &ah = ""); void setActionHandler(uint lineIndex, const std::string &ah = "");
void setActionHandlerParam(uint lineIndex, const std::string &params = ""); void setActionHandlerParam(uint lineIndex, const std::string &params = "");
void setRightClickHandler(uint lineIndex, const std::string &ah = "");
void setRightClickHandlerParam(uint lineIndex, const std::string &params = "");
void openSubMenu (sint32 nb); void openSubMenu (sint32 nb);
@ -235,6 +239,8 @@ namespace NLGUI
CInterfaceGroup *Separator; CInterfaceGroup *Separator;
std::string AHName; std::string AHName;
std::string AHParams; std::string AHParams;
std::string AHRightClick;
std::string AHRightClickParams;
std::string Id; std::string Id;
std::string Cond; // condition to know if the entry is grayed std::string Cond; // condition to know if the entry is grayed
CViewBitmap *CheckBox; CViewBitmap *CheckBox;
@ -332,9 +338,13 @@ namespace NLGUI
void deleteLine(uint index); void deleteLine(uint index);
const std::string getActionHandler(uint lineIndex) const; const std::string getActionHandler(uint lineIndex) const;
const std::string getActionHandlerParam(uint lineIndex) const; const std::string getActionHandlerParam(uint lineIndex) const;
const std::string getRightClickHandler(uint lineIndex) const;
const std::string getRightClickHandlerParam(uint lineIndex) const;
void setActionHandler(uint lineIndex, const std::string &ah = ""); void setActionHandler(uint lineIndex, const std::string &ah = "");
void setActionHandlerParam(uint lineIndex, const std::string &params = ""); void setActionHandlerParam(uint lineIndex, const std::string &params = "");
void setRightClickHandler(uint lineIndex, const std::string &ah = "");
void setRightClickHandlerParam(uint lineIndex, const std::string &params = "");
void addLine (const ucstring &name, const std::string &ah = "", const std::string &params = "", void addLine (const ucstring &name, const std::string &ah = "", const std::string &params = "",
const std::string &id = std::string(), const std::string &id = std::string(),
@ -357,7 +367,7 @@ namespace NLGUI
void setMinH(sint32 minH); void setMinH(sint32 minH);
// change fontsize for new menu items // change fontsize for new menu items
void setFontSize(uint32 fontSize); void setFontSize(uint32 fontSize, bool coef = true);
// Gray a line on the RootMenu // Gray a line on the RootMenu
void setGrayedLine(uint line, bool g); void setGrayedLine(uint line, bool g);
@ -397,6 +407,7 @@ namespace NLGUI
bool _Formatted; bool _Formatted;
uint8 _Space; uint8 _Space;
sint32 _FontSize; sint32 _FontSize;
bool _FontSizeCoef;
NLMISC::CRGBA _ColorOver; // Color of the text when the mouse is over it NLMISC::CRGBA _ColorOver; // Color of the text when the mouse is over it
NLMISC::CRGBA _ShadowColorOver; // Color of the shadow when the mouse is over it NLMISC::CRGBA _ShadowColorOver; // Color of the shadow when the mouse is over it

@ -23,9 +23,11 @@
#include "nel/gui/group_frame.h" #include "nel/gui/group_frame.h"
#include "nel/gui/view_text.h" #include "nel/gui/view_text.h"
#include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_button.h"
#include "nel/gui/css_types.h"
namespace NLGUI namespace NLGUI
{ {
class CSSBorderRenderer;
/** /**
* This group is used to simulate HTML cells. * This group is used to simulate HTML cells.
@ -39,6 +41,7 @@ namespace NLGUI
DECLARE_UI_CLASS( CGroupCell ) DECLARE_UI_CLASS( CGroupCell )
CGroupCell(const TCtorParam &param); CGroupCell(const TCtorParam &param);
~CGroupCell();
enum TAlign enum TAlign
{ {
@ -91,11 +94,18 @@ namespace NLGUI
// The cell color // The cell color
NLMISC::CRGBA BgColor; NLMISC::CRGBA BgColor;
CSSBorderRenderer* Border;
uint32 PaddingTop, PaddingRight, PaddingBottom, PaddingLeft;
// Texture // Texture
CViewRenderer::CTextureId _TextureId; /// Accelerator CViewRenderer::CTextureId _TextureId;
bool _UserTexture;
bool _TextureTiled; bool _TextureTiled;
bool _TextureScaled; bool _TextureScaled;
// cached absolute coords for background texture
sint32 _TextureXReal;
sint32 _TextureYReal;
sint32 _TextureWReal;
sint32 _TextureHReal;
// Alignment // Alignment
TAlign Align; TAlign Align;
@ -112,10 +122,17 @@ namespace NLGUI
void setTextureTile(bool tiled); void setTextureTile(bool tiled);
void setTextureScale(bool scaled); void setTextureScale(bool scaled);
uint32 getPaddingLeftRight() const { return PaddingLeft + PaddingRight; };
uint32 getPaddingTopBottom() const { return PaddingTop + PaddingBottom; };
virtual void updateCoords();
static void setDebugUICell( bool d ){ DebugUICell = d; } static void setDebugUICell( bool d ){ DebugUICell = d; }
static bool getDebugUICell(){ return DebugUICell; } static bool getDebugUICell(){ return DebugUICell; }
private: private:
void updateTextureCoords();
void setEnclosedGroupDefaultParams(); void setEnclosedGroupDefaultParams();
static bool DebugUICell; static bool DebugUICell;
}; };
@ -143,9 +160,10 @@ namespace NLGUI
// The Width you want in pixel. This is the <table width="100"> parameter // The Width you want in pixel. This is the <table width="100"> parameter
sint32 ForceWidthMin; sint32 ForceWidthMin;
// Table borders CSSBorderRenderer* Border;
sint32 Border;
NLMISC::CRGBA BorderColor; // Cell has 1px solid border when <table> has 'border' attribute with width > 0
bool CellBorder;
sint32 CellPadding; sint32 CellPadding;
sint32 CellSpacing; sint32 CellSpacing;
@ -155,6 +173,10 @@ namespace NLGUI
bool ContinuousUpdate; bool ContinuousUpdate;
void setTexture(const std::string & TxName);
void setTextureTile(bool tiled);
void setTextureScale(bool scaled);
std::string getProperties( const std::string &name ) const; std::string getProperties( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value ); void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const; xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
@ -176,6 +198,18 @@ namespace NLGUI
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup); virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
// Texture
CViewRenderer::CTextureId _TextureId;
bool _TextureTiled;
bool _TextureScaled;
// cached absolute coords for background texture
sint32 _TextureXReal;
sint32 _TextureYReal;
sint32 _TextureWReal;
sint32 _TextureHReal;
void updateTextureCoords();
// Content validated // Content validated
bool _ContentValidated; bool _ContentValidated;

@ -101,6 +101,12 @@ namespace NLGUI
return _TextureId; return _TextureId;
} }
// Return true if TextureId is not set
bool empty() const { return _TextureId < 0; };
// delete TextureId if set
void clear();
void serial(NLMISC::IStream &f); void serial(NLMISC::IStream &f);
private: private:

@ -26,6 +26,7 @@
#include "nel/misc/types_nl.h" #include "nel/misc/types_nl.h"
#include "nel/gui/interface_common.h" #include "nel/gui/interface_common.h"
#include "nel/gui/interface_options.h" #include "nel/gui/interface_options.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/event_descriptor.h" #include "nel/gui/event_descriptor.h"
#include "nel/3d/u_camera.h" #include "nel/3d/u_camera.h"
#include "nel/gui/parser.h" #include "nel/gui/parser.h"

@ -119,6 +119,11 @@ public: // Advanced Usage.
// return a string separated by \n or eof, used to parsing text file // return a string separated by \n or eof, used to parsing text file
void getline (char *buffer, uint32 bufferSize); void getline (char *buffer, uint32 bufferSize);
// read whole file into a string. resulting buffer may contain NULL chars.
// internal read position is modified.
// return true on success, false on failure.
bool readAll(std::string &buffer);
// return the size of the file // return the size of the file
uint32 getFileSize () const { return _FileSize; } uint32 getFileSize () const { return _FileSize; }

@ -377,6 +377,7 @@ public:
static const CRGBA Magenta ; static const CRGBA Magenta ;
static const CRGBA Cyan ; static const CRGBA Cyan ;
static const CRGBA White ; static const CRGBA White ;
static const CRGBA Transparent ;
}; };

@ -0,0 +1,320 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "nel/gui/css_border_renderer.h"
#include "nel/gui/view_renderer.h"
#include "nel/gui/widget_manager.h"
using namespace std;
using namespace NLMISC;
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
namespace NLGUI
{
// ----------------------------------------------------------------------------
CSSBorderRenderer::CSSBorderRenderer()
{
TopWidth = RightWidth = BottomWidth = LeftWidth = 0;
TopColor = RightColor = BottomColor = LeftColor = CRGBA(128, 128, 128, 255);
TopStyle = RightStyle = BottomStyle = LeftStyle = CSSLineStyle::SOLID;
CurrentAlpha = 255;
_RenderLayer = 0;
_ModulateGlobalColor = false;
_Border = true;
_Dirty = true;
_BorderTop = _BorderRight = _BorderBottom = _BorderLeft = false;
//
_QuadT.Uv0.set(0.f, 0.f);
_QuadT.Uv1.set(0.f, 0.f);
_QuadT.Uv2.set(1.f, 1.f);
_QuadT.Uv3.set(0.f, 1.f);
//
_QuadR.Uv0.set(0.f, 0.f);
_QuadR.Uv1.set(0.f, 0.f);
_QuadR.Uv2.set(1.f, 1.f);
_QuadR.Uv3.set(0.f, 1.f);
//
_QuadB.Uv0.set(0.f, 0.f);
_QuadB.Uv1.set(0.f, 0.f);
_QuadB.Uv2.set(1.f, 1.f);
_QuadB.Uv3.set(0.f, 1.f);
//
_QuadL.Uv0.set(0.f, 0.f);
_QuadL.Uv1.set(0.f, 0.f);
_QuadL.Uv2.set(1.f, 1.f);
_QuadL.Uv3.set(0.f, 1.f);
}
// ----------------------------------------------------------------------------
void CSSBorderRenderer::setRenderLayer(sint layer)
{
_RenderLayer = layer;
}
// ----------------------------------------------------------------------------
void CSSBorderRenderer::setModulateGlobalColor(bool s)
{
_ModulateGlobalColor = s;
}
// ----------------------------------------------------------------------------
void CSSBorderRenderer::setRect(sint32 x, sint32 y, sint32 w, sint32 h)
{
_XReal = x;
_YReal = y;
_WReal = w;
_HReal = h;
_Dirty = _Border = (w > 0 && h > 0);
}
// ----------------------------------------------------------------------------
void CSSBorderRenderer::setWidth(uint32 top, uint32 right, uint32 bottom, uint32 left)
{
TopWidth = top;
RightWidth = right;
BottomWidth = bottom;
LeftWidth = left;
_Dirty = _Border = (top > 0 || right > 0 || bottom > 0 || left > 0);
}
// ----------------------------------------------------------------------------
void CSSBorderRenderer::setStyle(CSSLineStyle top, CSSLineStyle right, CSSLineStyle bottom, CSSLineStyle left)
{
TopStyle = top;
RightStyle = right;
BottomStyle = bottom;
LeftStyle = left;
_Dirty = _Border = true;
}
// ----------------------------------------------------------------------------
void CSSBorderRenderer::setColor(const NLMISC::CRGBA &top, const NLMISC::CRGBA &right, const NLMISC::CRGBA &bottom, const NLMISC::CRGBA &left)
{
TopColor = top;
RightColor = right;
BottomColor = bottom;
LeftColor = left;
_Dirty = true;
}
// ----------------------------------------------------------------------------
uint32 CSSBorderRenderer::getTopWidth() const
{
if (TopStyle == CSSLineStyle::NONE || TopStyle == CSSLineStyle::HIDDEN)
return 0;
return TopWidth;
}
// ----------------------------------------------------------------------------
uint32 CSSBorderRenderer::getRightWidth() const
{
if (RightStyle == CSSLineStyle::NONE || RightStyle == CSSLineStyle::HIDDEN)
return 0;
return RightWidth;
}
// ----------------------------------------------------------------------------
uint32 CSSBorderRenderer::getBottomWidth() const
{
if (BottomStyle == CSSLineStyle::NONE || BottomStyle == CSSLineStyle::HIDDEN)
return 0;
return BottomWidth;
}
// ----------------------------------------------------------------------------
uint32 CSSBorderRenderer::getLeftWidth() const
{
if (LeftStyle == CSSLineStyle::NONE || LeftStyle == CSSLineStyle::HIDDEN)
return 0;
return LeftWidth;
}
// ----------------------------------------------------------------------------
uint32 CSSBorderRenderer::getLeftRightWidth() const
{
return getLeftWidth() + getRightWidth();
}
// ----------------------------------------------------------------------------
uint32 CSSBorderRenderer::getTopBottomWidth() const
{
return getTopWidth() + getBottomWidth();
}
// ----------------------------------------------------------------------------
void CSSBorderRenderer::updateCoords()
{
_Dirty = false;
if (!_Border) return;
sint dTop = getTopWidth(); _BorderTop = dTop > 0;
sint dRight = getRightWidth(); _BorderRight = dRight > 0;
sint dBottom = getBottomWidth(); _BorderBottom = dBottom > 0;
sint dLeft = getLeftWidth(); _BorderLeft = dLeft > 0;
_Border = _BorderTop || _BorderRight || _BorderBottom || _BorderLeft;
if (!_Border) return;
if (_BorderTop)
{
// top-left
_QuadT.V3.x = _XReal;
_QuadT.V3.y = _YReal + _HReal;
// top-right
_QuadT.V2.x = _XReal + _WReal;
_QuadT.V2.y = _YReal + _HReal;
// bottom-right
_QuadT.V1.x = _XReal + _WReal - dRight;
_QuadT.V1.y = _YReal + _HReal - dTop;
// bottom-left
_QuadT.V0.x = _XReal + dLeft;
_QuadT.V0.y = _YReal + _HReal - dTop;
}
if (_BorderRight)
{
// top-left
_QuadR.V3.x = _XReal + _WReal - dRight;
_QuadR.V3.y = _YReal + _HReal - dTop;
// top-right
_QuadR.V2.x = _XReal + _WReal;
_QuadR.V2.y = _YReal + _HReal;
// bottom-right
_QuadR.V1.x = _XReal + _WReal;
_QuadR.V1.y = _YReal;
// bottom-left
_QuadR.V0.x = _XReal + _WReal - dRight;
_QuadR.V0.y = _YReal + dBottom;
}
if (_BorderBottom)
{
// top-left
_QuadB.V3.x = _XReal + dLeft;
_QuadB.V3.y = _YReal + dBottom;
// top-right
_QuadB.V2.x = _XReal + _WReal - dRight;
_QuadB.V2.y = _YReal + dBottom;
// bottom-right
_QuadB.V1.x = _XReal + _WReal;
_QuadB.V1.y = _YReal;
// bottom-left
_QuadB.V0.x = _XReal;
_QuadB.V0.y = _YReal;
}
if (_BorderLeft)
{
// top-left
_QuadL.V3.x = _XReal;
_QuadL.V3.y = _YReal + _HReal;
// top-right
_QuadL.V2.x = _XReal + dLeft;
_QuadL.V2.y = _YReal + _HReal - dTop;
// bottom-right
_QuadL.V1.x = _XReal + dLeft;
_QuadL.V1.y = _YReal + dBottom;
// bottom-left
_QuadL.V0.x = _XReal;
_QuadL.V0.y = _YReal;
}
}
// ----------------------------------------------------------------------------
void CSSBorderRenderer::draw() {
if (_Dirty) updateCoords();
if (!_Border) return;
CViewRenderer &rVR = *CViewRenderer::getInstance();
// TODO: no need for widget manager, if global color is set from parent
CRGBA globalColor;
if (_ModulateGlobalColor)
globalColor = CWidgetManager::getInstance()->getGlobalColor();
// TODO: monitor ModulateGlobalColor and CurrentAlpha in table checkCoords and recalculate colors on change only
// OUTSET - bottom/right darker than normal (default table style)
// INSET - top/left darker than normal
if (_BorderTop)
{
CRGBA borderColorT = TopColor;
if (TopStyle == CSSLineStyle::INSET)
borderColorT = blend(borderColorT, CRGBA::Black, 0.5f);
if (_ModulateGlobalColor)
borderColorT.modulateFromColor (borderColorT, globalColor);
borderColorT.A = (uint8) (((uint16) CurrentAlpha * (uint16) borderColorT.A) >> 8);
rVR.drawQuad(_RenderLayer, _QuadT, rVR.getBlankTextureId(), borderColorT, false);
}
if (_BorderRight)
{
CRGBA borderColorR = RightColor;
if (RightStyle == CSSLineStyle::OUTSET)
borderColorR = blend(borderColorR, CRGBA::Black, 0.5f);
if (_ModulateGlobalColor)
borderColorR.modulateFromColor (borderColorR, globalColor);
borderColorR.A = (uint8) (((uint16) CurrentAlpha * (uint16) borderColorR.A) >> 8);
rVR.drawQuad(_RenderLayer, _QuadR, rVR.getBlankTextureId(), borderColorR, false);
}
if (_BorderBottom)
{
CRGBA borderColorB = BottomColor;
if (BottomStyle == CSSLineStyle::OUTSET)
borderColorB = blend(borderColorB, CRGBA::Black, 0.5f);
if (_ModulateGlobalColor)
borderColorB.modulateFromColor (borderColorB, globalColor);
borderColorB.A = (uint8) (((uint16) CurrentAlpha * (uint16) borderColorB.A) >> 8);
rVR.drawQuad(_RenderLayer, _QuadB, rVR.getBlankTextureId(), borderColorB, false);
}
if (_BorderLeft)
{
CRGBA borderColorL = LeftColor;
if (LeftStyle == CSSLineStyle::INSET)
borderColorL = blend(borderColorL, CRGBA::Black, 0.5f);
if (_ModulateGlobalColor)
borderColorL.modulateFromColor (borderColorL, globalColor);
borderColorL.A = (uint8) (((uint16) CurrentAlpha * (uint16) borderColorL.A) >> 8);
rVR.drawQuad(_RenderLayer, _QuadL, rVR.getBlankTextureId(), borderColorL, false);
}
}
}//namespace

@ -35,9 +35,9 @@ namespace NLGUI
// //
// key is converted to lowercase // key is converted to lowercase
// value is left as is // value is left as is
TStyle CCssParser::parseDecls(const std::string &styleString) TStyleVec CCssParser::parseDecls(const std::string &styleString)
{ {
TStyle styles; TStyleVec styles;
std::vector<std::string> elements; std::vector<std::string> elements;
NLMISC::splitString(styleString, ";", elements); NLMISC::splitString(styleString, ";", elements);
@ -49,7 +49,7 @@ namespace NLGUI
{ {
std::string key = trim(toLower(elements[i].substr(0, pos))); std::string key = trim(toLower(elements[i].substr(0, pos)));
std::string value = trim(elements[i].substr(pos+1)); std::string value = trim(elements[i].substr(pos+1));
styles[key] = value; styles.push_back(TStylePair(key, value));
} }
} }
@ -94,7 +94,7 @@ namespace NLGUI
std::vector<ucstring> selectors; std::vector<ucstring> selectors;
NLMISC::explode(selectorString, ucstring(","), selectors); NLMISC::explode(selectorString, ucstring(","), selectors);
TStyle props; TStyleVec props;
props = parseDecls(styleString.toUtf8()); props = parseDecls(styleString.toUtf8());
// duplicate props to each selector in selector list, // duplicate props to each selector in selector list,

@ -102,7 +102,9 @@ namespace NLGUI
} }
else else
{ {
elm.setPseudo(i->PseudoElement, i->Properties); TStyle props;
merge(props, i->Properties);
elm.setPseudo(i->PseudoElement, props);
} }
} }
} }
@ -110,17 +112,18 @@ namespace NLGUI
// style from "style" attribute overrides <style> // style from "style" attribute overrides <style>
if (elm.hasNonEmptyAttribute("style")) if (elm.hasNonEmptyAttribute("style"))
{ {
TStyle styles = CCssParser::parseDecls(elm.getAttribute("style")); TStyleVec styles = CCssParser::parseDecls(elm.getAttribute("style"));
merge(elm.Style, styles); merge(elm.Style, styles);
} }
} }
void CCssStyle::merge(TStyle &dst, const TStyle &src) const void CCssStyle::merge(TStyle &dst, const TStyleVec &src) const
{ {
// TODO: does not use '!important' flag // TODO: does not use '!important' flag
for(TStyle::const_iterator it = src.begin(); it != src.end(); ++it) for(TStyleVec::const_iterator it = src.begin(); it != src.end(); ++it)
{ {
dst[it->first] = it->second; dst[it->first] = it->second;
expandShorthand(it->first, it->second, dst);
} }
} }
@ -304,6 +307,48 @@ namespace NLGUI
return false; return false;
} }
// ***************************************************************************
void CCssStyle::splitParams(const std::string &str, char sep, std::vector<std::string> &result) const
{
// TODO: does not handle utf8
uint32 pos = 0;
for(uint i = 0; i< str.size(); i++)
{
// split by separator first, then check if string or function
if (str[i] == sep)
{
std::string sub = trim(str.substr(pos, i - pos));
if (!sub.empty())
result.push_back(str.substr(pos, i - pos));
// skip sep
pos = i + 1;
}
else if (str[i] == '"' || str[i] == '(')
{
// string "this is string", or function rgb(1, 2, 3)
char endChar;
if (str[i] == '"')
endChar = '"';
else if (str[i] == '\'')
endChar = '\'';
else
endChar = ')';
// skip start
i++;
while(i < str.size() && str[i] != endChar)
{
if (str[i] == '\\')
i++;
i++;
}
}
}
if (pos < str.size())
result.push_back(str.substr(pos).c_str());
}
// *************************************************************************** // ***************************************************************************
// CStyleParams style; // CStyleParams style;
// style.FontSize; // font-size: 10px; // style.FontSize; // font-size: 10px;
@ -312,7 +357,10 @@ namespace NLGUI
// style.StrikeThrough; // text-decoration: line-through; text-decoration-line: line-through; // style.StrikeThrough; // text-decoration: line-through; text-decoration-line: line-through;
void CCssStyle::getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams &current) const void CCssStyle::getStyleParams(const std::string &styleString, CStyleParams &style, const CStyleParams &current) const
{ {
TStyle styles = CCssParser::parseDecls(styleString); TStyleVec stylevec = CCssParser::parseDecls(styleString);
TStyle styles;
merge(styles, stylevec);
getStyleParams(styles, style, current); getStyleParams(styles, style, current);
} }
@ -428,11 +476,6 @@ namespace NLGUI
} }
} }
else else
if (it->first == "background")
{
parseBackgroundShorthand(it->second, style);
}
else
if (it->first == "background-repeat") if (it->first == "background-repeat")
{ {
// old ryzom specific value // old ryzom specific value
@ -440,23 +483,6 @@ namespace NLGUI
style.StyleRules[it->first] = "repeat"; style.StyleRules[it->first] = "repeat";
} }
else else
if (it->first == "background-scale")
{
// replace old ryzom specific rule with background-size
if (it->second != "1")
{
style.StyleRules["background-size"] = "auto";
}
else
{
style.StyleRules["background-size"] = "100%";
}
TStyle::iterator pos = style.StyleRules.find(it->first);
if (pos != style.StyleRules.end())
style.StyleRules.erase(pos);
}
else
if (it->first == "display") if (it->first == "display")
{ {
if (it->second == "inherit") if (it->second == "inherit")
@ -467,55 +493,131 @@ namespace NLGUI
} }
} }
// apply style rules void CCssStyle::applyBorderWidth(const std::string &value, uint32 *dest, const uint32 currentWidth, const uint32 fontSize) const
void CCssStyle::apply(CStyleParams &style, const CStyleParams &current) const
{
float tmpf;
TStyle::const_iterator it;
for (it=style.StyleRules.begin(); it != style.StyleRules.end(); ++it)
{ {
if (it->first == "border" || it->first == "border-width") if (!dest) return;
if (value == "inherit")
{ {
// TODO: border: 1px solid red; *dest = currentWidth;
if (it->second == "inherit")
{
style.BorderWidth = current.BorderWidth;
} }
else if (it->second == "none") else if (value == "thin")
{ {
style.BorderWidth = 0; *dest = 1;
} }
else if (it->second == "thin") else if (value == "medium")
{ {
style.BorderWidth = 1; *dest = 3;
} }
else if (it->second == "medium") else if (value == "thick")
{ {
style.BorderWidth = 3; *dest = 5;
} }
else if (it->second == "thick") else if (value == "0")
{ {
style.BorderWidth = 5; *dest = 0;
} }
else else
{ {
float tmpf; float tmpf;
std::string unit; std::string unit;
if (getCssLength(tmpf, unit, it->second.c_str())) if (getCssLength(tmpf, unit, value.c_str()))
{ {
if (unit == "rem") if (unit == "rem")
style.BorderWidth = Root.FontSize * tmpf; *dest = fontSize * tmpf;
else if (unit == "em") else if (unit == "em")
style.BorderWidth = current.FontSize * tmpf; *dest = fontSize * tmpf;
else if (unit == "pt") else if (unit == "pt")
style.BorderWidth = tmpf / 0.75f; *dest = tmpf / 0.75f;
else if (unit == "%") else if (unit == "%")
style.BorderWidth = 0; // no support for % in border width *dest = 0; // no support for % in border width
else else
style.BorderWidth = tmpf; *dest = tmpf;
} }
} }
} }
void CCssStyle::applyBorderColor(const std::string &value, CRGBA *dest, const CRGBA &currentColor, const CRGBA &textColor) const
{
if (!dest) return;
if (value == "inherit")
*dest = currentColor;
else if (value == "transparent")
*dest = CRGBA::Transparent;
else if (value == "currentcolor")
*dest = textColor;
else
scanHTMLColor(value.c_str(), *dest);
}
void CCssStyle::applyLineStyle(const std::string &value, CSSLineStyle *dest, const CSSLineStyle &currentStyle) const
{
if (!dest) return;
if (value == "inherit")
*dest = currentStyle;
else if (value == "none")
*dest = CSSLineStyle::NONE;
else if (value == "hidden")
*dest = CSSLineStyle::HIDDEN;
else if (value == "inset")
*dest = CSSLineStyle::INSET;
else if (value == "outset")
*dest = CSSLineStyle::OUTSET;
else if (value == "solid")
*dest = CSSLineStyle::SOLID;
}
void CCssStyle::applyPaddingWidth(const std::string &value, uint32 *dest, const uint32 currentPadding, uint32 fontSize) const
{
if (!dest) return;
if (value == "inherit")
{
*dest = currentPadding;
return;
}
float tmpf;
std::string unit;
if (getCssLength(tmpf, unit, value.c_str()))
{
if (unit == "rem")
*dest = fontSize * tmpf;
else if (unit == "em")
*dest = fontSize * tmpf;
else if (unit == "pt")
*dest = tmpf / 0.75f;
else if (unit == "%")
*dest = 0; // TODO: requires content width, must remember 'unit' type
else
*dest = tmpf;
}
}
// apply style rules
void CCssStyle::apply(CStyleParams &style, const CStyleParams &current) const
{
float tmpf;
TStyle::const_iterator it;
for (it=style.StyleRules.begin(); it != style.StyleRules.end(); ++it)
{
if (it->first == "border-top-width") applyBorderWidth(it->second, &style.BorderTopWidth, current.BorderTopWidth, current.FontSize);
else if (it->first == "border-top-color") applyBorderColor(it->second, &style.BorderTopColor, current.BorderTopColor, current.TextColor);
else if (it->first == "border-top-style") applyLineStyle(it->second, &style.BorderTopStyle, current.BorderTopStyle);
else if (it->first == "border-right-width") applyBorderWidth(it->second, &style.BorderRightWidth, current.BorderRightWidth, current.FontSize);
else if (it->first == "border-right-color") applyBorderColor(it->second, &style.BorderRightColor, current.BorderRightColor, current.TextColor);
else if (it->first == "border-right-style") applyLineStyle(it->second, &style.BorderRightStyle, current.BorderRightStyle);
else if (it->first == "border-bottom-width") applyBorderWidth(it->second, &style.BorderBottomWidth, current.BorderBottomWidth, current.FontSize);
else if (it->first == "border-bottom-color") applyBorderColor(it->second, &style.BorderBottomColor, current.BorderBottomColor, current.TextColor);
else if (it->first == "border-bottom-style") applyLineStyle(it->second, &style.BorderBottomStyle, current.BorderBottomStyle);
else if (it->first == "border-left-width") applyBorderWidth(it->second, &style.BorderLeftWidth, current.BorderLeftWidth, current.FontSize);
else if (it->first == "border-left-color") applyBorderColor(it->second, &style.BorderLeftColor, current.BorderLeftColor, current.TextColor);
else if (it->first == "border-left-style") applyLineStyle(it->second, &style.BorderLeftStyle, current.BorderLeftStyle);
else if (it->first == "padding-top") applyPaddingWidth(it->second, &style.PaddingTop, current.PaddingTop, current.FontSize);
else if (it->first == "padding-right") applyPaddingWidth(it->second, &style.PaddingRight, current.PaddingRight, current.FontSize);
else if (it->first == "padding-bottom") applyPaddingWidth(it->second, &style.PaddingBottom, current.PaddingBottom, current.FontSize);
else if (it->first == "padding-left") applyPaddingWidth(it->second, &style.PaddingLeft, current.PaddingLeft, current.FontSize);
else else
if (it->first == "font-style") if (it->first == "font-style")
{ {
@ -586,7 +688,7 @@ namespace NLGUI
uint px = 0; uint px = 0;
CRGBA color; CRGBA color;
std::vector<std::string> parts; std::vector<std::string> parts;
NLMISC::splitString(it->second, " ", parts); splitParams(it->second, ' ', parts);
if (parts.size() == 1) if (parts.size() == 1)
{ {
success = scanCssLength(parts[0], px); success = scanCssLength(parts[0], px);
@ -635,7 +737,7 @@ namespace NLGUI
prop = prop.substr(0, pos); prop = prop.substr(0, pos);
std::vector<std::string> parts; std::vector<std::string> parts;
NLMISC::splitString(prop, " ", parts); splitParams(prop, ' ', parts);
switch(parts.size()) switch(parts.size())
{ {
case 1: case 1:
@ -834,7 +936,7 @@ namespace NLGUI
// normalize // normalize
std::string val = toLower(trim(it->second)); std::string val = toLower(trim(it->second));
std::vector<std::string> parts; std::vector<std::string> parts;
NLMISC::splitString(val, " ", parts); splitParams(val, ' ', parts);
// check for "repeat repeat" // check for "repeat repeat"
if (parts.size() == 2 && parts[0] == parts[1]) if (parts.size() == 2 && parts[0] == parts[1])
val = parts[0]; val = parts[0];
@ -847,7 +949,7 @@ namespace NLGUI
// normalize // normalize
std::string val = toLower(trim(it->second)); std::string val = toLower(trim(it->second));
std::vector<std::string> parts; std::vector<std::string> parts;
NLMISC::splitString(val, " ", parts); splitParams(val, ' ', parts);
if (parts.size() == 2 && parts[0] == parts[1]) if (parts.size() == 2 && parts[0] == parts[1])
val = parts[0]; val = parts[0];
@ -864,7 +966,8 @@ namespace NLGUI
style.StrikeThrough = current.StrikeThrough; style.StrikeThrough = current.StrikeThrough;
} }
void CCssStyle::parseBackgroundShorthand(const std::string &value, CStyleParams &style) const // ***************************************************************************
void CCssStyle::expandBackgroundShorthand(const std::string &value, TStyle &style) const
{ {
// background: url(image.jpg) top center / 200px 200px no-repeat fixed padding-box content-box red; // background: url(image.jpg) top center / 200px 200px no-repeat fixed padding-box content-box red;
// background-image : url(image.jpg) // background-image : url(image.jpg)
@ -889,9 +992,7 @@ namespace NLGUI
uint partIndex = 0; uint partIndex = 0;
std::vector<std::string> parts; std::vector<std::string> parts;
std::vector<std::string>::iterator it; std::vector<std::string>::iterator it;
// FIXME: this will fail if url() contains ' ' chars splitParams(value, ' ', parts);
// FIXME: this will also fail on 'background: rgb(255, 0, 0)'
NLMISC::splitString(value, " ", parts);
bool failed = false; bool failed = false;
bool allowSize = false; bool allowSize = false;
@ -1142,16 +1243,16 @@ namespace NLGUI
{ {
if (props[i] == "background-position") if (props[i] == "background-position")
{ {
style.StyleRules["background-position-x"] = bgPositionX; style["background-position-x"] = bgPositionX;
style.StyleRules["background-position-y"] = bgPositionY; style["background-position-y"] = bgPositionY;
} }
else if (props[i] == "background-clip") else if (props[i] == "background-clip")
{ {
style.StyleRules["background-clip"] = bgClipValue; style["background-clip"] = bgClipValue;
} }
else else
{ {
style.StyleRules[props[i]] = values[i]; style[props[i]] = values[i];
} }
} }
else else
@ -1159,42 +1260,343 @@ namespace NLGUI
// fill in default if one is set // fill in default if one is set
if (props[i] == "background-image") if (props[i] == "background-image")
{ {
style.StyleRules[props[i]] = "none"; style[props[i]] = "none";
} }
else if (props[i] == "background-position") else if (props[i] == "background-position")
{ {
style.StyleRules[props[i]] = "0% 0%"; style[props[i]] = "0% 0%";
style.StyleRules["background-position-x"] = "left 0%"; style["background-position-x"] = "left 0%";
style.StyleRules["background-position-y"] = "top 0%"; style["background-position-y"] = "top 0%";
} }
else if (props[i] == "background-size") else if (props[i] == "background-size")
{ {
style.StyleRules[props[i]] = "auto auto"; style[props[i]] = "auto auto";
} }
else if (props[i] == "background-repeat") else if (props[i] == "background-repeat")
{ {
style.StyleRules[props[i]] = "repeat"; style[props[i]] = "repeat";
} }
else if(props[i] == "background-attachment") else if(props[i] == "background-attachment")
{ {
style.StyleRules[props[i]] = "scroll"; style[props[i]] = "scroll";
} }
else if(props[i] == "background-origin") else if(props[i] == "background-origin")
{ {
style.StyleRules[props[i]] = "padding-box"; style[props[i]] = "padding-box";
} }
else if (props[i] == "background-clip") else if (props[i] == "background-clip")
{ {
if (bgClipFound) if (bgClipFound)
style.StyleRules[props[i]] = bgClipValue; style[props[i]] = bgClipValue;
else else
style.StyleRules[props[i]] = "border-box"; style[props[i]] = "border-box";
} }
else if (props[i] == "background-color") else if (props[i] == "background-color")
{ {
style.StyleRules[props[i]] = "transparent"; style[props[i]] = "transparent";
}
}
}
}
// ***************************************************************************
bool CCssStyle::getShorthandIndices(const uint32 size, uint8 &t, uint8 &r, uint8 &b, uint8 &l) const
{
if (size == 0 || size > 4) return false;
if (size == 1)
{
t = r = b = l = 0;
}
else if (size == 2)
{
t = b = 0;
r = l = 1;
}
else if (size == 3)
{
t = 0;
r = l = 1;
b = 2;
}
else // size == 4
{
t = 0;
r = 1;
b = 2;
l = 3;
}
return true;
}
// ***************************************************************************
bool CCssStyle::tryBorderWidthShorthand(const std::string &prop, const std::string &value, TStyle &style) const
{
std::vector<std::string> parts;
splitParams(toLower(value), ' ', parts);
float tmpf;
std::string unit;
// verify that parts are valid
uint8 maxSize = (prop == "border" || prop == "border-width") ? 4 : 1;
bool hasTop = (prop == "border" || prop == "border-width" || prop == "border-top" || prop == "border-top-width");
bool hasRight = (prop == "border" || prop == "border-width" || prop == "border-right" || prop == "border-right-width");
bool hasBottom = (prop == "border" || prop == "border-width" || prop == "border-bottom" || prop == "border-bottom-width");
bool hasLeft = (prop == "border" || prop == "border-width" || prop == "border-left" || prop == "border-left-width");
if (parts.size() > maxSize || (!hasTop && !hasRight && !hasBottom && !hasLeft))
{
return false;
}
for(uint i = 0; i< parts.size(); ++i)
{
if (parts[i] != "inherit" && parts[i] != "thin" && parts[i] != "medium" && parts[i] != "thick"
&& !getCssLength(tmpf, unit, parts[i].c_str()))
{
return false;
}
}
uint8 t, r, b, l;
if (!getShorthandIndices(parts.size(), t, r, b, l)) return false;
if (hasTop) style["border-top-width"] = parts[t];
if (hasRight) style["border-right-width"] = parts[r];
if (hasBottom) style["border-bottom-width"] = parts[b];
if (hasLeft) style["border-left-width"] = parts[l];
return true;
}
// ***************************************************************************
bool CCssStyle::tryBorderStyleShorthand(const std::string &prop, const std::string &value, TStyle &style) const
{
std::vector<std::string> parts;
splitParams(toLower(value), ' ', parts);
// verify that parts are valid
uint8 maxSize = (prop == "border" || prop == "border-style") ? 4 : 1;
bool hasTop = (prop == "border" || prop == "border-style" || prop == "border-top" || prop == "border-top-style");
bool hasRight = (prop == "border" || prop == "border-style" || prop == "border-right" || prop == "border-right-style");
bool hasBottom = (prop == "border" || prop == "border-style" || prop == "border-bottom" || prop == "border-bottom-style");
bool hasLeft = (prop == "border" || prop == "border-style" || prop == "border-left" || prop == "border-left-style");
if (parts.size() > maxSize || (!hasTop && !hasRight && !hasBottom && !hasLeft))
{
return false;
}
const uint nbValues = 10;
std::string values[nbValues] = {"none", "hidden", "dotted", "dashed",
"solid", "double", "groove", "ridge", "inset", "outset"};
for(uint i = 0; i < parts.size(); ++i)
{
bool found = false;
for(uint iValue = 0; iValue < nbValues; ++iValue)
{
if (parts[i] == values[iValue])
{
found = true;
break;
}
}
if (!found)
{
// invalid rule
return false;
}
}
uint8 t, r, b, l;
if (!getShorthandIndices(parts.size(), t, r, b, l)) return false;
if (hasTop) style["border-top-style"] = parts[t];
if (hasRight) style["border-right-style"] = parts[r];
if (hasBottom) style["border-bottom-style"] = parts[b];
if (hasLeft) style["border-left-style"] = parts[l];
return true;
}
// ***************************************************************************
bool CCssStyle::tryBorderColorShorthand(const std::string &prop, const std::string &value, TStyle &style) const
{
std::vector<std::string> parts;
splitParams(toLower(value), ' ', parts);
CRGBA color;
// verify that parts are valid
uint8 maxSize = (prop == "border" || prop == "border-color") ? 4 : 1;
bool hasTop = (prop == "border" || prop == "border-color" || prop == "border-top" || prop == "border-top-color");
bool hasRight = (prop == "border" || prop == "border-color" || prop == "border-right" || prop == "border-right-color");
bool hasBottom = (prop == "border" || prop == "border-color" || prop == "border-bottom" || prop == "border-bottom-color");
bool hasLeft = (prop == "border" || prop == "border-color" || prop == "border-left" || prop == "border-left-color");
if (parts.size() > maxSize || (!hasTop && !hasRight && !hasBottom && !hasLeft))
{
return false;
}
for(uint i = 0; i< parts.size(); ++i)
{
if (!scanHTMLColor(parts[i].c_str(), color) && parts[i] != "currentcolor" && parts[i] != "inherit")
return false;
}
uint8 t, r, b, l;
if (!getShorthandIndices(parts.size(), t, r, b, l)) return false;
if (hasTop) style["border-top-color"] = parts[t];
if (hasRight) style["border-right-color"] = parts[r];
if (hasBottom) style["border-bottom-color"] = parts[b];
if (hasLeft) style["border-left-color"] = parts[l];
return true;
}
// ***************************************************************************
void CCssStyle::expandBorderShorthand(const std::string &prop, const std::string &value, TStyle &style) const
{
// border: 1px solid #000;
bool hasTop = (prop == "border" || prop == "border-top");
bool hasRight = (prop == "border" || prop == "border-right");
bool hasBottom = (prop == "border" || prop == "border-bottom");
bool hasLeft = (prop == "border" || prop == "border-left");
bool foundWidth = false;
bool foundStyle = false;
bool foundColor = false;
TStyle borderStyle;
std::vector<std::string> parts;
splitParams(toLower(value), ' ', parts);
for(uint index = 0; index < parts.size(); ++index)
{
bool matched = false;
if (!foundWidth)
{
matched = foundWidth = tryBorderWidthShorthand(prop, parts[index], borderStyle);
} }
if (!matched && !foundStyle)
{
matched = foundStyle = tryBorderStyleShorthand(prop, parts[index], borderStyle);
}
if (!matched && !foundColor)
{
matched = foundColor = tryBorderColorShorthand(prop, parts[index], borderStyle);
} }
// invalid rule if nothing gets matched
if (!matched)
{
return;
}
}
// apply rules that are present
TStyle::const_iterator it = borderStyle.begin();
while(it != borderStyle.end())
{
style[it->first] = it->second;
++it;
}
// reset those not present
if (!foundWidth)
{
if (hasTop) style["border-top-width"] = "medium";
if (hasRight) style["border-right-width"] = "medium";
if (hasBottom) style["border-bottom-width"] = "medium";
if (hasLeft) style["border-left-width"] = "medium";
}
//
if (!foundStyle)
{
if (hasTop) style["border-top-style"] = "none";
if (hasRight) style["border-right-style"] = "none";
if (hasBottom) style["border-bottom-style"] = "none";
if (hasLeft) style["border-left-style"] = "none";
}
//
if (!foundColor)
{
if (hasTop) style["border-top-color"] = "currentcolor";
if (hasRight) style["border-right-color"] = "currentcolor";
if (hasBottom) style["border-bottom-color"] = "currentcolor";
if (hasLeft) style["border-left-color"] = "currentcolor";
}
}
// ***************************************************************************
void CCssStyle::expandPaddingShorthand(const std::string &value, TStyle &style) const
{
std::vector<std::string> parts;
splitParams(toLower(value), ' ', parts);
uint8 t, r, b, l;
if (!getShorthandIndices(parts.size(), t, r, b, l))
return;
style["padding-top"] = parts[t];
style["padding-right"] = parts[r];
style["padding-bottom"] = parts[b];
style["padding-left"] = parts[l];
}
// ***************************************************************************
void CCssStyle::expandShorthand(const std::string &prop, const std::string &value, TStyle &style) const
{
// if shorthand matches, then remove it after expansion
bool keep = false;
if (prop == "background")
{
expandBackgroundShorthand(value, style);
}
else if (prop == "background-scale")
{
// replace old ryzom specific rule with background-size
if (value != "1")
{
style["background-size"] = "auto";
}
else
{
style["background-size"] = "100%";
}
}
else if (prop == "border"
|| prop == "border-top" || prop == "border-right"
|| prop == "border-bottom" || prop == "border-left")
{
// TODO: use enum or bitmap constant instead of passing a string name (prop)
expandBorderShorthand(prop, value, style);
}
else if (prop == "border-width")
{
tryBorderWidthShorthand(prop, value, style);
}
else if (prop == "border-style")
{
tryBorderStyleShorthand(prop, value, style);
}
else if (prop == "border-color")
{
tryBorderColorShorthand(prop, value, style);
}
else if (prop == "padding")
{
expandPaddingShorthand(value, style);
}
else
{
keep = true;
}
if (!keep)
{
TStyle::iterator pos = style.find(prop);
if (pos != style.end())
style.erase(pos);
} }
} }

@ -52,6 +52,7 @@
#include "nel/gui/html_element.h" #include "nel/gui/html_element.h"
#include "nel/gui/css_style.h" #include "nel/gui/css_style.h"
#include "nel/gui/css_parser.h" #include "nel/gui/css_parser.h"
#include "nel/gui/css_border_renderer.h"
#include <curl/curl.h> #include <curl/curl.h>
@ -286,9 +287,10 @@ namespace NLGUI
{ {
btn->setTextureOver(file); btn->setTextureOver(file);
} }
return;
} }
else
{
CViewBitmap *btm = dynamic_cast<CViewBitmap*>(view); CViewBitmap *btm = dynamic_cast<CViewBitmap*>(view);
if(btm) if(btm)
{ {
@ -296,9 +298,10 @@ namespace NLGUI
btm->invalidateCoords(); btm->invalidateCoords();
btm->invalidateContent(); btm->invalidateContent();
paragraphChange(); paragraphChange();
return;
} }
else
{
CGroupCell *btgc = dynamic_cast<CGroupCell*>(view); CGroupCell *btgc = dynamic_cast<CGroupCell*>(view);
if(btgc) if(btgc)
{ {
@ -306,8 +309,16 @@ namespace NLGUI
btgc->invalidateCoords(); btgc->invalidateCoords();
btgc->invalidateContent(); btgc->invalidateContent();
paragraphChange(); paragraphChange();
return;
} }
}
CGroupTable *table = dynamic_cast<CGroupTable*>(view);
if (table)
{
table->setTexture(file);
return;
} }
} }
@ -433,10 +444,9 @@ namespace NLGUI
{ {
if (pVT) if (pVT)
{ {
pVT->setFontSize(style.FontSize);
pVT->setColor(style.TextColor); pVT->setColor(style.TextColor);
pVT->setFontName(style.FontFamily); pVT->setFontName(style.FontFamily);
pVT->setFontSize(style.FontSize); pVT->setFontSize(style.FontSize, false);
pVT->setEmbolden(style.FontWeight >= FONT_WEIGHT_BOLD); pVT->setEmbolden(style.FontWeight >= FONT_WEIGHT_BOLD);
pVT->setOblique(style.FontOblique); pVT->setOblique(style.FontOblique);
pVT->setUnderlined(style.Underlined); pVT->setUnderlined(style.Underlined);
@ -649,10 +659,12 @@ namespace NLGUI
if (download.type == StylesheetType) if (download.type == StylesheetType)
{ {
// no tmpfile if file was already in cache if (CFile::fileExists(tmpfile))
if (CFile::fileExists(tmpfile) && CFile::fileExists(download.dest)) {
if (CFile::fileExists(download.dest))
{ {
CFile::deleteFile(download.dest); CFile::deleteFile(download.dest);
}
CFile::moveFile(download.dest, tmpfile); CFile::moveFile(download.dest, tmpfile);
} }
cssDownloadFinished(download.url, download.dest); cssDownloadFinished(download.url, download.dest);
@ -697,7 +709,7 @@ namespace NLGUI
} }
// Add a image download request in the multi_curl // Add a image download request in the multi_curl
void CGroupHTML::addImageDownload(const string &url, CViewBase *img, const CStyleParams &style, TImageType type) void CGroupHTML::addImageDownload(const string &url, CViewBase *img, const CStyleParams &style, TImageType type, const std::string &placeholder)
{ {
std::string finalUrl; std::string finalUrl;
img->setModulateGlobalColor(style.GlobalColor); img->setModulateGlobalColor(style.GlobalColor);
@ -723,8 +735,7 @@ namespace NLGUI
std::string temp = dest; std::string temp = dest;
if (!CFile::fileExists(temp)) if (!CFile::fileExists(temp))
{ {
// TODO: placeholder temp = placeholder;
temp = "web_del.tga";
} }
setImage(img, temp, type); setImage(img, temp, type);
setImageSize(img, style); setImageSize(img, style);
@ -1144,8 +1155,10 @@ namespace NLGUI
case HTML_STRONG: renderPseudoElement(":before", elm); break; case HTML_STRONG: renderPseudoElement(":before", elm); break;
case HTML_STYLE: htmlSTYLE(elm); break; case HTML_STYLE: htmlSTYLE(elm); break;
case HTML_TABLE: htmlTABLE(elm); break; case HTML_TABLE: htmlTABLE(elm); break;
case HTML_TBODY: renderPseudoElement(":before", elm); break;
case HTML_TD: htmlTD(elm); break; case HTML_TD: htmlTD(elm); break;
case HTML_TEXTAREA: htmlTEXTAREA(elm); break; case HTML_TEXTAREA: htmlTEXTAREA(elm); break;
case HTML_TFOOT: renderPseudoElement(":before", elm); break;
case HTML_TH: htmlTH(elm); break; case HTML_TH: htmlTH(elm); break;
case HTML_TITLE: htmlTITLE(elm); break; case HTML_TITLE: htmlTITLE(elm); break;
case HTML_TR: htmlTR(elm); break; case HTML_TR: htmlTR(elm); break;
@ -1206,7 +1219,9 @@ namespace NLGUI
case HTML_STYLE: htmlSTYLEend(elm); break; case HTML_STYLE: htmlSTYLEend(elm); break;
case HTML_TABLE: htmlTABLEend(elm); break; case HTML_TABLE: htmlTABLEend(elm); break;
case HTML_TD: htmlTDend(elm); break; case HTML_TD: htmlTDend(elm); break;
case HTML_TBODY: renderPseudoElement(":after", elm); break;
case HTML_TEXTAREA: htmlTEXTAREAend(elm); break; case HTML_TEXTAREA: htmlTEXTAREAend(elm); break;
case HTML_TFOOT: renderPseudoElement(":after", elm); break;
case HTML_TH: htmlTHend(elm); break; case HTML_TH: htmlTHend(elm); break;
case HTML_TITLE: htmlTITLEend(elm); break; case HTML_TITLE: htmlTITLEend(elm); break;
case HTML_TR: htmlTRend(elm); break; case HTML_TR: htmlTRend(elm); break;
@ -1493,6 +1508,9 @@ namespace NLGUI
initImageDownload(); initImageDownload();
initBnpDownload(); initBnpDownload();
// setup default browser style
setProperty("browser_css_file", "browser.css");
} }
// *************************************************************************** // ***************************************************************************
@ -1771,6 +1789,11 @@ namespace NLGUI
{ {
return toString( _TimeoutValue ); return toString( _TimeoutValue );
} }
else
if( name == "browser_css_file" )
{
return _BrowserCssFile;
}
else else
return CGroupScrollText::getProperty( name ); return CGroupScrollText::getProperty( name );
} }
@ -2144,6 +2167,36 @@ namespace NLGUI
_TimeoutValue = d; _TimeoutValue = d;
return; return;
} }
else
if( name == "browser_css_file")
{
_BrowserStyle.reset();
_BrowserCssFile = value;
if (!_BrowserCssFile.empty())
{
std::string filename = CPath::lookup(_BrowserCssFile, false, true, true);
if (!filename.empty())
{
CIFile in;
if (in.open(filename))
{
std::string css;
if (in.readAll(css))
_BrowserStyle.parseStylesheet(css);
else
nlwarning("Failed to read browser css from '%s'", filename.c_str());
}
else
{
nlwarning("Failed to open browser css file '%s'", filename.c_str());
}
}
else
{
nlwarning("Browser css file '%s' not found", _BrowserCssFile.c_str());
}
}
}
else else
CGroupScrollText::setProperty( name, value ); CGroupScrollText::setProperty( name, value );
} }
@ -2217,6 +2270,7 @@ namespace NLGUI
xmlSetProp( node, BAD_CAST "browse_redo", BAD_CAST _BrowseRedoButton.c_str() ); xmlSetProp( node, BAD_CAST "browse_redo", BAD_CAST _BrowseRedoButton.c_str() );
xmlSetProp( node, BAD_CAST "browse_refresh", BAD_CAST _BrowseRefreshButton.c_str() ); xmlSetProp( node, BAD_CAST "browse_refresh", BAD_CAST _BrowseRefreshButton.c_str() );
xmlSetProp( node, BAD_CAST "timeout", BAD_CAST toString( _TimeoutValue ).c_str() ); xmlSetProp( node, BAD_CAST "timeout", BAD_CAST toString( _TimeoutValue ).c_str() );
xmlSetProp( node, BAD_CAST "browser_css_file", BAD_CAST _BrowserCssFile.c_str() );
return node; return node;
} }
@ -2400,6 +2454,12 @@ namespace NLGUI
if(ptr) if(ptr)
fromString((const char*)ptr, _TimeoutValue); fromString((const char*)ptr, _TimeoutValue);
ptr = xmlGetProp (cur, (xmlChar*)"browser_css_file");
if (ptr)
{
setProperty("browser_css_file", (const char *)ptr);
}
return true; return true;
} }
@ -2528,6 +2588,7 @@ namespace NLGUI
// go // go
_URL = uri.toString(); _URL = uri.toString();
_BrowseNextTime = true; _BrowseNextTime = true;
_WaitingForStylesheet = false;
// if a BrowseTree is bound to us, try to select the node that opens this URL (auto-locate) // if a BrowseTree is bound to us, try to select the node that opens this URL (auto-locate)
if(!_BrowseTree.empty()) if(!_BrowseTree.empty())
@ -2597,11 +2658,21 @@ namespace NLGUI
// Keep this char ? // Keep this char ?
bool keep = true; bool keep = true;
// char is between table elements
// TODO: only whitespace is handled, text is added to either TD, or after TABLE (should be before)
bool tableWhitespace = getTable() && (_Cells.empty() || _Cells.back() == NULL);
switch (input) switch (input)
{ {
// Return / tab only in <PRE> mode // Return / tab only in <PRE> mode
case '\t': case '\t':
case '\n': case '\n':
{
if (tableWhitespace)
{
keep = false;
}
else
{ {
// Get the last char // Get the last char
ucchar lastChar = lastCharParam; ucchar lastChar = lastCharParam;
@ -2612,8 +2683,15 @@ namespace NLGUI
if(!getPRE()) if(!getPRE())
input = ' '; input = ' ';
} }
}
break; break;
case ' ': case ' ':
{
if (tableWhitespace)
{
keep = false;
}
else
{ {
// Get the last char // Get the last char
ucchar lastChar = lastCharParam; ucchar lastChar = lastCharParam;
@ -2623,6 +2701,7 @@ namespace NLGUI
(lastChar != (ucchar)'\n') && (lastChar != (ucchar)'\n') &&
(lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0)); (lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0));
} }
}
break; break;
case 0xd: case 0xd:
keep = false; keep = false;
@ -3407,6 +3486,7 @@ namespace NLGUI
CViewBitmap *bitmap = dynamic_cast<CViewBitmap*> (view); CViewBitmap *bitmap = dynamic_cast<CViewBitmap*> (view);
if (bitmap) if (bitmap)
{ {
// TODO: background color should have separate bitmap from background texture
// Change the background color // Change the background color
bitmap->setColor (bgcolor); bitmap->setColor (bgcolor);
bitmap->setModulateGlobalColor(false); bitmap->setModulateGlobalColor(false);
@ -3429,6 +3509,7 @@ namespace NLGUI
bitmap->setPosRef(Hotspot_TL); bitmap->setPosRef(Hotspot_TL);
bitmap->setX(0); bitmap->setX(0);
bitmap->setY(0); bitmap->setY(0);
// FIXME: renders behind container background
bitmap->setRenderLayer(-2); bitmap->setRenderLayer(-2);
bitmap->setScale(scale); bitmap->setScale(scale);
bitmap->setTile(tile); bitmap->setTile(tile);
@ -3439,7 +3520,7 @@ namespace NLGUI
else else
bitmap->setSizeRef(""); bitmap->setSizeRef("");
addImageDownload(bgtex, view); addImageDownload(bgtex, view, CStyleParams(), TImageType::NormalImage, "");
} }
} }
} }
@ -4084,7 +4165,7 @@ namespace NLGUI
void CGroupHTML::renderDocument() void CGroupHTML::renderDocument()
{ {
if (!_StylesheetQueue.empty()) if (!Curls.empty() && !_StylesheetQueue.empty())
{ {
// waiting for stylesheets to finish downloading // waiting for stylesheets to finish downloading
return; return;
@ -4140,6 +4221,8 @@ namespace NLGUI
removeContent(); removeContent();
endBuild(); endBuild();
success = false;
} }
else else
{ {
@ -4924,49 +5007,7 @@ namespace NLGUI
_WaitingForStylesheet = false; _WaitingForStylesheet = false;
_StylesheetQueue.clear(); _StylesheetQueue.clear();
_Style.reset(); _Style.reset();
_Style = _BrowserStyle;
std::string css;
// TODO: browser css
css += "html { background-color: " + getRGBAString(BgColor) + "; color: " + getRGBAString(TextColor) + "; font-size: " + toString(TextFontSize) + "px;}";
css += "a { color: " + getRGBAString(LinkColor) + "; text-decoration: underline; -ryzom-modulate-color: "+toString(LinkColorGlobalColor)+";}";
css += "h1 { color: " + getRGBAString(H1Color) + "; font-size: "+ toString("%d", H1FontSize) + "px; -ryzom-modulate-color: "+toString(H1ColorGlobalColor)+";}";
css += "h2 { color: " + getRGBAString(H2Color) + "; font-size: "+ toString("%d", H2FontSize) + "px; -ryzom-modulate-color: "+toString(H2ColorGlobalColor)+";}";
css += "h3 { color: " + getRGBAString(H3Color) + "; font-size: "+ toString("%d", H3FontSize) + "px; -ryzom-modulate-color: "+toString(H3ColorGlobalColor)+";}";
css += "h4 { color: " + getRGBAString(H4Color) + "; font-size: "+ toString("%d", H4FontSize) + "px; -ryzom-modulate-color: "+toString(H4ColorGlobalColor)+";}";
css += "h5 { color: " + getRGBAString(H5Color) + "; font-size: "+ toString("%d", H5FontSize) + "px; -ryzom-modulate-color: "+toString(H5ColorGlobalColor)+";}";
css += "h6 { color: " + getRGBAString(H6Color) + "; font-size: "+ toString("%d", H6FontSize) + "px; -ryzom-modulate-color: "+toString(H6ColorGlobalColor)+";}";
css += "input[type=\"text\"] { color: " + getRGBAString(TextColor) + "; font-size: " + toString("%d", TextFontSize) + "px; font-weight: normal; text-shadow: 1px 1px #000;}";
css += "pre { font-family: monospace;}";
// th { text-align: center; } - overwrites align property
css += "th { font-weight: bold; }";
css += "textarea { color: " + getRGBAString(TextColor) + "; font-weight: normal; font-size: " + toString("%d", TextFontSize) + "px; text-shadow: 1px 1px #000;}";
css += "del { text-decoration: line-through;}";
css += "u { text-decoration: underline;}";
css += "em { font-style: italic; }";
css += "strong { font-weight: bold; }";
css += "small { font-size: smaller;}";
css += "dt { font-weight: bold; }";
css += "hr { color: rgb(120, 120, 120);}";
// block level elements
css += "address, article, aside, blockquote, details, dialog, dd, div, dl, dt, fieldset, figcaption, figure,";
css += "footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, li, main, nav, ol, p, pre, section, table,";
css += "ul { display: block; }";
css += "table { display: table; }";
// td { padding: 1px;} - overwrites cellpadding attribute
// table { border-spacing: 2px;} - overwrites cellspacing attribute
css += "table { border-collapse: separate;}";
// webkit pseudo elements
css += "meter::-webkit-meter-bar, meter::-webkit-optimum-value, meter::-webkit-suboptimum-value, meter::-webkit-even-less-good-value { background: none; }";
css += "meter::-webkit-meter-bar { background-color: rgb(100, 100, 100); width: 5em; height: 1em;}";
css += "meter::-webkit-meter-optimum-value { background-color: rgb(80, 220, 80); }";
css += "meter::-webkit-meter-suboptimum-value { background-color: rgb(220, 220, 80); }";
css += "meter::-webkit-meter-even-less-good-value { background-color: rgb(220, 80, 80); }";
// webkit pseudo elements
css += "progress::-webkit-progress-bar, progress::-webkit-progress-value { background: none; }";
css += "progress::-webkit-progress-bar { background-color: rgb(230, 230, 230); width: 10em; height: 1em; }";
css += "progress::-webkit-progress-value { background-color: rgb(0, 100, 180);}";
_Style.parseStylesheet(css);
} }
// *************************************************************************** // ***************************************************************************
@ -5245,9 +5286,7 @@ namespace NLGUI
{ {
CGroupHTML::CCellParams cellParams; CGroupHTML::CCellParams cellParams;
if (!_CellParams.empty() && inherit) if (!_CellParams.empty() && inherit)
{
cellParams = _CellParams.back(); cellParams = _CellParams.back();
}
if (_Style.hasStyle("background-color")) if (_Style.hasStyle("background-color"))
cellParams.BgColor = _Style.Current.BackgroundColor; cellParams.BgColor = _Style.Current.BackgroundColor;
@ -5260,6 +5299,11 @@ namespace NLGUI
if (elm.hasNonEmptyAttribute("l_margin")) if (elm.hasNonEmptyAttribute("l_margin"))
fromString(elm.getAttribute("l_margin"), cellParams.LeftMargin); fromString(elm.getAttribute("l_margin"), cellParams.LeftMargin);
if (_Style.hasStyle("height"))
cellParams.Height = _Style.Current.Height;
else if (elm.hasNonEmptyAttribute("height"))
fromString(elm.getAttribute("height"), cellParams.Height);
{ {
std::string align; std::string align;
// having text-align on table/tr should not override td align attribute // having text-align on table/tr should not override td align attribute
@ -5989,16 +6033,20 @@ namespace NLGUI
ucstring ucValue; ucstring ucValue;
ucValue.fromUtf8(elm.getAttribute("value")); ucValue.fromUtf8(elm.getAttribute("value"));
uint size = 120; uint size = 20;
uint maxlength = 1024; uint maxlength = 1024;
if (elm.hasNonEmptyAttribute("size")) if (elm.hasNonEmptyAttribute("size"))
fromString(elm.getAttribute("size"), size); fromString(elm.getAttribute("size"), size);
if (elm.hasNonEmptyAttribute("maxlength")) if (elm.hasNonEmptyAttribute("maxlength"))
fromString(elm.getAttribute("maxlength"), maxlength); fromString(elm.getAttribute("maxlength"), maxlength);
// ryzom client used to have 'size' attribute in pixels, (12 == was default font size)
if (_Style.hasStyle("-ryzom-input-size-px") && _Style.getStyle("-ryzom-input-size-px") == "true")
size = size / 12;
string textTemplate(!templateName.empty() ? templateName : DefaultFormTextGroup); string textTemplate(!templateName.empty() ? templateName : DefaultFormTextGroup);
// Add the editbox // Add the editbox
CInterfaceGroup *textArea = addTextArea (textTemplate, name.c_str (), 1, size/12, false, ucValue, maxlength); CInterfaceGroup *textArea = addTextArea (textTemplate, name.c_str (), 1, size, false, ucValue, maxlength);
if (textArea) if (textArea)
{ {
// Add the text area to the form // Add the text area to the form
@ -6213,7 +6261,8 @@ namespace NLGUI
// width: 5em, height: 1em // width: 5em, height: 1em
uint32 width = _Style.Current.Width > -1 ? _Style.Current.Width : _Style.Current.FontSize * 5; uint32 width = _Style.Current.Width > -1 ? _Style.Current.Width : _Style.Current.FontSize * 5;
uint32 height = _Style.Current.Height > -1 ? _Style.Current.Height : _Style.Current.FontSize; uint32 height = _Style.Current.Height > -1 ? _Style.Current.Height : _Style.Current.FontSize;
uint32 border = _Style.Current.BorderWidth > -1 ? _Style.Current.BorderWidth : 0; // FIXME: only using border-top
uint32 border = _Style.Current.BorderTopWidth > -1 ? _Style.Current.BorderTopWidth : 0;
uint barw = (uint) (width * meter.getValueRatio()); uint barw = (uint) (width * meter.getValueRatio());
CRGBA bgColor = meter.getBarColor(elm, _Style); CRGBA bgColor = meter.getBarColor(elm, _Style);
@ -6428,7 +6477,8 @@ namespace NLGUI
// width: 10em, height: 1em // width: 10em, height: 1em
uint32 width = _Style.Current.Width > -1 ? _Style.Current.Width : _Style.Current.FontSize * 10; uint32 width = _Style.Current.Width > -1 ? _Style.Current.Width : _Style.Current.FontSize * 10;
uint32 height = _Style.Current.Height > -1 ? _Style.Current.Height : _Style.Current.FontSize; uint32 height = _Style.Current.Height > -1 ? _Style.Current.Height : _Style.Current.FontSize;
uint32 border = _Style.Current.BorderWidth > -1 ? _Style.Current.BorderWidth : 0; // FIXME: only using border-top
uint32 border = _Style.Current.BorderTopWidth > -1 ? _Style.Current.BorderTopWidth : 0;
uint barw = (uint) (width * progress.getValueRatio()); uint barw = (uint) (width * progress.getValueRatio());
CRGBA bgColor = progress.getBarColor(elm, _Style); CRGBA bgColor = progress.getBarColor(elm, _Style);
@ -6503,7 +6553,7 @@ namespace NLGUI
sb->setMinH(_Style.Current.Height); sb->setMinH(_Style.Current.Height);
sb->setMaxVisibleLine(size); sb->setMaxVisibleLine(size);
sb->setFontSize(_Style.Current.FontSize); sb->setFontSize(_Style.Current.FontSize, false);
} }
entry.SelectBox = sb; entry.SelectBox = sb;
@ -6576,36 +6626,82 @@ namespace NLGUI
fromString(elm.getAttribute("cellpadding"), table->CellPadding); fromString(elm.getAttribute("cellpadding"), table->CellPadding);
if (_Style.hasStyle("width")) if (_Style.hasStyle("width"))
{
// _Style.Width does not handle '%' unit currently
if (_Style.Current.Width > 0)
{
table->ForceWidthMin = _Style.Current.Width;
table->TableRatio = 0;
}
else
{
getPercentage (table->ForceWidthMin, table->TableRatio, _Style.getStyle("width").c_str()); getPercentage (table->ForceWidthMin, table->TableRatio, _Style.getStyle("width").c_str());
}
}
else if (elm.hasNonEmptyAttribute("width")) else if (elm.hasNonEmptyAttribute("width"))
{
getPercentage (table->ForceWidthMin, table->TableRatio, elm.getAttribute("width").c_str()); getPercentage (table->ForceWidthMin, table->TableRatio, elm.getAttribute("width").c_str());
}
if (_Style.hasStyle("border") || _Style.hasStyle("border-width")) // border from css or from attribute
{ {
table->Border = _Style.Current.BorderWidth; uint32 borderWidth = 0;
} CRGBA borderColor = CRGBA::Transparent;
else if (elm.hasAttribute("border"))
if (elm.hasAttribute("border"))
{ {
std::string s = elm.getAttribute("border"); std::string s = elm.getAttribute("border");
if (s.empty()) if (s.empty())
table->Border = 1; borderWidth = 1;
else else
fromString(elm.getAttribute("border"), table->Border); fromString(elm.getAttribute("border"), borderWidth);
}
if (_Style.hasStyle("border-color")) if (elm.hasNonEmptyAttribute("bordercolor"))
{ scanHTMLColor(elm.getAttribute("bordercolor").c_str(), borderColor);
std::string s = toLower(_Style.getStyle("border-color"));
if (s == "currentcolor")
table->BorderColor = _Style.Current.TextColor;
else else
scanHTMLColor(s.c_str(), table->BorderColor); borderColor = CRGBA(128, 128, 128, 255);
table->CellBorder = (borderWidth > 0);
table->Border->setWidth(borderWidth, borderWidth, borderWidth, borderWidth);
table->Border->setColor(borderColor, borderColor, borderColor, borderColor);
table->Border->setStyle(CSSLineStyle::OUTSET, CSSLineStyle::OUTSET, CSSLineStyle::OUTSET, CSSLineStyle::OUTSET);
} }
else if (elm.hasNonEmptyAttribute("bordercolor")) else
{ {
scanHTMLColor(elm.getAttribute("bordercolor").c_str(), table->BorderColor); table->CellBorder = false;
} }
if (_Style.hasStyle("border-top-width")) table->Border->TopWidth = _Style.Current.BorderTopWidth;
if (_Style.hasStyle("border-right-width")) table->Border->RightWidth = _Style.Current.BorderRightWidth;
if (_Style.hasStyle("border-bottom-width")) table->Border->BottomWidth = _Style.Current.BorderBottomWidth;
if (_Style.hasStyle("border-left-width")) table->Border->LeftWidth = _Style.Current.BorderLeftWidth;
if (_Style.hasStyle("border-top-color")) table->Border->TopColor = _Style.Current.BorderTopColor;
if (_Style.hasStyle("border-right-color")) table->Border->RightColor = _Style.Current.BorderRightColor;
if (_Style.hasStyle("border-bottom-color")) table->Border->BottomColor = _Style.Current.BorderBottomColor;
if (_Style.hasStyle("border-left-color")) table->Border->LeftColor = _Style.Current.BorderLeftColor;
if (_Style.hasStyle("border-top-style")) table->Border->TopStyle = _Style.Current.BorderTopStyle;
if (_Style.hasStyle("border-right-style")) table->Border->RightStyle = _Style.Current.BorderRightStyle;
if (_Style.hasStyle("border-bottom-style")) table->Border->BottomStyle = _Style.Current.BorderBottomStyle;
if (_Style.hasStyle("border-left-style")) table->Border->LeftStyle = _Style.Current.BorderLeftStyle;
}
if (_Style.hasStyle("background-image"))
{
if (_Style.checkStyle("background-repeat", "repeat"))
table->setTextureTile(true);
if (_Style.checkStyle("background-size", "100%"))
table->setTextureScale(true);
string image = _Style.getStyle("background-image");
addImageDownload(image, table, CStyleParams(), TImageType::NormalImage, "");
}
// setting ModulateGlobalColor must be after addImageDownload
if (_Style.checkStyle("-ryzom-modulate-bgcolor", "true"))
table->setModulateGlobalColor(true);
table->setMarginLeft(getIndent()); table->setMarginLeft(getIndent());
addHtmlGroup (table, 0); addHtmlGroup (table, 0);
@ -6633,9 +6729,21 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CGroupHTML::htmlTD(const CHtmlElement &elm) void CGroupHTML::htmlTD(const CHtmlElement &elm)
{ {
CRGBA rowColor = CRGBA::Transparent;
// remember row color so we can blend it with cell color
if (!_CellParams.empty())
rowColor = _CellParams.back().BgColor;
// Get cells parameters // Get cells parameters
getCellsParameters(elm, true); getCellsParameters(elm, true);
// if cell has own background,then it must be blended with row
if (rowColor.A > 0 && (elm.hasNonEmptyAttribute("bgcolor") || _Style.hasStyle("background-color")))
{
if (_CellParams.back().BgColor.A < 255)
_CellParams.back().BgColor.blendFromui(rowColor, _CellParams.back().BgColor, _CellParams.back().BgColor.A);
}
if (elm.ID == HTML_TH) if (elm.ID == HTML_TH)
{ {
if (!_Style.hasStyle("font-weight")) if (!_Style.hasStyle("font-weight"))
@ -6658,14 +6766,6 @@ namespace NLGUI
return; return;
} }
if (_Style.hasStyle("padding"))
{
uint32 a;
// TODO: cssLength
if (fromString(_Style.getStyle("padding"), a))
table->CellPadding = a;
}
_Cells.back() = new CGroupCell(CViewBase::TCtorParam()); _Cells.back() = new CGroupCell(CViewBase::TCtorParam());
if (_Style.checkStyle("background-repeat", "repeat")) if (_Style.checkStyle("background-repeat", "repeat"))
@ -6677,7 +6777,7 @@ namespace NLGUI
if (_Style.hasStyle("background-image")) if (_Style.hasStyle("background-image"))
{ {
string image = _Style.getStyle("background-image"); string image = _Style.getStyle("background-image");
addImageDownload(image, _Cells.back()); addImageDownload(image, _Cells.back(), CStyleParams(), TImageType::NormalImage, "");
} }
if (elm.hasNonEmptyAttribute("colspan")) if (elm.hasNonEmptyAttribute("colspan"))
@ -6692,19 +6792,70 @@ namespace NLGUI
_Cells.back()->NoWrap = _CellParams.back().NoWrap; _Cells.back()->NoWrap = _CellParams.back().NoWrap;
_Cells.back()->ColSpan = std::max(1, _Cells.back()->ColSpan); _Cells.back()->ColSpan = std::max(1, _Cells.back()->ColSpan);
_Cells.back()->RowSpan = std::max(1, _Cells.back()->RowSpan); _Cells.back()->RowSpan = std::max(1, _Cells.back()->RowSpan);
_Cells.back()->Height = _CellParams.back().Height;
float temp; float temp;
if (_Style.hasStyle("width")) if (_Style.hasStyle("width"))
{
// _Style.Width does not handle '%' unit currently
if (_Style.Current.Width > 0)
{
_Cells.back()->WidthWanted = _Style.Current.Width;
_Cells.back()->TableRatio = 0;
}
else
{
getPercentage (_Cells.back()->WidthWanted, _Cells.back()->TableRatio, _Style.getStyle("width").c_str()); getPercentage (_Cells.back()->WidthWanted, _Cells.back()->TableRatio, _Style.getStyle("width").c_str());
}
}
else if (elm.hasNonEmptyAttribute("width")) else if (elm.hasNonEmptyAttribute("width"))
{
getPercentage (_Cells.back()->WidthWanted, _Cells.back()->TableRatio, elm.getAttribute("width").c_str()); getPercentage (_Cells.back()->WidthWanted, _Cells.back()->TableRatio, elm.getAttribute("width").c_str());
}
if (_Style.hasStyle("height"))
getPercentage (_Cells.back()->Height, temp, _Style.getStyle("height").c_str());
else if (elm.hasNonEmptyAttribute("height"))
getPercentage (_Cells.back()->Height, temp, elm.getAttribute("height").c_str());
_Cells.back()->NewLine = getTR(); _Cells.back()->NewLine = getTR();
// setting ModulateGlobalColor must be after addImageDownload
if (_Style.checkStyle("-ryzom-modulate-bgcolor", "true"))
_Cells.back()->setModulateGlobalColor(true);
// border from <table border="1">
if (table->CellBorder)
{
_Cells.back()->Border->setWidth(1, 1, 1, 1);
_Cells.back()->Border->setColor(table->Border->TopColor, table->Border->RightColor, table->Border->BottomColor, table->Border->LeftColor);
_Cells.back()->Border->setStyle(CSSLineStyle::INSET, CSSLineStyle::INSET, CSSLineStyle::INSET, CSSLineStyle::INSET);
}
if (_Style.hasStyle("border-top-width")) _Cells.back()->Border->TopWidth = _Style.Current.BorderTopWidth;
if (_Style.hasStyle("border-right-width")) _Cells.back()->Border->RightWidth = _Style.Current.BorderRightWidth;
if (_Style.hasStyle("border-bottom-width")) _Cells.back()->Border->BottomWidth = _Style.Current.BorderBottomWidth;
if (_Style.hasStyle("border-left-width")) _Cells.back()->Border->LeftWidth = _Style.Current.BorderLeftWidth;
if (_Style.hasStyle("border-top-color")) _Cells.back()->Border->TopColor = _Style.Current.BorderTopColor;
if (_Style.hasStyle("border-right-color")) _Cells.back()->Border->RightColor = _Style.Current.BorderRightColor;
if (_Style.hasStyle("border-bottom-color")) _Cells.back()->Border->BottomColor = _Style.Current.BorderBottomColor;
if (_Style.hasStyle("border-left-color")) _Cells.back()->Border->LeftColor = _Style.Current.BorderLeftColor;
if (_Style.hasStyle("border-top-style")) _Cells.back()->Border->TopStyle = _Style.Current.BorderTopStyle;
if (_Style.hasStyle("border-right-style")) _Cells.back()->Border->RightStyle = _Style.Current.BorderRightStyle;
if (_Style.hasStyle("border-bottom-style")) _Cells.back()->Border->BottomStyle = _Style.Current.BorderBottomStyle;
if (_Style.hasStyle("border-left-style")) _Cells.back()->Border->LeftStyle = _Style.Current.BorderLeftStyle;
// padding from <table cellpadding="1">
if (table->CellPadding)
{
_Cells.back()->PaddingTop = table->CellPadding;
_Cells.back()->PaddingRight = table->CellPadding;
_Cells.back()->PaddingBottom = table->CellPadding;
_Cells.back()->PaddingLeft = table->CellPadding;
}
if (_Style.hasStyle("padding-top")) _Cells.back()->PaddingTop = _Style.Current.PaddingTop;
if (_Style.hasStyle("padding-right")) _Cells.back()->PaddingRight = _Style.Current.PaddingRight;
if (_Style.hasStyle("padding-bottom")) _Cells.back()->PaddingBottom = _Style.Current.PaddingBottom;
if (_Style.hasStyle("padding-left")) _Cells.back()->PaddingLeft = _Style.Current.PaddingLeft;
table->addChild (_Cells.back()); table->addChild (_Cells.back());
// reusing indent pushed by table // reusing indent pushed by table
@ -6813,6 +6964,13 @@ namespace NLGUI
// *************************************************************************** // ***************************************************************************
void CGroupHTML::htmlTR(const CHtmlElement &elm) void CGroupHTML::htmlTR(const CHtmlElement &elm)
{ {
// prevent inheriting from table
if (!_CellParams.empty())
{
_CellParams.back().BgColor = CRGBA::Transparent;
_CellParams.back().Height = 0;
}
// Get cells parameters // Get cells parameters
getCellsParameters(elm, true); getCellsParameters(elm, true);

@ -1038,6 +1038,18 @@ namespace NLGUI
} }
} }
if (eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouserightup)
{
// If a line is selected and the line is not grayed and has right click action handler
if ((_Selected != -1) && (!_Lines[i].ViewText->getGrayed()) && !_Lines[_Selected].AHRightClick.empty())
{
CAHManager::getInstance()->runActionHandler ( _Lines[_Selected].AHRightClick,
CWidgetManager::getInstance()->getCtrlLaunchingModal(),
_Lines[_Selected].AHRightClickParams );
return true;
}
}
if (event.getType() == NLGUI::CEventDescriptor::mouse) if (event.getType() == NLGUI::CEventDescriptor::mouse)
{ {
const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event; const NLGUI::CEventDescriptorMouse &eventDesc = (const NLGUI::CEventDescriptorMouse &)event;
@ -1221,7 +1233,7 @@ namespace NLGUI
pV->setText (name); pV->setText (name);
} }
pV->setColor (_GroupMenu->_Color); pV->setColor (_GroupMenu->_Color);
pV->setFontSize (_GroupMenu->_FontSize); pV->setFontSize (_GroupMenu->_FontSize, _GroupMenu->_FontSizeCoef);
pV->setShadow (_GroupMenu->_Shadow); pV->setShadow (_GroupMenu->_Shadow);
pV->setShadowOutline (_GroupMenu->_ShadowOutline); pV->setShadowOutline (_GroupMenu->_ShadowOutline);
pV->setCheckable(checkable); pV->setCheckable(checkable);
@ -1310,7 +1322,7 @@ namespace NLGUI
} }
pV->setColor (_GroupMenu->_Color); pV->setColor (_GroupMenu->_Color);
pV->setFontSize (_GroupMenu->_FontSize); pV->setFontSize (_GroupMenu->_FontSize, _GroupMenu->_FontSizeCoef);
pV->setShadow (_GroupMenu->_Shadow); pV->setShadow (_GroupMenu->_Shadow);
pV->setShadowOutline (_GroupMenu->_ShadowOutline); pV->setShadowOutline (_GroupMenu->_ShadowOutline);
pV->setCheckable(checkable); pV->setCheckable(checkable);
@ -1685,6 +1697,28 @@ namespace NLGUI
_Lines[lineIndex].AHParams = params; _Lines[lineIndex].AHParams = params;
} }
// ------------------------------------------------------------------------------------------------
void CGroupSubMenu::setRightClickHandler(uint lineIndex, const std::string &ah)
{
if (lineIndex > _Lines.size())
{
nlwarning("Bad index");
return;
}
_Lines[lineIndex].AHRightClick = ah;
}
// ------------------------------------------------------------------------------------------------
void CGroupSubMenu::setRightClickHandlerParam(uint lineIndex, const std::string &params)
{
if (lineIndex > _Lines.size())
{
nlwarning("Bad index");
return;
}
_Lines[lineIndex].AHRightClickParams = params;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CGroupSubMenu::setSelectable(uint lineIndex, bool selectable) void CGroupSubMenu::setSelectable(uint lineIndex, bool selectable)
{ {
@ -1990,6 +2024,7 @@ namespace NLGUI
_ShadowColorGrayed = CRGBA::Black; _ShadowColorGrayed = CRGBA::Black;
_HighLightOver.set(128, 0, 0, 255); _HighLightOver.set(128, 0, 0, 255);
_FontSize = 12; _FontSize = 12;
_FontSizeCoef = true;
_Shadow = false; _Shadow = false;
_ShadowOutline = false; _ShadowOutline = false;
_ResizeFromChildH = _ResizeFromChildW = true; _ResizeFromChildH = _ResizeFromChildW = true;
@ -2584,9 +2619,10 @@ namespace NLGUI
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CGroupMenu::setFontSize(uint fontSize) void CGroupMenu::setFontSize(uint fontSize, bool coef)
{ {
_FontSize = fontSize; _FontSize = fontSize;
_FontSizeCoef = coef;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -2632,6 +2668,20 @@ namespace NLGUI
_RootMenu->setActionHandlerParam(lineIndex, params); _RootMenu->setActionHandlerParam(lineIndex, params);
} }
// ------------------------------------------------------------------------------------------------
void CGroupMenu::setRightClickHandler(uint lineIndex, const std::string &ah)
{
if (_RootMenu)
_RootMenu->setRightClickHandler(lineIndex, ah);
}
// ------------------------------------------------------------------------------------------------
void CGroupMenu::setRightClickHandlerParam(uint lineIndex, const std::string &params)
{
if (_RootMenu)
_RootMenu->setRightClickHandlerParam(lineIndex, params);
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CGroupMenu::setUserGroupRight(uint line, CInterfaceGroup *gr, bool ownerShip /*=true*/) void CGroupMenu::setUserGroupRight(uint line, CInterfaceGroup *gr, bool ownerShip /*=true*/)
{ {

@ -25,6 +25,7 @@
#include "nel/misc/i_xml.h" #include "nel/misc/i_xml.h"
#include "nel/misc/i18n.h" #include "nel/misc/i18n.h"
#include "nel/misc/xml_auto_ptr.h" #include "nel/misc/xml_auto_ptr.h"
#include "nel/gui/css_border_renderer.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -52,6 +53,9 @@ namespace NLGUI
RowSpan = 1; RowSpan = 1;
TableColumnIndex = 0; TableColumnIndex = 0;
Group = new CInterfaceGroup(CViewBase::TCtorParam()); Group = new CInterfaceGroup(CViewBase::TCtorParam());
// TODO: only initialize if border is set
Border = new CSSBorderRenderer();
PaddingTop = PaddingRight = PaddingBottom = PaddingLeft = 0;
Align = Left; Align = Left;
VAlign = Middle; VAlign = Middle;
LeftMargin = 0; LeftMargin = 0;
@ -59,13 +63,26 @@ namespace NLGUI
IgnoreMaxWidth = false; IgnoreMaxWidth = false;
IgnoreMinWidth = false; IgnoreMinWidth = false;
AddChildW = false; AddChildW = false;
_UserTexture = false;
_TextureTiled = false; _TextureTiled = false;
_TextureScaled = false; _TextureScaled = false;
_TextureXReal = 0;
_TextureYReal = 0;
_TextureWReal = 0;
_TextureHReal = 0;
setEnclosedGroupDefaultParams(); setEnclosedGroupDefaultParams();
addGroup (Group); addGroup (Group);
} }
// ----------------------------------------------------------------------------
CGroupCell::~CGroupCell()
{
if (Border)
{
delete Border;
Border = NULL;
}
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupCell::setEnclosedGroupDefaultParams() void CGroupCell::setEnclosedGroupDefaultParams()
{ {
@ -481,85 +498,72 @@ namespace NLGUI
rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_WReal-1, _YReal, 1, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,255,255) ); rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_WReal-1, _YReal, 1, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,255,255) );
} }
uint8 CurrentAlpha = 255;
CGroupTable *table = NULL;
if (getParent ())
{
table = static_cast<CGroupTable*> (getParent ());
CurrentAlpha = table->CurrentAlpha;
}
// Draw the background // Draw the background
if (_UserTexture || BgColor.A != 0) if (BgColor.A > 0 || !_TextureId.empty())
{ {
CViewRenderer &rVR = *CViewRenderer::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance();
if (_UserTexture)
bool flush = false;
if (CurrentAlpha > 0 && !_TextureId.empty())
{ {
CRGBA col; CRGBA col = CRGBA::White;
if (BgColor.A == 0 ) col.A = CurrentAlpha;
col = CRGBA(255,255,255,255);
else
col = BgColor;
sint32 oldSciX, oldSciY, oldSciW, oldSciH;
makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH);
if (_TextureScaled && !_TextureTiled) if (_TextureScaled && !_TextureTiled)
{ {
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, rVR.drawRotFlipBitmap(_RenderLayer, _TextureXReal, _TextureYReal, _WReal, _HReal, 0, false, _TextureId, col);
_WReal, _HReal,
0, false,
_TextureId,
col );
} }
else else
{ {
if (!_TextureTiled) if (!_TextureTiled)
{ rVR.drawRotFlipBitmap(_RenderLayer, _TextureXReal, _TextureYReal, _TextureWReal, _TextureHReal, 0, false, _TextureId, col);
rVR.draw11RotFlipBitmap (_RenderLayer, _XReal, _YReal,
0, false,
_TextureId,
col);
}
else else
{ rVR.drawRotFlipBitmapTiled(_RenderLayer, _TextureXReal, _TextureYReal, _WReal, _TextureHReal, 0, false, _TextureId, 0, col);
rVR.drawRotFlipBitmapTiled(_RenderLayer, _XReal, _YReal,
_WReal, _HReal,
0, false,
_TextureId,
0,
col);
}
} }
restoreClip (oldSciX, oldSciY, oldSciW, oldSciH);
flush = true;
} }
else
{
CRGBA finalColor;
finalColor.modulateFromColor (BgColor, CWidgetManager::getInstance()->getGlobalColor());
// Get the parent table if (BgColor.A > 0)
if (getParent ())
{ {
CGroupTable *table = static_cast<CGroupTable*> (getParent ()); CRGBA finalColor = BgColor;
finalColor.A = (uint8) (((uint16) table->CurrentAlpha * (uint16) finalColor.A) >> 8); if (_ModulateGlobalColor)
} finalColor.modulateFromColor (finalColor, CWidgetManager::getInstance()->getGlobalColor());
finalColor.A = (uint8) (((uint16) CurrentAlpha * (uint16) finalColor.A) >> 8);
//nlinfo("Blank Texture"); if (finalColor.A > 0)
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), finalColor); rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), finalColor);
flush = true;
} }
if (flush)
rVR.flush();
} }
// Get the parent table if (Border)
if (getParent ())
{ {
CGroupTable *table = static_cast<CGroupTable*> (getParent ()); // TODO: monitor these in checkCoords and update when changed
if (table->Border) { uint8 contentAlpha = CWidgetManager::getInstance()->getGlobalColorForContent().A;
CRGBA lighter = blend(table->BorderColor, CRGBA::White, 0.5f); if (contentAlpha > 0)
{
CRGBA borderColorTL; Border->CurrentAlpha = contentAlpha;
borderColorTL.modulateFromColor (lighter, CWidgetManager::getInstance()->getGlobalColor()); Border->setRenderLayer(_RenderLayer);
borderColorTL.A = (uint8) (((uint16) table->CurrentAlpha * (uint16) borderColorTL.A) >> 8); Border->setModulateGlobalColor(_ModulateGlobalColor);
Border->draw();
CRGBA borderColorBR;
borderColorBR.modulateFromColor (table->BorderColor, CWidgetManager::getInstance()->getGlobalColor());
borderColorBR.A = (uint8) (((uint16) table->CurrentAlpha * (uint16) borderColorBR.A) >> 8);
CViewRenderer &rVR = *CViewRenderer::getInstance();
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, 1, 0, false, rVR.getBlankTextureId(), borderColorTL );
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, 1, _HReal, 0, false, rVR.getBlankTextureId(), borderColorBR );
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_HReal-1, _WReal, 1, 0, false, rVR.getBlankTextureId(), borderColorBR );
rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_WReal-1, _YReal, 1, _HReal, 0, false, rVR.getBlankTextureId(), borderColorTL );
} }
} }
@ -569,13 +573,19 @@ namespace NLGUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
sint32 CGroupCell::getMaxUsedW() const sint32 CGroupCell::getMaxUsedW() const
{ {
return Group->getMaxUsedW(); sint32 result = getPaddingLeftRight() + Group->getMaxUsedW();
if (Border)
result += Border->getLeftRightWidth();
return result;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
sint32 CGroupCell::getMinUsedW() const sint32 CGroupCell::getMinUsedW() const
{ {
return Group->getMinUsedW(); sint32 result = getPaddingLeftRight() + Group->getMinUsedW();
if (Border)
result += Border->getLeftRightWidth();
return result;
} }
@ -584,14 +594,13 @@ namespace NLGUI
{ {
if (TxName.empty() || TxName == "none") if (TxName.empty() || TxName == "none")
{ {
_UserTexture = false; _TextureId.clear();
nlinfo("Set no texture");
} }
else else
{ {
nlinfo("Set texture to cell : %s", TxName.c_str());
_UserTexture = true;
_TextureId.setTexture (TxName.c_str (), 0, 0, -1, -1, false); _TextureId.setTexture (TxName.c_str (), 0, 0, -1, -1, false);
updateTextureCoords();
} }
} }
@ -611,6 +620,31 @@ namespace NLGUI
_TextureScaled = scaled; _TextureScaled = scaled;
} }
// ----------------------------------------------------------------------------
void CGroupCell::updateTextureCoords()
{
if (_TextureId.empty()) return;
CViewRenderer &rVR = *CViewRenderer::getInstance();
rVR.getTextureSizeFromId (_TextureId, _TextureWReal, _TextureHReal);
_TextureXReal = _XReal;
_TextureYReal = _YReal + _HReal - _TextureHReal;
if (_TextureTiled && _TextureHReal > 0)
{
sint diff = (_HReal / _TextureHReal) * _TextureHReal;
_TextureYReal -= diff;
_TextureHReal += diff;
}
}
// ----------------------------------------------------------------------------
void CGroupCell::updateCoords()
{
CInterfaceGroup::updateCoords();
updateTextureCoords();
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
NLMISC_REGISTER_OBJECT(CViewBase, CGroupTable, std::string, "table"); NLMISC_REGISTER_OBJECT(CViewBase, CGroupTable, std::string, "table");
@ -622,11 +656,21 @@ namespace NLGUI
_ContentValidated = false; _ContentValidated = false;
TableRatio = 0.f; TableRatio = 0.f;
ForceWidthMin = 0; ForceWidthMin = 0;
Border=0;
BorderColor = CRGBA(32, 32, 32, 255); // TODO: only initialize when needed
Border = new CSSBorderRenderer();
CellBorder = false;
CellPadding=1; CellPadding=1;
CellSpacing=2; CellSpacing=2;
ContinuousUpdate = false; ContinuousUpdate = false;
_TextureTiled = false;
_TextureScaled = false;
_TextureXReal = 0;
_TextureYReal = 0;
_TextureWReal = 0;
_TextureHReal = 0;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -688,13 +732,62 @@ namespace NLGUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
CGroupTable::~CGroupTable() CGroupTable::~CGroupTable()
{ {
if (Border)
{
delete Border;
Border = NULL;
}
/* uint i; /* uint i;
for (i=0; i<_Cells.size(); i++) for (i=0; i<_Cells.size(); i++)
delete _Cells[i]; delete _Cells[i];
_Cells.clear ();*/ _Cells.clear ();*/
} }
// ----------------------------------------------------------------------------
void CGroupTable::setTexture(const std::string & TxName)
{
if (TxName.empty() || TxName == "none")
{
_TextureId.clear();
}
else
{
_TextureId.setTexture (TxName.c_str (), 0, 0, -1, -1, false);
updateTextureCoords();
}
}
// ----------------------------------------------------------------------------
void CGroupTable::setTextureTile(bool tiled)
{
_TextureTiled = tiled;
}
// ----------------------------------------------------------------------------
void CGroupTable::setTextureScale(bool scaled)
{
_TextureScaled = scaled;
}
// ----------------------------------------------------------------------------
void CGroupTable::updateTextureCoords()
{
if (_TextureId.empty()) return;
CViewRenderer &rVR = *CViewRenderer::getInstance();
rVR.getTextureSizeFromId (_TextureId, _TextureWReal, _TextureHReal);
_TextureXReal = _XReal;
_TextureYReal = _YReal + _HReal - _TextureHReal;
if (_TextureTiled && _TextureHReal > 0)
{
sint diff = (_HReal / _TextureHReal) * _TextureHReal;
_TextureYReal -= diff;
_TextureHReal += diff;
}
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void CGroupTable::updateCoords() void CGroupTable::updateCoords()
@ -738,21 +831,22 @@ namespace NLGUI
// Get width min and max // Get width min and max
if( !cell->IgnoreMaxWidth) if( !cell->IgnoreMaxWidth)
{
cell->WidthMax = cell->getMaxUsedW() + cell->LeftMargin; cell->WidthMax = cell->getMaxUsedW() + cell->LeftMargin;
}
else else
{
cell->WidthMax = cell->WidthWanted + additionnalWidth + cell->LeftMargin; cell->WidthMax = cell->WidthWanted + additionnalWidth + cell->LeftMargin;
}
sint32 cellWidth; sint32 cellWidth;
if(!cell->IgnoreMinWidth) if(!cell->IgnoreMinWidth)
{
cellWidth = cell->NoWrap ? cell->WidthMax : cell->getMinUsedW() + cell->LeftMargin; cellWidth = cell->NoWrap ? cell->WidthMax : cell->getMinUsedW() + cell->LeftMargin;
}
else else
{
cellWidth = cell->NoWrap ? cell->WidthMax : cell->LeftMargin; cellWidth = cell->NoWrap ? cell->WidthMax : cell->LeftMargin;
{
sint32 cellBorderPadding = cell->getPaddingLeftRight();
if (cell->Border)
cellBorderPadding += cell->Border->getLeftRightWidth();
if (cellWidth < cellBorderPadding)
cellWidth = cellBorderPadding;
} }
// New cell ? // New cell ?
@ -795,11 +889,11 @@ namespace NLGUI
_Columns[column].WidthMax = (sint32)(cell->WidthMax*colspan); _Columns[column].WidthMax = (sint32)(cell->WidthMax*colspan);
if (cell->TableRatio*colspan > _Columns[column].TableRatio) if (cell->TableRatio*colspan > _Columns[column].TableRatio)
_Columns[column].TableRatio = cell->TableRatio*colspan; _Columns[column].TableRatio = cell->TableRatio*colspan;
if (cell->WidthWanted*colspan + additionnalWidth > _Columns[column].WidthWanted) if ((cell->WidthWanted + additionnalWidth)*colspan > _Columns[column].WidthWanted)
_Columns[column].WidthWanted = (sint32)(cell->WidthWanted*colspan) + additionnalWidth; _Columns[column].WidthWanted = (sint32)((cell->WidthWanted + additionnalWidth)*colspan);
if (_Columns[column].WidthWanted + additionnalWidth) if (_Columns[column].WidthWanted > _Columns[column].WidthMax)
_Columns[column].WidthMax = _Columns[column].WidthWanted + additionnalWidth; _Columns[column].WidthMax = _Columns[column].WidthWanted;
if (_Columns[column].WidthWanted > _Columns[column].Width) if (_Columns[column].WidthWanted > _Columns[column].Width)
_Columns[column].Width = _Columns[column].WidthWanted; _Columns[column].Width = _Columns[column].WidthWanted;
@ -821,15 +915,23 @@ namespace NLGUI
column++; column++;
} }
// Width of cells and table borders // Additional space contributing to table width
sint32 padding = CellPadding + (Border ? 1 : 0); sint32 tableBorderSpacing = 0;
sint32 borderWidth = 2*Border + ((sint32)_Columns.size()+1) * CellSpacing + ((sint32)_Columns.size()*2) * padding; if (Border)
tableBorderSpacing += Border->getLeftRightWidth();
tableBorderSpacing += ((sint32)_Columns.size()+1) * CellSpacing;;
sint32 innerForceWidthMin = ForceWidthMin;
if (innerForceWidthMin < tableBorderSpacing)
innerForceWidthMin = 0;
else
innerForceWidthMin -= tableBorderSpacing;
// Get the width // Get the width
sint32 tableWidthMax = ForceWidthMin?ForceWidthMin:_LastParentW; // getWReal(); sint32 tableWidthMax = innerForceWidthMin ? innerForceWidthMin : _LastParentW - tableBorderSpacing; // getWReal();
sint32 tableWidthMin = std::max(ForceWidthMin, (sint32)((float)tableWidthMax*TableRatio)); sint32 tableWidthMin = std::max(innerForceWidthMin, (sint32)((float)tableWidthMax*TableRatio));
tableWidthMax = std::max ((sint32)0, tableWidthMax-borderWidth); tableWidthMax = std::max ((sint32)0, tableWidthMax);
tableWidthMin = std::max ((sint32)0, tableWidthMin-borderWidth); tableWidthMin = std::max ((sint32)0, tableWidthMin);
// Get the width of the table and normalize percent of the cell (sum of TableRatio must == 1) // Get the width of the table and normalize percent of the cell (sum of TableRatio must == 1)
sint32 tableWidth = 0; sint32 tableWidth = 0;
@ -845,10 +947,10 @@ namespace NLGUI
// force table width to fit all columns // force table width to fit all columns
// if width is set, then use column min width // if width is set, then use column min width
if (ForceWidthMin > 0) if (innerForceWidthMin > 0)
tableWidthMax = std::min(_LastParentW - borderWidth, std::max(tableWidthMax, tableWidth)); tableWidthMax = std::min(_LastParentW - tableBorderSpacing, std::max(tableWidthMax, tableWidth));
else else
tableWidthMax = std::min(_LastParentW - borderWidth, std::max(tableWidthMax, tableMaxContentWidth)); tableWidthMax = std::min(_LastParentW - tableBorderSpacing, std::max(tableWidthMax, tableMaxContentWidth));
if (tableWidthMax < 0) if (tableWidthMax < 0)
tableWidthMax = 0; tableWidthMax = 0;
@ -857,6 +959,7 @@ namespace NLGUI
std::swap(tableWidthMin, tableWidthMax); std::swap(tableWidthMin, tableWidthMax);
// Eval table size with all percent cells resized // Eval table size with all percent cells resized
// TODO: _Columns[i].TableRatio is for outer width
sint32 tableWidthSizeAfterPercent = tableWidth; sint32 tableWidthSizeAfterPercent = tableWidth;
for (i=0; i<_Columns.size(); i++) for (i=0; i<_Columns.size(); i++)
{ {
@ -1029,7 +1132,7 @@ namespace NLGUI
column = 0; column = 0;
sint32 row = 0; sint32 row = 0;
sint32 currentX = Border + CellSpacing + padding; sint32 currentX = 0;
_Rows.clear (); _Rows.clear ();
for (i=0; i<_Cells.size(); i++) for (i=0; i<_Cells.size(); i++)
@ -1039,7 +1142,9 @@ namespace NLGUI
if (cell->NewLine) if (cell->NewLine)
{ {
column = 0; column = 0;
currentX = Border + CellSpacing + padding; currentX = CellSpacing;
if (Border)
currentX += Border->getLeftWidth();
_Rows.push_back(CRow()); _Rows.push_back(CRow());
} }
@ -1048,7 +1153,7 @@ namespace NLGUI
{ {
// we have active rowspan, must add up 'skipped' columns // we have active rowspan, must add up 'skipped' columns
for( ; column < (uint)cell->TableColumnIndex; ++column) for( ; column < (uint)cell->TableColumnIndex; ++column)
currentX += _Columns[column].Width + padding*2 + CellSpacing; currentX += _Columns[column].Width + CellSpacing;
} }
// Set the x and width // Set the x and width
@ -1057,11 +1162,19 @@ namespace NLGUI
sint32 alignmentX = 0; sint32 alignmentX = 0;
sint32 widthReduceX = 0; sint32 widthReduceX = 0;
sint32 columnWidth = _Columns[column].Width; sint32 columnWidth = _Columns[column].Width;
sint32 cellBorderPaddingLeft = cell->PaddingLeft;
sint32 cellBorderPaddingRight = cell->PaddingRight;
if (cell->Border)
{
cellBorderPaddingLeft += cell->Border->getLeftWidth();
cellBorderPaddingRight += cell->Border->getRightWidth();
}
if (cell->ColSpan > 1) if (cell->ColSpan > 1)
{ {
// scan ahead and add up column widths as they might be different // scan ahead and add up column widths as they might be different
for(int j = 1; j<cell->ColSpan; j++) for(int j = 1; j<cell->ColSpan; j++)
columnWidth += CellSpacing + padding*2 + _Columns[column+j].Width; columnWidth += CellSpacing + _Columns[column+j].Width;
} }
if (cell->WidthMax < columnWidth) if (cell->WidthMax < columnWidth)
@ -1081,11 +1194,13 @@ namespace NLGUI
} }
} }
cell->setX(currentX - padding); // outer
cell->setW(columnWidth + padding*2); cell->setX(currentX);
cell->setW(columnWidth);
cell->Group->setX(alignmentX + cell->LeftMargin + padding); // inner
cell->Group->setW(columnWidth - widthReduceX); cell->Group->setX(cellBorderPaddingLeft + alignmentX + cell->LeftMargin);
cell->Group->setW(columnWidth - widthReduceX - cellBorderPaddingLeft - cellBorderPaddingRight);
cell->Group->CInterfaceElement::updateCoords(); cell->Group->CInterfaceElement::updateCoords();
// Update coords to get H // Update coords to get H
@ -1094,16 +1209,23 @@ namespace NLGUI
// Resize the row array // Resize the row array
float rowspan = 1.f / (float)cell->RowSpan; float rowspan = 1.f / (float)cell->RowSpan;
_Rows.back().Height = std::max((sint32)(cell->Height*rowspan), std::max(_Rows.back().Height, (sint32)(cell->Group->getH()*rowspan))); uint cellBorderPadding = cell->getPaddingTopBottom();
if (cell->Border)
cellBorderPadding += cell->Border->getTopBottomWidth();
sint32 cellHeight = std::max((sint32)(cell->Height*rowspan), (sint32)(cell->Group->getH()*rowspan + cellBorderPadding));
_Rows.back().Height = std::max(_Rows.back().Height, (sint32)cellHeight);
// Next column // Next column
currentX += columnWidth + 2*padding + CellSpacing; currentX += columnWidth + CellSpacing;
column += cell->ColSpan; column += cell->ColSpan;
} }
// Set cell Y // Set cell Y
row = 0; row = 0;
sint32 currentY = -(Border + CellSpacing + padding); sint32 currentY = -CellSpacing;
if (Border)
currentY -= Border->getTopWidth();
for (i=0; i<_Cells.size(); i++) for (i=0; i<_Cells.size(); i++)
{ {
// New cell ? // New cell ?
@ -1112,7 +1234,7 @@ namespace NLGUI
{ {
if (_Rows[row].Height != 0) if (_Rows[row].Height != 0)
{ {
currentY -= _Rows[row].Height + 2*padding + CellSpacing; currentY -= _Rows[row].Height + CellSpacing;
} }
row++; row++;
} }
@ -1120,12 +1242,19 @@ namespace NLGUI
// Check align // Check align
sint32 alignmentY = 0; sint32 alignmentY = 0;
sint32 rowHeight = _Rows[row].Height; sint32 rowHeight = _Rows[row].Height;
sint32 cellBorderPaddingTop = cell->PaddingTop;
sint32 cellBorderPaddingBottom = cell->PaddingBottom;
if (cell->Border)
{
cellBorderPaddingTop += cell->Border->getTopWidth();
cellBorderPaddingBottom += cell->Border->getBottomWidth();
}
if (cell->RowSpan > 1) if (cell->RowSpan > 1)
{ {
// we need to scan down and add up row heights // we need to scan down and add up row heights
int k = std::min((sint32)_Rows.size(), row + cell->RowSpan); int k = std::min((sint32)_Rows.size(), row + cell->RowSpan);
for(int j=row+1; j<k; j++) for(int j=row+1; j<k; j++)
rowHeight += CellSpacing + padding*2 + _Rows[j].Height; rowHeight += CellSpacing + _Rows[j].Height;
} }
if ((sint32)cell->Group->getH() < rowHeight) if ((sint32)cell->Group->getH() < rowHeight)
{ {
@ -1142,15 +1271,26 @@ namespace NLGUI
} }
} }
cell->setY(currentY + padding); // outer
cell->setH (rowHeight + 2*padding); cell->setY(currentY);
cell->Group->setY(-(alignmentY + padding)); cell->setH (rowHeight);
// inner
cell->Group->setY(-(alignmentY + cellBorderPaddingTop - cellBorderPaddingBottom));
} }
// Resize the table // final row
setW(finalWidth+borderWidth-_LastParentW);
if (!_Rows.empty()) if (!_Rows.empty())
currentY -= _Rows[row].Height + padding + CellSpacing + Border; currentY -= _Rows.back().Height;
currentY -= CellSpacing;
finalWidth += ((sint)_Columns.size() + 1) * CellSpacing;
if (Border)
{
currentY -= Border->getBottomWidth();
finalWidth += Border->getLeftRightWidth();
}
// Resize the table
setW(finalWidth-_LastParentW);
setH(-currentY); setH(-currentY);
// All done // All done
@ -1160,8 +1300,22 @@ namespace NLGUI
CInterfaceGroup::updateCoords(); CInterfaceGroup::updateCoords();
updateTextureCoords();
// update borders if present
if (Border)
{
Border->setRect(_XReal + _MarginLeft, _YReal, _WReal, _HReal);
}
// update cell borders if present
for (uint32 i=0; i<_Cells.size(); i++)
{
if (_Cells[i]->Border)
{
_Cells[i]->Border->setRect(_Cells[i]->_XReal, _Cells[i]->_YReal, _Cells[i]->_WReal, _Cells[i]->_HReal);
}
}
// Validated // Validated
_ContentValidated = true; _ContentValidated = true;
@ -1267,7 +1421,9 @@ namespace NLGUI
for (i=0; i<columns.size(); i++) for (i=0; i<columns.size(); i++)
maxWidth += columns[i]; maxWidth += columns[i];
maxWidth += 2*Border + ((sint32)columns.size()+1) * CellSpacing + ((sint32)columns.size()*2) * CellPadding; maxWidth += ((sint32)columns.size()+1) * CellSpacing;
if (Border)
maxWidth += Border->getLeftRightWidth();
return maxWidth; return maxWidth;
} }
@ -1312,7 +1468,9 @@ namespace NLGUI
for (i=0; i<columns.size(); i++) for (i=0; i<columns.size(); i++)
maxWidth += columns[i]; maxWidth += columns[i];
maxWidth += 2*Border + ((sint32)columns.size()+1) * CellSpacing + ((sint32)columns.size()*2) * CellPadding; maxWidth += ((sint32)columns.size()+1) * CellSpacing;
if (Border)
maxWidth += Border->getLeftRightWidth();
return maxWidth; return maxWidth;
} }
@ -1342,64 +1500,62 @@ namespace NLGUI
if (!_Columns.empty() && !_Rows.empty()) if (!_Columns.empty() && !_Rows.empty())
{ {
sint32 border = Border + CellSpacing; bool flush = false;
if (border && BgColor.A) CViewRenderer &rVR = *CViewRenderer::getInstance();
if (BgColor.A > 0)
{ {
CRGBA finalColor; CRGBA finalColor = BgColor;
finalColor.modulateFromColor (BgColor, CWidgetManager::getInstance()->getGlobalColor()); if (_ModulateGlobalColor)
finalColor.A = CurrentAlpha; finalColor.modulateFromColor (finalColor, CWidgetManager::getInstance()->getGlobalColor());
finalColor.A = (uint8) (((uint16) CurrentAlpha * (uint16) finalColor.A) >> 8);
// Draw the top line rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), finalColor);
CViewRenderer &rVR = *CViewRenderer::getInstance();
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal-border+_HReal, _WReal, border, 0, false, rVR.getBlankTextureId(), finalColor);
// Draw the left line flush = true;
sint32 insideHeight = std::max((sint32)0, (sint32)_HReal - (sint32)border); }
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, border, insideHeight, 0, false, rVR.getBlankTextureId(), finalColor);
// Draw the inside borders // Draw the background
if (CellSpacing) if (CurrentAlpha > 0 && !_TextureId.empty())
{
uint i;
sint32 x, y;
for (i=0; i<_Cells.size(); i++)
{ {
CGroupCell *cell = _Cells[i]; sint32 oldSciX, oldSciY, oldSciW, oldSciH;
makeNewClip (oldSciX, oldSciY, oldSciW, oldSciH);
x = cell->getXReal(); CRGBA col = CRGBA::White;
y = cell->getYReal() - CellSpacing; col.A = CurrentAlpha;
// right
rVR.drawRotFlipBitmap (_RenderLayer, x + cell->getW(), y, CellSpacing, cell->getH() + CellSpacing, 0, false, rVR.getBlankTextureId(), finalColor);
// bottom
rVR.drawRotFlipBitmap (_RenderLayer, x, y, cell->getW(), CellSpacing, 0, false, rVR.getBlankTextureId(), finalColor);
}
}
if (_TextureScaled && !_TextureTiled)
{
rVR.drawRotFlipBitmap(_RenderLayer, _TextureXReal, _TextureYReal, _WReal, _HReal, 0, false, _TextureId, col);
} }
if (Border) else
{ {
CViewRenderer &rVR = *CViewRenderer::getInstance(); if (!_TextureTiled)
rVR.drawRotFlipBitmap(_RenderLayer, _TextureXReal, _TextureYReal, _TextureWReal, _TextureHReal, 0, false, _TextureId, col);
else
rVR.drawRotFlipBitmapTiled(_RenderLayer, _TextureXReal, _TextureYReal, _WReal, _TextureHReal, 0, false, _TextureId, 0, col);
}
CRGBA borderColorTL; restoreClip (oldSciX, oldSciY, oldSciW, oldSciH);
CRGBA lighter = blend(BorderColor, CRGBA::White, 0.5f); flush = true;
borderColorTL.modulateFromColor (lighter, CWidgetManager::getInstance()->getGlobalColor()); }
borderColorTL.A = CurrentAlpha;
CRGBA borderColorBR; // flush background color and image
borderColorBR.modulateFromColor (BorderColor, CWidgetManager::getInstance()->getGlobalColor()); if (flush)
borderColorBR.A = CurrentAlpha; rVR.flush();
// beveled table border if (Border)
for (sint32 i=0; i<Border; i++)
{ {
// bottom, left, top, right // TODO: monitor these in checkCoords and update when changed
rVR.drawRotFlipBitmap (_RenderLayer, _XReal+i, _YReal+i, _WReal-i*2, 1, 0, false, rVR.getBlankTextureId(), borderColorBR); uint8 contentAlpha = CWidgetManager::getInstance()->getGlobalColorForContent().A;
rVR.drawRotFlipBitmap (_RenderLayer, _XReal+i, _YReal+i, 1, _HReal-i*2, 0, false, rVR.getBlankTextureId(), borderColorTL); if (contentAlpha > 0)
rVR.drawRotFlipBitmap (_RenderLayer, _XReal+i, _YReal+_HReal-i-1, _WReal-i*2, 1, 0, false, rVR.getBlankTextureId(), borderColorTL); {
rVR.drawRotFlipBitmap (_RenderLayer, _XReal+_WReal-i-1, _YReal+i, 1, _HReal-i*2, 0, false, rVR.getBlankTextureId(), borderColorBR); Border->CurrentAlpha = CurrentAlpha;
Border->setRenderLayer(_RenderLayer);
Border->setModulateGlobalColor(_ModulateGlobalColor);
Border->draw();
} }
} }
} }
CInterfaceGroup::draw (); CInterfaceGroup::draw ();
@ -1412,12 +1568,16 @@ namespace NLGUI
{ {
if( name == "border" ) if( name == "border" )
{ {
return toString( Border ); if (Border)
return toString( Border->TopWidth );
return "0";
} }
else else
if( name == "bordercolor" ) if( name == "bordercolor" )
{ {
return toString( BorderColor ); if (Border)
return toString( Border->TopColor );
return toString(CRGBA::Transparent);
} }
else else
if( name == "cellpadding" ) if( name == "cellpadding" )
@ -1452,7 +1612,14 @@ namespace NLGUI
{ {
sint32 i; sint32 i;
if( fromString( value, i ) ) if( fromString( value, i ) )
Border = i; {
if (!Border)
Border = new CSSBorderRenderer();
Border->TopWidth = i;
Border->RightWidth = i;
Border->BottomWidth = i;
Border->LeftWidth = i;
}
return; return;
} }
else else
@ -1460,7 +1627,14 @@ namespace NLGUI
{ {
CRGBA c; CRGBA c;
if( fromString( value, c ) ) if( fromString( value, c ) )
BorderColor = c; {
if (!Border)
Border = new CSSBorderRenderer();
Border->TopColor = c;
Border->RightColor = c;
Border->BottomColor = c;
Border->LeftColor = c;
}
return; return;
} }
else else
@ -1505,8 +1679,11 @@ namespace NLGUI
return NULL; return NULL;
xmlSetProp( node, BAD_CAST "type", BAD_CAST "table" ); xmlSetProp( node, BAD_CAST "type", BAD_CAST "table" );
xmlSetProp( node, BAD_CAST "border", BAD_CAST toString( Border ).c_str() ); if (Border)
xmlSetProp( node, BAD_CAST "bordercolor", BAD_CAST toString( BorderColor ).c_str() ); {
xmlSetProp( node, BAD_CAST "border", BAD_CAST toString( Border->TopWidth ).c_str() );
xmlSetProp( node, BAD_CAST "bordercolor", BAD_CAST toString( Border->TopColor ).c_str() );
}
xmlSetProp( node, BAD_CAST "cellpadding", BAD_CAST toString( CellPadding ).c_str() ); xmlSetProp( node, BAD_CAST "cellpadding", BAD_CAST toString( CellPadding ).c_str() );
xmlSetProp( node, BAD_CAST "cellspacing", BAD_CAST toString( CellSpacing ).c_str() ); xmlSetProp( node, BAD_CAST "cellspacing", BAD_CAST toString( CellSpacing ).c_str() );
xmlSetProp( node, BAD_CAST "bgcolor", BAD_CAST toString( BgColor ).c_str() ); xmlSetProp( node, BAD_CAST "bgcolor", BAD_CAST toString( BgColor ).c_str() );
@ -1528,13 +1705,20 @@ namespace NLGUI
ptr = (char*) xmlGetProp( cur, (xmlChar*)"border" ); ptr = (char*) xmlGetProp( cur, (xmlChar*)"border" );
if (ptr) if (ptr)
{ {
fromString((const char*)ptr, Border); uint32 w;
fromString((const char*)ptr, w);
if (!Border)
Border = new CSSBorderRenderer();
Border->setWidth(w, w, w, w);
} }
// //
ptr = (char*) xmlGetProp( cur, (xmlChar*)"bordercolor" ); ptr = (char*) xmlGetProp( cur, (xmlChar*)"bordercolor" );
if (ptr) if (ptr)
{ {
BorderColor = convertColor((const char*)ptr); CRGBA c = convertColor((const char*)ptr);
if (!Border)
Border = new CSSBorderRenderer();
Border->setColor(c, c, c, c);
} }
// //
ptr = (char*) xmlGetProp( cur, (xmlChar*)"cellpadding" ); ptr = (char*) xmlGetProp( cur, (xmlChar*)"cellpadding" );

@ -190,6 +190,35 @@ namespace NLGUI
elm.reindexChilds(); elm.reindexChilds();
parent.reindexChilds(); parent.reindexChilds();
} }
// move all <tr> directly under <table> to its own <tbody> ("table > tbody > tr" selector).
// TODO: move first real <thead> to front, move first real <tfoot> at the end
if (elm.ID == HTML_TABLE)
{
std::list<CHtmlElement>::iterator it = elm.Children.begin();
std::list<CHtmlElement>::iterator tbody = elm.Children.end();
for(it = elm.Children.begin(); it != elm.Children.end(); ++it)
{
if (it->ID == HTML_TR)
{
if (tbody == elm.Children.end())
{
tbody = elm.Children.insert(it, CHtmlElement(CHtmlElement::ELEMENT_NODE, "tbody"));
tbody->ID = HTML_TBODY;
tbody->parent = &elm;
}
tbody->Children.splice(tbody->Children.end(), elm.Children, it);
it = tbody;
}
else if (tbody != elm.Children.end())
{
tbody->reindexChilds();
tbody = elm.Children.end();
}
}
elm.reindexChilds();
}
} }
} }

@ -1932,6 +1932,16 @@ namespace NLGUI
return _TextureId >= 0; return _TextureId >= 0;
} }
// ***************************************************************************
void CViewRenderer::CTextureId::clear()
{
if (_TextureId >= 0)
{
CViewRenderer::getInstance()->deleteTexture(_TextureId);
_TextureId = -1;
}
}
// *************************************************************************** // ***************************************************************************
void CViewRenderer::CTextureId::serial(NLMISC::IStream &f) void CViewRenderer::CTextureId::serial(NLMISC::IStream &f)
{ {

@ -1091,7 +1091,8 @@ namespace NLGUI
else else
mouseIn= isIn(x,y); mouseIn= isIn(x,y);
// if the mouse cursor is in the clip area // if the mouse cursor is in the clip area
if(mouseIn) { if(mouseIn)
{
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, 1, 0, false, rVR.getBlankTextureId(), CRGBA(200,200,200,255)); rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, _WReal, 1, 0, false, rVR.getBlankTextureId(), CRGBA(200,200,200,255));
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_HReal, _WReal, 1, 0, false, rVR.getBlankTextureId(), CRGBA(200,200,200,255)); rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal+_HReal, _WReal, 1, 0, false, rVR.getBlankTextureId(), CRGBA(200,200,200,255));
rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, 1, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(200,200,200,255)); rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal, 1, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(200,200,200,255));
@ -2402,6 +2403,7 @@ namespace NLGUI
if (_Lines.empty()) if (_Lines.empty())
{ {
x = 0; x = 0;
fx = 0;
} }
else else
{ {

@ -135,7 +135,7 @@ CApplicationContext::~CApplicationContext()
std::string message = toString("Instance '%s' still allocated at %p", it->first.c_str(), it->second); std::string message = toString("Instance '%s' still allocated at %p", it->first.c_str(), it->second);
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
OutputDebugStringW(utf8ToWide(message)); OutputDebugStringW(nlUtf8ToWide(message));
#else #else
printf("%s\n", message.c_str()); printf("%s\n", message.c_str());
#endif #endif

@ -361,6 +361,37 @@ void CIFile::flush()
} }
} }
// ======================================================================================================
bool CIFile::readAll(std::string &buffer)
{
try
{
uint32 remaining = _FileSize;
buffer.clear();
buffer.reserve(_FileSize);
while(!eof() && remaining > 0)
{
const static uint bufsize = 1024;
char buf[bufsize];
uint32 readnow = bufsize;
if (readnow > remaining)
readnow = remaining;
serialBuffer((uint8 *)&buf[0], readnow);
buffer.append(buf, readnow);
remaining -= readnow;
}
}
catch (const EFile &)
{
// buffer state is unknown
return false;
}
return true;
}
// ====================================================================================================== // ======================================================================================================
void CIFile::getline (char *buffer, uint32 bufferSize) void CIFile::getline (char *buffer, uint32 bufferSize)
{ {

@ -48,6 +48,7 @@ const CRGBA CRGBA::Blue(0, 0, 255) ;
const CRGBA CRGBA::Magenta(255, 0, 255) ; const CRGBA CRGBA::Magenta(255, 0, 255) ;
const CRGBA CRGBA::Cyan(0, 255, 255) ; const CRGBA CRGBA::Cyan(0, 255, 255) ;
const CRGBA CRGBA::White(255, 255, 255) ; const CRGBA CRGBA::White(255, 255, 255) ;
const CRGBA CRGBA::Transparent(0, 0, 0, 0);
// *************************************************************************** // ***************************************************************************
void CRGBA::serial(NLMISC::IStream &f) void CRGBA::serial(NLMISC::IStream &f)

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -1,5 +1,5 @@
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/> // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
// Copyright (C) 2010 Winch Gate Property Limited // Copyright (C) 2008 Jan Boon (Kaetemi)
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as

@ -620,6 +620,8 @@ CClientConfig::CClientConfig()
MaxMapScale = 2.0f; MaxMapScale = 2.0f;
R2EDMaxMapScale = 8.0f; R2EDMaxMapScale = 8.0f;
TargetChangeCompass = true;
// VERBOSES // VERBOSES
VerboseVP = false; VerboseVP = false;
VerboseAnimUser = false; VerboseAnimUser = false;
@ -1501,6 +1503,9 @@ void CClientConfig::setValues()
READ_FLOAT_FV(MaxMapScale); READ_FLOAT_FV(MaxMapScale);
READ_FLOAT_FV(R2EDMaxMapScale); READ_FLOAT_FV(R2EDMaxMapScale);
// /tar to update compass or not
READ_BOOL_FV(TargetChangeCompass);
///////////// /////////////
// SHADOWS // // SHADOWS //
// Shadows : Get Shadows state // Shadows : Get Shadows state

@ -607,6 +607,9 @@ struct CClientConfig
float MaxMapScale; float MaxMapScale;
float R2EDMaxMapScale; float R2EDMaxMapScale;
// If successfull /tar command should set compass or not
bool TargetChangeCompass;
////////////// //////////////
// VERBOSES // // VERBOSES //
bool VerboseVP; bool VerboseVP;

@ -23,6 +23,7 @@
#include "nel/gui/group_container.h" #include "nel/gui/group_container.h"
#include "nel/gui/group_editbox.h" #include "nel/gui/group_editbox.h"
#include "nel/gui/group_menu.h"
#include "dbctrl_sheet.h" #include "dbctrl_sheet.h"
#include "interface_3d_scene.h" #include "interface_3d_scene.h"
#include "character_3d.h" #include "character_3d.h"
@ -74,7 +75,31 @@ class CAHActiveMenu : public IActionHandler
// open the menu // open the menu
if (CDBCtrlSheet::getDraggedSheet() == NULL) if (CDBCtrlSheet::getDraggedSheet() == NULL)
{ {
CWidgetManager::getInstance()->enableModalWindow (pCaller, getParam(Params, "menu")); std::string menuId = getParam(Params, "menu");
CGroupMenu *groupMenu = dynamic_cast<CGroupMenu*>(CWidgetManager::getInstance()->getElementFromId(menuId));
if (groupMenu)
{
bool pushModal;
// default = false
fromString(getParam(Params, "pushmodal"), pushModal);
if (pushModal)
{
// if false, then close all modal window when groupMenu deactivates
bool popModal;
if (!fromString(getParam(Params, "popmodal"), popModal))
{
popModal = true;
}
groupMenu->setCloseSubMenuUsingPopModal(popModal);
CWidgetManager::getInstance()->pushModalWindow(pCaller, groupMenu);
}
else
{
groupMenu->setCloseSubMenuUsingPopModal(false);
CWidgetManager::getInstance()->enableModalWindow(pCaller, groupMenu);
}
}
} }
} }
}; };

@ -2473,6 +2473,8 @@ class CAHTarget : public IActionHandler
if (entity && entity->properties().selectable() && !entity->getDisplayName().empty()) if (entity && entity->properties().selectable() && !entity->getDisplayName().empty())
{ {
UserEntity->selection(entity->slot()); UserEntity->selection(entity->slot());
if (ClientCfg.TargetChangeCompass)
{
CGroupCompas *gc = dynamic_cast<CGroupCompas *>(CWidgetManager::getInstance()->getElementFromId("ui:interface:compass")); CGroupCompas *gc = dynamic_cast<CGroupCompas *>(CWidgetManager::getInstance()->getElementFromId("ui:interface:compass"));
if (gc) if (gc)
{ {
@ -2485,6 +2487,7 @@ class CAHTarget : public IActionHandler
CWidgetManager::getInstance()->setTopWindow(gc); CWidgetManager::getInstance()->setTopWindow(gc);
} }
} }
}
else if (!quiet) else if (!quiet)
{ {
CInterfaceManager::getInstance()->displaySystemInfo(CI18N::get("uiTargetErrorCmd")); CInterfaceManager::getInstance()->displaySystemInfo(CI18N::get("uiTargetErrorCmd"));

@ -100,7 +100,6 @@ void CControlSheetInfoWaiter::infoReceived()
ucstring CControlSheetInfoWaiter::infoValidated() const ucstring CControlSheetInfoWaiter::infoValidated() const
{ {
ucstring help; ucstring help;
if (CtrlSheet && !LuaMethodName.empty()) if (CtrlSheet && !LuaMethodName.empty())
{ {
// delegate setup of context he help ( & window ) to lua // delegate setup of context he help ( & window ) to lua
@ -3390,6 +3389,9 @@ void CDBCtrlSheet::getContextHelp(ucstring &help) const
// call lua function to update tooltip window // call lua function to update tooltip window
_ItemInfoWaiter.sendRequest(); _ItemInfoWaiter.sendRequest();
help = _ItemInfoWaiter.infoValidated(); help = _ItemInfoWaiter.infoValidated();
// its expected to get at least item name back
if (help.empty())
help = getItemActualName();
} }
else if (!_ContextHelp.empty()) else if (!_ContextHelp.empty())
{ {

@ -2596,6 +2596,9 @@ static void hideTeleportButtonsInPopupMenuIfNotEnoughPriv()
ie = CWidgetManager::getInstance()->getElementFromId("ui:interface:user_land_mark_menu:lmteleport"); ie = CWidgetManager::getInstance()->getElementFromId("ui:interface:user_land_mark_menu:lmteleport");
if(ie) ie->setActive(showTeleport); if(ie) ie->setActive(showTeleport);
ie = CWidgetManager::getInstance()->getElementFromId("ui:interface:user_land_mark_menu_base:lmteleport");
if(ie) ie->setActive(showTeleport);
} }
//============================================================================================================ //============================================================================================================
@ -2659,8 +2662,8 @@ CGroupMap::CLandMarkButton *CGroupMap::createLandMarkButton(const CLandMarkOptio
lmb->setModulateGlobalColorAll(false); lmb->setModulateGlobalColorAll(false);
if (!options.LandMarkMenu.empty()) if (!options.LandMarkMenu.empty())
{ {
lmb->setActionOnRightClick("active_menu"); lmb->setActionOnRightClick("world_map_right_click");
lmb->setParamsOnRightClick(NLMISC::toString("menu=%s", options.LandMarkMenu.c_str())); lmb->setParamsOnRightClick(NLMISC::toString("map=%s|menu=%s", _Id.c_str(), options.LandMarkMenu.c_str()));
} }
lmb->setPosRef(Hotspot_MM); lmb->setPosRef(Hotspot_MM);
return lmb; return lmb;
@ -2744,6 +2747,23 @@ CCtrlButton *CGroupMap::addUserLandMark(const NLMISC::CVector2f &pos, const ucst
return _UserLM.back(); return _UserLM.back();
} }
//============================================================================================================
CCtrlButton* CGroupMap::getLandmarkCtrl(const std::string &lmType, uint lmIndex) const
{
CCtrlButton *ctrl = NULL;
if (lmType == "user")
{
if (lmIndex < _UserLM.size())
{
ctrl = _UserLM[lmIndex];
}
else nlwarning("_UserLM index out of bounds (size:%u, index:%u)", (uint)_UserLM.size(), lmIndex);
}
else nlwarning("unsupported landmark type '%s'", lmType.c_str());
return ctrl;
}
//============================================================================================================ //============================================================================================================
void CGroupMap::removeUserLandMark(CCtrlButton *button) void CGroupMap::removeUserLandMark(CCtrlButton *button)
{ {
@ -3557,6 +3577,126 @@ int CGroupMap::luaIsIsland(CLuaState &ls)
// ACTION HANDLERS // // ACTION HANDLERS //
///////////////////// /////////////////////
//=========================================================================================================
void CGroupMap::updateClosestLandMarkMenu(const std::string &menu, const NLMISC::CVector2f &pos) const
{
static uint nbShowLandmarks = 5;
static uint nbShowLandmarksMax = 5;
const CGroupMenu *pMenu = dynamic_cast<CGroupMenu *>(CWidgetManager::getInstance()->getElementFromId(menu));
if (!pMenu) return;
CGroupSubMenu *rootMenu = pMenu->getRootMenu();
if (!rootMenu) return;
// remove previous markers from menu
for(uint i = 0; i < nbShowLandmarksMax; ++i)
{
std::string lineId = toString("%s:lmcosest%d", menu.c_str(), i);
sint index = rootMenu->getLineFromId(lineId);
if (index < 0) break;
rootMenu->removeLine(index);
}
// no continent selected (ie world map view)
if (!_CurContinent) return;
// sort landmarks, keep indices
typedef std::pair<uint, float> TSortedDistPair;
std::vector<TSortedDistPair> sortedIndices;
for(uint i = 0; i < _CurContinent->UserLandMarks.size(); ++i)
{
float dist = distsqr(pos, _CurContinent->UserLandMarks[i].Pos);
if (sortedIndices.empty())
{
sortedIndices.push_back(TSortedDistPair(i, dist));
}
else
{
bool found = false;
for(uint j = 0; j< sortedIndices.size(); j++)
{
if (dist < sortedIndices[j].second)
{
sortedIndices.insert(sortedIndices.begin() + j, TSortedDistPair(i, dist));
found = true;
if (sortedIndices.size() > nbShowLandmarks)
{
sortedIndices.pop_back();
}
break;
}
}
if (!found && sortedIndices.size() < nbShowLandmarks)
{
sortedIndices.push_back(TSortedDistPair(i, dist));
}
}
}
// add landmarks to menu
uint lineIndex = rootMenu->getNumLines();
for(uint i = 0; i< sortedIndices.size(); ++i)
{
uint32 index = sortedIndices[i].first;
ucstring name = ucstring(toString("%.2fm ", sqrt(sortedIndices[i].second))) + _CurContinent->UserLandMarks[index].Title;
std::string lineId = toString("%s:lmcosest%d", menu.c_str(), i);
std::string ahParams = toString("type=user|map=%s|index=%d", _Id.c_str(), index);
CViewTextMenu* vt = rootMenu->addLine(ucstring(""), "map_landmark_by_index", ahParams, lineId.c_str(), "", "", false, false, false);
if (!vt) break;
vt->setSingleLineTextFormatTaged(name);
// TODO: should calculate from mouse pos and client width
vt->setLineMaxW(800);
CLandMarkOptions options = getUserLandMarkOptions(index);
typedef std::pair<std::string, std::string> TTmplParams;
std::vector<TTmplParams> vparams;
vparams.push_back(TTmplParams("id", toString("lmicon%d", i)));
vparams.push_back(TTmplParams("sizeref", ""));
vparams.push_back(TTmplParams("icon_texture", options.LandMarkTexNormal));
vparams.push_back(TTmplParams("icon_color", options.ColorNormal.toString()));
CInterfaceGroup *pUGLeft = CWidgetManager::getInstance()->getParser()->createGroupInstance("landmark_row_icon", lineId, vparams);
if (pUGLeft)
rootMenu->setUserGroupLeft(lineIndex, pUGLeft, true);
rootMenu->setRightClickHandler(lineIndex, "map_landmark_by_index");
rootMenu->setRightClickHandlerParam(lineIndex, toString("%s|menu=%s_base", ahParams.c_str(), options.LandMarkMenu.c_str()));
lineIndex++;
}
}
//=========================================================================================================
// remap caller with landmark using index/type and call popup menu or set compass target if no menu is set
class CAHMapLandmarkByIndex : public IActionHandler
{
virtual void execute (CCtrlBase* pCaller, const string &params )
{
const std::string mapName = getParam(params, "map");
const std::string lmType = getParam(params, "type");
const std::string menuId = getParam(params, "menu");
uint index;
if (!fromString(getParam(params, "index"), index)) return;
CGroupMap *map = dynamic_cast<CGroupMap *>(CWidgetManager::getInstance()->getElementFromId(mapName));
if (!map) return;
// remap caller to landmark from menu row
CCtrlButton* pButton = map->getLandmarkCtrl(lmType, index);
if (!pButton) return;
if (menuId.empty())
map->targetLandmark(pButton);
else
CAHManager::getInstance()->runActionHandler("active_menu", pButton, toString("pushmodal=true|popmodal=false|menu=%s", menuId.c_str()));
}
};
REGISTER_ACTION_HANDLER(CAHMapLandmarkByIndex, "map_landmark_by_index");
//========================================================================================================= //=========================================================================================================
// Set landmark filter // Set landmark filter
class CAHLandMarkFilter : public IActionHandler class CAHLandMarkFilter : public IActionHandler
@ -3861,20 +4001,45 @@ class CAHWorldMapRightClick : public IActionHandler
virtual void execute (CCtrlBase *pCaller, const string &params) virtual void execute (CCtrlBase *pCaller, const string &params)
{ {
std::string map = getParam(params, "map"); std::string map = getParam(params, "map");
CInterfaceManager *im = CInterfaceManager::getInstance(); std::string menu = getParam(params, "menu");
hideTeleportButtonsInPopupMenuIfNotEnoughPriv(); hideTeleportButtonsInPopupMenuIfNotEnoughPriv();
CGroupMap *gm = dynamic_cast<CGroupMap *>(CWidgetManager::getInstance()->getElementFromId(map)); CGroupMap *gm = dynamic_cast<CGroupMap *>(CWidgetManager::getInstance()->getElementFromId(map));
if (!gm) return; if (!gm) return;
if (!gm->isIsland())
if (gm->isIsland())
{ {
CAHManager::getInstance()->runActionHandler("active_menu", pCaller, "menu=ui:interface:map_menu"); if (gm->getArkPowoMode() == "editor")
menu = gm->getArkPowoMapMenu();
else
menu = "ui:interface:map_menu_island";
} }
else else
{ {
<<<<<<< HEAD
CAHManager::getInstance()->runActionHandler("active_menu", pCaller, "menu=ui:interface:map_menu_island"); CAHManager::getInstance()->runActionHandler("active_menu", pCaller, "menu=ui:interface:map_menu_island");
=======
if (menu.empty())
menu = "ui:interface:map_menu";
// update menu with closest landmarks
NLMISC::CVector2f pos(NLMISC::CVector2f::Null);
CCtrlButton *button = dynamic_cast<CCtrlButton *>(pCaller);
if (button)
gm->getLandmarkPosition(button, pos);
if(pos == NLMISC::CVector2f::Null)
{
pos = gm->getRightClickLastPos();
gm->mapToWorld(pos, pos);
}
gm->updateClosestLandMarkMenu(menu, pos);
>>>>>>> origin/develop
} }
CAHManager::getInstance()->runActionHandler("active_menu", pCaller, "menu=" + menu);
} }
}; };
REGISTER_ACTION_HANDLER(CAHWorldMapRightClick, "world_map_right_click") REGISTER_ACTION_HANDLER(CAHWorldMapRightClick, "world_map_right_click")

@ -177,6 +177,8 @@ public:
float getScale() const { return _UserScale; } float getScale() const { return _UserScale; }
/// add a user landmark (returns a pointer on its button).Coordinate are in the current map (not world coordinates) /// add a user landmark (returns a pointer on its button).Coordinate are in the current map (not world coordinates)
CCtrlButton *addUserLandMark(const NLMISC::CVector2f &pos, const ucstring &title, const CUserLandMark::EUserLandMarkType lmType); CCtrlButton *addUserLandMark(const NLMISC::CVector2f &pos, const ucstring &title, const CUserLandMark::EUserLandMarkType lmType);
/// return current continent landmark by its index and type
CCtrlButton* getLandmarkCtrl(const std::string &lmType, uint lmIndex) const;
// remove a user landmark from a pointer on its button // remove a user landmark from a pointer on its button
void removeUserLandMark(CCtrlButton *button); void removeUserLandMark(CCtrlButton *button);
// update a user landmark from a pointer on its button // update a user landmark from a pointer on its button
@ -260,6 +262,8 @@ public:
bool isIsland() const { return _IsIsland; } bool isIsland() const { return _IsIsland; }
void updateClosestLandMarkMenu(const std::string &menu, const NLMISC::CVector2f &pos) const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private: private:
// A non rectangular button to click on zone of the map // A non rectangular button to click on zone of the map

Loading…
Cancel
Save