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
This commit is contained in:
Norman Feske 2024-06-05 12:40:13 +02:00
parent bb06d879aa
commit c629c54153
131 changed files with 1200 additions and 1218 deletions

View File

@ -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 <util/misc_math.h>
#include <util/xml_node.h>
#include <base/stdint.h>
#include <base/output.h>
namespace Genode {
template <typename CT = int> class Point;
template <typename DT = unsigned> class Area;
template <typename CT = int, typename DT = unsigned> class Rect;
}
/**
* \param CT coordinate type
*/
template <typename CT>
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 <typename DT>
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 <typename CT, typename DT>
struct Genode::Rect
{
using Point = Genode::Point<CT>;
using Area = Genode::Area<DT>;
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_ */

View File

@ -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

View File

@ -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<Command::Geometry>(_view, rect);
Gui::Point offset(0, _flip_state ? -_max_size.h() : 0);
Gui::Point offset(0, _flip_state ? -_max_size.h : 0);
_gui.enqueue<Command::Offset>(_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<PT>( _back_idx());
PT *dst = _base<PT>(_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);

View File

@ -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:

View File

@ -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);
}

View File

@ -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;

View File

@ -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);
}
};

View File

@ -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<PT, DT>(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());
}
};

View File

@ -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());
}

View File

@ -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<Child_entry<PT> >::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);

View File

@ -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)));

View File

@ -82,15 +82,15 @@ Launchpad_window<PT>::Launchpad_window(Genode::Env &env,
template <typename PT>
void Launchpad_window<PT>::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 <typename PT>
void Launchpad_window<PT>::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);

View File

@ -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);
};
/**

View File

@ -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));

View File

@ -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()
{

View File

@ -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));
}
};

View File

@ -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)));

View File

@ -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();

View File

@ -345,16 +345,16 @@ Browser_window<PT>::Browser_window(Document *initial_content,
template <typename PT>
void Browser_window<PT>::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<PT>::_content(Element *content)
template <typename PT>
void Browser_window<PT>::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<PT>::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);
}

View File

@ -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);
}
};

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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<PT>::Scrollbar()
template <typename PT>
int Scrollbar<PT>::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 <typename PT>
int Scrollbar<PT>::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<PT>::slider_pos()
template <typename PT>
void Scrollbar<PT>::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));

View File

@ -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);
}
};

View File

@ -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);

View File

@ -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<PT, W, H>::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;
}

View File

@ -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); }
};

View File

@ -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);
};
};

View File

@ -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()
{

View File

@ -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);
}
/**

View File

@ -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 };

View File

@ -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(); }
};

View File

@ -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)
{

View File

@ -200,9 +200,9 @@ class Png_image
Chunky_texture<PT>(_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;

View File

@ -24,21 +24,21 @@ static void scale(Genode::Texture<PT> const &src, Genode::Texture<PT> &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<PT> const &src, Genode::Texture<PT> &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<SRC_PT> 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) {

View File

@ -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

View File

@ -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++) {

View File

@ -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));
}
};

View File

@ -209,17 +209,17 @@ class Polygon::Painter_base
template <typename POINT>
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);
}
}
}

View File

@ -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();

View File

@ -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();

View File

@ -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++) {

View File

@ -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<PT> &surface, Texture<PT> 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);

View File

@ -333,7 +333,7 @@ class Cpu_load_display::Scene : public Nano3d::Scene<PT>
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<PT>
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<PT>
/* 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) {

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -77,7 +77,7 @@ class Decorator::Window : public Window_base
void place(Rect rect)
{
_gui.enqueue<Command::Geometry>(_handle, rect);
Point offset = Point(0, 0) - rect.p1();
Point offset = Point(0, 0) - rect.at;
_gui.enqueue<Command::Offset>(_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;
}

View File

@ -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 */

View File

@ -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_rgb888> &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)));
});
}

View File

@ -56,7 +56,7 @@ class Menu_view::Cursor : List_model<Cursor>::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<Cursor>::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<Cursor>::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);

View File

@ -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_rgb888> &pixel_surface,
Surface<Pixel_alpha8> &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); });
}
};

View File

@ -97,14 +97,14 @@ struct Menu_view::Dialog : List_model<Dialog>::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<Dialog>::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<Dialog>::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;

View File

@ -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);
});
}

View File

@ -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_rgb888> &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)));
});
}

View File

@ -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));
});
}
}

View File

@ -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);
});
}
};

View File

@ -199,8 +199,8 @@ class Menu_view::Widget : List_model<Widget>::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<Widget>::Element
void position(Point position)
{
_geometry = Rect(position, _geometry.area());
_geometry = Rect(position, _geometry.area);
}
static Point _at_child(Point at, Widget const &w)

View File

@ -116,8 +116,8 @@ class Scene : public Nano3d::Scene<PT>
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<PT>
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);

View File

@ -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)

View File

@ -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();

View File

@ -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)

View File

@ -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)) };
}

View File

@ -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;

View File

@ -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<Pixel_rgb888> 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));
}

View File

@ -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()];

View File

@ -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;
}

View File

@ -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();

View File

@ -116,13 +116,13 @@ class Window_layouter::Assign : public List_model<Assign>::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<Assign>::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)

View File

@ -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));
}
};

View File

@ -116,7 +116,7 @@ class Window_layouter::Window : public List_model<Window>::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<Window>::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<Window>::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<Window>::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<Window>::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<Window>::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<Window>::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<Window>::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<Window>::Element
_drag_top_border = false;
_drag_bottom_border = false;
_geometry = effective_inner_geometry();
_dragged_size = _geometry.area();
_dragged_size = _geometry.area;
_dragged = false;
}

View File

@ -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()); }

View File

@ -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)

View File

@ -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();

View File

@ -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();
}

View File

@ -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<Char_cell>::bytes_needed(surface.size().w(),
surface.size().h());
return Cell_array<Char_cell>::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();

View File

@ -183,7 +183,7 @@ class Wm::Gui::View : private Genode::Weak_object<View>,
using Genode::Weak_object<View>::weak_ptr;
using Genode::Weak_object<View>::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<Top_level_view>::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<Top_level_view>::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<Gui::Session>,
{
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<Gui::Session>,
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<Genode::Typed_root<Session> >,
* 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});
}

View File

@ -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);
}
});
}

View File

@ -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");

View File

@ -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),

View File

@ -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<Command::Geometry>(_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);

View File

@ -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);

View File

@ -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});

View File

@ -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<uint8_t>(), src_stride_argb,
reinterpret_cast<uint8_t*>(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;
}

View File

@ -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);
}
};

View File

@ -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;

View File

@ -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 */

View File

@ -34,8 +34,8 @@ struct Framebuffer::Connection : Genode::Connection<Session>, Session_client
Connection(Genode::Env &env, Framebuffer::Mode mode)
:
Genode::Connection<Session>(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())
{ }
};

View File

@ -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);

View File

@ -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;

View File

@ -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)));
}
};

View File

@ -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;

View File

@ -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; }
};

View File

@ -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(); }

View File

@ -24,11 +24,11 @@ namespace Genode {
inline void
Texture<Pixel_rgb888>::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++) {

View File

@ -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++) {

View File

@ -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:

View File

@ -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 <util/misc_math.h>
#include <util/xml_node.h>
#include <base/stdint.h>
#include <base/output.h>
namespace Genode {
template <typename CT = int> class Point;
template <typename DT = unsigned> class Area;
template <typename CT = int, typename DT = unsigned> class Rect;
}
/**
* \param CT coordinate type
*/
template <typename CT>
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 <typename DT>
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 <typename CT, typename DT>
class Genode::Rect
{
private:
Point<CT> _p1, _p2;
public:
/**
* Constructors
*/
Rect(Point<CT> p1, Point<CT> p2): _p1(p1), _p2(p2) { }
Rect(Point<CT> p, Area<DT> 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<CT> p1() const { return _p1; }
Point<CT> p2() const { return _p2; }
Area<DT> area() const { return Area<DT>(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<DT> area) const { return w() >= area.w() && h() >= area.h(); }
/**
* Return true if the specified point lies within the rectangle
*/
bool contains(Point<CT> 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<CT>(max(r1.x1(), r2.x1()), max(r1.y1(), r2.y1())),
Point<CT>(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<CT>(min(r1.x1(), r2.x1()), min(r1.y1(), r2.y1())),
Point<CT>(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<CT>(x1(), y1()), Point<CT>(x2(), r.y1() - 1));
*left = Rect(Point<CT>(x1(), r.y1()), Point<CT>(r.x1() - 1, r.y2()));
*right = Rect(Point<CT>(r.x2() + 1, r.y1()), Point<CT>(x2(), r.y2()));
*bottom = Rect(Point<CT>(x1(), r.y2() + 1), Point<CT>(x2(), y2()));
}
/**
* Return position of an area when centered within the rectangle
*/
Point<CT> center(Area<DT> area) const {
return Point<CT>(((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<CT>::from_xml(node), Area<DT>::from_xml(node));
}
};
#endif /* _INCLUDE__UTIL__GEOMETRY_H_ */

Some files were not shown because too many files have changed in this diff Show More