Example #1
0
void wxRibbonMetroArtProvider::DrawPartialPageBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect,
                                                         wxRibbonPage* page, wxPoint offset, bool hovered)
{
    wxRect background;
    // Expanded panels need a background - the expanded panel at
    // best size may have a greater Y dimension higher than when
    // on the bar if it has a sizer. AUI art provider does not need this
    // because it paints the panel without reference to its parent's size.
    // Expanded panels use a wxFrame as parent (not a wxRibbonPage).

    if(wnd->GetSizer() && wnd->GetParent() != page) {
        background = wnd->GetParent()->GetSize();
        offset = wxPoint(0, 0);
    } else {
        background = page->GetSize();
        page->AdjustRectToIncludeScrollButtons(&background);
        background.height -= 2;
    }
    // Page background isn't dependant upon the width of the page
    // (at least not the part of it intended to be painted by this
    // function). Set to wider than the page itself for when externally
    // expanded panels need a background - the expanded panel can be wider
    // than the bar.
    background.x = 0;
    background.width = INT_MAX;

    wxRect paint_rect(rect);

    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(m_page_background_colour);
    dc.DrawRectangle(rect);
}
Example #2
0
static int decode_hextile(VmncContext *c, uint8_t* dst, const uint8_t* src, int ssize, int w, int h, int stride)
{
    int i, j, k;
    int bg = 0, fg = 0, rects, color, flags, xy, wh;
    const int bpp = c->bpp2;
    uint8_t *dst2;
    int bw = 16, bh = 16;
    const uint8_t *ssrc=src;

    for(j = 0; j < h; j += 16) {
        dst2 = dst;
        bw = 16;
        if(j + 16 > h) bh = h - j;
        for(i = 0; i < w; i += 16, dst2 += 16 * bpp) {
            if(src - ssrc >= ssize) {
                av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
                return -1;
            }
            if(i + 16 > w) bw = w - i;
            flags = *src++;
            if(flags & HT_RAW) {
                if(src - ssrc > ssize - bw * bh * bpp) {
                    av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
                    return -1;
                }
                paint_raw(dst2, bw, bh, src, bpp, c->bigendian, stride);
                src += bw * bh * bpp;
            } else {
                if(flags & HT_BKG) {
                    bg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
                }
                if(flags & HT_FG) {
                    fg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
                }
                rects = 0;
                if(flags & HT_SUB)
                    rects = *src++;
                color = !!(flags & HT_CLR);

                paint_rect(dst2, 0, 0, bw, bh, bg, bpp, stride);

                if(src - ssrc > ssize - rects * (color * bpp + 2)) {
                    av_log(c->avctx, AV_LOG_ERROR, "Premature end of data!\n");
                    return -1;
                }
                for(k = 0; k < rects; k++) {
                    if(color) {
                        fg = vmnc_get_pixel(src, bpp, c->bigendian); src += bpp;
                    }
                    xy = *src++;
                    wh = *src++;
                    paint_rect(dst2, xy >> 4, xy & 0xF, (wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);
                }
            }
        }
        dst += stride * 16;
    }
    return src - ssrc;
}
Example #3
0
// ---------------------------------------------------------------
// paint a window
// ---------------------------------------------------------------
// paint a single window
static void paint_window( t_window* window, t_paint_surface& paint_surface, t_screen_rect const& rect )
{
    t_screen_point paint_origin;
    t_screen_point size = paint_surface.get_screen_rect().size();

    for (paint_origin.x = rect.left; paint_origin.x < rect.right; paint_origin.x += size.x)
    {
        for (paint_origin.y = rect.top; paint_origin.y < rect.bottom; paint_origin.y += size.y)
        {
            t_screen_rect paint_rect( paint_origin.x, paint_origin.y, paint_origin.x + size.x, paint_origin.y + size.y );

            paint_rect = intersection( paint_rect, rect );

            paint_surface.set_screen_rect( paint_rect );
            window->paint( paint_surface );
            paint_surface.copy_buffer();
        }
    }
}
Example #4
0
// ---------------------------------------------------------------
// paint a window
// ---------------------------------------------------------------
static void paint_transparency( t_window* window, t_paint_surface& paint_surface,
                                t_window_rect& region )
{
    t_screen_point paint_origin;
    t_screen_point size = paint_surface.get_screen_rect().size();
    t_screen_point window_origin = paint_surface.get_window_origin();

    for (paint_origin.x = region.left; paint_origin.x < region.right; paint_origin.x += size.x)
    {
        for (paint_origin.y = region.top; paint_origin.y < region.bottom;
                paint_origin.y += size.y)
        {
            t_screen_rect paint_rect( paint_origin.x, paint_origin.y,
                                      paint_origin.x + size.x, paint_origin.y + size.y );

            paint_rect = intersection( paint_rect, region );
            paint_surface.set_screen_rect( paint_rect );
            paint_surface.set_window_origin( window_origin );
            window->paint_transparency( paint_surface, region.windows );
        }
    }
}
Example #5
0
int
main(void)
{
    zplPlatform p_ = {0};
    zplPlatform *p = &p_;
    
    zpl_platform_init_with_software(p, "Test", WIN_WIDTH, WIN_HEIGHT, 0);
    
    b32 IsRunning = true;
    u32 *pixels = p->sw_framebuffer.memory;
    
    Rect window_rect = {
        .x = 0, .y = 0,
        .w = p->window_width, .h = p->window_height
    };
    
    i32 player_size = 64;
    i32 player_x = window_rect.w/2 - player_size/2; 
    i32 player_y = window_rect.h/2 - player_size/2; 
    i32 player_speed = 2; 
    
    Rect player_rect = {
        .x = player_x, .y = player_y,
        .w = player_size, .h = player_size
    };
    
    i32 font_x, font_y, font_n;
    u8 *font = stbi_load("font.bmp", &font_x, &font_y, &font_n, 4);
    
    i32 image_x, image_y, image_n;
    u8 *image_data = stbi_load("test0.jpg", &image_x, &image_y, &image_n, 4);
    u32 *filt_mem = zpl_malloc(image_x*image_y*4);
    
    f64 filter[5][5] = {
        -1, -1, -1, -1,  0,
        -1, -1, -1,  0,  1,
        -1, -1,  0,  1,  1,
        -1,  0,  1,  1,  1,
        0,  1,  1,  1,  1
    };
    
    zpl_image_rgb_filter(cast(u32 *)image_data, image_x, image_y,
                         filt_mem,
                         &filter[0][0], 5, 5,
                         1.0, 128.0);
    
    zpl_memcopy(image_data, filt_mem, image_x*image_y*4);
    
    Rect image_rect = {
        .x = 10, .y = 10,
        .w = image_x, .h = image_y
    };
    
    i32 gif_x, gif_y, gif_frames, gif_cursor = 0, gif_cd = 0;
    zplGifResult *gif = zpl_image_gif_load("test1.gif", &gif_x, &gif_y, &gif_frames);
    zplGifResult *gif_ptr = gif;
    //u32 *blur_mem = zpl_malloc(gif_x*gif_y*64);
    
    
    zplGifResult *node = gif;
    for(; node; node = node->next) {
        u8 *old_mem = node->data;
        u8 *new_mem = zpl_malloc(gif_x*gif_y*64);
        
        zpl_image_rgb_resize(cast(u32 *)old_mem, gif_x, gif_y,
                             cast(u32 *)new_mem, gif_x*4, gif_y*4, 
                             512, new_mem);
        
        node->data = new_mem;
        
        STBI_FREE(old_mem);
    }
    
    //zpl_mfree(blur_mem);
    zpl_mfree(filt_mem);
    
    gif_x *= 4;
    gif_y *= 4;
    
    Rect gif_rect = {
        .x = image_x+10, .y = 10,
        .w = gif_x, .h = gif_y
    };
    
    zplString str = 0;
    str = zpl_string_make(zpl_heap_allocator(), "Hello World!");
    
    while (IsRunning) {
        zpl_platform_update(p);
        
        if (p->keys[zplKey_Escape] == true ||
            p->keys[zplKey_Space]  == true) {
            IsRunning = false;
        }
        else if (p->window_is_closed) {
            IsRunning = false;
        }
        
        // NOTE(ZaKlaus): player controls
        if(p->keys[zplKey_A]) {
            player_x -= player_speed;
        }
        if (p->keys[zplKey_D]) {
            player_x += player_speed;
        }
        if (p->keys[zplKey_W]) {
            player_y -= player_speed;
        }
        if (p->keys[zplKey_S]) {
            player_y += player_speed;
        }
        
        slider = zpl_clamp(slider, 0, 255);
        
        /**/ if (p->keys[zplKey_K]) {
            slider--;
        }
        else if (p->keys[zplKey_L]) {
            slider++;
        }
        
        player_x = zpl_clamp(player_x, 0, p->window_width -player_size);
        player_y = zpl_clamp(player_y, 0, p->window_height-player_size);
        
        player_rect.x = player_x;
        player_rect.y = player_y;
        
        // NOTE(ZaKlaus): gif playback
        
        //gif_delay = &gif_data[(slider+1) * 4 * gif_x * gif_y + pad];
        //u8 delay[2] = { *(gif_delay), *(gif_delay+1) };
        
        if (gif_cursor == gif_frames-1) {
            gif_cursor = 0;
            gif_ptr = gif;
        }
        else {
            if (!gif_cd) {
                ++gif_cursor;
                gif_ptr = gif_ptr->next;
            }
        }
        
        if (!gif_cd) {
            gif_cd  = gif_ptr->delay;
        }
        else {
            gif_cd -= 2;
        }
        
        // NOTE(ZaKlaus): clear the screen
        fill_rect(pixels, 0x000000, window_rect);
        
        // NOTE(ZaKlaus): draw the image
        paint_rect(pixels, cast(u32 *)image_data, image_x, image_rect);
        
        // NOTE(ZaKlaus): draw the gif
        paint_rect(pixels, cast(u32 *)gif_ptr->data, gif_x, gif_rect);
        
        // NOTE(ZaKlaus): render the player
        fill_rect(pixels, 0xFF0000, player_rect);
        
        Rect font_rect = {
            .x = 10, .y = WIN_HEIGHT - 100,
            .w = 32, .h = 32
        };
        
        draw_text(pixels, cast(u32 *)font, str, font_x, font_rect);
        
        zpl_platform_display(p);
        
        zpl_sleep_ms(16);
    }
    
    zpl_image_gif_free(gif, true);
    
    return 0;
}
Example #6
0
void wxRibbonAUIArtProvider::DrawPartialPanelBackground(wxDC& dc,
        wxWindow* wnd, const wxRect& rect)
{
    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(m_background_brush);
    dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);

    wxPoint offset(wnd->GetPosition());
    wxWindow* parent = wnd->GetParent();
    wxRibbonPanel* panel = NULL;

    for(; parent; parent = parent->GetParent())
    {
        panel = wxDynamicCast(parent, wxRibbonPanel);
        if(panel != NULL)
        {
            if(!panel->IsHovered())
                return;
            break;
        }
        offset += parent->GetPosition();
    }
    if(panel == NULL)
        return;

    wxRect background(panel->GetSize());
    RemovePanelPadding(&background);
    background.x++;
    background.width -= 2;
    dc.SetFont(m_panel_label_font);
    int caption_height = dc.GetTextExtent(panel->GetLabel()).GetHeight() + 7;
    background.y += caption_height - 1;
    background.height -= caption_height;

    wxRect paint_rect(rect);
    paint_rect.x += offset.x;
    paint_rect.y += offset.y;

    wxColour bg_clr, bg_grad_clr;
#ifdef __WXMAC__
    bg_grad_clr = m_page_hover_background_colour;
    bg_clr = m_page_hover_background_gradient_colour;
#else
    bg_clr = m_page_hover_background_colour;
    bg_grad_clr = m_page_hover_background_gradient_colour;
#endif

    paint_rect.Intersect(background);
    if(!paint_rect.IsEmpty())
    {
        wxColour starting_colour(wxRibbonInterpolateColour(bg_clr, bg_grad_clr,
            paint_rect.y, background.y, background.y + background.height));
        wxColour ending_colour(wxRibbonInterpolateColour(bg_clr, bg_grad_clr,
            paint_rect.y + paint_rect.height, background.y,
            background.y + background.height));
        paint_rect.x -= offset.x;
        paint_rect.y -= offset.y;
        dc.GradientFillLinear(paint_rect, starting_colour, ending_colour
            , wxSOUTH);
    }
}