49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#pragma once
 | 
						|
 | 
						|
#include <memory>
 | 
						|
#include <vector>
 | 
						|
#include <SDL3/SDL.h>
 | 
						|
 | 
						|
#include "client_network.h"
 | 
						|
#include "gfx/types.h"
 | 
						|
#include "ui/ui_window.h"
 | 
						|
#include "ui/taskbar.h"
 | 
						|
#include "ui/launcher.h"
 | 
						|
#include "ui/ui_renderer.h"
 | 
						|
 | 
						|
/* Animated background stuff. */
 | 
						|
struct ScrollingText {
 | 
						|
  std::string text;
 | 
						|
  float x;
 | 
						|
  float y_precise; /* sub-pixel animation. */
 | 
						|
  float speed;
 | 
						|
  int render_y;    /* For pixel-perfect rendering. */
 | 
						|
};
 | 
						|
 | 
						|
class Desktop {
 | 
						|
public:
 | 
						|
  Desktop(int screen_width, int screen_height, ClientNetwork* network);
 | 
						|
  ~Desktop(void);
 | 
						|
 | 
						|
  void add_window(std::unique_ptr<UIWindow> window);
 | 
						|
  void handle_event(SDL_Event* event, int screen_width, int screen_height);
 | 
						|
  void update(float dt, int screen_width, int screen_height);
 | 
						|
  void render(const RenderContext& context);
 | 
						|
 | 
						|
  UIWindow* get_focused_window(void);
 | 
						|
 | 
						|
private:
 | 
						|
  void _set_focused_window(UIWindow* window);
 | 
						|
  void _render_wallpaper(UIRenderer* ui_renderer);
 | 
						|
  void _update_wallpaper(float dt, int screen_width, int screen_height);
 | 
						|
 | 
						|
  std::vector<std::unique_ptr<UIWindow>> _windows;
 | 
						|
  std::unique_ptr<Taskbar>   _taskbar;
 | 
						|
  std::unique_ptr<Launcher>  _launcher;
 | 
						|
  UIWindow*                  _focused_window;
 | 
						|
  ClientNetwork*             _network;
 | 
						|
  std::vector<ScrollingText> _background_text;
 | 
						|
  std::vector<std::string>   _snippets;
 | 
						|
  bool                       _launcher_is_open;
 | 
						|
};
 |