nitpicker: internal cleanup

This patch simplifies the internal naming of the nitpicker GUI server as
a preparatory step for adding support for the capture session interface.

Issue #3812
This commit is contained in:
Norman Feske 2020-06-26 16:09:53 +02:00
parent 3863de9589
commit 067a7ad7e9
17 changed files with 295 additions and 308 deletions

View File

@ -16,36 +16,34 @@
#include <nitpicker_gfx/box_painter.h>
#include "session_component.h"
#include "gui_session.h"
#include "clip_guard.h"
namespace Nitpicker { struct Background; }
struct Nitpicker::Background : private Texture_base, View_component
struct Nitpicker::Background : private Texture_base, View
{
static Color default_color() { return Color(25, 37, 50); }
Color color = default_color();
/*
* The background uses no texture. Therefore
* we can pass a null pointer as texture argument
* to the Session constructor.
* The background uses no texture. Therefore we can pass a null pointer as
* texture argument to the Session constructor.
*/
Background(View_owner &owner, Area size)
:
Texture_base(Area(0, 0)),
View_component(owner, View_component::NOT_TRANSPARENT,
View_component::BACKGROUND, 0)
View(owner, View::NOT_TRANSPARENT, View::BACKGROUND, 0)
{
View_component::geometry(Rect(Point(0, 0), size));
View::geometry(Rect(Point(0, 0), size));
}
/******************************
** View_component interface **
******************************/
/********************
** View interface **
********************/
int frame_size(Focus const &) const override { return 0; }
void frame(Canvas_base &, Focus const &) const override { }

View File

@ -61,8 +61,7 @@ namespace Nitpicker { struct Buffer_provider; }
/**
* Interface for triggering the re-allocation of a virtual framebuffer
*
* Used by 'Framebuffer::Session_component',
* implemented by 'Nitpicker::Session_component'
* Used by 'Framebuffer::Session_component', * implemented by 'Gui_session'
*/
struct Nitpicker::Buffer_provider : Interface
{

View File

@ -15,7 +15,7 @@
#define _FOCUS_H_
#include "types.h"
#include "view_component.h"
#include "view.h"
namespace Nitpicker {
struct Focus;
@ -55,7 +55,7 @@ class Nitpicker::Focus : Noncopyable
* Return true if the specified view is the background view as defined for
* the currentlu focused view owner.
*/
bool focused_background(View_component const &view) const
bool focused_background(View const &view) const
{
return _focused && (_focused->background() == &view);
}

View File

@ -1,5 +1,5 @@
/*
* \brief Framebuffer sub session as part of the nitpicker session
* \brief Framebuffer sub session as part of the GUI session
* \author Norman Feske
* \date 2017-11-16
*/
@ -38,37 +38,33 @@ class Framebuffer::Session_component : public Rpc_object<Session>
Session_component(Session_component const &);
Session_component &operator = (Session_component const &);
Buffer *_buffer = 0;
View_stack &_view_stack;
Nitpicker::Session_component &_session;
Framebuffer::Session &_framebuffer;
Buffer_provider &_buffer_provider;
Signal_context_capability _mode_sigh { };
Signal_context_capability _sync_sigh { };
Framebuffer::Mode _mode { };
bool _alpha = false;
Buffer *_buffer = 0;
View_stack &_view_stack;
Nitpicker::Gui_session &_session;
Buffer_provider &_buffer_provider;
Signal_context_capability _mode_sigh { };
Signal_context_capability _sync_sigh { };
Framebuffer::Mode _mode { };
bool _alpha = false;
public:
/**
* Constructor
*/
Session_component(View_stack &view_stack,
Nitpicker::Session_component &session,
Framebuffer::Session &framebuffer,
Buffer_provider &buffer_provider)
Session_component(View_stack &view_stack,
Nitpicker::Gui_session &session,
Buffer_provider &buffer_provider)
:
_view_stack(view_stack),
_session(session),
_framebuffer(framebuffer),
_buffer_provider(buffer_provider)
{ }
/**
* Change virtual framebuffer mode
*
* Called by Nitpicker::Session_component when re-dimensioning the
* buffer.
* Called by Nitpicker::Gui_session when re-dimensioning the buffer.
*
* The new mode does not immediately become active. The client can
* keep using an already obtained framebuffer dataspace. However,

View File

@ -13,7 +13,6 @@
/* local includes */
#include "global_keys.h"
#include "session_component.h"
using namespace Nitpicker;
@ -63,7 +62,7 @@ void Global_keys::apply_config(Xml_node config, Session_list &session_list)
}
/* assign policy to matching client session */
for (Session_component *s = session_list.first(); s; s = s->next())
for (Gui_session *s = session_list.first(); s; s = s->next())
if (node.attribute("label").has_value(s->label().string()))
policy->client(s);
}

View File

@ -18,7 +18,7 @@
#include <input/keycodes.h>
/* local includes */
#include "session_component.h"
#include "gui_session.h"
namespace Nitpicker { class Global_keys; }
@ -29,11 +29,11 @@ class Nitpicker::Global_keys
struct Policy
{
Session_component *_session = nullptr;
Gui_session *_session = nullptr;
bool defined() const { return _session != nullptr; }
void client(Session_component *s) { _session = s; }
void client(Gui_session *s) { _session = s; }
};
enum { NUM_POLICIES = Input::KEY_MAX + 1 };
@ -50,7 +50,7 @@ class Nitpicker::Global_keys
public:
Session_component *global_receiver(Input::Keycode key) {
Gui_session *global_receiver(Input::Keycode key) {
return _valid(key) ? _policies[key]._session : 0; }
void apply_config(Xml_node config, Session_list &session_list);

View File

@ -1,5 +1,5 @@
/*
* \brief Nitpicker session component
* \brief GUI session component
* \author Norman Feske
* \date 2017-11-16
*/
@ -16,7 +16,7 @@
using namespace Nitpicker;
void Session_component::_release_buffer()
void Gui_session::_release_buffer()
{
if (!_texture)
return;
@ -36,24 +36,24 @@ void Session_component::_release_buffer()
}
bool Session_component::_views_are_equal(View_handle v1, View_handle v2)
bool Gui_session::_views_are_equal(View_handle v1, View_handle v2)
{
if (!v1.valid() || !v2.valid())
return false;
Weak_ptr<View_component> v1_ptr = _view_handle_registry.lookup(v1);
Weak_ptr<View_component> v2_ptr = _view_handle_registry.lookup(v2);
Weak_ptr<View> v1_ptr = _view_handle_registry.lookup(v1);
Weak_ptr<View> v2_ptr = _view_handle_registry.lookup(v2);
return v1_ptr == v2_ptr;
}
View_owner &Session_component::forwarded_focus()
View_owner &Gui_session::forwarded_focus()
{
Session_component *next_focus = this;
Gui_session *next_focus = this;
/* helper used for detecting cycles */
Session_component *next_focus_slow = next_focus;
Gui_session *next_focus_slow = next_focus;
for (bool odd = false; ; odd = !odd) {
@ -78,14 +78,14 @@ View_owner &Session_component::forwarded_focus()
}
void Session_component::_execute_command(Command const &command)
void Gui_session::_execute_command(Command const &command)
{
switch (command.opcode) {
case Command::OP_GEOMETRY:
{
Command::Geometry const &cmd = command.geometry;
Locked_ptr<View_component> view(_view_handle_registry.lookup(cmd.view));
Locked_ptr<View> view(_view_handle_registry.lookup(cmd.view));
if (!view.valid())
return;
@ -104,7 +104,7 @@ void Session_component::_execute_command(Command const &command)
case Command::OP_OFFSET:
{
Command::Offset const &cmd = command.offset;
Locked_ptr<View_component> view(_view_handle_registry.lookup(cmd.view));
Locked_ptr<View> view(_view_handle_registry.lookup(cmd.view));
if (view.valid())
_view_stack.buffer_offset(*view, cmd.offset);
@ -118,7 +118,7 @@ void Session_component::_execute_command(Command const &command)
if (_views_are_equal(cmd.view, cmd.neighbor))
return;
Locked_ptr<View_component> view(_view_handle_registry.lookup(cmd.view));
Locked_ptr<View> view(_view_handle_registry.lookup(cmd.view));
if (!view.valid())
return;
@ -129,7 +129,7 @@ void Session_component::_execute_command(Command const &command)
}
/* stack view relative to neighbor */
Locked_ptr<View_component> neighbor(_view_handle_registry.lookup(cmd.neighbor));
Locked_ptr<View> neighbor(_view_handle_registry.lookup(cmd.neighbor));
if (neighbor.valid())
_view_stack.stack(*view, &(*neighbor), false);
@ -142,7 +142,7 @@ void Session_component::_execute_command(Command const &command)
if (_views_are_equal(cmd.view, cmd.neighbor))
return;
Locked_ptr<View_component> view(_view_handle_registry.lookup(cmd.view));
Locked_ptr<View> view(_view_handle_registry.lookup(cmd.view));
if (!view.valid())
return;
@ -153,7 +153,7 @@ void Session_component::_execute_command(Command const &command)
}
/* stack view relative to neighbor */
Locked_ptr<View_component> neighbor(_view_handle_registry.lookup(cmd.neighbor));
Locked_ptr<View> neighbor(_view_handle_registry.lookup(cmd.neighbor));
if (neighbor.valid())
_view_stack.stack(*view, &(*neighbor), true);
@ -164,7 +164,7 @@ void Session_component::_execute_command(Command const &command)
{
Command::Background const &cmd = command.background;
if (_provides_default_bg) {
Locked_ptr<View_component> view(_view_handle_registry.lookup(cmd.view));
Locked_ptr<View> view(_view_handle_registry.lookup(cmd.view));
if (!view.valid())
return;
@ -178,7 +178,7 @@ void Session_component::_execute_command(Command const &command)
_background->background(false);
/* assign session background */
Locked_ptr<View_component> view(_view_handle_registry.lookup(cmd.view));
Locked_ptr<View> view(_view_handle_registry.lookup(cmd.view));
if (!view.valid())
return;
@ -194,10 +194,10 @@ void Session_component::_execute_command(Command const &command)
case Command::OP_TITLE:
{
Command::Title const &cmd = command.title;
Locked_ptr<View_component> view(_view_handle_registry.lookup(cmd.view));
Locked_ptr<View> view(_view_handle_registry.lookup(cmd.view));
if (view.valid())
_view_stack.title(*view, _font, cmd.title.string());
_view_stack.title(*view, cmd.title.string());
return;
}
@ -208,7 +208,7 @@ void Session_component::_execute_command(Command const &command)
}
void Session_component::_destroy_view(View_component &view)
void Gui_session::_destroy_view(View &view)
{
if (_background == &view)
_background = nullptr;
@ -224,14 +224,14 @@ void Session_component::_destroy_view(View_component &view)
}
void Session_component::destroy_all_views()
void Gui_session::destroy_all_views()
{
while (Session_view_list_elem *v = _view_list.first())
_destroy_view(*static_cast<View_component *>(v));
_destroy_view(*static_cast<View *>(v));
}
void Session_component::submit_input_event(Input::Event e)
void Gui_session::submit_input_event(Input::Event e)
{
using namespace Input;
@ -251,9 +251,9 @@ void Session_component::submit_input_event(Input::Event e)
}
Session_component::View_handle Session_component::create_view(View_handle parent_handle)
Gui_session::View_handle Gui_session::create_view(View_handle parent_handle)
{
View_component *view = nullptr;
View *view = nullptr;
/*
* Create child view
@ -261,14 +261,12 @@ Session_component::View_handle Session_component::create_view(View_handle parent
if (parent_handle.valid()) {
try {
Locked_ptr<View_component> parent(_view_handle_registry.lookup(parent_handle));
Locked_ptr<View> parent(_view_handle_registry.lookup(parent_handle));
if (!parent.valid())
return View_handle();
view = new (_view_alloc)
View_component(*this,
View_component::NOT_TRANSPARENT, View_component::NOT_BACKGROUND,
&(*parent));
View(*this, View::NOT_TRANSPARENT, View::NOT_BACKGROUND, &(*parent));
parent->add_child(*view);
}
@ -282,14 +280,12 @@ Session_component::View_handle Session_component::create_view(View_handle parent
else {
try {
view = new (_view_alloc)
View_component(*this,
View_component::NOT_TRANSPARENT, View_component::NOT_BACKGROUND,
nullptr);
View(*this, View::NOT_TRANSPARENT, View::NOT_BACKGROUND, nullptr);
}
catch (Allocator::Out_of_memory) { throw Out_of_ram(); }
}
view->title(_font, "");
_view_stack.title(*view, "");
view->apply_origin_policy(_pointer_origin);
_view_list.insert(view);
@ -302,8 +298,8 @@ Session_component::View_handle Session_component::create_view(View_handle parent
}
void Session_component::apply_session_policy(Xml_node config,
Domain_registry const &domain_registry)
void Gui_session::apply_session_policy(Xml_node config,
Domain_registry const &domain_registry)
{
reset_domain();
@ -331,7 +327,7 @@ void Session_component::apply_session_policy(Xml_node config,
}
void Session_component::destroy_view(View_handle handle)
void Gui_session::destroy_view(View_handle handle)
{
/*
* Search view object given the handle
@ -345,7 +341,7 @@ void Session_component::destroy_view(View_handle handle)
*/
for (Session_view_list_elem *v = _view_list.first(); v; v = v->next()) {
auto handle_matches = [&] (View_component const &view)
auto handle_matches = [&] (View const &view)
{
try { return _view_handle_registry.has_handle(view, handle); }
@ -353,7 +349,7 @@ void Session_component::destroy_view(View_handle handle)
catch (...) { return false; };
};
View_component &view = *static_cast<View_component *>(v);
View &view = *static_cast<View *>(v);
if (handle_matches(view)) {
_destroy_view(view);
@ -364,10 +360,10 @@ void Session_component::destroy_view(View_handle handle)
}
Session_component::View_handle
Session_component::view_handle(View_capability view_cap, View_handle handle)
Gui_session::View_handle
Gui_session::view_handle(View_capability view_cap, View_handle handle)
{
auto lambda = [&] (View_component *view)
auto lambda = [&] (View *view)
{
return (view) ? _view_handle_registry.alloc(*view, handle)
: View_handle();
@ -380,17 +376,17 @@ Session_component::view_handle(View_capability view_cap, View_handle handle)
}
View_capability Session_component::view_capability(View_handle handle)
View_capability Gui_session::view_capability(View_handle handle)
{
try {
Locked_ptr<View_component> view(_view_handle_registry.lookup(handle));
Locked_ptr<View> view(_view_handle_registry.lookup(handle));
return view.valid() ? view->cap() : View_capability();
}
catch (View_handle_registry::Lookup_failed) { return View_capability(); }
}
void Session_component::release_view_handle(View_handle handle)
void Gui_session::release_view_handle(View_handle handle)
{
try {
_view_handle_registry.free(handle); }
@ -402,7 +398,7 @@ void Session_component::release_view_handle(View_handle handle)
}
void Session_component::execute()
void Gui_session::execute()
{
for (unsigned i = 0; i < _command_buffer.num(); i++) {
try {
@ -413,13 +409,13 @@ void Session_component::execute()
}
Framebuffer::Mode Session_component::mode()
Framebuffer::Mode Gui_session::mode()
{
return Framebuffer::Mode { .area = screen_area(_framebuffer.mode().area) };
return Framebuffer::Mode { .area = screen_area(_screen_size) };
}
void Session_component::buffer(Framebuffer::Mode mode, bool use_alpha)
void Gui_session::buffer(Framebuffer::Mode mode, bool use_alpha)
{
/* check if the session quota suffices for the specified mode */
if (_buffer_size + _ram_quota_guard().avail().value < ram_quota(mode, use_alpha))
@ -433,14 +429,14 @@ void Session_component::buffer(Framebuffer::Mode mode, bool use_alpha)
}
void Session_component::focus(Capability<Gui::Session> session_cap)
void Gui_session::focus(Capability<Gui::Session> session_cap)
{
if (this->cap() == session_cap)
return;
_forwarded_focus = nullptr;
_env.ep().rpc_ep().apply(session_cap, [&] (Session_component *session) {
_env.ep().rpc_ep().apply(session_cap, [&] (Gui_session *session) {
if (session)
_forwarded_focus = session; });
@ -448,7 +444,7 @@ void Session_component::focus(Capability<Gui::Session> session_cap)
}
void Session_component::session_control(Label suffix, Session_control control)
void Gui_session::session_control(Label suffix, Session_control control)
{
switch (control) {
case SESSION_CONTROL_HIDE:
@ -466,7 +462,7 @@ void Session_component::session_control(Label suffix, Session_control control)
}
Buffer *Session_component::realloc_buffer(Framebuffer::Mode mode, bool use_alpha)
Buffer *Gui_session::realloc_buffer(Framebuffer::Mode mode, bool use_alpha)
{
typedef Pixel_rgb888 PT;

View File

@ -1,5 +1,5 @@
/*
* \brief Nitpicker session component
* \brief GUI session component
* \author Norman Feske
* \date 2017-11-16
*/
@ -11,8 +11,8 @@
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _SESSION_COMPONENT_H_
#define _SESSION_COMPONENT_H_
#ifndef _GUI_SESSION_H_
#define _GUI_SESSION_H_
/* Genode includes */
#include <util/list.h>
@ -30,15 +30,15 @@
#include "input_session.h"
#include "focus.h"
#include "chunky_texture.h"
#include "view_component.h"
#include "view.h"
namespace Nitpicker {
class Visibility_controller;
class Session_component;
class View_component;
class Gui_session;
class View;
typedef List<Session_component> Session_list;
typedef List<Gui_session> Session_list;
}
@ -52,22 +52,22 @@ struct Nitpicker::Visibility_controller : Interface
};
class Nitpicker::Session_component : public Session_object<Gui::Session>,
public View_owner,
public Buffer_provider,
private Session_list::Element
class Nitpicker::Gui_session : public Session_object<Gui::Session>,
public View_owner,
public Buffer_provider,
private Session_list::Element
{
private:
friend class List<Session_component>;
friend class List<Gui_session>;
using Gui::Session::Label;
/*
* Noncopyable
*/
Session_component(Session_component const &);
Session_component &operator = (Session_component const &);
Gui_session(Gui_session const &);
Gui_session &operator = (Gui_session const &);
Env &_env;
@ -75,7 +75,7 @@ class Nitpicker::Session_component : public Session_object<Gui::Session>,
Domain_registry::Entry const *_domain = nullptr;
Texture_base const *_texture = nullptr;
View_component *_background = nullptr;
View *_background = nullptr;
/*
* The input mask buffer containing a byte value per texture pixel,
@ -93,7 +93,7 @@ class Nitpicker::Session_component : public Session_object<Gui::Session>,
Sliced_heap _session_alloc;
Framebuffer::Session &_framebuffer;
Area const &_screen_size;
Framebuffer::Session_component _framebuffer_session_component;
@ -104,19 +104,17 @@ class Nitpicker::Session_component : public Session_object<Gui::Session>,
View_stack &_view_stack;
Font const &_font;
Focus_updater &_focus_updater;
Signal_context_capability _mode_sigh { };
View_component &_pointer_origin;
View &_pointer_origin;
View_component &_builtin_background;
View &_builtin_background;
List<Session_view_list_elem> _view_list { };
Tslab<View_component, 4000> _view_alloc { &_session_alloc };
Tslab<View, 4000> _view_alloc { &_session_alloc };
/* capabilities for sub sessions */
Framebuffer::Session_capability _framebuffer_session_cap;
@ -135,7 +133,7 @@ class Nitpicker::Session_component : public Session_object<Gui::Session>,
Command_buffer &_command_buffer = *_command_ds.local_addr<Command_buffer>();
typedef Handle_registry<View_handle, View_component> View_handle_registry;
typedef Handle_registry<View_handle, View> View_handle_registry;
View_handle_registry _view_handle_registry;
@ -143,7 +141,7 @@ class Nitpicker::Session_component : public Session_object<Gui::Session>,
Visibility_controller &_visibility_controller;
Session_component *_forwarded_focus = nullptr;
Gui_session *_forwarded_focus = nullptr;
/**
* Calculate session-local coordinate to physical screen position
@ -169,31 +167,30 @@ class Nitpicker::Session_component : public Session_object<Gui::Session>,
void _execute_command(Command const &);
void _destroy_view(View_component &);
void _destroy_view(View &);
public:
Session_component(Env &env,
Resources const &resources,
Label const &label,
Diag const &diag,
View_stack &view_stack,
Font const &font,
Focus_updater &focus_updater,
View_component &pointer_origin,
View_component &builtin_background,
Framebuffer::Session &framebuffer,
bool provides_default_bg,
Reporter &focus_reporter,
Visibility_controller &visibility_controller)
Gui_session(Env &env,
Resources const &resources,
Label const &label,
Diag const &diag,
View_stack &view_stack,
Focus_updater &focus_updater,
View &pointer_origin,
View &builtin_background,
Area const &screen_size,
bool provides_default_bg,
Reporter &focus_reporter,
Visibility_controller &visibility_controller)
:
Session_object(env.ep(), resources, label, diag),
_env(env),
_ram(env.ram(), _ram_quota_guard(), _cap_quota_guard()),
_session_alloc(_ram, env.rm()),
_framebuffer(framebuffer),
_framebuffer_session_component(view_stack, *this, framebuffer, *this),
_view_stack(view_stack), _font(font), _focus_updater(focus_updater),
_screen_size(screen_size),
_framebuffer_session_component(view_stack, *this, *this),
_view_stack(view_stack), _focus_updater(focus_updater),
_pointer_origin(pointer_origin),
_builtin_background(builtin_background),
_framebuffer_session_cap(_env.ep().manage(_framebuffer_session_component)),
@ -204,7 +201,7 @@ class Nitpicker::Session_component : public Session_object<Gui::Session>,
_visibility_controller(visibility_controller)
{ }
~Session_component()
~Gui_session()
{
_env.ep().dissolve(_framebuffer_session_component);
_env.ep().dissolve(_input_session_component);
@ -247,7 +244,7 @@ class Nitpicker::Session_component : public Session_object<Gui::Session>,
bool has_same_domain(View_owner const *owner) const override
{
if (!owner) return false;
return static_cast<Session_component const &>(*owner)._domain == _domain;
return static_cast<Gui_session const &>(*owner)._domain == _domain;
}
bool has_focusable_domain() const override
@ -353,7 +350,7 @@ class Nitpicker::Session_component : public Session_object<Gui::Session>,
_framebuffer_session_component.submit_sync();
}
void forget(Session_component &session)
void forget(Gui_session &session)
{
if (_forwarded_focus == &session)
_forwarded_focus = nullptr;
@ -361,7 +358,7 @@ class Nitpicker::Session_component : public Session_object<Gui::Session>,
/*********************************
** Nitpicker session interface **
** GUI session interface **
*********************************/
Framebuffer::Session_capability framebuffer_session() override {
@ -402,4 +399,4 @@ class Nitpicker::Session_component : public Session_object<Gui::Session>,
Buffer *realloc_buffer(Framebuffer::Mode mode, bool use_alpha) override;
};
#endif /* _SESSION_COMPONENT_H_ */
#endif /* _GUI_SESSION_H_ */

View File

@ -1,5 +1,5 @@
/*
* \brief Input sub session as part of the nitpicker session
* \brief Input sub session as part of the GUI session
* \author Norman Feske
* \date 2017-11-16
*/

View File

@ -1,5 +1,5 @@
/*
* \brief Nitpicker main program for Genode
* \brief Nitpicker main program
* \author Norman Feske
* \date 2006-08-04
*/
@ -32,7 +32,7 @@
#include "domain_registry.h"
namespace Nitpicker {
template <typename> class Root;
class Gui_root;
struct Main;
}
@ -56,13 +56,12 @@ void Framebuffer::Session_component::refresh(int x, int y, int w, int h)
}
/*****************************************
** Implementation of Nitpicker service **
*****************************************/
/***************************************
** Implementation of the GUI service **
***************************************/
template <typename PT>
class Nitpicker::Root : public Root_component<Session_component>,
public Visibility_controller
class Nitpicker::Gui_root : public Root_component<Gui_session>,
public Visibility_controller
{
private:
@ -71,33 +70,30 @@ class Nitpicker::Root : public Root_component<Session_component>,
Session_list &_session_list;
Domain_registry const &_domain_registry;
Global_keys &_global_keys;
Framebuffer::Mode _scr_mode { };
View_stack &_view_stack;
Font const &_font;
User_state &_user_state;
View_component &_pointer_origin;
View_component &_builtin_background;
Framebuffer::Session &_framebuffer;
View &_pointer_origin;
View &_builtin_background;
Area const &_screen_size;
Reporter &_focus_reporter;
Reporter &_hover_reporter;
Focus_updater &_focus_updater;
protected:
Session_component *_create_session(const char *args) override
Gui_session *_create_session(const char *args) override
{
Session_label const label = label_from_args(args);
bool const provides_default_bg = (label == "backdrop");
Session_component *session = new (md_alloc())
Session_component(_env,
session_resources_from_args(args), label,
session_diag_from_args(args),
_view_stack, _font, _focus_updater,
_pointer_origin, _builtin_background, _framebuffer,
provides_default_bg,
_focus_reporter, *this);
Gui_session *session = new (md_alloc())
Gui_session(_env,
session_resources_from_args(args), label,
session_diag_from_args(args),
_view_stack, _focus_updater, _pointer_origin,
_builtin_background, _screen_size,
provides_default_bg, _focus_reporter, *this);
session->apply_session_policy(_config.xml(), _domain_registry);
_session_list.insert(session);
@ -107,16 +103,16 @@ class Nitpicker::Root : public Root_component<Session_component>,
return session;
}
void _upgrade_session(Session_component *s, const char *args) override
void _upgrade_session(Gui_session *s, const char *args) override
{
s->upgrade(ram_quota_from_args(args));
s->upgrade(cap_quota_from_args(args));
}
void _destroy_session(Session_component *session) override
void _destroy_session(Gui_session *session) override
{
/* invalidate pointers held by other sessions to the destroyed session */
for (Session_component *s = _session_list.first(); s; s = s->next())
for (Gui_session *s = _session_list.first(); s; s = s->next())
s->forget(*session);
_session_list.remove(session);
@ -145,23 +141,29 @@ class Nitpicker::Root : public Root_component<Session_component>,
/**
* Constructor
*/
Root(Env &env, Attached_rom_dataspace const &config,
Session_list &session_list, Domain_registry const &domain_registry,
Global_keys &global_keys, View_stack &view_stack, Font const &font,
User_state &user_state, View_component &pointer_origin,
View_component &builtin_background, Allocator &md_alloc,
Framebuffer::Session &framebuffer, Reporter &focus_reporter,
Reporter &hover_reporter, Focus_updater &focus_updater)
Gui_root(Env &env,
Attached_rom_dataspace const &config,
Session_list &session_list,
Domain_registry const &domain_registry,
Global_keys &global_keys,
View_stack &view_stack,
User_state &user_state,
View &pointer_origin,
View &builtin_background,
Allocator &md_alloc,
Area const &screen_size,
Reporter &focus_reporter,
Reporter &hover_reporter,
Focus_updater &focus_updater)
:
Root_component<Session_component>(&env.ep().rpc_ep(), &md_alloc),
Root_component<Gui_session>(&env.ep().rpc_ep(), &md_alloc),
_env(env), _config(config), _session_list(session_list),
_domain_registry(domain_registry), _global_keys(global_keys),
_view_stack(view_stack), _font(font), _user_state(user_state),
_view_stack(view_stack), _user_state(user_state),
_pointer_origin(pointer_origin),
_builtin_background(builtin_background),
_framebuffer(framebuffer),
_focus_reporter(focus_reporter), _hover_reporter(hover_reporter),
_focus_updater(focus_updater)
_screen_size(screen_size), _focus_reporter(focus_reporter),
_hover_reporter(hover_reporter), _focus_updater(focus_updater)
{ }
@ -174,7 +176,7 @@ class Nitpicker::Root : public Root_component<Session_component>,
{
Gui::Session::Label const selector(label, suffix);
for (Session_component *s = _session_list.first(); s; s = s->next())
for (Gui_session *s = _session_list.first(); s; s = s->next())
if (s->matches_session_label(selector))
s->visible(visible);
@ -259,8 +261,12 @@ struct Nitpicker::Main : Focus_updater
Reconstructible<Domain_registry> _domain_registry {
_domain_registry_heap, Xml_node("<config/>") };
Tff_font::Static_glyph_buffer<4096> _glyph_buffer { };
Tff_font const _font { _binary_default_tff_start, _glyph_buffer };
Focus _focus { };
View_stack _view_stack { _fb_screen->screen.size(), _focus };
View_stack _view_stack { _fb_screen->screen.size(), _focus, _font };
User_state _user_state { _focus, _global_keys, _view_stack, _initial_pointer_pos() };
View_owner _global_view_owner { };
@ -273,7 +279,7 @@ struct Nitpicker::Main : Focus_updater
Background _builtin_background = { _global_view_owner, Area(99999, 99999) };
/*
* Initialize Nitpicker root interface
* Initialize GUI root interface
*/
Sliced_heap _sliced_heap { _env.ram(), _env.rm() };
@ -288,13 +294,9 @@ struct Nitpicker::Main : Focus_updater
Constructible<Attached_rom_dataspace> _focus_rom { };
Tff_font::Static_glyph_buffer<4096> _glyph_buffer { };
Tff_font const _font { _binary_default_tff_start, _glyph_buffer };
Root<PT> _root { _env, _config_rom, _session_list, *_domain_registry,
_global_keys, _view_stack, _font, _user_state, _pointer_origin,
_builtin_background, _sliced_heap, _framebuffer,
Gui_root _root { _env, _config_rom, _session_list, *_domain_registry,
_global_keys, _view_stack, _user_state, _pointer_origin,
_builtin_background, _sliced_heap, _fb_screen->size,
_focus_reporter, _hover_reporter, *this };
/**
@ -364,7 +366,7 @@ struct Nitpicker::Main : Focus_updater
*/
void _draw_and_flush()
{
_view_stack.draw(_fb_screen->screen, _font).flush([&] (Rect const &rect) {
_view_stack.draw(_fb_screen->screen).flush([&] (Rect const &rect) {
_framebuffer.refresh(rect.x1(), rect.y1(),
rect.w(), rect.h()); });
}
@ -470,14 +472,14 @@ void Nitpicker::Main::_handle_input()
_view_stack.geometry(_pointer_origin, Rect(_user_state.pointer_pos(), Area()));
/* perform redraw and flush pixels to the framebuffer */
_view_stack.draw(_fb_screen->screen, _font).flush([&] (Rect const &rect) {
_view_stack.draw(_fb_screen->screen).flush([&] (Rect const &rect) {
_framebuffer.refresh(rect.x1(), rect.y1(),
rect.w(), rect.h()); });
_view_stack.mark_all_views_as_clean();
/* deliver framebuffer synchronization events */
for (Session_component *s = _session_list.first(); s; s = s->next())
for (Gui_session *s = _session_list.first(); s; s = s->next())
s->submit_sync();
}
@ -509,7 +511,7 @@ void Nitpicker::Main::_handle_focus()
* Determine session that matches the label found in the focus ROM
*/
View_owner *next_focus = nullptr;
for (Session_component *s = _session_list.first(); s; s = s->next())
for (Gui_session *s = _session_list.first(); s; s = s->next())
if (s->label() == label)
next_focus = s;
@ -544,13 +546,13 @@ void Nitpicker::Main::_handle_config()
configure_reporter(config, _displays_reporter);
/* update domain registry and session policies */
for (Session_component *s = _session_list.first(); s; s = s->next())
for (Gui_session *s = _session_list.first(); s; s = s->next())
s->reset_domain();
try { _domain_registry.construct(_domain_registry_heap, config); }
catch (...) { }
for (Session_component *s = _session_list.first(); s; s = s->next()) {
for (Gui_session *s = _session_list.first(); s; s = s->next()) {
s->apply_session_policy(config, *_domain_registry);
s->notify_mode_change();
}
@ -614,7 +616,7 @@ void Nitpicker::Main::_handle_fb_mode()
_view_stack.update_all_views();
/* notify clients about the change screen mode */
for (Session_component *s = _session_list.first(); s; s = s->next())
for (Gui_session *s = _session_list.first(); s; s = s->next())
s->notify_mode_change();
_report_displays();

View File

@ -14,24 +14,23 @@
#ifndef _POINTER_ORIGIN_H_
#define _POINTER_ORIGIN_H_
#include "view_component.h"
#include "session_component.h"
#include "view.h"
#include "gui_session.h"
namespace Nitpicker { struct Pointer_origin; }
struct Nitpicker::Pointer_origin : View_component
struct Nitpicker::Pointer_origin : View
{
Pointer_origin(View_owner &owner)
:
View_component(owner, View_component::TRANSPARENT,
View_component::NOT_BACKGROUND, 0)
View(owner, View::TRANSPARENT, View::NOT_BACKGROUND, 0)
{ }
/******************************
** View_component interface **
******************************/
/********************
** View interface **
********************/
int frame_size(Focus const &) const override { return 0; }
void frame(Canvas_base &, Focus const &) const override { }

View File

@ -38,7 +38,7 @@ namespace Nitpicker {
static inline Color black() { return Color(0, 0, 0); }
static inline Color white() { return Color(255, 255, 255); }
class Session_component;
class Gui_session;
class View_stack;
}

View File

@ -124,7 +124,7 @@ void User_state::_handle_input_event(Input::Event ev)
_key_array.pressed(key, false);
});
View_component const * const pointed_view = _view_stack.find_view(_pointer_pos);
View const * const pointed_view = _view_stack.find_view(_pointer_pos);
View_owner * const hovered = pointed_view ? &pointed_view->owner() : 0;
@ -420,7 +420,7 @@ User_state::Handle_forget_result User_state::forget(View_owner const &owner)
if (&owner == _last_clicked) _last_clicked = nullptr;
if (_hovered == &owner) {
View_component * const pointed_view = _view_stack.find_view(_pointer_pos);
View * const pointed_view = _view_stack.find_view(_pointer_pos);
_hovered = pointed_view ? &pointed_view->owner() : nullptr;
}

View File

@ -16,9 +16,9 @@
#include <nitpicker_gfx/texture_painter.h>
#include <nitpicker_gfx/box_painter.h>
#include "view_component.h"
#include "view.h"
#include "clip_guard.h"
#include "session_component.h"
#include "gui_session.h"
#include "draw_label.h"
@ -63,8 +63,9 @@ namespace Nitpicker {
texture_painter_mode(Focus const &focus, View_owner const &owner)
{
/*
* Tint view unless it belongs to a domain that is explicitly configured to
* display the raw client content or if belongs to the focused domain.
* Tint view unless it belongs to a domain that is explicitly
* configured to display the raw client content or if belongs to the
* focused domain.
*/
if (owner.content_client() || focus.same_domain_as_focused(owner))
return Texture_painter::SOLID;
@ -73,10 +74,8 @@ namespace Nitpicker {
}
}
using namespace Nitpicker;
void View_component::title(Font const &font, Title const &title)
void Nitpicker::View::title(Font const &font, Title const &title)
{
_title = title;
@ -86,7 +85,7 @@ void View_component::title(Font const &font, Title const &title)
}
void View_component::frame(Canvas_base &canvas, Focus const &focus) const
void Nitpicker::View::frame(Canvas_base &canvas, Focus const &focus) const
{
if (!_owner.label_visible())
return;
@ -97,7 +96,7 @@ void View_component::frame(Canvas_base &canvas, Focus const &focus) const
}
void View_component::draw(Canvas_base &canvas, Font const &font, Focus const &focus) const
void Nitpicker::View::draw(Canvas_base &canvas, Font const &font, Focus const &focus) const
{
Texture_painter::Mode const op = texture_painter_mode(focus, _owner);
@ -143,7 +142,7 @@ void View_component::draw(Canvas_base &canvas, Font const &font, Focus const &fo
}
void View_component::apply_origin_policy(View_component &pointer_origin)
void Nitpicker::View::apply_origin_policy(View &pointer_origin)
{
if (owner().origin_pointer() && !has_parent(pointer_origin))
_assign_parent(&pointer_origin);
@ -153,7 +152,7 @@ void View_component::apply_origin_policy(View_component &pointer_origin)
}
bool View_component::input_response_at(Point p) const
bool Nitpicker::View::input_response_at(Point p) const
{
Rect const view_rect = abs_geometry();
@ -170,7 +169,7 @@ bool View_component::input_response_at(Point p) const
}
int View_component::frame_size(Focus const &focus) const
int Nitpicker::View::frame_size(Focus const &focus) const
{
if (!_owner.label_visible()) return 0;
@ -178,13 +177,13 @@ int View_component::frame_size(Focus const &focus) const
}
bool View_component::transparent() const
bool Nitpicker::View::transparent() const
{
return _transparent || _owner.uses_alpha();
}
bool View_component::uses_alpha() const
bool Nitpicker::View::uses_alpha() const
{
return _owner.uses_alpha();
}

View File

@ -52,7 +52,7 @@ namespace Nitpicker {
*/
struct Session_view_list_elem : List<Session_view_list_elem>::Element { };
class View_component;
class View;
}
@ -66,12 +66,12 @@ namespace Gui {
}
class Nitpicker::View_component : private Same_buffer_list_elem,
private Session_view_list_elem,
private View_stack_elem,
private View_parent_elem,
private Weak_object<View_component>,
public Rpc_object<Gui::View>
class Nitpicker::View : private Same_buffer_list_elem,
private Session_view_list_elem,
private View_stack_elem,
private View_parent_elem,
private Weak_object<View>,
public Rpc_object<Gui::View>
{
public:
@ -80,31 +80,31 @@ class Nitpicker::View_component : private Same_buffer_list_elem,
enum Transparent { NOT_TRANSPARENT = 0, TRANSPARENT = 1 };
enum Background { NOT_BACKGROUND = 0, BACKGROUND = 1 };
using Weak_object<View_component>::weak_ptr;
using Weak_object<View_component>::weak_ptr_const;
using Weak_object<View>::weak_ptr;
using Weak_object<View>::weak_ptr_const;
private:
friend class View_stack;
friend class Session_component;
friend class Locked_ptr<View_component>;
friend class Gui_session;
friend class Locked_ptr<View>;
/*
* Noncopyable
*/
View_component(View_component const &);
View_component &operator = (View_component const &);
View(View const &);
View &operator = (View const &);
Transparent const _transparent; /* background is partly visible */
Background _background; /* view is a background view */
View_component *_parent; /* parent view */
Rect _geometry { }; /* position and size relative to parent */
Rect _label_rect { }; /* position and size of label */
Point _buffer_off { }; /* offset to the visible buffer area */
View_owner &_owner;
Title _title { "" };
Dirty_rect _dirty_rect { };
View *_parent; /* parent view */
Rect _geometry { }; /* position and size relative to parent */
Rect _label_rect { }; /* position and size of label */
Point _buffer_off { }; /* offset to the visible buffer area */
View_owner &_owner;
Title _title { "" };
Dirty_rect _dirty_rect { };
List<View_parent_elem> _children { };
@ -115,7 +115,7 @@ class Nitpicker::View_component : private Same_buffer_list_elem,
* of the view. However, if the domain origin changes at runtime, we
* need to dynamically re-assign the pointer origin as the parent.
*/
void _assign_parent(View_component *parent)
void _assign_parent(View *parent)
{
if (_parent == parent)
return;
@ -131,13 +131,12 @@ class Nitpicker::View_component : private Same_buffer_list_elem,
public:
View_component(View_owner &owner, Transparent transparent,
Background bg, View_component *parent)
View(View_owner &owner, Transparent transparent, Background bg, View *parent)
:
_transparent(transparent), _background(bg), _parent(parent), _owner(owner)
{ }
virtual ~View_component()
virtual ~View()
{
/* invalidate weak pointers to this object */
lock_for_destruction();
@ -148,7 +147,7 @@ class Nitpicker::View_component : private Same_buffer_list_elem,
/* break links to our children */
while (View_parent_elem *e = _children.first()) {
static_cast<View_component *>(e)->dissolve_from_parent();
static_cast<View *>(e)->dissolve_from_parent();
_children.remove(e);
}
}
@ -181,28 +180,28 @@ class Nitpicker::View_component : private Same_buffer_list_elem,
_geometry = Rect();
}
bool has_parent(View_component const &parent) const { return &parent == _parent; }
bool has_parent(View const &parent) const { return &parent == _parent; }
void apply_origin_policy(View_component &pointer_origin);
void apply_origin_policy(View &pointer_origin);
Rect geometry() const { return _geometry; }
void geometry(Rect geometry) { _geometry = geometry; }
void add_child(View_component const &child) { _children.insert(&child); }
void add_child(View const &child) { _children.insert(&child); }
void remove_child(View_component const &child) { _children.remove(&child); }
void remove_child(View const &child) { _children.remove(&child); }
template <typename FN>
void for_each_child(FN const &fn) {
for (View_parent_elem *e = _children.first(); e; e = e->next())
fn(*static_cast<View_component *>(e));
fn(*static_cast<View *>(e));
}
template <typename FN>
void for_each_const_child(FN const &fn) const {
for (View_parent_elem const *e = _children.first(); e; e = e->next())
fn(*static_cast<View_component const *>(e));
fn(*static_cast<View const *>(e));
}
/**
@ -228,11 +227,11 @@ class Nitpicker::View_component : private Same_buffer_list_elem,
/**
* Return successor in view stack
*/
View_component const *view_stack_next() const {
return static_cast<View_component const *>(View_stack_elem::next()); }
View const *view_stack_next() const {
return static_cast<View const *>(View_stack_elem::next()); }
View_component *view_stack_next() {
return static_cast<View_component *>(View_stack_elem::next()); }
View *view_stack_next() {
return static_cast<View *>(View_stack_elem::next()); }
/**
* Set view as background
@ -252,7 +251,7 @@ class Nitpicker::View_component : private Same_buffer_list_elem,
return &owner == &_owner;
}
bool same_owner_as(View_component const &other) const
bool same_owner_as(View const &other) const
{
return &_owner == &other._owner;
}

View File

@ -1,5 +1,5 @@
/*
* \brief Nitpicker view stack implementation
* \brief Nitpicker view-stack implementation
* \author Norman Feske
* \date 2006-08-09
*/
@ -40,7 +40,7 @@ VIEW *View_stack::_next_view(VIEW &view) const
}
Nitpicker::Rect View_stack::_outline(View_component const &view) const
Nitpicker::Rect View_stack::_outline(View const &view) const
{
Rect const rect = view.abs_geometry();
@ -52,7 +52,7 @@ Nitpicker::Rect View_stack::_outline(View_component const &view) const
}
View_component const *View_stack::_target_stack_position(View_component const *neighbor, bool behind)
Nitpicker::View const *View_stack::_target_stack_position(View const *neighbor, bool behind)
{
if (behind) {
@ -60,7 +60,7 @@ View_component const *View_stack::_target_stack_position(View_component const *n
return nullptr;
/* find target position behind neighbor */
for (View_component const *cv = _first_view(); cv; cv = _next_view(*cv))
for (View const *cv = _first_view(); cv; cv = _next_view(*cv))
if (cv == neighbor)
return cv;
@ -70,7 +70,7 @@ View_component const *View_stack::_target_stack_position(View_component const *n
return nullptr;
/* find target position in front of neighbor */
for (View_component const *cv = _first_view(), *next = nullptr; cv; cv = next) {
for (View const *cv = _first_view(), *next = nullptr; cv; cv = next) {
next = _next_view(*cv);
if (!next || next == neighbor || next->background())
@ -83,7 +83,7 @@ View_component const *View_stack::_target_stack_position(View_component const *n
}
void View_stack::_optimize_label_rec(View_component const *cv, View_component const *lv,
void View_stack::_optimize_label_rec(View const *cv, View const *lv,
Rect rect, Rect *optimal)
{
/* if label already fits in optimized rectangle, we are happy */
@ -136,8 +136,8 @@ void View_stack::_place_labels(Rect rect)
*/
/* ignore mouse cursor */
View_component const *start = _next_view(*_first_view());
View_component *view = _next_view(*_first_view());
View const *start = _next_view(*_first_view());
View *view = _next_view(*_first_view());
for (; view && _next_view(*view); view = _next_view(*view)) {
@ -169,7 +169,7 @@ void View_stack::_place_labels(Rect rect)
void View_stack::draw_rec(Canvas_base &canvas, Font const &font,
View_component const *view, Rect rect) const
View const *view, Rect rect) const
{
Rect clipped;
@ -183,7 +183,7 @@ void View_stack::draw_rec(Canvas_base &canvas, Font const &font,
Rect top, left, right, bottom;
rect.cut(clipped, &top, &left, &right, &bottom);
View_component const *next = _next_view(*view);
View const *next = _next_view(*view);
/* draw areas at the top/left of the current view */
if (next && top.valid()) draw_rec(canvas, font, next, top);
@ -208,21 +208,21 @@ void View_stack::draw_rec(Canvas_base &canvas, Font const &font,
}
void View_stack::refresh_view(View_component &view, Rect const rect)
void View_stack::refresh_view(View &view, Rect const rect)
{
/* rectangle constrained to view geometry */
Rect const view_rect = Rect::intersect(rect, _outline(view));
for (View_component *v = _first_view(); v; v = v->view_stack_next())
for (View *v = _first_view(); v; v = v->view_stack_next())
_mark_view_as_dirty(*v, view_rect);
view.for_each_child([&] (View_component &child) { refresh_view(child, rect); });
view.for_each_child([&] (View &child) { refresh_view(child, rect); });
}
void View_stack::refresh(Rect const rect)
{
for (View_component *v = _first_view(); v; v = v->view_stack_next()) {
for (View *v = _first_view(); v; v = v->view_stack_next()) {
Rect const intersection = Rect::intersect(rect, _outline(*v));
@ -232,7 +232,7 @@ void View_stack::refresh(Rect const rect)
}
void View_stack::geometry(View_component &view, Rect const rect)
void View_stack::geometry(View &view, Rect const rect)
{
Rect const old_outline = _outline(view);
@ -259,7 +259,7 @@ void View_stack::geometry(View_component &view, Rect const rect)
}
void View_stack::buffer_offset(View_component &view, Point const buffer_off)
void View_stack::buffer_offset(View &view, Point const buffer_off)
{
view.buffer_off(buffer_off);
@ -267,7 +267,7 @@ void View_stack::buffer_offset(View_component &view, Point const buffer_off)
}
void View_stack::stack(View_component &view, View_component const *neighbor, bool behind)
void View_stack::stack(View &view, View const *neighbor, bool behind)
{
_views.remove(&view);
_views.insert(&view, _target_stack_position(neighbor, behind));
@ -281,18 +281,18 @@ void View_stack::stack(View_component &view, View_component const *neighbor, boo
}
void View_stack::title(View_component &view, Font const &font, const char *title)
void View_stack::title(View &view, const char *title)
{
view.title(font, title);
view.title(_font, title);
_place_labels(view.abs_geometry());
_mark_view_as_dirty(view, _outline(view));
}
View_component *View_stack::find_view(Point p)
Nitpicker::View *View_stack::find_view(Point p)
{
View_component *view = _first_view();
View *view = _first_view();
for ( ; view; view = _next_view(*view))
if (view->input_response_at(p))
@ -302,9 +302,9 @@ View_component *View_stack::find_view(Point p)
}
void View_stack::remove_view(View_component const &view, bool /* redraw */)
void View_stack::remove_view(View const &view, bool /* redraw */)
{
view.for_each_const_child([&] (View_component const &child) { remove_view(child); });
view.for_each_const_child([&] (View const &child) { remove_view(child); });
/* remember geometry of view to remove */
Rect rect = _outline(view);
@ -329,7 +329,7 @@ void View_stack::sort_views_by_layer()
unsigned lowest_layer = ~0U;
View_stack_elem *lowest_view = nullptr;
for (View_stack_elem *v = _views.first(); v; v = v->next()) {
unsigned const layer = static_cast<View_component *>(v)->owner().layer();
unsigned const layer = static_cast<View *>(v)->owner().layer();
if (layer < lowest_layer) {
lowest_layer = layer;
lowest_view = v;
@ -359,8 +359,8 @@ void View_stack::to_front(char const *selector)
* Move all views that match the selector to the front while
* maintaining their ordering.
*/
View_component *at = nullptr;
for (View_component *v = _first_view(); v; v = v->view_stack_next()) {
View *at = nullptr;
for (View *v = _first_view(); v; v = v->view_stack_next()) {
if (!v->owner().matches_session_label(selector))
continue;

View File

@ -14,8 +14,8 @@
#ifndef _VIEW_STACK_H_
#define _VIEW_STACK_H_
#include "view_component.h"
#include "session_component.h"
#include "view.h"
#include "gui_session.h"
#include "canvas.h"
namespace Nitpicker { class View_stack; }
@ -27,8 +27,9 @@ class Nitpicker::View_stack
Area _size;
Focus &_focus;
Font const &_font;
List<View_stack_elem> _views { };
View_component *_default_background = nullptr;
View *_default_background = nullptr;
Dirty_rect mutable _dirty_rect { };
/**
@ -38,30 +39,30 @@ class Nitpicker::View_stack
* Nitpicker mode. In non-flat modes, we incorporate the surrounding
* frame.
*/
Rect _outline(View_component const &view) const;
Rect _outline(View const &view) const;
/**
* Return top-most view of the view stack
*/
View_component const *_first_view() const
View const *_first_view() const
{
return static_cast<View_component const *>(_views.first());
return static_cast<View const *>(_views.first());
}
View_component *_first_view()
View *_first_view()
{
return static_cast<View_component *>(_views.first());
return static_cast<View *>(_views.first());
}
/**
* Find position in view stack for inserting a view
*/
View_component const *_target_stack_position(View_component const *neighbor, bool behind);
View const *_target_stack_position(View const *neighbor, bool behind);
/**
* Find best visible label position
*/
void _optimize_label_rec(View_component const *cv, View_component const *lv,
void _optimize_label_rec(View const *cv, View const *lv,
Rect rect, Rect *optimal);
/**
@ -81,7 +82,7 @@ class Nitpicker::View_stack
/**
* Schedule 'rect' to be redrawn
*/
void _mark_view_as_dirty(View_component &view, Rect rect)
void _mark_view_as_dirty(View &view, Rect rect)
{
_dirty_rect.mark_as_dirty(rect);
@ -93,7 +94,9 @@ class Nitpicker::View_stack
/**
* Constructor
*/
View_stack(Area size, Focus &focus) : _size(size), _focus(focus)
View_stack(Area size, Focus &focus, Font const &font)
:
_size(size), _focus(focus), _font(font)
{
_dirty_rect.mark_as_dirty(Rect(Point(0, 0), _size));
}
@ -115,17 +118,17 @@ class Nitpicker::View_stack
*
* \param view current view in view stack
*/
void draw_rec(Canvas_base &, Font const &, View_component const *, Rect) const;
void draw_rec(Canvas_base &, Font const &, View const *, Rect) const;
/**
* Draw dirty areas
*/
Dirty_rect draw(Canvas_base &canvas, Font const &font) const
Dirty_rect draw(Canvas_base &canvas) const
{
Dirty_rect result = _dirty_rect;
_dirty_rect.flush([&] (Rect const &rect) {
draw_rec(canvas, font, _first_view(), rect); });
draw_rec(canvas, _font, _first_view(), rect); });
return result;
}
@ -140,7 +143,7 @@ class Nitpicker::View_stack
_place_labels(whole_screen);
_dirty_rect.mark_as_dirty(whole_screen);
for (View_component *view = _first_view(); view; view = view->view_stack_next())
for (View *view = _first_view(); view; view = view->view_stack_next())
view->mark_as_dirty(_outline(*view));
}
@ -149,7 +152,7 @@ class Nitpicker::View_stack
*/
void mark_all_views_as_clean()
{
for (View_component *view = _first_view(); view; view = view->view_stack_next())
for (View *view = _first_view(); view; view = view->view_stack_next())
view->mark_as_clean();
}
@ -159,9 +162,9 @@ class Nitpicker::View_stack
* \param Session Session that created the view
* \param Rect Buffer area to update
*/
void mark_session_views_as_dirty(Session_component const &session, Rect rect)
void mark_session_views_as_dirty(Gui_session const &session, Rect rect)
{
for (View_component *view = _first_view(); view; view = view->view_stack_next()) {
for (View *view = _first_view(); view; view = view->view_stack_next()) {
if (!view->owned_by(session))
continue;
@ -184,12 +187,12 @@ class Nitpicker::View_stack
*
* \param view view that should be updated on screen
*/
void refresh_view(View_component &view, Rect);
void refresh_view(View &view, Rect);
/**
* Refresh entire view
*/
void refresh_view(View_component &view) { refresh_view(view, _outline(view)); }
void refresh_view(View &view) { refresh_view(view, _outline(view)); }
/**
* Refresh area
@ -201,14 +204,14 @@ class Nitpicker::View_stack
*
* \param rect new geometry of view on screen
*/
void geometry(View_component &view, Rect rect);
void geometry(View &view, Rect rect);
/**
* Define buffer offset of view
*
* \param buffer_off view offset of displayed buffer
*/
void buffer_offset(View_component &view, Point buffer_off);
void buffer_offset(View &view, Point buffer_off);
/**
* Insert view at specified position in view stack
@ -221,40 +224,40 @@ class Nitpicker::View_stack
* bottom of the view stack, specify neighbor = 0 and
* behind = false.
*/
void stack(View_component &view, View_component const *neighbor = 0,
void stack(View &view, View const *neighbor = 0,
bool behind = true);
/**
* Set view title
*/
void title(View_component &view, Font const &font, char const *title);
void title(View &view, char const *title);
/**
* Find view at specified position
*/
View_component *find_view(Point);
View *find_view(Point);
/**
* Remove view from view stack
*/
void remove_view(View_component const &, bool redraw = true);
void remove_view(View const &, bool redraw = true);
/**
* Define default background
*/
void default_background(View_component &view) { _default_background = &view; }
void default_background(View &view) { _default_background = &view; }
/**
* Return true if view is the default background
*/
bool is_default_background(View_component const &view) const
bool is_default_background(View const &view) const
{
return &view == _default_background;
}
void apply_origin_policy(View_component &pointer_origin)
void apply_origin_policy(View &pointer_origin)
{
for (View_component *v = _first_view(); v; v = v->view_stack_next())
for (View *v = _first_view(); v; v = v->view_stack_next())
v->apply_origin_policy(pointer_origin);
}