mirror of
https://github.com/xenia-project/elemental-forms.git
synced 2026-01-31 01:25:17 +01:00
Window->Form, cause names.
This commit is contained in:
@@ -273,50 +273,50 @@ elements
|
||||
img-position-x 0
|
||||
img-ofs-x 5
|
||||
|
||||
# == Window skin =================================================================================
|
||||
Window
|
||||
# == Form skin =================================================================================
|
||||
Form
|
||||
bitmap window.png
|
||||
cut 16
|
||||
expand 12
|
||||
padding 10
|
||||
overrides
|
||||
element Window.selected
|
||||
element Form.selected
|
||||
state selected
|
||||
Window.fullscreen
|
||||
clone Window
|
||||
Form.fullscreen
|
||||
clone Form
|
||||
expand 12
|
||||
padding 0
|
||||
Window.selected
|
||||
Form.selected
|
||||
bitmap window_active.png
|
||||
cut 16
|
||||
expand 12
|
||||
Window.close
|
||||
Form.close
|
||||
bitmap window_close.png
|
||||
type image
|
||||
children
|
||||
element Window.close.pressed
|
||||
element Form.close.pressed
|
||||
state pressed
|
||||
Window.close.pressed
|
||||
Form.close.pressed
|
||||
bitmap window_close_pressed.png
|
||||
type image
|
||||
Window.mover
|
||||
Form.mover
|
||||
text-color #b8b8b8
|
||||
bitmap window_mover_bg_tile.png
|
||||
type tile
|
||||
expand -1
|
||||
padding 4
|
||||
overrides
|
||||
element Window.mover.active
|
||||
element Form.mover.active
|
||||
state selected
|
||||
children
|
||||
element Window.mover.overlay
|
||||
element Form.mover.overlay
|
||||
state all
|
||||
Window.mover.overlay
|
||||
Form.mover.overlay
|
||||
bitmap window_mover_overlay.png
|
||||
cut 12
|
||||
expand 3
|
||||
Window.mover.active
|
||||
clone Window.mover
|
||||
Form.mover.active
|
||||
clone Form.mover
|
||||
text-color #fefefe
|
||||
overrides
|
||||
overlays
|
||||
@@ -373,13 +373,13 @@ elements
|
||||
clone Button
|
||||
DropDownButton.arrow
|
||||
clone arrow.down
|
||||
DropDownButton.window
|
||||
clone PopupWindow
|
||||
PopupWindow
|
||||
clone Window
|
||||
DropDownButton.form
|
||||
clone PopupForm
|
||||
PopupForm
|
||||
clone Form
|
||||
padding 2
|
||||
MenuWindow
|
||||
clone PopupWindow
|
||||
MenuForm
|
||||
clone PopupForm
|
||||
ListItem
|
||||
padding 4 10
|
||||
children
|
||||
|
||||
@@ -41,8 +41,8 @@ enum class AnimationTime {
|
||||
// Using this is most often preferable since starting a animation is often
|
||||
// accompanied with some extra work that might eat up a considerable time of
|
||||
// the total duration (and chop of the beginning of it).
|
||||
// F.ex: Creating a window and starting its appearance animation. During
|
||||
// initialization of the window, you might initiate loading of additional
|
||||
// F.ex: Creating a form and starting its appearance animation. During
|
||||
// initialization of the form, you might initiate loading of additional
|
||||
// resources. When that is done and you finally end up updating animations,
|
||||
// most of the animation time might already have passed. If the animation
|
||||
// start time is adjusted to the first update, the whole animation will run
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
#define EL_CONFIG_H_
|
||||
|
||||
// Enables for some handy runtime debugging, enabled by modifying the various
|
||||
// settings in DebugInfo::get()-> A settings window can be shown by calling
|
||||
// ShowDebugInfoSettingsWindow.
|
||||
// settings in DebugInfo::get()-> A settings form can be shown by calling
|
||||
// ShowDebugInfoSettingsForm.
|
||||
#ifndef NDEBUG
|
||||
#define EL_RUNTIME_DEBUG_INFO
|
||||
#endif // !NDEBUG
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "el/design/designer_window.h"
|
||||
#include "el/design/designer_form.h"
|
||||
#include "el/elements.h"
|
||||
|
||||
namespace el {
|
||||
namespace design {
|
||||
|
||||
DesignerWindow::DesignerWindow() {
|
||||
DesignerForm::DesignerForm() {
|
||||
set_text("Empty Designer");
|
||||
|
||||
LoadData(
|
||||
@@ -69,16 +69,16 @@ DesignerWindow::DesignerWindow() {
|
||||
build_content_root_ = build_container_->content_root();
|
||||
}
|
||||
|
||||
DesignerWindow::~DesignerWindow() { CloseContent(); }
|
||||
DesignerForm::~DesignerForm() { CloseContent(); }
|
||||
|
||||
void DesignerWindow::Show(Element* root_element) {
|
||||
void DesignerForm::Show(Element* root_element) {
|
||||
set_rect({100, 50, 900, 600});
|
||||
|
||||
auto root = root_element->parent_root();
|
||||
root->AddChild(this);
|
||||
}
|
||||
|
||||
void DesignerWindow::BindContent(Element* bind_element) {
|
||||
void DesignerForm::BindContent(Element* bind_element) {
|
||||
CloseContent();
|
||||
bind_element_ = bind_element;
|
||||
|
||||
@@ -88,12 +88,12 @@ void DesignerWindow::BindContent(Element* bind_element) {
|
||||
RefreshContent();
|
||||
}
|
||||
|
||||
void DesignerWindow::CloseContent() {
|
||||
void DesignerForm::CloseContent() {
|
||||
bind_element_.reset();
|
||||
RefreshContent();
|
||||
}
|
||||
|
||||
void DesignerWindow::RefreshContent() {
|
||||
void DesignerForm::RefreshContent() {
|
||||
// Clear existing content.
|
||||
build_content_root_->DeleteAllChildren();
|
||||
|
||||
@@ -123,7 +123,7 @@ void DesignerWindow::RefreshContent() {
|
||||
source_text_box_->set_focus(FocusReason::kUnknown);
|
||||
}
|
||||
|
||||
void DesignerWindow::PopulateElementListBox() {
|
||||
void DesignerForm::PopulateElementListBox() {
|
||||
element_list_source_.clear();
|
||||
|
||||
// TODO(benvanik): walk tree.
|
||||
@@ -7,28 +7,28 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef EL_DESIGN_DESIGNER_WINDOW_H_
|
||||
#define EL_DESIGN_DESIGNER_WINDOW_H_
|
||||
#ifndef EL_DESIGN_DESIGNER_FORM_H_
|
||||
#define EL_DESIGN_DESIGNER_FORM_H_
|
||||
|
||||
#include "el/element.h"
|
||||
#include "el/element_listener.h"
|
||||
#include "el/elements/form.h"
|
||||
#include "el/elements/list_box.h"
|
||||
#include "el/elements/text_box.h"
|
||||
#include "el/event_handler.h"
|
||||
#include "el/message_handler.h"
|
||||
#include "el/window.h"
|
||||
|
||||
namespace el {
|
||||
namespace design {
|
||||
|
||||
class DesignerWindow : public Window,
|
||||
public MessageHandler,
|
||||
public ElementListener {
|
||||
class DesignerForm : public elements::Form,
|
||||
public MessageHandler,
|
||||
public ElementListener {
|
||||
public:
|
||||
TBOBJECT_SUBCLASS(DesignerWindow, Window);
|
||||
TBOBJECT_SUBCLASS(DesignerForm, Form);
|
||||
|
||||
DesignerWindow();
|
||||
~DesignerWindow() override;
|
||||
DesignerForm();
|
||||
~DesignerForm() override;
|
||||
|
||||
void Show(Element* root_element);
|
||||
|
||||
@@ -62,4 +62,4 @@ class DesignerWindow : public Window,
|
||||
} // namespace design
|
||||
} // namespace el
|
||||
|
||||
#endif // EL_DESIGN_DESIGNER_WINDOW_H_
|
||||
#endif // EL_DESIGN_DESIGNER_FORM_H_
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "el/element.h"
|
||||
#include "el/element_listener.h"
|
||||
#include "el/elements/form.h"
|
||||
#include "el/elements/parts/scroller.h"
|
||||
#include "el/elements/tab_container.h"
|
||||
#include "el/elements/text_box.h"
|
||||
@@ -25,7 +26,6 @@
|
||||
#include "el/util/metrics.h"
|
||||
#include "el/util/string.h"
|
||||
#include "el/value.h"
|
||||
#include "el/window.h"
|
||||
|
||||
namespace el {
|
||||
|
||||
@@ -720,16 +720,16 @@ bool Element::set_focus(FocusReason reason, InvokeInfo info) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update windows last focus.
|
||||
Window* window = parent_window();
|
||||
if (window) {
|
||||
window->set_last_focus(this);
|
||||
// If not active, just return. We should get focus when the window is
|
||||
// Update forms last focus.
|
||||
auto form = parent_form();
|
||||
if (form) {
|
||||
form->set_last_focus(this);
|
||||
// If not active, just return. We should get focus when the form is
|
||||
// activated.
|
||||
// Exception for windows that doesn't activate. They may contain focusable
|
||||
// Exception for forms that doesn't activate. They may contain focusable
|
||||
// elements.
|
||||
if (!window->is_active() &&
|
||||
any(window->settings() & WindowSettings::kCanActivate)) {
|
||||
if (!form->is_active() &&
|
||||
any(form->settings() & elements::FormSettings::kCanActivate)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -795,7 +795,7 @@ bool Element::MoveFocus(bool forward) {
|
||||
origin = this;
|
||||
}
|
||||
|
||||
Element* root = origin->parent_window();
|
||||
Element* root = origin->parent_form();
|
||||
if (!root) {
|
||||
root = origin->parent_root();
|
||||
}
|
||||
@@ -937,12 +937,12 @@ Element* Element::parent_root() {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
Window* Element::parent_window() {
|
||||
elements::Form* Element::parent_form() {
|
||||
Element* tmp = this;
|
||||
while (tmp && !tmp->IsOfType<Window>()) {
|
||||
while (tmp && !tmp->IsOfType<elements::Form>()) {
|
||||
tmp = tmp->m_parent;
|
||||
}
|
||||
return static_cast<Window*>(tmp);
|
||||
return static_cast<elements::Form*>(tmp);
|
||||
}
|
||||
|
||||
void Element::AddListener(ElementListener* listener) {
|
||||
@@ -1505,11 +1505,10 @@ bool Element::InvokePointerDown(int x, int y, int click_count,
|
||||
captured_element->StartLongClickTimer(touch);
|
||||
}
|
||||
|
||||
// Get the closest parent window and bring it to the top.
|
||||
Window* window =
|
||||
captured_element ? captured_element->parent_window() : nullptr;
|
||||
if (window) {
|
||||
window->Activate();
|
||||
// Get the closest parent form and bring it to the top.
|
||||
auto form = captured_element ? captured_element->parent_form() : nullptr;
|
||||
if (form) {
|
||||
form->Activate();
|
||||
}
|
||||
}
|
||||
if (captured_element) {
|
||||
@@ -1931,9 +1930,9 @@ bool ElementSkinConditionContext::GetCondition(
|
||||
switch (info.prop) {
|
||||
case SkinProperty::kSkin:
|
||||
return element->background_skin() == info.value;
|
||||
case SkinProperty::kWindowActive:
|
||||
if (Window* window = element->parent_window()) {
|
||||
return window->is_active();
|
||||
case SkinProperty::kFormActive:
|
||||
if (auto form = element->parent_form()) {
|
||||
return form->is_active();
|
||||
}
|
||||
return false;
|
||||
case SkinProperty::kAxis:
|
||||
|
||||
@@ -32,8 +32,8 @@ class ElementListener;
|
||||
class EventHandler;
|
||||
class GenericStringItemSource;
|
||||
class LongClickTimer;
|
||||
class Window;
|
||||
namespace elements {
|
||||
class Form;
|
||||
namespace parts {
|
||||
class Scroller;
|
||||
} // namespace parts
|
||||
@@ -505,7 +505,7 @@ class Element : public util::TypedObject,
|
||||
// Sets if this element is a group root.
|
||||
// Grouped elements (such as RadioButton) will toggle all other elements with
|
||||
// the same group_id under the nearest parent group root.
|
||||
// Window is a group root by default.
|
||||
// Form is a group root by default.
|
||||
void set_group_root(bool group_root) { m_packed.is_group_root = group_root; }
|
||||
|
||||
bool is_focusable() const { return m_packed.is_focusable; }
|
||||
@@ -542,11 +542,11 @@ class Element : public util::TypedObject,
|
||||
// keyboard input.
|
||||
// Elements can be focused only after enabling it (see set_focusable(true)).
|
||||
// Invisible or disabled elements can not be focused.
|
||||
// If SetFocus is called on a element in a inactive window, it will succeed
|
||||
// (return true), but it won't actually become focused until that window is
|
||||
// activated (see Window::set_last_focus).
|
||||
// If SetFocus is called on a element in a inactive form, it will succeed
|
||||
// (return true), but it won't actually become focused until that form is
|
||||
// activated (see Form::set_last_focus).
|
||||
// Returns true if successfully focused, or if set as last focus in its
|
||||
// window.
|
||||
// form.
|
||||
bool set_focus(FocusReason reason, InvokeInfo info = InvokeInfo::kNormal);
|
||||
|
||||
// Calls SetFocus on all children and their children, until a element is found
|
||||
@@ -556,8 +556,8 @@ class Element : public util::TypedObject,
|
||||
|
||||
// Moves focus from the currently focused element to another focusable
|
||||
// element.
|
||||
// It will search for a focusable element in the same Window (or top root if
|
||||
// there is no window) forward or backwards in the element order.
|
||||
// It will search for a focusable element in the same Form (or top root if
|
||||
// there is no form) forward or backwards in the element order.
|
||||
bool MoveFocus(bool forward);
|
||||
|
||||
// Returns the child element that contains the coordinate or nullptr if no one
|
||||
@@ -748,10 +748,10 @@ class Element : public util::TypedObject,
|
||||
// Gets this element or a parent element that is the absolute root parent.
|
||||
Element* parent_root();
|
||||
|
||||
// Gets the closest parent element that is a Window or nullptr if there is
|
||||
// Gets the closest parent element that is a Form or nullptr if there is
|
||||
// none.
|
||||
// If this element is a window itself, this will be returned.
|
||||
Window* parent_window();
|
||||
// If this element is a form itself, this will be returned.
|
||||
elements::Form* parent_form();
|
||||
|
||||
// Gets the parent element, or nullptr if this element is not added.
|
||||
inline Element* parent() const { return m_parent; }
|
||||
@@ -1299,7 +1299,7 @@ struct ElementNode : public Node {
|
||||
set("tooltip", value);
|
||||
return *reinterpret_cast<R*>(this);
|
||||
}
|
||||
// The Element will be focused automatically the first time its Window is
|
||||
// The Element will be focused automatically the first time its Form is
|
||||
// activated.
|
||||
R& autofocus(bool value) {
|
||||
set("autofocus", value ? 1 : 0);
|
||||
|
||||
@@ -25,9 +25,9 @@ class ElementAnimation : public Animation,
|
||||
TBOBJECT_SUBCLASS(ElementAnimation, Animation);
|
||||
|
||||
// Don't use 0.0 for opacity animations since that may break focus code.
|
||||
// At the moment a window should appear and start fading in from opacity 0,
|
||||
// At the moment a form should appear and start fading in from opacity 0,
|
||||
// it would also attempt setting the focus to it, but if opacity is 0 it will
|
||||
// think focus should not be set in that window and fail.
|
||||
// think focus should not be set in that form and fail.
|
||||
static const float kAlmostZeroOpacity;
|
||||
|
||||
ElementAnimation(Element* element);
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
#include "el/element_animation.h"
|
||||
#include "el/element_animation_manager.h"
|
||||
#include "el/elements/dimmer.h"
|
||||
#include "el/elements/message_window.h"
|
||||
#include "el/window.h"
|
||||
#include "el/elements/form.h"
|
||||
#include "el/elements/message_form.h"
|
||||
|
||||
namespace el {
|
||||
|
||||
@@ -59,16 +59,16 @@ void ElementAnimationManager::OnElementDelete(Element* element) {
|
||||
|
||||
bool ElementAnimationManager::OnElementDying(Element* element) {
|
||||
bool handled = false;
|
||||
if (Window* window = SafeCast<Window>(element)) {
|
||||
// Fade out dying windows.
|
||||
if (auto form = SafeCast<elements::Form>(element)) {
|
||||
// Fade out dying forms.
|
||||
auto anim = new OpacityElementAnimation(
|
||||
window, 1.f, ElementAnimation::kAlmostZeroOpacity, true);
|
||||
form, 1.f, ElementAnimation::kAlmostZeroOpacity, true);
|
||||
AnimationManager::StartAnimation(anim, AnimationCurve::kBezier);
|
||||
handled = true;
|
||||
}
|
||||
if (auto window = SafeCast<elements::MessageWindow>(element)) {
|
||||
// Move out dying message windows.
|
||||
auto anim = new RectElementAnimation(window, Rect(0, 50, 0, 0),
|
||||
if (auto form = SafeCast<elements::MessageForm>(element)) {
|
||||
// Move out dying message forms.
|
||||
auto anim = new RectElementAnimation(form, Rect(0, 50, 0, 0),
|
||||
RectElementAnimation::Mode::kDeltaIn);
|
||||
AnimationManager::StartAnimation(anim, AnimationCurve::kSpeedUp);
|
||||
handled = true;
|
||||
@@ -85,15 +85,15 @@ bool ElementAnimationManager::OnElementDying(Element* element) {
|
||||
|
||||
void ElementAnimationManager::OnElementAdded(Element* parent,
|
||||
Element* element) {
|
||||
if (Window* window = SafeCast<Window>(element)) {
|
||||
// Fade in new windows.
|
||||
if (auto form = SafeCast<elements::Form>(element)) {
|
||||
// Fade in new forms.
|
||||
auto anim = new OpacityElementAnimation(
|
||||
window, ElementAnimation::kAlmostZeroOpacity, 1.f, false);
|
||||
form, ElementAnimation::kAlmostZeroOpacity, 1.f, false);
|
||||
AnimationManager::StartAnimation(anim, AnimationCurve::kBezier);
|
||||
}
|
||||
if (auto window = SafeCast<elements::MessageWindow>(element)) {
|
||||
// Move in new message windows.
|
||||
auto anim = new RectElementAnimation(window, Rect(0, -50, 0, 0),
|
||||
if (auto form = SafeCast<elements::MessageForm>(element)) {
|
||||
// Move in new message forms.
|
||||
auto anim = new RectElementAnimation(form, Rect(0, -50, 0, 0),
|
||||
RectElementAnimation::Mode::kDeltaOut);
|
||||
AnimationManager::StartAnimation(anim);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "el/elements/check_box.h"
|
||||
#include "el/elements/dimmer.h"
|
||||
#include "el/elements/drop_down_button.h"
|
||||
#include "el/elements/form.h"
|
||||
#include "el/elements/group_box.h"
|
||||
#include "el/elements/icon_box.h"
|
||||
#include "el/elements/image_box.h"
|
||||
@@ -24,11 +25,11 @@
|
||||
#include "el/elements/label_container.h"
|
||||
#include "el/elements/layout_box.h"
|
||||
#include "el/elements/list_box.h"
|
||||
#include "el/elements/menu_window.h"
|
||||
#include "el/elements/message_window.h"
|
||||
#include "el/elements/modal_window.h"
|
||||
#include "el/elements/menu_form.h"
|
||||
#include "el/elements/message_form.h"
|
||||
#include "el/elements/modal_form.h"
|
||||
#include "el/elements/mover.h"
|
||||
#include "el/elements/popup_window.h"
|
||||
#include "el/elements/popup_form.h"
|
||||
#include "el/elements/progress_spinner.h"
|
||||
#include "el/elements/radio_button.h"
|
||||
#include "el/elements/resizer.h"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "el/elements/drop_down_button.h"
|
||||
#include "el/elements/menu_window.h"
|
||||
#include "el/elements/menu_form.h"
|
||||
#include "el/parsing/element_inflater.h"
|
||||
#include "el/util/string.h"
|
||||
#include "el/util/string_builder.h"
|
||||
@@ -33,7 +33,7 @@ DropDownButton::DropDownButton() {
|
||||
DropDownButton::~DropDownButton() {
|
||||
content_root()->RemoveChild(&m_arrow);
|
||||
set_source(nullptr);
|
||||
CloseWindow();
|
||||
CloseForm();
|
||||
}
|
||||
|
||||
void DropDownButton::OnInflate(const parsing::InflateInfo& info) {
|
||||
@@ -72,25 +72,25 @@ TBID DropDownButton::selected_item_id() {
|
||||
return TBID();
|
||||
}
|
||||
|
||||
void DropDownButton::OpenWindow() {
|
||||
if (!m_source || !m_source->size() || m_window_pointer.get()) {
|
||||
void DropDownButton::OpenForm() {
|
||||
if (!m_source || !m_source->size() || m_form_pointer.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MenuWindow* window = new MenuWindow(this, TBIDC("DropDownButton.window"));
|
||||
m_window_pointer.reset(window);
|
||||
window->set_background_skin(TBIDC("DropDownButton.window"));
|
||||
window->Show(m_source, PopupAlignment(), value());
|
||||
MenuForm* form = new MenuForm(this, TBIDC("DropDownButton.form"));
|
||||
m_form_pointer.reset(form);
|
||||
form->set_background_skin(TBIDC("DropDownButton.form"));
|
||||
form->Show(m_source, PopupAlignment(), value());
|
||||
}
|
||||
|
||||
void DropDownButton::CloseWindow() {
|
||||
if (MenuWindow* window = menu_if_open()) {
|
||||
window->Close();
|
||||
void DropDownButton::CloseForm() {
|
||||
if (MenuForm* form = menu_if_open()) {
|
||||
form->Close();
|
||||
}
|
||||
}
|
||||
|
||||
MenuWindow* DropDownButton::menu_if_open() const {
|
||||
return util::SafeCast<MenuWindow>(m_window_pointer.get());
|
||||
MenuForm* DropDownButton::menu_if_open() const {
|
||||
return util::SafeCast<MenuForm>(m_form_pointer.get());
|
||||
}
|
||||
|
||||
bool DropDownButton::OnEvent(const Event& ev) {
|
||||
@@ -98,29 +98,29 @@ bool DropDownButton::OnEvent(const Event& ev) {
|
||||
// Open the menu, or set the value and close it if already open (this will
|
||||
// happen when clicking by keyboard since that will call click on this
|
||||
// button).
|
||||
if (MenuWindow* menu_window = menu_if_open()) {
|
||||
if (MenuForm* menu_form = menu_if_open()) {
|
||||
WeakElementPointer tmp(this);
|
||||
int value = menu_window->list_box()->value();
|
||||
menu_window->Die();
|
||||
int value = menu_form->list_box()->value();
|
||||
menu_form->Die();
|
||||
if (tmp.get()) {
|
||||
set_value(value);
|
||||
}
|
||||
} else {
|
||||
OpenWindow();
|
||||
OpenForm();
|
||||
}
|
||||
return true;
|
||||
} else if (ev.target->id() == TBIDC("DropDownButton.window") &&
|
||||
} else if (ev.target->id() == TBIDC("DropDownButton.form") &&
|
||||
ev.type == EventType::kClick) {
|
||||
// Set the value of the clicked item.
|
||||
if (MenuWindow* menu_window = menu_if_open()) {
|
||||
set_value(menu_window->list_box()->value());
|
||||
if (MenuForm* menu_form = menu_if_open()) {
|
||||
set_value(menu_form->list_box()->value());
|
||||
}
|
||||
return true;
|
||||
} else if (ev.target == this && m_source && ev.is_key_event()) {
|
||||
if (MenuWindow* menu_window = menu_if_open()) {
|
||||
if (MenuForm* menu_form = menu_if_open()) {
|
||||
// Redirect the key strokes to the list.
|
||||
Event redirected_ev(ev);
|
||||
return menu_window->list_box()->InvokeEvent(redirected_ev);
|
||||
return menu_form->list_box()->InvokeEvent(redirected_ev);
|
||||
}
|
||||
}
|
||||
return Element::OnEvent(ev);
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
#define EL_ELEMENTS_DROP_DOWN_BUTTON_H_
|
||||
|
||||
#include "el/element.h"
|
||||
#include "el/elements/form.h"
|
||||
#include "el/elements/icon_box.h"
|
||||
#include "el/list_item.h"
|
||||
#include "el/window.h"
|
||||
|
||||
namespace el {
|
||||
namespace elements {
|
||||
|
||||
class MenuWindow;
|
||||
class MenuForm;
|
||||
|
||||
// Shows a button that opens a popup with a ListBox with items provided by a
|
||||
// ItemSource.
|
||||
@@ -46,14 +46,14 @@ class DropDownButton : public Button, public ListItemObserver {
|
||||
// Gets the ID of the selected item, or 0 if there is no item selected.
|
||||
TBID selected_item_id();
|
||||
|
||||
// Opens the window if the model has items.
|
||||
void OpenWindow();
|
||||
// Opens the form if the model has items.
|
||||
void OpenForm();
|
||||
|
||||
// Closes the window if it is open.
|
||||
void CloseWindow();
|
||||
// Closes the form if it is open.
|
||||
void CloseForm();
|
||||
|
||||
// Returns the menu window if it's open, or nullptr.
|
||||
MenuWindow* menu_if_open() const;
|
||||
// Returns the menu form if it's open, or nullptr.
|
||||
MenuForm* menu_if_open() const;
|
||||
|
||||
void OnInflate(const parsing::InflateInfo& info) override;
|
||||
bool OnEvent(const Event& ev) override;
|
||||
@@ -68,7 +68,7 @@ class DropDownButton : public Button, public ListItemObserver {
|
||||
GenericStringItemSource m_default_source;
|
||||
IconBox m_arrow;
|
||||
int m_value = -1;
|
||||
WeakElementPointer m_window_pointer; // Dropdown window, if opened.
|
||||
WeakElementPointer m_form_pointer; // Dropdown form, if opened.
|
||||
};
|
||||
|
||||
} // namespace elements
|
||||
|
||||
@@ -10,31 +10,32 @@
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
#include "el/design/designer_window.h"
|
||||
#include "el/design/designer_form.h"
|
||||
#include "el/elements/form.h"
|
||||
#include "el/util/math.h"
|
||||
#include "el/window.h"
|
||||
|
||||
namespace el {
|
||||
namespace elements {
|
||||
|
||||
Window::Window() {
|
||||
set_background_skin(TBIDC("Window"), InvokeInfo::kNoCallbacks);
|
||||
Form::Form() {
|
||||
set_background_skin(TBIDC("Form"), InvokeInfo::kNoCallbacks);
|
||||
AddChild(&title_mover_);
|
||||
AddChild(&title_resizer_);
|
||||
title_mover_.set_background_skin(TBIDC("Window.mover"));
|
||||
title_mover_.set_background_skin(TBIDC("Form.mover"));
|
||||
title_mover_.AddChild(&title_label_);
|
||||
title_label_.set_ignoring_input(true);
|
||||
title_mover_.AddChild(&title_design_button_);
|
||||
title_design_button_.set_background_skin(TBIDC("Window.close"));
|
||||
title_design_button_.set_background_skin(TBIDC("Form.close"));
|
||||
title_design_button_.set_focusable(false);
|
||||
title_design_button_.set_id(TBIDC("Window.design"));
|
||||
title_design_button_.set_id(TBIDC("Form.design"));
|
||||
title_mover_.AddChild(&title_close_button_);
|
||||
title_close_button_.set_background_skin(TBIDC("Window.close"));
|
||||
title_close_button_.set_background_skin(TBIDC("Form.close"));
|
||||
title_close_button_.set_focusable(false);
|
||||
title_close_button_.set_id(TBIDC("Window.close"));
|
||||
title_close_button_.set_id(TBIDC("Form.close"));
|
||||
set_group_root(true);
|
||||
}
|
||||
|
||||
Window::~Window() {
|
||||
Form::~Form() {
|
||||
title_resizer_.RemoveFromParent();
|
||||
title_mover_.RemoveFromParent();
|
||||
title_design_button_.RemoveFromParent();
|
||||
@@ -42,7 +43,7 @@ Window::~Window() {
|
||||
title_mover_.RemoveChild(&title_label_);
|
||||
}
|
||||
|
||||
Rect Window::GetResizeToFitContentRect(ResizeFit fit) {
|
||||
Rect Form::GetResizeToFitContentRect(ResizeFit fit) {
|
||||
PreferredSize ps = GetPreferredSize();
|
||||
int new_w = ps.pref_w;
|
||||
int new_h = ps.pref_h;
|
||||
@@ -60,32 +61,32 @@ Rect Window::GetResizeToFitContentRect(ResizeFit fit) {
|
||||
return Rect(rect().x, rect().y, new_w, new_h);
|
||||
}
|
||||
|
||||
void Window::ResizeToFitContent(ResizeFit fit) {
|
||||
void Form::ResizeToFitContent(ResizeFit fit) {
|
||||
set_rect(GetResizeToFitContentRect(fit));
|
||||
}
|
||||
|
||||
void Window::Close() { Die(); }
|
||||
void Form::Close() { Die(); }
|
||||
|
||||
bool Window::is_active() const { return has_state(Element::State::kSelected); }
|
||||
bool Form::is_active() const { return has_state(Element::State::kSelected); }
|
||||
|
||||
Window* Window::GetTopMostOtherWindow(bool only_activable_windows) {
|
||||
Window* other_window = nullptr;
|
||||
Form* Form::GetTopMostOtherForm(bool only_activable_forms) {
|
||||
Form* other_form = nullptr;
|
||||
Element* sibling = parent()->last_child();
|
||||
while (sibling && !other_window) {
|
||||
while (sibling && !other_form) {
|
||||
if (sibling != this) {
|
||||
other_window = util::SafeCast<Window>(sibling);
|
||||
other_form = util::SafeCast<Form>(sibling);
|
||||
}
|
||||
if (only_activable_windows && other_window &&
|
||||
!any(other_window->window_settings_ & WindowSettings::kCanActivate)) {
|
||||
other_window = nullptr;
|
||||
if (only_activable_forms && other_form &&
|
||||
!any(other_form->form_settings_ & FormSettings::kCanActivate)) {
|
||||
other_form = nullptr;
|
||||
}
|
||||
sibling = sibling->GetPrev();
|
||||
}
|
||||
return other_window;
|
||||
return other_form;
|
||||
}
|
||||
|
||||
void Window::Activate() {
|
||||
if (!parent() || !any(window_settings_ & WindowSettings::kCanActivate)) {
|
||||
void Form::Activate() {
|
||||
if (!parent() || !any(form_settings_ & FormSettings::kCanActivate)) {
|
||||
return;
|
||||
}
|
||||
if (is_active()) {
|
||||
@@ -95,19 +96,19 @@ void Window::Activate() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Deactivate currently active window.
|
||||
Window* active_window = GetTopMostOtherWindow(true);
|
||||
if (active_window) {
|
||||
active_window->Deactivate();
|
||||
// Deactivate currently active form.
|
||||
Form* active_form = GetTopMostOtherForm(true);
|
||||
if (active_form) {
|
||||
active_form->Deactivate();
|
||||
}
|
||||
|
||||
// Activate this window.
|
||||
// Activate this form.
|
||||
set_z(ElementZ::kTop);
|
||||
SetWindowActiveState(true);
|
||||
SetFormActiveState(true);
|
||||
EnsureFocus();
|
||||
}
|
||||
|
||||
bool Window::EnsureFocus() {
|
||||
bool Form::EnsureFocus() {
|
||||
// If we already have focus, we're done.
|
||||
if (focused_element && IsAncestorOf(focused_element)) {
|
||||
return true;
|
||||
@@ -125,42 +126,42 @@ bool Window::EnsureFocus() {
|
||||
return success;
|
||||
}
|
||||
|
||||
void Window::Deactivate() {
|
||||
void Form::Deactivate() {
|
||||
if (!is_active()) return;
|
||||
SetWindowActiveState(false);
|
||||
SetFormActiveState(false);
|
||||
}
|
||||
|
||||
void Window::SetWindowActiveState(bool active) {
|
||||
void Form::SetFormActiveState(bool active) {
|
||||
set_state(Element::State::kSelected, active);
|
||||
title_mover_.set_state(Element::State::kSelected, active);
|
||||
}
|
||||
|
||||
void Window::set_settings(WindowSettings settings) {
|
||||
if (settings == window_settings_) return;
|
||||
window_settings_ = settings;
|
||||
void Form::set_settings(FormSettings settings) {
|
||||
if (settings == form_settings_) return;
|
||||
form_settings_ = settings;
|
||||
|
||||
if (any(settings & WindowSettings::kTitleBar)) {
|
||||
if (any(settings & FormSettings::kTitleBar)) {
|
||||
if (!title_mover_.parent()) {
|
||||
AddChild(&title_mover_);
|
||||
}
|
||||
} else {
|
||||
title_mover_.RemoveFromParent();
|
||||
}
|
||||
if (any(settings & WindowSettings::kResizable)) {
|
||||
if (any(settings & FormSettings::kResizable)) {
|
||||
if (!title_resizer_.parent()) {
|
||||
AddChild(&title_resizer_);
|
||||
}
|
||||
} else {
|
||||
title_resizer_.RemoveFromParent();
|
||||
}
|
||||
if (any(settings & WindowSettings::kDesignButton)) {
|
||||
if (any(settings & FormSettings::kDesignButton)) {
|
||||
if (!title_design_button_.parent()) {
|
||||
title_mover_.AddChild(&title_design_button_);
|
||||
}
|
||||
} else {
|
||||
title_design_button_.RemoveFromParent();
|
||||
}
|
||||
if (any(settings & WindowSettings::kCloseButton)) {
|
||||
if (any(settings & FormSettings::kCloseButton)) {
|
||||
if (!title_close_button_.parent()) {
|
||||
title_mover_.AddChild(&title_close_button_);
|
||||
}
|
||||
@@ -168,19 +169,19 @@ void Window::set_settings(WindowSettings settings) {
|
||||
title_close_button_.RemoveFromParent();
|
||||
}
|
||||
|
||||
if (any(settings & WindowSettings::kFullScreen)) {
|
||||
set_background_skin(TBIDC("Window.fullscreen"));
|
||||
if (any(settings & FormSettings::kFullScreen)) {
|
||||
set_background_skin(TBIDC("Form.fullscreen"));
|
||||
set_gravity(Gravity::kAll);
|
||||
FitToParent();
|
||||
} else {
|
||||
set_background_skin(TBIDC("Window"));
|
||||
set_background_skin(TBIDC("Form"));
|
||||
}
|
||||
|
||||
// FIX: invalidate layout / resize window!
|
||||
// FIX: invalidate layout / resize form!
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void Window::CenterInParent() {
|
||||
void Form::CenterInParent() {
|
||||
if (!parent()) {
|
||||
return;
|
||||
}
|
||||
@@ -188,14 +189,14 @@ void Window::CenterInParent() {
|
||||
set_rect(rect().CenterIn(bounds).MoveIn(bounds).Clip(bounds));
|
||||
}
|
||||
|
||||
int Window::title_bar_height() {
|
||||
if (any(window_settings_ & WindowSettings::kTitleBar)) {
|
||||
int Form::title_bar_height() {
|
||||
if (any(form_settings_ & FormSettings::kTitleBar)) {
|
||||
return title_mover_.GetPreferredSize().pref_h;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Rect Window::padding_rect() {
|
||||
Rect Form::padding_rect() {
|
||||
Rect padding_rect = Element::padding_rect();
|
||||
int title_height = title_bar_height();
|
||||
padding_rect.y += title_height;
|
||||
@@ -203,25 +204,25 @@ Rect Window::padding_rect() {
|
||||
return padding_rect;
|
||||
}
|
||||
|
||||
PreferredSize Window::OnCalculatePreferredSize(
|
||||
PreferredSize Form::OnCalculatePreferredSize(
|
||||
const SizeConstraints& constraints) {
|
||||
PreferredSize ps = OnCalculatePreferredContentSize(constraints);
|
||||
|
||||
// Add window skin padding
|
||||
// Add form skin padding
|
||||
if (auto e = background_skin_element()) {
|
||||
ps.min_w += e->padding_left + e->padding_right;
|
||||
ps.pref_w += e->padding_left + e->padding_right;
|
||||
ps.min_h += e->padding_top + e->padding_bottom;
|
||||
ps.pref_h += e->padding_top + e->padding_bottom;
|
||||
}
|
||||
// Add window title bar height
|
||||
// Add form title bar height
|
||||
int title_height = title_bar_height();
|
||||
ps.min_h += title_height;
|
||||
ps.pref_h += title_height;
|
||||
return ps;
|
||||
}
|
||||
|
||||
bool Window::OnEvent(const Event& ev) {
|
||||
bool Form::OnEvent(const Event& ev) {
|
||||
if (ev.target == &title_close_button_) {
|
||||
if (ev.type == EventType::kClick) {
|
||||
Close();
|
||||
@@ -236,31 +237,30 @@ bool Window::OnEvent(const Event& ev) {
|
||||
return Element::OnEvent(ev);
|
||||
}
|
||||
|
||||
void Window::OnAdded() {
|
||||
void Form::OnAdded() {
|
||||
// If we was added last, call Activate to update status etc.
|
||||
if (parent()->last_child() == this) {
|
||||
Activate();
|
||||
}
|
||||
|
||||
// Fit if needed.
|
||||
if (any(window_settings_ & WindowSettings::kFullScreen)) {
|
||||
if (any(form_settings_ & FormSettings::kFullScreen)) {
|
||||
FitToParent();
|
||||
}
|
||||
}
|
||||
|
||||
void Window::OnRemove() {
|
||||
void Form::OnRemove() {
|
||||
Deactivate();
|
||||
|
||||
// Active the top most other window
|
||||
if (Window* active_window = GetTopMostOtherWindow(true))
|
||||
active_window->Activate();
|
||||
// Active the top most other form
|
||||
if (Form* active_form = GetTopMostOtherForm(true)) active_form->Activate();
|
||||
}
|
||||
|
||||
void Window::OnChildAdded(Element* child) {
|
||||
void Form::OnChildAdded(Element* child) {
|
||||
title_resizer_.set_z(ElementZ::kTop);
|
||||
}
|
||||
|
||||
void Window::OnResized(int old_w, int old_h) {
|
||||
void Form::OnResized(int old_w, int old_h) {
|
||||
// Apply gravity on children.
|
||||
Element::OnResized(old_w, old_h);
|
||||
// Manually move our own decoration children.
|
||||
@@ -278,19 +278,20 @@ void Window::OnResized(int old_w, int old_h) {
|
||||
title_close_button_.set_rect(
|
||||
{title_mover_rect.x + title_mover_rect.w - button_size,
|
||||
title_mover_rect.y, button_size, button_size});
|
||||
if (any(window_settings_ & WindowSettings::kDesignButton)) {
|
||||
if (any(form_settings_ & FormSettings::kDesignButton)) {
|
||||
title_mover_rect.w -= button_size;
|
||||
}
|
||||
if (any(window_settings_ & WindowSettings::kCloseButton)) {
|
||||
if (any(form_settings_ & FormSettings::kCloseButton)) {
|
||||
title_mover_rect.w -= button_size;
|
||||
}
|
||||
title_label_.set_rect(title_mover_rect);
|
||||
}
|
||||
|
||||
void Window::OpenDesigner() {
|
||||
auto designer_window = new design::DesignerWindow();
|
||||
designer_window->BindContent(this);
|
||||
designer_window->Show(this);
|
||||
void Form::OpenDesigner() {
|
||||
auto designer_form = new design::DesignerForm();
|
||||
designer_form->BindContent(this);
|
||||
designer_form->Show(this);
|
||||
}
|
||||
|
||||
} // namespace elements
|
||||
} // namespace el
|
||||
@@ -7,8 +7,8 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef EL_WINDOW_H_
|
||||
#define EL_WINDOW_H_
|
||||
#ifndef EL_ELEMENTS_FORM_H_
|
||||
#define EL_ELEMENTS_FORM_H_
|
||||
|
||||
#include "el/element_listener.h"
|
||||
#include "el/elements/button.h"
|
||||
@@ -17,69 +17,70 @@
|
||||
#include "el/elements/resizer.h"
|
||||
|
||||
namespace el {
|
||||
namespace elements {
|
||||
|
||||
enum class WindowSettings {
|
||||
kNone = 0, // Chrome less window without any other settings.
|
||||
kTitleBar = 1 << 0, // Show a title bar that can also move the window.
|
||||
kResizable = 1 << 1, // Show an element for resizing the window.
|
||||
kCloseButton = 1 << 2, // Show an element for closing the window.
|
||||
kCanActivate = 1 << 3, // Can be activated and deactivate other windows.
|
||||
kDesignButton = 1 << 4, // Show a button to open a designer for the window.
|
||||
enum class FormSettings {
|
||||
kNone = 0, // Chrome less form without any other settings.
|
||||
kTitleBar = 1 << 0, // Show a title bar that can also move the form.
|
||||
kResizable = 1 << 1, // Show an element for resizing the form.
|
||||
kCloseButton = 1 << 2, // Show an element for closing the form.
|
||||
kCanActivate = 1 << 3, // Can be activated and deactivate other forms.
|
||||
kDesignButton = 1 << 4, // Show a button to open a designer for the form.
|
||||
kFullScreen = 1 << 5, // Fully fill parent.
|
||||
|
||||
kDefault =
|
||||
kTitleBar | kResizable | kCloseButton | kCanActivate | kDesignButton,
|
||||
};
|
||||
MAKE_ENUM_FLAG_COMBO(WindowSettings);
|
||||
MAKE_ENUM_FLAG_COMBO(FormSettings);
|
||||
|
||||
// A Element that provides some window-like features.
|
||||
// A Element that provides some form-like features.
|
||||
// It can have a titlebar, be movable, resizable etc.
|
||||
// It will activate and deactivate other windows on click (which will restore
|
||||
// It will activate and deactivate other forms on click (which will restore
|
||||
// focus to the last focused child element).
|
||||
class Window : public Element {
|
||||
class Form : public Element {
|
||||
public:
|
||||
TBOBJECT_SUBCLASS(Window, Element);
|
||||
TBOBJECT_SUBCLASS(Form, Element);
|
||||
|
||||
Window();
|
||||
~Window() override;
|
||||
Form();
|
||||
~Form() override;
|
||||
|
||||
// Closes this window.
|
||||
// NOTE: This window will be deleted after this call!
|
||||
// Closes this form.
|
||||
// NOTE: This form will be deleted after this call!
|
||||
void Close();
|
||||
|
||||
// Returns true if this window is active.
|
||||
// Returns true if this form is active.
|
||||
bool is_active() const;
|
||||
|
||||
// Activates this window if it's not already activated.
|
||||
// This will deactivate any currently activated window.
|
||||
// Activates this form if it's not already activated.
|
||||
// This will deactivate any currently activated form.
|
||||
// This will automatically call EnsureFocus to restore/set focus to this
|
||||
// window.
|
||||
// form.
|
||||
void Activate();
|
||||
|
||||
// Ensures that this window has focus by attempting to find a focusable child
|
||||
// Ensures that this form has focus by attempting to find a focusable child
|
||||
// element.
|
||||
// It will first try to restore focus to the last focused element in this
|
||||
// window, or a element that has received SetFocus while the window was
|
||||
// form, or a element that has received SetFocus while the form was
|
||||
// inactive. If that doesn't succeed, it will go through all children and try
|
||||
// to set focus.
|
||||
// Returns false if no focusable child was found.
|
||||
bool EnsureFocus();
|
||||
|
||||
// Sets the element that should be focused when this window is activated next
|
||||
// Sets the element that should be focused when this form is activated next
|
||||
// time.
|
||||
// This should not be used to change focus. Call Element::SetFocus to focus,
|
||||
// which will call this method if the window is inactive!
|
||||
// which will call this method if the form is inactive!
|
||||
void set_last_focus(Element* last_focus) {
|
||||
last_focus_element_.reset(last_focus);
|
||||
}
|
||||
|
||||
WindowSettings settings() const { return window_settings_; }
|
||||
// Sets settings for how this window should look and behave.
|
||||
void set_settings(WindowSettings settings);
|
||||
FormSettings settings() const { return form_settings_; }
|
||||
// Sets settings for how this form should look and behave.
|
||||
void set_settings(FormSettings settings);
|
||||
|
||||
void CenterInParent();
|
||||
|
||||
// ResizeFit specifies how ResizeToFitContent should resize the window.
|
||||
// ResizeFit specifies how ResizeToFitContent should resize the form.
|
||||
enum class ResizeFit {
|
||||
kPreferred, // Fit the preferred size of all content.
|
||||
kMinimal, // Fit the minimal size of all content.
|
||||
@@ -88,21 +89,21 @@ class Window : public Element {
|
||||
// size.
|
||||
};
|
||||
|
||||
// Gets a suitable rect for the window based on the contents and the given
|
||||
// Gets a suitable rect for the form based on the contents and the given
|
||||
// fit.
|
||||
Rect GetResizeToFitContentRect(ResizeFit fit = ResizeFit::kPreferred);
|
||||
|
||||
// Resizes the window to fit the its content. This is the same as doing
|
||||
// Resizes the form to fit the its content. This is the same as doing
|
||||
// set_rect(GetResizeToFitContentRect(fit)).
|
||||
void ResizeToFitContent(ResizeFit fit = ResizeFit::kPreferred);
|
||||
|
||||
std::string text() override { return title_label_.text(); }
|
||||
// Sets the window title.
|
||||
// Sets the form title.
|
||||
void set_text(const char* text) override { title_label_.set_text(text); }
|
||||
using Element::set_text;
|
||||
|
||||
// Gets the height of the title bar (or 0 if the WindowSettings say this
|
||||
// window shouldn't have any title bar).
|
||||
// Gets the height of the title bar (or 0 if the FormSettings say this
|
||||
// form shouldn't have any title bar).
|
||||
int title_bar_height();
|
||||
|
||||
Rect padding_rect() override;
|
||||
@@ -118,8 +119,8 @@ class Window : public Element {
|
||||
void OpenDesigner();
|
||||
|
||||
protected:
|
||||
Window* GetTopMostOtherWindow(bool only_activable_windows);
|
||||
void SetWindowActiveState(bool active);
|
||||
Form* GetTopMostOtherForm(bool only_activable_forms);
|
||||
void SetFormActiveState(bool active);
|
||||
void Deactivate();
|
||||
|
||||
elements::Mover title_mover_;
|
||||
@@ -127,10 +128,11 @@ class Window : public Element {
|
||||
elements::Label title_label_;
|
||||
elements::Button title_design_button_;
|
||||
elements::Button title_close_button_;
|
||||
WindowSettings window_settings_ = WindowSettings::kDefault;
|
||||
FormSettings form_settings_ = FormSettings::kDefault;
|
||||
WeakElementPointer last_focus_element_;
|
||||
};
|
||||
|
||||
} // namespace elements
|
||||
} // namespace el
|
||||
|
||||
#endif // EL_WINDOW_H_
|
||||
#endif // EL_ELEMENTS_FORM_H_
|
||||
@@ -7,13 +7,13 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "el/elements/form.h"
|
||||
#include "el/elements/label.h"
|
||||
#include "el/elements/list_box.h"
|
||||
#include "el/elements/menu_window.h"
|
||||
#include "el/elements/menu_form.h"
|
||||
#include "el/parsing/element_inflater.h"
|
||||
#include "el/util/string.h"
|
||||
#include "el/util/string_table.h"
|
||||
#include "el/window.h"
|
||||
|
||||
namespace el {
|
||||
namespace elements {
|
||||
@@ -277,15 +277,15 @@ bool ListBox::OnEvent(const Event& ev) {
|
||||
// If we're still around, invoke the click event too.
|
||||
if (this_element.get()) {
|
||||
ListBox* target_list = this;
|
||||
// If the parent window is a MenuWindow, we will iterate up the event
|
||||
// destination chain to find the top MenuWindow and invoke the event
|
||||
// If the parent form is a MenuForm, we will iterate up the event
|
||||
// destination chain to find the top MenuForm and invoke the event
|
||||
// there.
|
||||
// That way events in submenus will reach the caller properly, and seem
|
||||
// like it was invoked on the top menu.
|
||||
Window* window = parent_window();
|
||||
while (auto menu_win = util::SafeCast<MenuWindow>(window)) {
|
||||
Form* form = parent_form();
|
||||
while (auto menu_win = util::SafeCast<MenuForm>(form)) {
|
||||
target_list = menu_win->list_box();
|
||||
window = menu_win->event_destination()->parent_window();
|
||||
form = menu_win->event_destination()->parent_form();
|
||||
}
|
||||
|
||||
// Invoke the click event on the target list.
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
*/
|
||||
|
||||
#include "el/element_listener.h"
|
||||
#include "el/elements/menu_window.h"
|
||||
#include "el/elements/menu_form.h"
|
||||
|
||||
namespace el {
|
||||
namespace elements {
|
||||
|
||||
MenuWindow::MenuWindow(Element* target, TBID id) : PopupWindow(target) {
|
||||
MenuForm::MenuForm(Element* target, TBID id) : PopupForm(target) {
|
||||
set_id(id);
|
||||
set_background_skin(TBIDC("MenuWindow"), InvokeInfo::kNoCallbacks);
|
||||
set_background_skin(TBIDC("MenuForm"), InvokeInfo::kNoCallbacks);
|
||||
m_select_list.scroll_container()->set_adapt_to_content_size(true);
|
||||
// Avoid it autoclosing its window on click:
|
||||
// Avoid it autoclosing its form on click:
|
||||
m_select_list.set_focusable(false);
|
||||
m_select_list.set_background_skin("");
|
||||
m_select_list.set_rect(padding_rect());
|
||||
@@ -25,17 +25,17 @@ MenuWindow::MenuWindow(Element* target, TBID id) : PopupWindow(target) {
|
||||
AddChild(&m_select_list);
|
||||
}
|
||||
|
||||
MenuWindow::~MenuWindow() { RemoveChild(&m_select_list); }
|
||||
MenuForm::~MenuForm() { RemoveChild(&m_select_list); }
|
||||
|
||||
void MenuWindow::Show(ListItemSource* source, const PopupAlignment& alignment,
|
||||
int initial_value) {
|
||||
void MenuForm::Show(ListItemSource* source, const PopupAlignment& alignment,
|
||||
int initial_value) {
|
||||
m_select_list.set_value(initial_value);
|
||||
m_select_list.set_source(source);
|
||||
m_select_list.ValidateList();
|
||||
PopupWindow::Show(alignment);
|
||||
PopupForm::Show(alignment);
|
||||
}
|
||||
|
||||
bool MenuWindow::OnEvent(const Event& ev) {
|
||||
bool MenuForm::OnEvent(const Event& ev) {
|
||||
if (ev.type == EventType::kClick && &m_select_list == ev.target) {
|
||||
WeakElementPointer this_element(this);
|
||||
|
||||
@@ -50,7 +50,7 @@ bool MenuWindow::OnEvent(const Event& ev) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return PopupWindow::OnEvent(ev);
|
||||
return PopupForm::OnEvent(ev);
|
||||
}
|
||||
|
||||
} // namespace elements
|
||||
@@ -7,25 +7,25 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef EL_ELEMENTS_MENU_WINDOW_H_
|
||||
#define EL_ELEMENTS_MENU_WINDOW_H_
|
||||
#ifndef EL_ELEMENTS_MENU_FORM_H_
|
||||
#define EL_ELEMENTS_MENU_FORM_H_
|
||||
|
||||
#include "el/elements/list_box.h"
|
||||
#include "el/elements/popup_window.h"
|
||||
#include "el/elements/popup_form.h"
|
||||
|
||||
namespace el {
|
||||
namespace elements {
|
||||
|
||||
// MenuWindow is a popup window that shows a list of items (ListBox).
|
||||
// MenuForm is a popup form that shows a list of items (ListBox).
|
||||
// When selected it will invoke a click with the id given to the menu,
|
||||
// and the id of the clicked item as ref_id, and then close itself.
|
||||
// It may open sub items as new windows at the same time as this window is open.
|
||||
class MenuWindow : public PopupWindow {
|
||||
// It may open sub items as new forms at the same time as this form is open.
|
||||
class MenuForm : public PopupForm {
|
||||
public:
|
||||
TBOBJECT_SUBCLASS(MenuWindow, PopupWindow);
|
||||
TBOBJECT_SUBCLASS(MenuForm, PopupForm);
|
||||
|
||||
MenuWindow(Element* target, TBID id);
|
||||
~MenuWindow() override;
|
||||
MenuForm(Element* target, TBID id);
|
||||
~MenuForm() override;
|
||||
|
||||
void Show(ListItemSource* source, const PopupAlignment& alignment,
|
||||
int initial_value = -1);
|
||||
@@ -41,4 +41,4 @@ class MenuWindow : public PopupWindow {
|
||||
} // namespace elements
|
||||
} // namespace el
|
||||
|
||||
#endif // EL_ELEMENTS_MENU_WINDOW_H_
|
||||
#endif // EL_ELEMENTS_MENU_FORM_H_
|
||||
@@ -11,19 +11,19 @@
|
||||
|
||||
#include "el/elements/dimmer.h"
|
||||
#include "el/elements/icon_box.h"
|
||||
#include "el/elements/message_window.h"
|
||||
#include "el/elements/message_form.h"
|
||||
#include "el/elements/text_box.h"
|
||||
#include "el/util/string_table.h"
|
||||
|
||||
namespace el {
|
||||
namespace elements {
|
||||
|
||||
MessageWindow::MessageWindow(Element* target, TBID id) : m_target(target) {
|
||||
MessageForm::MessageForm(Element* target, TBID id) : m_target(target) {
|
||||
ElementListener::AddGlobalListener(this);
|
||||
set_id(id);
|
||||
}
|
||||
|
||||
MessageWindow::~MessageWindow() {
|
||||
MessageForm::~MessageForm() {
|
||||
ElementListener::RemoveGlobalListener(this);
|
||||
if (Element* dimmer = m_dimmer.get()) {
|
||||
dimmer->parent()->RemoveChild(dimmer);
|
||||
@@ -31,12 +31,12 @@ MessageWindow::~MessageWindow() {
|
||||
}
|
||||
}
|
||||
|
||||
bool MessageWindow::Show(const std::string& title, const std::string& message,
|
||||
MessageWindowSettings* settings) {
|
||||
bool MessageForm::Show(const std::string& title, const std::string& message,
|
||||
MessageFormSettings* settings) {
|
||||
Element* target = m_target.get();
|
||||
if (!target) return false;
|
||||
|
||||
MessageWindowSettings default_settings;
|
||||
MessageFormSettings default_settings;
|
||||
if (!settings) {
|
||||
settings = &default_settings;
|
||||
}
|
||||
@@ -63,14 +63,14 @@ bool MessageWindow::Show(const std::string& title, const std::string& message,
|
||||
text_box->set_background_skin("");
|
||||
|
||||
// Create buttons.
|
||||
if (settings->msg == MessageWindowButtons::kOk) {
|
||||
AddButton("MessageWindow.ok", true);
|
||||
} else if (settings->msg == MessageWindowButtons::kOkCancel) {
|
||||
AddButton("MessageWindow.ok", true);
|
||||
AddButton("MessageWindow.cancel", false);
|
||||
} else if (settings->msg == MessageWindowButtons::kYesNo) {
|
||||
AddButton("MessageWindow.yes", true);
|
||||
AddButton("MessageWindow.no", false);
|
||||
if (settings->msg == MessageFormButtons::kOk) {
|
||||
AddButton("MessageForm.ok", true);
|
||||
} else if (settings->msg == MessageFormButtons::kOkCancel) {
|
||||
AddButton("MessageForm.ok", true);
|
||||
AddButton("MessageForm.cancel", false);
|
||||
} else if (settings->msg == MessageFormButtons::kYesNo) {
|
||||
AddButton("MessageForm.yes", true);
|
||||
AddButton("MessageForm.no", false);
|
||||
}
|
||||
|
||||
// Size to fit content. This will use the default size of the textfield.
|
||||
@@ -98,7 +98,7 @@ bool MessageWindow::Show(const std::string& title, const std::string& message,
|
||||
return true;
|
||||
}
|
||||
|
||||
void MessageWindow::AddButton(TBID id, bool focused) {
|
||||
void MessageForm::AddButton(TBID id, bool focused) {
|
||||
auto layout = GetElementById<LayoutBox>(3);
|
||||
if (!layout) return;
|
||||
Button* btn = new Button();
|
||||
@@ -110,7 +110,7 @@ void MessageWindow::AddButton(TBID id, bool focused) {
|
||||
}
|
||||
}
|
||||
|
||||
bool MessageWindow::OnEvent(const Event& ev) {
|
||||
bool MessageForm::OnEvent(const Event& ev) {
|
||||
if (ev.type == EventType::kClick && ev.target->IsOfType<Button>()) {
|
||||
WeakElementPointer this_element(this);
|
||||
|
||||
@@ -130,23 +130,23 @@ bool MessageWindow::OnEvent(const Event& ev) {
|
||||
title_close_button_.InvokeEvent(click_ev);
|
||||
return true;
|
||||
}
|
||||
return Window::OnEvent(ev);
|
||||
return Form::OnEvent(ev);
|
||||
}
|
||||
|
||||
void MessageWindow::OnDie() {
|
||||
void MessageForm::OnDie() {
|
||||
if (Element* dimmer = m_dimmer.get()) {
|
||||
dimmer->Die();
|
||||
}
|
||||
}
|
||||
|
||||
void MessageWindow::OnElementDelete(Element* element) {
|
||||
void MessageForm::OnElementDelete(Element* element) {
|
||||
// If the target element is deleted, close!
|
||||
if (!m_target.get()) {
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
bool MessageWindow::OnElementDying(Element* element) {
|
||||
bool MessageForm::OnElementDying(Element* element) {
|
||||
// If the target element or an ancestor of it is dying, close!
|
||||
if (element == m_target.get() || element->IsAncestorOf(m_target.get())) {
|
||||
Close();
|
||||
@@ -7,51 +7,51 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef EL_ELEMENTS_MESSAGE_WINDOW_H_
|
||||
#define EL_ELEMENTS_MESSAGE_WINDOW_H_
|
||||
#ifndef EL_ELEMENTS_MESSAGE_FORM_H_
|
||||
#define EL_ELEMENTS_MESSAGE_FORM_H_
|
||||
|
||||
#include "el/element_listener.h"
|
||||
#include "el/window.h"
|
||||
#include "el/elements/form.h"
|
||||
|
||||
namespace el {
|
||||
namespace elements {
|
||||
|
||||
enum class MessageWindowButtons {
|
||||
enum class MessageFormButtons {
|
||||
kOk,
|
||||
kOkCancel,
|
||||
kYesNo,
|
||||
};
|
||||
|
||||
// Contains additional settings for MessageWindow.
|
||||
class MessageWindowSettings {
|
||||
// Contains additional settings for MessageForm.
|
||||
class MessageFormSettings {
|
||||
public:
|
||||
MessageWindowSettings() : msg(MessageWindowButtons::kOk) {}
|
||||
MessageWindowSettings(MessageWindowButtons msg, TBID icon_skin)
|
||||
MessageFormSettings() : msg(MessageFormButtons::kOk) {}
|
||||
MessageFormSettings(MessageFormButtons msg, TBID icon_skin)
|
||||
: msg(msg), icon_skin(icon_skin) {}
|
||||
|
||||
public:
|
||||
MessageWindowButtons msg; // The type of response for the message.
|
||||
TBID icon_skin; // The icon skin (0 for no icon)
|
||||
MessageFormButtons msg; // The type of response for the message.
|
||||
TBID icon_skin; // The icon skin (0 for no icon)
|
||||
bool dimmer = false; // Set to true to dim background elements by a Dimmer.
|
||||
bool styling = false; // Enable styling in the textfield.
|
||||
};
|
||||
|
||||
// A window for showing simple messages.
|
||||
// Events invoked in this window will travel up through the target element.
|
||||
// A form for showing simple messages.
|
||||
// Events invoked in this form will travel up through the target element.
|
||||
// When the user click any of its buttons, it will invoke a click event
|
||||
// (with the window ID), with the clicked buttons id as ref_id.
|
||||
// (with the form ID), with the clicked buttons id as ref_id.
|
||||
// Then it will delete itself.
|
||||
// If the target element is deleted while this window is alive, the window will
|
||||
// If the target element is deleted while this form is alive, the form will
|
||||
// delete itself.
|
||||
class MessageWindow : public Window, private ElementListener {
|
||||
class MessageForm : public Form, private ElementListener {
|
||||
public:
|
||||
TBOBJECT_SUBCLASS(MessageWindow, Window);
|
||||
TBOBJECT_SUBCLASS(MessageForm, Form);
|
||||
|
||||
MessageWindow(Element* target, TBID id);
|
||||
~MessageWindow() override;
|
||||
MessageForm(Element* target, TBID id);
|
||||
~MessageForm() override;
|
||||
|
||||
bool Show(const std::string& title, const std::string& message,
|
||||
MessageWindowSettings* settings = nullptr);
|
||||
MessageFormSettings* settings = nullptr);
|
||||
|
||||
Element* event_destination() override { return m_target.get(); }
|
||||
|
||||
@@ -69,4 +69,4 @@ class MessageWindow : public Window, private ElementListener {
|
||||
} // namespace elements
|
||||
} // namespace el
|
||||
|
||||
#endif // EL_ELEMENTS_MESSAGE_WINDOW_H_
|
||||
#endif // EL_ELEMENTS_MESSAGE_FORM_H_
|
||||
@@ -12,23 +12,22 @@
|
||||
#include "el/animation_manager.h"
|
||||
#include "el/element_animation.h"
|
||||
#include "el/elements/dimmer.h"
|
||||
#include "el/elements/modal_window.h"
|
||||
#include "el/elements/modal_form.h"
|
||||
|
||||
namespace el {
|
||||
namespace elements {
|
||||
|
||||
int ModalWindow::visible_count_ = 0;
|
||||
int ModalForm::visible_count_ = 0;
|
||||
|
||||
ModalWindow::ModalWindow(std::function<void()> on_close_callback)
|
||||
ModalForm::ModalForm(std::function<void()> on_close_callback)
|
||||
: on_close_callback_(on_close_callback) {
|
||||
++visible_count_;
|
||||
set_settings(el::WindowSettings::kTitleBar |
|
||||
el::WindowSettings::kCloseButton |
|
||||
el::WindowSettings::kCanActivate);
|
||||
set_settings(FormSettings::kTitleBar | FormSettings::kCloseButton |
|
||||
FormSettings::kCanActivate);
|
||||
el::ElementListener::AddGlobalListener(this);
|
||||
}
|
||||
|
||||
ModalWindow::~ModalWindow() {
|
||||
ModalForm::~ModalForm() {
|
||||
--visible_count_;
|
||||
el::ElementListener::RemoveGlobalListener(this);
|
||||
if (auto dimmer = dimmer_.get()) {
|
||||
@@ -37,7 +36,7 @@ ModalWindow::~ModalWindow() {
|
||||
}
|
||||
}
|
||||
|
||||
void ModalWindow::Show(el::Element* root_element) {
|
||||
void ModalForm::Show(el::Element* root_element) {
|
||||
auto dimmer = new Dimmer();
|
||||
root_element->AddChild(dimmer);
|
||||
dimmer_.reset(dimmer);
|
||||
@@ -49,7 +48,7 @@ void ModalWindow::Show(el::Element* root_element) {
|
||||
CenterInParent();
|
||||
}
|
||||
|
||||
bool ModalWindow::OnEvent(const el::Event& ev) {
|
||||
bool ModalForm::OnEvent(const el::Event& ev) {
|
||||
if (ev.target->id() == TBIDC("exit_button") &&
|
||||
ev.type == el::EventType::kClick) {
|
||||
Die();
|
||||
@@ -59,19 +58,19 @@ bool ModalWindow::OnEvent(const el::Event& ev) {
|
||||
Die();
|
||||
return true;
|
||||
}
|
||||
return el::Window::OnEvent(ev);
|
||||
return Form::OnEvent(ev);
|
||||
}
|
||||
|
||||
void ModalWindow::OnDie() {
|
||||
void ModalForm::OnDie() {
|
||||
if (auto dimmer = dimmer_.get()) {
|
||||
dimmer->Die();
|
||||
}
|
||||
Window::OnDie();
|
||||
Form::OnDie();
|
||||
}
|
||||
|
||||
void ModalWindow::OnRemove() { on_close_callback_(); }
|
||||
void ModalForm::OnRemove() { on_close_callback_(); }
|
||||
|
||||
void ModalWindow::OnElementAdded(Element* parent, Element* element) {
|
||||
void ModalForm::OnElementAdded(Element* parent, Element* element) {
|
||||
if (element == this) {
|
||||
// Move in.
|
||||
auto anim = new RectElementAnimation(this, Rect(0, -50, 0, 0),
|
||||
@@ -80,7 +79,7 @@ void ModalWindow::OnElementAdded(Element* parent, Element* element) {
|
||||
}
|
||||
}
|
||||
|
||||
bool ModalWindow::OnElementDying(Element* element) {
|
||||
bool ModalForm::OnElementDying(Element* element) {
|
||||
if (element == this) {
|
||||
// Move out.
|
||||
auto anim = new RectElementAnimation(this, Rect(0, 50, 0, 0),
|
||||
@@ -7,30 +7,30 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef EL_ELEMENTS_MODAL_WINDOW_H_
|
||||
#define EL_ELEMENTS_MODAL_WINDOW_H_
|
||||
#ifndef EL_ELEMENTS_MODAL_FORM_H_
|
||||
#define EL_ELEMENTS_MODAL_FORM_H_
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "el/element_listener.h"
|
||||
#include "el/window.h"
|
||||
#include "el/elements/form.h"
|
||||
|
||||
namespace el {
|
||||
namespace elements {
|
||||
|
||||
// A window for showing modal messages.
|
||||
// Events invoked in this window will travel up through the target element.
|
||||
// A form for showing modal messages.
|
||||
// Events invoked in this form will travel up through the target element.
|
||||
// When the user click any of its buttons, it will invoke a click event
|
||||
// (with the window ID), with the clicked buttons id as ref_id.
|
||||
// (with the form ID), with the clicked buttons id as ref_id.
|
||||
// Then it will delete itself.
|
||||
// If the target element is deleted while this window is alive, the window will
|
||||
// If the target element is deleted while this form is alive, the form will
|
||||
// delete itself.
|
||||
class ModalWindow : public Window, private ElementListener {
|
||||
class ModalForm : public Form, private ElementListener {
|
||||
public:
|
||||
TBOBJECT_SUBCLASS(ModalWindow, Window);
|
||||
TBOBJECT_SUBCLASS(ModalForm, Form);
|
||||
|
||||
ModalWindow(std::function<void()> on_close_callback);
|
||||
~ModalWindow() override;
|
||||
ModalForm(std::function<void()> on_close_callback);
|
||||
~ModalForm() override;
|
||||
|
||||
void Show(el::Element* root_element);
|
||||
|
||||
@@ -54,4 +54,4 @@ class ModalWindow : public Window, private ElementListener {
|
||||
} // namespace elements
|
||||
} // namespace el
|
||||
|
||||
#endif // EL_ELEMENTS_MODAL_WINDOW_H_
|
||||
#endif // EL_ELEMENTS_MODAL_FORM_H_
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "el/elements/popup_window.h"
|
||||
#include "el/elements/popup_form.h"
|
||||
#include "el/util/math.h"
|
||||
|
||||
namespace el {
|
||||
@@ -71,37 +71,37 @@ Rect PopupAlignment::GetAlignedRect(Element* popup, Element* target) const {
|
||||
return Rect(x, y, w, h);
|
||||
}
|
||||
|
||||
PopupWindow::PopupWindow(Element* target) : m_target(target) {
|
||||
PopupForm::PopupForm(Element* target) : m_target(target) {
|
||||
ElementListener::AddGlobalListener(this);
|
||||
set_background_skin(TBIDC("PopupWindow"), InvokeInfo::kNoCallbacks);
|
||||
set_settings(WindowSettings::kNone);
|
||||
set_background_skin(TBIDC("PopupForm"), InvokeInfo::kNoCallbacks);
|
||||
set_settings(FormSettings::kNone);
|
||||
}
|
||||
|
||||
PopupWindow::~PopupWindow() { ElementListener::RemoveGlobalListener(this); }
|
||||
PopupForm::~PopupForm() { ElementListener::RemoveGlobalListener(this); }
|
||||
|
||||
void PopupWindow::Show(const PopupAlignment& alignment) {
|
||||
// Calculate and set a good size for the popup window
|
||||
void PopupForm::Show(const PopupAlignment& alignment) {
|
||||
// Calculate and set a good size for the popup form
|
||||
set_rect(alignment.GetAlignedRect(this, m_target.get()));
|
||||
|
||||
Element* root = m_target.get()->parent_root();
|
||||
root->AddChild(this);
|
||||
}
|
||||
|
||||
bool PopupWindow::OnEvent(const Event& ev) {
|
||||
bool PopupForm::OnEvent(const Event& ev) {
|
||||
if (ev.type == EventType::kKeyDown && ev.special_key == SpecialKey::kEsc) {
|
||||
Close();
|
||||
return true;
|
||||
}
|
||||
return Window::OnEvent(ev);
|
||||
return Form::OnEvent(ev);
|
||||
}
|
||||
|
||||
void PopupWindow::OnElementFocusChanged(Element* element, bool focused) {
|
||||
void PopupForm::OnElementFocusChanged(Element* element, bool focused) {
|
||||
if (focused && !IsEventDestinationFor(element)) {
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
bool PopupWindow::OnElementInvokeEvent(Element* element, const Event& ev) {
|
||||
bool PopupForm::OnElementInvokeEvent(Element* element, const Event& ev) {
|
||||
if ((ev.type == EventType::kPointerDown ||
|
||||
ev.type == EventType::kContextMenu) &&
|
||||
!IsEventDestinationFor(ev.target)) {
|
||||
@@ -110,14 +110,14 @@ bool PopupWindow::OnElementInvokeEvent(Element* element, const Event& ev) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void PopupWindow::OnElementDelete(Element* element) {
|
||||
void PopupForm::OnElementDelete(Element* element) {
|
||||
// If the target element is deleted, close!
|
||||
if (!m_target.get()) {
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
bool PopupWindow::OnElementDying(Element* element) {
|
||||
bool PopupForm::OnElementDying(Element* element) {
|
||||
// If the target element or an ancestor of it is dying, close!
|
||||
if (element == m_target.get() || element->IsAncestorOf(m_target.get())) {
|
||||
Close();
|
||||
@@ -7,11 +7,11 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef EL_ELEMENTS_POPUP_WINDOW_H_
|
||||
#define EL_ELEMENTS_POPUP_WINDOW_H_
|
||||
#ifndef EL_ELEMENTS_POPUP_FORM_H_
|
||||
#define EL_ELEMENTS_POPUP_FORM_H_
|
||||
|
||||
#include "el/element_listener.h"
|
||||
#include "el/window.h"
|
||||
#include "el/elements/form.h"
|
||||
|
||||
namespace el {
|
||||
namespace elements {
|
||||
@@ -43,7 +43,7 @@ class PopupAlignment {
|
||||
align(Align::kBottom),
|
||||
expand_to_target_width(true) {}
|
||||
|
||||
// Calculates a good rect for the given popup window using its preferred size
|
||||
// Calculates a good rect for the given popup form using its preferred size
|
||||
// and the preferred alignment information stored in this class.
|
||||
Rect GetAlignedRect(Element* popup, Element* target) const;
|
||||
|
||||
@@ -56,15 +56,15 @@ class PopupAlignment {
|
||||
bool expand_to_target_width;
|
||||
};
|
||||
|
||||
// A popup window that redirects any child elements events through the given
|
||||
// A popup form that redirects any child elements events through the given
|
||||
// target. It will automatically close on click events that are not sent through
|
||||
// this popup.
|
||||
class PopupWindow : public Window, private ElementListener {
|
||||
class PopupForm : public Form, private ElementListener {
|
||||
public:
|
||||
TBOBJECT_SUBCLASS(PopupWindow, Window);
|
||||
TBOBJECT_SUBCLASS(PopupForm, Form);
|
||||
|
||||
PopupWindow(Element* target);
|
||||
~PopupWindow() override;
|
||||
PopupForm(Element* target);
|
||||
~PopupForm() override;
|
||||
|
||||
void Show(const PopupAlignment& alignment);
|
||||
|
||||
@@ -86,4 +86,4 @@ class PopupWindow : public Window, private ElementListener {
|
||||
} // namespace elements
|
||||
} // namespace el
|
||||
|
||||
#endif // EL_ELEMENTS_POPUP_WINDOW_H_
|
||||
#endif // EL_ELEMENTS_POPUP_FORM_H_
|
||||
@@ -7,7 +7,7 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "el/elements/menu_window.h"
|
||||
#include "el/elements/menu_form.h"
|
||||
#include "el/elements/text_box.h"
|
||||
#include "el/parsing/element_inflater.h"
|
||||
#include "el/text/font_face.h"
|
||||
@@ -282,7 +282,7 @@ bool TextBox::OnEvent(const Event& ev) {
|
||||
Point pos_in_root(ev.target_x, ev.target_y);
|
||||
ev.target->ConvertToRoot(pos_in_root.x, pos_in_root.y);
|
||||
|
||||
MenuWindow* menu = new MenuWindow(ev.target, TBIDC("popupmenu"));
|
||||
MenuForm* menu = new MenuForm(ev.target, TBIDC("popupmenu"));
|
||||
GenericStringItemSource* source = menu->list_box()->default_source();
|
||||
source->push_back(std::make_unique<GenericStringItem>(
|
||||
util::GetString(TBIDC("cut")), TBIDC("cut")));
|
||||
|
||||
@@ -69,7 +69,7 @@ class Renderer {
|
||||
|
||||
// Should be called before invoking paint on any element.
|
||||
// render_target_w and render_target_h should be the size of the render target
|
||||
// that the renderer renders to. I.e window size, screen size or frame buffer
|
||||
// that the renderer renders to. I.e form size, screen size or frame buffer
|
||||
// object.
|
||||
virtual void BeginPaint(int render_target_w, int render_target_h);
|
||||
virtual void EndPaint();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "el/elements/icon_box.h"
|
||||
#include "el/elements/layout_box.h"
|
||||
#include "el/elements/menu_window.h"
|
||||
#include "el/elements/menu_form.h"
|
||||
#include "el/elements/separator.h"
|
||||
#include "el/list_item.h"
|
||||
#include "el/parsing/parse_node.h"
|
||||
@@ -41,7 +41,7 @@ class SimpleBoxItemElement : public LayoutBox, private ElementListener {
|
||||
Label m_textfield;
|
||||
IconBox m_image;
|
||||
IconBox m_image_arrow;
|
||||
MenuWindow* m_menu = nullptr; // Points to the submenu window if opened.
|
||||
MenuForm* m_menu = nullptr; // Points to the submenu form if opened.
|
||||
};
|
||||
|
||||
SimpleBoxItemElement::SimpleBoxItemElement(TBID image, ListItemSource* source,
|
||||
@@ -92,8 +92,8 @@ void SimpleBoxItemElement::OnElementDelete(Element* element) {
|
||||
void SimpleBoxItemElement::OpenSubMenu() {
|
||||
if (m_menu) return;
|
||||
|
||||
// Open a new menu window for the submenu with this element as target.
|
||||
m_menu = new MenuWindow(this, TBIDC("submenu"));
|
||||
// Open a new menu form for the submenu with this element as target.
|
||||
m_menu = new MenuForm(this, TBIDC("submenu"));
|
||||
set_state(SkinState::kSelected, true);
|
||||
m_menu->AddListener(this);
|
||||
m_menu->Show(m_source, PopupAlignment(Align::kRight), -1);
|
||||
|
||||
@@ -66,11 +66,11 @@ class ElementInflater;
|
||||
// gravity SetGravity string
|
||||
// combination of left, top, right, bottom, or all
|
||||
// visibility SetVisibility string (visible, invisible,
|
||||
// gone)
|
||||
// gone)
|
||||
// state SetState string (disabled)
|
||||
// skin SetSkinBg TBID (string or int)
|
||||
// rect set_rect 4 integers (x, y, width,
|
||||
// height)
|
||||
// height)
|
||||
// lp>width set_layout_params dimension
|
||||
// lp>min-width set_layout_params dimension
|
||||
// lp>max-width set_layout_params dimension
|
||||
@@ -80,7 +80,7 @@ class ElementInflater;
|
||||
// lp>max-height set_layout_params dimension
|
||||
// lp>pref-height set_layout_params dimension
|
||||
// autofocus The Element will be focused automatically the
|
||||
// first time its Window is activated.
|
||||
// first time its Form is activated.
|
||||
// font>name Font name
|
||||
// font>size Font size
|
||||
class ElementFactory {
|
||||
|
||||
@@ -95,20 +95,20 @@ MAKE_ORDERED_ENUM_STRING_UTILS(SkinTarget, "this", "parent", "ancestors",
|
||||
|
||||
// Defines which property in the context that should be checked.
|
||||
enum class SkinProperty {
|
||||
kSkin, // The background skin id.
|
||||
kWindowActive, // The window is active (no value required).
|
||||
kAxis, // The axis of the content (x or y)
|
||||
kAlign, // The alignment.
|
||||
kId, // The id.
|
||||
kState, // The state is set.
|
||||
kValue, // The current value (integer).
|
||||
kHover, // Focus is on the target or any child (no value required).
|
||||
kCapture, // Capture is on the target or any child (no value required).
|
||||
kFocus, // Focus is on the target or any child (no value required).
|
||||
kSkin, // The background skin id.
|
||||
kFormActive, // The form is active (no value required).
|
||||
kAxis, // The axis of the content (x or y)
|
||||
kAlign, // The alignment.
|
||||
kId, // The id.
|
||||
kState, // The state is set.
|
||||
kValue, // The current value (integer).
|
||||
kHover, // Focus is on the target or any child (no value required).
|
||||
kCapture, // Capture is on the target or any child (no value required).
|
||||
kFocus, // Focus is on the target or any child (no value required).
|
||||
kCustom, // It's a property unknown to skin, that the SkinConditionContext
|
||||
// might know about.
|
||||
};
|
||||
MAKE_ORDERED_ENUM_STRING_UTILS(SkinProperty, "skin", "window active", "axis",
|
||||
MAKE_ORDERED_ENUM_STRING_UTILS(SkinProperty, "skin", "form active", "axis",
|
||||
"align", "id", "state", "value", "hover",
|
||||
"capture", "focus", "custom");
|
||||
|
||||
|
||||
@@ -31,9 +31,9 @@ EL_TEST_GROUP(tb_text_box) {
|
||||
* tests. */
|
||||
edit->set_rect({0, 0, 1000, 1000});
|
||||
|
||||
/** Force windows style line breaks so testing is the same on all platforms.
|
||||
/** Force forms style line breaks so testing is the same on all platforms.
|
||||
*/
|
||||
sedit->set_windows_style_break(true);
|
||||
sedit->set_forms_style_break(true);
|
||||
}
|
||||
EL_TEST(Cleanup) { delete edit; }
|
||||
|
||||
@@ -46,7 +46,7 @@ EL_TEST_GROUP(tb_text_box) {
|
||||
}
|
||||
|
||||
EL_TEST(settext_multiline) {
|
||||
// Both unix and windows line endings should be ok.
|
||||
// Both unix and forms line endings should be ok.
|
||||
edit->set_text("One\nTwo", CaretPosition::kEnd);
|
||||
EL_VERIFY_STR(edit->text(), "One\nTwo");
|
||||
edit->set_text("One\r\nTwo", CaretPosition::kEnd);
|
||||
@@ -179,7 +179,7 @@ EL_TEST_GROUP(tb_text_box) {
|
||||
}
|
||||
|
||||
EL_TEST(settext_undo_stack_ins_linebreak_3) {
|
||||
sedit->set_windows_style_break(false);
|
||||
sedit->set_forms_style_break(false);
|
||||
|
||||
sedit->InsertBreak();
|
||||
EL_VERIFY_STR(edit->text(), "\n\n");
|
||||
|
||||
@@ -96,12 +96,12 @@ class TextView {
|
||||
void set_password(bool password = true);
|
||||
void set_wrapping(bool wrapping = true);
|
||||
|
||||
// Sets if line breaks should be inserted in windows style (\r\n) or unix
|
||||
// style (\n). The default is windows style on the windows platform and
|
||||
// Sets if line breaks should be inserted in forms style (\r\n) or unix
|
||||
// style (\n). The default is forms style on the forms platform and
|
||||
// disabled elsewhere.
|
||||
// NOTE: This only affects InsertBreak (pressing enter). Content set from
|
||||
// SetText (and clipboard etc.) maintains the used line break.
|
||||
void set_windows_style_break(bool win_style_br) {
|
||||
void set_forms_style_break(bool win_style_br) {
|
||||
packed.win_style_br = win_style_br;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include "el/elements/popup_window.h"
|
||||
#include "el/elements/popup_form.h"
|
||||
#include "el/elements/text_box.h"
|
||||
#include "el/tooltip_manager.h"
|
||||
|
||||
@@ -32,14 +32,14 @@ class TTMsgParam : public util::TypedObject {
|
||||
|
||||
} // namespace
|
||||
|
||||
// Implements functionality of tooltip popups, based on PopupWindow and
|
||||
// Implements functionality of tooltip popups, based on PopupForm and
|
||||
// contains TextBox as content viewer.
|
||||
class TooltipWindow : public elements::PopupWindow {
|
||||
class TooltipForm : public elements::PopupForm {
|
||||
public:
|
||||
TBOBJECT_SUBCLASS(TooltipWindow, elements::PopupWindow);
|
||||
TBOBJECT_SUBCLASS(TooltipForm, elements::PopupForm);
|
||||
|
||||
TooltipWindow(Element* target);
|
||||
~TooltipWindow() override;
|
||||
TooltipForm(Element* target);
|
||||
~TooltipForm() override;
|
||||
|
||||
bool Show(int mouse_x, int mouse_y);
|
||||
|
||||
@@ -53,9 +53,9 @@ class TooltipWindow : public elements::PopupWindow {
|
||||
int m_offset_y = 0;
|
||||
};
|
||||
|
||||
TooltipWindow::TooltipWindow(Element* target) : PopupWindow(target) {
|
||||
TooltipForm::TooltipForm(Element* target) : PopupForm(target) {
|
||||
set_background_skin("", InvokeInfo::kNoCallbacks);
|
||||
set_settings(WindowSettings::kNone);
|
||||
set_settings(elements::FormSettings::kNone);
|
||||
m_content.set_background_skin(TBIDC("TBTooltip"), InvokeInfo::kNoCallbacks);
|
||||
m_content.set_focusable(false);
|
||||
m_content.set_styled(true);
|
||||
@@ -67,9 +67,9 @@ TooltipWindow::TooltipWindow(Element* target) : PopupWindow(target) {
|
||||
AddChild(&m_content);
|
||||
}
|
||||
|
||||
TooltipWindow::~TooltipWindow() { RemoveChild(&m_content); }
|
||||
TooltipForm::~TooltipForm() { RemoveChild(&m_content); }
|
||||
|
||||
bool TooltipWindow::Show(int mouse_x, int mouse_y) {
|
||||
bool TooltipForm::Show(int mouse_x, int mouse_y) {
|
||||
m_offset_x = mouse_x;
|
||||
m_offset_y = mouse_y;
|
||||
|
||||
@@ -78,7 +78,7 @@ bool TooltipWindow::Show(int mouse_x, int mouse_y) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Rect TooltipWindow::GetAlignedRect(int x, int y) {
|
||||
Rect TooltipForm::GetAlignedRect(int x, int y) {
|
||||
Element* root = parent_root();
|
||||
|
||||
SizeConstraints sc(root->rect().w, root->rect().h);
|
||||
@@ -166,7 +166,7 @@ void TooltipManager::OnMessageReceived(Message* msg) {
|
||||
if (tipped_element == param->m_hovered) {
|
||||
KillToolTip();
|
||||
|
||||
m_tooltip = new TooltipWindow(tipped_element);
|
||||
m_tooltip = new TooltipForm(tipped_element);
|
||||
|
||||
int x = Element::pointer_move_element_x;
|
||||
int y = Element::pointer_move_element_y;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace el {
|
||||
|
||||
class TooltipWindow;
|
||||
class TooltipForm;
|
||||
|
||||
// Implements logic for show/hide tooltips.
|
||||
class TooltipManager : private ElementListener, public MessageHandler {
|
||||
@@ -49,7 +49,7 @@ class TooltipManager : private ElementListener, public MessageHandler {
|
||||
|
||||
static std::unique_ptr<TooltipManager> tooltip_manager_singleton_;
|
||||
|
||||
TooltipWindow* m_tooltip = nullptr;
|
||||
TooltipForm* m_tooltip = nullptr;
|
||||
Element* m_last_tipped_element = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include "el/elements/check_box.h"
|
||||
#include "el/elements/form.h"
|
||||
#include "el/elements/label_container.h"
|
||||
#include "el/elements/text_box.h"
|
||||
#include "el/graphics/image_manager.h"
|
||||
#include "el/text/font_manager.h"
|
||||
#include "el/util/debug.h"
|
||||
#include "el/util/string.h"
|
||||
#include "el/window.h"
|
||||
|
||||
#ifdef EL_RUNTIME_DEBUG_INFO
|
||||
|
||||
@@ -27,14 +27,14 @@ DebugInfo DebugInfo::debug_info_singleton_;
|
||||
|
||||
DebugInfo::DebugInfo() = default;
|
||||
|
||||
// Window showing runtime debug settings.
|
||||
class DebugSettingsWindow : public Window, public ElementListener {
|
||||
// Form showing runtime debug settings.
|
||||
class DebugSettingsForm : public elements::Form, public ElementListener {
|
||||
public:
|
||||
TBOBJECT_SUBCLASS(DebugSettingsWindow, Window);
|
||||
TBOBJECT_SUBCLASS(DebugSettingsForm, elements::Form);
|
||||
|
||||
elements::TextBox* output;
|
||||
|
||||
DebugSettingsWindow(Element* root) {
|
||||
DebugSettingsForm(Element* root) {
|
||||
set_text("Debug settings");
|
||||
LoadData(
|
||||
"LayoutBox: axis: y, distribution: available, position: left\n"
|
||||
@@ -66,7 +66,7 @@ class DebugSettingsWindow : public Window, public ElementListener {
|
||||
ElementListener::AddGlobalListener(this);
|
||||
}
|
||||
|
||||
~DebugSettingsWindow() { ElementListener::RemoveGlobalListener(this); }
|
||||
~DebugSettingsForm() { ElementListener::RemoveGlobalListener(this); }
|
||||
|
||||
void AddCheckbox(DebugInfo::Setting setting, const char* str) {
|
||||
auto check = new elements::CheckBox();
|
||||
@@ -89,11 +89,11 @@ class DebugSettingsWindow : public Window, public ElementListener {
|
||||
parent_root()->Invalidate();
|
||||
return true;
|
||||
}
|
||||
return Window::OnEvent(ev);
|
||||
return Form::OnEvent(ev);
|
||||
}
|
||||
|
||||
void OnPaint(const PaintProps& paint_props) override {
|
||||
// Draw stuff to the right of the debug window.
|
||||
// Draw stuff to the right of the debug form.
|
||||
graphics::Renderer::get()->Translate(rect().w, 0);
|
||||
|
||||
// Draw skin bitmap fragments.
|
||||
@@ -135,10 +135,10 @@ class DebugSettingsWindow : public Window, public ElementListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Always ignore activity in this window (or we might get endless
|
||||
// Always ignore activity in this form (or we might get endless
|
||||
// recursion).
|
||||
if (Window* window = element->parent_window()) {
|
||||
if (SafeCast<DebugSettingsWindow>(window)) {
|
||||
if (Form* form = element->parent_form()) {
|
||||
if (SafeCast<DebugSettingsForm>(form)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -187,9 +187,7 @@ class DebugSettingsWindow : public Window, public ElementListener {
|
||||
}
|
||||
};
|
||||
|
||||
void ShowDebugInfoSettingsWindow(Element* root) {
|
||||
new DebugSettingsWindow(root);
|
||||
}
|
||||
void ShowDebugInfoSettingsForm(Element* root) { new DebugSettingsForm(root); }
|
||||
|
||||
} // namespace util
|
||||
} // namespace el
|
||||
|
||||
@@ -65,8 +65,8 @@ class DebugInfo {
|
||||
static DebugInfo debug_info_singleton_;
|
||||
};
|
||||
|
||||
// Shows a window containing runtime debugging settings.
|
||||
void ShowDebugInfoSettingsWindow(Element* root);
|
||||
// Shows a form containing runtime debugging settings.
|
||||
void ShowDebugInfoSettingsForm(Element* root);
|
||||
|
||||
#define EL_DEBUG_SETTING(setting) \
|
||||
el::util::DebugInfo::get()->settings[int(setting)]
|
||||
@@ -81,7 +81,7 @@ void ShowDebugInfoSettingsWindow(Element* root);
|
||||
#else
|
||||
namespace el {
|
||||
namespace util {
|
||||
inline void ShowDebugInfoSettingsWindow(Element* root) {}
|
||||
inline void ShowDebugInfoSettingsForm(Element* root) {}
|
||||
} // namespace util
|
||||
} // namespace el
|
||||
#define EL_DEBUG_SETTING(setting) false
|
||||
|
||||
@@ -70,7 +70,7 @@ void ResourceEditWindow::Load(const char* resource_file) {
|
||||
file_contents->size());
|
||||
} else {
|
||||
// Error, show message.
|
||||
auto msg_win = new MessageWindow(parent_root(), TBIDC(""));
|
||||
auto msg_win = new MessageForm(parent_root(), TBIDC(""));
|
||||
msg_win->Show(
|
||||
"Error loading resource",
|
||||
el::util::format_string("Could not load file %s", resource_file));
|
||||
@@ -156,7 +156,7 @@ bool ResourceEditWindow::OnEvent(const Event& ev) {
|
||||
return true;
|
||||
} else if (ev.type == EventType::kClick && ev.target->id() == TBIDC("test")) {
|
||||
// Create a window containing the current layout, resize and center it.
|
||||
Window* win = new Window();
|
||||
auto win = new Form();
|
||||
win->set_text("Test window");
|
||||
win->content_root()->LoadData(m_source_text_box->text());
|
||||
Rect bounds(0, 0, parent()->rect().w, parent()->rect().h);
|
||||
@@ -172,11 +172,11 @@ bool ResourceEditWindow::OnEvent(const Event& ev) {
|
||||
} else if (ev.type == EventType::kFileDrop) {
|
||||
return OnDropFileEvent(ev);
|
||||
}
|
||||
return Window::OnEvent(ev);
|
||||
return Form::OnEvent(ev);
|
||||
}
|
||||
|
||||
void ResourceEditWindow::OnPaintChildren(const PaintProps& paint_props) {
|
||||
Window::OnPaintChildren(paint_props);
|
||||
Form::OnPaintChildren(paint_props);
|
||||
|
||||
// Paint the selection of the selected element
|
||||
if (Element* selected_element = GetSelectedElement()) {
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
|
||||
#include "el/element.h"
|
||||
#include "el/element_listener.h"
|
||||
#include "el/elements/form.h"
|
||||
#include "el/elements/list_box.h"
|
||||
#include "el/elements/text_box.h"
|
||||
#include "el/message_handler.h"
|
||||
#include "el/window.h"
|
||||
|
||||
namespace testbed {
|
||||
|
||||
@@ -30,11 +30,11 @@ class ResourceItem : public el::GenericStringItem {
|
||||
Element* m_element;
|
||||
};
|
||||
|
||||
class ResourceEditWindow : public Window,
|
||||
class ResourceEditWindow : public elements::Form,
|
||||
public MessageHandler,
|
||||
public ElementListener {
|
||||
public:
|
||||
TBOBJECT_SUBCLASS(ResourceEditWindow, Window);
|
||||
TBOBJECT_SUBCLASS(ResourceEditWindow, elements::Form);
|
||||
|
||||
ResourceEditWindow();
|
||||
~ResourceEditWindow() override;
|
||||
|
||||
@@ -145,7 +145,7 @@ bool TestbedApplication::Init() {
|
||||
new TabContainerWindow();
|
||||
|
||||
if (num_failed_tests) {
|
||||
MessageWindow* msg_win = new MessageWindow(GetRoot(), TBIDC(""));
|
||||
auto msg_win = new MessageForm(GetRoot(), TBIDC(""));
|
||||
msg_win->Show(
|
||||
"Testing results",
|
||||
el::util::format_string(
|
||||
@@ -379,7 +379,7 @@ bool DemoWindow::OnEvent(const Event& ev) {
|
||||
title_close_button_.InvokeEvent(click_ev);
|
||||
return true;
|
||||
}
|
||||
return Window::OnEvent(ev);
|
||||
return Form::OnEvent(ev);
|
||||
}
|
||||
|
||||
// == EditWindow ==============================================================
|
||||
@@ -443,7 +443,7 @@ bool EditWindow::OnEvent(const Event& ev) {
|
||||
"Align right", TBIDC("align right")));
|
||||
}
|
||||
|
||||
if (MenuWindow* menu = new MenuWindow(ev.target, TBIDC("popup_menu")))
|
||||
if (auto menu = new MenuForm(ev.target, TBIDC("popup_menu")))
|
||||
menu->Show(&source, PopupAlignment());
|
||||
return true;
|
||||
} else if (ev.target->id() == TBIDC("popup_menu")) {
|
||||
@@ -625,11 +625,11 @@ bool ScrollContainerWindow::OnEvent(const Event& ev) {
|
||||
delete ev.target;
|
||||
return true;
|
||||
} else if (ev.target->id() == TBIDC("showpopupmenu1")) {
|
||||
if (MenuWindow* menu = new MenuWindow(ev.target, TBIDC("popupmenu1")))
|
||||
if (auto menu = new MenuForm(ev.target, TBIDC("popupmenu1")))
|
||||
menu->Show(&popup_menu_source, PopupAlignment());
|
||||
return true;
|
||||
} else if (ev.target->id() == TBIDC("popupmenu1")) {
|
||||
MessageWindow* msg_win = new MessageWindow(this, TBIDC("popup_dialog"));
|
||||
auto msg_win = new MessageForm(this, TBIDC("popup_dialog"));
|
||||
msg_win->Show("Info",
|
||||
el::util::format_string("Menu event received!\nref_id: %d",
|
||||
(int)ev.ref_id));
|
||||
@@ -730,7 +730,7 @@ bool AnimationsWindow::OnEvent(const Event& ev) {
|
||||
class FullScreenWindow : public DemoWindow {
|
||||
public:
|
||||
FullScreenWindow() : DemoWindow() {
|
||||
set_settings(WindowSettings::kFullScreen);
|
||||
set_settings(FormSettings::kFullScreen);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -825,13 +825,13 @@ MainWindow::MainWindow() {
|
||||
|
||||
void MainWindow::OnMessageReceived(Message* msg) {
|
||||
if (msg->message_id() == TBIDC("instantmsg")) {
|
||||
MessageWindow* msg_win = new MessageWindow(this, TBIDC("test_dialog"));
|
||||
auto msg_win = new MessageForm(this, TBIDC("test_dialog"));
|
||||
msg_win->Show("Message window", "Instant message received!");
|
||||
} else if (msg->message_id() == TBIDC("busy")) {
|
||||
// Keep the message queue busy by posting another "busy" message.
|
||||
PostMessage(TBIDC("busy"), nullptr);
|
||||
} else if (msg->message_id() == TBIDC("delayedmsg")) {
|
||||
MessageWindow* msg_win = new MessageWindow(this, TBIDC(""));
|
||||
auto msg_win = new MessageForm(this, TBIDC(""));
|
||||
msg_win->Show("Message window",
|
||||
el::util::format_string(
|
||||
"Delayed message received!\n\n"
|
||||
@@ -855,8 +855,7 @@ bool MainWindow::OnEvent(const Event& ev) {
|
||||
assert(!GetMessageById(TBIDC("busy")));
|
||||
if (!GetMessageById(TBIDC("busy"))) {
|
||||
PostMessage(TBIDC("busy"), nullptr);
|
||||
MessageWindow* msg_win =
|
||||
new MessageWindow(this, TBIDC("test_dialog"));
|
||||
auto msg_win = new MessageForm(this, TBIDC("test_dialog"));
|
||||
msg_win->Show("Message window",
|
||||
"The message loop is now constantly busy with messages "
|
||||
"to process.\n\n"
|
||||
@@ -876,10 +875,8 @@ bool MainWindow::OnEvent(const Event& ev) {
|
||||
} else if (ev.target->id() == TBIDC("Window.close")) {
|
||||
// Intercept the Window.close message and stop it from bubbling
|
||||
// to Window (prevent the window from closing)
|
||||
MessageWindow* msg_win =
|
||||
new MessageWindow(this, TBIDC("confirm_close_dialog"));
|
||||
MessageWindowSettings settings(MessageWindowButtons::kYesNo,
|
||||
TBIDC("Icon48"));
|
||||
auto msg_win = new MessageForm(this, TBIDC("confirm_close_dialog"));
|
||||
MessageFormSettings settings(MessageFormButtons::kYesNo, TBIDC("Icon48"));
|
||||
settings.dimmer = true;
|
||||
settings.styling = true;
|
||||
msg_win->Show("Are you sure?",
|
||||
@@ -897,7 +894,7 @@ bool MainWindow::OnEvent(const Event& ev) {
|
||||
}
|
||||
uint64_t t2 = util::GetTimeMS();
|
||||
|
||||
MessageWindow* msg_win = new MessageWindow(ev.target, TBID());
|
||||
auto msg_win = new MessageForm(ev.target, TBID());
|
||||
msg_win->Show("GFX load performance",
|
||||
el::util::format_string(
|
||||
"Reloading the skin graphics %d times took %dms",
|
||||
@@ -906,7 +903,7 @@ bool MainWindow::OnEvent(const Event& ev) {
|
||||
} else if (ev.target->id() == TBIDC("test context lost")) {
|
||||
Renderer::get()->InvokeContextLost();
|
||||
Renderer::get()->InvokeContextRestored();
|
||||
MessageWindow* msg_win = new MessageWindow(ev.target, TBID());
|
||||
auto msg_win = new MessageForm(ev.target, TBID());
|
||||
msg_win->Show("Context lost & restore",
|
||||
"Called InvokeContextLost and InvokeContextRestored.\n\n"
|
||||
"Does everything look fine?");
|
||||
@@ -952,7 +949,7 @@ bool MainWindow::OnEvent(const Event& ev) {
|
||||
} else if (ev.type == EventType::kClick &&
|
||||
ev.target->id() == TBIDC("debug settings")) {
|
||||
#ifdef EL_RUNTIME_DEBUG_INFO
|
||||
util::ShowDebugInfoSettingsWindow(parent_root());
|
||||
util::ShowDebugInfoSettingsForm(parent_root());
|
||||
#else
|
||||
MessageWindow* msg_win = new MessageWindow(ev.target, TBID());
|
||||
msg_win->Show("Debug settings",
|
||||
|
||||
@@ -57,7 +57,7 @@ class TestbedApplication {
|
||||
ApplicationBackend* m_backend;
|
||||
};
|
||||
|
||||
class DemoWindow : public Window {
|
||||
class DemoWindow : public elements::Form {
|
||||
public:
|
||||
DemoWindow();
|
||||
bool LoadResourceFile(const std::string& filename);
|
||||
|
||||
Reference in New Issue
Block a user