From c629c5415348ccd166d08f52026ffd77d4dfc0d3 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 5 Jun 2024 12:40:13 +0200 Subject: [PATCH] Make util/geometry.h C++20 friendly - Move header to base/include to make it applicable for base types like 'Affinity' down the road. - Represent 'Rect' as typle of point and area, which is the most common form of initialization, creates in valid 'Rect' by default. - Turn Point, Area, and Rect into compound types, making x, y, w, h, at, area accessible without a method call - 'Rect::Compound' function for constructing a 'Rect' from two points, replacing a former constructor - Use result type 'Rect::Cut_remainder' instead of out parameters. Fixes #5239 --- repos/base/include/util/geometry.h | 253 +++++++++++++++++ repos/demo/include/scout/element.h | 6 +- .../include/scout/graphics_backend_impl.h | 12 +- repos/demo/include/scout/user_state.h | 2 +- repos/demo/include/scout/window.h | 30 +- .../scout_gfx/horizontal_shadow_painter.h | 4 +- repos/demo/include/scout_gfx/icon_painter.h | 22 +- .../scout_gfx/refracted_icon_painter.h | 22 +- .../include/scout_gfx/sky_texture_painter.h | 14 +- repos/demo/src/app/launchpad/child_entry.h | 12 +- repos/demo/src/app/launchpad/launch_entry.h | 14 +- .../src/app/launchpad/launchpad_window.cc | 44 +-- .../demo/src/app/launchpad/launchpad_window.h | 8 +- repos/demo/src/app/launchpad/loadbar.h | 32 +-- repos/demo/src/app/launchpad/main.cc | 2 +- repos/demo/src/app/launchpad/section.h | 24 +- repos/demo/src/app/launchpad/status_entry.h | 12 +- repos/demo/src/app/scout/browser.h | 2 +- repos/demo/src/app/scout/browser_window.cc | 56 ++-- repos/demo/src/app/scout/browser_window.h | 8 +- repos/demo/src/app/scout/elements.cc | 90 +++--- repos/demo/src/app/scout/elements.h | 12 +- repos/demo/src/app/scout/main.cc | 18 +- repos/demo/src/app/scout/navbar.cc | 22 +- repos/demo/src/app/scout/png_image.cc | 4 +- repos/demo/src/app/scout/scrollbar.cc | 12 +- repos/demo/src/app/scout/sky_texture.h | 2 +- repos/demo/src/app/scout/titlebar.h | 16 +- repos/demo/src/app/scout/widgets.cc | 16 +- repos/demo/src/app/scout/widgets.h | 2 +- .../liquid_framebuffer/framebuffer_window.h | 36 +-- .../src/server/liquid_framebuffer/main.cc | 2 +- .../src/server/liquid_framebuffer/services.cc | 6 +- repos/demo/src/server/nitlog/main.cc | 14 +- repos/gems/include/gems/animated_geometry.h | 12 +- repos/gems/include/gems/gui_buffer.h | 4 +- repos/gems/include/gems/png_image.h | 4 +- repos/gems/include/gems/texture_utils.h | 18 +- repos/gems/include/nano3d/scene.h | 8 +- repos/gems/include/polygon_gfx/clipping.h | 14 +- repos/gems/include/polygon_gfx/line_painter.h | 11 +- .../polygon_gfx/polygon_painter_base.h | 22 +- .../polygon_gfx/shaded_polygon_painter.h | 2 +- .../polygon_gfx/textured_polygon_painter.h | 4 +- .../gems/include/polygon_gfx/texturize_rgba.h | 8 +- repos/gems/src/app/backdrop/main.cc | 28 +- repos/gems/src/app/cpu_load_display/main.cc | 10 +- repos/gems/src/app/decorator/canvas.h | 2 +- repos/gems/src/app/decorator/window.cc | 68 ++--- repos/gems/src/app/decorator/window.h | 62 ++--- .../src/app/menu_view/box_layout_widget.h | 22 +- repos/gems/src/app/menu_view/button_widget.h | 14 +- repos/gems/src/app/menu_view/cursor.h | 8 +- .../gems/src/app/menu_view/depgraph_widget.h | 30 +- repos/gems/src/app/menu_view/dialog.h | 20 +- repos/gems/src/app/menu_view/float_widget.h | 10 +- repos/gems/src/app/menu_view/frame_widget.h | 14 +- repos/gems/src/app/menu_view/label_widget.h | 16 +- repos/gems/src/app/menu_view/root_widget.h | 4 +- repos/gems/src/app/menu_view/widget.h | 6 +- repos/gems/src/app/nano3d/main.cc | 6 +- repos/gems/src/app/osci/main.cc | 6 +- repos/gems/src/app/phone_manager/main.cc | 10 +- repos/gems/src/app/rom_osci/main.cc | 10 +- repos/gems/src/app/screenshot_trigger/main.cc | 4 +- repos/gems/src/app/sculpt_manager/main.cc | 76 +++--- repos/gems/src/app/themed_decorator/theme.cc | 37 +-- .../src/app/themed_decorator/tint_painter.h | 4 +- repos/gems/src/app/themed_decorator/window.cc | 12 +- repos/gems/src/app/themed_decorator/window.h | 49 ++-- repos/gems/src/app/window_layouter/assign.h | 14 +- .../app/window_layouter/decorator_margins.h | 8 +- repos/gems/src/app/window_layouter/window.h | 44 +-- repos/gems/src/lib/ttf_font/ttf_font.cc | 2 +- repos/gems/src/lib/vfs/ttf/vfs.cc | 4 +- .../server/gui_fader/alpha_dither_painter.h | 8 +- repos/gems/src/server/terminal/main.cc | 6 +- .../src/server/terminal/text_screen_surface.h | 44 ++- repos/gems/src/server/wm/gui.h | 20 +- repos/gems/src/server/wm/main.cc | 4 +- repos/gems/src/server/wm/window_registry.h | 4 +- repos/gems/src/test/text_painter/main.cc | 10 +- repos/libports/src/app/pdf_view/main.cc | 32 +-- repos/libports/src/app/usb_webcam/main.cc | 8 +- .../src/driver/framebuffer/vesa/main.cc | 4 +- repos/libports/src/lib/qemu-usb/webcam.cc | 16 +- .../src/test/mesa_demo/eglut/eglut_genode.cc | 2 +- repos/os/include/blit/painter.h | 8 +- repos/os/include/decorator/window_stack.h | 12 +- .../include/framebuffer_session/connection.h | 4 +- repos/os/include/nitpicker_gfx/box_painter.h | 6 +- .../os/include/nitpicker_gfx/glyph_painter.h | 4 +- repos/os/include/nitpicker_gfx/text_painter.h | 8 +- .../include/nitpicker_gfx/texture_painter.h | 8 +- repos/os/include/nitpicker_gfx/tff_font.h | 5 +- repos/os/include/os/surface.h | 32 +-- repos/os/include/os/texture_rgb888.h | 8 +- repos/os/include/pointer/dither_painter.h | 4 +- repos/os/include/util/dirty_rect.h | 10 +- repos/os/include/util/geometry.h | 256 ------------------ repos/os/src/app/pointer/main.cc | 18 +- repos/os/src/app/status_bar/main.cc | 14 +- repos/os/src/driver/framebuffer/boot/main.cc | 4 +- repos/os/src/driver/framebuffer/sdl/main.cc | 6 +- .../src/driver/framebuffer/virtio/component.h | 18 +- repos/os/src/server/gui_fb/main.cc | 32 +-- repos/os/src/server/nitpicker/canvas.h | 8 +- .../os/src/server/nitpicker/capture_session.h | 3 +- .../os/src/server/nitpicker/chunky_texture.h | 2 +- .../os/src/server/nitpicker/domain_registry.h | 22 +- repos/os/src/server/nitpicker/draw_label.h | 2 +- repos/os/src/server/nitpicker/gui_session.cc | 12 +- repos/os/src/server/nitpicker/gui_session.h | 6 +- repos/os/src/server/nitpicker/main.cc | 10 +- repos/os/src/server/nitpicker/types.h | 2 +- repos/os/src/server/nitpicker/user_state.cc | 20 +- repos/os/src/server/nitpicker/user_state.h | 6 +- repos/os/src/server/nitpicker/view.cc | 6 +- repos/os/src/server/nitpicker/view.h | 4 +- repos/os/src/server/nitpicker/view_stack.cc | 32 +-- repos/os/src/server/nitpicker/view_stack.h | 4 +- repos/os/src/server/vmm/virtio_gpu.cc | 34 +-- repos/os/src/server/vmm/virtio_gpu.h | 2 +- repos/os/src/test/capture/main.cc | 4 +- repos/os/src/test/fb_bench/main.cc | 8 +- repos/os/src/test/framebuffer/main.cc | 4 +- repos/os/src/test/nitpicker/test.cc | 2 +- repos/os/src/test/vfs_capture/main.cc | 4 +- repos/ports/src/virtualbox5/frontend/fb.h | 32 +-- repos/ports/src/virtualbox6/include/fb.h | 32 +-- repos/ports/src/virtualbox6/input_adapter.h | 4 +- 131 files changed, 1200 insertions(+), 1218 deletions(-) create mode 100644 repos/base/include/util/geometry.h delete mode 100644 repos/os/include/util/geometry.h diff --git a/repos/base/include/util/geometry.h b/repos/base/include/util/geometry.h new file mode 100644 index 0000000000..0266ef6be9 --- /dev/null +++ b/repos/base/include/util/geometry.h @@ -0,0 +1,253 @@ +/* + * \brief Geometric primitives + * \author Norman Feske + * \date 2006-08-05 + */ + +/* + * Copyright (C) 2006-2024 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef _INCLUDE__UTIL__GEOMETRY_H_ +#define _INCLUDE__UTIL__GEOMETRY_H_ + +#include +#include +#include +#include + +namespace Genode { + template class Point; + template class Area; + template class Rect; +} + + +/** + * \param CT coordinate type + */ +template +struct Genode::Point +{ + CT x {}, y {}; + + /** + * Operator for adding points + */ + Point operator + (Point const &p) const { return Point(x + p.x, y + p.y); } + + /** + * Operator for subtracting points + */ + Point operator - (Point const &p) const { return Point(x - p.x, y - p.y); } + + /** + * Operator for testing non-equality of two points + */ + bool operator != (Point const &p) const { return p.x != x || p.y != y; } + + /** + * Operator for testing equality of two points + */ + bool operator == (Point const &p) const { return p.x == x && p.y == y; } + + void print(Output &out) const + { + auto abs = [] (auto v) { return v >= 0 ? v : -v; }; + + Genode::print(out, x >= 0 ? "+" : "-", abs(x), + y >= 0 ? "+" : "-", abs(y)); + } + + /** + * Construct point from XML node attributes + * + * The XML node is expected to feature the attributes 'xpos' and 'ypos'. + */ + static Point from_xml(Xml_node const &node) + { + return Point(node.attribute_value("xpos", CT{}), + node.attribute_value("ypos", CT{})); + } +}; + + +/** + * \param DT distance type + */ +template +struct Genode::Area +{ + DT w {}, h {}; + + bool valid() const { return w > 0 && h > 0; } + + size_t count() const { return size_t(w)*size_t(h); } + + /** + * Operator for testing non-equality of two areas + */ + bool operator != (Area const &a) const { return a.w != w || a.h != h; } + + /** + * Operator for testing equality of two areas + */ + bool operator == (Area const &a) const { return a.w == w && a.h == h; } + + void print(Output &out) const { Genode::print(out, w, "x", h); } + + /** + * Construct area from XML node attributes + * + * The XML node is expected to feature the attributes 'width' and + * 'height'. + */ + static Area from_xml(Xml_node const &node) + { + return Area(node.attribute_value("width", DT{}), + node.attribute_value("height", DT{})); + } +}; + + +/** + * Rectangle + * + * A valid rectangle consists of two points wheras point 2 has higher or equal + * coordinates than point 1. All other cases are threated as invalid + * rectangles. + * + * \param CT coordinate type + * \param DT distance type + */ +template +struct Genode::Rect +{ + using Point = Genode::Point; + using Area = Genode::Area
; + + Point at {}; + Area area {}; + + /** + * Construct rectangle from two given points + * + * The x and y coordinates of p1 must not be higher than those of p2. + */ + static constexpr Rect compound(Point const p1, Point const p2) + { + if (p1.x > p2.x || p1.y > p2.y) return { /* invalid */ }; + + return { .at = p1, + .area = { .w = DT(p2.x - p1.x + 1), + .h = DT(p2.y - p1.y + 1) } }; + } + + /** + * Construct compounding rectangle of two rectangles + */ + static constexpr Rect compound(Rect r1, Rect r2) + { + return compound(Point(min(r1.x1(), r2.x1()), min(r1.y1(), r2.y1())), + Point(max(r1.x2(), r2.x2()), max(r1.y2(), r2.y2()))); + } + + /** + * Construct rectangle by intersecting two rectangles + */ + static constexpr Rect intersect(Rect const r1, Rect const r2) + { + return Rect::compound(Point(max(r1.x1(), r2.x1()), max(r1.y1(), r2.y1())), + Point(min(r1.x2(), r2.x2()), min(r1.y2(), r2.y2()))); + } + + CT x1() const { return at.x; } + CT y1() const { return at.y; } + CT x2() const { return at.x + area.w - 1; } + CT y2() const { return at.y + area.h - 1; } + DT w() const { return area.w; } + DT h() const { return area.h; } + Point p1() const { return at; } + Point p2() const { return { x2(), y2() }; } + + /** + * Return true if rectangle area is greater than zero + */ + bool valid() const { return area.valid(); } + + /** + * Return true if area fits in rectangle + */ + bool fits(Area const area) const { return w() >= area.w && h() >= area.h; } + + /** + * Return true if the specified point lies within the rectangle + */ + bool contains(Point const p) const + { + return p.x >= x1() && p.x <= x2() && p.y >= y1() && p.y <= y2(); + } + + struct Cut_remainder + { + Rect top, left, right, bottom; + + void for_each(auto const &fn) const { fn(top); fn(left); fn(right); fn(bottom); } + }; + + /** + * Cut out rectangle from rectangle + * + * \param r rectangle to cut out + * + * In the worst case (if we cut a hole into the rectangle) we get + * four valid resulting rectangles. + */ + Cut_remainder cut(Rect r) const + { + /* limit the cut-out area to the actual rectangle */ + r = intersect(r, *this); + + return { + .top = compound(Point(x1(), y1()), Point(x2(), r.y1() - 1)), + .left = compound(Point(x1(), r.y1()), Point(r.x1() - 1, r.y2())), + .right = compound(Point(r.x2() + 1, r.y1()), Point(x2(), r.y2())), + .bottom = compound(Point(x1(), r.y2() + 1), Point(x2(), y2())) + }; + } + + /** + * Return position of an area when centered within the rectangle + */ + Point center(Area const area) const + { + return Point((CT(w()) - CT(area.w))/2, + (CT(h()) - CT(area.h))/2) + at; + } + + /** + * Print rectangle coordinates + * + * The output has the form 'width' x 'height' +/- 'p1.x' +/- 'p1.y'. + * For example, a rectange of size 15x16 as position (-13, 14) is + * printed as "15x16-13+14". + */ + void print(Output &out) const { Genode::print(out, area, at); } + + /** + * Construct rectangle from XML node attributes + * + * The XML node is expected to feature the attributes 'xpos', 'ypos'. + * 'width', and 'height'. If an attribute is absent, the corresponding + * value is set to 0. + */ + static Rect from_xml(Xml_node const &node) + { + return Rect(Point::from_xml(node), Area::from_xml(node)); + } +}; + +#endif /* _INCLUDE__UTIL__GEOMETRY_H_ */ diff --git a/repos/demo/include/scout/element.h b/repos/demo/include/scout/element.h index d0a6fbc830..ad622e168b 100644 --- a/repos/demo/include/scout/element.h +++ b/repos/demo/include/scout/element.h @@ -88,8 +88,8 @@ class Scout::Element */ virtual void geometry(Rect rect) { - _position = rect.p1(); - _size = rect.area(); + _position = rect.at; + _size = rect.area; } /** @@ -184,7 +184,7 @@ class Scout::Element /** * Trigger the refresh of an element on screen */ - void refresh() { redraw_area(0, 0, _size.w(), _size.h()); } + void refresh() { redraw_area(0, 0, _size.w, _size.h); } /** * Handle user input or timer event diff --git a/repos/demo/include/scout/graphics_backend_impl.h b/repos/demo/include/scout/graphics_backend_impl.h index 9e4c690924..506da8ea62 100644 --- a/repos/demo/include/scout/graphics_backend_impl.h +++ b/repos/demo/include/scout/graphics_backend_impl.h @@ -45,7 +45,7 @@ class Scout::Graphics_backend_impl : public Graphics_backend Genode::Dataspace_capability _init_fb_ds(Area max_size) { - Framebuffer::Mode const mode { .area = { max_size.w(), max_size.h()*2 }}; + Framebuffer::Mode const mode { .area = { max_size.w, max_size.h*2 }}; _gui.buffer(mode, false); @@ -71,7 +71,7 @@ class Scout::Graphics_backend_impl : public Graphics_backend Gui::Rect rect(_position, _view_size); _gui.enqueue(_view, rect); - Gui::Point offset(0, _flip_state ? -_max_size.h() : 0); + Gui::Point offset(0, _flip_state ? -_max_size.h : 0); _gui.enqueue(_view, offset); _gui.execute(); @@ -79,7 +79,7 @@ class Scout::Graphics_backend_impl : public Graphics_backend void _refresh_view(Rect rect) { - int const y_offset = _flip_state ? _max_size.h() : 0; + int const y_offset = _flip_state ? _max_size.h : 0; _gui.framebuffer()->refresh(rect.x1(), rect.y1() + y_offset, rect.w(), rect.h()); } @@ -137,13 +137,13 @@ class Scout::Graphics_backend_impl : public Graphics_backend PT const *src = _base( _back_idx()); PT *dst = _base(_front_idx()); - unsigned long const offset = rect.y1()*_max_size.w() + rect.x1(); + unsigned long const offset = rect.y1()*_max_size.w + rect.x1(); src += offset; dst += offset; - blit(src, (unsigned)sizeof(PT)*_max_size.w(), dst, - (int)sizeof(PT)*_max_size.w(), + blit(src, (unsigned)sizeof(PT)*_max_size.w, dst, + (int)sizeof(PT)*_max_size.w, (int)sizeof(PT)*rect.w(), rect.h()); _refresh_view(rect); diff --git a/repos/demo/include/scout/user_state.h b/repos/demo/include/scout/user_state.h index bf4232dccb..d99724f38c 100644 --- a/repos/demo/include/scout/user_state.h +++ b/repos/demo/include/scout/user_state.h @@ -134,7 +134,7 @@ class Scout::User_state : public Parent_element case Event::WHEEL: if (_key_cnt == 0) - _window->ypos(_window->ypos() + 23 * ev.mouse_position.y()); + _window->ypos(_window->ypos() + 23 * ev.mouse_position.y); break; default: diff --git a/repos/demo/include/scout/window.h b/repos/demo/include/scout/window.h index 3e8b2c8f2b..a7743aaa81 100644 --- a/repos/demo/include/scout/window.h +++ b/repos/demo/include/scout/window.h @@ -69,10 +69,10 @@ class Scout::Window : public Parent_element /** * Return current window position */ - int view_x() const { return _next_view_position.x(); } - int view_y() const { return _next_view_position.y(); } - int view_w() const { return _size.w(); } - int view_h() const { return _size.h(); } + int view_x() const { return _next_view_position.x; } + int view_y() const { return _next_view_position.y; } + int view_w() const { return _size.w; } + int view_h() const { return _size.h; } Area max_size() const { return _max_size; } @@ -118,7 +118,7 @@ class Scout::Window : public Parent_element */ if (_scout_quirk && y < 64 + 32) { h = max(h + y, 64 + 32); - w = _size.w(); + w = _size.w; x = 0; y = 0; } @@ -149,8 +149,8 @@ class Scout::Window : public Parent_element /* get actual drawing area (clipped against canvas dimensions) */ int x1 = max(0, _dirty.x1()); int y1 = max(0, _dirty.y1()); - int x2 = min((int)_size.w() - 1, _dirty.x2()); - int y2 = min((int)_size.h() - 1, _dirty.y2()); + int x2 = min((int)_size.w - 1, _dirty.x2()); + int y2 = min((int)_size.h - 1, _dirty.y2()); if (x1 > x2 || y1 > y2) return; @@ -167,8 +167,8 @@ class Scout::Window : public Parent_element */ /* detemine if the whole area must be drawn */ - if (x1 == 0 && x2 == (int)_size.w() - 1 - && y1 == 0 && y2 == (int)_size.h() - 1) { + if (x1 == 0 && x2 == (int)_size.w - 1 + && y1 == 0 && y2 == (int)_size.h - 1) { /* flip back end front buffers */ _gfx_backend.swap_back_and_front(); @@ -223,8 +223,8 @@ class Scout::Drag_event_handler : public Event_handler } /* check if mouse was moved */ - if ((ev.mouse_position.x() == _current_mouse_position.x()) - && (ev.mouse_position.y() == _current_mouse_position.y())) + if ((ev.mouse_position.x == _current_mouse_position.x) + && (ev.mouse_position.y == _current_mouse_position.y)) return; /* remember current mouse position */ @@ -262,8 +262,8 @@ class Scout::Sizer_event_handler : public Drag_event_handler void do_drag() override { /* calculate new window size */ - int nbw = _obw + _current_mouse_position.x() - _old_mouse_position.x(); - int nbh = _obh + _current_mouse_position.y() - _old_mouse_position.y(); + int nbw = _obw + _current_mouse_position.x - _old_mouse_position.x; + int nbh = _obh + _current_mouse_position.y - _old_mouse_position.y; _window->format(Area(nbw, nbh)); } @@ -301,8 +301,8 @@ class Scout::Mover_event_handler : public Drag_event_handler void do_drag() override { - int nbx = _obx + _current_mouse_position.x() - _old_mouse_position.x(); - int nby = _oby + _current_mouse_position.y() - _old_mouse_position.y(); + int nbx = _obx + _current_mouse_position.x - _old_mouse_position.x; + int nby = _oby + _current_mouse_position.y - _old_mouse_position.y; _window->vpos(nbx, nby); } diff --git a/repos/demo/include/scout_gfx/horizontal_shadow_painter.h b/repos/demo/include/scout_gfx/horizontal_shadow_painter.h index 22ccd519ed..81925e2b00 100644 --- a/repos/demo/include/scout_gfx/horizontal_shadow_painter.h +++ b/repos/demo/include/scout_gfx/horizontal_shadow_painter.h @@ -58,11 +58,11 @@ struct Horizontal_shadow_painter if (h > cy2 - y + 1) h = cy2 - y + 1; - addr += surface.size().w()*y + x; + addr += surface.size().w*y + x; PT shadow_color(0,0,0); - for (int j = 0; j < h; j++, addr += surface.size().w()) { + for (int j = 0; j < h; j++, addr += surface.size().w) { PT *d = addr; diff --git a/repos/demo/include/scout_gfx/icon_painter.h b/repos/demo/include/scout_gfx/icon_painter.h index a0481e5c37..318d557f3e 100644 --- a/repos/demo/include/scout_gfx/icon_painter.h +++ b/repos/demo/include/scout_gfx/icon_painter.h @@ -171,8 +171,8 @@ class Icon_painter int const cx2 = surface.clip().x2(); int const cy2 = surface.clip().y2(); - unsigned const icon_w = icon.size().w(), - icon_h = icon.size().h(); + unsigned const icon_w = icon.size().w, + icon_h = icon.size().h; /* determine point positions */ int const x1 = rect.x1(); @@ -203,15 +203,15 @@ class Icon_painter if (_clip(x1, y1, x2 - 1, y2 - 1, cx1, cy1, cx2, cy2, &dx, &dy, &w, &h)) _draw_cslice(src + tx1 + dy*icon_w + dx, src_a + tx1 + dy*icon_w + dx, icon_w, alpha, - addr + (y1 + dy)*surface.size().w() + x1 + dx, surface.size().w(), w, h); + addr + (y1 + dy)*surface.size().w + x1 + dx, surface.size().w, w, h); if (_clip(x2, y1, x3 - 1, y2 - 1, cx1, cy1, cx2, cy2, &dx, &dy, &w, &h)) _draw_hslice(src + tx2 + dy*icon_w + dx, src_a + tx2 + dy*icon_w + dx, icon_w, alpha, - addr + (y1 + dy)*surface.size().w() + x2 + dx, surface.size().w(), w, h); + addr + (y1 + dy)*surface.size().w + x2 + dx, surface.size().w, w, h); if (_clip(x3, y1, x4, y2 - 1, cx1, cy1, cx2, cy2, &dx, &dy, &w, &h)) _draw_cslice(src + tx3 + dy*icon_w + dx, src_a + tx3 + dy*icon_w + dx, icon_w, alpha, - addr + (y1 + dy)*surface.size().w() + x3 + dx, surface.size().w(), w, h); + addr + (y1 + dy)*surface.size().w + x3 + dx, surface.size().w, w, h); /* * mid row @@ -222,15 +222,15 @@ class Icon_painter if (_clip(x1, y2, x2 - 1, y3 - 1, cx1, cy1, cx2, cy2, &dx, &dy, &w, &h)) _draw_vslice(src + tx1 + dx, src_a + tx1 + dx, icon_w, alpha, - addr + (y2 + dy)*surface.size().w() + x1 + dx, surface.size().w(), w, h); + addr + (y2 + dy)*surface.size().w + x1 + dx, surface.size().w, w, h); if (_clip(x2, y2, x3 - 1, y3 - 1, cx1, cy1, cx2, cy2, &dx, &dy, &w, &h)) _draw_center(src + tx2, src_a + tx2, icon_w, alpha, - addr + (y2 + dy)*surface.size().w() + x2 + dx, surface.size().w(), w, h); + addr + (y2 + dy)*surface.size().w + x2 + dx, surface.size().w, w, h); if (_clip(x3, y2, x4, y3 - 1, cx1, cy1, cx2, cy2, &dx, &dy, &w, &h)) _draw_vslice(src + tx3 + dx, src_a + tx3 + dx, icon_w, alpha, - addr + (y2 + dy)*surface.size().w() + x3 + dx, surface.size().w(), w, h); + addr + (y2 + dy)*surface.size().w + x3 + dx, surface.size().w, w, h); /* * low row @@ -241,15 +241,15 @@ class Icon_painter if (_clip(x1, y3, x2 - 1, y4, cx1, cy1, cx2, cy2, &dx, &dy, &w, &h)) _draw_cslice(src + tx1 + dy*icon_w + dx, src_a + tx1 + dy*icon_w + dx, icon_w, alpha, - addr + (y3 + dy)*surface.size().w() + x1 + dx, surface.size().w(), w, h); + addr + (y3 + dy)*surface.size().w + x1 + dx, surface.size().w, w, h); if (_clip(x2, y3, x3 - 1, y4, cx1, cy1, cx2, cy2, &dx, &dy, &w, &h)) _draw_hslice(src + tx2 + dy*icon_w + dx, src_a + tx2 + dy*icon_w + dx, icon_w, alpha, - addr + (y3 + dy)*surface.size().w() + x2 + dx, surface.size().w(), w, h); + addr + (y3 + dy)*surface.size().w + x2 + dx, surface.size().w, w, h); if (_clip(x3, y3, x4, y4, cx1, cy1, cx2, cy2, &dx, &dy, &w, &h)) _draw_cslice(src + tx3 + dy*icon_w + dx, src_a + tx3 + dy*icon_w + dx, icon_w, alpha, - addr + (y3 + dy)*surface.size().w() + x3 + dx, surface.size().w(), w, h); + addr + (y3 + dy)*surface.size().w + x3 + dx, surface.size().w, w, h); } }; diff --git a/repos/demo/include/scout_gfx/refracted_icon_painter.h b/repos/demo/include/scout_gfx/refracted_icon_painter.h index aa25c1d7cb..b95f99ed7c 100644 --- a/repos/demo/include/scout_gfx/refracted_icon_painter.h +++ b/repos/demo/include/scout_gfx/refracted_icon_painter.h @@ -139,31 +139,31 @@ struct Scout::Refracted_icon_painter bool detail, bool filter_backbuf) { - PT *dst = surface.addr() + surface.size().w()*(pos.y()) + pos.x(); + PT *dst = surface.addr() + surface.size().w*(pos.y) + pos.x; Rect const clipped = Rect::intersect(surface.clip(), Rect(pos, foreground.size())); if (detail == false) { - copy(foreground.pixel(), foreground.size().w(), - dst, surface.size().w(), clipped.w(), foreground.size().h()); + copy(foreground.pixel(), foreground.size().w, + dst, surface.size().w, clipped.w(), foreground.size().h); return; } /* backup old canvas pixels */ if (filter_backbuf) - filter_src_to_backbuf(dst, surface.size().w(), tmp.pixel(), - tmp.size().w(), tmp.size().h(), - foreground.size().w()); + filter_src_to_backbuf(dst, surface.size().w, tmp.pixel(), + tmp.size().w, tmp.size().h, + foreground.size().w); else - copy_src_to_backbuf(dst, surface.size().w(), - tmp.pixel(), tmp.size().w(), - tmp.size().h(), foreground.size().w()); + copy_src_to_backbuf(dst, surface.size().w, + tmp.pixel(), tmp.size().w, + tmp.size().h, foreground.size().w); /* draw distorted pixels back to canvas */ distort(tmp.pixel(), - distmap.base(), distmap.size().w(), distmap.size().h(), + distmap.base(), distmap.size().w, distmap.size().h, foreground.pixel(), foreground.alpha(), - dst, surface.size().w(), clipped.w()); + dst, surface.size().w, clipped.w()); } }; diff --git a/repos/demo/include/scout_gfx/sky_texture_painter.h b/repos/demo/include/scout_gfx/sky_texture_painter.h index 712c38b39d..2871d53f8d 100644 --- a/repos/demo/include/scout_gfx/sky_texture_painter.h +++ b/repos/demo/include/scout_gfx/sky_texture_painter.h @@ -246,20 +246,20 @@ struct Sky_texture_painter int v = -py; int y0 = cy1 + v; - int y1 = cy1 + (( (5*v)/16)%texture.size().h()); - int y2 = cy1 + (((11*v)/16)%texture.size().h()); + int y1 = cy1 + (( (5*v)/16)%texture.size().h); + int y2 = cy1 + (((11*v)/16)%texture.size().h); - addr += cy1*surface.size().w(); + addr += cy1*surface.size().w; if (detail == false) { - _copy(addr, surface.size().w(), cy2 - cy1 + 1, cx1, cx2, - texture.fallback(), cy1 - py, texture.size().w(), texture.size().h()); + _copy(addr, surface.size().w, cy2 - cy1 + 1, cx1, cx2, + texture.fallback(), cy1 - py, texture.size().w, texture.size().h); return; } - _compose(addr, surface.size().w(), cy2 - cy1 + 1, cx1, cx2, + _compose(addr, surface.size().w, cy2 - cy1 + 1, cx1, cx2, texture.buf(0), y0, texture.buf(1), y1, texture.buf(2), y2, - texture.size().w(), texture.size().h(), texture.coltab()); + texture.size().w, texture.size().h, texture.coltab()); surface.flush_pixels(surface.clip()); } diff --git a/repos/demo/src/app/launchpad/child_entry.h b/repos/demo/src/app/launchpad/child_entry.h index aab8098abe..f685815803 100644 --- a/repos/demo/src/app/launchpad/child_entry.h +++ b/repos/demo/src/app/launchpad/child_entry.h @@ -114,7 +114,7 @@ class Child_entry : public Scout::Parent_element, append(&_kill_icon); append(&_fold_icon); - _min_size = Scout::Area(_PTW + 100, _min_size.h()); + _min_size = Scout::Area(_PTW + 100, _min_size.h); } using Genode::List >::Element::next; @@ -134,16 +134,16 @@ class Child_entry : public Scout::Parent_element, using namespace Scout; _block.format_fixed_width(_PTW); - int bh = _block.min_size().h(); - int iy = max(0U, (bh - _loadbar.min_size().h())/2); + int bh = _block.min_size().h; + int iy = max(0U, (bh - _loadbar.min_size().h)/2); _fold_icon.geometry(Rect(Point(0, iy), Area(_IW, _IH))); _kill_icon.geometry(Rect(Point(w - _IW - 8, iy), Area(_IW, _IH))); - _block.geometry(Rect(Point(max(10, _PTW - (int)_block.min_size().w()), - max(0, (bh - (int)_block.min_size().h())/2)), + _block.geometry(Rect(Point(max(10, _PTW - (int)_block.min_size().w), + max(0, (bh - (int)_block.min_size().h)/2)), Area(min((int)_PTW, - (int)_block.min_size().w()), bh))); + (int)_block.min_size().w), bh))); int lw = w - 2*_PADX - _PTW - _IW; _loadbar.format_fixed_width(lw); diff --git a/repos/demo/src/app/launchpad/launch_entry.h b/repos/demo/src/app/launchpad/launch_entry.h index db44ffdf75..c4159f3a8e 100644 --- a/repos/demo/src/app/launchpad/launch_entry.h +++ b/repos/demo/src/app/launchpad/launch_entry.h @@ -55,7 +55,7 @@ class Launch_entry : public Scout::Parent_element, public Loadbar_listener append(&_loadbar); append(&_block); - _min_size = Scout::Area(_PTW + 100, _min_size.h()); + _min_size = Scout::Area(_PTW + 100, _min_size.h); } @@ -65,7 +65,7 @@ class Launch_entry : public Scout::Parent_element, public Loadbar_listener void loadbar_changed(int mx) override { - int value = _loadbar.value_by_xpos(mx - _loadbar.abs_position().x()); + int value = _loadbar.value_by_xpos(mx - _loadbar.abs_position().x); _loadbar.value(value); _loadbar.refresh(); _launcher.quota(1024 * (unsigned long)value); @@ -81,13 +81,13 @@ class Launch_entry : public Scout::Parent_element, public Loadbar_listener using namespace Scout; _block.format_fixed_width(_PTW); - _lh = _block.min_size().h(); - _block.geometry(Rect(Point(max(10U, _PTW - _block.min_size().w()), - max(0U, (_lh - _block.min_size().h())/2)), - Area(min((unsigned)_PTW, _block.min_size().w()), _lh))); + _lh = _block.min_size().h; + _block.geometry(Rect(Point(max(10U, _PTW - _block.min_size().w), + max(0U, (_lh - _block.min_size().h)/2)), + Area(min((unsigned)_PTW, _block.min_size().w), _lh))); int lw = max(0, w - 2*_PADX - _PTW - _PADR); - int ly = max(0U, (_lh - _loadbar.min_size().h())/2); + int ly = max(0U, (_lh - _loadbar.min_size().h)/2); _loadbar.format_fixed_width(lw); _loadbar.geometry(Rect(Point(_PADX + _PTW, ly), Area(lw, 16))); diff --git a/repos/demo/src/app/launchpad/launchpad_window.cc b/repos/demo/src/app/launchpad/launchpad_window.cc index 4128994ef7..847d5da331 100644 --- a/repos/demo/src/app/launchpad/launchpad_window.cc +++ b/repos/demo/src/app/launchpad/launchpad_window.cc @@ -82,15 +82,15 @@ Launchpad_window::Launchpad_window(Genode::Env &env, template void Launchpad_window::ypos_sb(int ypos, int update_scrollbar) { - if (ypos < -(int)(_docview.size().h() + _size.h())) - ypos = -_docview.size().h() + _size.h(); + if (ypos < -(int)(_docview.size().h + _size.h)) + ypos = -_docview.size().h + _size.h; _ypos = ypos <= 0 ? ypos : 0; - _docview.geometry(Rect(Point(_docview.position().x(), _ypos), _docview.size())); + _docview.geometry(Rect(Point(_docview.position().x, _ypos), _docview.size())); if (update_scrollbar) - _scrollbar.view(_docview.size().h(), _size.h(), -_ypos); + _scrollbar.view(_docview.size().h, _size.h, -_ypos); refresh(); } @@ -104,52 +104,52 @@ template void Launchpad_window::format(Scout::Area size) { /* limit window size to valid values */ - unsigned w = size.w(); - unsigned h = size.h(); + unsigned w = size.w; + unsigned h = size.h; - w = max(w, min_size().w()); - h = max(h, min_size().h()); - w = min(w, max_size().w()); - h = min(h, max_size().h()); + w = max(w, min_size().w); + h = max(h, min_size().h); + w = min(w, max_size().w); + h = min(h, max_size().h); /* determine old scrollbar visibility */ - int old_sb_visibility = (_docview.min_size().h() > _size.h()); + int old_sb_visibility = (_docview.min_size().h > _size.h); /* assign new size to window */ _size = Scout::Area(w, h); /* format document */ - _docview.format_fixed_width(_size.w()); + _docview.format_fixed_width(_size.w); /* format titlebar */ - _titlebar.format_fixed_width(_size.w()); + _titlebar.format_fixed_width(_size.w); /* determine new scrollbar visibility */ - int new_sb_visibility = (_docview.min_size().h() > _size.h()); + int new_sb_visibility = (_docview.min_size().h > _size.h); /* reformat docview on change of scrollbar visibility */ if (old_sb_visibility ^ new_sb_visibility) { - _docview.right_pad(new_sb_visibility ? _scrollbar.min_size().w() : 0); - _docview.format_fixed_width(_size.w()); + _docview.right_pad(new_sb_visibility ? _scrollbar.min_size().w : 0); + _docview.format_fixed_width(_size.w); } /* position docview */ _docview.geometry(Rect(Point(0, _ypos), - Area(_docview.min_size().w(), - max(_docview.min_size().h(), _size.h())))); + Area(_docview.min_size().w, + max(_docview.min_size().h, _size.h)))); /* start at top */ int y = 0; /* position titlebar */ - _titlebar.geometry(Rect(Point(y, 0), Area(_size.w(), _TH))); + _titlebar.geometry(Rect(Point(y, 0), Area(_size.w, _TH))); y += _TH; - _scrollbar.geometry(Rect(Point(w - _scrollbar.min_size().w() - _SB_XPAD, y + _SB_YPAD), - Area(_scrollbar.min_size().w(), h - y - _SB_YPAD*2 - 8))); + _scrollbar.geometry(Rect(Point(w - _scrollbar.min_size().w - _SB_XPAD, y + _SB_YPAD), + Area(_scrollbar.min_size().w, h - y - _SB_YPAD*2 - 8))); - _sizer.geometry(Rect(Point(_size.w() - 32, _size.h() - 32), Area(32, 32))); + _sizer.geometry(Rect(Point(_size.w - 32, _size.h - 32), Area(32, 32))); Window::format(_size); ypos(_ypos); diff --git a/repos/demo/src/app/launchpad/launchpad_window.h b/repos/demo/src/app/launchpad/launchpad_window.h index e009ab0c90..8ed2c29328 100644 --- a/repos/demo/src/app/launchpad/launchpad_window.h +++ b/repos/demo/src/app/launchpad/launchpad_window.h @@ -111,10 +111,10 @@ class Launchpad_window : public Scout::Scrollbar_listener, /* border */ Color const color = Color::black(); - canvas.draw_box(0, 0, _size.w(), 1, color); - canvas.draw_box(0, _size.h() - 1, _size.w(), 1, color); - canvas.draw_box(0, 1, 1, _size.h() - 2, color); - canvas.draw_box(_size.w() - 1, 1, 1, _size.h() - 2, color); + canvas.draw_box(0, 0, _size.w, 1, color); + canvas.draw_box(0, _size.h - 1, _size.w, 1, color); + canvas.draw_box(0, 1, 1, _size.h - 2, color); + canvas.draw_box(_size.w - 1, 1, 1, _size.h - 2, color); }; /** diff --git a/repos/demo/src/app/launchpad/loadbar.h b/repos/demo/src/app/launchpad/loadbar.h index a2ad96d84c..fd6c4dc934 100644 --- a/repos/demo/src/app/launchpad/loadbar.h +++ b/repos/demo/src/app/launchpad/loadbar.h @@ -64,7 +64,7 @@ class Loadbar_event_handler : public Scout::Event_handler if (ev.type == Event::PRESS || ev.type == Event::MOTION) if (_listener && key_cnt > 0) - _listener->loadbar_changed(ev.mouse_position.x()); + _listener->loadbar_changed(ev.mouse_position.x); } }; @@ -110,7 +110,7 @@ class Loadbar : public Scout::Parent_element int max_w = w - _LW; int bar_w = (_value * max_w) / _max_value; bar_w += _LW; - _bar.geometry(Rect(Point(_bar.position().x(), _bar.position().y()), + _bar.geometry(Rect(Point(_bar.position().x, _bar.position().y), Area(bar_w, _LH))); } @@ -125,7 +125,7 @@ class Loadbar : public Scout::Parent_element { using namespace Scout; - _min_size = Area(_min_size.w(), _LH); + _min_size = Area(_min_size.w, _LH); _cover.rgba(LOADBAR_RGBA); _cover.alpha(100); _cover.focus_alpha(150); @@ -144,7 +144,7 @@ class Loadbar : public Scout::Parent_element int value_by_xpos(int xpos) { xpos -= _LW/2; - int max_w = _size.w() - _LW; + int max_w = _size.w - _LW; return Scout::max(Scout::min((_max_value * xpos) / max_w, _max_value), 0); } @@ -153,7 +153,7 @@ class Loadbar : public Scout::Parent_element void value(int value) { _value = Scout::max(Scout::min(value, _max_value), 0); - _update_bar_geometry(_size.w()); + _update_bar_geometry(_size.w); } int max_value() { return _max_value; } @@ -161,7 +161,7 @@ class Loadbar : public Scout::Parent_element void max_value(int max_value) { _max_value = max_value; - _update_bar_geometry(_size.w()); + _update_bar_geometry(_size.w); } void txt(const char *txt) @@ -169,7 +169,7 @@ class Loadbar : public Scout::Parent_element if (!_font) return; _txt = txt; _txt_w = _font->string_width(_txt, Scout::strlen(_txt)).decimal(); - _txt_h = _font->bounding_box().h(); + _txt_h = _font->bounding_box().h; _txt_len = Scout::strlen(_txt); } @@ -181,7 +181,7 @@ class Loadbar : public Scout::Parent_element using namespace Scout; _cover.geometry(Rect(Point(0, 0), Area(w, _LH))); _update_bar_geometry(w); - _min_size = Scout::Area(w, _min_size.h()); + _min_size = Scout::Area(w, _min_size.h); } void draw(Scout::Canvas_base &canvas, Scout::Point abs_position) override @@ -192,19 +192,19 @@ class Loadbar : public Scout::Parent_element using namespace Scout; - int txt_x = abs_position.x() + _position.x() - + (int)max((_size.w() - (size_t)_txt_w)/2, 8UL); + int txt_x = abs_position.x + _position.x + + (int)max((_size.w - (size_t)_txt_w)/2, 8UL); - int txt_y = abs_position.y() + _position.y() - + (int)max((_size.h() - (size_t)_txt_h)/2, 0UL) - 1; + int txt_y = abs_position.y + _position.y + + (int)max((_size.h - (size_t)_txt_h)/2, 0UL) - 1; /* shrink clipping area to text area (limit too long label) */ int cx1 = canvas.clip().x1(), cy1 = canvas.clip().y1(); int cx2 = canvas.clip().x2(), cy2 = canvas.clip().y2(); - int nx1 = max(cx1, _position.x() + abs_position.x()); - int ny1 = max(cy1, _position.y() + abs_position.y()); - int nx2 = min(cx2, nx1 + (int)_size.w() - 8); - int ny2 = min(cy2, ny1 + (int)_size.h()); + int nx1 = max(cx1, _position.x + abs_position.x); + int ny1 = max(cy1, _position.y + abs_position.y); + int nx2 = min(cx2, nx1 + (int)_size.w - 8); + int ny2 = min(cy2, ny1 + (int)_size.h); canvas.clip(Rect(Point(nx1, ny1), Area(nx2 - nx1 + 1, ny2 - ny1 + 1))); canvas.draw_string(txt_x , txt_y+1, _font, Color(0,0,0,150), _txt, strlen(_txt)); diff --git a/repos/demo/src/app/launchpad/main.cc b/repos/demo/src/app/launchpad/main.cc index 18223e8cbb..80e4e383b9 100644 --- a/repos/demo/src/app/launchpad/main.cc +++ b/repos/demo/src/app/launchpad/main.cc @@ -119,7 +119,7 @@ struct Main : Scout::Event_handler Avail_quota_update _avail_quota_update { _env.pd(), _launchpad }; User_state _user_state { &_launchpad, &_launchpad, - _initial_position.x(), _initial_position.y() }; + _initial_position.x, _initial_position.y }; void _init_launchpad() { diff --git a/repos/demo/src/app/launchpad/section.h b/repos/demo/src/app/launchpad/section.h index 3943fe1836..f08d505c96 100644 --- a/repos/demo/src/app/launchpad/section.h +++ b/repos/demo/src/app/launchpad/section.h @@ -39,7 +39,7 @@ class Section : public Scout::Parent_element char const *_txt; Scout::Font *_font; int _txt_w = _font->string_width(_txt, Scout::strlen(_txt)).decimal(); - int _txt_h = _font->bounding_box().h(); + int _txt_h = _font->bounding_box().h; size_t _txt_len = Scout::strlen(_txt); int _r_add; @@ -63,32 +63,32 @@ class Section : public Scout::Parent_element _min_size = Area(w, _format_children(0, w) + _SH/2); _bg.geometry(Rect(_bg.position(), - Area(_bg.size().w() + _r_add, _bg.size().h()))); + Area(_bg.size().w + _r_add, _bg.size().h))); _shadow.geometry(Rect(_shadow.position(), - Area(_shadow.size().w() + _r_add, - _shadow.size().h()))); + Area(_shadow.size().w + _r_add, + _shadow.size().h))); } void draw(Scout::Canvas_base &canvas, Scout::Point abs_position) override { using namespace Scout; - canvas.draw_box(abs_position.x() + _position.x(), - abs_position.y() + _position.y() + 1, - _size.w() + _r_add, _txt_h - 1, Color(240,240,240,130)); + canvas.draw_box(abs_position.x + _position.x, + abs_position.y + _position.y + 1, + _size.w + _r_add, _txt_h - 1, Color(240,240,240,130)); - int _txt_x = abs_position.x() + _position.x() - + (int)max((_size.w() - (size_t)_txt_w)/2, 8UL); + int _txt_x = abs_position.x + _position.x + + (int)max((_size.w - (size_t)_txt_w)/2, 8UL); - int _txt_y = abs_position.y() + _position.y() + int _txt_y = abs_position.y + _position.y + max((_STH - _SH - (int)_txt_h)/2, 0) - 1; Parent_element::draw(canvas, abs_position); canvas.draw_string(_txt_x , _txt_y, _font, Color(0,0,0,150), _txt, strlen(_txt)); - canvas.draw_box(abs_position.x() + _position.x(), abs_position.y() + _position.y(), - _size.w() + _r_add, 1, Color(0,0,0,64)); + canvas.draw_box(abs_position.x + _position.x, abs_position.y + _position.y, + _size.w + _r_add, 1, Color(0,0,0,64)); } }; diff --git a/repos/demo/src/app/launchpad/status_entry.h b/repos/demo/src/app/launchpad/status_entry.h index ea0d7ff610..348ae023dd 100644 --- a/repos/demo/src/app/launchpad/status_entry.h +++ b/repos/demo/src/app/launchpad/status_entry.h @@ -45,7 +45,7 @@ class Status_entry : public Scout::Parent_element append(&_loadbar); append(&_block); - _min_size = Scout::Area(_PTW + 100, _min_size.h()); + _min_size = Scout::Area(_PTW + 100, _min_size.h); } void format_fixed_width(int w) override @@ -53,13 +53,13 @@ class Status_entry : public Scout::Parent_element using namespace Scout; _block.format_fixed_width(_PTW); - _lh = _block.min_size().h(); - _block.geometry(Rect(Point(max(10U, _PTW - _block.min_size().w()), - max(0U, (_lh - _block.min_size().h())/2)), - Area(min((unsigned)_PTW, _block.min_size().w()), _lh))); + _lh = _block.min_size().h; + _block.geometry(Rect(Point(max(10U, _PTW - _block.min_size().w), + max(0U, (_lh - _block.min_size().h)/2)), + Area(min((unsigned)_PTW, _block.min_size().w), _lh))); int lw = max(0, w - 2*_PADX - _PTW - _PADR); - int ly = max(0U, (_lh - _loadbar.min_size().h())/2); + int ly = max(0U, (_lh - _loadbar.min_size().h)/2); _loadbar.format_fixed_width(lw); _loadbar.geometry(Rect(Point(_PADX + _PTW, ly), Area(lw, 16))); diff --git a/repos/demo/src/app/scout/browser.h b/repos/demo/src/app/scout/browser.h index 6254154c38..1e561fd393 100644 --- a/repos/demo/src/app/scout/browser.h +++ b/repos/demo/src/app/scout/browser.h @@ -129,7 +129,7 @@ class Scout::Browser _content(new_content); ypos(0); - ypos(_ypos - anchor->abs_position().y() + _voffset); + ypos(_ypos - anchor->abs_position().y + _voffset); if (new_content) { new_content->refresh(); diff --git a/repos/demo/src/app/scout/browser_window.cc b/repos/demo/src/app/scout/browser_window.cc index 70eb5c91c4..93e410904a 100644 --- a/repos/demo/src/app/scout/browser_window.cc +++ b/repos/demo/src/app/scout/browser_window.cc @@ -345,16 +345,16 @@ Browser_window::Browser_window(Document *initial_content, template void Browser_window::ypos_sb(int ypos, int update_scrollbar) { - if (ypos < -(int)_docview.size().h() + (int)_size.h()) - ypos = -(int)_docview.size().h() + (int)_size.h(); + if (ypos < -(int)_docview.size().h + (int)_size.h) + ypos = -(int)_docview.size().h + (int)_size.h; _ypos = ypos <= 0 ? ypos : 0; - _docview.geometry(Rect(Point(_docview.position().x(), _ypos), - Area(_docview.size().w(), _docview.size().h()))); + _docview.geometry(Rect(Point(_docview.position().x, _ypos), + Area(_docview.size().w, _docview.size().h))); if (update_scrollbar) - _scrollbar.view(_docview.size().h(), _size.h(), -_ypos); + _scrollbar.view(_docview.size().h, _size.h, -_ypos); refresh(); } @@ -386,47 +386,47 @@ void Browser_window::_content(Element *content) template void Browser_window::format(Area size) { - unsigned w = size.w(); - unsigned h = size.h(); + unsigned w = size.w; + unsigned h = size.h; /* limit browser window size to valid values */ - w = max(w, min_size().w()); - h = max(h, min_size().h()); - w = min(w, max_size().w()); - h = min(h, max_size().h()); + w = max(w, min_size().w); + h = max(h, min_size().h); + w = min(w, max_size().w); + h = min(h, max_size().h); /* determine old scrollbar visibility */ - int old_sb_visibility = (_docview.min_size().h() > _size.h()); + int old_sb_visibility = (_docview.min_size().h > _size.h); /* assign new size to browser window */ _size = Scout::Area(w, h); /* format document */ - _docview.format_fixed_width(_size.w()); + _docview.format_fixed_width(_size.w); /* format titlebar */ - _titlebar.format_fixed_width(_size.w()); + _titlebar.format_fixed_width(_size.w); /* determine new scrollbar visibility */ - int new_sb_visibility = (_docview.min_size().h() > _size.h()); + int new_sb_visibility = (_docview.min_size().h > _size.h); /* reformat docview on change of scrollbar visibility */ if (old_sb_visibility ^ new_sb_visibility) { - _docview.right_pad(new_sb_visibility ? _scrollbar.min_size().w() : 0); - _docview.format_fixed_width(_size.w()); + _docview.right_pad(new_sb_visibility ? _scrollbar.min_size().w : 0); + _docview.format_fixed_width(_size.w); } /* position docview */ _docview.geometry(Rect(Point(0, _ypos), - Area(_docview.min_size().w(), - max(_docview.min_size().h(), _size.h())))); + Area(_docview.min_size().w, + max(_docview.min_size().h, _size.h)))); /* start at top */ int y = 0; /* position titlebar */ if (_attr & ATTR_TITLEBAR) { - _titlebar.geometry(Rect(Point(y, 0), Area(_size.w(), _TH))); + _titlebar.geometry(Rect(Point(y, 0), Area(_size.w, _TH))); y += _TH; } @@ -435,23 +435,23 @@ void Browser_window::format(Area size) _icon[i].geometry(Rect(Point(i*_IW, y), Area(_IW, _IH))); _glow_icon[i].geometry(Rect(Point(i*_IW, y), Area(_IW, _IH))); } - _icon[ICON_ABOUT].geometry(Rect(Point(_size.w() - _IW, y), Area(_IW, _IH))); - _glow_icon[ICON_ABOUT].geometry(Rect(Point(_size.w() - _IW, y), Area(_IW, _IH))); + _icon[ICON_ABOUT].geometry(Rect(Point(_size.w - _IW, y), Area(_IW, _IH))); + _glow_icon[ICON_ABOUT].geometry(Rect(Point(_size.w - _IW, y), Area(_IW, _IH))); /* the panel is the space between the left icon set and the right about icon */ - int panel_x = _icon[ICON_INDEX].position().x() + _IW; + int panel_x = _icon[ICON_INDEX].position().x + _IW; _panel.geometry(Rect(Point(panel_x, y), - Area(_icon[ICON_ABOUT].position().x() - panel_x, _IH))); + Area(_icon[ICON_ABOUT].position().x - panel_x, _IH))); y += _IH; - _scrollbar.geometry(Rect(Point(w - _scrollbar.min_size().w() - _SB_XPAD, y + _SB_YPAD), - Area(_scrollbar.min_size().w(), + _scrollbar.geometry(Rect(Point(w - _scrollbar.min_size().w - _SB_XPAD, y + _SB_YPAD), + Area(_scrollbar.min_size().w, h - y - _SB_YPAD*2 - (_attr & ATTR_SIZER ? 8 : 0)))); - _shadow.geometry(Rect(Point(0, y), Area(_size.w(), 10))); + _shadow.geometry(Rect(Point(0, y), Area(_size.w, 10))); if (_attr & ATTR_SIZER) - _sizer.geometry(Rect(Point(_size.w() - 32, _size.h() - 32), Area(32, 32))); + _sizer.geometry(Rect(Point(_size.w - 32, _size.h - 32), Area(32, 32))); Window::format(_size); } diff --git a/repos/demo/src/app/scout/browser_window.h b/repos/demo/src/app/scout/browser_window.h index 178831f78b..5f4ced5ce8 100644 --- a/repos/demo/src/app/scout/browser_window.h +++ b/repos/demo/src/app/scout/browser_window.h @@ -146,10 +146,10 @@ class Scout::Browser_window : public Scrollbar_listener, if (_attr & ATTR_BORDER) { Color color = Color::black(); - canvas.draw_box(0, 0, _size.w(), 1, color); - canvas.draw_box(0, _size.h() - 1, _size.w(), 1, color); - canvas.draw_box(0, 1, 1, _size.h() - 2, color); - canvas.draw_box(_size.w() - 1, 1, 1, _size.h() - 2, color); + canvas.draw_box(0, 0, _size.w, 1, color); + canvas.draw_box(0, _size.h - 1, _size.w, 1, color); + canvas.draw_box(0, 1, 1, _size.h - 2, color); + canvas.draw_box(_size.w - 1, 1, 1, _size.h - 2, color); } }; diff --git a/repos/demo/src/app/scout/elements.cc b/repos/demo/src/app/scout/elements.cc index b35dc86e52..f688a59830 100644 --- a/repos/demo/src/app/scout/elements.cc +++ b/repos/demo/src/app/scout/elements.cc @@ -32,14 +32,14 @@ Element::~Element() void Element::redraw_area(int x, int y, int w, int h) { - x += _position.x(); - y += _position.y(); + x += _position.x; + y += _position.y; /* intersect specified area with element geometry */ - int x1 = max(x, _position.x()); - int y1 = max(y, _position.y()); - int x2 = min(x + w - 1, _position.x() + (int)_size.w() - 1); - int y2 = min(y + h - 1, _position.y() + (int)_size.h() - 1); + int x1 = max(x, _position.x); + int y1 = max(y, _position.y); + int x2 = min(x + w - 1, _position.x + (int)_size.w - 1); + int y2 = min(y + h - 1, _position.y + (int)_size.h - 1); if (x1 > x2 || y1 > y2) return; @@ -51,8 +51,8 @@ void Element::redraw_area(int x, int y, int w, int h) Element *Element::find(Point position) { - if (position.x() >= _position.x() && position.x() < _position.x() + (int)_size.w() - && position.y() >= _position.y() && position.y() < _position.y() + (int)_size.h() + if (position.x >= _position.x && position.x < _position.x + (int)_size.w + && position.y >= _position.y && position.y < _position.y + (int)_size.h && _flags.findable) return this; @@ -62,7 +62,7 @@ Element *Element::find(Point position) Element *Element::find_by_y(int y) { - return (y >= _position.y() && y < _position.y() + (int)_size.h()) ? this : 0; + return (y >= _position.y && y < _position.y + (int)_size.h) ? this : 0; } @@ -142,7 +142,7 @@ int Parent_element::_format_children(int x, int w) for (Element *e = _first; e; e = e->next) { e->format_fixed_width(w); e->geometry(Rect(Point(x, y), e->min_size())); - y += e->min_size().h(); + y += e->min_size().h; } return y; @@ -159,8 +159,8 @@ void Parent_element::draw(Canvas_base &canvas, Point abs_position) Element *Parent_element::find(Point position) { /* check if position is outside the parent element */ - if (position.x() < _position.x() || position.x() >= _position.x() + (int)_size.w() - || position.y() < _position.y() || position.y() >= _position.y() + (int)_size.h()) + if (position.x < _position.x || position.x >= _position.x + (int)_size.w + || position.y < _position.y || position.y >= _position.y + (int)_size.h) return 0; position = position - _position; @@ -179,10 +179,10 @@ Element *Parent_element::find(Point position) Element *Parent_element::find_by_y(int y) { /* check if position is outside the parent element */ - if (y < _position.y() || y >= _position.y() + (int)_size.h()) + if (y < _position.y || y >= _position.y + (int)_size.h) return 0; - y -= _position.y(); + y -= _position.y; /* check children */ for (Element *e = _first; e; e = e->next) { @@ -200,8 +200,8 @@ void Parent_element::geometry(Rect rect) if (!_last || !_last->bottom()) return; - _last->geometry(Rect(Point(_last->position().x(), - rect.h() - _last->size().h()), _last->size())); + _last->geometry(Rect(Point(_last->position().x, + rect.h() - _last->size().h), _last->size())); } @@ -235,7 +235,7 @@ Token::Token(Style *style, const char *str, size_t len) _min_size = Area(_style->font->string_width(str, len).decimal() + _style->font->string_width(" ").decimal(), - _style->font->bounding_box().h()); + _style->font->bounding_box().h); } @@ -249,12 +249,12 @@ void Token::draw(Canvas_base &canvas, Point abs_position) if (_outline.a) for (int i = -1; i <= 1; i++) for (int j = -1; j <= 1; j++) - canvas.draw_string(_position.x() + abs_position.x() + i, - _position.y() + abs_position.y() + j, + canvas.draw_string(_position.x + abs_position.x + i, + _position.y + abs_position.y + j, _style->font, _outline, _str, _len); - canvas.draw_string(_position.x() + abs_position.x(), - _position.y() + abs_position.y(), + canvas.draw_string(_position.x + abs_position.x, + _position.y + abs_position.y, _style->font, _col, _str, _len); } @@ -306,23 +306,23 @@ void Block::format_fixed_width(int w) for (Element *e = _first; e; e = e->next) { /* wrap at the end of the line */ - if (x + (int)e->min_size().w() >= w) { + if (x + (int)e->min_size().w >= w) { x = _second_indent; y += line_max_h; line_max_h = 0; } /* position element */ - if (max_w < x + e->min_size().w()) - max_w = x + e->min_size().w(); + if (max_w < x + e->min_size().w) + max_w = x + e->min_size().w; e->geometry(Rect(Point(x, y), e->min_size())); /* determine token with the biggest height of the line */ - if (line_max_h < e->min_size().h()) - line_max_h = e->min_size().h(); + if (line_max_h < e->min_size().h) + line_max_h = e->min_size().h; - x += e->min_size().w(); + x += e->min_size().w; } /* @@ -334,23 +334,23 @@ void Block::format_fixed_width(int w) for (Element *line = _first; line; ) { Element *e; - int cy = line->position().y(); /* y position of current line */ + int cy = line->position().y; /* y position of current line */ int max_x; /* rightmost position */ /* determine free space at the end of the line */ - for (max_x = 0, e = line; e && (e->position().y() == cy); e = e->next) - max_x = max(max_x, e->position().x() + (int)e->size().w() - 1); + for (max_x = 0, e = line; e && (e->position().y == cy); e = e->next) + max_x = max(max_x, e->position().x + (int)e->size().w - 1); /* indent elements of the line according to the alignment */ int dx = 0; if (_align == CENTER) dx = (int)max(0UL, (max_w - max_x)/2); if (_align == RIGHT) dx = (int)max(0UL, max_w - max_x); - for (e = line; e && (e->position().y() == cy); e = e->next) - e->geometry(Rect(Point(e->position().x() + dx, e->position().y()), + for (e = line; e && (e->position().y == cy); e = e->next) + e->geometry(Rect(Point(e->position().x + dx, e->position().y), e->size())); /* find first element of next line */ - for (; line && (line->position().y() == cy); line = line->next); + for (; line && (line->position().y == cy); line = line->next); } } @@ -367,21 +367,21 @@ void Block::format_fixed_width(int w) void Center::format_fixed_width(int w) { - _min_size = Area(_min_size.w(), _format_children(0, w)); + _min_size = Area(_min_size.w, _format_children(0, w)); /* determine highest min with of children */ unsigned highest_min_w = 0; for (Element *e = _first; e; e = e->next) - if (highest_min_w < e->min_size().w()) - highest_min_w = e->min_size().w(); + if (highest_min_w < e->min_size().w) + highest_min_w = e->min_size().w; unsigned dx = (w - highest_min_w)>>1; - _min_size = Area(max((unsigned)w, highest_min_w), _min_size.h()); + _min_size = Area(max((unsigned)w, highest_min_w), _min_size.h); /* move children to center */ for (Element *e = _first; e; e = e->next) - e->geometry(Rect(Point(dx, e->position().y()), e->size())); + e->geometry(Rect(Point(dx, e->position().y), e->size())); } @@ -393,16 +393,16 @@ void Verbatim::draw(Canvas_base &canvas, Point abs_position) { static const int pad = 5; - canvas.draw_box(_position.x() + abs_position.x() + pad, - _position.y() + abs_position.x() + pad, - _size.w() - 2*pad, _size.h() - 2*pad, bgcol); + canvas.draw_box(_position.x + abs_position.x + pad, + _position.y + abs_position.x + pad, + _size.w - 2*pad, _size.h - 2*pad, bgcol); int cx1 = canvas.clip().x1(), cy1 = canvas.clip().y1(); int cx2 = canvas.clip().x2(), cy2 = canvas.clip().y2(); - canvas.clip(Rect(Point(_position.x() + abs_position.x() + pad, - _position.y() + abs_position.y() + pad), - Area(_size.w() - 2*pad, _size.h() - 2*pad))); + canvas.clip(Rect(Point(_position.x + abs_position.x + pad, + _position.y + abs_position.y + pad), + Area(_size.w - 2*pad, _size.h - 2*pad))); Parent_element::draw(canvas, abs_position); canvas.clip(Rect(Point(cx1, cy1), Area(cx2 - cx1 + 1, cy2 - cy1 + 1))); @@ -418,7 +418,7 @@ void Verbatim::format_fixed_width(int w) /* position element */ e->geometry(Rect(Point(10, y), e->min_size())); - y += e->min_size().h(); + y += e->min_size().h; } _min_size = Area(w, y + 10); diff --git a/repos/demo/src/app/scout/elements.h b/repos/demo/src/app/scout/elements.h index 4ac827aead..1e17812efe 100644 --- a/repos/demo/src/app/scout/elements.h +++ b/repos/demo/src/app/scout/elements.h @@ -105,7 +105,7 @@ class Scout::Token : public Element * Element interface */ void draw(Canvas_base &, Point) override; - void refresh() { redraw_area(-1, 0, _size.w() + 1, _size.h()); } + void refresh() { redraw_area(-1, 0, _size.w + 1, _size.h); } }; @@ -173,9 +173,9 @@ class Scout::Link_token : public Token, private Link, public Event_handler, Token::draw(canvas, abs_position); - canvas.draw_box(_position.x() + abs_position.x(), - _position.y() + abs_position.y() + _size.h() - 1, - _size.w(), 1, Color::rgb(0,0,255)); + canvas.draw_box(_position.x + abs_position.x, + _position.y + abs_position.y + _size.h - 1, + _size.w, 1, Color::rgb(0,0,255)); } void mfocus(bool flag) override @@ -568,8 +568,8 @@ class Scout::Item : public Parent_element void draw(Canvas_base &canvas, Point abs_position) override { - canvas.draw_string(_position.x() + abs_position.x(), - _position.y() + abs_position.y(), + canvas.draw_string(_position.x + abs_position.x, + _position.y + abs_position.y, _style->font, _style->color, _tag, 255); Parent_element::draw(canvas, abs_position); } diff --git a/repos/demo/src/app/scout/main.cc b/repos/demo/src/app/scout/main.cc index 23f366ea43..41d2451710 100644 --- a/repos/demo/src/app/scout/main.cc +++ b/repos/demo/src/app/scout/main.cc @@ -115,7 +115,7 @@ struct Scout::Main : Scout::Event_handler bool const _mouse_cursor_initialized = (_init_mouse_cursor(), true); User_state _user_state { &_browser, &_browser, - _initial_position.x(), _initial_position.y() }; + _initial_position.x, _initial_position.y }; bool const _browser_ypos_initialized = (_browser.ypos(0), true); @@ -134,14 +134,14 @@ struct Scout::Main : Scout::Event_handler ev.mouse_position = ev.mouse_position - _user_state.view_position(); /* update mouse cursor */ - if (_config.mouse_cursor && (ev.mouse_position.x() != _mouse_position.x() - || ev.mouse_position.y() != _mouse_position.y())) { - int x1 = min(ev.mouse_position.x(), _mouse_position.x()); - int y1 = min(ev.mouse_position.y(), _mouse_position.y()); - int x2 = max(ev.mouse_position.x() + _mcursor.size().w() - 1, - _mouse_position.x() + _mcursor.size().w() - 1); - int y2 = max(ev.mouse_position.y() + _mcursor.size().h() - 1, - _mouse_position.y() + _mcursor.size().h() - 1); + if (_config.mouse_cursor && (ev.mouse_position.x != _mouse_position.x + || ev.mouse_position.y != _mouse_position.y)) { + int x1 = min(ev.mouse_position.x, _mouse_position.x); + int y1 = min(ev.mouse_position.y, _mouse_position.y); + int x2 = max(ev.mouse_position.x + _mcursor.size().w - 1, + _mouse_position.x + _mcursor.size().w - 1); + int y2 = max(ev.mouse_position.y + _mcursor.size().h - 1, + _mouse_position.y + _mcursor.size().h - 1); _mcursor.geometry(Rect(ev.mouse_position, _mcursor.size())); _browser.redraw_area(x1, y1, x2 - x1 + 1, y2 - y1 + 1); diff --git a/repos/demo/src/app/scout/navbar.cc b/repos/demo/src/app/scout/navbar.cc index 842a08dae0..2ceb0a43f4 100644 --- a/repos/demo/src/app/scout/navbar.cc +++ b/repos/demo/src/app/scout/navbar.cc @@ -125,12 +125,12 @@ void Navbar::format_fixed_width(int w) if (_prev_title) _prev_title->format_fixed_width(text_w); /* determine right-alignment offset for right label */ - int next_dx = _next_title ? text_w - _next_title->min_size().w() : 0; + int next_dx = _next_title ? text_w - _next_title->min_size().w : 0; /* determine bounding box of navbar */ unsigned h = ARROW_H; - if (_next_title) h = max(h, _next_title->min_size().h()); - if (_prev_title) h = max(h, _prev_title->min_size().h()); + if (_next_title) h = max(h, _next_title->min_size().h); + if (_prev_title) h = max(h, _prev_title->min_size().h); h += 16; /* assign icons to this navbar instance */ @@ -150,14 +150,14 @@ void Navbar::format_fixed_width(int w) /* place labels */ if (_next_title) { - ypos = (h - _next_title->min_size().h())/2 + 1; + ypos = (h - _next_title->min_size().h)/2 + 1; _next_title->geometry(Rect(Point(w/2 + padx + next_dx, ypos), - Area(text_w, _next_title->min_size().h()))); + Area(text_w, _next_title->min_size().h))); } if (_prev_title) { - ypos = (h - _prev_title->min_size().h())/2 + 1; + ypos = (h - _prev_title->min_size().h)/2 + 1; _prev_title->geometry(Rect(Point(ARROW_W, ypos), - Area(text_w, _prev_title->min_size().h()))); + Area(text_w, _prev_title->min_size().h))); } _min_size = Scout::Area(w, h); @@ -170,10 +170,10 @@ void Navbar::draw(Canvas_base &canvas, Point abs_position) int cx2 = canvas.clip().x2(), cy2 = canvas.clip().y2(); /* shrink clipping area to text area (cut too long words) */ - int nx1 = max(cx1, _position.x() + abs_position.x() + ARROW_W); - int ny1 = max(cy1, _position.y() + abs_position.y()); - int nx2 = min(cx2, nx1 + (int)_size.w() - 2*ARROW_W); - int ny2 = min(cy2, ny1 + (int)_size.h()); + int nx1 = max(cx1, _position.x + abs_position.x + ARROW_W); + int ny1 = max(cy1, _position.y + abs_position.y); + int nx2 = min(cx2, nx1 + (int)_size.w - 2*ARROW_W); + int ny2 = min(cy2, ny1 + (int)_size.h); canvas.clip(Rect(Point(nx1, ny1), Area(nx2 - nx1 + 1, ny2 - ny1 + 1))); Parent_element::draw(canvas, abs_position); diff --git a/repos/demo/src/app/scout/png_image.cc b/repos/demo/src/app/scout/png_image.cc index 2504987870..b61cd818aa 100644 --- a/repos/demo/src/app/scout/png_image.cc +++ b/repos/demo/src/app/scout/png_image.cc @@ -134,9 +134,9 @@ void Png_image::fill_cache(Canvas_base &canvas) memset(row_ptr, 0, curr_row_size); /* fill texture */ - for (unsigned j = 0; j < _min_size.h(); j++) { + for (unsigned j = 0; j < _min_size.h; j++) { png_read_row(png_ptr, row_ptr, NULL); - canvas.set_rgba_texture(_texture, (unsigned char *)row_ptr, _min_size.w(), j); + canvas.set_rgba_texture(_texture, (unsigned char *)row_ptr, _min_size.w, j); } } diff --git a/repos/demo/src/app/scout/scrollbar.cc b/repos/demo/src/app/scout/scrollbar.cc index 3e17d68a09..78a80032b9 100644 --- a/repos/demo/src/app/scout/scrollbar.cc +++ b/repos/demo/src/app/scout/scrollbar.cc @@ -188,7 +188,7 @@ class Slider_event_handler : public Event_handler _icon->rgba(_rgba, 1, 3); _icon->refresh(); - orig_my = curr_my = ev.mouse_position.y(); + orig_my = curr_my = ev.mouse_position.y; orig_slider_pos = _sb->slider_pos(); } @@ -199,8 +199,8 @@ class Slider_event_handler : public Event_handler _icon->refresh(); } - if (key_cnt && (ev.mouse_position.y() != curr_my)) { - curr_my = ev.mouse_position.y(); + if (key_cnt && (ev.mouse_position.y != curr_my)) { + curr_my = ev.mouse_position.y; _sb->slider_pos(orig_slider_pos + curr_my - orig_my); _sb->notify_listener(); } @@ -240,7 +240,7 @@ Scrollbar::Scrollbar() template int Scrollbar::slider_size() { - return max((unsigned)sb_elem_h, ((_size.h() - sb_elem_h*2)*_view_size)/_real_size); + return max((unsigned)sb_elem_h, ((_size.h - sb_elem_h*2)*_view_size)/_real_size); } @@ -248,7 +248,7 @@ template int Scrollbar::slider_pos() { int real_range = _real_size - _view_size; - int slider_range = _size.h() - sb_elem_h*2 - slider_size(); + int slider_range = _size.h - sb_elem_h*2 - slider_size(); int pos = real_range ? (slider_range*_view_pos)/real_range : 0; return pos + sb_elem_h; @@ -258,7 +258,7 @@ int Scrollbar::slider_pos() template void Scrollbar::slider_pos(int pos) { - int slider_bg_h = _size.h() - sb_elem_h*2; + int slider_bg_h = _size.h - sb_elem_h*2; _view_pos = ((pos - sb_elem_h)*_real_size)/slider_bg_h; _view_pos = max(0, min(_view_pos, _real_size - _view_size)); diff --git a/repos/demo/src/app/scout/sky_texture.h b/repos/demo/src/app/scout/sky_texture.h index 1ce179ce5c..2ee3efa45a 100644 --- a/repos/demo/src/app/scout/sky_texture.h +++ b/repos/demo/src/app/scout/sky_texture.h @@ -42,7 +42,7 @@ class Scout::Sky_texture : public Element void draw(Canvas_base &canvas, Point abs_position) override { - canvas.draw_sky_texture(abs_position.y(), _sky_texture, + canvas.draw_sky_texture(abs_position.y, _sky_texture, _detailed); } }; diff --git a/repos/demo/src/app/scout/titlebar.h b/repos/demo/src/app/scout/titlebar.h index 61090627cb..3a4a0f70c5 100644 --- a/repos/demo/src/app/scout/titlebar.h +++ b/repos/demo/src/app/scout/titlebar.h @@ -49,7 +49,7 @@ class Scout::Titlebar : public Parent_element { _txt = txt ? txt : "Scout"; _txt_w = title_font.string_width(_txt, strlen(_txt)).decimal(); - _txt_h = title_font.bounding_box().h(); + _txt_h = title_font.bounding_box().h; _txt_len = strlen(_txt); } @@ -83,15 +83,15 @@ class Scout::Titlebar : public Parent_element void draw(Canvas_base &canvas, Point abs_position) override { const int b = 180, a = 200; - canvas.draw_box(abs_position.x() + _position.x(), - abs_position.y() + _position.y(), - _size.w(), _size.h(), Color(b, b, b, a)); + canvas.draw_box(abs_position.x + _position.x, + abs_position.y + _position.y, + _size.w, _size.h, Color(b, b, b, a)); - int _txt_x = abs_position.x() + _position.x() - + (int)max((_size.w() - _txt_w)/2, 8U); + int _txt_x = abs_position.x + _position.x + + (int)max((_size.w - _txt_w)/2, 8U); - int _txt_y = abs_position.y() + _position.y() - + (int)max((_size.h() - _txt_h)/2, 0U) - 1; + int _txt_y = abs_position.y + _position.y + + (int)max((_size.h - _txt_h)/2, 0U) - 1; canvas.draw_string(_txt_x , _txt_y, &title_font, Color(0,0,0,200), _txt, strlen(_txt)); Parent_element::draw(canvas, abs_position); diff --git a/repos/demo/src/app/scout/widgets.cc b/repos/demo/src/app/scout/widgets.cc index 672940fa5e..a3bfaccea6 100644 --- a/repos/demo/src/app/scout/widgets.cc +++ b/repos/demo/src/app/scout/widgets.cc @@ -28,7 +28,7 @@ void Docview::format_fixed_width(int w) if (_cont) { _cont->format_fixed_width(w - 2*_padx - _right_pad); - _min_size = Area(w, _voffset + _cont->min_size().h()); + _min_size = Area(w, _voffset + _cont->min_size().h); } if (_bg) @@ -57,7 +57,7 @@ void Docview::geometry(Rect rect) if (_cont) _cont->geometry(Rect(Point(_padx, _voffset), - Area(_cont->min_size().w(), rect.h() - _voffset))); + Area(_cont->min_size().w, rect.h() - _voffset))); } @@ -182,18 +182,18 @@ Element *Icon::find(Point position) position = position - _position; /* check icon boundaries (the height is flexible) */ - if ((position.x() < 0) || (position.x() >= W) - || (position.y() < 0) || (position.y() >= (int)_size.h())) return 0; + if ((position.x < 0) || (position.x >= W) + || (position.y < 0) || (position.y >= (int)_size.h)) return 0; /* upper part of the icon */ - if (position.y() <= H/2) return _alpha[position.y()][position.x()] ? this : 0; + if (position.y <= H/2) return _alpha[position.y][position.x] ? this : 0; /* lower part of the icon */ - if (position.y() > (int)_size.h() - H/2) - return _alpha[position.y() - _size.h() + H][position.x()] ? this : 0; + if (position.y > (int)_size.h - H/2) + return _alpha[position.y - _size.h + H][position.x] ? this : 0; /* middle part of the icon */ - if (_alpha[H/2][position.x()]) return this; + if (_alpha[H/2][position.x]) return this; return 0; } diff --git a/repos/demo/src/app/scout/widgets.h b/repos/demo/src/app/scout/widgets.h index 710471bb6e..99de78d565 100644 --- a/repos/demo/src/app/scout/widgets.h +++ b/repos/demo/src/app/scout/widgets.h @@ -98,7 +98,7 @@ struct Scout::Horizontal_shadow : Element */ void draw(Canvas_base &, Point) override; Element *find(Point) override { return 0; } - void format_fixed_width(int w) override { _min_size = Area(w, _min_size.h()); } + void format_fixed_width(int w) override { _min_size = Area(w, _min_size.h); } }; diff --git a/repos/demo/src/server/liquid_framebuffer/framebuffer_window.h b/repos/demo/src/server/liquid_framebuffer/framebuffer_window.h index e38a1c5d14..e3f388a12d 100644 --- a/repos/demo/src/server/liquid_framebuffer/framebuffer_window.h +++ b/repos/demo/src/server/liquid_framebuffer/framebuffer_window.h @@ -71,8 +71,8 @@ class Framebuffer_window : public Scout::Window bool config_decoration) : Scout::Window(gfx_backend, position, - Scout::Area(content->min_size().w() + 2, - content->min_size().h() + 1 + _TH), + Scout::Area(content->min_size().w + 2, + content->min_size().h + 1 + _TH), max_size, false), _content(content), _config_alpha(config_alpha), _config_resize_handle(config_resize_handle), @@ -167,14 +167,14 @@ class Framebuffer_window : public Scout::Window { using namespace Scout; - unsigned w = size.w(); - unsigned h = size.h(); + unsigned w = size.w; + unsigned h = size.h; /* limit window size to valid values */ - w = max(w, min_size().w()); - h = max(h, min_size().h()); - w = min(w, max_size().w()); - h = min(h, max_size().h()); + w = max(w, min_size().w); + h = max(h, min_size().h); + w = min(w, max_size().w); + h = min(h, max_size().h); _size = Scout::Area(w, h); @@ -183,9 +183,9 @@ class Framebuffer_window : public Scout::Window if (_config_decoration) { _titlebar.format_fixed_width(w); _titlebar.geometry(Rect(Point(1, y), - Area(_titlebar.min_size().w(), - _titlebar.min_size().h()))); - y += _titlebar.min_size().h(); + Area(_titlebar.min_size().w, + _titlebar.min_size().h))); + y += _titlebar.min_size().h; } int const content_h = ((int)h > y + 1) ? (h - y - 1) : 0; @@ -196,12 +196,12 @@ class Framebuffer_window : public Scout::Window _content->geometry(Rect(Point(content_x, y), Area(content_w, content_h))); - _sizer.geometry(Rect(Point(_size.w() - 32, _size.h() - 32), Area(32, 32))); + _sizer.geometry(Rect(Point(_size.w - 32, _size.h - 32), Area(32, 32))); if (_config_decoration) Window::format(_size); else - Window::format(Area(_size.w() - 2, _size.h() - 1 - _TH)); + Window::format(Area(_size.w - 2, _size.h - 1 - _TH)); refresh(); } @@ -225,12 +225,12 @@ class Framebuffer_window : public Scout::Window /* border */ Color const color = Color::black(); - canvas.draw_box(0, 0, _size.w(), 1, color); + canvas.draw_box(0, 0, _size.w, 1, color); if (_config_decoration) - canvas.draw_box(0, _TH, _size.w(), 1, color); - canvas.draw_box(0, _size.h() - 1, _size.w(), 1, color); - canvas.draw_box(0, 1, 1, _size.h() - 2, color); - canvas.draw_box(_size.w() - 1, 1, 1, _size.h() - 2, color); + canvas.draw_box(0, _TH, _size.w, 1, color); + canvas.draw_box(0, _size.h - 1, _size.w, 1, color); + canvas.draw_box(0, 1, 1, _size.h - 2, color); + canvas.draw_box(_size.w - 1, 1, 1, _size.h - 2, color); }; }; diff --git a/repos/demo/src/server/liquid_framebuffer/main.cc b/repos/demo/src/server/liquid_framebuffer/main.cc index edcb53765d..113dbce873 100644 --- a/repos/demo/src/server/liquid_framebuffer/main.cc +++ b/repos/demo/src/server/liquid_framebuffer/main.cc @@ -186,7 +186,7 @@ class Liquid_fb::Main : public Scout::Event_handler bool _background_animator_initialized = (_init_background_animator(), true); User_state _user_state { &_fb_win, &_fb_win, - _initial_position.x(), _initial_position.y() }; + _initial_position.x, _initial_position.y }; void _init_fb_win() { diff --git a/repos/demo/src/server/liquid_framebuffer/services.cc b/repos/demo/src/server/liquid_framebuffer/services.cc index ac3797939f..71dca7a021 100644 --- a/repos/demo/src/server/liquid_framebuffer/services.cc +++ b/repos/demo/src/server/liquid_framebuffer/services.cc @@ -61,7 +61,7 @@ class Window_content : public Scout::Element Point mouse_position = ev.mouse_position - _element->abs_position(); - auto motion = [&] (Point p) { return Input::Absolute_motion{p.x(), p.y()}; }; + auto motion = [&] (Point p) { return Input::Absolute_motion{p.x, p.y}; }; if (ev.type == Event::MOTION) _input_session.submit(motion(mouse_position)); @@ -193,10 +193,10 @@ class Window_content : public Scout::Element void realloc_framebuffer() { /* skip reallocation if size has not changed */ - if (_next_size.w() == _fb->w && _next_size.h() == _fb->h) + if (_next_size.w == _fb->w && _next_size.h == _fb->h) return; - _fb.construct(_ram, _rm, _alloc, _next_size.w(), _next_size.h(), _config_alpha); + _fb.construct(_ram, _rm, _alloc, _next_size.w, _next_size.h, _config_alpha); } /** diff --git a/repos/demo/src/server/nitlog/main.cc b/repos/demo/src/server/nitlog/main.cc index c6b213e736..23ddbb2665 100644 --- a/repos/demo/src/server/nitlog/main.cc +++ b/repos/demo/src/server/nitlog/main.cc @@ -88,7 +88,7 @@ class Canvas : public Canvas_base void draw_string(Point p, Font const &font, Color color, char const *sstr) override { - Text_painter::paint(_surface, Text_painter::Position(p.x(), p.y()), + Text_painter::paint(_surface, Text_painter::Position(p.x, p.y), font, color, sstr); } @@ -157,7 +157,7 @@ class Log_entry /* calculate label dimensions */ int label_w = font.string_width(_label).decimal(); - int label_h = font.bounding_box().h(); + int label_h = font.bounding_box().h; if (new_section) { canvas.draw_box(Rect(Point(1, y), Area(label_w + 2, label_h - 1)), label_bgcol); @@ -244,7 +244,7 @@ class Log_window _dirty = false; } - int line_h = _font.bounding_box().h(); + int line_h = _font.bounding_box().h; int curr_session_id = -1; for (int i = 0, y = 0; i < LOG_H; i++, y += line_h) { @@ -365,8 +365,8 @@ class Log_view Log_view(Gui::Session_client &gui, Gui::Rect geometry) : _gui(gui), - _pos(geometry.p1()), - _size(geometry.area()), + _pos(geometry.at), + _size(geometry.area), _handle(gui.create_view()) { move(_pos); @@ -401,8 +401,8 @@ struct Nitlog::Main Tff_font _font { _binary_mono_tff_start, _glyph_buffer }; /* calculate size of log view in pixels */ - unsigned const _win_w = _font.bounding_box().w() * LOG_W + 2; - unsigned const _win_h = _font.bounding_box().h() * LOG_H + 2; + unsigned const _win_w = _font.bounding_box().w * LOG_W + 2; + unsigned const _win_h = _font.bounding_box().h * LOG_H + 2; /* init sessions to the required external services */ Gui::Connection _gui { _env }; diff --git a/repos/gems/include/gems/animated_geometry.h b/repos/gems/include/gems/animated_geometry.h index 8d9af66c57..57940e42b1 100644 --- a/repos/gems/include/gems/animated_geometry.h +++ b/repos/gems/include/gems/animated_geometry.h @@ -51,12 +51,12 @@ class Genode::Animated_rect : private Animator::Item, Noncopyable void move_to(Point p, Steps steps) { if (_initial) { - _x = Lazy_value(p.x() << 10); - _y = Lazy_value(p.y() << 10); + _x = Lazy_value(p.x << 10); + _y = Lazy_value(p.y << 10); _initial = false; } else { - _x.dst(p.x() << 10, steps.value); - _y.dst(p.y() << 10, steps.value); + _x.dst(p.x << 10, steps.value); + _y.dst(p.y << 10, steps.value); } } @@ -79,7 +79,7 @@ class Genode::Animated_rect : private Animator::Item, Noncopyable { _p1.animate(); _p2.animate(); - _rect = Rect(Point(_p1.x(), _p1.y()), Point(_p2.x(), _p2.y())); + _rect = Rect::compound(Point(_p1.x(), _p1.y()), Point(_p2.x(), _p2.y())); if (_remaining.value > 1) _remaining.value--; @@ -113,7 +113,7 @@ class Genode::Animated_rect : private Animator::Item, Noncopyable bool initialized() const { return _p1._initial == false; } Rect rect() const { return _rect; } - Area area() const { return _rect.area(); } + Area area() const { return _rect.area; } Point p1() const { return _rect.p1(); } Point p2() const { return _rect.p2(); } }; diff --git a/repos/gems/include/gems/gui_buffer.h b/repos/gems/include/gems/gui_buffer.h index 2b8c2f6e3d..9d775b765a 100644 --- a/repos/gems/include/gems/gui_buffer.h +++ b/repos/gems/include/gems/gui_buffer.h @@ -94,8 +94,8 @@ struct Gui_buffer : Genode::Noncopyable Genode::Color reset_color = default_reset_color()) : ram(ram), rm(rm), gui(gui), - mode({ .area = { Genode::max(1U, size.w()), - Genode::max(1U, size.h()) } }), + mode({ .area = { Genode::max(1U, size.w), + Genode::max(1U, size.h) } }), use_alpha(alpha == Alpha::ALPHA), reset_color(reset_color.r, reset_color.g, reset_color.b, reset_color.a) { diff --git a/repos/gems/include/gems/png_image.h b/repos/gems/include/gems/png_image.h index 9f93fc0997..b0f628e750 100644 --- a/repos/gems/include/gems/png_image.h +++ b/repos/gems/include/gems/png_image.h @@ -200,9 +200,9 @@ class Png_image Chunky_texture(_ram, _rm, size()); /* fill texture with PNG image data */ - for (unsigned i = 0; i < size().h(); i++) { + for (unsigned i = 0; i < size().h; i++) { png_read_row(_read_struct.png_ptr, _row.row_ptr, NULL); - texture->rgba((unsigned char *)_row.row_ptr, size().w()*4, i); + texture->rgba((unsigned char *)_row.row_ptr, size().w*4, i); } return texture; diff --git a/repos/gems/include/gems/texture_utils.h b/repos/gems/include/gems/texture_utils.h index 39f566a769..d5db70e775 100644 --- a/repos/gems/include/gems/texture_utils.h +++ b/repos/gems/include/gems/texture_utils.h @@ -24,21 +24,21 @@ static void scale(Genode::Texture const &src, Genode::Texture &dst, if (dst.size().count() == 0) return; - Genode::size_t const row_num_bytes = dst.size().w()*4; + Genode::size_t const row_num_bytes = dst.size().w*4; unsigned char *row = (unsigned char *)alloc.alloc(row_num_bytes); - unsigned const mx = (src.size().w() << 16) / dst.size().w(); - unsigned const my = (src.size().h() << 16) / dst.size().h(); + unsigned const mx = (src.size().w << 16) / dst.size().w; + unsigned const my = (src.size().h << 16) / dst.size().h; - for (unsigned y = 0, src_y = 0; y < dst.size().h(); y++, src_y += my) { + for (unsigned y = 0, src_y = 0; y < dst.size().h; y++, src_y += my) { - unsigned const src_line_offset = src.size().w()*(src_y >> 16); + unsigned const src_line_offset = src.size().w*(src_y >> 16); PT const *pixel_line = src.pixel() + src_line_offset; unsigned char const *alpha_line = src.alpha() + src_line_offset; unsigned char *d = row; - for (unsigned x = 0, src_x = 0; x < dst.size().w(); x++, src_x += mx) { + for (unsigned x = 0, src_x = 0; x < dst.size().w; x++, src_x += mx) { unsigned const pixel_offset = src_x >> 16; @@ -51,7 +51,7 @@ static void scale(Genode::Texture const &src, Genode::Texture &dst, *d++ = (unsigned char)alpha; } - dst.rgba(row, dst.size().w(), y); + dst.rgba(row, dst.size().w, y); } alloc.free(row, row_num_bytes); @@ -68,11 +68,11 @@ static void convert_pixel_format(Genode::Texture const &src, if (src.size() != dst.size()) return; - Genode::size_t const row_num_bytes = dst.size().w()*4; + Genode::size_t const row_num_bytes = dst.size().w*4; unsigned char *row = (unsigned char *)alloc.alloc(row_num_bytes); /* shortcuts */ - unsigned const w = dst.size().w(), h = dst.size().h(); + unsigned const w = dst.size().w, h = dst.size().h; for (unsigned y = 0, line_offset = 0; y < h; y++, line_offset += w) { diff --git a/repos/gems/include/nano3d/scene.h b/repos/gems/include/nano3d/scene.h index 8aef5ea297..92e2dd0c41 100644 --- a/repos/gems/include/nano3d/scene.h +++ b/repos/gems/include/nano3d/scene.h @@ -87,8 +87,8 @@ class Nano3d::Scene * front buffer, and the back buffer. */ bool const use_alpha = true; - unsigned const height = size.h()*NUM_BUFFERS; - gui.buffer(Framebuffer::Mode { .area = { size.w(), height } }, + unsigned const height = size.h*NUM_BUFFERS; + gui.buffer(Framebuffer::Mode { .area = { size.w, height } }, use_alpha); return *gui.framebuffer(); @@ -103,7 +103,7 @@ class Nano3d::Scene */ Gui::Area size() const { - return Gui::Area(mode.area.w(), mode.area.h()/NUM_BUFFERS); + return Gui::Area(mode.area.w, mode.area.h/NUM_BUFFERS); } Genode::Attached_dataspace ds { rm, framebuffer.dataspace() }; @@ -254,7 +254,7 @@ class Nano3d::Scene _swap_visible_and_front_surfaces(); _swap_back_and_front_surfaces(); - int const h = _framebuffer.size().h(); + int const h = _framebuffer.size().h; int const buf_y = (_surface_visible == &_surface_0) ? 0 : (_surface_visible == &_surface_1) ? -h diff --git a/repos/gems/include/polygon_gfx/clipping.h b/repos/gems/include/polygon_gfx/clipping.h index 31e5e427b1..0a035503f8 100644 --- a/repos/gems/include/polygon_gfx/clipping.h +++ b/repos/gems/include/polygon_gfx/clipping.h @@ -52,12 +52,12 @@ struct Polygon::Point_base : Genode::Point<> /** * Return edge attribute by ID */ - inline int edge_attr(int) const { return x(); } + inline int edge_attr(int) const { return x; } /** * Assign value to edge attribute with specified ID */ - inline void edge_attr(int, int value) { *this = Point_base(value, y()); } + inline void edge_attr(int, int value) { *this = Point_base(value, y); } }; @@ -90,7 +90,7 @@ struct Polygon::Clipper_vertical /** * Select clipping-sensitive attribute from polygon point */ - static int clip_value(POINT p) { return p.x(); } + static int clip_value(POINT p) { return p.x; } /** * Calculate intersection point @@ -106,11 +106,11 @@ struct Polygon::Clipper_vertical if (clip_value(p1) > clip_value(p2)) { POINT tmp = p1; p1 = p2; p2 = tmp; } /* calculate ratio of the intersection of edge and clipping boundary */ - int ratio = intersect_ratio(p1.x(), p2.x(), clip); + int ratio = intersect_ratio(p1.x, p2.x, clip); /* calculate y value at intersection point */ POINT result; - *(Point_base *)&result = Point_base(clip, p1.y() + ((ratio*(p2.y() - p1.y()))>>16)); + *(Point_base *)&result = Point_base(clip, p1.y + ((ratio*(p2.y - p1.y))>>16)); /* calculate intersection values for edge attributes other than x */ for (int i = 1; i < POINT::NUM_EDGE_ATTRIBUTES; i++) { @@ -132,7 +132,7 @@ struct Polygon::Clipper_horizontal /** * Select clipping-sensitive attribute from polygon point */ - static int clip_value(POINT p) { return p.y(); } + static int clip_value(POINT p) { return p.y; } /** * Calculate intersection point @@ -146,7 +146,7 @@ struct Polygon::Clipper_horizontal /* calculate y value at intersection point */ POINT result; - *(Point_base *)&result = Point_base(p1.x() + ((ratio*(p2.x() - p1.x()))>>16), clip); + *(Point_base *)&result = Point_base(p1.x + ((ratio*(p2.x - p1.x))>>16), clip); /* calculate intersection values for edge attributes other than x */ for (int i = 1; i < POINT::NUM_EDGE_ATTRIBUTES; i++) { diff --git a/repos/gems/include/polygon_gfx/line_painter.h b/repos/gems/include/polygon_gfx/line_painter.h index 9f2e9f1982..dddec0e936 100644 --- a/repos/gems/include/polygon_gfx/line_painter.h +++ b/repos/gems/include/polygon_gfx/line_painter.h @@ -126,7 +126,8 @@ struct Line_painter * Reduce clipping area by one pixel as the antialiased line touches an * area of 2x2 for each pixel. */ - Rect const clip(surface.clip().p1(), surface.clip().p2() + Point(-1, -1)); + Rect const clip = Rect::compound(surface.clip().p1(), + surface.clip().p2() + Point(-1, -1)); if (!clip.valid()) return; @@ -158,7 +159,7 @@ struct Line_painter int const alpha = color.a; PT * const dst = surface.addr(); - unsigned const dst_w = surface.size().w(); + unsigned const dst_w = surface.size().w; long x = x1.value << 8, y = y1.value << 8; @@ -178,11 +179,11 @@ struct Line_painter Genode::Color color) const { paint(surface, - Fixpoint::from_int(p1.x()), Fixpoint::from_int(p1.y()), - Fixpoint::from_int(p2.x()), Fixpoint::from_int(p2.y()), + Fixpoint::from_int(p1.x), Fixpoint::from_int(p1.y), + Fixpoint::from_int(p2.x), Fixpoint::from_int(p2.y), color); - surface.flush_pixels(Rect(p1, p2)); + surface.flush_pixels(Rect::compound(p1, p2)); } }; diff --git a/repos/gems/include/polygon_gfx/polygon_painter_base.h b/repos/gems/include/polygon_gfx/polygon_painter_base.h index 0fd00c0856..ac771d6191 100644 --- a/repos/gems/include/polygon_gfx/polygon_painter_base.h +++ b/repos/gems/include/polygon_gfx/polygon_painter_base.h @@ -209,17 +209,17 @@ class Polygon::Painter_base template static Rect bounding_box(POINT const points[], int num_points, Area area) { - int x_min = area.w() - 1, x_max = 0; - int y_min = area.h() - 1, y_max = 0; + int x_min = area.w - 1, x_max = 0; + int y_min = area.h - 1, y_max = 0; for (int i = 0; i < num_points; i++) { - x_min = Genode::min(x_min, points[i].x()); - x_max = Genode::max(x_max, points[i].x()); - y_min = Genode::min(y_min, points[i].y()); - y_max = Genode::max(y_max, points[i].y()); + x_min = Genode::min(x_min, points[i].x); + x_max = Genode::max(x_max, points[i].x); + y_min = Genode::min(y_min, points[i].y); + y_max = Genode::max(y_max, points[i].y); } - return Rect(Point_base(x_min, y_min), Point_base(x_max, y_max)); + return Rect::compound(Point_base(x_min, y_min), Point_base(x_max, y_max)); } @@ -248,15 +248,15 @@ class Polygon::Painter_base int const p2_attr = p2.edge_attr(i); /* horizontal edge */ - if (p1.y() == p2.y()); + if (p1.y == p2.y); /* right edge */ - else if (p1.y() < p2.y()) - _interpolate(p1_attr, p2_attr, r_edge + p1.y(), p2.y() - p1.y()); + else if (p1.y < p2.y) + _interpolate(p1_attr, p2_attr, r_edge + p1.y, p2.y - p1.y); /* left edge */ else - _interpolate(p2_attr, p1_attr, l_edge + p2.y(), p1.y() - p2.y()); + _interpolate(p2_attr, p1_attr, l_edge + p2.y, p1.y - p2.y); } } } diff --git a/repos/gems/include/polygon_gfx/shaded_polygon_painter.h b/repos/gems/include/polygon_gfx/shaded_polygon_painter.h index 0234c6db8b..ba91f3c074 100644 --- a/repos/gems/include/polygon_gfx/shaded_polygon_painter.h +++ b/repos/gems/include/polygon_gfx/shaded_polygon_painter.h @@ -116,7 +116,7 @@ class Polygon::Shaded_painter : public Polygon::Painter_base int * const a_r_edge = _edges.right(ATTR_A); /* calculate begin of first destination scanline */ - unsigned const dst_w = pixel_surface.size().w(); + unsigned const dst_w = pixel_surface.size().w; PT *dst_pixel = pixel_surface.addr() + dst_w*bbox.y1(); AT *dst_alpha = alpha_surface.addr() + dst_w*bbox.y1(); diff --git a/repos/gems/include/polygon_gfx/textured_polygon_painter.h b/repos/gems/include/polygon_gfx/textured_polygon_painter.h index 60b4d8c4be..b8d2aba679 100644 --- a/repos/gems/include/polygon_gfx/textured_polygon_painter.h +++ b/repos/gems/include/polygon_gfx/textured_polygon_painter.h @@ -109,12 +109,12 @@ class Polygon::Textured_painter : public Polygon::Painter_base int * const v_l_edge = _edges.left (ATTR_V); int * const v_r_edge = _edges.right(ATTR_V); - unsigned const src_w = texture.size().w(); + unsigned const src_w = texture.size().w; PT const *src_pixel = texture.pixel(); unsigned char const *src_alpha = texture.alpha(); /* calculate begin of destination scanline */ - unsigned const dst_w = pixel_surface.size().w(); + unsigned const dst_w = pixel_surface.size().w; PT *dst_pixel = pixel_surface.addr() + dst_w*bbox.y1(); AT *dst_alpha = alpha_surface.addr() + dst_w*bbox.y1(); diff --git a/repos/gems/include/polygon_gfx/texturize_rgba.h b/repos/gems/include/polygon_gfx/texturize_rgba.h index e1e9a7a671..61e8b71fac 100644 --- a/repos/gems/include/polygon_gfx/texturize_rgba.h +++ b/repos/gems/include/polygon_gfx/texturize_rgba.h @@ -43,12 +43,12 @@ static inline void Polygon::texturize_rgba(Genode::Point<> start, Genode::Point< if (num_values <= 0) return; /* use 16.16 fixpoint values for the calculation */ - int tx_ascent = ((end.x() - start.x())<<16)/(int)num_values, - ty_ascent = ((end.y() - start.y())<<16)/(int)num_values; + int tx_ascent = ((end.x - start.x)<<16)/(int)num_values, + ty_ascent = ((end.y - start.y)<<16)/(int)num_values; /* set start values for color components */ - int tx = start.x()<<16, - ty = start.y()<<16; + int tx = start.x<<16, + ty = start.y<<16; for ( ; num_values--; dst++, dst_alpha++) { diff --git a/repos/gems/src/app/backdrop/main.cc b/repos/gems/src/app/backdrop/main.cc index 5e533e7575..2ad069192f 100644 --- a/repos/gems/src/app/backdrop/main.cc +++ b/repos/gems/src/app/backdrop/main.cc @@ -178,19 +178,19 @@ static Surface_base::Area calc_scaled_size(Xml_node operation, */ unsigned const ratio = operation.attribute(attr).has_value("fit") ? - min((mode_size.w() << 16) / image_size.w(), - (mode_size.h() << 16) / image_size.h()) : + min((mode_size.w << 16) / image_size.w, + (mode_size.h << 16) / image_size.h) : operation.attribute(attr).has_value("zoom") ? - max((mode_size.w() << 16) / image_size.w(), - (mode_size.h() << 16) / image_size.h()) : + max((mode_size.w << 16) / image_size.w, + (mode_size.h << 16) / image_size.h) : 1 << 16; /* * We add 0.5 (1 << 15) to round instead of truncating the fractional * part when converting the fixpoint numbers to integers. */ - return Surface_base::Area((image_size.w()*ratio + (1 << 15)) >> 16, - (image_size.h()*ratio + (1 << 15)) >> 16); + return Surface_base::Area((image_size.w*ratio + (1 << 15)) >> 16, + (image_size.h*ratio + (1 << 15)) >> 16); } @@ -205,12 +205,12 @@ void Backdrop::Main::_paint_texture(Surface &surface, Texture const &tex if (tiled) { /* shortcuts */ - int const w = texture.size().w(), surface_w = surface.size().w(); - int const h = texture.size().h(), surface_h = surface.size().h(); + int const w = texture.size().w, surface_w = surface.size().w; + int const h = texture.size().h, surface_h = surface.size().h; /* draw tiles across the whole surface */ - for (int y = (pos.y() % h) - h; y < surface_h + h; y += h) - for (int x = (pos.x() % w) - w; x < surface_w + w; x += w) + for (int y = (pos.y % h) - h; y < surface_h + h; y += h) + for (int x = (pos.x % w) - w; x < surface_w + w; x += w) Texture_painter::paint(surface, texture, Color(), Texture_painter::Point(x, y), Texture_painter::SOLID, @@ -248,8 +248,8 @@ void Backdrop::Main::_apply_image(Xml_node operation) /* * Determine parameters of graphics operation */ - int const h_gap = (int)_buffer->mode.area.w() - scaled_size.w(), - v_gap = (int)_buffer->mode.area.h() - scaled_size.h(); + int const h_gap = (int)_buffer->mode.area.w - scaled_size.w, + v_gap = (int)_buffer->mode.area.h - scaled_size.h; int const anchored_xpos = anchor.horizontal == Anchor::LOW ? 0 : anchor.horizontal == Anchor::CENTER ? h_gap/2 @@ -318,8 +318,8 @@ void Backdrop::Main::_handle_config() Framebuffer::Mode const phys_mode = _gui.mode(); Framebuffer::Mode const - mode { .area = { _config.xml().attribute_value("width", phys_mode.area.w()), - _config.xml().attribute_value("height", phys_mode.area.h()) } }; + mode { .area = { _config.xml().attribute_value("width", phys_mode.area.w), + _config.xml().attribute_value("height", phys_mode.area.h) } }; _buffer.construct(_env, _gui, mode); diff --git a/repos/gems/src/app/cpu_load_display/main.cc b/repos/gems/src/app/cpu_load_display/main.cc index a9ca2fe7e5..da86a55dd4 100644 --- a/repos/gems/src/app/cpu_load_display/main.cc +++ b/repos/gems/src/app/cpu_load_display/main.cc @@ -333,7 +333,7 @@ class Cpu_load_display::Scene : public Nano3d::Scene private: - Polygon::Shaded_painter _shaded_painter { _heap, _size.h() }; + Polygon::Shaded_painter _shaded_painter { _heap, _size.h }; long _activity_sum[Timeline::HISTORY_LEN]; long _y_level[Timeline::HISTORY_LEN]; @@ -433,8 +433,8 @@ class Cpu_load_display::Scene : public Nano3d::Scene Color const top_color = Color(10, 10, 10, 20); Color const bottom_color = Color(10, 10, 10, 100); - unsigned const w = pixel.size().w(); - unsigned const h = pixel.size().h(); + unsigned const w = pixel.size().w; + unsigned const h = pixel.size().h; typedef Polygon::Shaded_painter::Point Point; Point points[4]; @@ -453,8 +453,8 @@ class Cpu_load_display::Scene : public Nano3d::Scene /* plot graphs for the CPUs below each other */ enum { GAP = 8 }; - Gui::Point const step(0, _size.h()/num_cpus); - Gui::Area const size(_size.w(), step.y() - GAP); + Gui::Point const step(0, _size.h/num_cpus); + Gui::Area const size(_size.w, step.y - GAP); Gui::Point point(0, GAP/2); _cpu_registry.for_each_cpu([&] (Cpu const &cpu) { diff --git a/repos/gems/src/app/decorator/canvas.h b/repos/gems/src/app/decorator/canvas.h index f0d2bd93a9..a2a81c6f95 100644 --- a/repos/gems/src/app/decorator/canvas.h +++ b/repos/gems/src/app/decorator/canvas.h @@ -83,7 +83,7 @@ class Decorator::Canvas : public Decorator::Canvas_base void draw_text(Point pos, Font const &font, Color color, char const *string) override { - Text_painter::paint(_surface, Text_painter::Position(pos.x(), pos.y()), + Text_painter::paint(_surface, Text_painter::Position(pos.x, pos.y), font, color, string); } diff --git a/repos/gems/src/app/decorator/window.cc b/repos/gems/src/app/decorator/window.cc index 23c1e10069..c133b8b7d3 100644 --- a/repos/gems/src/app/decorator/window.cc +++ b/repos/gems/src/app/decorator/window.cc @@ -33,35 +33,35 @@ void Decorator::Window::draw(Decorator::Canvas_base &canvas, _draw_corner(canvas, Rect(p1, corner), _border_size, true, true, _window_elem_attr(Element::TOP_LEFT)); - _draw_corner(canvas, Rect(Point(p1.x(), p2.y() - _corner_size + 1), corner), + _draw_corner(canvas, Rect(Point(p1.x, p2.y - _corner_size + 1), corner), _border_size, true, false, _window_elem_attr(Element::BOTTOM_LEFT)); - _draw_corner(canvas, Rect(Point(p2.x() - _corner_size + 1, p1.y()), corner), + _draw_corner(canvas, Rect(Point(p2.x - _corner_size + 1, p1.y), corner), _border_size, false, true, _window_elem_attr(Element::TOP_RIGHT)); - _draw_corner(canvas, Rect(Point(p2.x() - _corner_size + 1, p2.y() - _corner_size + 1), corner), + _draw_corner(canvas, Rect(Point(p2.x - _corner_size + 1, p2.y - _corner_size + 1), corner), _border_size, false, false, _window_elem_attr(Element::BOTTOM_RIGHT)); - _draw_raised_box(canvas, Rect(Point(p1.x() + _corner_size, p1.y()), + _draw_raised_box(canvas, Rect(Point(p1.x + _corner_size, p1.y), Area(rect.w() - 2*_corner_size, _border_size)), _window_elem_attr(Element::TOP)); - _draw_raised_box(canvas, Rect(Point(p1.x() + _corner_size, p2.y() - _border_size + 1), + _draw_raised_box(canvas, Rect(Point(p1.x + _corner_size, p2.y - _border_size + 1), Area(rect.w() - 2*_corner_size, _border_size)), _window_elem_attr(Element::BOTTOM)); - _draw_raised_box(canvas, Rect(Point(p1.x(), p1.y() + _corner_size), + _draw_raised_box(canvas, Rect(Point(p1.x, p1.y + _corner_size), Area(_border_size, rect.h() - 2*_corner_size)), _window_elem_attr(Element::LEFT)); - _draw_raised_box(canvas, Rect(Point(p2.x() - _border_size + 1, p1.y() + _corner_size), + _draw_raised_box(canvas, Rect(Point(p2.x - _border_size + 1, p1.y + _corner_size), Area(_border_size, rect.h() - 2*_corner_size)), _window_elem_attr(Element::RIGHT)); - Rect controls_rect(Point(p1.x() + _border_size, p1.y() + _border_size), + Rect controls_rect(Point(p1.x + _border_size, p1.y + _border_size), Area(rect.w() - 2*_border_size, _title_height)); @@ -84,14 +84,14 @@ void Decorator::Window::draw(Decorator::Canvas_base &canvas, } _draw_window_control(canvas, Rect(left_pos, _icon_size), control); - left_pos = left_pos + Point(_icon_size.w(), 0); + left_pos = left_pos + Point(_icon_size.w, 0); } /* * Draw right controls from right to left */ - Point right_pos = controls_rect.p1() + Point(controls_rect.w() - _icon_size.w(), 0); + Point right_pos = controls_rect.p1() + Point(controls_rect.w() - _icon_size.w, 0); if (_controls.num() > 0) { for (int i = _controls.num() - 1; i >= 0; i--) { @@ -103,11 +103,11 @@ void Decorator::Window::draw(Decorator::Canvas_base &canvas, break; /* detect overlap with left controls */ - if (right_pos.x() <= left_pos.x()) + if (right_pos.x <= left_pos.x) break; _draw_window_control(canvas, Rect(right_pos, _icon_size), control); - right_pos = right_pos + Point(-_icon_size.w(), 0); + right_pos = right_pos + Point(-_icon_size.w, 0); } } @@ -115,7 +115,7 @@ void Decorator::Window::draw(Decorator::Canvas_base &canvas, * Draw title between left and right controls */ - Rect title_rect(left_pos, Area(right_pos.x() - left_pos.x() + _icon_size.w(), + Rect title_rect(left_pos, Area(right_pos.x - left_pos.x + _icon_size.w, _title_height)); _draw_title_box(canvas, title_rect, _window_elem_attr(Element::TITLE)); @@ -123,7 +123,7 @@ void Decorator::Window::draw(Decorator::Canvas_base &canvas, char const * const text = _title.string(); Area const label_area(default_font().string_width(text).decimal(), - default_font().bounding_box().h()); + default_font().bounding_box().h); /* * Position the text in the center of the window. @@ -135,7 +135,7 @@ void Decorator::Window::draw(Decorator::Canvas_base &canvas, /* * Horizontal position of the title text */ - int x = window_centered_text_pos.x(); + int x = window_centered_text_pos.x; /* * If the title bar is narrower than three times the label but the text @@ -143,9 +143,9 @@ void Decorator::Window::draw(Decorator::Canvas_base &canvas, * towards the center of the title bar. If the text fits twice in the * title bar, it is centered within the title bar. */ - if (label_area.w() <= title_rect.w() && label_area.w()*3 > title_rect.w()) { + if (label_area.w <= title_rect.w() && label_area.w*3 > title_rect.w()) { - int ratio = ((label_area.w()*3 - title_rect.w()) << 8) / title_rect.w(); + int ratio = ((label_area.w*3 - title_rect.w()) << 8) / title_rect.w(); if (ratio > 255) ratio = 255; @@ -153,8 +153,8 @@ void Decorator::Window::draw(Decorator::Canvas_base &canvas, Point const titlebar_centered_text_pos = title_rect.center(label_area) - Point(0, 1); - x = (titlebar_centered_text_pos.x()*ratio + - window_centered_text_pos.x()*(255 - ratio)) >> 8; + x = (titlebar_centered_text_pos.x*ratio + + window_centered_text_pos.x*(255 - ratio)) >> 8; } /* minimum distance between the title text and the title border */ @@ -167,22 +167,22 @@ void Decorator::Window::draw(Decorator::Canvas_base &canvas, x = title_rect.x1() + min_horizontal_padding; if (title_align == Control::ALIGN_RIGHT) - x = title_rect.x2() - label_area.w() - min_horizontal_padding; + x = title_rect.x2() - label_area.w - min_horizontal_padding; /* * If the text does not fit into the title bar, align it to the left * border of the title bar to show the first part. */ - if (label_area.w() + 2*min_horizontal_padding > title_rect.w()) + if (label_area.w + 2*min_horizontal_padding > title_rect.w()) x = title_rect.x1() + min_horizontal_padding; { - Rect const title_content_rect(title_rect.p1() + Point(1, 1), - title_rect.p2() - Point(1, 1)); + Rect const title_content_rect = Rect::compound(title_rect.p1() + Point(1, 1), + title_rect.p2() - Point(1, 1)); Clip_guard clip_guard(canvas, title_content_rect); - Point const text_pos(x, window_centered_text_pos.y()); + Point const text_pos(x, window_centered_text_pos.y); canvas.draw_text(text_pos + Point(1, 1), default_font(), Color(0, 0, 0, 128), text); @@ -302,22 +302,22 @@ Decorator::Window_base::Hover Decorator::Window::hover(Point abs_pos) const hover.window_id = id(); - unsigned const x = abs_pos.x() - outer_geometry().x1(), - y = abs_pos.y() - outer_geometry().y1(); + unsigned const x = abs_pos.x - outer_geometry().x1(), + y = abs_pos.y - outer_geometry().y1(); - Area const area = outer_geometry().area(); + Area const area = outer_geometry().area; bool const at_border = x < _border_size - || x >= area.w() - _border_size + || x >= area.w - _border_size || y < _border_size - || y >= area.h() - _border_size; + || y >= area.h - _border_size; if (at_border) { hover.left_sizer = (x < _corner_size); hover.top_sizer = (y < _corner_size); - hover.right_sizer = (x >= area.w() - _corner_size); - hover.bottom_sizer = (y >= area.h() - _corner_size); + hover.right_sizer = (x >= area.w - _corner_size); + hover.bottom_sizer = (y >= area.h - _corner_size); } else { @@ -348,7 +348,7 @@ Decorator::Window_base::Hover Decorator::Window::hover(Point abs_pos) const if (Rect(pos, _icon_size).contains(Point(x + _border_size, y))) hovered_control = _controls.control(i); - pos = pos + Point(_icon_size.w(), 0); + pos = pos + Point(_icon_size.w, 0); } } @@ -356,7 +356,7 @@ Decorator::Window_base::Hover Decorator::Window::hover(Point abs_pos) const if (_controls.num() > 0) { Point pos = titlbar_pos + - Point(area.w() - _border_size - _icon_size.w(), 0); + Point(area.w - _border_size - _icon_size.w, 0); for (int i = _controls.num() - 1; i >= 0; i--) { @@ -367,7 +367,7 @@ Decorator::Window_base::Hover Decorator::Window::hover(Point abs_pos) const if (Rect(pos, _icon_size).contains(Point(x + _border_size, y))) hovered_control = _controls.control(i); - pos = pos + Point(-_icon_size.w(), 0); + pos = pos + Point(-_icon_size.w, 0); } } diff --git a/repos/gems/src/app/decorator/window.h b/repos/gems/src/app/decorator/window.h index 23e077ec70..c6abbe8e33 100644 --- a/repos/gems/src/app/decorator/window.h +++ b/repos/gems/src/app/decorator/window.h @@ -77,7 +77,7 @@ class Decorator::Window : public Window_base void place(Rect rect) { _gui.enqueue(_handle, rect); - Point offset = Point(0, 0) - rect.p1(); + Point offset = Point(0, 0) - rect.at; _gui.enqueue(_handle, offset); } }; @@ -231,34 +231,34 @@ class Decorator::Window : public Window_base bool at_left, bool at_right, unsigned border, Color color) const { - int const x1 = at_left ? (pos.x()) : (pos.x() + w - border); - int const x2 = at_right ? (pos.x() + w - 1) : (pos.x() + border - 1); + int const x1 = at_left ? (pos.x) : (pos.x + w - border); + int const x2 = at_right ? (pos.x + w - 1) : (pos.x + border - 1); - canvas.draw_box(Rect(Point(x1, pos.y()), - Point(x2, pos.y())), color); + canvas.draw_box(Rect::compound(Point(x1, pos.y), + Point(x2, pos.y)), color); } void _draw_vline(Canvas_base &canvas, Point pos, unsigned h, bool at_top, bool at_bottom, unsigned border, Color color) const { - int const y1 = at_top ? (pos.y()) : (pos.y() + h - border); - int const y2 = at_bottom ? (pos.y() + h - 1) : (pos.y() + border - 1); + int const y1 = at_top ? (pos.y) : (pos.y + h - border); + int const y2 = at_bottom ? (pos.y + h - 1) : (pos.y + border - 1); - canvas.draw_box(Rect(Point(pos.x(), y1), - Point(pos.x(), y2)), color); + canvas.draw_box(Rect::compound(Point(pos.x, y1), + Point(pos.x, y2)), color); } void _draw_raised_frame(Canvas_base &canvas, Rect rect, bool pressed) const { Color const top_left_color = pressed ? _dimmed : _bright; - _draw_hline(canvas, rect.p1(), rect.w(), true, true, 0, top_left_color); - _draw_vline(canvas, rect.p1(), rect.h(), true, true, 0, top_left_color); + _draw_hline(canvas, rect.at, rect.w(), true, true, 0, top_left_color); + _draw_vline(canvas, rect.at, rect.h(), true, true, 0, top_left_color); - _draw_hline(canvas, Point(rect.p1().x(), rect.p2().y()), rect.w(), + _draw_hline(canvas, Point(rect.x1(), rect.y2()), rect.w(), true, true, 0, _dark); - _draw_vline(canvas, Point(rect.p2().x(), rect.p1().y()), rect.h(), + _draw_vline(canvas, Point(rect.x2(), rect.y1()), rect.h(), true, true, 0, _dark); } @@ -308,7 +308,7 @@ class Decorator::Window : public Window_base Color const mix_color = upper_half ? upper_color : lower_color; Color const line_color = _mix_colors(mix_color, attr.color, alpha); - canvas.draw_box(Rect(rect.p1() + Point(0, i), + canvas.draw_box(Rect(rect.at + Point(0, i), Area(rect.w(), 1)), line_color); } @@ -322,10 +322,10 @@ class Decorator::Window : public Window_base bool const bottom = !top; bool const right = !left; - int const x1 = rect.p1().x(); - int const y1 = rect.p1().y(); - int const x2 = rect.p2().x(); - int const y2 = rect.p2().y(); + int const x1 = rect.x1(); + int const y1 = rect.y1(); + int const x2 = rect.x2(); + int const y2 = rect.y2(); int const w = rect.w(); int const h = rect.h(); @@ -339,7 +339,7 @@ class Decorator::Window : public Window_base Area(border, h - border)), attr.color); /* top bright line */ - _draw_hline(canvas, rect.p1(), w, + _draw_hline(canvas, rect.at, w, top || left, top || right, border, top_left_color); /* inner horizontal line */ @@ -352,7 +352,7 @@ class Decorator::Window : public Window_base bottom || left, bottom || right, border, _dark); /* left bright line */ - _draw_vline(canvas, rect.p1(), h, + _draw_vline(canvas, rect.at, h, left || top, left || bottom, border, top_left_color); /* inner vertical line */ @@ -405,7 +405,7 @@ class Decorator::Window : public Window_base { _draw_title_box(canvas, rect, _window_control_attr(control)); - canvas.draw_texture(rect.p1() + Point(1,1), + canvas.draw_texture(rect.at + Point(1,1), _window_control_texture(control)); } @@ -461,13 +461,8 @@ class Decorator::Window : public Window_base Rect outer_geometry() const override { - return Rect(geometry().p1() - Point(_border.left, _border.top), - geometry().p2() + Point(_border.right, _border.bottom)); - } - - void border_rects(Rect *top, Rect *left, Rect *right, Rect *bottom) const - { - outer_geometry().cut(geometry(), top, left, right, bottom); + return Rect::compound(geometry().p1() - Point(_border.left, _border.top), + geometry().p2() + Point(_border.right, _border.bottom)); } void update_gui_views() override @@ -475,14 +470,13 @@ class Decorator::Window : public Window_base if (!_gui_views_up_to_date) { /* update view positions */ - Rect top, left, right, bottom; - border_rects(&top, &left, &right, &bottom); + auto const border = outer_geometry().cut(geometry()); _content_view.place(geometry()); - _top_view .place(top); - _left_view .place(left); - _right_view .place(right); - _bottom_view .place(bottom); + _top_view .place(border.top); + _left_view .place(border.left); + _right_view .place(border.right); + _bottom_view .place(border.bottom); _gui_views_up_to_date = true; } diff --git a/repos/gems/src/app/menu_view/box_layout_widget.h b/repos/gems/src/app/menu_view/box_layout_widget.h index 0d2ac3afb7..c523f054ac 100644 --- a/repos/gems/src/app/menu_view/box_layout_widget.h +++ b/repos/gems/src/app/menu_view/box_layout_widget.h @@ -44,8 +44,8 @@ struct Menu_view::Box_layout_widget : Widget unsigned largest_size = 0; _children.for_each([&] (Widget const &w) { largest_size = - max(largest_size, _direction == VERTICAL ? w.min_size().w() - : w.min_size().h()); }); + max(largest_size, _direction == VERTICAL ? w.min_size().w + : w.min_size().h); }); /* position children on one row/column */ Point position(0, 0); @@ -57,16 +57,16 @@ struct Menu_view::Box_layout_widget : Widget w.position(position); /* don't account space for zero-sized child widgets */ - if ((child_min_size.w() == 0) && (child_min_size.h() == 0)) + if ((child_min_size.w == 0) && (child_min_size.h == 0)) return; if (_direction == VERTICAL) { unsigned const next_top_margin = w.next() ? w.next()->margin.top : 0; - unsigned const dy = child_min_size.h() - min(w.margin.bottom, next_top_margin); + unsigned const dy = child_min_size.h - min(w.margin.bottom, next_top_margin); position = position + Point(0, dy); } else { unsigned const next_left_margin = w.next() ? w.next()->margin.left : 0; - unsigned const dx = child_min_size.w() - min(w.margin.right, next_left_margin); + unsigned const dx = child_min_size.w - min(w.margin.right, next_left_margin); position = position + Point(dx, 0); } @@ -74,8 +74,8 @@ struct Menu_view::Box_layout_widget : Widget }); _min_size = (_direction == VERTICAL) - ? Area(largest_size, position.y()) - : Area(position.x(), largest_size); + ? Area(largest_size, position.y) + : Area(position.x, largest_size); } /** @@ -85,8 +85,8 @@ struct Menu_view::Box_layout_widget : Widget { using Genode::max; unsigned const unused_pixels = - _vertical() ? max(_geometry.h(), _min_size.h()) - _min_size.h() - : max(_geometry.w(), _min_size.w()) - _min_size.w(); + _vertical() ? max(_geometry.h(), _min_size.h) - _min_size.h + : max(_geometry.w(), _min_size.w) - _min_size.w; /* number of excess pixels at the end of the stack (fixpoint) */ unsigned const step_fp = (_count > 0) ? (unused_pixels << 8) / _count : 0; @@ -99,10 +99,10 @@ struct Menu_view::Box_layout_widget : Widget - (consumed_fp >> 8); if (_direction == VERTICAL) { w.position(w.geometry().p1() + Point(0, consumed_fp >> 8)); - w.size(Area(geometry().w(), w.min_size().h() + padding_pixels)); + w.size(Area(geometry().w(), w.min_size().h + padding_pixels)); } else { w.position(w.geometry().p1() + Point(consumed_fp >> 8, 0)); - w.size(Area(w.min_size().w() + padding_pixels, geometry().h())); + w.size(Area(w.min_size().w + padding_pixels, geometry().h())); } /* don't account space for zero-sized child widgets */ diff --git a/repos/gems/src/app/menu_view/button_widget.h b/repos/gems/src/app/menu_view/button_widget.h index 7771cc493b..4d8f4bf6e8 100644 --- a/repos/gems/src/app/menu_view/button_widget.h +++ b/repos/gems/src/app/menu_view/button_widget.h @@ -116,8 +116,8 @@ struct Menu_view::Button_widget : Widget, Animator::Item /* don't get smaller than the background texture */ Area const texture_size = _curr_texture->size(); - return Area(max(_space().w() + child_min_size.w(), texture_size.w()), - max(_space().h() + child_min_size.h(), texture_size.h())); + return Area(max(_space().w + child_min_size.w, texture_size.w), + max(_space().h + child_min_size.h, texture_size.h)); } void draw(Surface &pixel_surface, @@ -182,14 +182,14 @@ struct Menu_view::Button_widget : Widget, Animator::Item child.position(Point(margin.left + _padding.left, margin.top + _padding.top)); - Area const avail = geometry().area(); + Area const avail = geometry().area; unsigned const - w = avail.w() >= _space().w() ? avail.w() - _space().w() : 0, - h = avail.h() >= _space().h() ? avail.h() - _space().w() : 0; + w = avail.w >= _space().w ? avail.w - _space().w : 0, + h = avail.h >= _space().h ? avail.h - _space().w : 0; - child.size(Area(max(w, child.min_size().w()), - max(h, child.min_size().h()))); + child.size(Area(max(w, child.min_size().w), + max(h, child.min_size().h))); }); } diff --git a/repos/gems/src/app/menu_view/cursor.h b/repos/gems/src/app/menu_view/cursor.h index 052d3b2d21..fef59be82c 100644 --- a/repos/gems/src/app/menu_view/cursor.h +++ b/repos/gems/src/app/menu_view/cursor.h @@ -56,7 +56,7 @@ class Menu_view::Cursor : List_model::Element /* cursor position in pixels, only p1.x is used */ Animated_rect _position; - int _xpos() const { return _position.p1().x(); } + int _xpos() const { return _position.p1().x; } static Name _node_name(Xml_node node) { @@ -70,7 +70,7 @@ class Menu_view::Cursor : List_model::Element void _move_to(int position, Steps steps) { - _position.move_to(Rect(Point(position, 0), Point()), steps); + _position.move_to(Rect::compound(Point(position, 0), Point()), steps); } /* @@ -101,8 +101,8 @@ class Menu_view::Cursor : List_model::Element Rect(at + Point(_xpos(), 0), Area(1, height)), Color(0, 0, 0, 255)); } else { - unsigned const w = _texture->size().w(); - Rect const rect(Point(_xpos() + at.x() - w/2 + 1, at.y()), + unsigned const w = _texture->size().w; + Rect const rect(Point(_xpos() + at.x - w/2 + 1, at.y), Area(w, height)); Icon_painter::paint(pixel_surface, rect, *_texture, 255); diff --git a/repos/gems/src/app/menu_view/depgraph_widget.h b/repos/gems/src/app/menu_view/depgraph_widget.h index ee45ecc377..af2402a7fd 100644 --- a/repos/gems/src/app/menu_view/depgraph_widget.h +++ b/repos/gems/src/app/menu_view/depgraph_widget.h @@ -91,7 +91,7 @@ struct Menu_view::Depgraph_widget : Widget void apply_layout_to_widget() { _widget.position(_widget_geometry.p1()); - _widget.size(_widget_geometry.area()); + _widget.size(_widget_geometry.area); } struct Dependency : Animator::Item @@ -240,7 +240,7 @@ struct Menu_view::Depgraph_widget : Widget unsigned depth_size(Depth_direction dir) const { - return dir.horizontal() ? _widget.min_size().w() : _widget.min_size().h(); + return dir.horizontal() ? _widget.min_size().w : _widget.min_size().h; } /** @@ -263,7 +263,7 @@ struct Menu_view::Depgraph_widget : Widget unsigned breadth_size(Depth_direction dir) const { unsigned const widget_size = - dir.horizontal() ? _widget.min_size().h() : _widget.min_size().w(); + dir.horizontal() ? _widget.min_size().h : _widget.min_size().w; unsigned const breadth_padding = 10; @@ -616,7 +616,7 @@ struct Menu_view::Depgraph_widget : Widget }); } - Area min_size() const override { return _bounding_box.area(); } + Area min_size() const override { return _bounding_box.area; } void _draw_connect(Surface &pixel_surface, Surface &alpha_surface, @@ -635,17 +635,17 @@ struct Menu_view::Depgraph_widget : Widget line_painter.paint(alpha_surface, fx1, fy1, fx2, fy2, color); }; - long const mid_x = (p1.x() + p2.x()) / 2, - mid_y = (p1.y() + p2.y()) / 2; + long const mid_x = (p1.x + p2.x) / 2, + mid_y = (p1.y + p2.y) / 2; - long const x1 = p1.x(), - y1 = p1.y(), - x2 = horizontal ? mid_x : p1.x(), - y2 = horizontal ? p1.y() : mid_y, - x3 = horizontal ? mid_x : p2.x(), - y3 = horizontal ? p2.y() : mid_y, - x4 = p2.x(), - y4 = p2.y(); + long const x1 = p1.x, + y1 = p1.y, + x2 = horizontal ? mid_x : p1.x, + y2 = horizontal ? p1.y : mid_y, + x3 = horizontal ? mid_x : p2.x, + y3 = horizontal ? p2.y : mid_y, + x4 = p2.x, + y4 = p2.y; auto abs = [] (auto v) { return v >= 0 ? v : -v; }; @@ -736,7 +736,7 @@ struct Menu_view::Depgraph_widget : Widget * Prompt each child to update its layout */ _children.for_each([&] (Widget &w) { - w.size(w.geometry().area()); }); + w.size(w.geometry().area); }); } }; diff --git a/repos/gems/src/app/menu_view/dialog.h b/repos/gems/src/app/menu_view/dialog.h index e13c04ec9c..93cf5ccb52 100644 --- a/repos/gems/src/app/menu_view/dialog.h +++ b/repos/gems/src/app/menu_view/dialog.h @@ -97,14 +97,14 @@ struct Menu_view::Dialog : List_model::Element Area _root_widget_size() const { Area const min_size = _root_widget.min_size(); - return Area(max(_configured_size.w(), min_size.w()), - max(_configured_size.h(), min_size.h())); + return Area(max(_configured_size.w, min_size.w), + max(_configured_size.h, min_size.h)); } void _update_view(Rect geometry) { - if (_view_geometry.p1() == geometry.p1() - && _view_geometry.area() == geometry.area()) + if (_view_geometry.p1() == geometry.p1() + && _view_geometry.area == geometry.area) return; using Command = Gui::Session::Command; @@ -154,13 +154,13 @@ struct Menu_view::Dialog : List_model::Element Area const size = _root_widget_size(); - unsigned const buffer_w = _buffer.constructed() ? _buffer->size().w() : 0, - buffer_h = _buffer.constructed() ? _buffer->size().h() : 0; + unsigned const buffer_w = _buffer.constructed() ? _buffer->size().w : 0, + buffer_h = _buffer.constructed() ? _buffer->size().h : 0; - Area const max_size(max(buffer_w, size.w()), max(buffer_h, size.h())); + Area const max_size(max(buffer_w, size.w), max(buffer_h, size.h)); - bool const size_increased = (max_size.w() > buffer_w) - || (max_size.h() > buffer_h); + bool const size_increased = (max_size.w > buffer_w) + || (max_size.h > buffer_h); if (!_buffer.constructed() || size_increased) _buffer.construct(_gui, max_size, _env.ram(), _env.rm(), @@ -178,7 +178,7 @@ struct Menu_view::Dialog : List_model::Element }); _buffer->flush_surface(); - _gui.framebuffer()->refresh(0, 0, _buffer->size().w(), _buffer->size().h()); + _gui.framebuffer()->refresh(0, 0, _buffer->size().w, _buffer->size().h); _update_view(Rect(_position, size)); _redraw_scheduled = false; diff --git a/repos/gems/src/app/menu_view/float_widget.h b/repos/gems/src/app/menu_view/float_widget.h index bb2e4375c1..4d81993eac 100644 --- a/repos/gems/src/app/menu_view/float_widget.h +++ b/repos/gems/src/app/menu_view/float_widget.h @@ -32,12 +32,12 @@ struct Menu_view::Float_widget : Widget Area const child_min = child.min_size(); /* space around the minimal-sized child */ - int const w_space = geometry().w() - child_min.w(); - int const h_space = geometry().h() - child_min.h(); + int const w_space = geometry().w() - child_min.w; + int const h_space = geometry().h() - child_min.h; /* stretch child size opposite attributes are specified */ - int const w = (_east && _west) ? geometry().w() : child_min.w(); - int const h = (_north && _south) ? geometry().h() : child_min.h(); + int const w = (_east && _west) ? geometry().w() : child_min.w; + int const h = (_north && _south) ? geometry().h() : child_min.h; /* align / center child position */ int const x = _west ? 0 : _east ? w_space : w_space / 2; @@ -79,7 +79,7 @@ struct Menu_view::Float_widget : Widget { _children.for_each([&] (Widget &child) { _place_child(child); - child.size(child.geometry().area()); + child.size(child.geometry().area); }); } diff --git a/repos/gems/src/app/menu_view/frame_widget.h b/repos/gems/src/app/menu_view/frame_widget.h index d93ebf2d28..6f5ba299f2 100644 --- a/repos/gems/src/app/menu_view/frame_widget.h +++ b/repos/gems/src/app/menu_view/frame_widget.h @@ -56,8 +56,8 @@ struct Menu_view::Frame_widget : Widget /* don't get smaller than the background texture */ Area const texture_size = texture ? texture->size() : Area(0, 0); - return Area(max(_space().w() + child_min_size.w(), texture_size.w()), - max(_space().h() + child_min_size.h(), texture_size.h())); + return Area(max(_space().w + child_min_size.w, texture_size.w), + max(_space().h + child_min_size.h, texture_size.h)); } void draw(Surface &pixel_surface, @@ -82,14 +82,14 @@ struct Menu_view::Frame_widget : Widget child.position(Point(margin.left + padding.left, margin.top + padding.top)); - Area const avail = geometry().area(); + Area const avail = geometry().area; unsigned const - w = avail.w() >= _space().w() ? avail.w() - _space().w() : 0, - h = avail.h() >= _space().h() ? avail.h() - _space().w() : 0; + w = avail.w >= _space().w ? avail.w - _space().w : 0, + h = avail.h >= _space().h ? avail.h - _space().w : 0; - child.size(Area(max(w, child.min_size().w()), - max(h, child.min_size().h()))); + child.size(Area(max(w, child.min_size().w), + max(h, child.min_size().h))); }); } diff --git a/repos/gems/src/app/menu_view/label_widget.h b/repos/gems/src/app/menu_view/label_widget.h index 0bf6209fb4..ca9ecfcb01 100644 --- a/repos/gems/src/app/menu_view/label_widget.h +++ b/repos/gems/src/app/menu_view/label_widget.h @@ -124,29 +124,29 @@ struct Menu_view::Label_widget : Widget, Cursor::Glyph_position Area text_size = min_size(); - int const dx = (int)geometry().w() - text_size.w(), - dy = (int)geometry().h() - text_size.h(); + int const dx = (int)geometry().w() - text_size.w, + dy = (int)geometry().h() - text_size.h; Point const centered = at + Point(dx/2, dy/2); _selections.for_each([&] (Text_selection const &selection) { - selection.draw(pixel_surface, alpha_surface, at, text_size.h()); }); + selection.draw(pixel_surface, alpha_surface, at, text_size.h); }); Color const color = _color.color(); uint8_t const alpha = color.a; if (alpha) { Text_painter::paint(pixel_surface, - Text_painter::Position(centered.x(), centered.y()), + Text_painter::Position(centered.x, centered.y), *_font, color, _text.string()); Text_painter::paint(alpha_surface, - Text_painter::Position(centered.x(), centered.y()), + Text_painter::Position(centered.x, centered.y), *_font, Color(alpha, alpha, alpha, alpha), _text.string()); } _cursors.for_each([&] (Cursor const &cursor) { - cursor.draw(pixel_surface, alpha_surface, at, text_size.h()); }); + cursor.draw(pixel_surface, alpha_surface, at, text_size.h); }); } /** @@ -173,7 +173,7 @@ struct Menu_view::Label_widget : Widget, Cursor::Glyph_position return Hovered { .unique_id = hovered_id, .detail = { } }; return { .unique_id = hovered_id, - .detail = { _char_index_at_xpos(at.x()) } }; + .detail = { _char_index_at_xpos(at.x) } }; } void gen_hover_model(Xml_generator &xml, Point at) const override @@ -184,7 +184,7 @@ struct Menu_view::Label_widget : Widget, Cursor::Glyph_position _gen_common_hover_attr(xml); - xml.attribute("at", _char_index_at_xpos(at.x())); + xml.attribute("at", _char_index_at_xpos(at.x)); }); } } diff --git a/repos/gems/src/app/menu_view/root_widget.h b/repos/gems/src/app/menu_view/root_widget.h index ea824e23ab..fc8d51f569 100644 --- a/repos/gems/src/app/menu_view/root_widget.h +++ b/repos/gems/src/app/menu_view/root_widget.h @@ -33,7 +33,7 @@ struct Menu_view::Root_widget : Widget Area result(1, 1); _children.for_each([&] (Widget const &child) { - result = child.animated_geometry().area(); }); + result = child.animated_geometry().area; }); return result; } @@ -76,7 +76,7 @@ struct Menu_view::Root_widget : Widget { _children.for_each([&] (Widget &child) { child.position(Point(0, 0)); - child.size(_geometry.area()); + child.size(_geometry.area); }); } }; diff --git a/repos/gems/src/app/menu_view/widget.h b/repos/gems/src/app/menu_view/widget.h index 2403ee07f0..cc843480ac 100644 --- a/repos/gems/src/app/menu_view/widget.h +++ b/repos/gems/src/app/menu_view/widget.h @@ -199,8 +199,8 @@ class Menu_view::Widget : List_model::Element Rect edges() const { Rect const r = _animated_geometry.rect(); - return Rect(Point(r.x1() + margin.left, r.y1() + margin.top), - Point(r.x2() - margin.right, r.y2() - margin.bottom)); + return Rect::compound(Point(r.x1() + margin.left, r.y1() + margin.top), + Point(r.x2() - margin.right, r.y2() - margin.bottom)); } Widget(Name const &name, Unique_id const id, @@ -244,7 +244,7 @@ class Menu_view::Widget : List_model::Element void position(Point position) { - _geometry = Rect(position, _geometry.area()); + _geometry = Rect(position, _geometry.area); } static Point _at_child(Point at, Widget const &w) diff --git a/repos/gems/src/app/nano3d/main.cc b/repos/gems/src/app/nano3d/main.cc index 7bfa5c0975..47a43969d0 100644 --- a/repos/gems/src/app/nano3d/main.cc +++ b/repos/gems/src/app/nano3d/main.cc @@ -116,8 +116,8 @@ class Scene : public Nano3d::Scene private: - Polygon::Shaded_painter _shaded_painter { _heap, _size.h() }; - Polygon::Textured_painter _textured_painter { _heap, _size.h() }; + Polygon::Shaded_painter _shaded_painter { _heap, _size.h }; + Polygon::Textured_painter _textured_painter { _heap, _size.h }; Nano3d::Cube_shape const _cube { 7000 }; Nano3d::Dodecahedron_shape const _dodecahedron { 10000 }; @@ -156,7 +156,7 @@ class Scene : public Nano3d::Scene backward_facing ? points[num_vertices - 1 - i] : points[i]; - int const r = _texture.size.w()/2; + int const r = _texture.size.w/2; int const u = r + (r*Nano3d::cos_frac16(angle) >> 16); int const v = r + (r*Nano3d::sin_frac16(angle) >> 16); diff --git a/repos/gems/src/app/osci/main.cc b/repos/gems/src/app/osci/main.cc index 4aa6fe99d1..e674535c05 100644 --- a/repos/gems/src/app/osci/main.cc +++ b/repos/gems/src/app/osci/main.cc @@ -143,13 +143,13 @@ struct Osci::Main * Draw captured audio from right to left. */ - Point const centered { 0, int(pixel.size().h()/2) }; + Point const centered { 0, int(pixel.size().h/2) }; Point previous_p { }; bool first_iteration = true; - unsigned const w = pixel.size().w(); + unsigned const w = pixel.size().w; for (unsigned i = 0; i < w; i++) { @@ -176,7 +176,7 @@ struct Osci::Main _gui_buffer->flush_surface(); - _gui.framebuffer()->refresh(0, 0, _size.w(), _size.h()); + _gui.framebuffer()->refresh(0, 0, _size.w, _size.h); } Main(Env &env) : _env(env) diff --git a/repos/gems/src/app/phone_manager/main.cc b/repos/gems/src/app/phone_manager/main.cc index d397dd8f84..f32d115eb6 100644 --- a/repos/gems/src/app/phone_manager/main.cc +++ b/repos/gems/src/app/phone_manager/main.cc @@ -2105,15 +2105,15 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, Area const size = win_size(win); Point const pos = _touch_keyboard.visible - ? Point(0, int(mode.area.h()) - int(size.h())) - : Point(0, int(mode.area.h())); + ? Point(0, int(mode.area.h) - int(size.h)) + : Point(0, int(mode.area.h)); gen_window(win, Rect(pos, size)); }); _with_window(window_list, main_view_label, [&] (Xml_node win) { Area const size = win_size(win); - Point const pos(_leitzentrale_visible ? 0 : int(size.w()), 0); + Point const pos(_leitzentrale_visible ? 0 : int(size.w), 0); gen_window(win, Rect(pos, size)); }); }); @@ -2130,8 +2130,8 @@ void Sculpt::Main::_handle_gui_mode() _gui_mode_ready = true; _screen_size = mode.area; - _main_view.min_width = _screen_size.w(); - _main_view.min_height = _screen_size.h(); + _main_view.min_width = _screen_size.w; + _main_view.min_height = _screen_size.h; generate_runtime_config(); _update_window_layout(); diff --git a/repos/gems/src/app/rom_osci/main.cc b/repos/gems/src/app/rom_osci/main.cc index 7e639c0593..30610a23ac 100644 --- a/repos/gems/src/app/rom_osci/main.cc +++ b/repos/gems/src/app/rom_osci/main.cc @@ -212,9 +212,9 @@ struct Osci::Main */ Area const area = pixel.size(); - unsigned const w = area.w(); - int const y_pos = int(_attr.v_pos*area.h()); - double const screen_v_scale = _attr.v_scale*area.h()/2; + unsigned const w = area.w; + int const y_pos = int(_attr.v_pos*area.h); + double const screen_v_scale = _attr.v_scale*area.h/2; auto _horizontal_line = [&] (Color c, int y, Color::channel_t alpha) { @@ -314,7 +314,7 @@ struct Osci::Main Phase_lock phase_lock { }; if (_phase_lock) _channels.with_first([&] (Channel const &channel) { - phase_lock = channel.phase_lock(_size.w()/2, -0.1f, _size.w()/2); }); + phase_lock = channel.phase_lock(_size.w/2, -0.1f, _size.w/2); }); _gui_buffer->reset_surface(); _gui_buffer->apply_to_surface([&] (auto &pixel, auto &alpha) { @@ -322,7 +322,7 @@ struct Osci::Main channel.render(pixel, alpha, phase_lock); }); }); _gui_buffer->flush_surface(); - _gui.framebuffer()->refresh(0, 0, _size.w(), _size.h()); + _gui.framebuffer()->refresh(0, 0, _size.w, _size.h); } Main(Env &env) : _env(env) diff --git a/repos/gems/src/app/screenshot_trigger/main.cc b/repos/gems/src/app/screenshot_trigger/main.cc index b1bc8d9dbc..75c9bb1a3e 100644 --- a/repos/gems/src/app/screenshot_trigger/main.cc +++ b/repos/gems/src/app/screenshot_trigger/main.cc @@ -132,8 +132,8 @@ struct Screenshot_trigger::Main /* fill alpha channel */ Pixel_alpha8 *base = alpha.addr(); - for (unsigned y = 0; y < _area.h(); y++) - for (unsigned x = 0; x < _area.w(); x++) + for (unsigned y = 0; y < _area.h; y++) + for (unsigned x = 0; x < _area.w; x++) *base++ = Pixel_alpha8 { 0, 0, 0, int(intensity(x, y)) }; } diff --git a/repos/gems/src/app/sculpt_manager/main.cc b/repos/gems/src/app/sculpt_manager/main.cc index 73347d4b4a..0099e6ef1b 100644 --- a/repos/gems/src/app/sculpt_manager/main.cc +++ b/repos/gems/src/app/sculpt_manager/main.cc @@ -953,8 +953,8 @@ struct Sculpt::Main : Input_event_handler, ev.handle_wheel([&] (int, int y) { dy = y*32; }); - if (ev.key_press(Input::KEY_PAGEUP)) dy = int(_gui.mode().area.h() / 3); - if (ev.key_press(Input::KEY_PAGEDOWN)) dy = -int(_gui.mode().area.h() / 3); + if (ev.key_press(Input::KEY_PAGEUP)) dy = int(_gui.mode().area.h / 3); + if (ev.key_press(Input::KEY_PAGEDOWN)) dy = -int(_gui.mode().area.h / 3); if (dy != 0) { scroll_ypos += dy; @@ -1720,7 +1720,7 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, unsigned panel_height = 0; _with_window(window_list, panel_view_label, [&] (Xml_node win) { - panel_height = win_size(win).h(); }); + panel_height = win_size(win).h; }); /* suppress intermediate states during the restart of the panel */ if (panel_height == 0) @@ -1733,20 +1733,20 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, return; /* area reserved for the panel */ - Rect const panel(Point(0, 0), Area(mode.area.w(), panel_height)); + Rect const panel = Rect(Point(0, 0), Area(mode.area.w, panel_height)); /* available space on the right of the menu */ - Rect avail(Point(0, panel.h()), - Point(mode.area.w() - 1, mode.area.h() - 1)); + Rect avail = Rect::compound(Point(0, panel.h()), + Point(mode.area.w - 1, mode.area.h - 1)); Point const log_offset = _log_visible ? Point(0, 0) : Point(log_min_w + margins.left + margins.right, 0); - Point const log_p1(avail.x2() - log_min_w - margins.right + 1 + log_offset.x(), + Point const log_p1(avail.x2() - log_min_w - margins.right + 1 + log_offset.x, avail.y1() + margins.top); - Point const log_p2(mode.area.w() - margins.right - 1 + log_offset.x(), - mode.area.h() - margins.bottom - 1); + Point const log_p2(mode.area.w - margins.right - 1 + log_offset.x, + mode.area.h - margins.bottom - 1); /* position of the inspect window */ Point const inspect_p1(avail.x1() + margins.left, avail.y1() + margins.top); @@ -1771,18 +1771,18 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, /* window size limited to space unobstructed by the menu and log */ auto constrained_win_size = [&] (Xml_node const &win) { - unsigned const inspect_w = inspect_p2.x() - inspect_p1.x(), - inspect_h = inspect_p2.y() - inspect_p1.y(); + unsigned const inspect_w = inspect_p2.x - inspect_p1.x, + inspect_h = inspect_p2.y - inspect_p1.y; Area const size = win_size(win); - return Area(min(inspect_w, size.w()), min(inspect_h, size.h())); + return Area(min(inspect_w, size.w), min(inspect_h, size.h)); }; _with_window(window_list, panel_view_label, [&] (Xml_node const &win) { gen_window(win, panel); }); _with_window(window_list, Label("log"), [&] (Xml_node const &win) { - gen_window(win, Rect(log_p1, log_p2)); }); + gen_window(win, Rect::compound(log_p1, log_p2)); }); int system_right_xpos = 0; if (system_available()) { @@ -1790,11 +1790,11 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, Area const size = win_size(win); Point const pos = _system_visible ? Point(0, avail.y1()) - : Point(-size.w(), avail.y1()); + : Point(-size.w, avail.y1()); gen_window(win, Rect(pos, size)); if (_system_visible) - system_right_xpos = size.w(); + system_right_xpos = size.w; }); } @@ -1802,7 +1802,7 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, Area const size = win_size(win); Point const pos = _settings_visible ? Point(system_right_xpos, avail.y1()) - : Point(-size.w(), avail.y1()); + : Point(-size.w, avail.y1()); if (_settings.interactive_settings_available()) gen_window(win, Rect(pos, size)); @@ -1811,8 +1811,8 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, _with_window(window_list, network_view_label, [&] (Xml_node const &win) { Area const size = win_size(win); Point const pos = _network_visible - ? Point(log_p1.x() - size.w(), avail.y1()) - : Point(mode.area.w(), avail.y1()); + ? Point(log_p1.x - size.w, avail.y1()) + : Point(mode.area.w, avail.y1()); gen_window(win, Rect(pos, size)); }); @@ -1820,10 +1820,10 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, if (_selected_tab == Panel_dialog::Tab::FILES) { Area const size = constrained_win_size(win); - Point const pos = Rect(inspect_p1, inspect_p2).center(size); + Point const pos = Rect::compound(inspect_p1, inspect_p2).center(size); Point const offset = _file_browser_state.text_area.constructed() - ? Point((2*avail.w())/3 - pos.x(), 0) + ? Point((2*avail.w())/3 - pos.x, 0) : Point(0, 0); gen_window(win, Rect(pos - offset, size)); @@ -1833,10 +1833,10 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, _with_window(window_list, editor_view_label, [&] (Xml_node const &win) { if (_selected_tab == Panel_dialog::Tab::FILES) { Area const size = constrained_win_size(win); - Point const pos = Rect(inspect_p1 + Point(400, 0), inspect_p2).center(size); + Point const pos = Rect::compound(inspect_p1 + Point(400, 0), inspect_p2).center(size); Point const offset = _file_browser_state.text_area.constructed() - ? Point(avail.w()/3 - pos.x(), 0) + ? Point(avail.w()/3 - pos.x, 0) : Point(0, 0); gen_window(win, Rect(pos + offset, size)); @@ -1846,16 +1846,16 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, _with_window(window_list, diag_view_label, [&] (Xml_node const &win) { if (_selected_tab == Panel_dialog::Tab::COMPONENTS) { Area const size = win_size(win); - Point const pos(0, avail.y2() - size.h()); + Point const pos(0, avail.y2() - size.h); gen_window(win, Rect(pos, size)); } }); auto sanitize_scroll_position = [&] (Area const &win_size, int &scroll_ypos) { - unsigned const inspect_h = unsigned(inspect_p2.y() - inspect_p1.y() + 1); - if (win_size.h() > inspect_h) { - int const out_of_view_h = win_size.h() - inspect_h; + unsigned const inspect_h = unsigned(inspect_p2.y - inspect_p1.y + 1); + if (win_size.h > inspect_h) { + int const out_of_view_h = win_size.h - inspect_h; scroll_ypos = max(scroll_ypos, -out_of_view_h); scroll_ypos = min(scroll_ypos, 0); } else @@ -1869,14 +1869,14 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, Point runtime_view_pos { }; _with_window(window_list, runtime_view_label, [&] (Xml_node const &win) { Area const size = win_size(win); - Rect const inspect(inspect_p1, inspect_p2); + Rect const inspect = Rect::compound(inspect_p1, inspect_p2); /* center graph if there is enough space, scroll otherwise */ - if (size.h() < inspect.h()) { + if (size.h < inspect.h()) { runtime_view_pos = inspect.center(size); } else { sanitize_scroll_position(size, _graph_scroll_ypos); - runtime_view_pos = { inspect.center(size).x(), + runtime_view_pos = { inspect.center(size).x, int(panel.h()) + _graph_scroll_ypos }; } }); @@ -1884,17 +1884,17 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, if (_popup.state == Popup::VISIBLE) { _with_window(window_list, popup_view_label, [&] (Xml_node const &win) { Area const size = win_size(win); - Rect const inspect(inspect_p1, inspect_p2); + Rect const inspect = Rect::compound(inspect_p1, inspect_p2); - int const x = runtime_view_pos.x() + _popup.anchor.x2(); + int const x = runtime_view_pos.x + _popup.anchor.x2(); auto y = [&] { /* try to vertically align the popup at the '+' button */ - if (size.h() < inspect.h()) { + if (size.h < inspect.h()) { int const anchor_y = (_popup.anchor.y1() + _popup.anchor.y2())/2; - int const abs_anchor_y = runtime_view_pos.y() + anchor_y; - return max((int)panel_height, abs_anchor_y - (int)size.h()/2); + int const abs_anchor_y = runtime_view_pos.y + anchor_y; + return max((int)panel_height, abs_anchor_y - (int)size.h/2); } else { sanitize_scroll_position(size, _popup_scroll_ypos); return int(panel.h()) + _popup_scroll_ypos; @@ -1906,7 +1906,7 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, _with_window(window_list, inspect_label, [&] (Xml_node const &win) { if (_selected_tab == Panel_dialog::Tab::INSPECT) - gen_window(win, Rect(inspect_p1, inspect_p2)); }); + gen_window(win, Rect::compound(inspect_p1, inspect_p2)); }); /* * Position runtime view centered within the inspect area, but allow @@ -1918,7 +1918,7 @@ void Sculpt::Main::_update_window_layout(Xml_node const &decorator_margins, _with_window(window_list, logo_label, [&] (Xml_node const &win) { Area const size = win_size(win); - Point const pos(mode.area.w() - size.w(), mode.area.h() - size.h()); + Point const pos(mode.area.w - size.w, mode.area.h - size.h); gen_window(win, Rect(pos, size)); }); }); @@ -1956,7 +1956,7 @@ void Sculpt::Main::_handle_gui_mode() if (!_settings.manual_fonts_config) { - _font_size_px = (double)mode.area.h() / 60.0; + _font_size_px = (double)mode.area.h / 60.0; if (_settings.font_size == Settings::Font_size::SMALL) _font_size_px *= 0.85; if (_settings.font_size == Settings::Font_size::LARGE) _font_size_px *= 1.35; @@ -2012,7 +2012,7 @@ void Sculpt::Main::_handle_gui_mode() } _screen_size = mode.area; - _panel_dialog.min_width = _screen_size.w(); + _panel_dialog.min_width = _screen_size.w; unsigned const menu_width = max((unsigned)(_font_size_px*21.0), 320u); _diag_dialog.min_width = menu_width; _network_dialog.min_width = menu_width; diff --git a/repos/gems/src/app/themed_decorator/theme.cc b/repos/gems/src/app/themed_decorator/theme.cc index 5ed274210c..c2313fc2de 100644 --- a/repos/gems/src/app/themed_decorator/theme.cc +++ b/repos/gems/src/app/themed_decorator/theme.cc @@ -208,15 +208,15 @@ void Decorator::Theme::draw_background(Decorator::Pixel_surface &pixel_surface, unsigned const left = aura_margins().left + decor_margins().left; unsigned const right = aura_margins().right + decor_margins().right; - unsigned const middle = left + right < area.w() - ? area.w() - left - right + unsigned const middle = left + right < area.w + ? area.w - left - right : 0; Rect const orig_clip = pixel_surface.clip(); /* left */ if (left) { - Rect curr_clip = Rect(Point(0, 0), Area(left, area.h())); + Rect curr_clip = Rect(Point(0, 0), Area(left, area.h)); pixel_surface.clip(curr_clip); alpha_surface.clip(curr_clip); @@ -228,7 +228,7 @@ void Decorator::Theme::draw_background(Decorator::Pixel_surface &pixel_surface, /* middle */ if (middle) { - Rect curr_clip = Rect(Point(left, 0), Area(middle, area.h())); + Rect curr_clip = Rect(Point(left, 0), Area(middle, area.h)); pixel_surface.clip(curr_clip); alpha_surface.clip(curr_clip); @@ -240,16 +240,16 @@ void Decorator::Theme::draw_background(Decorator::Pixel_surface &pixel_surface, /* right */ if (right) { - Rect curr_clip = Rect(Point(left + middle, 0), Area(right, area.h())); + Rect curr_clip = Rect(Point(left + middle, 0), Area(right, area.h)); pixel_surface.clip(curr_clip); alpha_surface.clip(curr_clip); Point at(0, 0); Area size = area; - if (texture.size().w() > area.w()) { - at = Point((int)area.w() - (int)texture.size().w(), 0); - size = Area(texture.size().w(), size.h()); + if (texture.size().w > area.w) { + at = Point((int)area.w - (int)texture.size().w, 0); + size = Area(texture.size().w, size.h); } Icon_painter::paint(pixel_surface, Rect(at, size), texture, alpha); @@ -265,18 +265,18 @@ void Decorator::Theme::draw_title(Decorator::Pixel_surface &pixel_surface, Area const area, char const *title) const { /* skip title drawing if the metadata lacks a title declaration */ - if (!title_geometry().area().valid()) + if (!title_geometry().area.valid()) return; Text_painter::Font const &font = title_font(_alloc); Area const label_area(font.string_width(title).decimal(), - font.bounding_box().h()); + font.bounding_box().h); Rect const target_rect(Point(0, 0), area); Rect const title_rect = absolute(title_geometry(), target_rect); Point const pos = title_rect.center(label_area) - Point(0, 1); - Text_painter::paint(pixel_surface, Text_painter::Position(pos.x(), pos.y()), + Text_painter::paint(pixel_surface, Text_painter::Position(pos.x, pos.y), font, Color::black(), title); } @@ -287,7 +287,7 @@ void Decorator::Theme::draw_element(Decorator::Pixel_surface &pixel_surface, Element_type element_type, unsigned alpha) const { - if (!element_geometry(element_type).area().valid()) + if (!element_geometry(element_type).area.valid()) return; Genode::Texture const &texture = @@ -296,7 +296,7 @@ void Decorator::Theme::draw_element(Decorator::Pixel_surface &pixel_surface, Rect const target_rect(Point(0, 0), area); Rect const element_rect = element_geometry(element_type); Point const pos = absolute(element_rect.p1(), target_rect); - Rect const rect(pos, element_rect.area()); + Rect const rect(pos, element_rect.area); Icon_painter::paint(pixel_surface, rect, texture, alpha); Icon_painter::paint(alpha_surface, rect, texture, alpha); @@ -308,11 +308,11 @@ Decorator::Point Decorator::Theme::absolute(Decorator::Point pos, { Area const theme_size = background_size(); - int x = pos.x(); - int y = pos.y(); + int x = pos.x; + int y = pos.y; - if (x > (int)theme_size.w()/2) x = win_rect.w() - theme_size.w() + x; - if (y > (int)theme_size.h()/2) y = win_rect.h() - theme_size.h() + y; + if (x > (int)theme_size.w/2) x = win_rect.w() - theme_size.w + x; + if (y > (int)theme_size.h/2) y = win_rect.h() - theme_size.h + y; return win_rect.p1() + Point(x, y); } @@ -321,5 +321,6 @@ Decorator::Point Decorator::Theme::absolute(Decorator::Point pos, Decorator::Rect Decorator::Theme::absolute(Decorator::Rect rect, Decorator::Rect win_rect) const { - return Rect(absolute(rect.p1(), win_rect), absolute(rect.p2(), win_rect)); + return Rect::compound(absolute(rect.p1(), win_rect), + absolute(rect.p2(), win_rect)); } diff --git a/repos/gems/src/app/themed_decorator/tint_painter.h b/repos/gems/src/app/themed_decorator/tint_painter.h index d632f10d23..eb613824ae 100644 --- a/repos/gems/src/app/themed_decorator/tint_painter.h +++ b/repos/gems/src/app/themed_decorator/tint_painter.h @@ -58,9 +58,9 @@ struct Tint_painter PT pix(color.r, color.g, color.b); - PT *dst, *dst_line = surface.addr() + surface.size().w()*clipped.y1() + clipped.x1(); + PT *dst, *dst_line = surface.addr() + surface.size().w*clipped.y1() + clipped.x1(); - for (int w, h = clipped.h() ; h--; dst_line += surface.size().w()) + for (int w, h = clipped.h() ; h--; dst_line += surface.size().w) for (dst = dst_line, w = clipped.w(); w--; dst++) { PT const pixel = *dst; *dst = pixel_lut[pixel.r() + pixel.g() + pixel.b()]; diff --git a/repos/gems/src/app/themed_decorator/window.cc b/repos/gems/src/app/themed_decorator/window.cc index f5cae4327c..6410f78263 100644 --- a/repos/gems/src/app/themed_decorator/window.cc +++ b/repos/gems/src/app/themed_decorator/window.cc @@ -50,15 +50,15 @@ Decorator::Window_base::Hover Decorator::Window::hover(Point abs_pos) const return hover; } - int const x = abs_pos.x(); - int const y = abs_pos.y(); + int const x = abs_pos.x; + int const y = abs_pos.y; Area const theme_size = _theme.background_size(); - hover.left_sizer = x < outer_geometry().x1() + (int)theme_size.w()/2; - hover.right_sizer = x > outer_geometry().x2() - (int)theme_size.w()/2; - hover.top_sizer = y < outer_geometry().y1() + (int)theme_size.h()/2; - hover.bottom_sizer = y > outer_geometry().y2() - (int)theme_size.h()/2; + hover.left_sizer = x < outer_geometry().x1() + (int)theme_size.w/2; + hover.right_sizer = x > outer_geometry().x2() - (int)theme_size.w/2; + hover.top_sizer = y < outer_geometry().y1() + (int)theme_size.h/2; + hover.bottom_sizer = y > outer_geometry().y2() - (int)theme_size.h/2; return hover; } diff --git a/repos/gems/src/app/themed_decorator/window.h b/repos/gems/src/app/themed_decorator/window.h index d73e90c367..782a817e7f 100644 --- a/repos/gems/src/app/themed_decorator/window.h +++ b/repos/gems/src/app/themed_decorator/window.h @@ -261,14 +261,14 @@ class Decorator::Window : public Window_base, public Animator::Item { Area const outer_size = _outer_from_inner_size(inner_size); - return Area(outer_size.w(), _theme.background_size().h()); + return Area(outer_size.w, _theme.background_size().h); } Area _visible_left_right_area(Area const inner_size) const { Area const outer_size = _outer_from_inner_size(inner_size); - return Area(outer_size.w() - inner_size.w(), outer_size.h()); + return Area(outer_size.w - inner_size.w, outer_size.h); } Gui_view _bottom_view { _gui, _gui_top_bottom }, @@ -300,12 +300,12 @@ class Decorator::Window : public Window_base, public Animator::Item buffer.flush_surface(); - buffer.gui.framebuffer()->refresh(0, 0, buffer.size().w(), buffer.size().h()); + buffer.gui.framebuffer()->refresh(0, 0, buffer.size().w, buffer.size().h); } void _repaint_decorations() { - Area const inner_size = _curr_inner_geometry().area(); + Area const inner_size = _curr_inner_geometry().area; _repaint_decorations(*_buffer_top_bottom, _visible_top_bottom_area(inner_size)); _repaint_decorations(*_buffer_left_right, _visible_left_right_area(inner_size)); @@ -315,14 +315,14 @@ class Decorator::Window : public Window_base, public Animator::Item { bool const use_alpha = true; - Area const size_top_bottom = _visible_top_bottom_area(geometry().area()); + Area const size_top_bottom = _visible_top_bottom_area(geometry().area); - if (size_top_bottom.w() > _size_top_bottom.w() - || size_top_bottom.h() > _size_top_bottom.h() + if (size_top_bottom.w > _size_top_bottom.w + || size_top_bottom.h > _size_top_bottom.h || !_buffer_top_bottom.constructed()) { - _gui_top_bottom.buffer(Framebuffer::Mode { .area = { size_top_bottom.w(), - size_top_bottom.h() } }, + _gui_top_bottom.buffer(Framebuffer::Mode { .area = { size_top_bottom.w, + size_top_bottom.h } }, use_alpha); _buffer_top_bottom.construct(_gui_top_bottom, size_top_bottom, @@ -331,14 +331,14 @@ class Decorator::Window : public Window_base, public Animator::Item _size_top_bottom = size_top_bottom; } - Area const size_left_right = _visible_left_right_area(geometry().area()); + Area const size_left_right = _visible_left_right_area(geometry().area); - if (size_left_right.w() > _size_left_right.w() - || size_left_right.h() > _size_left_right.h() + if (size_left_right.w > _size_left_right.w + || size_left_right.h > _size_left_right.h || !_buffer_left_right.constructed()) { - _gui_left_right.buffer(Framebuffer::Mode { .area = { size_left_right.w(), - size_left_right.h() } }, + _gui_left_right.buffer(Framebuffer::Mode { .area = { size_left_right.w, + size_left_right.h } }, use_alpha); _buffer_left_right.construct(_gui_left_right, size_left_right, @@ -422,8 +422,8 @@ class Decorator::Window : public Window_base, public Animator::Item { Theme::Margins const decor = _theme.decor_margins(); - return Rect(_curr_inner_geometry().p1() - Point(decor.left, decor.top), - _curr_inner_geometry().p2() + Point(decor.right, decor.bottom)); + return Rect::compound(_curr_inner_geometry().p1() - Point(decor.left, decor.top), + _curr_inner_geometry().p2() + Point(decor.right, decor.bottom)); } Rect _outer_from_inner_geometry(Rect inner) const @@ -436,13 +436,13 @@ class Decorator::Window : public Window_base, public Animator::Item unsigned const top = aura.top + decor.top; unsigned const bottom = aura.bottom + decor.bottom; - return Rect(inner.p1() - Point(left, top), - inner.p2() + Point(right, bottom)); + return Rect::compound(inner.p1() - Point(left, top), + inner.p2() + Point(right, bottom)); } Area _outer_from_inner_size(Area inner) const { - return _outer_from_inner_geometry(Rect(Point(0, 0), inner)).area(); + return _outer_from_inner_geometry(Rect(Point(0, 0), inner)).area; } Rect outer_geometry() const override @@ -463,14 +463,13 @@ class Decorator::Window : public Window_base, public Animator::Item Rect const outer = _outer_from_inner_geometry(inner); /* update view positions */ - Rect top, left, right, bottom; - outer.cut(inner, &top, &left, &right, &bottom); + Rect::Cut_remainder const r = outer.cut(inner); _content_view.place(inner, Point(0, 0)); - _top_view .place(top, Point(0, 0)); - _left_view .place(left, Point(0, -top.h())); - _right_view .place(right, Point(-right.w(), -top.h())); - _bottom_view .place(bottom, Point(0, -theme_size.h() + bottom.h())); + _top_view .place(r.top, Point(0, 0)); + _left_view .place(r.left, Point(0, -r.top.h())); + _right_view .place(r.right, Point(-r.right.w(), -r.top.h())); + _bottom_view .place(r.bottom, Point(0, -theme_size.h + r.bottom.h())); _gui.execute(); diff --git a/repos/gems/src/app/window_layouter/assign.h b/repos/gems/src/app/window_layouter/assign.h index b8e21936c7..1c956cde1b 100644 --- a/repos/gems/src/app/window_layouter/assign.h +++ b/repos/gems/src/app/window_layouter/assign.h @@ -116,13 +116,13 @@ class Window_layouter::Assign : public List_model::Element Point const any_pos(150*win_id % 800, 30 + (100*win_id % 500)); - Point const pos(_xpos_any ? any_pos.x() : _pos.x(), - _ypos_any ? any_pos.y() : _pos.y()); + Point const pos(_xpos_any ? any_pos.x : _pos.x, + _ypos_any ? any_pos.y : _pos.y); Rect const inner(pos, _size_defined ? _size : client_size); Rect const outer = decorator_margins.outer_geometry(inner); - return Rect(outer.p1() + target_geometry.p1(), outer.area()); + return Rect(outer.p1() + target_geometry.p1(), outer.area); } bool maximized() const { return _maximized; } @@ -204,15 +204,15 @@ class Window_layouter::Assign : public List_model::Element { if (_pos_defined) { if (_xpos_any) xml.attribute("xpos", "any"); - else xml.attribute("xpos", _pos.x()); + else xml.attribute("xpos", _pos.x); if (_ypos_any) xml.attribute("ypos", "any"); - else xml.attribute("ypos", _pos.y()); + else xml.attribute("ypos", _pos.y); } if (_size_defined) { - xml.attribute("width", _size.w()); - xml.attribute("height", _size.h()); + xml.attribute("width", _size.w); + xml.attribute("height", _size.h); } if (_maximized) diff --git a/repos/gems/src/app/window_layouter/decorator_margins.h b/repos/gems/src/app/window_layouter/decorator_margins.h index f0ea2cd432..a4b2ea9156 100644 --- a/repos/gems/src/app/window_layouter/decorator_margins.h +++ b/repos/gems/src/app/window_layouter/decorator_margins.h @@ -40,8 +40,8 @@ struct Window_layouter::Decorator_margins /* enforce assumption that outer must be larger than the decorations */ outer = Rect::compound(outer, { outer.p1(), Area { left + right + 1, top + bottom + 1 } }); - return Rect(outer.p1() + Point(left, top), - outer.p2() - Point(right, bottom)); + return Rect::compound(outer.p1() + Point(left, top), + outer.p2() - Point(right, bottom)); } /** @@ -49,8 +49,8 @@ struct Window_layouter::Decorator_margins */ Rect outer_geometry(Rect inner) const { - return Rect(inner.p1() - Point(left, top), - inner.p2() + Point(right, bottom)); + return Rect::compound(inner.p1() - Point(left, top), + inner.p2() + Point(right, bottom)); } }; diff --git a/repos/gems/src/app/window_layouter/window.h b/repos/gems/src/app/window_layouter/window.h index 160a5e5bf1..50d866ec05 100644 --- a/repos/gems/src/app/window_layouter/window.h +++ b/repos/gems/src/app/window_layouter/window.h @@ -116,7 +116,7 @@ class Window_layouter::Window : public List_model::Element Area _requested_size() const { return (_maximized || !_floating) - ? _decorator_margins.inner_geometry(_target_geometry).area() + ? _decorator_margins.inner_geometry(_target_geometry).area : _dragged_size; } @@ -209,7 +209,7 @@ class Window_layouter::Window : public List_model::Element _orig_geometry = _geometry; _drag_geometry = _geometry; - _dragged_size = _geometry.area(); + _dragged_size = _geometry.area; _dragged = true; } @@ -222,7 +222,7 @@ class Window_layouter::Window : public List_model::Element /* move window */ if (!_drag_border()) { _drag_geometry = Rect(_orig_geometry.p1() + offset, - _orig_geometry.area()); + _orig_geometry.area); return; } @@ -230,14 +230,14 @@ class Window_layouter::Window : public List_model::Element int x1 = _orig_geometry.x1(), y1 = _orig_geometry.y1(), x2 = _orig_geometry.x2(), y2 = _orig_geometry.y2(); - if (_drag_left_border) x1 = min(x1 + offset.x(), x2); - if (_drag_right_border) x2 = max(x2 + offset.x(), x1); - if (_drag_top_border) y1 = min(y1 + offset.y(), y2); - if (_drag_bottom_border) y2 = max(y2 + offset.y(), y1); + if (_drag_left_border) x1 = min(x1 + offset.x, x2); + if (_drag_right_border) x2 = max(x2 + offset.x, x1); + if (_drag_top_border) y1 = min(y1 + offset.y, y2); + if (_drag_bottom_border) y2 = max(y2 + offset.y, y1); - _drag_geometry = Rect(Point(x1, y1), Point(x2, y2)); + _drag_geometry = Rect::compound(Point(x1, y1), Point(x2, y2)); - _dragged_size = _drag_geometry.area(); + _dragged_size = _drag_geometry.area; } /** @@ -287,12 +287,12 @@ class Window_layouter::Window : public List_model::Element return _drag_geometry; /* resize window */ - if (_drag_left_border) x1 = x2 - _client_size.w() + 1; - if (_drag_right_border) x2 = x1 + _client_size.w() - 1; - if (_drag_top_border) y1 = y2 - _client_size.h() + 1; - if (_drag_bottom_border) y2 = y1 + _client_size.h() - 1; + if (_drag_left_border) x1 = x2 - _client_size.w + 1; + if (_drag_right_border) x2 = x1 + _client_size.w - 1; + if (_drag_top_border) y1 = y2 - _client_size.h + 1; + if (_drag_bottom_border) y2 = y1 + _client_size.h - 1; - return Rect(Point(x1, y1), Point(x2, y2)); + return Rect::compound(Point(x1, y1), Point(x2, y2)); } /** @@ -308,7 +308,7 @@ class Window_layouter::Window : public List_model::Element _geometry = _decorator_margins.inner_geometry(outer); - _dragged_size = _geometry.area(); + _dragged_size = _geometry.area; } Rect outer_geometry() const @@ -366,8 +366,8 @@ class Window_layouter::Window : public List_model::Element xml.node("window", [&] () { xml.attribute("id", _id.value); - xml.attribute("width", size.w()); - xml.attribute("height", size.h()); + xml.attribute("width", size.w); + xml.attribute("height", size.h); }); } @@ -417,12 +417,12 @@ class Window_layouter::Window : public List_model::Element * impersonate other applications. */ Area const size = _use_target_area() - ? Area(min(rect.w(), _client_size.w()), - min(rect.h(), _client_size.h())) + ? Area(min(rect.w(), _client_size.w), + min(rect.h(), _client_size.h)) : _client_size; - xml.attribute("width", size.w()); - xml.attribute("height", size.h()); + xml.attribute("width", size.w); + xml.attribute("height", size.h); if (_focused) xml.attribute("focused", "yes"); @@ -471,7 +471,7 @@ class Window_layouter::Window : public List_model::Element _drag_top_border = false; _drag_bottom_border = false; _geometry = effective_inner_geometry(); - _dragged_size = _geometry.area(); + _dragged_size = _geometry.area; _dragged = false; } diff --git a/repos/gems/src/lib/ttf_font/ttf_font.cc b/repos/gems/src/lib/ttf_font/ttf_font.cc index 7f91b735b9..775e867ae4 100644 --- a/repos/gems/src/lib/ttf_font/ttf_font.cc +++ b/repos/gems/src/lib/ttf_font/ttf_font.cc @@ -117,7 +117,7 @@ struct Ttf_font::Glyph_buffer alloc(alloc), /* glyphs are horizontally stretched by factor 4 */ - capacity(4*(bounding_box.w() + PAD_X)*(bounding_box.h() + PAD_Y)) + capacity(4*(bounding_box.w + PAD_X)*(bounding_box.h + PAD_Y)) { } ~Glyph_buffer() { alloc.free(_values, _num_bytes()); } diff --git a/repos/gems/src/lib/vfs/ttf/vfs.cc b/repos/gems/src/lib/vfs/ttf/vfs.cc index f6af223dda..259b888aec 100644 --- a/repos/gems/src/lib/vfs/ttf/vfs.cc +++ b/repos/gems/src/lib/vfs/ttf/vfs.cc @@ -113,8 +113,8 @@ struct Vfs_ttf::Local_factory : File_system_factory, Watch_response_handler { _baseline_fs .value(_font->font.font().baseline()); _height_fs .value(_font->font.font().height()); - _max_width_fs .value(_font->font.font().bounding_box().w()); - _max_height_fs.value(_font->font.font().bounding_box().h()); + _max_width_fs .value(_font->font.font().bounding_box().w); + _max_height_fs.value(_font->font.font().bounding_box().h); } Local_factory(Vfs::Env &env, Xml_node config) diff --git a/repos/gems/src/server/gui_fader/alpha_dither_painter.h b/repos/gems/src/server/gui_fader/alpha_dither_painter.h index dbe018f496..0c0aefb2c6 100644 --- a/repos/gems/src/server/gui_fader/alpha_dither_painter.h +++ b/repos/gems/src/server/gui_fader/alpha_dither_painter.h @@ -36,14 +36,14 @@ struct Alpha_dither_painter if (!clipped.valid()) return; - Pixel_alpha8 *dst, *dst_line = surface.addr() + surface.size().w()*clipped.y1() + clipped.x1(); + Pixel_alpha8 *dst, *dst_line = surface.addr() + surface.size().w*clipped.y1() + clipped.x1(); int y = clipped.y1(); /* scale fade value to range of alpha values */ fade *= 256; - for (int w, h = clipped.h() ; h--; dst_line += surface.size().w()) { + for (int w, h = clipped.h() ; h--; dst_line += surface.size().w) { int x = clipped.x1(); @@ -73,8 +73,8 @@ struct Alpha_dither_painter if (!clipped.valid()) return; - unsigned const src_line_w = texture.size().w(), - dst_line_w = surface.size().w(); + unsigned const src_line_w = texture.size().w, + dst_line_w = surface.size().w; unsigned const src_start = src_line_w*clipped.y1() + clipped.x1(), dst_start = dst_line_w*clipped.y1() + clipped.x1(); diff --git a/repos/gems/src/server/terminal/main.cc b/repos/gems/src/server/terminal/main.cc index 2d45f6ed96..7f728ba6db 100644 --- a/repos/gems/src/server/terminal/main.cc +++ b/repos/gems/src/server/terminal/main.cc @@ -219,8 +219,8 @@ struct Terminal::Main : Character_consumer /* apply initial size from config, if provided */ _config.xml().with_optional_sub_node("initial", [&] (Xml_node const &initial) { - _fb_mode.area = Area(initial.attribute_value("width", _fb_mode.area.w()), - initial.attribute_value("height", _fb_mode.area.h())); + _fb_mode.area = Area(initial.attribute_value("width", _fb_mode.area.w), + initial.attribute_value("height", _fb_mode.area.h)); }); _handle_config(); @@ -330,7 +330,7 @@ void Terminal::Main::_handle_config() _terminal_size = Area(0, 0); } - _root.notify_resized(Session::Size(_terminal_size.w(), _terminal_size.h())); + _root.notify_resized(Session::Size(_terminal_size.w, _terminal_size.h)); _schedule_flush(); } diff --git a/repos/gems/src/server/terminal/text_screen_surface.h b/repos/gems/src/server/terminal/text_screen_surface.h index b094087434..0518f133cd 100644 --- a/repos/gems/src/server/terminal/text_screen_surface.h +++ b/repos/gems/src/server/terminal/text_screen_surface.h @@ -66,8 +66,8 @@ class Terminal::Text_screen_surface fb_size(initial_fb_size), char_width(font.string_width(Utf8_ptr("M"))), char_height(font.height()), - columns((_visible(initial_fb_size.w()) << 8)/char_width.value), - lines(_visible(initial_fb_size.h())/char_height) + columns((_visible(initial_fb_size.w) << 8)/char_width.value), + lines(_visible(initial_fb_size.h)/char_height) { if (columns*lines == 0) throw Invalid(); @@ -90,8 +90,8 @@ class Terminal::Text_screen_surface */ Area unused_pixels() const { - return Area(fb_size.w() - used_pixels().w(), - fb_size.h() - used_pixels().h()); + return Area(fb_size.w - used_pixels().w, + fb_size.h - used_pixels().h); } /** @@ -109,7 +109,7 @@ class Terminal::Text_screen_surface if (char_width.value == 0 || char_height == 0) return Position { }; - return Position((p.x() << 8) / char_width.value, p.y() / char_height); + return Position((p.x << 8) / char_width.value, p.y / char_height); } }; @@ -128,8 +128,8 @@ class Terminal::Text_screen_surface static size_t bytes_needed(Text_screen_surface const &surface) { - return Cell_array::bytes_needed(surface.size().w(), - surface.size().h()); + return Cell_array::bytes_needed(surface.size().w, + surface.size().h); } Snapshot(Allocator &alloc, Text_screen_surface const &from) @@ -217,22 +217,20 @@ class Terminal::Text_screen_surface Color const bg_color = _palette.background(Color_palette::Index{0}, Color_palette::Highlighted{false}); - Rect r[4] { }; - Rect const all(Point(0, 0), _geometry.fb_size); - _geometry.fb_rect().cut(_geometry.used_rect(), &r[0], &r[1], &r[2], &r[3]); - for (unsigned i = 0; i < 4; i++) - Box_painter::paint(surface, r[i], bg_color); + + _geometry.fb_rect().cut(_geometry.used_rect()).for_each([&] (Rect const &r) { + Box_painter::paint(surface, r, bg_color); }); } - int const clip_top = 0, clip_bottom = _geometry.fb_size.h(), - clip_left = 0, clip_right = _geometry.fb_size.w(); + int const clip_top = 0, clip_bottom = _geometry.fb_size.h, + clip_left = 0, clip_right = _geometry.fb_size.w; - unsigned y = _geometry.start().y(); + unsigned y = _geometry.start().y; for (unsigned line = 0; line < _cell_array.num_lines(); line++) { if (_cell_array.line_dirty(line)) { - Fixpoint_number x { (int)_geometry.start().x() }; + Fixpoint_number x { (int)_geometry.start().x }; for (unsigned column = 0; column < _cell_array.num_cols(); column++) { Char_cell const cell = _cell_array.get_cell(column, line); @@ -288,16 +286,16 @@ class Terminal::Text_screen_surface next_x.value += _geometry.char_width.value; Box_painter::paint(surface, - Rect(Point(x.decimal(), y), - Point(next_x.decimal() - 1, - y + _geometry.char_height - 1)), + Rect::compound(Point(x.decimal(), y), + Point(next_x.decimal() - 1, + y + _geometry.char_height - 1)), bg_color); /* horizontally align glyph within cell */ x.value += (_geometry.char_width.value - (int)((glyph.width - 1)<<8)) >> 1; Glyph_painter::paint(Glyph_painter::Position(x, (int)y), - glyph, surface.addr(), _geometry.fb_size.w(), + glyph, surface.addr(), _geometry.fb_size.w, clip_top, clip_bottom, clip_left, clip_right, pixel, fg_alpha); x = next_x; @@ -321,12 +319,12 @@ class Terminal::Text_screen_surface int const num_dirty_lines = last_dirty_line - first_dirty_line + 1; if (num_dirty_lines > 0) { - int const y = _geometry.start().y() + int const y = _geometry.start().y + first_dirty_line*_geometry.char_height; unsigned const h = num_dirty_lines*_geometry.char_height - + _geometry.unused_pixels().h(); + + _geometry.unused_pixels().h; - return Rect(Point(0, y), Area(_geometry.fb_size.w(),h)); + return Rect(Point(0, y), Area(_geometry.fb_size.w, h)); } return Rect(); diff --git a/repos/gems/src/server/wm/gui.h b/repos/gems/src/server/wm/gui.h index 675879b9af..69f02ac38e 100644 --- a/repos/gems/src/server/wm/gui.h +++ b/repos/gems/src/server/wm/gui.h @@ -183,7 +183,7 @@ class Wm::Gui::View : private Genode::Weak_object, using Genode::Weak_object::weak_ptr; using Genode::Weak_object::lock_for_destruction; - Point virtual_position() const { return _geometry.p1(); } + Point virtual_position() const { return _geometry.at; } virtual bool belongs_to_win_id(Window_registry::Id id) const = 0; @@ -301,12 +301,12 @@ class Wm::Gui::Top_level_view : public View, private List::Eleme _window_registry.resizeable(_win_id, _resizeable); } - _window_registry.size(_win_id, geometry.area()); + _window_registry.size(_win_id, geometry.area); View::geometry(geometry); } - Area size() const { return _geometry.area(); } + Area size() const { return _geometry.area; } void title(char const *title) override { @@ -327,12 +327,12 @@ class Wm::Gui::Top_level_view : public View, private List::Eleme Point input_anchor_position() const override { - return _content_geometry.p1(); + return _content_geometry.at; } void content_geometry(Rect rect) { - bool const position_changed = _content_geometry.p1() != rect.p1(); + bool const position_changed = _content_geometry.at != rect.at; _content_geometry = rect; @@ -541,13 +541,13 @@ class Wm::Gui::Session_component : public Rpc_object, { ev.handle_absolute_motion([&] (int x, int y) { Point const p = Point(x, y) + origin; - ev = Input::Absolute_motion{p.x(), p.y()}; + ev = Input::Absolute_motion{p.x, p.y}; }); ev.handle_touch([&] (Input::Touch_id id, float x, float y) { ev = Input::Touch { .id = id, - .x = x + (float)origin.x(), - .y = y + (float)origin.y() }; }); + .x = x + (float)origin.x, + .y = y + (float)origin.y }; }); return ev; } @@ -643,7 +643,7 @@ class Wm::Gui::Session_component : public Rpc_object, Point const pos = _pointer_pos + _input_origin(); - _input_session.submit(Input::Absolute_motion { pos.x(), pos.y() }); + _input_session.submit(Input::Absolute_motion { pos.x, pos.y }); } View &_create_view_object(View_handle parent_handle) @@ -1105,7 +1105,7 @@ class Wm::Gui::Root : public Genode::Rpc_object >, * Supply artificial mouse click to the decorator's input session * (which is routed to the layouter). */ - window_layouter_input.submit(Input::Absolute_motion{pos.x(), pos.y()}); + window_layouter_input.submit(Input::Absolute_motion{pos.x, pos.y}); window_layouter_input.submit(Input::Press{Input::BTN_LEFT}); window_layouter_input.submit(Input::Release{Input::BTN_LEFT}); } diff --git a/repos/gems/src/server/wm/main.cc b/repos/gems/src/server/wm/main.cc index 92bb23d329..69836b7c01 100644 --- a/repos/gems/src/server/wm/main.cc +++ b/repos/gems/src/server/wm/main.cc @@ -122,8 +122,8 @@ struct Wm::Main : Pointer::Tracker Reporter::Xml_generator xml(pointer_reporter, [&] () { if (pos.valid) { - xml.attribute("xpos", pos.value.x()); - xml.attribute("ypos", pos.value.y()); + xml.attribute("xpos", pos.value.x); + xml.attribute("ypos", pos.value.y); } }); } diff --git a/repos/gems/src/server/wm/window_registry.h b/repos/gems/src/server/wm/window_registry.h index 3445cf409f..5dc203e17f 100644 --- a/repos/gems/src/server/wm/window_registry.h +++ b/repos/gems/src/server/wm/window_registry.h @@ -131,8 +131,8 @@ class Wm::Window_registry xml.attribute("id", _id.value); xml.attribute("label", _attr.label.string()); xml.attribute("title", _attr.title.string()); - xml.attribute("width", _attr.size.w()); - xml.attribute("height", _attr.size.h()); + xml.attribute("width", _attr.size.w); + xml.attribute("height", _attr.size.h); if (_attr.has_alpha == HAS_ALPHA) xml.attribute("has_alpha", "yes"); diff --git a/repos/gems/src/test/text_painter/main.cc b/repos/gems/src/test/text_painter/main.cc index 81e8422a55..4af2168b4e 100644 --- a/repos/gems/src/test/text_painter/main.cc +++ b/repos/gems/src/test/text_painter/main.cc @@ -80,7 +80,7 @@ struct Test::Main Vfs_font _font_4 { _heap, _root, "fonts/regular" }; - void _refresh() { _fb.refresh(0, 0, _size.w(), _size.h()); } + void _refresh() { _fb.refresh(0, 0, _size.w, _size.h); } Main(Env &env) : _env(env) { @@ -102,7 +102,7 @@ struct Test::Main _surface.clip(Rect(Point(20, 15), Area(40, 300))); Box_painter::paint(_surface, Rect(Point(0, 0), _size), Color::rgb(150, 20, 10)); - for (int x = 0, y = -30; y < (int)_size.h() + 30; x++, y += _font_2.bounding_box().h()) + for (int x = 0, y = -30; y < (int)_size.h + 30; x++, y += _font_2.bounding_box().h) Text_painter::paint(_surface, Text_painter::Position(x, y), _font_2, Color::rgb(255, 255, 255), @@ -111,9 +111,9 @@ struct Test::Main /* test horizontal subpixel positioning */ _surface.clip(Rect(Point(90, 15), Area(100, 300))); Box_painter::paint(_surface, Rect(Point(0, 0), _size), Color::rgb(150, 20, 10)); - float const font_3_h = (float)_font_3.bounding_box().h(); + float const font_3_h = (float)_font_3.bounding_box().h; - for (float x = 90, y = -30; y < (float)_size.h() + 30; x += 0.2f, y += font_3_h) + for (float x = 90, y = -30; y < (float)_size.h + 30; x += 0.2f, y += font_3_h) Text_painter::paint(_surface, Text_painter::Position(x, y), _font_3, Color::rgb(255, 255, 255), @@ -122,7 +122,7 @@ struct Test::Main _surface.clip(Rect(Point(90, 320), Area(100, 300))); Box_painter::paint(_surface, Rect(Point(0, 0), _size), Color::rgb(255, 255, 255)); - for (float x = 90, y = 300; y < (float)_size.h() + 30; x += 0.2f, y += font_3_h) + for (float x = 90, y = 300; y < (float)_size.h + 30; x += 0.2f, y += font_3_h) Text_painter::paint(_surface, Text_painter::Position(x, y), _font_3, Color::rgb(0, 0, 0), diff --git a/repos/libports/src/app/pdf_view/main.cc b/repos/libports/src/app/pdf_view/main.cc index 75bf2ec4c3..ab0f27550b 100644 --- a/repos/libports/src/app/pdf_view/main.cc +++ b/repos/libports/src/app/pdf_view/main.cc @@ -119,10 +119,10 @@ class Pdf_view _nit_mode = _gui.mode(); - unsigned max_x = Genode::max(_nit_mode.area.w(), _fb_mode.area.w()); - unsigned max_y = Genode::max(_nit_mode.area.h(), _fb_mode.area.h()); + unsigned max_x = Genode::max(_nit_mode.area.w, _fb_mode.area.w); + unsigned max_y = Genode::max(_nit_mode.area.h, _fb_mode.area.h); - if (max_x > _fb_mode.area.w() || max_y > _fb_mode.area.h()) { + if (max_x > _fb_mode.area.w || max_y > _fb_mode.area.h) { _fb_mode = Mode { .area = { max_x, max_y } }; _gui.buffer(_fb_mode, NO_ALPHA); if (_fb_ds.constructed()) @@ -130,8 +130,8 @@ class Pdf_view _fb_ds.construct(_env.rm(), _framebuffer.dataspace()); } - _pdfapp.scrw = _nit_mode.area.w(); - _pdfapp.scrh = _nit_mode.area.h(); + _pdfapp.scrw = _nit_mode.area.w; + _pdfapp.scrh = _nit_mode.area.h; /* * XXX replace heuristics with a meaningful computation @@ -139,8 +139,8 @@ class Pdf_view * The magic values are hand-tweaked manually to accommodating the * use case of showing slides. */ - _pdfapp.resolution = Genode::min(_nit_mode.area.w()/5, - _nit_mode.area.h()/4); + _pdfapp.resolution = Genode::min(_nit_mode.area.w/5, + _nit_mode.area.h/4); typedef Gui::Session::Command Command; _gui.enqueue(_view, Rect(Point(), _nit_mode.area)); @@ -151,7 +151,7 @@ class Pdf_view void _handle_nit_mode() { _rebuffer(); - pdfapp_onresize(&_pdfapp, _nit_mode.area.w(), _nit_mode.area.h()); + pdfapp_onresize(&_pdfapp, _nit_mode.area.w, _nit_mode.area.h); } pdfapp_t _pdfapp { }; @@ -219,7 +219,7 @@ class Pdf_view void _refresh() { - _framebuffer.refresh(0, 0, _nit_mode.area.w(), _nit_mode.area.h()); + _framebuffer.refresh(0, 0, _nit_mode.area.w, _nit_mode.area.h); /* handle one sync signal only */ _framebuffer.sync_sigh(Genode::Signal_context_capability()); @@ -290,8 +290,8 @@ void Pdf_view::show() return (value >= diff) ? value - diff : 0; }; Framebuffer::Area const fb_size = _fb_mode.area; - int const x_max = Genode::min((int)fb_size.w(), reduce_by(_pdfapp.image->w, 2)); - int const y_max = Genode::min((int)fb_size.h(), _pdfapp.image->h); + int const x_max = Genode::min((int)fb_size.w, reduce_by(_pdfapp.image->w, 2)); + int const y_max = Genode::min((int)fb_size.h, _pdfapp.image->h); /* clear framebuffer */ ::memset((void *)_fb_base(), 0, _fb_ds->size()); @@ -299,7 +299,7 @@ void Pdf_view::show() Genode::size_t src_line_bytes = _pdfapp.image->n * _pdfapp.image->w; unsigned char *src_line = _pdfapp.image->samples; - Genode::size_t dst_line_width = fb_size.w(); /* in pixels */ + Genode::size_t dst_line_width = fb_size.w; /* in pixels */ pixel_t *dst_line = _fb_base(); /* skip first two lines as they contain white (XXX) */ @@ -308,12 +308,12 @@ void Pdf_view::show() int const tweaked_y_max = y_max - 2; /* center vertically if the dst buffer is higher than the image */ - if ((unsigned)_pdfapp.image->h < _nit_mode.area.h()) - dst_line += dst_line_width*((_nit_mode.area.h() - _pdfapp.image->h)/2); + if ((unsigned)_pdfapp.image->h < _nit_mode.area.h) + dst_line += dst_line_width*((_nit_mode.area.h - _pdfapp.image->h)/2); /* center horizontally if the dst buffer is wider than the image */ - if ((unsigned)_pdfapp.image->w < _nit_mode.area.w()) - dst_line += (_nit_mode.area.w() - _pdfapp.image->w)/2; + if ((unsigned)_pdfapp.image->w < _nit_mode.area.w) + dst_line += (_nit_mode.area.w - _pdfapp.image->w)/2; for (int y = 0; y < tweaked_y_max; y++) { copy_line_rgba(src_line, dst_line, x_max); diff --git a/repos/libports/src/app/usb_webcam/main.cc b/repos/libports/src/app/usb_webcam/main.cc index 7be1a71843..29c8ea015c 100644 --- a/repos/libports/src/app/usb_webcam/main.cc +++ b/repos/libports/src/app/usb_webcam/main.cc @@ -78,7 +78,7 @@ class Viewer uint8_t *framebuffer() { return _framebuffer; } void refresh() { - _gui.framebuffer()->refresh(0, 0, _mode.area.w(), _mode.area.h()); + _gui.framebuffer()->refresh(0, 0, _mode.area.w, _mode.area.h); } Framebuffer::Mode const &mode() { return _mode; } @@ -91,8 +91,8 @@ static void cb(uvc_frame_t *frame, void *ptr) if (!viewer) return; int err = 0; - int width = viewer->mode().area.w(); - int height = viewer->mode().area.h(); + int width = viewer->mode().area.w; + int height = viewer->mode().area.h; switch (frame->frame_format) { case UVC_COLOR_FORMAT_MJPEG: @@ -183,7 +183,7 @@ class Webcam uvc_stream_ctrl_t control; res = uvc_get_stream_ctrl_format_size(_handle, &control, format, - mode.area.w(), mode.area.h(), + mode.area.w, mode.area.h, fps); if (res < 0) { error("Unsupported mode: ", mode, " format: ", (unsigned)format, " fps: ", fps); diff --git a/repos/libports/src/driver/framebuffer/vesa/main.cc b/repos/libports/src/driver/framebuffer/vesa/main.cc index cb6079df31..e4dabc3f1a 100644 --- a/repos/libports/src/driver/framebuffer/vesa/main.cc +++ b/repos/libports/src/driver/framebuffer/vesa/main.cc @@ -130,8 +130,8 @@ void Vesa_driver::Main::_handle_config() Genode::print(out, "VESA mode ", size, "@", (int)BITS_PER_PIXEL); } }; - unsigned width = configured_size.w(), - height = configured_size.h(); + unsigned width = configured_size.w, + height = configured_size.h; if (Framebuffer::set_mode(width, height, BITS_PER_PIXEL) != 0) { warning("could not set ", Pretty_mode{configured_size}); diff --git a/repos/libports/src/lib/qemu-usb/webcam.cc b/repos/libports/src/lib/qemu-usb/webcam.cc index c267bc3e6e..8e07b37b7c 100644 --- a/repos/libports/src/lib/qemu-usb/webcam.cc +++ b/repos/libports/src/lib/qemu-usb/webcam.cc @@ -72,12 +72,12 @@ struct Capture_webcam if (!changed) return false; - int const src_stride_argb = _area.w() * 4; - int const dst_stride_yuy2 = _area.w() * 2; + int const src_stride_argb = _area.w * 4; + int const dst_stride_yuy2 = _area.w * 2; libyuv::ARGBToYUY2(_ds->local_addr(), src_stride_argb, reinterpret_cast(frame), dst_stride_yuy2, - _area.w(), _area.h()); + _area.w, _area.h); if (_force_update) _force_update = false; @@ -98,11 +98,11 @@ struct Capture_webcam auto const &update_fn = ([&](auto &rect) { changed = true; for (int y = rect.y1(); y <= rect.y2(); y++) { - unsigned const row = _vflip ? y : _area.h() - 1 - y; - unsigned const row_byte = (row * _area.w() * 3); + unsigned const row = _vflip ? y : _area.h - 1 - y; + unsigned const row_byte = (row * _area.w * 3); for (int x = rect.x1(); x < rect.x2(); x++) { - auto &pixel = data[y * _area.w() + x]; + auto &pixel = data[y * _area.w + x]; bgr[row_byte + x * 3 + 0] = pixel.b(); bgr[row_byte + x * 3 + 1] = pixel.g(); bgr[row_byte + x * 3 + 2] = pixel.r(); @@ -217,8 +217,8 @@ extern "C" bool capture_yuv_frame(void * pixel) extern "C" void webcam_backend_config(struct webcam_config *config) { config->fps = capture->_fps; - config->width = capture->_area.w(); - config->height = capture->_area.h(); + config->width = capture->_area.w; + config->height = capture->_area.h; } diff --git a/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc b/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc index 12ba462152..2158d1b6ae 100644 --- a/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc +++ b/repos/libports/src/test/mesa_demo/eglut/eglut_genode.cc @@ -89,7 +89,7 @@ struct Window : Genode_egl_window void refresh() { - gui.framebuffer()->refresh(0, 0, mode.area.w(), mode.area.h()); + gui.framebuffer()->refresh(0, 0, mode.area.w, mode.area.h); } }; diff --git a/repos/os/include/blit/painter.h b/repos/os/include/blit/painter.h index 3efd9d6373..b807b3b38c 100644 --- a/repos/os/include/blit/painter.h +++ b/repos/os/include/blit/painter.h @@ -35,12 +35,12 @@ struct Blit_painter if (!clipped.valid()) return; - int const src_w = texture.size().w(); - int const dst_w = surface.size().w(); + int const src_w = texture.size().w; + int const dst_w = surface.size().w; /* calculate offset of first texture pixel to copy */ - unsigned long const tex_start_offset = (clipped.y1() - position.y())*src_w - + clipped.x1() - position.x(); + unsigned long const tex_start_offset = (clipped.y1() - position.y)*src_w + + clipped.x1() - position.x; /* start address of source pixels */ PT const * const src = texture.pixel() + tex_start_offset; diff --git a/repos/os/include/decorator/window_stack.h b/repos/os/include/decorator/window_stack.h index 9d3db1ab63..c3c70e6c15 100644 --- a/repos/os/include/decorator/window_stack.h +++ b/repos/os/include/decorator/window_stack.h @@ -170,13 +170,13 @@ void Decorator::Window_stack::_draw_rec(Decorator::Canvas_base &canvas, /* draw areas around the current window */ if (Window_base const * const next = win->next()) { - Rect top, left, right, bottom; - rect.cut(clipped, &top, &left, &right, &bottom); - if (top.valid()) _draw_rec(canvas, next, top); - if (left.valid()) _draw_rec(canvas, next, left); - if (right.valid()) _draw_rec(canvas, next, right); - if (bottom.valid()) _draw_rec(canvas, next, bottom); + Rect::Cut_remainder const r = rect.cut(clipped); + + if (r.top.valid()) _draw_rec(canvas, next, r.top); + if (r.left.valid()) _draw_rec(canvas, next, r.left); + if (r.right.valid()) _draw_rec(canvas, next, r.right); + if (r.bottom.valid()) _draw_rec(canvas, next, r.bottom); } /* draw current window */ diff --git a/repos/os/include/framebuffer_session/connection.h b/repos/os/include/framebuffer_session/connection.h index 6dfd1ed1d6..7d6ac22fb2 100644 --- a/repos/os/include/framebuffer_session/connection.h +++ b/repos/os/include/framebuffer_session/connection.h @@ -34,8 +34,8 @@ struct Framebuffer::Connection : Genode::Connection, Session_client Connection(Genode::Env &env, Framebuffer::Mode mode) : Genode::Connection(env, Label(), Ram_quota { 8*1024 }, - Args("fb_width=", mode.area.w(), ", " - "fb_height=", mode.area.h())), + Args("fb_width=", mode.area.w, ", " + "fb_height=", mode.area.h)), Session_client(cap()) { } }; diff --git a/repos/os/include/nitpicker_gfx/box_painter.h b/repos/os/include/nitpicker_gfx/box_painter.h index 2e38d21e41..8f9c3ed33a 100644 --- a/repos/os/include/nitpicker_gfx/box_painter.h +++ b/repos/os/include/nitpicker_gfx/box_painter.h @@ -37,17 +37,17 @@ struct Box_painter if (!clipped.valid()) return; PT pix(color.r, color.g, color.b); - PT *dst, *dst_line = surface.addr() + surface.size().w()*clipped.y1() + clipped.x1(); + PT *dst, *dst_line = surface.addr() + surface.size().w*clipped.y1() + clipped.x1(); int const alpha = color.a; if (color.opaque()) - for (int w, h = clipped.h() ; h--; dst_line += surface.size().w()) + for (unsigned w, h = clipped.h() ; h--; dst_line += surface.size().w) for (dst = dst_line, w = clipped.w(); w--; dst++) *dst = pix; else if (!color.transparent()) - for (int w, h = clipped.h() ; h--; dst_line += surface.size().w()) + for (unsigned w, h = clipped.h() ; h--; dst_line += surface.size().w) for (dst = dst_line, w = clipped.w(); w--; dst++) *dst = PT::mix(*dst, pix, alpha); diff --git a/repos/os/include/nitpicker_gfx/glyph_painter.h b/repos/os/include/nitpicker_gfx/glyph_painter.h index 7f4e5b4045..511e1ecda3 100644 --- a/repos/os/include/nitpicker_gfx/glyph_painter.h +++ b/repos/os/include/nitpicker_gfx/glyph_painter.h @@ -77,8 +77,8 @@ struct Glyph_painter int const clip_left, int const clip_right, PT const color, int const alpha) { - Fixpoint_number const x = position.x(); - int const y = position.y().decimal(); + Fixpoint_number const x = position.x; + int const y = position.y.decimal(); int const dst_y1 = y + glyph.vpos, dst_y2 = dst_y1 + glyph.height; diff --git a/repos/os/include/nitpicker_gfx/text_painter.h b/repos/os/include/nitpicker_gfx/text_painter.h index 3e1c7d0d5e..e76702d213 100644 --- a/repos/os/include/nitpicker_gfx/text_painter.h +++ b/repos/os/include/nitpicker_gfx/text_painter.h @@ -126,8 +126,8 @@ struct Text_painter char const *string) { /* use sub-pixel positioning horizontally */ - Fixpoint_number x = position.x(); - Fixpoint_number const y = position.y(); + Fixpoint_number x = position.x; + Fixpoint_number const y = position.y; int const clip_top = surface.clip().y1(), clip_bottom = surface.clip().y2() + 1, @@ -149,7 +149,7 @@ struct Text_painter int const x_start = x.decimal(); - unsigned const dst_line_len = surface.size().w(); + unsigned const dst_line_len = surface.size().w; PT * const dst = surface.addr(); @@ -171,7 +171,7 @@ struct Text_painter surface.flush_pixels(Rect(Point(x_start, y.decimal()), Area(x.decimal() - x_start + 1, - font.bounding_box().h()))); + font.bounding_box().h))); } }; diff --git a/repos/os/include/nitpicker_gfx/texture_painter.h b/repos/os/include/nitpicker_gfx/texture_painter.h index d97a5779cd..c4545924f4 100644 --- a/repos/os/include/nitpicker_gfx/texture_painter.h +++ b/repos/os/include/nitpicker_gfx/texture_painter.h @@ -56,12 +56,12 @@ struct Texture_painter if (!clipped.valid()) return; - int const src_w = texture.size().w(); - int const dst_w = surface.size().w(); + int const src_w = texture.size().w; + int const dst_w = surface.size().w; /* calculate offset of first texture pixel to copy */ - unsigned long tex_start_offset = (clipped.y1() - position.y())*src_w - + clipped.x1() - position.x(); + unsigned long tex_start_offset = (clipped.y1() - position.y)*src_w + + clipped.x1() - position.x; /* start address of source pixels */ PT const *src = texture.pixel() + tex_start_offset; diff --git a/repos/os/include/nitpicker_gfx/tff_font.h b/repos/os/include/nitpicker_gfx/tff_font.h index 39198c809b..4569a9e7f1 100644 --- a/repos/os/include/nitpicker_gfx/tff_font.h +++ b/repos/os/include/nitpicker_gfx/tff_font.h @@ -231,10 +231,7 @@ class Tff_font : public Text_painter::Font return m.vpos + m.height; } - unsigned height() const override - { - return _bounding_box.h(); - } + unsigned height() const override { return _bounding_box.h; } Area bounding_box() const override { return _bounding_box; } }; diff --git a/repos/os/include/os/surface.h b/repos/os/include/os/surface.h index 6cdda53292..881f32593c 100644 --- a/repos/os/include/os/surface.h +++ b/repos/os/include/os/surface.h @@ -30,7 +30,7 @@ namespace Genode { * applied. All coordinates are specified in pixels. The coordinate origin * is the top-left corner of the surface. */ -class Genode::Surface_base +class Genode::Surface_base : Interface { private: @@ -42,10 +42,9 @@ class Genode::Surface_base public: - typedef Genode::Point<> Point; - typedef Genode::Area<> Area; - typedef Genode::Rect<> Rect; - typedef Genode::Color Color; + using Rect = Genode::Rect<>; + using Point = Rect::Point; + using Area = Rect::Area; enum Pixel_format { UNKNOWN, RGB565, RGB888, ALPHA8 }; @@ -56,21 +55,18 @@ class Genode::Surface_base protected: - Rect _clip; /* clipping area */ - Area _size; /* boundaries of surface */ - Pixel_format _format; - Flusher *_flusher; + Area const _size; /* boundaries of surface */ + Pixel_format const _format; + + Flusher *_flusher = nullptr; + + Rect _clip = Rect(Point(), _size); - /** - * Constructor - */ Surface_base(Area size, Pixel_format format) - : _clip(Point(0, 0), size), _size(size), _format(format), _flusher(0) { } + : _size(size), _format(format) { } public: - virtual ~Surface_base() { } - /** * Register part of surface to be flushed * @@ -91,8 +87,10 @@ class Genode::Surface_base /** * Define/request clipping rectangle */ - void clip(Rect clip) { - _clip = Rect::intersect(Rect(Point(0, 0), _size), clip); } + void clip(Rect clip) + { + _clip = Rect::intersect(Rect(Point(), _size), clip); + } Rect clip() const { return _clip; } bool clip_valid() const { return _clip.valid(); } diff --git a/repos/os/include/os/texture_rgb888.h b/repos/os/include/os/texture_rgb888.h index ff195eedf9..7458e39968 100644 --- a/repos/os/include/os/texture_rgb888.h +++ b/repos/os/include/os/texture_rgb888.h @@ -24,11 +24,11 @@ namespace Genode { inline void Texture::rgba(unsigned char const *rgba, size_t len, int y) { - if (len > size().w()) len = size().w(); - if (y < 0 || y >= (int)size().h()) return; + if (len > size().w) len = size().w; + if (y < 0 || y >= (int)size().h) return; - Pixel_rgb888 *dst_pixel = pixel() + y*size().w(); - unsigned char *dst_alpha = alpha() ? alpha() + y*size().w() : 0; + Pixel_rgb888 *dst_pixel = pixel() + y*size().w; + unsigned char *dst_alpha = alpha() ? alpha() + y*size().w : 0; for (unsigned i = 0; i < len; i++) { diff --git a/repos/os/include/pointer/dither_painter.h b/repos/os/include/pointer/dither_painter.h index 2779bec188..ce0d0dac28 100644 --- a/repos/os/include/pointer/dither_painter.h +++ b/repos/os/include/pointer/dither_painter.h @@ -34,13 +34,13 @@ struct Dither_painter if (!clipped.valid()) return; - unsigned const offset = surface.size().w()*clipped.y1() + clipped.x1(); + unsigned const offset = surface.size().w*clipped.y1() + clipped.x1(); DST_PT *dst, *dst_line = surface.addr() + offset; SRC_PT const *src_pixel, *src_pixel_line = texture.pixel() + offset; unsigned char const *src_alpha, *src_alpha_line = texture.alpha() + offset; - unsigned const line_len = surface.size().w(); + unsigned const line_len = surface.size().w; for (int y = clipped.y1(), h = clipped.h() ; h--; y++) { diff --git a/repos/os/include/util/dirty_rect.h b/repos/os/include/util/dirty_rect.h index b37eaf2a09..2a487b1131 100644 --- a/repos/os/include/util/dirty_rect.h +++ b/repos/os/include/util/dirty_rect.h @@ -41,8 +41,8 @@ class Genode::Dirty_rect */ static bool _should_be_merged(Rect const &r1, Rect const &r2) { - size_t const cnt_sum = r1.area().count() + r2.area().count(); - size_t const cnt_compound = Rect::compound(r1, r2).area().count(); + size_t const cnt_sum = r1.area.count() + r2.area.count(); + size_t const cnt_compound = Rect::compound(r1, r2).area.count(); return cnt_compound < cnt_sum; } @@ -57,7 +57,7 @@ class Genode::Dirty_rect * added rectangle. */ if (!existing.valid()) - return added.area().count(); + return added.area.count(); /* * If the existing rectangle is already populated, the costs @@ -65,8 +65,8 @@ class Genode::Dirty_rect * existing rectangle by the compound of the existing and new * rectangles. */ - return Rect::compound(existing, added).area().count() - - existing.area().count(); + return Rect::compound(existing, added).area.count() + - existing.area.count(); } public: diff --git a/repos/os/include/util/geometry.h b/repos/os/include/util/geometry.h deleted file mode 100644 index 1637b9d962..0000000000 --- a/repos/os/include/util/geometry.h +++ /dev/null @@ -1,256 +0,0 @@ -/* - * \brief Geometric primitives - * \author Norman Feske - * \date 2006-08-05 - */ - -/* - * Copyright (C) 2006-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#ifndef _INCLUDE__UTIL__GEOMETRY_H_ -#define _INCLUDE__UTIL__GEOMETRY_H_ - -#include -#include -#include -#include - -namespace Genode { - template class Point; - template class Area; - template class Rect; -} - - -/** - * \param CT coordinate type - */ -template -class Genode::Point -{ - private: - - CT _x, _y; - - public: - - Point(CT x, CT y): _x(x), _y(y) { } - Point(): _x(0), _y(0) { } - - CT x() const { return _x; } - CT y() const { return _y; } - - /** - * Operator for adding points - */ - Point operator + (Point const &p) const { return Point(_x + p.x(), _y + p.y()); } - - /** - * Operator for subtracting points - */ - Point operator - (Point const &p) const { return Point(_x - p.x(), _y - p.y()); } - - /** - * Operator for testing non-equality of two points - */ - bool operator != (Point const &p) const { return p.x() != _x || p.y() != _y; } - - /** - * Operator for testing equality of two points - */ - bool operator == (Point const &p) const { return p.x() == _x && p.y() == _y; } - - void print(Output &out) const - { - auto abs = [] (auto v) { return v >= 0 ? v : -v; }; - - Genode::print(out, _x >= 0 ? "+" : "-", abs(_x), - _y >= 0 ? "+" : "-", abs(_y)); - } - - /** - * Construct point from XML node attributes - * - * The XML node is expected to feature the attributes 'xpos' and 'ypos'. - */ - static Point from_xml(Xml_node const &node) - { - return Point((CT)node.attribute_value("xpos", (CT)0), - (CT)node.attribute_value("ypos", (CT)0)); - } -}; - - -/** - * \param DT distance type - */ -template -class Genode::Area -{ - private: - - DT _w, _h; - - public: - - Area(DT w, DT h): _w(w), _h(h) { } - Area(): _w(0), _h(0) { } - - DT w() const { return _w; } - DT h() const { return _h; } - - bool valid() const { return _w > 0 && _h > 0; } - - size_t count() const { return (size_t)_w*(size_t)_h; } - - /** - * Operator for testing non-equality of two areas - */ - bool operator != (Area const &a) const { return a.w() != _w || a.h() != _h; } - - /** - * Operator for testing equality of two areas - */ - bool operator == (Area const &a) const { return a.w() == _w && a.h() == _h; } - - void print(Output &out) const { Genode::print(out, _w, "x", _h); } - - /** - * Construct area from XML node attributes - * - * The XML node is expected to feature the attributes 'width' and - * 'height'. - */ - static Area from_xml(Xml_node const &node) - { - return Area((DT)node.attribute_value("width", (DT)0), - (DT)node.attribute_value("height", (DT)0)); - } -}; - - -/** - * Rectangle - * - * A valid rectangle consists of two points wheras point 2 has higher or equal - * coordinates than point 1. All other cases are threated as invalid - * rectangles. - * - * \param CT coordinate type - * \param DT distance type - */ -template -class Genode::Rect -{ - private: - - Point _p1, _p2; - - public: - - /** - * Constructors - */ - Rect(Point p1, Point p2): _p1(p1), _p2(p2) { } - - Rect(Point p, Area
a) - : _p1(p), _p2(p.x() + a.w() - 1, p.y() + a.h() - 1) { } - - Rect() : /* invalid */ _p1(1, 1), _p2(0, 0) { } - - /** - * Accessors - */ - CT x1() const { return _p1.x(); } - CT y1() const { return _p1.y(); } - CT x2() const { return _p2.x(); } - CT y2() const { return _p2.y(); } - DT w() const { return _p2.x() - _p1.x() + 1; } - DT h() const { return _p2.y() - _p1.y() + 1; } - Point p1() const { return _p1; } - Point p2() const { return _p2; } - Area
area() const { return Area
(w(), h()); } - - /** - * Return true if rectangle area is greater than zero - */ - bool valid() const { return _p1.x() <= _p2.x() && _p1.y() <= _p2.y(); } - - /** - * Return true if area fits in rectangle - */ - bool fits(Area
area) const { return w() >= area.w() && h() >= area.h(); } - - /** - * Return true if the specified point lies within the rectangle - */ - bool contains(Point p) const { - return p.x() >= x1() && p.x() <= x2() && p.y() >= y1() && p.y() <= y2(); } - - /** - * Create new rectangle by intersecting two rectangles - */ - static Rect intersect(Rect r1, Rect r2) { - return Rect(Point(max(r1.x1(), r2.x1()), max(r1.y1(), r2.y1())), - Point(min(r1.x2(), r2.x2()), min(r1.y2(), r2.y2()))); } - - /** - * Compute compounding rectangle of two rectangles - */ - static Rect compound(Rect r1, Rect r2) { - return Rect(Point(min(r1.x1(), r2.x1()), min(r1.y1(), r2.y1())), - Point(max(r1.x2(), r2.x2()), max(r1.y2(), r2.y2()))); } - - /** - * Cut out rectangle from rectangle - * - * \param r rectangle to cut out - * - * In the worst case (if we cut a hole into the rectangle) we get - * four valid resulting rectangles. - */ - void cut(Rect r, Rect *top, Rect *left, Rect *right, Rect *bottom) const - { - /* limit the cut-out area to the actual rectangle */ - r = intersect(r, *this); - - *top = Rect(Point(x1(), y1()), Point(x2(), r.y1() - 1)); - *left = Rect(Point(x1(), r.y1()), Point(r.x1() - 1, r.y2())); - *right = Rect(Point(r.x2() + 1, r.y1()), Point(x2(), r.y2())); - *bottom = Rect(Point(x1(), r.y2() + 1), Point(x2(), y2())); - } - - /** - * Return position of an area when centered within the rectangle - */ - Point center(Area
area) const { - return Point(((CT)w() - (CT)area.w())/2, - ((CT)h() - (CT)area.h())/2) + p1(); } - - /** - * Print rectangle coordinates - * - * The output has the form 'width' x 'height' +/- 'p1.x' +/- 'p1.y'. - * For example, a rectange of size 15x16 as position (-13, 14) is - * printed as "15x16-13+14". - */ - void print(Output &out) const { Genode::print(out, area(), p1()); } - - /** - * Construct rectangle from XML node attributes - * - * The XML node is expected to feature the attributes 'xpos', 'ypos'. - * 'width', and 'height'. If an attribute is absent, the corresponding - * value is set to 0. - */ - static Rect from_xml(Xml_node const &node) - { - return Rect(Point::from_xml(node), Area
::from_xml(node)); - } -}; - -#endif /* _INCLUDE__UTIL__GEOMETRY_H_ */ diff --git a/repos/os/src/app/pointer/main.cc b/repos/os/src/app/pointer/main.cc index 8b90366960..cefd59f21c 100644 --- a/repos/os/src/app/pointer/main.cc +++ b/repos/os/src/app/pointer/main.cc @@ -39,14 +39,14 @@ void convert_default_pointer_data_to_pixels(PT *pixel, Gui::Area size) { unsigned char *alpha = (unsigned char *)(pixel + size.count()); - for (unsigned y = 0; y < size.h(); y++) { - for (unsigned x = 0; x < size.w(); x++) { + for (unsigned y = 0; y < size.h; y++) { + for (unsigned x = 0; x < size.w; x++) { /* the source is known to be in RGB888 format */ Genode::Pixel_rgb565 src = *(Genode::Pixel_rgb565 *)(&big_mouse.pixels[y][x]); - unsigned const i = y*size.w() + x; + unsigned const i = y*size.w + x; pixel[i] = PT(src.r(), src.g(), src.b()); alpha[i] = src.r() ? 255 : 0; } @@ -155,7 +155,7 @@ void Pointer::Main::_show_default_pointer() _resize_gui_buffer_if_needed(pointer_size); } catch (...) { Genode::error(__func__, ": could not resize the pointer buffer " - "for ", pointer_size.w(), "x", pointer_size.h(), " pixels"); + "for ", pointer_size.w, "x", pointer_size.h, " pixels"); return; } @@ -163,7 +163,7 @@ void Pointer::Main::_show_default_pointer() convert_default_pointer_data_to_pixels(ds.local_addr(), pointer_size); - _gui.framebuffer()->refresh(0, 0, pointer_size.w(), pointer_size.h()); + _gui.framebuffer()->refresh(0, 0, pointer_size.w, pointer_size.h); Gui::Rect geometry(Gui::Point(0, 0), pointer_size); _gui.enqueue(_view, geometry); @@ -200,12 +200,12 @@ void Pointer::Main::_show_shape_pointer(Shape_report &shape_report) _texture_alpha_ds.local_addr(), shape_size); - for (unsigned int y = 0; y < shape_size.h(); y++) { + for (unsigned int y = 0; y < shape_size.h; y++) { /* import the RGBA-encoded line into the texture */ unsigned char *shape = shape_report.shape; - unsigned char *line = &shape[y * shape_size.w() * 4]; - texture.rgba(line, shape_size.w(), y); + unsigned char *line = &shape[y * shape_size.w * 4]; + texture.rgba(line, shape_size.w, y); } /* draw texture */ @@ -224,7 +224,7 @@ void Pointer::Main::_show_shape_pointer(Shape_report &shape_report) Dither_painter::paint(alpha_surface, texture); } - _gui.framebuffer()->refresh(0, 0, shape_size.w(), shape_size.h()); + _gui.framebuffer()->refresh(0, 0, shape_size.w, shape_size.h); Gui::Rect geometry(shape_hot, shape_size); _gui.enqueue(_view, geometry); diff --git a/repos/os/src/app/status_bar/main.cc b/repos/os/src/app/status_bar/main.cc index 4cf33d1d95..26cfd6e694 100644 --- a/repos/os/src/app/status_bar/main.cc +++ b/repos/os/src/app/status_bar/main.cc @@ -51,7 +51,7 @@ struct Status_bar::Buffer * The status bar is as wide as nitpicker's screen and has a fixed * height. */ - Framebuffer::Mode const _mode { .area = { _nit_mode.area.w(), HEIGHT } }; + Framebuffer::Mode const _mode { .area = { _nit_mode.area.w, HEIGHT } }; Dataspace_capability _init_buffer() { @@ -76,7 +76,7 @@ struct Status_bar::Buffer for (int i = -1; i <= 1; i++) if (i || j) Text_painter::paint(surface, - Text_painter::Position(pos.x() + i, pos.y() + j), + Text_painter::Position(pos.x + i, pos.y + j), _font, Color::black(), s); } @@ -93,13 +93,13 @@ struct Status_bar::Buffer pos = pos + Point(1, 1); _draw_outline(surface, pos, domain_name.string()); - Text_painter::paint(surface, Text_painter::Position(pos.x(), pos.y()), + Text_painter::paint(surface, Text_painter::Position(pos.x, pos.y), _font, domain_text_color, domain_name.string()); pos = pos + Point(_font.string_width(domain_name.string()).decimal() + LABEL_GAP, 0); _draw_outline(surface, pos, label.string()); - Text_painter::paint(surface, Text_painter::Position(pos.x(), pos.y()), + Text_painter::paint(surface, Text_painter::Position(pos.x, pos.y), _font, label_text_color, label.string()); } @@ -107,7 +107,7 @@ struct Status_bar::Buffer { return Area(_font.string_width(domain_name.string()).decimal() + LABEL_GAP + _font.string_width(label.string()).decimal() + 2, - _font.bounding_box().h() + 2); + _font.bounding_box().h + 2); } void draw(Domain_name const &, Label const &, Color); @@ -139,7 +139,7 @@ void Status_bar::Buffer::draw(Domain_name const &domain_name, Color::clamped_rgb(r + (r / 2), g + (g / 2), b + (b / 2))); /* draw slightly shaded background */ - for (unsigned i = 1; i < area.h() - 1; i++) { + for (unsigned i = 1; i < area.h - 1; i++) { r -= r > 3 ? 4 : 0; g -= g > 3 ? 4 : 0; b -= b > 4 ? 4 : 0; @@ -157,7 +157,7 @@ void Status_bar::Buffer::draw(Domain_name const &domain_name, _draw_label(surface, view_rect.center(_label_size(domain_name, label)), domain_name, label, color); - _gui.framebuffer()->refresh(0, 0, area.w(), area.h()); + _gui.framebuffer()->refresh(0, 0, area.w, area.h); } diff --git a/repos/os/src/driver/framebuffer/boot/main.cc b/repos/os/src/driver/framebuffer/boot/main.cc index 77d15dd28a..02f3511e3b 100644 --- a/repos/os/src/driver/framebuffer/boot/main.cc +++ b/repos/os/src/driver/framebuffer/boot/main.cc @@ -83,7 +83,7 @@ struct Framebuffer::Main bool const _checked_info = ( _check_info(), true ); Attached_io_mem_dataspace _fb_ds { _env, _info.addr, - _info.pitch*_info.size.h(), true }; + _info.pitch*_info.size.h, true }; Capture::Connection _capture { _env }; @@ -95,7 +95,7 @@ struct Framebuffer::Main void _handle_timer() { - Area const phys_size { (uint32_t)(_info.pitch/sizeof(Pixel)), _info.size.h() }; + Area const phys_size { (uint32_t)(_info.pitch/sizeof(Pixel)), _info.size.h }; Surface surface(_fb_ds.local_addr(), phys_size); diff --git a/repos/os/src/driver/framebuffer/sdl/main.cc b/repos/os/src/driver/framebuffer/sdl/main.cc index ce90bb9489..7376dcf44e 100644 --- a/repos/os/src/driver/framebuffer/sdl/main.cc +++ b/repos/os/src/driver/framebuffer/sdl/main.cc @@ -84,7 +84,7 @@ struct Fb_sdl::Main { unsigned const window_flags = 0; - SDL_Window *window_ptr = SDL_CreateWindow("fb_sdl", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, _initial_size.w(), _initial_size.h(), window_flags); + SDL_Window *window_ptr = SDL_CreateWindow("fb_sdl", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, _initial_size.w, _initial_size.h, window_flags); if (!window_ptr) { error("SDL_CreateWindow failed (", Genode::Cstring(SDL_GetError()), ")"); throw Sdl_createwindow_failed(); @@ -133,7 +133,7 @@ struct Fb_sdl::Main unsigned const blue_mask = 0x000000FF; unsigned const alpha_mask = 0xFF000000; - SDL_Surface *surface_ptr = SDL_CreateRGBSurface(flags, size.w(), size.h(), bpp, red_mask, green_mask, blue_mask, alpha_mask); + SDL_Surface *surface_ptr = SDL_CreateRGBSurface(flags, size.w, size.h, bpp, red_mask, green_mask, blue_mask, alpha_mask); if (!surface_ptr) { error("SDL_CreateRGBSurface failed (", Genode::Cstring(SDL_GetError()), ")"); throw Sdl_creatergbsurface_failed(); @@ -144,7 +144,7 @@ struct Fb_sdl::Main SDL_Texture &_init_sdl_texture() { - SDL_Texture *texture_ptr = SDL_CreateTexture(&renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, size.w(), size.h()); + SDL_Texture *texture_ptr = SDL_CreateTexture(&renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, size.w, size.h); if (!texture_ptr) { error("SDL_CreateTexture failed (", Genode::Cstring(SDL_GetError()), ")"); throw Sdl_createtexture_failed(); diff --git a/repos/os/src/driver/framebuffer/virtio/component.h b/repos/os/src/driver/framebuffer/virtio/component.h index ddf88ee843..6f1210aa94 100644 --- a/repos/os/src/driver/framebuffer/virtio/component.h +++ b/repos/os/src/driver/framebuffer/virtio/component.h @@ -191,7 +191,7 @@ class Virtio_fb::Driver Fb_memory_resource &operator = (Fb_memory_resource const &) = delete; static size_t _fb_size(Capture::Area const &area) { - return area.w() * area.h() * 4; } + return area.w * area.h * 4; } public: @@ -310,8 +310,8 @@ class Virtio_fb::Driver void _configure_display() { Control_header res2d_cmd { Control_header::CMD_RESOURCE_CREATE_2D }; Resource_create_2d res2d_data { - .width = _display_area.w(), - .height = _display_area.h(), + .width = _display_area.w, + .height = _display_area.h, }; if (!_exec_cmd(res2d_cmd, res2d_data)) { @@ -344,8 +344,8 @@ class Virtio_fb::Driver .rect = { .x = 0, .y = 0, - .width = _display_area.w(), - .height = _display_area.h(), + .width = _display_area.w, + .height = _display_area.h, }, .scanout_id = _selected_scanout_id, }; @@ -486,8 +486,8 @@ class Virtio_fb::Driver .rect = { .x = 0, .y = 0, - .width = _display_area.w(), - .height = _display_area.h(), + .width = _display_area.w, + .height = _display_area.h, }, .offset = 0, }; @@ -501,8 +501,8 @@ class Virtio_fb::Driver .rect = { .x = 0, .y = 0, - .width = _display_area.w(), - .height = _display_area.h(), + .width = _display_area.w, + .height = _display_area.h, }, }; if (!_exec_cmd(flush_cmd, flush_data)) { diff --git a/repos/os/src/server/gui_fb/main.cc b/repos/os/src/server/gui_fb/main.cc index 911200f79f..d2d4465bd0 100644 --- a/repos/os/src/server/gui_fb/main.cc +++ b/repos/os/src/server/gui_fb/main.cc @@ -50,20 +50,20 @@ static Input::Event translate_event(Input::Event ev, /* function to clamp point to bounday */ auto clamp = [boundary] (Point p) { - return Point(Genode::min((int)boundary.w() - 1, Genode::max(0, p.x())), - Genode::min((int)boundary.h() - 1, Genode::max(0, p.y()))); }; + return Point(Genode::min((int)boundary.w - 1, Genode::max(0, p.x)), + Genode::min((int)boundary.h - 1, Genode::max(0, p.y))); }; /* function to translate point to 'input_origin' */ auto translate = [input_origin] (Point p) { return p - input_origin; }; ev.handle_absolute_motion([&] (int x, int y) { Point p = clamp(translate(Point(x, y))); - ev = Input::Absolute_motion{p.x(), p.y()}; + ev = Input::Absolute_motion{p.x, p.y}; }); ev.handle_touch([&] (Input::Touch_id id, float x, float y) { Point p = clamp(translate(Point((int)x, (int)y))); - ev = Input::Touch{id, (float)p.x(), (float)p.y()}; + ev = Input::Touch{id, (float)p.x, (float)p.y}; }); return ev; @@ -148,7 +148,7 @@ struct Framebuffer::Session_component : Genode::Rpc_object void size(Gui::Area size) { /* ignore calls that don't change the size */ - if (Gui::Area(_next_mode.area.w(), _next_mode.area.h()) == size) + if (Gui::Area(_next_mode.area.w, _next_mode.area.h) == size) return; Framebuffer::Mode const mode { .area = size }; @@ -266,15 +266,15 @@ struct Nit_fb::Main : View_updater unsigned width(Framebuffer::Mode const &mode) const { if (_width > 0) return (unsigned)_width; - if (_width < 0) return (unsigned)(mode.area.w() + _width); - return mode.area.w(); + if (_width < 0) return (unsigned)(mode.area.w + _width); + return mode.area.w; } unsigned height(Framebuffer::Mode const &mode) const { if (_height > 0) return (unsigned)_height; - if (_height < 0) return (unsigned)(mode.area.h() + _height); - return mode.area.h(); + if (_height < 0) return (unsigned)(mode.area.h + _height); + return mode.area.h; } bool valid() const { return _width != 0 && _height != 0; } @@ -324,9 +324,9 @@ struct Nit_fb::Main : View_updater Value const value = config.attribute_value(attr, Value()); if (value == "top_left") return Point(0, 0); - if (value == "top_right") return Point(mode.area.w(), 0); - if (value == "bottom_left") return Point(0, mode.area.h()); - if (value == "bottom_right") return Point(mode.area.w(), mode.area.h()); + if (value == "top_right") return Point(mode.area.w, 0); + if (value == "bottom_left") return Point(0, mode.area.h); + if (value == "bottom_right") return Point(mode.area.w, mode.area.h); warning("unsupported ", attr, " attribute value '", value, "'"); return Point(0, 0); @@ -351,11 +351,11 @@ struct Nit_fb::Main : View_updater _initial_size.set = true; } - unsigned const gui_width = gui_mode.area.w(); - unsigned const gui_height = gui_mode.area.h(); + unsigned const gui_width = gui_mode.area.w; + unsigned const gui_height = gui_mode.area.h; - long width = config.attribute_value("width", (long)gui_mode.area.w()), - height = config.attribute_value("height", (long)gui_mode.area.h()); + long width = config.attribute_value("width", (long)gui_mode.area.w), + height = config.attribute_value("height", (long)gui_mode.area.h); if (!_initial_size.set && _initial_size.valid()) { width = _initial_size.width (gui_mode); diff --git a/repos/os/src/server/nitpicker/canvas.h b/repos/os/src/server/nitpicker/canvas.h index b5225f26c6..7da3294da6 100644 --- a/repos/os/src/server/nitpicker/canvas.h +++ b/repos/os/src/server/nitpicker/canvas.h @@ -82,17 +82,17 @@ class Nitpicker::Canvas : public Canvas_base, public Surface_base::Flusher Rect clip() const override { Rect const clip_rect = _surface.clip(); - return Rect(clip_rect.p1() + _offset, clip_rect.area()); + return Rect(clip_rect.p1() + _offset, clip_rect.area); } void clip(Rect rect) override { - _surface.clip(Rect(rect.p1() - _offset, rect.area())); + _surface.clip(Rect(rect.p1() - _offset, rect.area)); } void draw_box(Rect rect, Color color) override { - Box_painter::paint(_surface, Rect(rect.p1() - _offset, rect.area()), color); + Box_painter::paint(_surface, Rect(rect.p1() - _offset, rect.area), color); } void draw_texture(Point pos, Texture_base const &texture_base, @@ -108,7 +108,7 @@ class Nitpicker::Canvas : public Canvas_base, public Surface_base::Flusher Color color, char const *string) override { pos = pos - _offset; - Text_painter::paint(_surface, Text_painter::Position(pos.x(), pos.y()), + Text_painter::paint(_surface, Text_painter::Position(pos.x, pos.y), font, color, string); } }; diff --git a/repos/os/src/server/nitpicker/capture_session.h b/repos/os/src/server/nitpicker/capture_session.h index b0435a0f69..66490249c6 100644 --- a/repos/os/src/server/nitpicker/capture_session.h +++ b/repos/os/src/server/nitpicker/capture_session.h @@ -83,7 +83,6 @@ class Nitpicker::Capture_session : public Session_object void mark_as_damaged(Rect rect) { - // XXX not called yet _dirty_rect.mark_as_dirty(rect); } @@ -150,7 +149,7 @@ class Nitpicker::Capture_session : public Session_object _view_stack.draw(canvas, rect); if (i < Affected_rects::NUM_RECTS) { - Rect const translated(rect.p1() - pos, rect.area()); + Rect const translated(rect.p1() - pos, rect.area); Rect const clipped = Rect::intersect(translated, buffer_rect); affected.rects[i++] = clipped; } diff --git a/repos/os/src/server/nitpicker/chunky_texture.h b/repos/os/src/server/nitpicker/chunky_texture.h index fb703ed6bc..9e637fdc58 100644 --- a/repos/os/src/server/nitpicker/chunky_texture.h +++ b/repos/os/src/server/nitpicker/chunky_texture.h @@ -56,7 +56,7 @@ class Nitpicker::Chunky_texture : public Buffer, public Texture * alpha value and one byte for the input mask value. */ size_t bytes_per_pixel = sizeof(PT) + (use_alpha ? 2 : 0); - return bytes_per_pixel*size.w()*size.h(); + return bytes_per_pixel*size.count(); } unsigned char const *input_mask_buffer() const diff --git a/repos/os/src/server/nitpicker/domain_registry.h b/repos/os/src/server/nitpicker/domain_registry.h index 23e21d1851..d1af325b9f 100644 --- a/repos/os/src/server/nitpicker/domain_registry.h +++ b/repos/os/src/server/nitpicker/domain_registry.h @@ -68,15 +68,15 @@ class Nitpicker::Domain_registry _origin(origin), _layer(layer), _offset(offset), _area(area) { } - Point _corner(Area screen_area) const + Point _corner(Area const screen_area) const { switch (_origin) { case ORIGIN_POINTER: return Point(0, 0); case ORIGIN_TOP_LEFT: return Point(0, 0); - case ORIGIN_TOP_RIGHT: return Point(screen_area.w(), 0); - case ORIGIN_BOTTOM_LEFT: return Point(0, screen_area.h()); - case ORIGIN_BOTTOM_RIGHT: return Point(screen_area.w(), - screen_area.h()); + case ORIGIN_TOP_RIGHT: return Point(screen_area.w, 0); + case ORIGIN_BOTTOM_LEFT: return Point(0, screen_area.h); + case ORIGIN_BOTTOM_RIGHT: return Point(screen_area.w, + screen_area.h); } return Point(0, 0); } @@ -106,13 +106,13 @@ class Nitpicker::Domain_registry Area screen_area(Area phys_screen_area) const { - int const w = _area.x() > 0 - ? _area.x() - : max(0, (int)phys_screen_area.w() + _area.x()); + int const w = _area.x > 0 + ? _area.x + : max(0, (int)phys_screen_area.w + _area.x); - int const h = _area.y() > 0 - ? _area.y() - : max(0, (int)phys_screen_area.h() + _area.y()); + int const h = _area.y > 0 + ? _area.y + : max(0, (int)phys_screen_area.h + _area.y); return Area(w, h); } diff --git a/repos/os/src/server/nitpicker/draw_label.h b/repos/os/src/server/nitpicker/draw_label.h index b66c1005b4..bbe0bc952e 100644 --- a/repos/os/src/server/nitpicker/draw_label.h +++ b/repos/os/src/server/nitpicker/draw_label.h @@ -47,7 +47,7 @@ namespace Nitpicker { inline Area label_size(Font const &font, const char *sl, const char *vt) { return Area(font.string_width(sl).decimal() + LABEL_GAP + font.string_width(vt).decimal() + 2, - font.bounding_box().h() + 2); } + font.bounding_box().h + 2); } /** diff --git a/repos/os/src/server/nitpicker/gui_session.cc b/repos/os/src/server/nitpicker/gui_session.cc index 2efed5eded..9b78fefbc4 100644 --- a/repos/os/src/server/nitpicker/gui_session.cc +++ b/repos/os/src/server/nitpicker/gui_session.cc @@ -76,7 +76,7 @@ void Gui_session::_execute_command(Command const &command) pos = _phys_pos(pos, _view_stack.size()); if (view.valid()) - _view_stack.geometry(*view, Rect(pos, cmd.rect.area())); + _view_stack.geometry(*view, Rect(pos, cmd.rect.area)); return; } @@ -221,11 +221,11 @@ void Gui_session::submit_input_event(Input::Event e) * Transpose absolute coordinates by session-specific vertical offset. */ e.handle_absolute_motion([&] (int x, int y) { - e = Absolute_motion{max(0, x - origin_offset.x()), - max(0, y - origin_offset.y())}; }); + e = Absolute_motion{max(0, x - origin_offset.x), + max(0, y - origin_offset.y)}; }); e.handle_touch([&] (Touch_id id, float x, float y) { - e = Touch{ id, max(0.0f, x - (float)origin_offset.x()), - max(0.0f, y - (float)origin_offset.y())}; }); + e = Touch{ id, max(0.0f, x - (float)origin_offset.x), + max(0.0f, y - (float)origin_offset.y)}; }); _input_session_component.submit(&e); } @@ -401,7 +401,7 @@ Framebuffer::Mode Gui_session::mode() * the special case of 0x0, which can happen at boot time before the * framebuffer driver is running. */ - return { .area = { max(screen.w(), 1u), max(screen.h(), 1u) } }; + return { .area = { max(screen.w, 1u), max(screen.h, 1u) } }; } diff --git a/repos/os/src/server/nitpicker/gui_session.h b/repos/os/src/server/nitpicker/gui_session.h index e6efe554af..1492f8a9e7 100644 --- a/repos/os/src/server/nitpicker/gui_session.h +++ b/repos/os/src/server/nitpicker/gui_session.h @@ -260,11 +260,11 @@ class Nitpicker::Gui_session : public Session_object, if (!_input_mask || !_texture.valid()) return 0; /* check boundaries */ - if ((unsigned)p.x() >= _texture.size().w() - || (unsigned)p.y() >= _texture.size().h()) + if ((unsigned)p.x >= _texture.size().w + || (unsigned)p.y >= _texture.size().h) return 0; - return _input_mask[p.y()*_texture.size().w() + p.x()]; + return _input_mask[p.y*_texture.size().w + p.x]; } void submit_input_event(Input::Event e) override; diff --git a/repos/os/src/server/nitpicker/main.cc b/repos/os/src/server/nitpicker/main.cc index ea0b79834a..449dc9c40f 100644 --- a/repos/os/src/server/nitpicker/main.cc +++ b/repos/os/src/server/nitpicker/main.cc @@ -277,8 +277,8 @@ class Nitpicker::Capture_root : public Root_component return; xml.node("display", [&] () { - xml.attribute("width", size.w()); - xml.attribute("height", size.h()); + xml.attribute("width", size.w); + xml.attribute("height", size.h); }); } }; @@ -616,7 +616,7 @@ struct Nitpicker::Main : Focus_updater, Hover_updater, void _update_pointer_position() { - _view_stack.geometry(_pointer_origin, Rect(_user_state.pointer_pos(), Area())); + _view_stack.geometry(_pointer_origin, Rect(_user_state.pointer_pos(), Area{})); } Main(Env &env) : _env(env) @@ -901,8 +901,8 @@ void Nitpicker::Main::_report_displays() Reporter::Xml_generator xml(_displays_reporter, [&] () { if (_fb_screen.constructed()) { xml.node("display", [&] () { - xml.attribute("width", _fb_screen->size.w()); - xml.attribute("height", _fb_screen->size.h()); + xml.attribute("width", _fb_screen->size.w); + xml.attribute("height", _fb_screen->size.h); }); } diff --git a/repos/os/src/server/nitpicker/types.h b/repos/os/src/server/nitpicker/types.h index 46edc25dc2..defd1890b0 100644 --- a/repos/os/src/server/nitpicker/types.h +++ b/repos/os/src/server/nitpicker/types.h @@ -41,7 +41,7 @@ namespace Nitpicker { static inline Area max_area(Area a1, Area a2) { - return Area(max(a1.w(), a2.w()), max(a1.h(), a2.h())); + return Area(max(a1.w, a2.w), max(a1.h, a2.h)); } } diff --git a/repos/os/src/server/nitpicker/user_state.cc b/repos/os/src/server/nitpicker/user_state.cc index 2a6115fda4..fad6d14083 100644 --- a/repos/os/src/server/nitpicker/user_state.cc +++ b/repos/os/src/server/nitpicker/user_state.cc @@ -95,11 +95,11 @@ void User_state::_handle_input_event(Input::Event ev) /* transparently convert relative into absolute motion event */ ev.handle_relative_motion([&] (int x, int y) { - int const ox = _pointer_pos.x(), - oy = _pointer_pos.y(); + int const ox = _pointer_pos.x, + oy = _pointer_pos.y; - int const ax = max(0, min((int)_view_stack.size().w() - 1, ox + x)), - ay = max(0, min((int)_view_stack.size().h() - 1, oy + y)); + int const ax = max(0, min((int)_view_stack.size().w - 1, ox + x)), + ay = max(0, min((int)_view_stack.size().h - 1, oy + y)); ev = Absolute_motion{ax, ay}; }); @@ -188,8 +188,8 @@ void User_state::_handle_input_event(Input::Event ev) _focused->submit_input_event(Focus_leave()); if (_hovered) { - _hovered->submit_input_event(Absolute_motion{_pointer_pos.x(), - _pointer_pos.y()}); + _hovered->submit_input_event(Absolute_motion{_pointer_pos.x, + _pointer_pos.y}); _hovered->submit_input_event(Focus_enter()); } @@ -411,8 +411,8 @@ void User_state::report_keystate(Xml_generator &xml) const void User_state::report_pointer_position(Xml_generator &xml) const { - xml.attribute("xpos", _pointer_pos.x()); - xml.attribute("ypos", _pointer_pos.y()); + xml.attribute("xpos", _pointer_pos.x); + xml.attribute("ypos", _pointer_pos.y); } @@ -499,8 +499,8 @@ User_state::Update_hover_result User_state::update_hover() old_hovered->submit_input_event(Hover_leave()); if (_hovered) - _hovered->submit_input_event(Absolute_motion{_pointer_pos.x(), - _pointer_pos.y()}); + _hovered->submit_input_event(Absolute_motion{_pointer_pos.x, + _pointer_pos.y}); } return { .hover_changed = (_hovered != old_hovered) }; diff --git a/repos/os/src/server/nitpicker/user_state.h b/repos/os/src/server/nitpicker/user_state.h index 83813081a8..ed23ae2582 100644 --- a/repos/os/src/server/nitpicker/user_state.h +++ b/repos/os/src/server/nitpicker/user_state.h @@ -221,14 +221,14 @@ class Nitpicker::User_state /* center pointer initially */ if (!_initial_pointer_position_defined) { - _pointer_pos = Point(screen_size.w()/2, screen_size.h()/2); + _pointer_pos = Point(screen_size.w/2, screen_size.h/2); _initial_pointer_position_defined = true; } /* ensure that pointer remains within screen boundaries */ if (screen_size.count() > 0) - _pointer_pos = Point(min((int)screen_size.w() - 1, _pointer_pos.x()), - min((int)screen_size.h() - 1, _pointer_pos.y())); + _pointer_pos = Point(min((int)screen_size.w - 1, _pointer_pos.x), + min((int)screen_size.h - 1, _pointer_pos.y)); } diff --git a/repos/os/src/server/nitpicker/view.cc b/repos/os/src/server/nitpicker/view.cc index a2a069ce64..4d6e989a13 100644 --- a/repos/os/src/server/nitpicker/view.cc +++ b/repos/os/src/server/nitpicker/view.cc @@ -152,13 +152,13 @@ void Nitpicker::View::apply_origin_policy(View &pointer_origin) } -bool Nitpicker::View::input_response_at(Point p) const +bool Nitpicker::View::input_response_at(Point const p) const { Rect const view_rect = abs_geometry(); /* check if point lies outside view geometry */ - if ((p.x() < view_rect.x1()) || (p.x() > view_rect.x2()) - || (p.y() < view_rect.y1()) || (p.y() > view_rect.y2())) + if ((p.x < view_rect.x1()) || (p.x > view_rect.x2()) + || (p.y < view_rect.y1()) || (p.y > view_rect.y2())) return false; /* if view uses an alpha channel, check the input mask */ diff --git a/repos/os/src/server/nitpicker/view.h b/repos/os/src/server/nitpicker/view.h index 98b1f507cb..2d19074f8a 100644 --- a/repos/os/src/server/nitpicker/view.h +++ b/repos/os/src/server/nitpicker/view.h @@ -167,7 +167,7 @@ class Nitpicker::View : private Same_buffer_list_elem, */ Rect abs_geometry() const { - return Rect(abs_position(), _geometry.area()); + return Rect(abs_position(), _geometry.area); } /** @@ -269,7 +269,7 @@ class Nitpicker::View : private Same_buffer_list_elem, void buffer_off(Point buffer_off) { _buffer_off = buffer_off; } - void label_pos(Point pos) { _label_rect = Rect(pos, _label_rect.area()); } + void label_pos(Point pos) { _label_rect = Rect(pos, _label_rect.area); } /** * Return true if input at screen position 'p' refers to the view diff --git a/repos/os/src/server/nitpicker/view_stack.cc b/repos/os/src/server/nitpicker/view_stack.cc index e385029b3e..b8f439ca87 100644 --- a/repos/os/src/server/nitpicker/view_stack.cc +++ b/repos/os/src/server/nitpicker/view_stack.cc @@ -47,8 +47,8 @@ Nitpicker::Rect View_stack::_outline(View const &view) const /* request thickness of view frame */ int const frame_size = view.frame_size(_focus); - return Rect(Point(rect.x1() - frame_size, rect.y1() - frame_size), - Point(rect.x2() + frame_size, rect.y2() + frame_size)); + return Rect::compound(Point(rect.x1() - frame_size, rect.y1() - frame_size), + Point(rect.x2() + frame_size, rect.y2() + frame_size)); } @@ -87,7 +87,7 @@ void View_stack::_optimize_label_rec(View const *cv, View const *lv, Rect rect, Rect *optimal) { /* if label already fits in optimized rectangle, we are happy */ - if (optimal->fits(lv->label_rect().area())) + if (optimal->fits(lv->label_rect().area)) return; /* find next view that intersects with the rectangle or the target view */ @@ -100,11 +100,9 @@ void View_stack::_optimize_label_rec(View const *cv, View const *lv, if (cv != lv && _next_view(*cv)) { - /* cut current view from rectangle and go into sub rectangles */ - Rect r[4]; - rect.cut(clipped, &r[0], &r[1], &r[2], &r[3]); - for (int i = 0; i < 4; i++) - _optimize_label_rec(_next_view(*cv), lv, r[i], optimal); + /* cut current view from rectangle and recurse into sub rectangles */ + rect.cut(clipped).for_each([&] (Rect const &r) { + _optimize_label_rec(_next_view(*cv), lv, r, optimal); }); return; } @@ -122,7 +120,7 @@ void View_stack::_optimize_label_rec(View const *cv, View const *lv, * If label fits completely within current rectangle, we are done. * If label's width is not fully visible, choose the widest rectangle. */ - if (rect.fits(lv->label_rect().area()) || (rect.w() > optimal->w())) { + if (rect.fits(lv->label_rect().area) || (rect.w() > optimal->w())) { *optimal = rect; return; } @@ -155,7 +153,7 @@ void View_stack::_place_labels(Rect rect) * (most important) part. Otherwise, we center the label horizontally. */ int x = best.x1(); - if (best.fits(view->label_rect().area())) + if (best.fits(view->label_rect().area)) x += (best.w() - view->label_rect().w()) / 2; view->label_pos(Point(x, best.y1())); @@ -180,14 +178,13 @@ void View_stack::draw_rec(Canvas_base &canvas, Font const &font, /* check if we hit the bottom of the view stack */ if (!view) return; - Rect top, left, right, bottom; - rect.cut(clipped, &top, &left, &right, &bottom); + Rect::Cut_remainder const r = rect.cut(clipped); View const *next = _next_view(*view); /* draw areas at the top/left of the current view */ - if (next && top.valid()) draw_rec(canvas, font, next, top); - if (next && left.valid()) draw_rec(canvas, font, next, left); + if (next && r.top.valid()) draw_rec(canvas, font, next, r.top); + if (next && r.left.valid()) draw_rec(canvas, font, next, r.left); /* draw current view */ { @@ -202,8 +199,8 @@ void View_stack::draw_rec(Canvas_base &canvas, Font const &font, } /* draw areas at the bottom/right of the current view */ - if (next && right.valid()) draw_rec(canvas, font, next, right); - if (next && bottom.valid()) draw_rec(canvas, font, next, bottom); + if (next && r.right.valid()) draw_rec(canvas, font, next, r.right); + if (next && r.bottom.valid()) draw_rec(canvas, font, next, r.bottom); } @@ -212,7 +209,8 @@ void View_stack::refresh_view(View &view, Rect const rect) /* rectangle constrained to view geometry */ Rect const view_rect = Rect::intersect(rect, _outline(view)); - _damage.mark_as_damaged(view_rect); + if (view_rect.valid()) + _damage.mark_as_damaged(view_rect); view.for_each_child([&] (View &child) { refresh_view(child, rect); }); } diff --git a/repos/os/src/server/nitpicker/view_stack.h b/repos/os/src/server/nitpicker/view_stack.h index 1c54e730e8..5b3543a4c1 100644 --- a/repos/os/src/server/nitpicker/view_stack.h +++ b/repos/os/src/server/nitpicker/view_stack.h @@ -152,8 +152,8 @@ class Nitpicker::View_stack * specified by 'rect'. */ Point const offset = view->abs_position() + view->buffer_off(); - Rect const r = Rect::intersect(Rect(rect.p1() + offset, - rect.p2() + offset), + Rect const r = Rect::intersect(Rect::compound(rect.p1() + offset, + rect.p2() + offset), view->abs_geometry()); refresh_view(*view, r); diff --git a/repos/os/src/server/vmm/virtio_gpu.cc b/repos/os/src/server/vmm/virtio_gpu.cc index 8d0a9235f5..7938469ddf 100644 --- a/repos/os/src/server/vmm/virtio_gpu.cc +++ b/repos/os/src/server/vmm/virtio_gpu.cc @@ -50,8 +50,8 @@ void Vmm::Virtio_gpu_control_request::_get_display_info() dir.write(0); dir.write(0); - dir.write(mode.area.w()); - dir.write(mode.area.h()); + dir.write(mode.area.w); + dir.write(mode.area.h); dir.write(1); dir.write(0); } @@ -195,18 +195,18 @@ void Vmm::Virtio_gpu_control_request::_resource_flush() uint32_t x = rf.read(); uint32_t y = rf.read(); uint32_t w = min(rf.read(), - _device._fb_mode.area.w() - x); + _device._fb_mode.area.w - x); uint32_t h = min(rf.read(), - _device._fb_mode.area.h() - y); + _device._fb_mode.area.h - y); enum { BYTES_PER_PIXEL = Virtio_gpu_device::BYTES_PER_PIXEL }; - if (x > res.area.w() || - y > res.area.h() || - w > res.area.w() || - h > res.area.h() || - x + w > res.area.w() || - y + h > res.area.h()) { + if (x > res.area.w || + y > res.area.h || + w > res.area.w || + h > res.area.h || + x + w > res.area.w || + y + h > res.area.h) { response.write(Control_header::Type::ERR_INVALID_PARAMETER); return; } @@ -215,12 +215,12 @@ void Vmm::Virtio_gpu_control_request::_resource_flush() void * src = (void*)((addr_t)res.dst_ds.local_addr() + - (res.area.w() * y + x) * BYTES_PER_PIXEL); + (res.area.w * y + x) * BYTES_PER_PIXEL); void * dst = (void*)((addr_t)_device._fb_ds->local_addr() + - (_device._fb_mode.area.w() * y + x) * BYTES_PER_PIXEL); - uint32_t line_src = res.area.w() * BYTES_PER_PIXEL; - uint32_t line_dst = _device._fb_mode.area.w() * BYTES_PER_PIXEL; + (_device._fb_mode.area.w * y + x) * BYTES_PER_PIXEL); + uint32_t line_src = res.area.w * BYTES_PER_PIXEL; + uint32_t line_dst = _device._fb_mode.area.w * BYTES_PER_PIXEL; blit(src, line_src, dst, line_dst, w*BYTES_PER_PIXEL, h); _device._gui.framebuffer()->refresh(x, y, w, h); @@ -250,15 +250,15 @@ void Vmm::Virtio_gpu_control_request::_transfer_to_host_2d() uint32_t h = tth.read(); addr_t off = (addr_t)tth.read(); - if (x + w > res.area.w() || y + h > res.area.h()) { + if (x + w > res.area.w || y + h > res.area.h) { response.write(Control_header::Type::ERR_INVALID_PARAMETER); return; } void * src = (void*)((addr_t)res.src_ds.local_addr() + off); void * dst = (void*)((addr_t)res.dst_ds.local_addr() + - (y * res.area.w() + x) * BYTES_PER_PIXEL); - uint32_t line = res.area.w() * BYTES_PER_PIXEL; + (y * res.area.w + x) * BYTES_PER_PIXEL); + uint32_t line = res.area.w * BYTES_PER_PIXEL; blit(src, line, dst, line, w*BYTES_PER_PIXEL, h); diff --git a/repos/os/src/server/vmm/virtio_gpu.h b/repos/os/src/server/vmm/virtio_gpu.h index 0d3ee53364..3633568362 100644 --- a/repos/os/src/server/vmm/virtio_gpu.h +++ b/repos/os/src/server/vmm/virtio_gpu.h @@ -327,7 +327,7 @@ class Vmm::Virtio_gpu_device : public Virtio_device Area area; size_t _size() const { - return align_addr(area.w() * area.h() * BYTES_PER_PIXEL, 12); } + return align_addr(area.w * area.h * BYTES_PER_PIXEL, 12); } addr_t attach_off { 0UL }; Rm_connection rm { device._env }; diff --git a/repos/os/src/test/capture/main.cc b/repos/os/src/test/capture/main.cc index 4b379fd4d9..77cdc31dfb 100644 --- a/repos/os/src/test/capture/main.cc +++ b/repos/os/src/test/capture/main.cc @@ -74,8 +74,8 @@ struct Test::Main static Gui::Area _area_from_xml(Xml_node node, Gui::Area default_area) { - return Gui::Area(node.attribute_value("width", default_area.w()), - node.attribute_value("height", default_area.h())); + return Gui::Area(node.attribute_value("width", default_area.w), + node.attribute_value("height", default_area.h)); } struct Output diff --git a/repos/os/src/test/fb_bench/main.cc b/repos/os/src/test/fb_bench/main.cc index f8727bd1ef..96dfe86e8c 100644 --- a/repos/os/src/test/fb_bench/main.cc +++ b/repos/os/src/test/fb_bench/main.cc @@ -107,8 +107,8 @@ struct Blit_test : Test { unsigned kib = 0; uint64_t const start_ms = timer.elapsed_ms(); - unsigned const w = (unsigned)(fb_mode.area.w() * fb_mode.bytes_per_pixel()); - unsigned const h = fb_mode.area.h(); + unsigned const w = (unsigned)(fb_mode.area.w * fb_mode.bytes_per_pixel()); + unsigned const h = fb_mode.area.h; for (unsigned i = 0; timer.elapsed_ms() - start_ms < DURATION_MS; i++) { blit(buf[i % 2], w, fb_ds.local_addr(), w, w, h); kib += (w * h) / 1024; @@ -125,8 +125,8 @@ struct Unaligned_blit_test : Test { unsigned kib = 0; uint64_t const start_ms = timer.elapsed_ms(); - unsigned const w = (unsigned)(fb_mode.area.w() * fb_mode.bytes_per_pixel()); - unsigned const h = fb_mode.area.h(); + unsigned const w = (unsigned)(fb_mode.area.w * fb_mode.bytes_per_pixel()); + unsigned const h = fb_mode.area.h; for (unsigned i = 0; timer.elapsed_ms() - start_ms < DURATION_MS; i++) { blit(buf[i % 2] + 2, w, fb_ds.local_addr() + 2, w, w - 2, h); kib += (w * h) / 1024; diff --git a/repos/os/src/test/framebuffer/main.cc b/repos/os/src/test/framebuffer/main.cc index 890ac3b31b..f924dd5585 100644 --- a/repos/os/src/test/framebuffer/main.cc +++ b/repos/os/src/test/framebuffer/main.cc @@ -119,7 +119,7 @@ class Test::Main void Test::Capture_session::_draw_frame(Pixel *p, Pixel c, Area area) { - unsigned const w = area.w(), h = area.h(); + unsigned const w = area.w, h = area.h; /* top and bottom */ for (unsigned i = 0; i < w; ++i) @@ -144,7 +144,7 @@ void Test::Capture_session::_draw() case STRIPES: { log("black & white stripes"); - addr_t const stripe_width = _size.w() / 4; + addr_t const stripe_width = _size.w / 4; addr_t stripe_o = 0; bool stripe = 0; for (addr_t o = 0; o < num_pixels; o++) { diff --git a/repos/os/src/test/nitpicker/test.cc b/repos/os/src/test/nitpicker/test.cc index cce1a49d81..e24d32db85 100644 --- a/repos/os/src/test/nitpicker/test.cc +++ b/repos/os/src/test/nitpicker/test.cc @@ -154,7 +154,7 @@ void Component::construct(Genode::Env &env) Framebuffer::Mode const mode { .area = { 256, 256 } }; gui.buffer(mode, false); - int const scr_w = mode.area.w(), scr_h = mode.area.h(); + int const scr_w = mode.area.w, scr_h = mode.area.h; log("screen is ", mode); if (!scr_w || !scr_h) { diff --git a/repos/os/src/test/vfs_capture/main.cc b/repos/os/src/test/vfs_capture/main.cc index 71f77be575..789a02a5e0 100644 --- a/repos/os/src/test/vfs_capture/main.cc +++ b/repos/os/src/test/vfs_capture/main.cc @@ -78,8 +78,8 @@ struct Test::Main static Gui::Area _area_from_xml(Xml_node node, Gui::Area default_area) { - return Gui::Area(node.attribute_value("width", default_area.w()), - node.attribute_value("height", default_area.h())); + return Gui::Area(node.attribute_value("width", default_area.w), + node.attribute_value("height", default_area.h)); } struct Output diff --git a/repos/ports/src/virtualbox5/frontend/fb.h b/repos/ports/src/virtualbox5/frontend/fb.h index 0fb64f3153..3e272f6e72 100644 --- a/repos/ports/src/virtualbox5/frontend/fb.h +++ b/repos/ports/src/virtualbox5/frontend/fb.h @@ -55,10 +55,10 @@ class Genodefb : { if (!_fb_base) return; - size_t const max_h = Genode::min(_fb_mode.area.h(), _virtual_fb_mode.area.h()); - size_t const num_pixels = _fb_mode.area.w() * max_h; + size_t const max_h = Genode::min(_fb_mode.area.h, _virtual_fb_mode.area.h); + size_t const num_pixels = _fb_mode.area.w * max_h; memset(_fb_base, 0, num_pixels * _fb_mode.bytes_per_pixel()); - _fb.refresh(0, 0, _virtual_fb_mode.area.w(), _virtual_fb_mode.area.h()); + _fb.refresh(0, 0, _virtual_fb_mode.area.w, _virtual_fb_mode.area.h); } void _adjust_buffer() @@ -102,8 +102,8 @@ class Genodefb : Assert(rc == VINF_SUCCESS); } - int w() const { return _fb_mode.area.w(); } - int h() const { return _fb_mode.area.h(); } + int w() const { return _fb_mode.area.w; } + int h() const { return _fb_mode.area.h; } void update_mode(Fb_Genode::Mode mode) { @@ -145,11 +145,11 @@ class Genodefb : /* save the new bitmap reference */ _display->QuerySourceBitmap(screen, _display_bitmap.asOutParam()); - bool const ok = (w <= (ULONG)_fb_mode.area.w()) && - (h <= (ULONG)_fb_mode.area.h()); + bool const ok = (w <= (ULONG)_fb_mode.area.w) && + (h <= (ULONG)_fb_mode.area.h); - bool const changed = (w != (ULONG)_virtual_fb_mode.area.w()) || - (h != (ULONG)_virtual_fb_mode.area.h()); + bool const changed = (w != (ULONG)_virtual_fb_mode.area.w) || + (h != (ULONG)_virtual_fb_mode.area.h); if (ok && changed) { Genode::log("fb resize : [", screen, "] ", @@ -157,8 +157,8 @@ class Genodefb : w, "x", h, " (host: ", _fb_mode.area, ")"); - if ((w < (ULONG)_fb_mode.area.w()) || - (h < (ULONG)_fb_mode.area.h())) { + if ((w < (ULONG)_fb_mode.area.w) || + (h < (ULONG)_fb_mode.area.h)) { /* clear the old content around the new, smaller area. */ _clear_screen(); } @@ -223,8 +223,8 @@ class Genodefb : &ulBytesPerLine, &bitmapFormat); - Gui::Area const area_fb = Gui::Area(_fb_mode.area.w(), - _fb_mode.area.h()); + Gui::Area const area_fb = Gui::Area(_fb_mode.area.w, + _fb_mode.area.h); Gui::Area const area_vm = Gui::Area(ulWidth, ulHeight); using namespace Genode; @@ -279,7 +279,7 @@ class Genodefb : Texture_painter::SOLID, false); - _fb.refresh(o_x, o_y, area_vm.w(), area_vm.h()); + _fb.refresh(o_x, o_y, area_vm.w, area_vm.h); Unlock(); @@ -300,8 +300,8 @@ class Genodefb : if (!supported) return E_POINTER; - *supported = ((width <= (ULONG)_fb_mode.area.w()) && - (height <= (ULONG)_fb_mode.area.h())); + *supported = ((width <= (ULONG)_fb_mode.area.w) && + (height <= (ULONG)_fb_mode.area.h)); return S_OK; } diff --git a/repos/ports/src/virtualbox6/include/fb.h b/repos/ports/src/virtualbox6/include/fb.h index b154161fcb..482456a4b4 100644 --- a/repos/ports/src/virtualbox6/include/fb.h +++ b/repos/ports/src/virtualbox6/include/fb.h @@ -54,10 +54,10 @@ class Genodefb : { if (!_fb_base) return; - size_t const max_h = Genode::min(_fb_mode.area.h(), _virtual_fb_mode.area.h()); - size_t const num_pixels = _fb_mode.area.w() * max_h; + size_t const max_h = Genode::min(_fb_mode.area.h, _virtual_fb_mode.area.h); + size_t const num_pixels = _fb_mode.area.w * max_h; memset(_fb_base, 0, num_pixels * _fb_mode.bytes_per_pixel()); - _fb.refresh(0, 0, _virtual_fb_mode.area.w(), _virtual_fb_mode.area.h()); + _fb.refresh(0, 0, _virtual_fb_mode.area.w, _virtual_fb_mode.area.h); } void _adjust_buffer() @@ -105,8 +105,8 @@ class Genodefb : virtual ~Genodefb() { } - int w() const { return _fb_mode.area.w(); } - int h() const { return _fb_mode.area.h(); } + int w() const { return _fb_mode.area.w; } + int h() const { return _fb_mode.area.h; } void update_mode(Fb_Genode::Mode mode) { @@ -148,11 +148,11 @@ class Genodefb : /* save the new bitmap reference */ _display->QuerySourceBitmap(screen, _display_bitmap.asOutParam()); - bool const ok = (w <= (ULONG)_fb_mode.area.w()) && - (h <= (ULONG)_fb_mode.area.h()); + bool const ok = (w <= (ULONG)_fb_mode.area.w) && + (h <= (ULONG)_fb_mode.area.h); - bool const changed = (w != (ULONG)_virtual_fb_mode.area.w()) || - (h != (ULONG)_virtual_fb_mode.area.h()); + bool const changed = (w != (ULONG)_virtual_fb_mode.area.w) || + (h != (ULONG)_virtual_fb_mode.area.h); if (ok && changed) { Genode::log("fb resize : [", screen, "] ", @@ -160,8 +160,8 @@ class Genodefb : w, "x", h, " (host: ", _fb_mode.area, ")"); - if ((w < (ULONG)_fb_mode.area.w()) || - (h < (ULONG)_fb_mode.area.h())) { + if ((w < (ULONG)_fb_mode.area.w) || + (h < (ULONG)_fb_mode.area.h)) { /* clear the old content around the new, smaller area. */ _clear_screen(); } @@ -225,8 +225,8 @@ class Genodefb : &ulBytesPerLine, &bitmapFormat); - Gui::Area const area_fb = Gui::Area(_fb_mode.area.w(), - _fb_mode.area.h()); + Gui::Area const area_fb = Gui::Area(_fb_mode.area.w, + _fb_mode.area.h); Gui::Area const area_vm = Gui::Area(ulWidth, ulHeight); using namespace Genode; @@ -281,7 +281,7 @@ class Genodefb : Texture_painter::SOLID, false); - _fb.refresh(o_x, o_y, area_vm.w(), area_vm.h()); + _fb.refresh(o_x, o_y, area_vm.w, area_vm.h); Unlock(); @@ -302,8 +302,8 @@ class Genodefb : if (!supported) return E_POINTER; - *supported = ((width <= (ULONG)_fb_mode.area.w()) && - (height <= (ULONG)_fb_mode.area.h())); + *supported = ((width <= (ULONG)_fb_mode.area.w) && + (height <= (ULONG)_fb_mode.area.h)); return S_OK; } diff --git a/repos/ports/src/virtualbox6/input_adapter.h b/repos/ports/src/virtualbox6/input_adapter.h index b3b686babb..7ad0a6025e 100644 --- a/repos/ports/src/virtualbox6/input_adapter.h +++ b/repos/ports/src/virtualbox6/input_adapter.h @@ -137,11 +137,11 @@ void Input_adapter::Mouse::handle_input_event(Input::Event const &ev) if (abs_pos_changed || buttons_changed || wheel_changed) { if (_absolute) { - _imouse->PutMouseEventAbsolute(_abs_pos.x(), _abs_pos.y(), wheel_y, wheel_x, mouse_button_bits); + _imouse->PutMouseEventAbsolute(_abs_pos.x, _abs_pos.y, wheel_y, wheel_x, mouse_button_bits); } else { Point const rel = _abs_pos - old_abs_pos; - _imouse->PutMouseEvent(rel.x(), rel.y(), wheel_y, wheel_x, mouse_button_bits); + _imouse->PutMouseEvent(rel.x, rel.y, wheel_y, wheel_x, mouse_button_bits); } } }