diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-12-25 08:47:34 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-12-25 08:47:43 +0100 |
| commit | ec23419517078d032187b5b5f204d4c78de8c964 (patch) | |
| tree | b36af28b30113579c12d14391467563bee76c52f /dev | |
| parent | 738664e41b24ba7832d1ebe8dab8344d9440c5a1 (diff) | |
IMPL: Refactor the Graphics API of the OS (kernel side) (AppearanceMgr.h)
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/BootLoader/BootKit/BootKit.h | 2 | ||||
| -rw-r--r-- | dev/BootLoader/src/BootFileReader.cc | 2 | ||||
| -rw-r--r-- | dev/BootLoader/src/BootThread.cc | 8 | ||||
| -rw-r--r-- | dev/BootLoader/src/HEL/AMD64/BootMain.cc | 6 | ||||
| -rw-r--r-- | dev/Kernel/HALKit/AMD64/HalKernelMain.cc | 5 | ||||
| -rw-r--r-- | dev/Kernel/HALKit/ARM64/HalKernelMain.cc | 7 | ||||
| -rw-r--r-- | dev/Kernel/KernelKit/UserProcessScheduler.h | 8 | ||||
| -rw-r--r-- | dev/Kernel/KernelKit/UserProcessScheduler.inl | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | dev/Kernel/MoveAll.X64.sh | 0 | ||||
| -rw-r--r-- | dev/Kernel/src/KernelMain.cc | 7 | ||||
| -rw-r--r-- | dev/Kernel/src/Stop.cc | 32 | ||||
| -rw-r--r-- | dev/Kernel/src/UserProcessScheduler.cc | 11 | ||||
| -rw-r--r-- | dev/Modules/FB/AccessibilityMgr.h (renamed from dev/Modules/FB/Accessibility.h) | 0 | ||||
| -rw-r--r-- | dev/Modules/FB/AppearanceMgr.h | 266 | ||||
| -rw-r--r-- | dev/Modules/FB/KWindow.h | 242 | ||||
| -rw-r--r-- | dev/Modules/FB/Math.h | 10 | ||||
| -rw-r--r-- | dev/Modules/FB/Text.h | 8 | ||||
| -rw-r--r-- | dev/SCIKit/src/Makefile | 6 |
18 files changed, 323 insertions, 299 deletions
diff --git a/dev/BootLoader/BootKit/BootKit.h b/dev/BootLoader/BootKit/BootKit.h index a3d6a026..3a801ec8 100644 --- a/dev/BootLoader/BootKit/BootKit.h +++ b/dev/BootLoader/BootKit/BootKit.h @@ -15,7 +15,7 @@ #include <FirmwareKit/EPM.h> #include <CompilerKit/Version.h> #include <Modules/FB/FB.h> -#include <Modules/FB/KWindow.h> +#include <Modules/FB/AppearanceMgr.h> #include <BootKit/Rsrc/zka_disk.rsrc> #include <BootKit/Rsrc/zka_no_disk.rsrc> #include <BootKit/Rsrc/zka_has_disk.rsrc> diff --git a/dev/BootLoader/src/BootFileReader.cc b/dev/BootLoader/src/BootFileReader.cc index 1edf1281..06b66314 100644 --- a/dev/BootLoader/src/BootFileReader.cc +++ b/dev/BootLoader/src/BootFileReader.cc @@ -86,7 +86,7 @@ Boot::BFileReader::BFileReader(const CharacterTypeUTF16* path, .Write(L"\r"); this->mErrorCode = kNotSupported; - CGDrawString("BootZ: PLEASE RECOVER YOUR MINKRNL INSTALL.", 40, 10, RGB(0xFF, 0xFF, 0xFF)); + fb_render_string("BootZ: PLEASE RECOVER YOUR MINKRNL INSTALL.", 40, 10, RGB(0xFF, 0xFF, 0xFF)); mRootFs->Close(mRootFs); diff --git a/dev/BootLoader/src/BootThread.cc b/dev/BootLoader/src/BootThread.cc index 32f8fd86..68964084 100644 --- a/dev/BootLoader/src/BootThread.cc +++ b/dev/BootLoader/src/BootThread.cc @@ -122,7 +122,7 @@ namespace Boot #ifdef __ZKA_AMD64__ if (handover_struc->HandoverArch != HEL::kArchAMD64) { - CGDrawString("BootZ: NOT AN HANDOVER IMAGE, BAD ARCHITECTURE...", 40, 10, RGB(0xFF, 0xFF, 0xFF)); + fb_render_string("BootZ: NOT AN HANDOVER IMAGE, BAD ARCHITECTURE...", 40, 10, RGB(0xFF, 0xFF, 0xFF)); ::EFI::Stop(); } #endif @@ -130,11 +130,11 @@ namespace Boot #ifdef __ZKA_ARM64__ if (handover_struc->HandoverArch != HEL::kArchARM64) { - CGDrawString("BootZ: NOT AN HANDOVER IMAGE, BAD ARCHITECTURE...", 40, 10, RGB(0xFF, 0xFF, 0xFF)); + fb_render_string("BootZ: NOT AN HANDOVER IMAGE, BAD ARCHITECTURE...", 40, 10, RGB(0xFF, 0xFF, 0xFF)); ::EFI::Stop(); } #endif - CGDrawString("BootZ: NOT AN HANDOVER IMAGE...", 40, 10, RGB(0xFF, 0xFF, 0xFF)); + fb_render_string("BootZ: NOT AN HANDOVER IMAGE...", 40, 10, RGB(0xFF, 0xFF, 0xFF)); ::EFI::Stop(); } @@ -170,7 +170,7 @@ namespace Boot Void BThread::Start(HEL::BootInfoHeader* handover, Bool own_stack) { HEL::HandoverProc err_fn = [](HEL::BootInfoHeader* rcx) -> void { - CGDrawString("BootZ: INVALID IMAGE! ABORTING...", 50, 10, RGB(0xFF, 0xFF, 0xFF)); + fb_render_string("BootZ: INVALID IMAGE! ABORTING...", 50, 10, RGB(0xFF, 0xFF, 0xFF)); ::EFI::Stop(); }; diff --git a/dev/BootLoader/src/HEL/AMD64/BootMain.cc b/dev/BootLoader/src/HEL/AMD64/BootMain.cc index 64c2c983..1d0787cc 100644 --- a/dev/BootLoader/src/HEL/AMD64/BootMain.cc +++ b/dev/BootLoader/src/HEL/AMD64/BootMain.cc @@ -143,7 +143,7 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle, cg_init(); - CG::CGDrawBackground(); + CG::ui_draw_background(); CGDrawBitMapInRegion(zka_disk, ZKA_DISK_HEIGHT, ZKA_DISK_WIDTH, (kHandoverHeader->f_GOP.f_Width - ZKA_DISK_WIDTH) / 2, (kHandoverHeader->f_GOP.f_Height - ZKA_DISK_HEIGHT) / 2); @@ -168,7 +168,7 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle, #ifdef ZKA_AUTO_FORMAT if (!partition_factory.IsPartitionValid()) { - CG::CGDrawBackground(); + CG::ui_draw_background(); CGDrawBitMapInRegion(zka_no_disk, ZKA_NO_DISK_HEIGHT, ZKA_NO_DISK_WIDTH, (kHandoverHeader->f_GOP.f_Width - ZKA_NO_DISK_WIDTH) / 2, (kHandoverHeader->f_GOP.f_Height - ZKA_NO_DISK_HEIGHT) / 2); @@ -183,7 +183,7 @@ EFI_EXTERN_C EFI_API Int32 Main(EfiHandlePtr ImageHandle, partition_factory.Format("FileSystem (A:)\0", &root, 1); - CG::CGDrawBackground(); + CG::ui_draw_background(); CGDrawBitMapInRegion(zka_has_disk, ZKA_HAS_DISK_HEIGHT, ZKA_HAS_DISK_WIDTH, (kHandoverHeader->f_GOP.f_Width - ZKA_HAS_DISK_WIDTH) / 2, (kHandoverHeader->f_GOP.f_Height - ZKA_HAS_DISK_HEIGHT) / 2); diff --git a/dev/Kernel/HALKit/AMD64/HalKernelMain.cc b/dev/Kernel/HALKit/AMD64/HalKernelMain.cc index e9350af9..bf297d6a 100644 --- a/dev/Kernel/HALKit/AMD64/HalKernelMain.cc +++ b/dev/Kernel/HALKit/AMD64/HalKernelMain.cc @@ -11,7 +11,7 @@ #include <Modules/ACPI/ACPIFactoryInterface.h> #include <NetworkKit/IPC.h> #include <CFKit/Property.h> -#include <Modules/FB/KWindow.h> +#include <Modules/FB/AppearanceMgr.h> #include <Modules/FB/Text.h> EXTERN_C Kernel::VoidPtr kInterruptVectorTable[]; @@ -84,10 +84,9 @@ EXTERN_C void hal_init_platform( EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept { - CG::CGDrawBackground(); + CG::ui_draw_background(); auto str_proc = Kernel::rt_alloc_string("System"); - Kernel::rtl_create_process(rtl_kernel_main, str_proc); delete str_proc; diff --git a/dev/Kernel/HALKit/ARM64/HalKernelMain.cc b/dev/Kernel/HALKit/ARM64/HalKernelMain.cc index 2901e80b..3892e31b 100644 --- a/dev/Kernel/HALKit/ARM64/HalKernelMain.cc +++ b/dev/Kernel/HALKit/ARM64/HalKernelMain.cc @@ -15,7 +15,7 @@ #include <KernelKit/CodeMgr.h> #include <Modules/ACPI/ACPIFactoryInterface.h> #include <NetworkKit/IPC.h> -#include <Modules/FB/KWindow.h> +#include <Modules/FB/AppearanceMgr.h> #include <CFKit/Property.h> Kernel::Void hal_real_init(Kernel::Void) noexcept; @@ -47,9 +47,10 @@ EXTERN_C void hal_init_platform( /// @note do initialize the interrupts after it. - CG::CGDrawBackground(); + CG::ui_draw_background(); - Kernel::rtl_create_process(rtl_kernel_main, "ZkaOS System Kernel"); + auto str_proc = Kernel::rt_alloc_string("System"); + Kernel::rtl_create_process(rtl_kernel_main, str_proc); while (YES) { diff --git a/dev/Kernel/KernelKit/UserProcessScheduler.h b/dev/Kernel/KernelKit/UserProcessScheduler.h index ab8a52a1..cb1fc5a0 100644 --- a/dev/Kernel/KernelKit/UserProcessScheduler.h +++ b/dev/Kernel/KernelKit/UserProcessScheduler.h @@ -167,14 +167,14 @@ namespace Kernel SizeT MemoryCursor{0}; SizeT MemoryLimit{kSchedMaxMemoryLimit}; - struct UserProcessHeapList final + struct ProcessMemoryHeapList final { VoidPtr MemoryEntry{nullptr}; SizeT MemoryEntrySize{0UL}; SizeT MemoryEntryPad{0UL}; - struct UserProcessHeapList* MemoryPrev{nullptr}; - struct UserProcessHeapList* MemoryNext{nullptr}; + struct ProcessMemoryHeapList* MemoryPrev{nullptr}; + struct ProcessMemoryHeapList* MemoryNext{nullptr}; }; struct UserProcessSignal final @@ -185,7 +185,7 @@ namespace Kernel }; UserProcessSignal ProcessSignal; - UserProcessHeapList* ProcessMemoryHeap{nullptr}; + ProcessMemoryHeapList* ProcessMemoryHeap{nullptr}; UserProcessTeam* ProcessParentTeam; VoidPtr VMRegister{0UL}; diff --git a/dev/Kernel/KernelKit/UserProcessScheduler.inl b/dev/Kernel/KernelKit/UserProcessScheduler.inl index 2973d6a4..595ba71e 100644 --- a/dev/Kernel/KernelKit/UserProcessScheduler.inl +++ b/dev/Kernel/KernelKit/UserProcessScheduler.inl @@ -11,7 +11,7 @@ namespace Kernel sz == 0) return No; - UserProcessHeapList* entry = this->ProcessMemoryHeap; + ProcessMemoryHeapList* entry = this->ProcessMemoryHeap; while (entry != nullptr) { diff --git a/dev/Kernel/MoveAll.X64.sh b/dev/Kernel/MoveAll.X64.sh index 1c135d06..1c135d06 100644..100755 --- a/dev/Kernel/MoveAll.X64.sh +++ b/dev/Kernel/MoveAll.X64.sh diff --git a/dev/Kernel/src/KernelMain.cc b/dev/Kernel/src/KernelMain.cc index 556ab5e2..cc889619 100644 --- a/dev/Kernel/src/KernelMain.cc +++ b/dev/Kernel/src/KernelMain.cc @@ -22,13 +22,9 @@ #include <NewKit/Utils.h> #include <KernelKit/CodeMgr.h> #include <CFKit/Property.h> -#include <Modules/FB/KWindow.h> +#include <Modules/FB/AppearanceMgr.h> #include <KernelKit/Timer.h> -#define kKeCachedName "/System/CacheKernel" - -STATIC CG::ML_WINDOW_STRUCT* kKernelWnd = nullptr; - namespace Kernel::Detail { /// @brief Filesystem auto formatter, additional checks are also done by the class. @@ -129,6 +125,5 @@ namespace Kernel::Detail EXTERN_C Kernel::Void rtl_kernel_main(Kernel::SizeT argc, char** argv, char** envp, Kernel::SizeT envp_len) { Kernel::Detail::fs_init_newfs(); - Kernel::Detail::NeFilesystemInstaller installer{}; } diff --git a/dev/Kernel/src/Stop.cc b/dev/Kernel/src/Stop.cc index b8bfdb1b..a8974849 100644 --- a/dev/Kernel/src/Stop.cc +++ b/dev/Kernel/src/Stop.cc @@ -35,9 +35,9 @@ namespace Kernel auto x = 10; if (id != RUNTIME_CHECK_BOOTSTRAP) - CGDrawString("Kernel Panic!", start_y, x, panic_text); + fb_render_string("Kernel Panic!", start_y, x, panic_text); else - CGDrawString("Kernel Bootstrap:", start_y, x, panic_text); + fb_render_string("Kernel Bootstrap:", start_y, x, panic_text); start_y += 10; @@ -48,59 +48,59 @@ namespace Kernel switch (id) { case RUNTIME_CHECK_PROCESS: { - CGDrawString("0x00000008: Invalid process behavior.", start_y, x, panic_text); + fb_render_string("0x00000008: Invalid process behavior.", start_y, x, panic_text); break; } case RUNTIME_CHECK_ACPI: { - CGDrawString("0x00000006: ACPI configuration error.", start_y, x, panic_text); + fb_render_string("0x00000006: ACPI configuration error.", start_y, x, panic_text); break; } case RUNTIME_CHECK_PAGE: { - CGDrawString("0x0000000B: Write/Read in non paged area.", start_y, x, panic_text); + fb_render_string("0x0000000B: Write/Read in non paged area.", start_y, x, panic_text); break; } case RUNTIME_CHECK_FILESYSTEM: { - CGDrawString("0x0000000A: Filesystem driver error.", start_y, x, panic_text); + fb_render_string("0x0000000A: Filesystem driver error.", start_y, x, panic_text); break; } case RUNTIME_CHECK_POINTER: { - CGDrawString("0x00000000: Kernel heap is corrupted.", start_y, x, panic_text); + fb_render_string("0x00000000: Kernel heap is corrupted.", start_y, x, panic_text); break; } case RUNTIME_CHECK_BAD_BEHAVIOR: { - CGDrawString("0x00000009: Bad behavior.", start_y, x, panic_text); + fb_render_string("0x00000009: Bad behavior.", start_y, x, panic_text); break; } case RUNTIME_CHECK_BOOTSTRAP: { - CGDrawString("0x0000000A: Kernel has finished running, running OSLdr...", start_y, x, panic_text); + fb_render_string("0x0000000A: Kernel has finished running, running OSLdr...", start_y, x, panic_text); return; } case RUNTIME_CHECK_HANDSHAKE: { - CGDrawString("0x00000005: Handshake fault.", start_y, x, panic_text); + fb_render_string("0x00000005: Handshake fault.", start_y, x, panic_text); break; } case RUNTIME_CHECK_IPC: { - CGDrawString("0x00000003: Bad LPC message.", start_y, x, panic_text); + fb_render_string("0x00000003: Bad LPC message.", start_y, x, panic_text); break; } case RUNTIME_CHECK_INVALID_PRIVILEGE: { - CGDrawString("0x00000007: Privilege access violation.", start_y, x, panic_text); + fb_render_string("0x00000007: Privilege access violation.", start_y, x, panic_text); break; case RUNTIME_CHECK_UNEXCPECTED: { - CGDrawString("0x0000000B: Unexpected violation.", start_y, x, panic_text); + fb_render_string("0x0000000B: Unexpected violation.", start_y, x, panic_text); break; } case RUNTIME_CHECK_VIRTUAL_OUT_OF_MEM: { - CGDrawString("0x10000001: Out of virtual memory.", start_y, x, panic_text); + fb_render_string("0x10000001: Out of virtual memory.", start_y, x, panic_text); break; } case RUNTIME_CHECK_FAILED: { - CGDrawString("0x10000001: Kernel Bug check appears to have failed, a dump has been written to the storage.", start_y, x, panic_text); + fb_render_string("0x10000001: Kernel Bug check appears to have failed, a dump has been written to the storage.", start_y, x, panic_text); break; } default: { - CGDrawString("0xFFFFFFFC: Unknown Kernel Error code.", start_y, x, panic_text); + fb_render_string("0xFFFFFFFC: Unknown Kernel Error code.", start_y, x, panic_text); break; } } diff --git a/dev/Kernel/src/UserProcessScheduler.cc b/dev/Kernel/src/UserProcessScheduler.cc index b1bc7735..512b0c22 100644 --- a/dev/Kernel/src/UserProcessScheduler.cc +++ b/dev/Kernel/src/UserProcessScheduler.cc @@ -90,7 +90,8 @@ namespace Kernel } /***********************************************************************************/ - /// @brief Wake process-> + /// @brief Wakes process header. + /// @param should_wakeup if the program shall wakeup or not. /***********************************************************************************/ Void UserProcess::Wake(const bool should_wakeup) @@ -118,7 +119,7 @@ namespace Kernel if (!this->ProcessMemoryHeap) { - this->ProcessMemoryHeap = new UserProcess::UserProcessHeapList(); + this->ProcessMemoryHeap = new UserProcess::ProcessMemoryHeapList(); this->ProcessMemoryHeap->MemoryEntryPad = pad_amount; this->ProcessMemoryHeap->MemoryEntrySize = sz; @@ -132,8 +133,8 @@ namespace Kernel } else { - UserProcessHeapList* entry = this->ProcessMemoryHeap; - UserProcessHeapList* prev_entry = nullptr; + ProcessMemoryHeapList* entry = this->ProcessMemoryHeap; + ProcessMemoryHeapList* prev_entry = nullptr; while (!entry) { @@ -144,7 +145,7 @@ namespace Kernel entry = entry->MemoryNext; } - entry->MemoryNext = new UserProcessHeapList(); + entry->MemoryNext = new ProcessMemoryHeapList(); entry->MemoryNext->MemoryEntry = ptr; entry->MemoryNext->MemoryPrev = entry; diff --git a/dev/Modules/FB/Accessibility.h b/dev/Modules/FB/AccessibilityMgr.h index 843ad9a7..843ad9a7 100644 --- a/dev/Modules/FB/Accessibility.h +++ b/dev/Modules/FB/AccessibilityMgr.h diff --git a/dev/Modules/FB/AppearanceMgr.h b/dev/Modules/FB/AppearanceMgr.h new file mode 100644 index 00000000..fd14e3d3 --- /dev/null +++ b/dev/Modules/FB/AppearanceMgr.h @@ -0,0 +1,266 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#pragma once + +#include <Modules/FB/AccessibilityMgr.h> +#include <KernelKit/Heap.h> +#include <KernelKit/UserProcessScheduler.h> +#include <KernelKit/LPC.h> +#include <NewKit/Defines.h> +#include <NewKit/Utils.h> +#include <Modules/FB/FB.h> +#include <Modules/FB/Rsrc/WndControls.rsrc> +#include <Modules/FB/Text.h> + +namespace CG +{ + using namespace Kernel; + + struct UIObject; + + enum + { + kUIFlagNoShow = 0x02, + kUIFlagButton = 0x04, + kUIFlagWindow = 0x06, + kUIFlagButtonSelect = 0x08, + kUIFlagHideCloseControl = 0x010, + kUIFlagCloseControlSelect = 0x012, + }; + + struct UIObject final + { + Char w_window_name[255]{0}; + Char w_class_name[255]{0}; + Int32 w_type{0}; + Int32 w_sub_type{0}; + Int32 w_x{0}; + Int32 w_y{0}; + Int32 w_w{0}; + Int32 w_h{0}; + Int32 w_display_ptr_w{0}; + Int32 w_display_ptr_h{0}; + SizeT w_child_count{0}; + struct UIObject* w_child_elements[255]{0}; + struct UIObject* w_parent{nullptr}; + UInt32* w_display_ptr{nullptr}; + Bool w_needs_repaint{false}; + + Void (*w_display_custom_draw)(struct UIObject* am_win); + }; + + typedef struct UIObject UIObject; + + inline Void ui_draw_background() noexcept + { + cg_init(); + + CGDrawInRegion(cg_get_clear_clr(), CG::UIAccessibilty::Height(), CG::UIAccessibilty::Width(), + 0, 0); + + cg_fini(); + } + + inline struct UIObject* ui_create_object(Int32 kind, const Char* obj_name, const Char* class_name, Int32 x, Int32 y, Int32 width, Int32 height, UIObject* parent = nullptr) + { + UIObject* obj = new UIObject(); + + if (!obj) + { + err_local_get() = kErrorHeapOutOfMemory; + return nullptr; + } + + rt_copy_memory((VoidPtr)obj_name, obj->w_window_name, rt_string_len(obj_name)); + rt_copy_memory((VoidPtr)class_name, obj->w_class_name, rt_string_len(class_name)); + + if (parent) + { + obj->w_parent = parent; + + ++obj->w_parent->w_child_count; + obj->w_parent->w_child_elements[obj->w_parent->w_child_count - 1] = obj; + } + + obj->w_sub_type = 0; + obj->w_type = kind; + obj->w_x = x; + obj->w_y = y; + obj->w_display_ptr = nullptr; + obj->w_w = width; + obj->w_h = height; + obj->w_display_custom_draw = nullptr; + + return obj; + } + + inline bool ui_destroy_object(struct UIObject* obj) + { + if (obj) + { + delete obj; + + if (!mm_is_valid_heap(obj)) + { + obj = nullptr; + return false; + } + + obj = nullptr; + return true; + } + + return false; + } + + inline Kernel::Void ui_render_text(UIObject* obj, const Kernel::Char* text, Kernel::Int32 y_dst, Kernel::Int32 x_dst, Kernel::Int32 color) + { + y_dst += obj->w_y + FLAT_CONTROLS_HEIGHT; + x_dst += obj->w_x; + + if (y_dst > (obj->w_h + obj->w_y)) + return; + + for (Kernel::SizeT i = 0; text[i] != 0; ++i) + { + if (x_dst > (obj->w_w + obj->w_x)) + break; + + fb_render_string_for_bitmap(&kFontBitmap[text[i]][0], FONT_SIZE_X, FONT_SIZE_Y, y_dst, x_dst, color); + x_dst += FONT_SIZE_X; + } + } + + inline SizeT ui_render_object(UIObject* obj) + { + if (!obj || + (obj->w_type == kUIFlagNoShow) || + !obj->w_needs_repaint) + return 1; + + cg_init(); + + obj->w_needs_repaint = false; + + kcout << "Begin paint\r"; + + if (UIAccessibilty::Width() < obj->w_x) + { + if ((obj->w_x - UIAccessibilty::Width()) > 1) + { + obj->w_x -= obj->w_x - UIAccessibilty::Width(); + } + else + { + obj->w_x = 0; + } + } + + if (UIAccessibilty::Height() < obj->w_y) + { + if ((obj->w_y - UIAccessibilty::Height()) > 1) + { + obj->w_y -= obj->w_y - UIAccessibilty::Width(); + } + else + { + obj->w_y = 0; + } + } + + // Draw fake controls, just for the looks of it (WINDOW ONLY) + if (obj->w_type == kUIFlagWindow) + { + kcout << "Begin paint window\r"; + + if (!obj->w_display_custom_draw) + { + if (obj->w_display_ptr) + { + CGDrawInRegion(cg_color(0xDF, 0xDF, 0xDF), obj->w_h, obj->w_w, obj->w_x, obj->w_y); + CGDrawBitMapInRegion(obj->w_display_ptr, obj->w_display_ptr_h, obj->w_display_ptr_w, obj->w_x, obj->w_y); + } + else + { + CGDrawInRegion(cg_color(0xDF, 0xDF, 0xDF), obj->w_w, obj->w_h, obj->w_y, obj->w_x); + } + + CGDrawInRegion(cg_color(0xFF, 0xFF, 0xFF), obj->w_w, FLAT_CONTROLS_HEIGHT, obj->w_y, obj->w_x); + + if (obj->w_sub_type != kUIFlagHideCloseControl) + { + CGDrawBitMapInRegion(zka_flat_controls, FLAT_CONTROLS_HEIGHT, FLAT_CONTROLS_WIDTH, obj->w_y, obj->w_x + obj->w_w - FLAT_CONTROLS_WIDTH); + } + else if (obj->w_sub_type == kUIFlagCloseControlSelect) + { + CGDrawBitMapInRegion(zka_flat_controls_active, FLAT_CONTROLS_CLOSEHEIGHT, FLAT_CONTROLS_CLOSEWIDTH, obj->w_y, obj->w_x + obj->w_w - FLAT_CONTROLS_WIDTH); + } + + fb_render_string(obj->w_window_name, obj->w_x + 8, obj->w_y + 8, cg_color(0x00, 0x00, 0x00)); + } + else + { + obj->w_display_custom_draw(obj); + } + } + /// @note buttons in this library are dynamic, it's because we want to avoid as much as computations as possible. + /// (Such as getting the middle coordinates of a button, to center the text.) + else if (obj->w_type == kUIFlagButtonSelect) + { + auto x_center = obj->w_x + 6; + auto y_center = obj->w_y + 7; + + if (!obj->w_display_custom_draw) + { + CGDrawInRegion(cg_color(0xD3, 0x74, 0x00), obj->w_w + 1, obj->w_h + 1, obj->w_x, obj->w_y); + CGDrawInRegion(cg_color(0xFF, 0xFF, 0xFF), obj->w_w - 1, obj->w_h - 1, obj->w_x + 1, obj->w_y + 1); + ui_render_text(obj, obj->w_window_name, y_center, x_center, cg_color(0x00, 0x00, 0x00)); + } + else + { + obj->w_display_custom_draw(obj); + } + } + else if (obj->w_type == kUIFlagButton) + { + auto x_center = obj->w_x + 6; + auto y_center = obj->w_y + 7; + + if (!obj->w_display_custom_draw) + { + CGDrawInRegion(cg_color(0xDC, 0xDC, 0xDC), obj->w_w + 1, obj->w_h + 1, obj->w_y, obj->w_x); + CGDrawInRegion(cg_color(0xFF, 0xFF, 0xFF), obj->w_w - 1, obj->w_h - 1, obj->w_y + 1, obj->w_x + 1); + fb_render_string(obj->w_window_name, y_center, x_center, cg_color(0x00, 0x00, 0x00)); + } + else + { + obj->w_display_custom_draw(obj); + } + } + + cg_fini(); + + // draw child windows and controls. + // doesn't have to be a window, enabling then windows in windows. + + for (SizeT child = 0; child < obj->w_child_count; ++child) + { + obj->w_child_elements[child]->w_x += obj->w_x; + obj->w_child_elements[child]->w_y += obj->w_y + FLAT_CONTROLS_HEIGHT; + + if ((obj->w_child_elements[child]->w_w + obj->w_child_elements[child]->w_x) > (obj->w_x + obj->w_w) || + (obj->w_child_elements[child]->w_h + obj->w_child_elements[child]->w_y) > (obj->w_y + obj->w_h)) + continue; + + ui_render_object(obj->w_child_elements[child]); + } + + cg_fini(); + + return 0; + } +} // namespace CG diff --git a/dev/Modules/FB/KWindow.h b/dev/Modules/FB/KWindow.h deleted file mode 100644 index f84e36d4..00000000 --- a/dev/Modules/FB/KWindow.h +++ /dev/null @@ -1,242 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#pragma once - -#include <Modules/FB/Accessibility.h> -#include <KernelKit/Heap.h> -#include <KernelKit/UserProcessScheduler.h> -#include <KernelKit/LPC.h> -#include <NewKit/Defines.h> -#include <NewKit/Utils.h> -#include <Modules/FB/FB.h> -#include <Modules/FB/Rsrc/WndControls.rsrc> -#include <Modules/FB/Text.h> - -namespace CG -{ - using namespace Kernel; - - struct ML_WINDOW_STRUCT; - - enum - { - kWndFlagNoShow = 0x02, - kWndFlagButton = 0x04, - kWndFlagWindow = 0x06, - kWndFlagButtonSelect = 0x08, - kWndFlagHideCloseControl = 0x010, - kWndFlagCloseControlSelect = 0x012, - }; - - struct ML_WINDOW_STRUCT final - { - Char w_window_name[255]{0}; - Char w_class_name[255]{0}; - Int32 w_type{0}; - Int32 w_sub_type{0}; - Int32 w_x{0}; - Int32 w_y{0}; - Int32 w_w{0}; - Int32 w_h{0}; - Int32 w_display_ptr_w{0}; - Int32 w_display_ptr_h{0}; - SizeT w_child_count{0}; - struct ML_WINDOW_STRUCT* w_child_elements[255]{0}; - struct ML_WINDOW_STRUCT* w_parent{nullptr}; - UInt32* w_display_ptr{nullptr}; - Bool w_needs_repaint{false}; - }; - - typedef struct ML_WINDOW_STRUCT ML_WINDOW_STRUCT; - - inline Void CGDrawBackground() noexcept - { - cg_init(); - - CGDrawInRegion(cg_get_clear_clr(), CG::UIAccessibilty::Height(), CG::UIAccessibilty::Width(), - 0, 0); - - cg_fini(); - } - - inline struct ML_WINDOW_STRUCT* CGCreateWindow(Int32 kind, const Char* window_name, const Char* class_name, Int32 x, Int32 y, Int32 width, Int32 height, ML_WINDOW_STRUCT* parent = nullptr) - { - ML_WINDOW_STRUCT* wnd = new ML_WINDOW_STRUCT(); - - if (!wnd) - { - err_local_get() = kErrorHeapOutOfMemory; - return nullptr; - } - - rt_copy_memory((VoidPtr)window_name, wnd->w_window_name, rt_string_len(window_name)); - rt_copy_memory((VoidPtr)class_name, wnd->w_class_name, rt_string_len(class_name)); - - if (parent) - { - wnd->w_parent = parent; - - ++wnd->w_parent->w_child_count; - wnd->w_parent->w_child_elements[wnd->w_parent->w_child_count - 1] = wnd; - } - - wnd->w_sub_type = 0; - wnd->w_type = kind; - wnd->w_x = x; - wnd->w_y = y; - wnd->w_display_ptr = nullptr; - wnd->w_w = width; - wnd->w_h = height; - - return wnd; - } - - inline bool CGDestroyWindow(struct ML_WINDOW_STRUCT* wnd) - { - if (wnd) - { - delete wnd; - - if (!mm_is_valid_heap(wnd)) - { - wnd = nullptr; - return true; - } - - wnd = nullptr; - } - - return false; - } - - inline Kernel::Void CGDrawStringToWnd(ML_WINDOW_STRUCT* wnd, const Kernel::Char* text, Kernel::Int32 y_dst, Kernel::Int32 x_dst, Kernel::Int32 color) - { - y_dst += wnd->w_y + FLAT_CONTROLS_HEIGHT; - x_dst += wnd->w_x; - - if (y_dst > (wnd->w_h + wnd->w_y)) - return; - - for (Kernel::SizeT i = 0; text[i] != 0; ++i) - { - if (x_dst > (wnd->w_w + wnd->w_x)) - break; - - CGRenderStringFromBitMap(&cFontBitmap[text[i]][0], FONT_SIZE_X, FONT_SIZE_Y, y_dst, x_dst, color); - x_dst += FONT_SIZE_Y; - } - } - - inline SizeT CGDrawWindow(ML_WINDOW_STRUCT* wnd) - { - if (!wnd || - (wnd->w_type == kWndFlagNoShow) || - !wnd->w_needs_repaint) - return 1; - - cg_init(); - - wnd->w_needs_repaint = false; - - kcout << "Begin paint\r"; - - if (UIAccessibilty::Width() < wnd->w_x) - { - if ((wnd->w_x - UIAccessibilty::Width()) > 1) - { - wnd->w_x -= wnd->w_x - UIAccessibilty::Width(); - } - else - { - wnd->w_x = 0; - } - } - - if (UIAccessibilty::Height() < wnd->w_y) - { - if ((wnd->w_y - UIAccessibilty::Height()) > 1) - { - wnd->w_y -= wnd->w_y - UIAccessibilty::Width(); - } - else - { - wnd->w_y = 0; - } - } - - // Draw fake controls, just for the looks of it (WINDOW ONLY) - if (wnd->w_type == kWndFlagWindow) - { - kcout << "Begin paint window\r"; - - if (wnd->w_display_ptr) - { - CGDrawInRegion(cg_color(0xDF, 0xDF, 0xDF), wnd->w_h, wnd->w_w, wnd->w_x, wnd->w_y); - CGDrawBitMapInRegion(wnd->w_display_ptr, wnd->w_display_ptr_h, wnd->w_display_ptr_w, wnd->w_x, wnd->w_y); - } - else - { - CGDrawInRegion(cg_color(0xDF, 0xDF, 0xDF), wnd->w_w, wnd->w_h, wnd->w_y, wnd->w_x); - } - - CGDrawInRegion(cg_color(0xFF, 0xFF, 0xFF), wnd->w_w, FLAT_CONTROLS_HEIGHT, wnd->w_y, wnd->w_x); - - if (wnd->w_sub_type != kWndFlagHideCloseControl) - { - CGDrawBitMapInRegion(zka_flat_controls, FLAT_CONTROLS_HEIGHT, FLAT_CONTROLS_WIDTH, wnd->w_y, wnd->w_x + wnd->w_w - FLAT_CONTROLS_WIDTH); - } - else if (wnd->w_sub_type == kWndFlagCloseControlSelect) - { - CGDrawBitMapInRegion(zka_flat_controls_active, FLAT_CONTROLS_CLOSEHEIGHT, FLAT_CONTROLS_CLOSEWIDTH, wnd->w_y, wnd->w_x + wnd->w_w - FLAT_CONTROLS_WIDTH); - } - - CGDrawString(wnd->w_window_name, wnd->w_x + 8, wnd->w_y + 8, cg_color(0x00, 0x00, 0x00)); - } - /// @note buttons in this library are dynamic, it's because we want to avoid as much as computations as possible. - /// (Such as getting the middle coordinates of a button, to center the text.) - else if (wnd->w_type == kWndFlagButtonSelect) - { - auto x_center = wnd->w_x + 6; - auto y_center = wnd->w_y + 7; - - CGDrawInRegion(cg_color(0xD3, 0x74, 0x00), wnd->w_w + 1, wnd->w_h + 1, wnd->w_x, wnd->w_y); - CGDrawInRegion(cg_color(0xFF, 0xFF, 0xFF), wnd->w_w - 1, wnd->w_h - 1, wnd->w_x + 1, wnd->w_y + 1); - CGDrawStringToWnd(wnd, wnd->w_window_name, y_center, x_center, cg_color(0x00, 0x00, 0x00)); - } - else if (wnd->w_type == kWndFlagButton) - { - auto x_center = wnd->w_x + 6; - auto y_center = wnd->w_y + 7; - - CGDrawInRegion(cg_color(0xDC, 0xDC, 0xDC), wnd->w_w + 1, wnd->w_h + 1, wnd->w_y, wnd->w_x); - CGDrawInRegion(cg_color(0xFF, 0xFF, 0xFF), wnd->w_w - 1, wnd->w_h - 1, wnd->w_y + 1, wnd->w_x + 1); - CGDrawString(wnd->w_window_name, y_center, x_center, cg_color(0x00, 0x00, 0x00)); - } - - cg_fini(); - - // draw child windows and controls. - // doesn't have to be a window, enabling then windows in windows. - - for (SizeT child = 0; child < wnd->w_child_count; ++child) - { - wnd->w_child_elements[child]->w_x += wnd->w_x; - wnd->w_child_elements[child]->w_y += wnd->w_y + FLAT_CONTROLS_HEIGHT; - - if ((wnd->w_child_elements[child]->w_w + wnd->w_child_elements[child]->w_x) > (wnd->w_x + wnd->w_w) || - (wnd->w_child_elements[child]->w_h + wnd->w_child_elements[child]->w_y) > (wnd->w_y + wnd->w_h)) - continue; - - CGDrawWindow(wnd->w_child_elements[child]); - } - - - cg_fini(); - - return 0; - } -} // namespace CG diff --git a/dev/Modules/FB/Math.h b/dev/Modules/FB/Math.h index 3ccbaf5d..123e9914 100644 --- a/dev/Modules/FB/Math.h +++ b/dev/Modules/FB/Math.h @@ -9,14 +9,18 @@ /// @file Math.h /// @brief Linear interpolation implementation. -typedef float CGReal; +#ifdef ZKA_FB_USE_DOUBLE +typedef double fb_real_t; +#else +typedef float fb_real_t; +#endif /// @brief Linear interpolation equation solver. /// @param from where? /// @param to to? /// @param at which state we're at **to**. -inline CGReal CGLerp(CGReal to, CGReal from, CGReal stat) +inline fb_real_t fb_math_lerp(fb_real_t to, fb_real_t from, fb_real_t stat) { - CGReal difference = to - from; + fb_real_t difference = to - from; return from + (difference * stat); } diff --git a/dev/Modules/FB/Text.h b/dev/Modules/FB/Text.h index 36e082c3..ba328314 100644 --- a/dev/Modules/FB/Text.h +++ b/dev/Modules/FB/Text.h @@ -13,7 +13,7 @@ #define FONT_SIZE_Y 8
#define FONT_NOF_CHARS 128
-inline const Kernel::UInt8 cFontBitmap[FONT_NOF_CHARS][FONT_SIZE_X] = {
+inline const Kernel::UInt8 kFontBitmap[FONT_NOF_CHARS][FONT_SIZE_X] = {
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0000 (nul)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0001
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0002
@@ -145,7 +145,7 @@ inline const Kernel::UInt8 cFontBitmap[FONT_NOF_CHARS][FONT_SIZE_X] = { };
-inline Kernel::Void CGRenderStringFromBitMap(const Kernel::UInt8* bitmap, const Kernel::SizeT& x_sz, const Kernel::SizeT& y_sz, Kernel::Int32& x_dst, Kernel::Int32& y_dst, Kernel::Int32& color)
+inline Kernel::Void fb_render_string_for_bitmap(const Kernel::UInt8* bitmap, const Kernel::SizeT& x_sz, const Kernel::SizeT& y_sz, Kernel::Int32& x_dst, Kernel::Int32& y_dst, Kernel::Int32& color)
{
Kernel::Int32 x, y;
Kernel::Int32 set;
@@ -168,11 +168,11 @@ inline Kernel::Void CGRenderStringFromBitMap(const Kernel::UInt8* bitmap, const }
}
-inline Kernel::Void CGDrawString(const Kernel::Char* text, Kernel::Int32 x_dst, Kernel::Int32 y_dst, Kernel::Int32 color)
+inline Kernel::Void fb_render_string(const Kernel::Char* text, Kernel::Int32 x_dst, Kernel::Int32 y_dst, Kernel::Int32 color)
{
for (Kernel::SizeT i = 0; text[i] != 0; ++i)
{
- CGRenderStringFromBitMap(&cFontBitmap[text[i]][0], FONT_SIZE_X, FONT_SIZE_Y, x_dst, y_dst, color);
+ fb_render_string_for_bitmap(&kFontBitmap[text[i]][0], FONT_SIZE_X, FONT_SIZE_Y, x_dst, y_dst, color);
y_dst += FONT_SIZE_Y;
}
}
diff --git a/dev/SCIKit/src/Makefile b/dev/SCIKit/src/Makefile index 715674cf..83515aa3 100644 --- a/dev/SCIKit/src/Makefile +++ b/dev/SCIKit/src/Makefile @@ -9,8 +9,8 @@ FLAGS=-f win64 .PHONY: error error: @echo "==> Invalid rule." - @echo "==> Use sci_asm_io instead." + @echo "==> Use sci_asm_io_<arch> instead." -.PHONY: sci_asm_io -sci_asm_io: +.PHONY: sci_asm_io_x64 +sci_asm_io_x64: $(ASM) $(FLAGS) SCI+IO.asm -o SCI+IO.o |
