A sleek, modern digital clock application built with C++ and SFML 3.0. It features a borderless window with rounded corners, a thin visual cyan border, and professional window management including multi-monitor fullscreen support.
- Borderless & Transparent: A clean, modern look without standard Windows title bars or borders.
- Rounded Corners: Smooth 20px rounded window corners implemented via Win32 API.
- Smart Resizing: Custom-built resizing logic with enlarged corner hitboxes for easier handling.
- Multi-Monitor Fullscreen: Toggling fullscreen (
Alt+Enter) respects the monitor the window is currently on. - Proportional Scaling: The clock and date automatically scale to fit the window while maintaining a perfect aspect ratio.
- Embedded Assets: The DSEG7 font is embedded directly into the executable for single-file portability.
The application uses sf::Style::None to create a borderless window. Since this disables standard OS features, the following were manually implemented:
- Custom Dragging: Window can be moved by clicking and dragging anywhere in the center.
- Manual Resizing: Implemented via edge-detection logic:
- Gutter (8px): Used for horizontal and vertical resizing handles along the sides.
- Corner Zones (30px): Enlarged hit-areas in the corners to make diagonal resizing much more responsive.
- Window Shaping: Uses the Win32
SetWindowRgnandCreateRoundRectRgnto physically mask the window, making the areas outside the rounded corners transparent and "click-through."
The clock's size is dynamically calculated to ensure it remains legible and aesthetically pleasing at any window size:
- Target Aspect Ratio: The clock is designed around a 5.5:1 ratio.
- Dynamic Font Size: The font size is derived from the available height (
windowHeight * 0.8), ensuring the digits stay large. - Letterboxing: If the window is too wide or too tall, the layout adds proportional padding to center the clock.
- Date Positioning: The date is automatically centered and positioned below the time with a font size 25% of the main digits.
SFML's default fullscreen can sometimes jump to the primary monitor. This app uses Win32's MonitorFromWindow to identify the current display and creates a borderless window that perfectly matches that monitor's specific resolution and position.
- Alt + Enter: Toggle borderless fullscreen mode on the current monitor.
- Escape: Exit fullscreen and return to the last windowed position/size.
- Click & Drag: Move the windowed clock around the desktop.
- Edges & Corners: Resize the window (diagonal handles available in 30px corner radius).
- C++ Compiler: MinGW-w64 (g++) suggested.
- SFML 3.0.2: Statically linked (Graphics, Window, System).
- CMake: 3.16+ recommended for configuration.
# Configure
cmake -B build -G "MinGW Makefiles"
# Build
cmake --build build
# Run
.\build\DigitalClock.exemain.cpp: Core application logic, window management, and rendering.FontData.h: Compressed DSEG7 font binary data.CMakeLists.txt: Project configuration and dependency linking..vscode/: Pre-configured tasks for quick compilation and debugging.
- Font: DSEG7 Classic by Keshikan (Open Font License).
- Framework: SFML (Simple and Fast Multimedia Library).
