void ScrollView::suppressScrollbars(bool suppressed, bool repaintOnSuppress) { m_data->m_scrollbarsSuppressed = suppressed; if (repaintOnSuppress && !suppressed) { if (m_data->m_hBar) m_data->m_hBar->invalidate(); if (m_data->m_vBar) m_data->m_vBar->invalidate(); // Invalidate the scroll corner too on unsuppress. IntRect hCorner; if (m_data->m_hBar && width() - m_data->m_hBar->width() > 0) { hCorner = IntRect(m_data->m_hBar->width(), height() - m_data->m_hBar->height(), width() - m_data->m_hBar->width(), m_data->m_hBar->height()); invalidateRect(hCorner); } if (m_data->m_vBar && height() - m_data->m_vBar->height() > 0) { IntRect vCorner(width() - m_data->m_vBar->width(), m_data->m_vBar->height(), m_data->m_vBar->width(), height() - m_data->m_vBar->height()); if (vCorner != hCorner) invalidateRect(vCorner); } } }
bool GenerateGrids(int x_grids, int y_grids, Vertex_VCN **ppVertices, int *pNum_Vertices, unsigned short **ppIndices, int *pNum_Indices, int *num_triangles) { const int triangles_per_row = x_grids * 2; const int indices_per_row = triangles_per_row + 2; *num_triangles = triangles_per_row * y_grids; int num_vertices = (x_grids + 1) * (y_grids + 1); *pNum_Vertices = num_vertices; Vertex_VCN *pVertices = (Vertex_VCN *) Allocate16BytesAlignedMemory(sizeof(Vertex_VCN)*num_vertices); *ppVertices = pVertices; if ( pVertices==NULL ) return false; int num_indices = indices_per_row * y_grids; *pNum_Indices = num_indices; unsigned short *pIndices = new unsigned short[num_indices]; *ppIndices = pIndices; if ( pIndices==NULL ) { Release16BytesAlignedMemory(pVertices); return false; } Vector4 vCorner(-0.5f, 0.5f, 0.0f, 1.0f); Vector4 vStep(1.0f/float(x_grids), -1.0f/float(y_grids), 0.0f, 0.0f); Vector4 vPosition = vCorner; Vector4 vNormal(0.0f, 0.0f, 1.0f); Vector4 vColor(1.0f, 1.0f, 1.0f, 1.0f); int x,y; int vertex_index = 0; for ( y=0; y<=y_grids; y++) { vPosition[0] = vCorner[0]; for ( x=0; x<=x_grids; x++, vertex_index++) { pVertices[vertex_index].m_Position = vPosition; pVertices[vertex_index].m_Normal = vNormal; pVertices[vertex_index].m_Color = vColor; vPosition[0] += vStep[0]; } vPosition[1] += vStep[1]; } const int vertices_per_row = x_grids + 1; bool from_left_to_right = true; int index_index = 0; vertex_index = 0; for ( y=0; y<y_grids; y++ ) { if ( from_left_to_right ) { pIndices[index_index++] = y * vertices_per_row; pIndices[index_index++] = y * vertices_per_row + vertices_per_row; for ( x=0; x<x_grids; x++ ) { vertex_index = y * vertices_per_row + x; pIndices[index_index++] = vertex_index + 1; pIndices[index_index++] = vertex_index + 1 + vertices_per_row; } } else { pIndices[index_index++] = y * vertices_per_row + x_grids; pIndices[index_index++] = (y+1) * vertices_per_row + x_grids; for ( x=x_grids; x>0; x-- ) { vertex_index = y * vertices_per_row + x; pIndices[index_index++] = vertex_index - 1; pIndices[index_index++] = vertex_index - 1 + vertices_per_row; } } from_left_to_right = !from_left_to_right; } return true; }
void ScrollView::paint(GraphicsContext* context, const IntRect& rect) { // FIXME: This code is here so we don't have to fork FrameView.h/.cpp. // In the end, FrameView should just merge with ScrollView. ASSERT(isFrameView()); if (context->paintingDisabled() && !context->updatingControlTints()) return; IntRect documentDirtyRect = rect; documentDirtyRect.intersect(frameGeometry()); context->save(); context->translate(x(), y()); documentDirtyRect.move(-x(), -y()); context->translate(-contentsX(), -contentsY()); documentDirtyRect.move(contentsX(), contentsY()); context->clip(enclosingIntRect(visibleContentRect())); static_cast<const FrameView*>(this)->frame()->paint(context, documentDirtyRect); context->restore(); // Now paint the scrollbars. if (!m_data->m_scrollbarsSuppressed && (m_data->m_hBar || m_data->m_vBar)) { context->save(); IntRect scrollViewDirtyRect = rect; scrollViewDirtyRect.intersect(frameGeometry()); context->translate(x(), y()); scrollViewDirtyRect.move(-x(), -y()); if (m_data->m_hBar) m_data->m_hBar->paint(context, scrollViewDirtyRect); if (m_data->m_vBar) m_data->m_vBar->paint(context, scrollViewDirtyRect); // Fill the scroll corner with white. IntRect hCorner; if (m_data->m_hBar && width() - m_data->m_hBar->width() > 0) { hCorner = IntRect(m_data->m_hBar->width(), height() - m_data->m_hBar->height(), width() - m_data->m_hBar->width(), m_data->m_hBar->height()); if (hCorner.intersects(scrollViewDirtyRect)) context->fillRect(hCorner, Color::white); } if (m_data->m_vBar && height() - m_data->m_vBar->height() > 0) { IntRect vCorner(width() - m_data->m_vBar->width(), m_data->m_vBar->height(), m_data->m_vBar->width(), height() - m_data->m_vBar->height()); if (vCorner != hCorner && vCorner.intersects(scrollViewDirtyRect)) context->fillRect(vCorner, Color::white); } context->restore(); } }