32 SDL_Init(SDL_INIT_VIDEO);
33 this->
window_ = SDL_CreateWindow(
App.
get_name().
c_str(), this->pos_x_, this->pos_y_, this->width_, this->height_,
34 this->window_options_);
35 this->
renderer_ = SDL_CreateRenderer(this->
window_, -1, SDL_RENDERER_SOFTWARE);
38 SDL_CreateTexture(this->
renderer_, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STATIC, this->
width_, this->
height_);
39 SDL_SetTextureBlendMode(this->
texture_, SDL_BLENDMODE_BLEND);
46 this->x_low_ = this->
width_;
60 SDL_Rect rect{x_start, y_start, w,
h};
62 Display::draw_pixels_at(x_start, y_start, w,
h, ptr, order, bitness, big_endian, x_offset, y_offset, x_pad);
64 auto stride = x_offset + w + x_pad;
65 auto data = ptr + (stride * y_offset + x_offset) * 2;
66 SDL_UpdateTexture(this->
texture_, &rect, data, stride * 2);
88 SDL_Rect rect{
x,
y, 1, 1};
90 SDL_UpdateTexture(this->
texture_, &rect, &data, 2);
104 callback->second(down);
109 if (SDL_PollEvent(&e)) {
114 case SDL_MOUSEBUTTONDOWN:
115 case SDL_MOUSEBUTTONUP:
116 if (e.button.button == 1) {
123 case SDL_MOUSEMOTION:
124 if (e.motion.state & 1) {
134 ESP_LOGD(TAG,
"keydown %d", e.key.keysym.sym);
139 ESP_LOGD(TAG,
"keyup %d", e.key.keysym.sym);
143 case SDL_WINDOWEVENT:
144 switch (e.window.event) {
145 case SDL_WINDOWEVENT_SIZE_CHANGED:
146 case SDL_WINDOWEVENT_EXPOSED:
147 case SDL_WINDOWEVENT_RESIZED: {
158 ESP_LOGV(TAG,
"Event %d", e.type);
const StringRef & get_name() const
Get the name of this Application set by pre_setup().
constexpr const char * c_str() const
static uint16_t color_to_565(Color color, ColorOrder color_order=ColorOrder::COLOR_ORDER_RGB)
Rect get_clipping() const
Get the current the clipping rectangle.
DisplayRotation rotation_
int get_height() override
void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order, display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override
int get_height_internal() override
void process_key(uint32_t keycode, bool down)
void redraw_(SDL_Rect &rect)
void draw_pixel_at(int x, int y, Color color) override
int get_width_internal() override
std::map< int32_t, CallbackManager< void(bool)> > key_callbacks_
@ DISPLAY_ROTATION_0_DEGREES
@ DISPLAY_ROTATION_270_DEGREES
@ DISPLAY_ROTATION_180_DEGREES
@ DISPLAY_ROTATION_90_DEGREES
Application App
Global storage of Application pointer - only one Application can exist.