Пример #1
0
void repaint_playing()
{
    win_draw(&wins.ctrl, false, false);
    win_draw(&wins.vis, false, false);
    
    if (win_isstarted(&wins.alert))
        win_draw(&wins.alert, true, false);
    else if (win_isstarted(&wins.msg))
        win_draw(&wins.msg, true, false);
    
    doupdate();
}
Пример #2
0
int
  main(int argc, char *argv[])
{
	win_t win;
	GdiplusStartupInput gdiplusStartupInput;
	ULONG_PTR gdiplusToken;

	GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

	win.dpy = XOpenDisplay(0);

	if (win.dpy == NULL) {
		fprintf(stderr, "Failed to open display\n");
		return 1;
	}

	win_init(&win);

	win_draw(&win);

	win_handle_events(&win);

	win_deinit(&win);

	XCloseDisplay(win.dpy);

	GdiplusShutdown(gdiplusToken);
	return 0;
}
Пример #3
0
/*-----------------------------------------------------------------------------*/
void
plot_win (int ti, YT_PLOT *plot, int iw, int ih, int ih_one)
{
  int  wi;
  int  yi = 1;

  // создаем экранную форму и рисуем главную рамочку
  YT_WIN  *win = win_create (iw, ih);
  win_rect (win, '=', '|', 0, 0, iw, ih);

  // здесь надо идти не по списку функций, а по фреймам!
  for (wi=0; plot->fr[wi][0] != -1; wi++) {

    plot_win_main (plot, win,  /* fi */wi, ti,  1, yi, iw-2, ih_one);

    yi += ih_one;
    win_horz (win, '=', yi, 2, iw-3);
    yi++;
  }

  // выводим экранную форму
  win_draw (win, 0, 0);

  return;
}
Пример #4
0
void win_add_dialog(win_t *win, const char *title, const char *text, int attr, int boxattr)
{
    if (win->type == WIN_MSG)
    {
        if (title != NULL)
        {
            win->titled = true;
            str_home(&win->title);
            str_puts(&win->title, "Help");
        }
        else
        {
            win->titled = false;
        }
                
        win_msg_set_text(win, text);

        win->attr = attr;
        win->boxattr = boxattr;
    
        win_msg_setup(win);
        win_draw(win, true, true);
    }
    else
        error("win_add_dialog(): window wasn't a WIN_MSG!\n");
}
Пример #5
0
Файл: main.c Проект: trylle/sxiv
void read_info(void)
{
	ssize_t i, n;
	char buf[BAR_L_LEN];

	while (true) {
		n = read(info.fd, buf, sizeof(buf));
		if (n < 0 && errno == EAGAIN)
			return;
		else if (n == 0)
			goto end;
		for (i = 0; i < n; i++) {
			if (buf[i] == '\n') {
				if (info.lastsep == 0) {
					win.bar.l.buf[info.i++] = ' ';
					info.lastsep = 1;
				}
			} else {
				win.bar.l.buf[info.i++] = buf[i];
				info.lastsep = 0;
			}
			if (info.i + 1 == win.bar.l.size)
				goto end;
		}
	}
end:
	info.i -= info.lastsep;
	win.bar.l.buf[info.i] = '\0';
	win_draw(&win);
	close(info.fd);
	info.fd = -1;
	while (waitpid(-1, NULL, WNOHANG) > 0);
}
Пример #6
0
void clear_screen()
{
    win_t win;
    win_init(&win, NULL);
    
    win.boxed = 0;
    
    win_setdims(&win, 0, 0, g_data.ui.ydim, g_data.ui.xdim);
        
    win_start(&win);
    win_draw(&win, true, true);
    win_stop(&win);
    
    win_uninit(&win);
}
Пример #7
0
/*-----------------------------------------------------------------------------*/
void
win_test1 ()
{
  int iw=60,  ih=30;
  YT_WIN  *win;

  // создаем экранную форму и рисуем главную рамочку
  win = win_create (iw, ih);  
  win_rect (win, '=', '=', 0, 0, 60, 30);

  win_line (win, '*', 2, 2,  15, 15);
  win_line (win, '*', 2, 2,  15, 5);
  win_ellipse  (win, '@',  15,15, 25,25);             
  win_triangle (win, '$',  40, 5,   35, 20,  50, 15);
  
  win_draw (win, 0, 0); // выводим экранную форму
  return;
}
Пример #8
0
ENTRYPOINT void
draw_stonerview (ModeInfo *mi)
{
  stonerview_configuration *bp = &bps[MI_SCREEN(mi)];

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));

  glPushMatrix ();
  gltrackball_rotate (bp->trackball);
  win_draw(bp->st);
  if (! bp->button_down_p)
    move_increment(bp->st);
  glPopMatrix ();

  mi->polygon_count = NUM_ELS;
  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(MI_DISPLAY (mi), MI_WINDOW(mi));
}
Пример #9
0
void clear_screen_bylines()
{
    win_t   win;
    int16_t i, rnd, pos;
    int8_t *lines = (int8_t *)malloc(g_data.ui.ydim * sizeof(int8_t));

    win_init(&win, NULL);
    win.boxed = 0;
    memset(lines, 0, g_data.ui.ydim * sizeof(int8_t));
   
    rand_open();
    
    for (i = g_data.ui.ydim; i > 0; i--)
    {
        rnd = rand_get() % i;
        pos = -1;
        
        while (rnd > -1)
        {
            if (lines[++pos] == 0)
                rnd--;
        }
        
        win_setdims(&win, pos, 0, 1, g_data.ui.xdim);
        
        win_start(&win);
        win_draw(&win, true, true);
        win_stop(&win);
        
        lines[pos] = 1;
        usleep(min(50000, (500000 / g_data.ui.ydim)));
    }

    rand_close();

    win_uninit(&win);
    free(lines);
}
Пример #10
0
static void
  win_handle_events(win_t *win)
{
	XEvent xev;

	while (1) {
		XNextEvent(win->dpy, &xev);
		switch(xev.type) {
		 case KeyPress:
			{
				XKeyEvent *kev = &xev.xkey;

				if (kev->keycode == win->quit_code) {
					return;
				}
			}
			break;
		 case ConfigureNotify:
			{
				XConfigureEvent *cev = &xev.xconfigure;

				win->width = cev->width;
				win->height = cev->height;
			}
			break;
		 case Expose:
			{
				XExposeEvent *eev = &xev.xexpose;

				if (eev->count == 0)
				  win_draw(win);
			}
			break;
		}
	}
}
Пример #11
0
void repaint(bool all)
{
    win_draw(&wins.ctrl, all, false);
    win_draw(&wins.vis, all, false);
    win_draw(&wins.pl, all, false);
    
    if (g_opts.pl.usequeue)
        win_draw(&wins.queue, all, false);

    if (win_isstarted(&wins.alert))
        win_draw(&wins.alert, true, false);
    else if (win_isstarted(&wins.msg))
        win_draw(&wins.msg, true, false);

    doupdate();
    
    if (all)
        g_data.bump = false;

    delta_zero(&g_data.ui.redraw_delta);
}
Пример #12
0
void img_render(img_t *img) {
	win_t *win;
	int sx, sy, sw, sh;
	int dx, dy, dw, dh;

	if (img == NULL || img->im == NULL || img->win == NULL)
		return;

	win = img->win;
	img_fit(img);

	if (!img->re) {
		/* rendered for the first time */
		img->re = true;
		if (img->zoom * img->w <= win->w)
			img->x = (win->w - img->w * img->zoom) / 2;
		else
			img->x = 0;
		if (img->zoom * img->h <= win->h)
			img->y = (win->h - img->h * img->zoom) / 2;
		else
			img->y = 0;
	}
	
	if (img->checkpan) {
		img_check_pan(img, false);
		img->checkpan = false;
	}

	if (!img->dirty)
		return;

	/* calculate source and destination offsets */
	if (img->x < 0) {
		sx = -img->x / img->zoom;
		sw = win->w / img->zoom;
		dx = 0;
		dw = win->w;
	} else {
		sx = 0;
		sw = img->w;
		dx = img->x;
		dw = img->w * img->zoom;
	}
	if (img->y < 0) {
		sy = -img->y / img->zoom;
		sh = win->h / img->zoom;
		dy = 0;
		dh = win->h;
	} else {
		sy = 0;
		sh = img->h;
		dy = img->y;
		dh = img->h * img->zoom;
	}

	win_clear(win);

	imlib_context_set_image(img->im);

	if (!img->alpha && imlib_image_has_alpha())
		win_draw_rect(win, win->pm, dx, dy, dw, dh, True, 0, win->white);
	
	imlib_context_set_drawable(win->pm);
	imlib_render_image_part_on_drawable_at_size(sx, sy, sw, sh, dx, dy, dw, dh);

	win_draw(win);

	img->dirty = false;
}
Пример #13
0
bool i_drag(arg_t a)
{
    int dx = 0, dy = 0, i, ox, oy, x, y;
    unsigned int ui;
    bool dragging = true, next = false;
    XEvent e;
    Window w;

    if (mode != MODE_IMAGE)
        return false;
    if (!XQueryPointer(win.env.dpy, win.xwin, &w, &w, &i, &i, &ox, &oy, &ui))
        return false;

    win_set_cursor(&win, CURSOR_HAND);

    while (dragging) {
        if (!next)
            XMaskEvent(win.env.dpy,
                       ButtonPressMask | ButtonReleaseMask | PointerMotionMask, &e);
        switch (e.type) {
        case ButtonPress:
        case ButtonRelease:
            dragging = false;
            break;
        case MotionNotify:
            x = e.xmotion.x;
            y = e.xmotion.y;

            /* wrap the mouse around */
            if (x < 0) {
                WARP(win.w, y);
            } else if (x > win.w) {
                WARP(0, y);
            } else if (y < 0) {
                WARP(x, win.h);
            } else if (y > win.h) {
                WARP(x, 0);
            }
            dx += x - ox;
            dy += y - oy;
            ox = x;
            oy = y;
            break;
        }
        if (dragging)
            next = XCheckIfEvent(win.env.dpy, &e, is_motionnotify, None);
        if ((!dragging || !next) && (dx != 0 || dy != 0)) {
            if (img_move(&img, dx, dy)) {
                img_render(&img);
                win_draw(&win);
            }
            dx = dy = 0;
        }
    }

    win_set_cursor(&win, CURSOR_ARROW);
    set_timeout(reset_cursor, TO_CURSOR_HIDE, true);
    reset_timeout(redraw);

    return false;
}