/* * \brief Interface for obtaining widget style information * \author Norman Feske * \date 2009-09-11 */ /* * Copyright (C) 2014-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 _STYLE_DATABASE_H_ #define _STYLE_DATABASE_H_ /* gems includes */ #include #include #include #include /* local includes */ #include "types.h" namespace Menu_view { struct Style_database; } class Menu_view::Style_database { private: enum { PATH_MAX_LEN = 200 }; typedef String Path; typedef ::File::Reading_failed Reading_failed; struct Texture_entry : List::Element { Path const path; ::File png_file; Png_image png_image; Texture &texture; /** * Constructor * * \throw Reading_failed */ Texture_entry(Ram_session &ram, Region_map &rm, Allocator &alloc, Path const &path) : path(path), png_file(path.string(), alloc), png_image(ram, rm, alloc, png_file.data()), texture(*png_image.texture()) { } }; struct Font_entry : List::Element { Path const path; Cached_font::Limit _font_cache_limit { 256*1024 }; Vfs_font _vfs_font; Cached_font _cached_font; Text_painter::Font const &font() const { return _cached_font; } /** * Constructor * * \throw Reading_failed */ Font_entry(Directory const &fonts_dir, Path const &path, Allocator &alloc) try : path(path), _vfs_font(alloc, fonts_dir, path), _cached_font(alloc, _vfs_font, _font_cache_limit) { } catch (...) { throw Reading_failed(); } }; Ram_session &_ram; Region_map &_rm; Allocator &_alloc; Directory const &_fonts_dir; /* * The list is mutable because it is populated as a side effect of * calling the const lookup function. */ List mutable _textures { }; List mutable _fonts { }; template T const *_lookup(List &list, char const *path) const { for (T const *e = list.first(); e; e = e->next()) if (Genode::strcmp(e->path.string(), path) == 0) return e; return 0; } /* * Assemble path name 'styles//