cycfi / elements

Elements C++ GUI library
http://cycfi.github.io/elements/
3.12k stars 237 forks source link

where is the treeview example? #89

Closed stonedreamforest closed 4 years ago

stonedreamforest commented 4 years ago

listview etc...

djowel commented 4 years ago

Not at the moment, no. I am working an easy to use API. Of course you can also build those from standard elements such as tiles and grids, but it will be nice to have a clean, easy to use API.

BTW, do you have a list of features in mind?

stonedreamforest commented 4 years ago
  1. treeview
  2. listview
  3. tabview
  4. font/color/datedialog
stonedreamforest commented 4 years ago

I add it to my project and the compilation will failed

maindir\
    myproject\
        main.cpp
        cmakelists.txt
    submoudle\
        elements\

there is cmakelists.txt

set(ELEMENTS_APP_PROJECT "TEST1")
set(ELEMENTS_APP_TITLE "TEST2")
set(ELEMENTS_APP_COPYRIGHT "TEST3")
set(ELEMENTS_APP_ID "TEST4")
set(ELEMENTS_APP_VERSION "TEST5")

include("../submoudle/elements/CMakeMain.txt")
run vc.bat
cd myproject
mkdir build && cd build
cmake -G"NMake Makefiles" -DBOOST_ROOT=E:/boost_1_72_0 ..
djowel commented 4 years ago

Not sure how I can help you here given that information alone. What are the errors? Did cmake succeed?

stonedreamforest commented 4 years ago
C:\Users\sssss\Documents\test\build>cmake -G"NMake Makefiles" -DBOOST_ROOT=E:/boost_1_72_0 ..
-- The C compiler identification is MSVC 19.25.28614.0
-- The CXX compiler identification is MSVC 19.25.28614.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.25.28610/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.25.28610/bin/Hostx86/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.25.28610/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.25.28610/bin/Hostx86/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    BOOST_ROOT

-- Build files have been written to: C:/Users/sssss/Documents/test/build

C:\Users\sssss\Documents\test\build>nmake

Microsoft (R) Program Maintenance Utility Version 14.25.28614.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Scanning dependencies of target Dialogs
[ 50%] Building CXX object CMakeFiles/Dialogs.dir/main.cpp.obj
main.cpp
C:\Users\sssss\Documents\test\main.cpp(6): fatal error C1083: Cannot open include file: 'elements.hpp': No such file or directory
NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1\2019\PROFES~1\VC\Tools\MSVC\1425~1.286\bin\Hostx86\x86\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.25.28610\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.25.28610\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
stonedreamforest commented 4 years ago

i already make it work normally with use this configure:

###############################################################################
#  Copyright (c) 2016-2020 Joel de Guzman
#
#  Distributed under the MIT License (https://opensource.org/licenses/MIT)
###############################################################################
cmake_minimum_required(VERSION 3.9.6...3.15.0)

project(elements LANGUAGES C CXX)

set(DEFAULT_BUILD_TYPE "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
    message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
    set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE
        STRING "Choose the type of build." FORCE)
    # Set the possible values of build type for cmake-gui
    set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
        "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED)
if(MINGW)
    set(IPO_SUPPORTED FALSE)
endif()
if(IPO_SUPPORTED)
    message(STATUS "Link-time optimization supported. Will be enabled in Release build type")
endif()

###############################################################################
# UI Libraries

if(WIN32)
    set(HOST_UI_LIBRARY "win32" CACHE STRING "gtk, cocoa or win32")
elseif(UNIX AND NOT APPLE)
    set(HOST_UI_LIBRARY "gtk" CACHE STRING "gtk, cocoa or win32")
elseif(APPLE)
    set(HOST_UI_LIBRARY "cocoa" CACHE STRING "gtk, cocoa or win32")
endif()

if(HOST_UI_LIBRARY STREQUAL "gtk")
    add_definitions(-DELEMENTS_HOST_UI_LIBRARY_GTK)
elseif(HOST_UI_LIBRARY STREQUAL "cocoa")
    add_definitions(-DELEMENTS_HOST_UI_LIBRARY_COCOA)
    if(NOT APPLE)
        message(FATAL_ERROR "Only macOS support HOST_UI_LIBRARY=cocoa")
    endif()
elseif(HOST_UI_LIBRARY STREQUAL "win32")
    add_definitions(-DELEMENTS_HOST_UI_LIBRARY_WIN32)
    if(NOT WIN32)
        message(FATAL_ERROR "Only Windows support HOST_UI_LIBRARY=win32")
    endif()
else()
    message(FATAL_ERROR "Invalid HOST_UI_LIBRARY=" ${HOST_UI_LIBRARY}
            ". Support gtk, cocoa and win32")
endif()

###############################################################################

add_subdirectory(./../submoudle/elements/lib lib.out)

set(ELEMENTS_APP_PROJECT "Dialogs")
set(ELEMENTS_APP_TITLE "Dialogs")
set(ELEMENTS_APP_COPYRIGHT "Copyright (c) 2016-2020 Joel de Guzman")
set(ELEMENTS_APP_ID "com.cycfi.dialogs")
set(ELEMENTS_APP_VERSION "1.0")

include("./../submoudle/elements/CMakeMain.txt")

It looks terrible but works fine.

djowel commented 4 years ago

That looks terrible indeed. It should not work like that. Out of project builds should work just fine. @Xeverous it seems something happened in the cmake modernization that causes this? I'd appreciate it is you could you take a look.

Xeverous commented 4 years ago

@stonedreamforest Which commit exactly are you trying to build?

stonedreamforest commented 4 years ago

the last commit

djowel commented 4 years ago

@stonedreamforest Which commit exactly are you trying to build?

The issue here is that you should be able to easily take one of the examples (e.g. starter) and place them anywhere, adjust the cmake include path and it should build. Please make sure that is the case. It seems now that the examples can only build from the root elements project directory.

Xeverous commented 4 years ago

@stonedreamforest don't you think that "the last commit" is a bit ambiguous and may change over time? I don't get your exact problem.

stonedreamforest commented 4 years ago

there is full outputs

  1. clone
    
    **********************************************************************
    ** Visual Studio 2019 Developer Command Prompt v16.5.4
    ** Copyright (c) 2019 Microsoft Corporation
    **********************************************************************
    [vcvarsall.bat] Environment initialized for: 'x86'

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>cd C:\Users\sssss\Desktop\123123123

C:\Users\sssss\Desktop\123123123>git clone --recursive https://github.com/cycfi/elements.git Cloning into 'elements'... remote: Enumerating objects: 384, done. remote: Counting objects: 100% (384/384), done. remote: Compressing objects: 100% (190/190), done. remote: Total 14325 (delta 223), reused 308 (delta 194), pack-reused 13941 Receiving objects: 100% (14325/14325), 24.68 MiB | 4.94 MiB/s, done. Resolving deltas: 100% (9449/9449), done. Submodule 'lib/infra' (https://github.com/cycfi/infra) registered for path 'lib/infra' Submodule 'lib/json' (https://github.com/cycfi/json.git) registered for path 'lib/json' Cloning into 'C:/Users/sssss/Desktop/123123123/elements/lib/infra'... remote: Enumerating objects: 48, done. remote: Counting objects: 100% (48/48), done. remote: Compressing objects: 100% (24/24), done. remote: Total 204 (delta 20), reused 40 (delta 14), pack-reused 156 Receiving objects: 100% (204/204), 197.04 KiB | 3.00 KiB/s, done. Resolving deltas: 100% (94/94), done. Cloning into 'C:/Users/sssss/Desktop/123123123/elements/lib/json'... remote: Enumerating objects: 36, done. remote: Counting objects: 100% (36/36), done. remote: Compressing objects: 100% (25/25), done. remote: Total 158 (delta 8), reused 26 (delta 7), pack-reused 122 Receiving objects: 100% (158/158), 79.44 KiB | 260.00 KiB/s, done. Resolving deltas: 100% (62/62), done. Submodule path 'lib/infra': checked out '09282625563a5c896bdaed6a8d5119ef4b635ef6' Submodule 'external/filesystem' (https://github.com/gulrak/filesystem.git) registered for path 'lib/infra/external/filesystem' Cloning into 'C:/Users/sssss/Desktop/123123123/elements/lib/infra/external/filesystem'... remote: Enumerating objects: 159, done. remote: Counting objects: 100% (159/159), done. remote: Compressing objects: 100% (99/99), done. remote: Total 1605 (delta 93), reused 91 (delta 36), pack-reused 1446 Receiving objects: 100% (1605/1605), 613.66 KiB | 647.00 KiB/s, done. Resolving deltas: 100% (1036/1036), done. Submodule path 'lib/infra/external/filesystem': checked out '3605e869150032ffdd9eae3db93e12f8711a0c82' Submodule path 'lib/json': checked out 'fb4e03c4a83a2da2c931a2bf84f2c19d2bda531b' Submodule 'infra' (https://github.com/cycfi/infra) registered for path 'lib/json/infra' Cloning into 'C:/Users/sssss/Desktop/123123123/elements/lib/json/infra'... remote: Enumerating objects: 48, done. remote: Counting objects: 100% (48/48), done. remote: Compressing objects: 100% (24/24), done. remote: Total 204 (delta 20), reused 40 (delta 14), pack-reused 156 Receiving objects: 100% (204/204), 197.04 KiB | 302.00 KiB/s, done. Resolving deltas: 100% (94/94), done. Submodule path 'lib/json/infra': checked out '09282625563a5c896bdaed6a8d5119ef4b635ef6' Submodule 'external/filesystem' (https://github.com/gulrak/filesystem.git) registered for path 'lib/json/infra/external/filesystem' Cloning into 'C:/Users/sssss/Desktop/123123123/elements/lib/json/infra/external/filesystem'... remote: Enumerating objects: 159, done. remote: Counting objects: 100% (159/159), done. remote: Compressing objects: 100% (99/99), done. remote: Total 1605 (delta 93), reused 91 (delta 36), pack-reused 1446 Receiving objects: 100% (1605/1605), 613.66 KiB | 676.00 KiB/s, done. Resolving deltas: 100% (1036/1036), done. Submodule path 'lib/json/infra/external/filesystem': checked out '3605e869150032ffdd9eae3db93e12f8711a0c82'

2. copy `elements` to submoudle folder
3. copy `submoudle\elements\examples\dialogs` files to myproject dir
4. edit cmakelists.txt
```cmakelists.txt
###############################################################################
#  Copyright (c) 2016-2020 Joel de Guzman
#
#  Distributed under the MIT License (https://opensource.org/licenses/MIT)
###############################################################################
set(ELEMENTS_APP_PROJECT "Dialogs")
set(ELEMENTS_APP_TITLE "Dialogs")
set(ELEMENTS_APP_COPYRIGHT "Copyright (c) 2016-2020 Joel de Guzman")
set(ELEMENTS_APP_ID "com.cycfi.dialogs")
set(ELEMENTS_APP_VERSION "1.0")
# change to relative directory here
include("../submoudle/elements/CMakeMain.txt")

folder tree diagram:

maindir\
    myproject\
        main.cpp
        cmakelists.txt
    submoudle\
        elements\
  1. cmake
    
    C:\Users\sssss\Desktop\123123123>cd C:\Users\sssss\Desktop\123123123

C:\Users\sssss\Desktop\123123123>cd myproject

C:\Users\sssss\Desktop\123123123\myproject>mkdir build && cd build

C:\Users\sssss\Desktop\123123123\myproject\build>cmake -G"NMake Makefiles" -DBOOST_ROOT=E:/open.src/boost_1_72_0 .. CMake Warning (dev) in CMakeLists.txt: No project() command is present. The top-level CMakeLists.txt file must contain a literal, direct call to the project() command. Add a line of code such as

project(ProjectName)

near the top of the file, but after cmake_minimum_required().

CMake is pretending there is a "project(Project)" command on the first line. This warning is for project developers. Use -Wno-dev to suppress it.

-- The C compiler identification is MSVC 19.25.28614.0 -- The CXX compiler identification is MSVC 19.25.28614.0 -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.25.28610/bin/Hostx86/x86/cl.exe -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.25.28610/bin/Hostx86/x86/cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.25.28610/bin/Hostx86/x86/cl.exe -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.25.28610/bin/Hostx86/x86/cl.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 3.16)

should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more information run "cmake --help-policy CMP0000". This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring done -- Generating done CMake Warning: Manually-specified variables were not used by the project:

BOOST_ROOT

-- Build files have been written to: C:/Users/sssss/Desktop/123123123/myproject/build

6. nmake

C:\Users\sssss\Desktop\123123123\myproject\build>nmake

Microsoft (R) Program Maintenance Utility Version 14.25.28614.0 Copyright (C) Microsoft Corporation. All rights reserved.

Scanning dependencies of target Dialogs [ 50%] Building CXX object CMakeFiles/Dialogs.dir/main.obj main.cpp C:\Users\sssss\Desktop\123123123\myproject\main.cpp(6): fatal error C1083: Cannot open include file: 'elements.hpp': No such file or directory NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1\2019\PROFES~1\VC\Tools\MSVC\1425~1.286\bin\Hostx86\x86\cl.exe' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.25.28610\bin\HostX86\x86\nmake.exe"' : return code '0x2' Stop. NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.25.28610\bin\HostX86\x86\nmake.exe"' : return code '0x2' Stop.

C:\Users\sssss\Desktop\123123123\myproject\build>

Xeverous commented 4 years ago

I guess the problem is that elements examples include this file: https://github.com/cycfi/elements/blob/master/CMakeMain.txt

You are probably getting results of empty/broken CMake include function, which uses a non-existent variable which are empty strings by default. You moved examples and the paths likely broke.

@djowel and @stonedreamforest read this: https://gitlab.com/CLIUtils/modern-cmake/-/issues/24

IMO we should avoid including fixed CMake file filled with tons of variables to make recipes for examples. It's not really a code duplication and Henry makes some good points in the discussion.

djowel commented 4 years ago

So what should we do to satisfy the goal (allow easy out-of-project build)? I don't care how it's done as long as the goal is satisfied.

Xeverous commented 4 years ago

Definitely fix #91 first. Then remove CMakeMain.txt inclusion mechanism to let every example build its own recipe (they will be almost identical).

djowel commented 4 years ago

It looks terrible but works fine.

OK, I fixed this in develop and master. Now you can copy and paste any of the examples outside the project, set -DELEMENTS_ROOT ="path/to/elements". And the example should immediately build without any hassle.

djowel commented 4 years ago

I added instruction on how to build the examples outside the project: http://cycfi.github.io/elements/setup#building-outside-the-project

redtide commented 4 years ago

Maybe not the right place to ask, about those CMakeMain|Include.txt, could they be replaced by some ElementsConfig.cmake in the cmake directory?

djowel commented 4 years ago

Maybe not the right place to ask, about those CMakeMain|Include.txt, could they be replaced by some ElementsConfig.cmake in the cmake directory?

Sounds like a good idea!

redtide commented 4 years ago

Regarding those files I tried something here, not sure if the right way to do it. I've also added some missing titles in some example's CMakeLists. I noticed it seems we miss some ELEMENTS_APP_ICON? This for the application executable (except for unix) and for the window title.

OT: On our plugin we need c++14 compatibility; could be accepted some backport to c++14 (mainly because string_views)?

djowel commented 4 years ago

Regarding those files I tried something here, not sure if the right way to do it. I've also added some missing titles in some example's CMakeLists. I noticed it seems we miss some ELEMENTS_APP_ICON? This for the application executable (except for unix) and for the window title.

OT: On our plugin we need c++14 compatibility; could be accepted some backport to c++14 (mainly because string_views)?

Can we move to a new github issue instead for discussion, so it won't be confusing?

redtide commented 1 year ago

FTR this was a duplicate of #39 if based on the title, though it mention views in general.