[glass] Add application icon

This commit is contained in:
Peter Johnson
2020-12-23 13:05:44 -08:00
parent 7ac39b10f7
commit 4204da6ad4
17 changed files with 65 additions and 4 deletions

View File

@@ -5,5 +5,5 @@ repositories {
}
}
dependencies {
implementation "edu.wpi.first:native-utils:2021.0.6"
implementation "edu.wpi.first:native-utils:2021.1.0"
}

5
glass/.styleguide Normal file
View File

@@ -0,0 +1,5 @@
generatedFileExclude {
src/app/native/resources/
src/app/native/win/glass.ico
src/app/native/mac/glass.icns
}

View File

@@ -1,6 +1,7 @@
project(glass)
include(CompileWarnings)
include(GenResources)
include(LinkMacOSGUI)
#
@@ -49,13 +50,26 @@ install(DIRECTORY src/libnt/native/include/ DESTINATION "${include_dest}/glass")
# glass application
#
GENERATE_RESOURCES(src/app/native/resources generated/app/cpp GLASS glass glass_resources_src)
file(GLOB glass_src src/app/native/cpp/*.cpp)
add_executable(glass ${glass_src})
if (WIN32)
set(glass_rc src/app/native/win/glass.rc)
elseif(APPLE)
set(MACOSX_BUNDLE_ICON_FILE glass.icns)
set(APP_ICON_MACOSX src/app/native/mac/glass.icns)
set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
endif()
add_executable(glass ${glass_src} ${glass_resources_src} ${glass_rc} ${APP_ICON_MACOSX})
wpilib_link_macos_gui(glass)
target_link_libraries(glass libglassnt libglass)
if (WIN32)
set_target_properties(glass PROPERTIES WIN32_EXECUTABLE YES)
elseif(APPLE)
set_target_properties(glass PROPERTIES MACOSX_BUNDLE YES OUTPUT_NAME "Glass")
endif()
#if (MSVC OR FLAT_INSTALL_WPILIB)

View File

@@ -10,6 +10,8 @@
<string>Glass</string>
<key>CFBundleIdentifier</key>
<string>edu.wpi.first.tools.Glass</string>
<key>CFBundleIconFile</key>
<string>glass.icns</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSupportedPlatforms</key>

View File

@@ -1,3 +1,5 @@
import org.gradle.internal.os.OperatingSystem
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {
description = "A different kind of dashboard"
@@ -8,13 +10,23 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
if (OperatingSystem.current().isWindows()) {
apply plugin: 'windows-resources'
}
ext {
nativeName = 'glass'
}
apply from: "${rootDir}/shared/resources.gradle"
apply from: "${rootDir}/shared/config.gradle"
def generateTask = createGenerateResourcesTask('app', 'GLASS', 'glass', project)
project(':').libraryBuild.dependsOn build
tasks.withType(CppCompile) {
dependsOn generateTask
}
nativeUtils.exportsConfigs {
glass {
@@ -35,7 +47,7 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
sources {
cpp {
source {
srcDirs = ['src/lib/native/cpp']
srcDirs 'src/lib/native/cpp'
include '**/*.cpp'
}
exportedHeaders {
@@ -96,13 +108,20 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
sources {
cpp {
source {
srcDirs 'src/app/native/cpp'
srcDirs 'src/app/native/cpp', "$buildDir/generated/app/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/app/native/include'
}
}
if (OperatingSystem.current().isWindows()) {
rc {
source {
srcDirs 'src/app/native/win'
}
}
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) {

View File

@@ -14,6 +14,7 @@ model {
// We are now in the binary that we want.
// This is the default application path for the ZIP task.
def applicationPath = binary.executable.file
def icon = file("$project.projectDir/src/app/native/mac/glass.icns")
// Create the macOS bundle.
def bundleTask = project.tasks.create("bundleGlassOsxApp", Copy) {
@@ -21,6 +22,7 @@ model {
from(file("$project.projectDir/Info.plist"))
into(file("$project.buildDir/outputs/bundles/Glass.app/Contents"))
into("MacOS") { with copySpec { from binary.executable.file } }
into("Resources") { with copySpec { from icon } }
doLast {
if (project.hasProperty("developerID")) {

View File

@@ -23,6 +23,16 @@
namespace gui = wpi::gui;
namespace glass {
wpi::StringRef GetResource_glass_16_png();
wpi::StringRef GetResource_glass_32_png();
wpi::StringRef GetResource_glass_48_png();
wpi::StringRef GetResource_glass_64_png();
wpi::StringRef GetResource_glass_128_png();
wpi::StringRef GetResource_glass_256_png();
wpi::StringRef GetResource_glass_512_png();
} // namespace glass
static std::unique_ptr<glass::PlotProvider> gPlotProvider;
static std::unique_ptr<glass::NetworkTablesProvider> gNtProvider;
@@ -88,6 +98,14 @@ int main() {
gui::CreateContext();
glass::CreateContext();
gui::AddIcon(glass::GetResource_glass_16_png());
gui::AddIcon(glass::GetResource_glass_32_png());
gui::AddIcon(glass::GetResource_glass_48_png());
gui::AddIcon(glass::GetResource_glass_64_png());
gui::AddIcon(glass::GetResource_glass_128_png());
gui::AddIcon(glass::GetResource_glass_256_png());
gui::AddIcon(glass::GetResource_glass_512_png());
gPlotProvider = std::make_unique<glass::PlotProvider>("Plot");
gNtProvider = std::make_unique<glass::NetworkTablesProvider>("NTProvider");

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

View File

@@ -0,0 +1 @@
IDI_ICON1 ICON "glass.ico"