Тема: iCarDS+Foobar2000
Показать сообщение отдельно
Старый 18.08.2015, 22:36   #1841
kgena_ua
Пользователь
 
Регистрация: 14.02.2015
Возраст: 61
Регион: Украина
Машина: subaru forester
Сообщений: 54
kgena_ua is on a distinguished road
По умолчанию

Цитата:
Сообщение от duzzy Посмотреть сообщение
kgena_ua
а нельзя ли сделать анимацию перехода панелей просто по таймеру без функции on_paint?
duzzy. а вот пробую:
Код:
function RGB(r,g,b) { return (0xff000000|(r<<16)|(g<<8)|(b)); }

var font = gdi.Font("Arial",12,1);
var ww = window.Width, wh = window.Height;;

DT_LEFT = 0x00000000;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020; 
DT_WORD_ELLIPSIS = 0x00040000;

var panel = window.GetProperty("panel",0);
var c_panel = panel, n_panel;
var panels = 2;
var old_panel = panel;
var dir_move, move = false;

var y = 50;
var c_x = 0;
var n_x = 0;
var c_ww = 0;
var n_ww = 0;
var timer; 

var step_c = window.GetProperty("step_c", 10);
var step_n = window.GetProperty("step_n", 8);

pss.GetPanel(0).Show(true);   /// тут фигня какая-то, почему не отображается
pss.GetPanel(0).Move(c_x, y, window.Width, window.Height - y, true);

function on_paint(gr) {
	gr.FillSolidRect(0, 0, ww, wh, RGB(60,68,79));
	
	gr.GdiDrawText("1", font, RGB(250,250,250), 0, 0, ww / 3, y, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );
	gr.GdiDrawText("2", font, RGB(250,250,250), ww / 3, 0, ww / 3, y, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );	
	gr.GdiDrawText("3", font, RGB(250,250,250), ww / 3 * 2, 0, ww / 3, y, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );	

	dim();

//	pss.GetPanel(c_panel).Show(true);
//	pss.GetPanel(c_panel).Move(c_x, y, window.Width, window.Height - y, true);
	
//	if (dir_move == "right" ? n_x < 0 : n_x > 0) {
//		pss.GetPanel(n_panel).Show(true);
//		pss.GetPanel(n_panel).Move(n_x, y, n_ww, wh - y, true);
//	}

gr.GdiDrawText(panel, font, RGB(250,250,250), 0, 0, ww/2, y, DT_SINGLELINE | DT_CENTER | DT_VCENTER | DT_WORD_ELLIPSIS );	
}

function on_size(){
    ww = window.Width;   
    wh = window.Height;
}

function on_mouse_lbtn_down(x, y) {
	if (!move && on_mouse) {
		if (x >= 0 && x < ww / 3) {panel = 0};
		if (x >= ww / 3 && x <= ww / 3 * 2) {panel = 1};
	//	if (x >= ww / 3 * 2 && x <= ww) {panel = panel == 2 ? 3 : 2};
		
		if (x >= ww / 3 * 2 && x <= ww) {panel = panel == 3 ? 0 : panel + 1};

		dir_move = panel > old_panel ? "left" : "right";

		if (old_panel != panel) {
			move_panel();
			old_panel = panel
		}
	}
}

function on_mouse_wheel(delta) {
    if (pos_x >= ww / 3 * 2 && pos_x <= ww && on_mouse && !move) {	
		panel = panel == 3 ? 0 : panel + 1;
        
		dir_move = panel > old_panel ? "left" : "right";

		if (old_panel != panel) {
			move_panel();
			old_panel = panel
		}
    }
}

function move_panel() {
	n_panel = panel;

	dim();

	if (dir_move == "right" ? n_x = 0 - n_ww : n_x = c_ww);
	
	move = true;
	timer = window.CreateTimerInterval(10);
}

function on_timer(id) {
		if (dir_move == "left") {
			c_x = c_x - step_c;
			n_x = n_x - step_n;
		}
		if (dir_move == "right") {
			c_x = c_x + step_c;
			n_x = n_x + step_n;
		}
		
		pss.GetPanel(c_panel).Show(true);
		pss.GetPanel(c_panel).Move(c_x, y, window.Width, window.Height - y, true);
	
		if (dir_move == "right" ? n_x < 0 : n_x > 0) {
			pss.GetPanel(n_panel).Show(true);
			pss.GetPanel(n_panel).Move(n_x, y, n_ww, wh - y, true);
		}
		
		if (dir_move == "right" ? n_x >= 0 : n_x <= 0) {
//			pss.GetPanel(c_panel).Show(false);
//			window.SetProperty(c_panel,0);
//			window.SetProperty(n_panel,1);
			c_panel = n_panel;
			n_panel = null;
			c_x = 0;
			n_x = 0;
			timer.Dispose();
			move = false;
        }
	window.SetProperty("panel",panel);
	window.Repaint(); 
}

function dim() {
	n_ww = ww; 
	c_ww = ww; 
}

var pos_x;
var on_mouse = false;

function on_mouse_move(x, y) {
    on_mouse = true;
    window.SetCursor(32649);
    window.Repaint();
    pos_x = x;
}

function on_mouse_leave() {	
    on_mouse = false;
    window.SetCursor(32512);
    window.Repaint();
}
kgena_ua вне форума   Ответить с цитированием