mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-06 19:20:09 +00:00
parent
47ac55e9c5
commit
58f7ed268d
@ -85,8 +85,8 @@ class Window_layouter::Assign : public List_model<Assign>::Element
|
|||||||
_size = Area::from_xml(assign);
|
_size = Area::from_xml(assign);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Used by 'Assign_list::update_from_xml'
|
* List_model::Element
|
||||||
*/
|
*/
|
||||||
bool matches(Xml_node node) const
|
bool matches(Xml_node node) const
|
||||||
{
|
{
|
||||||
@ -95,6 +95,14 @@ class Window_layouter::Assign : public List_model<Assign>::Element
|
|||||||
&& node.attribute_value("label_suffix", Label()) == _label_suffix;
|
&& node.attribute_value("label_suffix", Label()) == _label_suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List_model::Element
|
||||||
|
*/
|
||||||
|
static bool type_matches(Xml_node const &node)
|
||||||
|
{
|
||||||
|
return node.has_type("assign");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate window geometry
|
* Calculate window geometry
|
||||||
*/
|
*/
|
||||||
|
@ -29,43 +29,21 @@ class Window_layouter::Assign_list : Noncopyable
|
|||||||
|
|
||||||
List_model<Assign> _assignments { };
|
List_model<Assign> _assignments { };
|
||||||
|
|
||||||
struct Update_policy : List_model<Assign>::Update_policy
|
|
||||||
{
|
|
||||||
Allocator &_alloc;
|
|
||||||
|
|
||||||
Update_policy(Allocator &alloc) : _alloc(alloc) { }
|
|
||||||
|
|
||||||
void destroy_element(Assign &elem) { destroy(_alloc, &elem); }
|
|
||||||
|
|
||||||
Assign &create_element(Xml_node node)
|
|
||||||
{
|
|
||||||
return *new (_alloc) Assign(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
void update_element(Assign &assign, Xml_node node)
|
|
||||||
{
|
|
||||||
assign.update(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool element_matches_xml_node(Assign const &elem, Xml_node node)
|
|
||||||
{
|
|
||||||
return elem.matches(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool node_is_element(Xml_node node)
|
|
||||||
{
|
|
||||||
return node.has_type("assign");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Assign_list(Allocator &alloc) : _alloc(alloc) { }
|
Assign_list(Allocator &alloc) : _alloc(alloc) { }
|
||||||
|
|
||||||
void update_from_xml(Xml_node node)
|
void update_from_xml(Xml_node node)
|
||||||
{
|
{
|
||||||
Update_policy policy(_alloc);
|
update_list_model_from_xml(_assignments, node,
|
||||||
_assignments.update_from_xml(policy, node);
|
|
||||||
|
[&] (Xml_node const &node) -> Assign & {
|
||||||
|
return *new (_alloc) Assign(node); },
|
||||||
|
|
||||||
|
[&] (Assign &assign) { destroy(_alloc, &assign); },
|
||||||
|
|
||||||
|
[&] (Assign &assign, Xml_node const &node) { assign.update(node); }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void assign_windows(Window_list &windows)
|
void assign_windows(Window_list &windows)
|
||||||
|
@ -502,6 +502,19 @@ class Window_layouter::Window : public List_model<Window>::Element
|
|||||||
|
|
||||||
_assign_member.construct(registry, *this);
|
_assign_member.construct(registry, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List_model::Element
|
||||||
|
*/
|
||||||
|
bool matches(Xml_node const &node) const
|
||||||
|
{
|
||||||
|
return node.attribute_value("id", 0U) == _id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List_model::Element
|
||||||
|
*/
|
||||||
|
static bool type_matches(Xml_node const &) { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _WINDOW_H_ */
|
#endif /* _WINDOW_H_ */
|
||||||
|
@ -50,26 +50,9 @@ class Window_layouter::Window_list
|
|||||||
_rom.update();
|
_rom.update();
|
||||||
|
|
||||||
/* import window-list changes */
|
/* import window-list changes */
|
||||||
Update_policy policy(*this);
|
update_list_model_from_xml(_list, _rom.xml(),
|
||||||
_list.update_from_xml(policy, _rom.xml());
|
|
||||||
|
|
||||||
/* notify main program */
|
[&] (Xml_node const &node) -> Window &
|
||||||
_change_handler.window_list_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Update_policy : List_model<Window>::Update_policy
|
|
||||||
{
|
|
||||||
Window_list &_window_list;
|
|
||||||
|
|
||||||
Update_policy(Window_list &window_list)
|
|
||||||
: _window_list(window_list) { }
|
|
||||||
|
|
||||||
void destroy_element(Window &elem)
|
|
||||||
{
|
|
||||||
destroy(_window_list._alloc, &elem);
|
|
||||||
}
|
|
||||||
|
|
||||||
Window &create_element(Xml_node node)
|
|
||||||
{
|
{
|
||||||
unsigned const id = node.attribute_value("id", 0U);
|
unsigned const id = node.attribute_value("id", 0U);
|
||||||
Area const initial_size = Area::from_xml(node);
|
Area const initial_size = Area::from_xml(node);
|
||||||
@ -77,26 +60,26 @@ class Window_layouter::Window_list
|
|||||||
Window::Label const label =
|
Window::Label const label =
|
||||||
node.attribute_value("label",Window::Label());
|
node.attribute_value("label",Window::Label());
|
||||||
|
|
||||||
return *new (_window_list._alloc)
|
return *new (_alloc)
|
||||||
Window(id, label, initial_size,
|
Window(id, label, initial_size,
|
||||||
_window_list._focus_history,
|
_focus_history, _decorator_margins);
|
||||||
_window_list._decorator_margins);
|
},
|
||||||
}
|
|
||||||
|
|
||||||
void update_element(Window &win, Xml_node node)
|
[&] (Window &window) { destroy(_alloc, &window); },
|
||||||
{
|
|
||||||
win.client_size(Area::from_xml(node));
|
|
||||||
win.title (node.attribute_value("title", Window::Title("")));
|
|
||||||
win.has_alpha (node.attribute_value("has_alpha", false));
|
|
||||||
win.hidden (node.attribute_value("hidden", false));
|
|
||||||
win.resizeable (node.attribute_value("resizeable", false));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool element_matches_xml_node(Window const &elem, Xml_node node)
|
[&] (Window &w, Xml_node const &node)
|
||||||
{
|
{
|
||||||
return elem.has_id(node.attribute_value("id", 0U));
|
w.client_size(Area::from_xml(node));
|
||||||
|
w.title (node.attribute_value("title", Window::Title("")));
|
||||||
|
w.has_alpha (node.attribute_value("has_alpha", false));
|
||||||
|
w.hidden (node.attribute_value("hidden", false));
|
||||||
|
w.resizeable (node.attribute_value("resizeable", false));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/* notify main program */
|
||||||
|
_change_handler.window_list_changed();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user