mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:48:12 +00:00
LibWeb: Make input widget (buttons, text boxes, etc) scroll with page
We now relayout all LayoutWidgets when the view is scrolled. This will cause them to follow along with the rest of the page content.
This commit is contained in:
parent
889a8e7d0f
commit
e58e315e0f
4 changed files with 28 additions and 3 deletions
|
@ -24,11 +24,15 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/ScrollBar.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <LibGfx/Font.h>
|
||||
#include <LibGfx/StylePainter.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/Frame.h>
|
||||
#include <LibWeb/Layout/LayoutWidget.h>
|
||||
#include <LibWeb/PageView.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
|
@ -47,7 +51,11 @@ void LayoutWidget::layout(LayoutMode layout_mode)
|
|||
{
|
||||
rect().set_size(widget().width(), widget().height());
|
||||
LayoutReplaced::layout(layout_mode);
|
||||
widget().move_to(rect().x(), rect().y());
|
||||
|
||||
auto adjusted_widget_position = rect().location().to_int_point();
|
||||
if (auto* page_view = document().frame()->page_view())
|
||||
adjusted_widget_position.move_by(-page_view->horizontal_scrollbar().value(), -page_view->vertical_scrollbar().value());
|
||||
widget().move_to(adjusted_widget_position);
|
||||
}
|
||||
|
||||
void LayoutWidget::render(RenderingContext& context)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue