Ejemplo n.º 1
0
static unsigned long
compass_draw (Display *dpy, Window window, void *closure)
{
  struct state *st = (struct state *) closure;
  XFillRectangle (st->dpy, st->b, st->erase_gc, 0, 0, st->xgwa.width, st->xgwa.height);

  draw_compass (st);
  draw_pointer (st);

#ifdef HAVE_DOUBLE_BUFFER_EXTENSION
  if (st->backb)
    {
      XdbeSwapInfo info[1];
      info[0].swap_window = st->window;
      info[0].swap_action = XdbeUndefined;
      XdbeSwapBuffers (st->dpy, info, 1);
    }
  else
#endif /* HAVE_DOUBLE_BUFFER_EXTENSION */
    if (st->dbuf)
      {
        XCopyArea (st->dpy, st->b, st->window, st->erase_gc, 0, 0,
                   st->size2, st->size2,
                   st->xgwa.width/2 - st->x,
                   st->xgwa.height/2 - st->y);
        st->b = (st->b == st->ba ? st->bb : st->ba);
      }

  return st->delay;
}
Ejemplo n.º 2
0
void ColorSlider::paintEvent(QPaintEvent * event)
{
    int w = width();
    int h = height();

    if (!pix || pix->width() != w) {
        delete pix;
        QImage img(w, 1, QImage::Format_RGB32);
        unsigned int * pixel = (unsigned int*)img.scanLine(0);
        const unsigned int * end = pixel + w;
        int x = 0;
        while (pixel < end) {
            QColor c;
            float hue = float(x) / float(w);
            c.setHsvF(hue, 1.0f, 1.0f);
            *pixel = c.rgb();
            pixel++;
            x++;
        }
        pix = new QPixmap(QPixmap::fromImage(img));
    }

    QPainter p(this);
    p.drawPixmap(0, 0, w, h, *pix);

    int p_x = int(value * w);
    draw_pointer(p_x, h / 2, p);
}
Ejemplo n.º 3
0
void ColorSpace::paintEvent(QPaintEvent * event)
{
    int w = width();
    int h = height();

    if (!pix || pix->height() != h || pix->width() != w) {
        delete pix;
        QImage img(w, h, QImage::Format_RGB32);
        unsigned int * pixel = (unsigned int*)img.scanLine(0);
        for (int y = 0; y < h; y++) {
            const unsigned int * end = pixel + w;
            int x = 0;
            while (pixel < end) {
                QColor c;
                float sat = float(x) / float(w);
                float val = 1.0f - float(y) / float(h);
                c.setHsvF(hue, sat, val);
                *pixel = c.rgb();
                pixel++;
                x++;
            }
        }
        pix = new QPixmap(QPixmap::fromImage(img));
    }

    QPainter p(this);
    p.drawPixmap(0, 0, *pix);

    int p_x = int(sat * w);
    int p_y = int((1.0f - val) * h);
    draw_pointer(p_x, p_y, p);
}
Ejemplo n.º 4
0
/* void draw_pointer (ESContext *esContext, int16_t x, int16_t y, int16_t w, int16_t h, char *file) { */
int tclcmd_draw_pointer (ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) {
    int len = 0;
    if (objc != 6) {
        Tcl_WrongNumArgs (interp, 1, objv, "{ESContext *esContext} { int16_t x} { int16_t y} { int16_t w} { int16_t h} { char *file}");
        return TCL_ERROR;
    }
    int16_t arg_x;
    if (Tcl_GetIntFromObj(interp, objv[1], (int *)&arg_x) != TCL_OK) {
        return TCL_ERROR;
    }
    int16_t arg_y;
    if (Tcl_GetIntFromObj(interp, objv[2], (int *)&arg_y) != TCL_OK) {
        return TCL_ERROR;
    }
    int16_t arg_w;
    if (Tcl_GetIntFromObj(interp, objv[3], (int *)&arg_w) != TCL_OK) {
        return TCL_ERROR;
    }
    int16_t arg_h;
    if (Tcl_GetIntFromObj(interp, objv[4], (int *)&arg_h) != TCL_OK) {
        return TCL_ERROR;
    }
    char arg_file[1024];
    strncpy(arg_file, Tcl_GetStringFromObj(objv[5], &len), 1024);
    draw_pointer(GlobalesContext, arg_x, arg_y, arg_w, arg_h, arg_file);
    return TCL_OK;
}
Ejemplo n.º 5
0
void glwidget::draw_decorating_info()
{
    // draw_pointer
    draw_pointer(nav);
    // draw orientation
    draw_orientation(nav);


    //error OpenGL_drawer_2
    GLenum errCode;
    const GLubyte *errString;
    if((errCode=glGetError()) != GL_NO_ERROR)
      {
        errString = gluErrorString(errCode);
        std::cout<<"OPENGL ERROR : "<<errString<<std::endl;
        //exit(-2);
      }


    //update fps
    nav.increase_frame_number();
    nav.time()=t_timer.elapsed();
    if(nav.delta_time()>1000)
        nav.update_fps();


    //draw fps
    draw_fps();


    //draw bottom right zoom
    draw_camera_stat();
}
Ejemplo n.º 6
0
int snd_menu(Sound *menu, int num_items)
{
	float x,y;
	float base_width = MAX_MENU_SIZE;
	float base_height = ((menu[num_items-1].y + ui_font_height()) - menu[0].y);

	int menu_pos;
	char work[32];

	int max_menu = 0;

	base_height += ui_font_height() * 2;
	for (int i = 0; i < num_items; ++i) {
    
		switch (menu[i].type) {
		case DLGTYPE_RADIO:
		case DLGTYPE_CHECK:
		case DLGTYPE_SLIDER:
			++max_menu;
			break;
		}
	}

	int result = -1;
	int id = 0;
	int sel = 0;
#if 0  
	int max_val  = 0;
	int min_val = 0;
	int val_index = 0;
#endif  
	float offx = ui_offx() + (ui_width() - base_width) / 2;
	float offy = ui_offy() + (ui_height() - base_height) / 2;

	int fade = 128;
  
	for (;;) {
		uisys_task();
      
		if (ui_keyrepeat(JOY_UP)) {

			switch (result) {
			case DID_PAD1_1A:
			case DID_PAD1_1B:
			case DID_PAD1_1C:
			case DID_PAD1_1D:
			case DID_PAD1_2A:
			case DID_PAD1_2B:
			case DID_PAD1_2C:
			case DID_PAD1_2D:
			case DID_PAD1_RA:
			case DID_PAD1_RB:
			case DID_PAD1_RC:
			case DID_PAD1_RD:
				break;
	
			default:
				if (--sel < 0)
					sel = max_menu - 1;
			}
      
		} else if (ui_keyrepeat(JOY_DOWN)) {
      
			switch (result) {
				
			case DID_PAD1_1A:
			case DID_PAD1_1B:
			case DID_PAD1_1C:
			case DID_PAD1_1D:
			case DID_PAD1_2A:
			case DID_PAD1_2B:
			case DID_PAD1_2C:
			case DID_PAD1_2D:
			case DID_PAD1_RA:
			case DID_PAD1_RB:
			case DID_PAD1_RC:
			case DID_PAD1_RD:
				break;
	
			default:
				if (++sel > (max_menu - 1))
					sel = 0;
			}
		}
#if 0			
		else if (ui_keyrepeat(JOY_RIGHT) || ui_keyrepeat(JOY_RTRIGGER)) {
      
			switch (result) {
			case DID_PAD1_1A:
			case DID_PAD1_1B:
			case DID_PAD1_1C:
			case DID_PAD1_1D:
			case DID_PAD1_2A:
			case DID_PAD1_2B:
			case DID_PAD1_2C:
			case DID_PAD1_2D:
			case DID_PAD1_RA:
			case DID_PAD1_RB:
			case DID_PAD1_RC:
			case DID_PAD1_RD:
				if (++val_index > max_val)
					val_index = max_val;
				break;
	
			default:
				if (++menu_index > 1) {
					menu_index = 1;
				} else {
					return 0;
				}
			}
		} else if (ui_keyrepeat(JOY_LEFT) || ui_keyrepeat(JOY_LTRIGGER)) {
      
			switch (result) {
			case DID_PAD1_1A:
			case DID_PAD1_1B:
			case DID_PAD1_1C:
			case DID_PAD1_1D:
			case DID_PAD1_2A:
			case DID_PAD1_2B:
			case DID_PAD1_2C:
			case DID_PAD1_2D:
			case DID_PAD1_RA:
			case DID_PAD1_RB:
			case DID_PAD1_RC:
			case DID_PAD1_RD:
				if (--val_index < min_val)
					val_index = min_val;
				break;
	
			default:
				if (--menu_index < 0) {
					menu_index = 0;
				} else {
					return 0;
				}
			}
		}
#endif
    
		if (ui_keypressed(JOY_A)) {

			switch (id) {

			case DID_JOYPAD1:
				menudlg_setval(id, !menudlg_getval(id));
				break;
				
			case DID_PAD1_1A:
			case DID_PAD1_1B:
			case DID_PAD1_1C:
			case DID_PAD1_1D:
			case DID_PAD1_2A:
			case DID_PAD1_2B:
			case DID_PAD1_2C:
			case DID_PAD1_2D:
			case DID_PAD1_RA:
			case DID_PAD1_RB:
			case DID_PAD1_RC:
			case DID_PAD1_RD:
				dlg_btn(id);
				break;

			}
		}
    
		if (ui_keypressed(JOY_B)) {

			switch (result) {
			case DID_PAD1_1A:
			case DID_PAD1_1B:
			case DID_PAD1_1C:
			case DID_PAD1_1D:
			case DID_PAD1_2A:
			case DID_PAD1_2B:
			case DID_PAD1_2C:
			case DID_PAD1_2D:
			case DID_PAD1_RA:
			case DID_PAD1_RB:
			case DID_PAD1_RC:
			case DID_PAD1_RD:
				result = -1;
				break;

			default:
				if (result < 0)
					return -1;
			}
		}

		if ((fade += 255/60) > 255) fade = 128;
      
		tx_resetfont();

		scrnmng_update();
		draw_transquad(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, UI_TR, UI_TR, UI_TR, UI_TR);
		draw_transquad(offx, offy, offx + base_width, offy + base_height, UI_BS, UI_BS, UI_BS, UI_BS);
      
		OEMSPRINTF(work, "%s ", mstr_snd);
		x = offx + (base_width - strlen(work) * ui_font_width()) / 2;
		y = offy;
		ui_font_draw(x, y, 255, 255, 255, work);

		y += ui_font_height();
		x = offx;

		draw_transquad(offx, y, offx + base_width, y + 1, MAKECOL32(128, 128, 128, 255),
					   MAKECOL32(128, 128, 128, 255), MAKECOL32(128, 128, 128, 255), MAKECOL32(128, 128, 128, 255));

		y += 6;

		menu_pos = 0;
		for (int i = 0; i < num_items; ++i) {
			
			int r = menu[i].r;
			int g = menu[i].g;
			int b = menu[i].b;
      
			switch (menu[i].type) {
	  
			case DLGTYPE_RADIO:
			case DLGTYPE_CHECK:
				if (menu_pos == sel) {

					draw_transquad(offx, y + menu[i].y, offx + base_width, y + menu[i].y + ui_font_height() + 5, MAKECOL32(255, 0, 0, fade), MAKECOL32(255, 0, 0, fade), MAKECOL32(255, 0, 0, fade), MAKECOL32(255, 0, 0, fade));

					id = menu[i].id;
				}


				switch (menu[i].id) {
	    
				default:
					if (menudlg_getval(menu[i].id))
						draw_pointer(x + menu[i].x - ui_font_width(), y + menu[i].y, 1);
				}
				ui_font_draw(x + menu[i].x, y + menu[i].y, r, g, b, (const char *)menu[i].arg);
				++menu_pos;
				break;
			}
		}
    
		for (int i = 0; i < num_items; ++i) {
      
			switch (menu[i].type) {
	
			case DLGTYPE_FRAME:
			case DLGTYPE_LTEXT:
			case DLGTYPE_RTEXT:
				ui_font_draw(x + menu[i].x, y + menu[i].y, menu[i].r, menu[i].g, menu[i].b, (const char *)menu[i].arg);
				break;
			}
		}

		x = ui_offx();
		y = ui_height() - ui_font_height();
    
		switch (result) {
		default:
			ui_font_draw(x, y, 255, 255, 255, "A:Select B:Back");
		}
		
		ta_commit_frame();
	}
}