Skip to content

Commit

Permalink
[GUI] Shadow around Start, and hints
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyTy committed Jun 21, 2024
1 parent 94723c7 commit 9faa085
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 5 deletions.
4 changes: 4 additions & 0 deletions kernel/formats/exe/exe.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class ExeLoader<SIZE, HEADER> {
}

// TODO simple size ofs should be evaluated at normalizer to exclude ifs
// TODO switch HEADER { case type PeOptionalHeader<UInt32> }
// TODO `if let header = HEADER as PeOptionalHeader<UInt32> { header.ok }`
let is64bit = sizeOf<SIZE>() == 8
let env = is64bit? "C:\\Windows\\System32\\" : "C:\\Windows\\SysWOW64\\"
let fullPath = env + @hide name // TODO dedup `//` and normalize `/` to `\`
Expand Down Expand Up @@ -636,6 +638,8 @@ fun loadExeIntoProcess(file String, process TofitaProcess) {

if is64 {
let loader = new ExeLoader<UInt64, Pe64OptionalHeader>()
// TODO Hexa: use interface (non-runtime?) here to avoid code dup
// or just move this code into function
let app = loader.loadExe(asset, root, exec)
loader.loadRelatedDLLsAndMapIntoProcess(app, root, exec, process)
} else {
Expand Down
2 changes: 1 addition & 1 deletion kernel/formats/ico/ico.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fun loadIcon(buffer ConstArrayPointer<UInt8>, width Int) Bitmap32 {
bits: buffer[best + 6] + buffer[best + 7] * 0xFF,
pixels: null
}
*/
*/ // TODO Hexa: sublime comment

let planes = buffer[best + 4] + buffer[best + 5] * 0xFF
let bits = buffer[best + 6] + buffer[best + 7] * 0xFF
Expand Down
4 changes: 4 additions & 0 deletions kernel/gui/collider.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ class ColliderRectangle {
// TODO `@capture(closure: true)`
var handler (id UInt64, event ColliderEventType) => Void // TODO `let`

// TODO just pass ColliderRectangle instead of `id` everywhere

/// Set this to `null` to indicate lack of hint, or function that lazily updates hint content
var hint (id UInt64) => String = null // TODO Hexa: nullable function type... `varName @nullable ()=>T`
// ^ `Null<(id UInt64) => String>`
// or `Function<UInt64, String>?` thus can de dup in code gen with the same ClassInstance...
// but no field names? `<@name('id') UInt64>` `<id UInt64>`
// TODO hint within screen bounds and under/above mouse
static var showHintAfter UInt64 = 0
static var showHint (id UInt64) => String = null
Expand Down
15 changes: 13 additions & 2 deletions kernel/gui/compositor.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var vibranceLight Bitmap32 = null // Size of framebuffer
var vibranceDark Bitmap32 = null // Size of framebuffer
var leaves Bitmap32 = null
var leaves16 Bitmap32 = null
var leaves16white Bitmap32 = null
var trashCan Bitmap32 = null
var notepad16 Bitmap32 = null
var notepad48 Bitmap32 = null
Expand Down Expand Up @@ -309,6 +310,10 @@ fun initializeCompositor() {
getRamDiskAsset(a, "root/Windows/Resources/Icons/leaves16.png")
leaves16 = loadPng32(a)

let a = new RamDiskAsset()
getRamDiskAsset(a, "root/Windows/Resources/Icons/leaves16white.png")
leaves16white = loadPng32(a)

// Tray

let a = new RamDiskAsset()
Expand Down Expand Up @@ -661,9 +666,8 @@ fun composite(startupMilliseconds UInt64) {

// TODO not inferred properly?
// for file in desktopFilesList as! [String] {
for i in desktopShortcuts.length {
for shortcut in desktopShortcuts {
// TODO Hexa: `let file = desktopFilesList[i]` [ ] must return T? not T
let shortcut = desktopShortcuts[i]
let xu = shortcut.rectangle.relativeX
let yu = shortcut.rectangle.relativeY

Expand Down Expand Up @@ -970,6 +974,11 @@ fun composite(startupMilliseconds UInt64) {
(defaultSession.popupZone.width / 2i16) - (w / 2i16) : 0i16
// Gap above taskbar in centered mode
let y = taskbarY - h - (Theme.centeredStart? 12i16 : 0i16)

if Theme.startShadow {
drawShadowBox(x, y, w, h)
}

drawVibrancedRectangle(x, y as! Int16, w, h, darkTheme)
// TODO probably `w - 2` to avoid some overdraw?
color.ref.color = 0x44444444u32
Expand Down Expand Up @@ -1011,6 +1020,8 @@ fun composite(startupMilliseconds UInt64) {
defaultSession.startPower.height = userPanelHeight

// Pins panel
// Avoid clip rect: just render center part of vibrance, icons, and other vibrance parts over those icon parts
// That's why we render the pins upfront
{
defaultSession.startPins.relativeY = userPanelHeight
defaultSession.startPins.width = defaultSession.startZone.width
Expand Down
9 changes: 9 additions & 0 deletions kernel/gui/concepts/files.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Files {
shortcut.icon = unknown48
let rectangle = new ColliderRectangle(0, startPinHandler) // TODO
shortcut.rectangle = rectangle
// TODO Hexa: must error! shortcut.rectangle.hint = shortcut.displayName
shortcuts.push(shortcut)
zone.children.push(rectangle)
// TODO shortcut.rectangle.hint = hintOfPin
Expand Down Expand Up @@ -211,6 +212,14 @@ class Files {
Screen.pixels = screenPixels
}

static fun hintOfFile(id UInt64) String {
//let key = "HKCR\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\Instance\{" + id.toString() + "}\TaskbarInfo"
//let taskbarInfo = readRegistryKey(key)
// TODO Hexa: if taskbarInfo.isNull { return "" }
//return String.fromWideString(taskbarInfo.ref.data)
return ''
}

static fun guessIcon(shortcut Shortcut) Void {
let file String = shortcut.file

Expand Down
3 changes: 2 additions & 1 deletion kernel/gui/quake.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Quake-style console with ~
// TODO change to `Start + ~` and change engine to cmd.exe + tabs etc

var quakeHeight UInt8 = 255 // TODO `256` better error message aka too large to fit
let quakeHeight UInt8 = 255 // TODO Hexa: `256` better error message aka too large to fit into u8
var quakeCommand String = ""
var quakePreviousCommand String = "help"
// `var quakeLines [String] = [0]` // TODO `= [0]` not valid type
Expand Down Expand Up @@ -159,6 +159,7 @@ fun quakeHandleButtonDown(key UInt8) {
quakePrintf("wallpaper - set alternative wallpaper\n".utf16())
quakePrintf("fast - faster screen rendering method\n".utf16())
quakePrintf("huge - large taskbar without labels\n".utf16())
// TODO quakePrintf("wallpaper - cycle wallpapers\n".utf16())//note this may crash compositor, in composite() check last!=new and load on demand
// TODO ACPI reboot quakePrintf("Enter 're' or 'reboot' to reboot the system\n".utf16())
// TODO ACPI power off quakePrintf("Enter 'po' or 'power' to shut down the system\n".utf16())
quakePrintf("Press UP to re-enter the last command\n".utf16())//
Expand Down
20 changes: 19 additions & 1 deletion kernel/gui/session.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,9 @@ fun hintOfFile(id UInt64) String {
let asset = new RamDiskAsset()
getRamDiskAsset(asset, shortcut.file)

if asset.data != null {
if asset.data != null/* TODO , asset.data.length > 0 */ {
// TODO more + comma separators
// TODO folder size 1 depth + `or more` / `and 5 nested folders`
return "Size: " + asset.size + " bytes"
}

Expand All @@ -573,6 +574,7 @@ fun hintOfPin(id UInt64) String {
}

fun hintOfTaskbar(id UInt64) String {
// TODO Hexa: `switch id { case (defaultSession.taskbarStart.id): return "Start" }`
if defaultSession.taskbarStart.id == id {
return "Start"
}
Expand All @@ -585,6 +587,22 @@ fun hintOfTaskbar(id UInt64) String {
return "Pinned items"
}

if defaultSession.taskbarDesktopPeek.id == id {
return "Peek desktop"
}

if defaultSession.taskbarTime.id == id {
return "Clock"
}

if defaultSession.taskbarInput.id == id {
return "Keyboard"
}

if defaultSession.taskbarSearch.id == id {
return "Search"
}

// TODO taskbarDesktopPeek
// TODO taskbarTime
// TODO taskbarInput
Expand Down
2 changes: 2 additions & 0 deletions kernel/gui/theme.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Theme {
/// Fast composition with special CPU instructions
static var fast = true

static var startShadow = true

static var hugeTaskbar = false

new () {}
Expand Down

0 comments on commit 9faa085

Please sign in to comment.