Skip to content

Commit

Permalink
Core UI grid development, layout begins.
Browse files Browse the repository at this point in the history
  • Loading branch information
furby-tm committed May 9, 2024
1 parent 97da658 commit 5d57270
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 129 deletions.
28 changes: 24 additions & 4 deletions Kraken.usda
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,29 @@ def Xform "Geometry"
double3 xformOp:translate = (0, 5, 0)
uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:scale"]

def Capsule "Sphere"
def Sphere "Sphere" (
prepend apiSchemas = ["MaterialBindingAPI"]
)
{
double3 xformOp:translate = (0, 0, -3)
rel material:binding = </Materials/RedMaterial>
double3 xformOp:translate = (0, 0, -5)
uniform token[] xformOpOrder = ["xformOp:translate"]
}
}
}
}

def "Materials"
{
def Material "RedMaterial"
{
token outputs:surface.connect = </Materials/RedMaterial/PBRShader.outputs:surface>

def Shader "PBRShader"
{
uniform token info:id = "UsdPreviewSurface"
color3f inputs:diffuseColor = (0.992, 0.207, 0.061)
float inputs:metallic = 0
float inputs:roughness = 0.4
token outputs:surface
}
}
}
124 changes: 90 additions & 34 deletions Sources/Kraken/KR/KR.Kraken.swift
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
/* --------------------------------------------------------------
* :: : K R A K E N : ::
* --------------------------------------------------------------
* @wabistudios :: metaverse :: kraken
/* ----------------------------------------------------------------
* :: : M E T A V E R S E : ::
* ----------------------------------------------------------------
* This software is Licensed under the terms of the Apache License,
* version 2.0 (the "Apache License") with the following additional
* modification; you may not use this file except within compliance
* of the Apache License and the following modification made to it.
* Section 6. Trademarks. is deleted and replaced with:
*
* This program is free software; you can redistribute it, and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* Trademarks. This License does not grant permission to use any of
* its trade names, trademarks, service marks, or the product names
* of this Licensor or its affiliates, except as required to comply
* with Section 4(c.) of this License, and to reproduce the content
* of the NOTICE file.
*
* 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. Check out
* the GNU General Public License for more details.
* This software is distributed in the hope that it will be useful,
* but WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND without even an
* implied warranty of MERCHANTABILITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the Apache License for more details.
*
* You should have received a copy for this software license, the
* GNU General Public License along with this program; or, if not
* write to the Free Software Foundation, Inc., to the address of
* You should have received a copy for this software license of the
* Apache License along with this program; or, if not, please write
* to the Free Software Foundation Inc., with the following address
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (C) 2023 Wabi Foundation.
* All Rights Reserved.
* --------------------------------------------------------------
* Copyright (C) 2024 Wabi Foundation. All Rights Reserved.
* ----------------------------------------------------------------
* . x x x . o o o . x x x . : : : . o x o . : : : .
* -------------------------------------------------------------- */
* ---------------------------------------------------------------- */

import CxxStdlib
import Foundation
Expand Down Expand Up @@ -89,26 +93,78 @@ public struct Kraken: SwiftUI.App
}
else
{
HStack
VStack(spacing: 0)
{
Kraken.UI.CodeEditor(
document: $usdFile,
stage: $stage,
fileURL: usdFile.fileURL
)
Divider()

VStack
HStack(spacing: 0)
{
SceneView(
scene: try? SCNScene(url: usdFile.fileURL ?? Kraken.IO.Stage.manager.getTmpURL()),
options: [
.allowsCameraControl,
.autoenablesDefaultLighting,
],
antialiasingMode: .multisampling4X
Button
{} label:
{
Image("wabi.hexagon.fill", bundle: .module)
}
.buttonStyle(.borderless)
.font(.system(size: 12, weight: .medium))
.padding(.init(top: 4, leading: 12, bottom: 4, trailing: 12))
.foregroundStyle(.white.opacity(0.7))
.background(RoundedRectangle(cornerRadius: 4, style: .continuous).fill(.clear))

Button("File")
{}
.buttonStyle(.borderless)
.font(.system(size: 12, weight: .medium))
.padding(.init(top: 4, leading: 12, bottom: 4, trailing: 12))
.foregroundStyle(.white.opacity(0.7))
.background(RoundedRectangle(cornerRadius: 4, style: .continuous).fill(.clear))

Button("Edit")
{}
.buttonStyle(.borderless)
.font(.system(size: 12, weight: .medium))
.padding(.init(top: 4, leading: 12, bottom: 4, trailing: 12))
.foregroundStyle(.white.opacity(0.7))
.background(RoundedRectangle(cornerRadius: 4, style: .continuous).fill(.clear))

Button("Render")
{}
.buttonStyle(.borderless)
.font(.system(size: 12, weight: .medium))
.padding(.init(top: 4, leading: 12, bottom: 4, trailing: 12))
.foregroundStyle(.white.opacity(0.7))
.background(RoundedRectangle(cornerRadius: 4, style: .continuous).fill(.clear))

Button("Window")
{}
.buttonStyle(.borderless)
.font(.system(size: 12, weight: .medium))
.padding(.init(top: 4, leading: 12, bottom: 4, trailing: 12))
.foregroundStyle(.white.opacity(0.7))
.background(RoundedRectangle(cornerRadius: 4, style: .continuous).fill(.clear))

Spacer()
}
.frame(height: 17)
.padding(4)
.zIndex(2)
.background(.black.opacity(0.3))

Divider()

HStack(spacing: 0)
{
Kraken.UI.CodeEditor(
document: $usdFile,
stage: $stage,
fileURL: usdFile.fileURL
)

Divider()

Kraken.UI.SceneView(
fileURL: usdFile.fileURL ?? Kraken.IO.Stage.manager.getTmpURL()
)
}
.frame(maxWidth: .infinity, alignment: .leading)
}
}
}
Expand Down
75 changes: 39 additions & 36 deletions Sources/Kraken/UI/Editors/KUI.CodeEditor.swift
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
/* --------------------------------------------------------------
* :: : K R A K E N : ::
* --------------------------------------------------------------
* @wabistudios :: metaverse :: kraken
/* ----------------------------------------------------------------
* :: : M E T A V E R S E : ::
* ----------------------------------------------------------------
* This software is Licensed under the terms of the Apache License,
* version 2.0 (the "Apache License") with the following additional
* modification; you may not use this file except within compliance
* of the Apache License and the following modification made to it.
* Section 6. Trademarks. is deleted and replaced with:
*
* This program is free software; you can redistribute it, and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* Trademarks. This License does not grant permission to use any of
* its trade names, trademarks, service marks, or the product names
* of this Licensor or its affiliates, except as required to comply
* with Section 4(c.) of this License, and to reproduce the content
* of the NOTICE file.
*
* 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. Check out
* the GNU General Public License for more details.
* This software is distributed in the hope that it will be useful,
* but WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND without even an
* implied warranty of MERCHANTABILITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the Apache License for more details.
*
* You should have received a copy for this software license, the
* GNU General Public License along with this program; or, if not
* write to the Free Software Foundation, Inc., to the address of
* You should have received a copy for this software license of the
* Apache License along with this program; or, if not, please write
* to the Free Software Foundation Inc., with the following address
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (C) 2023 Wabi Foundation.
* All Rights Reserved.
* --------------------------------------------------------------
* Copyright (C) 2024 Wabi Foundation. All Rights Reserved.
* ----------------------------------------------------------------
* . x x x . o o o . x x x . : : : . o x o . : : : .
* -------------------------------------------------------------- */
* ---------------------------------------------------------------- */

import CodeLanguages
import CosmoEditor
Expand Down Expand Up @@ -69,23 +73,6 @@ public extension Kraken.UI
{
VStack(spacing: 0)
{
HStack
{
Text("Language")

LanguagePicker(language: $language)
.frame(maxWidth: 100)

Toggle("Wrap Lines", isOn: $wrapLines)
Spacer()
Text(getLabel(cursorPositions))
}
.padding(4)
.zIndex(2)
.background(Color(NSColor.windowBackgroundColor))

Divider()

Editor.Code.Cosmo(
$document.text,
language: language,
Expand All @@ -107,6 +94,22 @@ public extension Kraken.UI
stage: &stage
)
}

Divider()

HStack
{
LanguagePicker(language: $language)
.frame(maxWidth: 35)

Spacer()

Text(getLabel(cursorPositions))
.font(.system(size: 8, weight: .bold, design: .monospaced))
}
.padding(4)
.zIndex(2)
.background(.ultraThinMaterial)
}
.onAppear
{
Expand Down
62 changes: 39 additions & 23 deletions Sources/Kraken/UI/Editors/KUI.CodeLanguage.swift
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
/* --------------------------------------------------------------
* :: : K R A K E N : ::
* --------------------------------------------------------------
* @wabistudios :: metaverse :: kraken
/* ----------------------------------------------------------------
* :: : M E T A V E R S E : ::
* ----------------------------------------------------------------
* This software is Licensed under the terms of the Apache License,
* version 2.0 (the "Apache License") with the following additional
* modification; you may not use this file except within compliance
* of the Apache License and the following modification made to it.
* Section 6. Trademarks. is deleted and replaced with:
*
* This program is free software; you can redistribute it, and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* Trademarks. This License does not grant permission to use any of
* its trade names, trademarks, service marks, or the product names
* of this Licensor or its affiliates, except as required to comply
* with Section 4(c.) of this License, and to reproduce the content
* of the NOTICE file.
*
* 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. Check out
* the GNU General Public License for more details.
* This software is distributed in the hope that it will be useful,
* but WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND without even an
* implied warranty of MERCHANTABILITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the Apache License for more details.
*
* You should have received a copy for this software license, the
* GNU General Public License along with this program; or, if not
* write to the Free Software Foundation, Inc., to the address of
* You should have received a copy for this software license of the
* Apache License along with this program; or, if not, please write
* to the Free Software Foundation Inc., with the following address
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (C) 2023 Wabi Foundation.
* All Rights Reserved.
* --------------------------------------------------------------
* Copyright (C) 2024 Wabi Foundation. All Rights Reserved.
* ----------------------------------------------------------------
* . x x x . o o o . x x x . : : : . o x o . : : : .
* -------------------------------------------------------------- */
* ---------------------------------------------------------------- */

import CodeLanguages
import CosmoEditor
Expand All @@ -36,15 +40,27 @@ public extension Kraken.UI.CodeEditor

public var body: some View
{
Picker("Language", selection: $language)
Menu
{
ForEach([.default] + Editor.Code.Language.allLanguages, id: \.id)
{ language in
Picker("Language", selection: $language)
{
ForEach([.default] + Editor.Code.Language.allLanguages, id: \.id)
{ language in
Text(language.id.rawValue)
.font(.system(size: 11, weight: .bold, design: .monospaced))
.tag(language)
}
}
} label:
{
HStack
{
Text(language.id.rawValue)
.tag(language)
.font(.system(size: 8, weight: .bold, design: .monospaced))
}
}
.labelsHidden()
.buttonStyle(.borderless)
}
}
}
Loading

0 comments on commit 5d57270

Please sign in to comment.