Exemplo n.º 1
0
void ScrubbingToolBar::EnableDisableButtons()
{
   const auto scrubButton = mButtons[STBScrubID];
   scrubButton->SetEnabled(true);
   const auto seekButton = mButtons[STBSeekID];
   seekButton->SetEnabled(true);

   AudacityProject *p = GetActiveProject();
   if (!p) return;

   auto &scrubber = p->GetScrubber();
   const auto canScrub = scrubber.CanScrub();

   if (scrubber.Scrubs()) {
      scrubButton->PushDown();
      scrubButton->Enable();
   }
   else {
      scrubButton->PopUp();
      if (canScrub)
         scrubButton->Enable();
      else
         scrubButton->Disable();
   }

   if (scrubber.Seeks()) {
      seekButton->PushDown();
      seekButton->Enable();
   }
   else {
      seekButton->PopUp();
      if (canScrub)
         seekButton->Enable();
      else
         seekButton->Disable();
   }

   const auto barButton = mButtons[STBRulerID];
   barButton->Enable();
   if (p->GetRulerPanel()->ShowingScrubRuler())
      barButton->PushDown();
   else
      barButton->PopUp();
   RegenerateTooltips();
   scrubber.CheckMenuItems();
}
__int64 Query(int s,int t,int l,int r,int rt)
{
    if (s<=l && r<=t)
        return sum[rt];
    PushDown(rt,r-l+1);
    __int64 ans=0;
    int m=(l+r)>>1;
    if (s<=m)   ans+=Query(s,t,l,m,rt<<1);
    if (m<t)    ans+=Query(s,t,m+1,r,rt<<1|1);
    return ans;
}
LL Query(int L,int R,int l,int r,int rt)
{
    if(L<=l&&R>=r)
        return sum[rt];
    PushDown(rt,r-l+1);
    int m=(l+r)>>1;
    LL ret=0;
    if(L<=m)   ret+=Query(L,R,lson);
    if(R>m)    ret+=Query(L,R,rson);
    return ret;
}
Exemplo n.º 4
0
huffman_node_t *Extract(priorityQueue *pqueue){
    huffman_node_t *tempnode;
    if(pqueue->size>0){
        tempnode=pqueue->queue[0];
        pqueue->queue[0]=pqueue->queue[pqueue->size-1];
        pqueue->queue[pqueue->size-1]=tempnode;
        --pqueue->size;
        PushDown(pqueue,0);
        return pqueue->queue[pqueue->size];
    }
    return null;
}
Exemplo n.º 5
0
void QuadTreeNode::AddMesh(QuadTreeMesh *new_mesh, int depth)
{
    size_t meshes_size = meshes.size();

    // If we have reached the last level of the quad tree, add the mesh and return
    if(depth == 0)
    {
        meshes.push_back(new_mesh);
        return;
    }

    // If this node has no meshes or children, go ahead and add the mesh to it
    if(GetChildCount() == 0 && meshes_size < QUADTREE_TARGET_LEAF_SIZE)
    {
        meshes.push_back(new_mesh);
        return;
    }

    // If there are already meshes at this node, add it anyway if it's close enough to the first one
    if(meshes_size > 0)
    {
        D3DXVECTOR3 diff = new_mesh->sphere.center - meshes[0]->sphere.center;
        if(D3DXVec3Length(&diff) <= QUADTREE_MIN_DIST)
        {
            meshes.push_back(new_mesh);
            return;
        }
    }

    // Push down the new mesh and the existing ones
    PushDown(new_mesh, depth);

    for (size_t i = 0; i != meshes_size; ++i)
        PushDown(meshes[i], depth);

    // Clear mesh list
    meshes.clear();
}
Exemplo n.º 6
0
void Run(UI* ui)
{   if(ui == NULL) return;
    NewGame(ui->game);
    NextTurn(ui->game);
    int c, running = 1;
    while(running && ui->game->status != GAME_STATUS_ERROR)
    {   DisplayGame(ui);
        c = getch();
        switch(c)
        {
        case KEY_LEFT:
            if(ui->game->status != GAME_STATUS_LOST)
            {	if(PushLeft(ui->game)) NextTurn(ui->game);
                else CheckTurn(ui->game);
            }
            break;
        case KEY_RIGHT:
            if(ui->game->status != GAME_STATUS_LOST)
            {	if(PushRight(ui->game)) NextTurn(ui->game);
                else CheckTurn(ui->game);
            }
            break;
        case KEY_UP:
            if(ui->game->status != GAME_STATUS_LOST)
            {	if(PushUp(ui->game)) NextTurn(ui->game);
                else CheckTurn(ui->game);
            }
            break;
        case KEY_DOWN:
            if(ui->game->status != GAME_STATUS_LOST)
            {	if(PushDown(ui->game)) NextTurn(ui->game);
                else CheckTurn(ui->game);
            }
            break;
        case 'q':
            running = 0;
            break;
        case 'n':
            NewGame(ui->game);
            NextTurn(ui->game);
            break;
        case 'r':
            StartGame(ui->game);
            NextTurn(ui->game);
            break;
        default:
            break;
        }
    }
}
Exemplo n.º 7
0
Arquivo: 3468.c Projeto: GuidoPaul/ACM
void query(int L, int R, int p) {
	if (L <= tree[p].L && R >= tree[p].R) {
		ans += tree[p].sum;
		return ;
	}
	PushDown(p);
	int mid = (tree[p].L + tree[p].R) >> 1;
	if (mid >= R) query(L, R, p << 1);
	else if (mid + 1 <= L) query(L, R, p << 1 | 1);
	else {
		query(L, mid, p << 1);
		query(mid + 1, R, p << 1 | 1);
	}
}
void Update(int s,int t,int v,int l,int r,int rt)
{
    if (s<=l && r<=t)
    {
        add[rt]+=v;
        sum[rt]+=v*(r-l+1);
        return ;
    }
    PushDown(rt,r-l+1);
    int m=(l+r)>>1;
    if (s<=m)   Update(s,t,v,l,m,rt<<1);
    if (m<t)    Update(s,t,v,m+1,r,rt<<1|1);
    PushUp(rt);
}
void query(int l,int r,int rt)
{
	if(cover[rt]==1)
	{
		for (int i=l; i<=r; i++) 
			hash[i]=true;
		return;
	}else if(cover[rt]==0) return;
	if(l==r)return;
	PushDown(rt);
	int m=(l+r)>>1;
	query(l,m,rt<<1);
	query(m+1,r,rt<<1|1);
}
Exemplo n.º 10
0
void TerrainTest::Event(SDL_Event* event)
{
	switch (event->type)
	{
		case SDL_KEYUP:
		{
			switch (event->key.keysym.sym)
			{
				case SDLK_n:
					NewGrid(Width() / TILE_SIZE, Height() / TILE_SIZE);
					break;	
				case SDLK_q:
					if (m_iUpperHeight < MAX_HEIGHT)
						m_iUpperHeight++;
					break;
				case SDLK_a:
					if (m_iUpperHeight > 0)
						m_iUpperHeight--;
					break;
				case SDLK_w:
					if (m_iLowerHeight < MAX_HEIGHT)
						m_iLowerHeight++;
					break;
				case SDLK_s:
					if (m_iLowerHeight > 0)
						m_iLowerHeight--;
					break;
				case SDLK_t:
					m_bDisplayTypeMap = !m_bDisplayTypeMap;
					break;
				default: break;
			}
		} break;
		case SDL_MOUSEMOTION:
		{
			int x, y;
			if (gui->IsMouseButtonDown(MOUSE_BUTTON_LEFT, &x, &y))
			{
				PushUp(x / TILE_SIZE, y / TILE_SIZE);
			}
			else if (gui->IsMouseButtonDown(MOUSE_BUTTON_RIGHT, &x, &y))
			{
				PushDown(x / TILE_SIZE, y / TILE_SIZE);
			}
		} break;
		default: break;
	}
}
Exemplo n.º 11
0
Arquivo: 3468.c Projeto: GuidoPaul/ACM
void update(int L, int R, int c, int p) {
	if (L <= tree[p].L && R >= tree[p].R) {
		tree[p].mark += c;
		tree[p].sum += (long long)c * (tree[p].R - tree[p].L + 1);
		return ;
	}
	PushDown(p);
	int mid = (tree[p].L + tree[p].R) >> 1;
	if (mid >= R) update(L, R, c, p << 1);
	else if (mid + 1 <= L) update(L, R, c, p << 1 | 1);
	else {
		update(L, mid, c, p << 1);
		update(mid + 1, R, c, p << 1 | 1);
	}
	PushUP(p);
}
void Update(int L,int R,int c,int l,int r,int rt)
{
    if(L<=l&&R>=r)
    {
        add[rt]+=c;
        sum[rt]+=(LL)c*(r-l+1);
        return;
    }
    PushDown(rt,r-l+1);
    int m=(l+r)>>1;
    if(L<=m)
        Update(L,R,c,lson);
    if(R>m)
        Update(L,R,c,rson);
    PushUP(rt);
}
Exemplo n.º 13
0
__int64 Query(int L, int R, int l, int r, int rt)
{
    if (L<=l && r<=R)
        return sum[rt];
    
    PushDown(rt, r-l+1);    /* Push down */
    
    __int64 ret = 0;
    int     m = (l+r)>>1;

    if (L <= m)
        ret += Query(L, R, lson);
    if (R > m)
        ret += Query(L, R, rson);

    return ret;
}/* Query */
Exemplo n.º 14
0
int query(int v,int l,int r,int pos)
{
    if(l==r)
    {
        if(v==l)
            return t[pos];
        return 0;
    }
    PushDown(pos);

    int mid=(l+r)>>1;

    if(v<=mid)
        return query(v,l,mid,pos<<1);

    return query(v,mid+1,r,pos<<1|1);
}
Exemplo n.º 15
0
Arquivo: 1698.c Projeto: GuidoPaul/ACM
void update(int L, int R, int c, int p) {
	if(L <= tree[p].L && R >= tree[p].R) {
		tree[p].mark = c;
		tree[p].sum = (tree[p].R - tree[p].L + 1) * c;
		return ;
	}
	PushDown(p);
	int mid = (tree[p].R + tree[p].L) >> 1;
	if(mid >= R) {
		update(L, R, c, p << 1);
	} else if(mid + 1 <= L) {
		update(L, R, c, p << 1 | 1);
	} else {
		update(L, mid, c, p << 1);
		update(mid + 1, R, c, p << 1 | 1);
	}
	PushUP(p);
}
Exemplo n.º 16
0
void UpData(int L, int R, int c, int l, int r, int rt)
{
    if (L<=l && r<=R)
    {
        col[rt] += c;
        sum[rt] += c*(r-l+1);
        
        return ;
    }/* End of If */

    PushDown(rt, r-l+1);    /* Push down */

    int m = (l+r)>>1;

    if (L <= m)
        UpData(L, R, c, lson);
    if (R > m)
        UpData(L, R, c, rson);
    sum[rt] = sum[rt<<1] + sum[rt<<1|1];    /* Push Up */
}/* UpData */
Exemplo n.º 17
0
void update(int a,int b,int l,int r,int pos)
{
    if(a>r || b<l)
        return;

    if(a<=l && b>=r)
    {
        t[pos]++;
        return;
    }
    if(l==r)    return;

    int mid=(l+r)>>1;

    PushDown(pos);

    if(a<=mid)
        update(a,b,l,mid,pos<<1);
    if(b>mid)
        update(a,b,mid+1,r,pos<<1|1);
}
Exemplo n.º 18
0
void update(int a,int b,int v,int l,int r,int pos)
{

    if(a<=l && b>=r)
    {
        mix[pos]=false;
        color[pos]=v;
        return;
    }

    if(l==r)    return;
    int mid=(l+r)>>1;
    PushDown(pos);

    if(a<=mid)
        update(a,b,v,l,mid,pos<<1);
    if(b>mid)
        update(a,b,v,mid+1,r,pos<<1|1);

    PushUp(pos);
}
Exemplo n.º 19
0
void query(int a,int b,int l,int r,int pos)
{
    if(!mix[pos])
    {
        in[color[pos]]=true;
        return;
    }

    PushDown(pos);

    if(l==r)    return;

    int mid=(l+r)>>1;


    if(a<=mid)
        query(a,b,l,mid,pos<<1);
    if(b>mid)
        query(a,b,mid+1,r,pos<<1|1);

    PushUp(pos);
}
void update(char op,int L,int R,int l,int r,int rt)
{
	if (L<=l&&r<=R) {
		if (op=='U') {
			cover[rt]=1;
			XOR[rt]=0;
		}else if (op=='D') {
			cover[rt]=0;
			XOR[rt]=0;
		}else if (op=='C' || op=='S') {
			FXOR(rt);
		}
		return;
	}
	PushDown(rt);
	int m=(l+r)>>1;
	if (L<=m) update(op,L,R,l,m,rt<<1);
	else if(op=='I'||op=='C')
		XOR[rt<<1]=cover[rt<<1]=0;
	if (R>m) update(op,L,R,m+1,r,rt<<1|1);
	else if (op=='I'||op=='C') 
		XOR[rt<<1|1]=cover[rt<<1|1]=0;
}