예제 #1
0
BOOL LLWindowMacOSX::setCursorPosition(const LLCoordWindow position)
{
	BOOL result = FALSE;
	LLCoordScreen screen_pos;

	if (!convertCoords(position, &screen_pos))
	{
		return FALSE;
	}

	CGPoint newPosition;

	//	LL_INFOS() << "setCursorPosition(" << screen_pos.mX << ", " << screen_pos.mY << ")" << LL_ENDL;

	newPosition.x = screen_pos.mX;
	newPosition.y = screen_pos.mY;

	CGSetLocalEventsSuppressionInterval(0.0);
	if(CGWarpMouseCursorPosition(newPosition) == noErr)
	{
		result = TRUE;
	}

	// Under certain circumstances, this will trigger us to decouple the cursor.
	adjustCursorDecouple(true);

	// trigger mouse move callback
	LLCoordGL gl_pos;
	convertCoords(position, &gl_pos);
	mCallbacks->handleMouseMove(this, gl_pos, (MASK)0);

	return result;
}
예제 #2
0
void RenderTarget::drawTriangle(float x1, float y1, float x2, float y2, float x3, float y3, bool fill, const ALLEGRO_COLOR &color) {
	setAsCurrent();
	convertCoords(x1, y1);
	convertCoords(x2, y2);
	convertCoords(x3, y3);
	if (fill) {
		al_draw_filled_triangle(x1, y1, x2, y2, x3, y3, color);
	}
	else {
		al_draw_triangle(x1, y1, x2, y2, x3, y3, color, CBEnchanted::instance()->gfxInterface->getLineWidth());
	}
}
예제 #3
0
void GDrawEnv::C_UpdatePAD::action(Component* co)
{
    //SelectPlane* s = (SelectPlane*)co;

    src->vals.clear();
    src->plane->getValueVec(src->vals);
   
    src->sigvals.clear();
    convertCoords(src->vals, src->sigvals);
   
    src->sig->setData(src->sigvals);
   
   
    /*   for(int i=0;i<src->vals.size();i++)
         {
         cout << src->vals[i].x << " " << src->vals[i].y << endl;
         }*/
   
    /*if(src->plane->hasLastSelected())
      {
      //Coord c = s->getValue(s->getLastSelected());
      //cout << c.x << " " << c.y << endl;
      }
    */
}
예제 #4
0
void RenderTarget::drawText(const ALLEGRO_FONT *font, const ISString &text, float x, float y, const ALLEGRO_COLOR &color, int flags) {
	setAsCurrent();
	convertCoords(x, y);
	if ((flags & Center) == Center) {
		al_draw_text(font, color, x, y - al_get_font_ascent(font) * 0.5f, ALLEGRO_ALIGN_CENTRE, text.getUtf8Encoded().c_str());
		return;
	}
	if ((flags & VCenter) == VCenter) {
		y -= al_get_font_ascent(font) * 0.5f;
	}
	else if ((flags & Bottom) == Bottom) {
		y -= al_get_font_ascent(font);
	}
	if ((flags & HCenter) == HCenter) {
		al_draw_text(
			font,
			color,
			x,
			y,
			ALLEGRO_ALIGN_CENTRE,
			text.getUtf8Encoded().c_str()
		);
		return;
	}
	if ((flags & Right) == Right) {
		al_draw_text(font, color, x, y, ALLEGRO_ALIGN_RIGHT, text.getUtf8Encoded().c_str());
		return;
	}
	al_draw_text(font, color, x, y, 0, text.getUtf8Encoded().c_str());
}
예제 #5
0
bool MF_Polar::update(unsigned int t){
	_coords->update(t);
	_origin->update(t);

	convertCoords();
	
	setSDL_RecPos();
	return checkBounds();
}
예제 #6
0
void RenderTarget::drawBox(float x, float y, float w, float h, bool fill, const ALLEGRO_COLOR &color) {
	setAsCurrent();
	convertCoords(x, y);
	if (fill) {
		al_draw_filled_rectangle(x, y, x + w, y + h, color);
	}
	else {
		al_draw_rectangle(x, y, x + w, y + h, color, CBEnchanted::instance()->gfxInterface->getLineWidth());
	}
}
예제 #7
0
BOOL LLWindowMacOSX::setSizeImpl(const LLCoordScreen size)
{
	if(mWindow)
	{
        LLCoordWindow to;
        convertCoords(size, &to);
		setWindowSize(mWindow, to.mX, to.mY);
        return TRUE;
	}

	return FALSE;
}
예제 #8
0
void RenderTarget::drawCircle(float cx, float cy, float r, bool fill, const ALLEGRO_COLOR &color) {
	convertCoords(cx, cy);
	if (r <= 0) {
		return;
	}
	setAsCurrent();
	if (fill) {
		al_draw_filled_circle(cx, cy, r, color);
	}
	else {
		al_draw_circle(cx, cy, r, color, CBEnchanted::instance()->gfxInterface->getLineWidth());
	}
}
예제 #9
0
void RenderTarget::drawEllipse(float x, float y, float w, float h, bool fill, const ALLEGRO_COLOR &color) {
	convertCoords(x, y);
	if (w < 0 || h < 0) {
		return;
	}
	setAsCurrent();
	if (fill) {
		al_draw_filled_ellipse(x, y, w * 0.5f, h * 0.5f, color);
	}
	else {
		al_draw_ellipse(x, y, w * 0.5f, h * 0.5f, color, CBEnchanted::instance()->gfxInterface->getLineWidth());
	}
}
예제 #10
0
void GDrawEnv::setState(SoundCompEvent* e)
{
    DASSERT(e!=NULL);
    if(e->empty())return;
    if(e->getSize()!=sizeof(State))
    {
        DERROR("size missmatch");
        if(e->getSize() < sizeof(State))return;
	
        DERROR("trying to read...");
    }
    const State* s = (const State*)e->getData();
   
    sust_slide->setValue(s->sust);
    sust_index = sust_slide->getValue()*MAX_INDEX;
    sig->setSustainIndex((int)sust_index);
   
    gate_on->setValue(s->b_gate);
    sig->setGateTrigOn(gate_on->isPressed());

    //set data
    vals.clear();
    for(unsigned int i=0;i<s->n_wp;i++)vals.push_back(s->data[i]);
   
    plane->setWaypoints(vals);
   
    sigvals.clear();
    convertCoords(vals, sigvals);
   
    sig->setData(sigvals);
   
    holdend->setValue(s->holdend);
    fincyc->setValue(s->fincyc);
   
    sig->setGateFinishCycle(fincyc->getValue());
    sig->setHoldEndValue(holdend->getValue());
}
예제 #11
0
void RenderTarget::drawDot(float x, float y, const ALLEGRO_COLOR &color) {
	setAsCurrent();
	convertCoords(x, y);
	al_draw_pixel(x, y, color);
}
예제 #12
0
void RenderTarget::drawBitmap(ALLEGRO_BITMAP *r, float x, float y, float rot, float xscale, float yscale, const ALLEGRO_COLOR &tint) {
	setAsCurrent();
	convertCoords(x, y);
	al_draw_tinted_scaled_rotated_bitmap(r, tint, al_get_bitmap_width(r) * 0.5f, al_get_bitmap_height(r) * 0.5f, x, y, xscale, yscale, rot, 0);
}
예제 #13
0
void RenderTarget::drawBitmap(ALLEGRO_BITMAP *r, float x, float y, const ALLEGRO_COLOR &tint) {
	setAsCurrent();
	convertCoords(x, y);
	al_draw_tinted_bitmap(r, tint, x, y, 0);
}
예제 #14
0
void RenderTarget::drawBitmapRegion(ALLEGRO_BITMAP *r, float sx, float sy, float sw, float sh, const ALLEGRO_COLOR &tint, float x, float y, float rot) {
	setAsCurrent();
	convertCoords(x, y);
	al_draw_tinted_scaled_rotated_bitmap_region(r, sx, sy, sw, sh, tint, sw * 0.5f, sh * 0.5f, x, y, 1.0f, 1.0f, rot, 0);
}
예제 #15
0
void RenderTarget::drawBitmapRegion(ALLEGRO_BITMAP *r, float sx, float sy, float sw, float sh, float dx, float dy, float xscale, float yscale, float rot) {
	setAsCurrent();
	convertCoords(dx, dy);
	al_draw_tinted_scaled_rotated_bitmap_region(r, sx, sy, sw, sh, al_map_rgba_f(1, 1, 1, 1), sw * 0.5, sh * 0.5, dx, dy, xscale, yscale, rot, 0);
}
예제 #16
0
void RenderTarget::drawBitmap(ALLEGRO_BITMAP *r, float x, float y, float rot) {
	setAsCurrent();
	convertCoords(x, y);
	al_draw_rotated_bitmap(r, al_get_bitmap_width(r) * 0.5f, al_get_bitmap_height(r) * 0.5f, x, y, rot, 0);
}
예제 #17
0
void RenderTarget::drawBitmapRegion(ALLEGRO_BITMAP *r, float rx, float ry, float rw, float rh, float x, float y) {
	setAsCurrent();
	convertCoords(x, y);
	al_draw_bitmap_region(r, rx, ry, rw, rh, x, y, 0);
}
예제 #18
0
void RenderTarget::drawBitmap(ALLEGRO_BITMAP *r, float x, float y, float w, float h) {
	convertCoords(x, y);
	drawBitmapRegion(r, 0, 0, al_get_bitmap_width(r), al_get_bitmap_height(r), x, y, w, h);
}
예제 #19
0
void RenderTarget::drawBitmapRegion(ALLEGRO_BITMAP*r, float sx, float sy, float sw, float sh, float tx, float ty, float tw, float th) {
	setAsCurrent();
	convertCoords(tx, ty);
	al_draw_scaled_bitmap(r, sx, sy, sw, sh, tx, ty, tw, th, 0);
}
예제 #20
0
void RenderTarget::drawBitmap(ALLEGRO_BITMAP *r, float x, float y) {
	setAsCurrent();
	convertCoords(x, y);
	al_draw_bitmap(r, x, y, 0);
}
예제 #21
0
//use this for static curve also
//spline mode
GDrawEnv::GDrawEnv(BitmapFont* f, GroundMixer& g) : SoundComp(g)
{
    v = new ConvertHz2Per(Convert(progstate.getSampleRate()),&empty);
   
    sig = new CPInterpolator();
   
    sig->setInput(NULL);
    sig->setPeriod((Value**)&v);
    sig->setGate(NULL);
    sig->setGateTrigOn(false);
   
    sust_index= (int)(MAX_INDEX*0.5);
    sig->setSustainIndex((int)sust_index);
   
    plane = new SelectPlane(192,96);
    plane->maxWaypoints(MAX_WAYP);
    plane->setValueRange(0, MAX_INDEX, -SMP_MAX, SMP_MAX);
   
    SDL_Color color;
    color.r=0;
    color.g=200;
    color.b=100;
   
    SelectPlane::ValueMarker v;
    v.data=sig->getDataIndexPtr();
    v.w=1;
    v.color=color;
    v.mode=SelectPlane::ValueMarker::LINE;
   
    plane->addValueMarker(v);
   
    color.r=200;
    color.g=0;
    color.b=100;
   
    v.data=&sust_index;
    v.color=color;
   
    plane->addValueMarker(v);
   
   
    plane->setAction(new C_UpdatePAD(this));
    plane->setMouseMoveAction(new C_UpdatePAD(this));
    plane->setFunctionMode();
    plane->setClickMoveDelay(75);
    plane->showLine(true);
   
    ProgramState& ps = ProgramState::instance();
    plane->setLineParam(ps.getGraphColor());
   
    vals.clear();
    sigvals.clear();
   
    plane->getValueVec(vals);
    convertCoords(vals, sigvals);
   
    sig->setData(sigvals);
   
   
   
    Pixmap* back_pix = new Pixmap(pix["320x158"]);
    add(back_pix, 0,0);
    add(new MoveBorder(this,back_pix->pos.w,20),0,0);
   
    Pixmap* vec_pix = new Pixmap(pix["vback192x96"]);
   
    int xp=116;
    int yp=24;
    add(vec_pix, xp,yp);
    add(plane,xp,yp);
   
    for(int i=0;i<3;i++)
    {
        in[i] = new InputTaker(pix["in"], this, i);
        addInputTaker(in[i]);
    }
   
    Label* l = new Label(fnt["label"]);
    l->printF("graphical envelope/osc");
    add(l,GCOMP_LABEL_XOFF, GCOMP_LABEL_YOFF);
      
    //input
    add(in[0], GCOMP_STDIN_XOFF,GCOMP_STDIN_YOFF);
   
   
    int xoff=12;
    int yoff=-40;
   
    //freq
    l = new Label(f);
    l->printF("frq");
    add(l, -2+xoff, 70+yoff);
   
    add(in[1],36+xoff, 68+yoff);
   
    //GATE
      
    add(in[2],36+xoff,88+yoff);
   
    l = new Label(f);
    l->printF("gate");
    add(l, -2+xoff, 90+yoff);
   

    l = new Label(f);
    l->printF("off");
    add(l, 6+xoff, 105+yoff);
   
    gate_on = new Button(pix["bs_left"],pix["bs_right"]);
    gate_on->stayPressed(true);
    gate_on->setAction(new C_GateOn(this));
    add(gate_on, 30+xoff,100+yoff);
   
    l = new Label(f);
    l->printF("on");
    add(l, 55+xoff, 105+yoff);
   
    LedsLevel<smp_t>* led=new LedsLevel<smp_t>(pix["led_on"],pix["led_off"]);
    led->setData(sig->gateValPtr());
    led->setThreshold(GATE_ZERO_LVL);
    add(led, 52+xoff,81+yoff);
   

    og = new OutputGiver(pix["out"],this,0);
    addOutputGiver(og);
    add(og,GCOMP_STDOUT_XOFF,GCOMP_STDOUT_YOFF);
   
    rem_sel = new Button(pix["up"],pix["down"]);
    rem_sel->stayPressed(false);
    rem_sel->setAction(new C_RemSel(this));
    add(rem_sel, 95,26);
   
      
    sust_slide = new Slider(pix["slide_knobv"], pix["slide_underv"],true);
    sust_slide->setMouseMoveAction(new C_SustPos(this));
    add(sust_slide, 95,46);
    sust_slide->setValue(0.5);
   
    drain = new Drain(this);
    out = new SmpPoint(&drain->cval);
   
    ground.addInput((Value**)&drain);
   
    yoff = 130;
    xoff = 20;
   
    l = new Label(f);
    l->printF("hold end.v");
    add(l, xoff, yoff+5);
   
    holdend = new Button(pix["up"],pix["down"]);
    holdend->stayPressed(true);
    holdend->setAction(new C_HOLDEND(this));
    add(holdend, xoff+90,yoff);
   
    xoff+=140;
   
    l = new Label(f);
    l->printF("fin cycle");
    add(l, xoff, yoff+5);
   
    fincyc = new Button(pix["up"],pix["down"]);
    fincyc->stayPressed(true);
    fincyc->setAction(new C_FINCYC(this));
    add(fincyc, xoff+80,yoff);
   
    sig->setGateFinishCycle(fincyc->getValue());
    sig->setHoldEndValue(holdend->getValue());
}
예제 #22
0
BOOL LLWindowMacOSX::convertCoords(LLCoordGL from, LLCoordScreen *to)
{
	LLCoordWindow window_coord;

	return(convertCoords(from, &window_coord) && convertCoords(window_coord, to));
}
예제 #23
0
/*
S16 LLWindowMacOSX::dragTrackingHandler(DragTrackingMessage message, WindowRef theWindow,
						  void * handlerRefCon, DragRef drag)
{
	S16 result = 0;
	LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon;

	LL_DEBUGS() << "drag tracking handler, message = " << message << LL_ENDL;

	switch(message)
	{
		case kDragTrackingInWindow:
			result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_TRACK);
		break;

		case kDragTrackingEnterHandler:
			result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_START_TRACKING);
		break;

		case kDragTrackingLeaveHandler:
			result = self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_STOP_TRACKING);
		break;

		default:
		break;
	}

	return result;
}
OSErr LLWindowMacOSX::dragReceiveHandler(WindowRef theWindow, void * handlerRefCon,
										 DragRef drag)
{
	LLWindowMacOSX *self = (LLWindowMacOSX*)handlerRefCon;
	return self->handleDragNDrop(drag, LLWindowCallbacks::DNDA_DROPPED);

}
*/
void LLWindowMacOSX::handleDragNDrop(std::string url, LLWindowCallbacks::DragNDropAction action)
{
	MASK mask = LLWindowMacOSX::modifiersToMask(getModifiers());

	float mouse_point[2];
	// This will return the mouse point in window coords
	getCursorPos(mWindow, mouse_point);
	LLCoordWindow window_coords(mouse_point[0], mouse_point[1]);
	LLCoordGL gl_pos;
	convertCoords(window_coords, &gl_pos);
	
	if(!url.empty())
	{
		LLWindowCallbacks::DragNDropResult res =
		mCallbacks->handleDragNDrop(this, gl_pos, mask, action, url);
		
		switch (res) {
			case LLWindowCallbacks::DND_NONE:		// No drop allowed
				if (action == LLWindowCallbacks::DNDA_TRACK)
				{
					mDragOverrideCursor = 0;
				}
				else {
					mDragOverrideCursor = -1;
				}
				break;
			case LLWindowCallbacks::DND_MOVE:		// Drop accepted would result in a "move" operation
				mDragOverrideCursor = UI_CURSOR_NO;
				break;
			case LLWindowCallbacks::DND_COPY:		// Drop accepted would result in a "copy" operation
				mDragOverrideCursor = UI_CURSOR_ARROWCOPY;
				break;
			default:
				mDragOverrideCursor = -1;
				break;
		}
		// This overrides the cursor being set by setCursor.
		// This is a bit of a hack workaround because lots of areas
		// within the viewer just blindly set the cursor.
		if (mDragOverrideCursor == -1)
		{
			// Restore the cursor
			ECursorType temp_cursor = mCurrentCursor;
			// get around the "setting the same cursor" code in setCursor()
			mCurrentCursor = UI_CURSOR_COUNT;
			setCursor(temp_cursor);
		}
		else {
			// Override the cursor
			switch (mDragOverrideCursor) {
				case 0:
					setArrowCursor();
					break;
				case UI_CURSOR_NO:
					setNotAllowedCursor();
				case UI_CURSOR_ARROWCOPY:
					setCopyCursor();
				default:
					break;
			};
		}
	}
}
예제 #24
0
Vector2f RenderTarget::convertCoords(const Vector2i& point) const
{
    return convertCoords(point, getView());
}
Tile * Map::getTile(unsigned int x, unsigned int y)
{
	auto tile = m_tileMap.find(convertCoords(x, y));
	return (tile != m_tileMap.end() ? tile->second : nullptr);
}
예제 #26
0
void RenderTarget::drawLine(float x1, float y1, float x2, float y2, const ALLEGRO_COLOR &color) {
	setAsCurrent();
	convertCoords(x1, y1);
	convertCoords(x2, y2);
	al_draw_line(x1, y1, x2, y2, color, CBEnchanted::instance()->gfxInterface->getLineWidth());
}