mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 10:13:22 +00:00
Refactor: replace jwidget_magnetic/expansive/decorative/focusrest with member functions of Widget class.
This commit is contained in:
parent
37d9a3d636
commit
f8f52f75fa
12
src/app.cpp
12
src/app.cpp
@ -199,12 +199,12 @@ int App::run()
|
|||||||
editor = create_new_editor();
|
editor = create_new_editor();
|
||||||
|
|
||||||
// configure all widgets to expansives
|
// configure all widgets to expansives
|
||||||
jwidget_expansive(menubar, true);
|
menubar->setExpansive(true);
|
||||||
jwidget_expansive(statusbar, true);
|
statusbar->setExpansive(true);
|
||||||
jwidget_expansive(colorbar, true);
|
colorbar->setExpansive(true);
|
||||||
jwidget_expansive(toolbar, true);
|
toolbar->setExpansive(true);
|
||||||
jwidget_expansive(tabsbar, true);
|
tabsbar->setExpansive(true);
|
||||||
jwidget_expansive(view, true);
|
view->setExpansive(true);
|
||||||
|
|
||||||
/* prepare the first editor */
|
/* prepare the first editor */
|
||||||
view->attachToView(editor);
|
view->attachToView(editor);
|
||||||
|
@ -80,10 +80,10 @@ void AboutCommand::onExecute(Context* context)
|
|||||||
grid->addChildInCell(website, 2, 1, 0);
|
grid->addChildInCell(website, 2, 1, 0);
|
||||||
grid->addChildInCell(bottom_box1, 2, 1, 0);
|
grid->addChildInCell(bottom_box1, 2, 1, 0);
|
||||||
|
|
||||||
jwidget_magnetic(close_button, true);
|
close_button->setFocusMagnet(true);
|
||||||
|
|
||||||
jwidget_expansive(bottom_box2, true);
|
bottom_box2->setExpansive(true);
|
||||||
jwidget_expansive(bottom_box3, true);
|
bottom_box3->setExpansive(true);
|
||||||
|
|
||||||
bottom_box1->addChild(bottom_box2);
|
bottom_box1->addChild(bottom_box2);
|
||||||
bottom_box1->addChild(close_button);
|
bottom_box1->addChild(close_button);
|
||||||
|
@ -75,7 +75,7 @@ void LayerPropertiesCommand::onExecute(Context* context)
|
|||||||
button_cancel->Click.connect(Bind<void>(&Frame::closeWindow, window.get(), button_cancel));
|
button_cancel->Click.connect(Bind<void>(&Frame::closeWindow, window.get(), button_cancel));
|
||||||
|
|
||||||
jwidget_set_min_size(entry_name, 128, 0);
|
jwidget_set_min_size(entry_name, 128, 0);
|
||||||
jwidget_expansive(entry_name, true);
|
entry_name->setExpansive(true);
|
||||||
|
|
||||||
box2->addChild(label_name);
|
box2->addChild(label_name);
|
||||||
box2->addChild(entry_name);
|
box2->addChild(entry_name);
|
||||||
@ -85,8 +85,8 @@ void LayerPropertiesCommand::onExecute(Context* context)
|
|||||||
box1->addChild(box3);
|
box1->addChild(box3);
|
||||||
window->addChild(box1);
|
window->addChild(box1);
|
||||||
|
|
||||||
jwidget_magnetic(entry_name, true);
|
entry_name->setFocusMagnet(true);
|
||||||
jwidget_magnetic(button_ok, true);
|
button_ok->setFocusMagnet(true);
|
||||||
|
|
||||||
window->open_window_fg();
|
window->open_window_fg();
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public:
|
|||||||
, m_editor(filter.getCurve(), 0, 0, 255, 255)
|
, m_editor(filter.getCurve(), 0, 0, 255, 255)
|
||||||
{
|
{
|
||||||
m_view.attachToView(&m_editor);
|
m_view.attachToView(&m_editor);
|
||||||
jwidget_expansive(&m_view, true);
|
m_view.setExpansive(true);
|
||||||
jwidget_set_min_size(&m_view, 128, 64);
|
jwidget_set_min_size(&m_view, 128, 64);
|
||||||
|
|
||||||
getContainer()->addChild(&m_view);
|
getContainer()->addChild(&m_view);
|
||||||
|
@ -74,7 +74,7 @@ ColorCurveEditor::ColorCurveEditor(ColorCurve* curve, int x1, int y1, int x2, in
|
|||||||
: Widget(JI_WIDGET)
|
: Widget(JI_WIDGET)
|
||||||
, m_curve(curve)
|
, m_curve(curve)
|
||||||
{
|
{
|
||||||
jwidget_focusrest(this, true);
|
this->setFocusStop(true);
|
||||||
|
|
||||||
border_width.l = border_width.r = 1;
|
border_width.l = border_width.r = 1;
|
||||||
border_width.t = border_width.b = 1;
|
border_width.t = border_width.b = 1;
|
||||||
|
@ -50,7 +50,7 @@ FilterWindow::FilterWindow(const char* title, const char* cfgSection,
|
|||||||
m_cancelButton.Click.connect(&FilterWindow::onCancel, this);
|
m_cancelButton.Click.connect(&FilterWindow::onCancel, this);
|
||||||
m_showPreview.Click.connect(&FilterWindow::onShowPreview, this);
|
m_showPreview.Click.connect(&FilterWindow::onShowPreview, this);
|
||||||
|
|
||||||
jwidget_expansive(&m_container, true);
|
m_container.setExpansive(true);
|
||||||
|
|
||||||
m_hbox.addChild(&m_container);
|
m_hbox.addChild(&m_container);
|
||||||
m_hbox.addChild(&m_vbox);
|
m_hbox.addChild(&m_vbox);
|
||||||
@ -74,7 +74,7 @@ FilterWindow::FilterWindow(const char* title, const char* cfgSection,
|
|||||||
m_showPreview.setSelected(get_config_bool(m_cfgSection, "Preview", true));
|
m_showPreview.setSelected(get_config_bool(m_cfgSection, "Preview", true));
|
||||||
|
|
||||||
// OK is magnetic (the default button)
|
// OK is magnetic (the default button)
|
||||||
jwidget_magnetic(&m_okButton, true);
|
m_okButton.setFocusMagnet(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
FilterWindow::~FilterWindow()
|
FilterWindow::~FilterWindow()
|
||||||
|
@ -70,8 +70,8 @@ Console::Console()
|
|||||||
window->addChild(grid);
|
window->addChild(grid);
|
||||||
|
|
||||||
view->setVisible(false);
|
view->setVisible(false);
|
||||||
jwidget_magnetic(button, true);
|
button->setFocusMagnet(true);
|
||||||
jwidget_expansive(view, true);
|
view->setExpansive(true);
|
||||||
|
|
||||||
/* force foreground mode */
|
/* force foreground mode */
|
||||||
/* ji_find_widget(window)->in_foreground = true; */
|
/* ji_find_widget(window)->in_foreground = true; */
|
||||||
|
@ -219,7 +219,7 @@ AnimationEditor::AnimationEditor(const Document* document, const Sprite* sprite)
|
|||||||
m_clk_part = A_PART_NOTHING;
|
m_clk_part = A_PART_NOTHING;
|
||||||
m_space_pressed = false;
|
m_space_pressed = false;
|
||||||
|
|
||||||
jwidget_focusrest(this, true);
|
this->setFocusStop(true);
|
||||||
|
|
||||||
regenerateLayers();
|
regenerateLayers();
|
||||||
}
|
}
|
||||||
|
@ -182,9 +182,9 @@ base::string ase_file_selector(const base::string& message,
|
|||||||
ASSERT(filetype != NULL);
|
ASSERT(filetype != NULL);
|
||||||
filename_entry = window->findChildT<Entry>("filename");
|
filename_entry = window->findChildT<Entry>("filename");
|
||||||
|
|
||||||
jwidget_focusrest(goback, false);
|
goback->setFocusStop(false);
|
||||||
jwidget_focusrest(goforward, false);
|
goforward->setFocusStop(false);
|
||||||
jwidget_focusrest(goup, false);
|
goup->setFocusStop(false);
|
||||||
|
|
||||||
set_gfxicon_to_button(goback,
|
set_gfxicon_to_button(goback,
|
||||||
PART_COMBOBOX_ARROW_LEFT,
|
PART_COMBOBOX_ARROW_LEFT,
|
||||||
@ -221,7 +221,7 @@ base::string ase_file_selector(const base::string& message,
|
|||||||
fileview->setName("fileview");
|
fileview->setName("fileview");
|
||||||
|
|
||||||
view->attachToView(fileview);
|
view->attachToView(fileview);
|
||||||
jwidget_expansive(view, true);
|
view->setExpansive(true);
|
||||||
|
|
||||||
box->addChild(view);
|
box->addChild(view);
|
||||||
|
|
||||||
|
@ -104,10 +104,10 @@ void dialogs_mask_color(Document* document)
|
|||||||
slider_tolerance->Change.connect(Bind<void>(&mask_preview, Ref(documentReader)));
|
slider_tolerance->Change.connect(Bind<void>(&mask_preview, Ref(documentReader)));
|
||||||
check_preview->Click.connect(Bind<void>(&mask_preview, Ref(documentReader)));
|
check_preview->Click.connect(Bind<void>(&mask_preview, Ref(documentReader)));
|
||||||
|
|
||||||
jwidget_magnetic(button_ok, true);
|
button_ok->setFocusMagnet(true);
|
||||||
jwidget_expansive(button_color, true);
|
button_color->setExpansive(true);
|
||||||
jwidget_expansive(slider_tolerance, true);
|
slider_tolerance->setExpansive(true);
|
||||||
jwidget_expansive(box2, true);
|
box2->setExpansive(true);
|
||||||
|
|
||||||
window->addChild(box1);
|
window->addChild(box1);
|
||||||
box1->addChild(box2);
|
box1->addChild(box2);
|
||||||
|
@ -185,8 +185,8 @@ void Alert::processString(char* buf, std::vector<Widget*>& labels, std::vector<W
|
|||||||
box4 = new Box(0);
|
box4 = new Box(0);
|
||||||
box5 = new Box(0);
|
box5 = new Box(0);
|
||||||
|
|
||||||
jwidget_expansive(box4, true);
|
box4->setExpansive(true);
|
||||||
jwidget_expansive(box5, true);
|
box5->setExpansive(true);
|
||||||
jwidget_noborders(box4);
|
jwidget_noborders(box4);
|
||||||
jwidget_noborders(box5);
|
jwidget_noborders(box5);
|
||||||
|
|
||||||
@ -209,5 +209,5 @@ void Alert::processString(char* buf, std::vector<Widget*>& labels, std::vector<W
|
|||||||
|
|
||||||
// Default button is the last one
|
// Default button is the last one
|
||||||
if (!buttons.empty())
|
if (!buttons.empty())
|
||||||
jwidget_magnetic(buttons[buttons.size()-1], true);
|
buttons[buttons.size()-1]->setFocusMagnet(true);
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@ union Message;
|
|||||||
#define JI_HASFOCUS 0x0008 // Has the input focus.
|
#define JI_HASFOCUS 0x0008 // Has the input focus.
|
||||||
#define JI_HASMOUSE 0x0010 // Has the mouse.
|
#define JI_HASMOUSE 0x0010 // Has the mouse.
|
||||||
#define JI_HASCAPTURE 0x0020 // Captured the mouse .
|
#define JI_HASCAPTURE 0x0020 // Captured the mouse .
|
||||||
#define JI_FOCUSREST 0x0040 // Want the focus (is a rest for focus).
|
#define JI_FOCUSSTOP 0x0040 // The widget support the focus on it.
|
||||||
#define JI_MAGNETIC 0x0080 // Attract the focus.
|
#define JI_FOCUSMAGNET 0x0080 // The widget wants the focus by default (e.g. when the dialog is shown by first time).
|
||||||
#define JI_EXPANSIVE 0x0100 // Is expansive (want more space).
|
#define JI_EXPANSIVE 0x0100 // Is expansive (want more space).
|
||||||
#define JI_DECORATIVE 0x0200 // To decorate windows.
|
#define JI_DECORATIVE 0x0200 // To decorate windows.
|
||||||
#define JI_INITIALIZED 0x0400 // The widget was already initialized by a theme.
|
#define JI_INITIALIZED 0x0400 // The widget was already initialized by a theme.
|
||||||
|
@ -156,7 +156,7 @@ void Box::box_set_position(JRect rect)
|
|||||||
\
|
\
|
||||||
child_width = reqSize.w; \
|
child_width = reqSize.w; \
|
||||||
\
|
\
|
||||||
if (jwidget_is_expansive(child)) { \
|
if (child->isExpansive()) { \
|
||||||
if (nexpand_children == 1) \
|
if (nexpand_children == 1) \
|
||||||
child_width += width; \
|
child_width += width; \
|
||||||
else \
|
else \
|
||||||
@ -199,7 +199,7 @@ void Box::box_set_position(JRect rect)
|
|||||||
|
|
||||||
if (!(child->flags & JI_HIDDEN)) {
|
if (!(child->flags & JI_HIDDEN)) {
|
||||||
nvis_children++;
|
nvis_children++;
|
||||||
if (jwidget_is_expansive(child))
|
if (child->isExpansive())
|
||||||
nexpand_children++;
|
nexpand_children++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class BoxFiller : public Box
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BoxFiller() : Box(JI_HORIZONTAL) {
|
BoxFiller() : Box(JI_HORIZONTAL) {
|
||||||
jwidget_expansive(this, true);
|
this->setExpansive(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ ButtonBase::ButtonBase(const char* text, int type, int behaviorType, int drawTyp
|
|||||||
{
|
{
|
||||||
this->setAlign(JI_CENTER | JI_MIDDLE);
|
this->setAlign(JI_CENTER | JI_MIDDLE);
|
||||||
this->setText(text);
|
this->setText(text);
|
||||||
jwidget_focusrest(this, true);
|
this->setFocusStop(true);
|
||||||
|
|
||||||
// Initialize theme
|
// Initialize theme
|
||||||
this->type = m_drawType; // TODO Fix this nasty trick
|
this->type = m_drawType; // TODO Fix this nasty trick
|
||||||
@ -110,7 +110,7 @@ bool ButtonBase::onProcessMessage(Message* msg)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/* magnetic */
|
/* magnetic */
|
||||||
else if (jwidget_is_magnetic(this) &&
|
else if (this->isFocusMagnet() &&
|
||||||
((msg->key.scancode == KEY_ENTER) ||
|
((msg->key.scancode == KEY_ENTER) ||
|
||||||
(msg->key.scancode == KEY_ENTER_PAD))) {
|
(msg->key.scancode == KEY_ENTER_PAD))) {
|
||||||
jmanager_set_focus(this);
|
jmanager_set_focus(this);
|
||||||
|
@ -57,10 +57,10 @@ ComboBox::ComboBox()
|
|||||||
// TODO this separation should be from the Theme*
|
// TODO this separation should be from the Theme*
|
||||||
this->child_spacing = 0;
|
this->child_spacing = 0;
|
||||||
|
|
||||||
jwidget_focusrest(this, true);
|
this->setFocusStop(true);
|
||||||
jwidget_add_hook(m_entry, JI_WIDGET, combobox_entry_msg_proc, NULL);
|
jwidget_add_hook(m_entry, JI_WIDGET, combobox_entry_msg_proc, NULL);
|
||||||
|
|
||||||
jwidget_expansive(m_entry, true);
|
m_entry->setExpansive(true);
|
||||||
|
|
||||||
// When the "m_button" is clicked ("Click" signal) call onButtonClick() method
|
// When the "m_button" is clicked ("Click" signal) call onButtonClick() method
|
||||||
m_button->Click.connect(&ComboBox::onButtonClick, this);
|
m_button->Click.connect(&ComboBox::onButtonClick, this);
|
||||||
|
@ -56,7 +56,7 @@ Entry::Entry(size_t maxsize, const char *format, ...)
|
|||||||
/* widget->align = JI_LEFT | JI_MIDDLE; */
|
/* widget->align = JI_LEFT | JI_MIDDLE; */
|
||||||
setText(buf);
|
setText(buf);
|
||||||
|
|
||||||
jwidget_focusrest(this, true);
|
this->setFocusStop(true);
|
||||||
initTheme();
|
initTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,7 +482,7 @@ void Frame::onPreferredSize(PreferredSizeEvent& ev)
|
|||||||
JI_LIST_FOR_EACH(this->children, link) {
|
JI_LIST_FOR_EACH(this->children, link) {
|
||||||
child = (JWidget)link->data;
|
child = (JWidget)link->data;
|
||||||
|
|
||||||
if (!jwidget_is_decorative(child)) {
|
if (!child->isDecorative()) {
|
||||||
reqSize = child->getPreferredSize();
|
reqSize = child->getPreferredSize();
|
||||||
|
|
||||||
maxSize.w = MAX(maxSize.w, reqSize.w);
|
maxSize.w = MAX(maxSize.w, reqSize.w);
|
||||||
@ -531,7 +531,7 @@ void Frame::window_set_position(JRect rect)
|
|||||||
JI_LIST_FOR_EACH(this->children, link) {
|
JI_LIST_FOR_EACH(this->children, link) {
|
||||||
child = (JWidget)link->data;
|
child = (JWidget)link->data;
|
||||||
|
|
||||||
if (jwidget_is_decorative(child))
|
if (child->isDecorative())
|
||||||
child->getTheme()->map_decorative_widget(child);
|
child->getTheme()->map_decorative_widget(child);
|
||||||
else
|
else
|
||||||
jwidget_set_rect(child, cpos);
|
jwidget_set_rect(child, cpos);
|
||||||
|
@ -34,7 +34,7 @@ JWidget jlistbox_new()
|
|||||||
JWidget widget = new Widget(JI_LISTBOX);
|
JWidget widget = new Widget(JI_LISTBOX);
|
||||||
|
|
||||||
jwidget_add_hook(widget, JI_LISTBOX, listbox_msg_proc, NULL);
|
jwidget_add_hook(widget, JI_LISTBOX, listbox_msg_proc, NULL);
|
||||||
jwidget_focusrest(widget, true);
|
widget->setFocusStop(true);
|
||||||
widget->initTheme();
|
widget->initTheme();
|
||||||
|
|
||||||
return widget;
|
return widget;
|
||||||
|
@ -23,10 +23,10 @@
|
|||||||
#define TOPWND(manager) reinterpret_cast<Frame*>(jlist_first_data((manager)->children))
|
#define TOPWND(manager) reinterpret_cast<Frame*>(jlist_first_data((manager)->children))
|
||||||
|
|
||||||
#define ACCEPT_FOCUS(widget) \
|
#define ACCEPT_FOCUS(widget) \
|
||||||
(((widget)->flags & (JI_FOCUSREST | \
|
(((widget)->flags & (JI_FOCUSSTOP | \
|
||||||
JI_DISABLED | \
|
JI_DISABLED | \
|
||||||
JI_HIDDEN | \
|
JI_HIDDEN | \
|
||||||
JI_DECORATIVE)) == JI_FOCUSREST)
|
JI_DECORATIVE)) == JI_FOCUSSTOP)
|
||||||
|
|
||||||
#define DOUBLE_CLICK_TIMEOUT_MSECS 400
|
#define DOUBLE_CLICK_TIMEOUT_MSECS 400
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ static void manager_pump_queue(JWidget widget);
|
|||||||
/* auxiliary */
|
/* auxiliary */
|
||||||
static void generate_setcursor_message();
|
static void generate_setcursor_message();
|
||||||
static void remove_msgs_for(JWidget widget, Message* msg);
|
static void remove_msgs_for(JWidget widget, Message* msg);
|
||||||
static int some_parent_is_focusrest(JWidget widget);
|
static bool some_parent_is_focusstop(JWidget widget);
|
||||||
static JWidget find_magnetic_widget(JWidget widget);
|
static JWidget find_magnetic_widget(JWidget widget);
|
||||||
static Message* new_mouse_msg(int type, JWidget destination);
|
static Message* new_mouse_msg(int type, JWidget destination);
|
||||||
static void broadcast_key_msg(JWidget manager, Message* msg);
|
static void broadcast_key_msg(JWidget manager, Message* msg);
|
||||||
@ -772,7 +772,7 @@ void jmanager_set_focus(JWidget widget)
|
|||||||
|| (!(widget->flags & JI_DISABLED)
|
|| (!(widget->flags & JI_DISABLED)
|
||||||
&& !(widget->flags & JI_HIDDEN)
|
&& !(widget->flags & JI_HIDDEN)
|
||||||
&& !(widget->flags & JI_DECORATIVE)
|
&& !(widget->flags & JI_DECORATIVE)
|
||||||
&& some_parent_is_focusrest(widget)))) {
|
&& some_parent_is_focusstop(widget)))) {
|
||||||
JList widget_parents = NULL;
|
JList widget_parents = NULL;
|
||||||
JWidget common_parent = NULL;
|
JWidget common_parent = NULL;
|
||||||
JLink link, link2;
|
JLink link, link2;
|
||||||
@ -826,7 +826,7 @@ void jmanager_set_focus(JWidget widget)
|
|||||||
for (; link != widget_parents->end; link=link->next) {
|
for (; link != widget_parents->end; link=link->next) {
|
||||||
JWidget w = (JWidget)link->data;
|
JWidget w = (JWidget)link->data;
|
||||||
|
|
||||||
if (w->flags & JI_FOCUSREST) {
|
if (w->flags & JI_FOCUSSTOP) {
|
||||||
w->flags |= JI_HASFOCUS;
|
w->flags |= JI_HASFOCUS;
|
||||||
|
|
||||||
jmessage_add_dest(msg, w);
|
jmessage_add_dest(msg, w);
|
||||||
@ -1417,13 +1417,13 @@ static void remove_msgs_for(JWidget widget, Message* msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int some_parent_is_focusrest(JWidget widget)
|
static bool some_parent_is_focusstop(JWidget widget)
|
||||||
{
|
{
|
||||||
if (jwidget_is_focusrest(widget))
|
if (widget->isFocusStop())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (widget->parent)
|
if (widget->parent)
|
||||||
return some_parent_is_focusrest(widget->parent);
|
return some_parent_is_focusstop(widget->parent);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1439,7 +1439,7 @@ static JWidget find_magnetic_widget(JWidget widget)
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jwidget_is_magnetic(widget))
|
if (widget->isFocusMagnet())
|
||||||
return widget;
|
return widget;
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -104,7 +104,7 @@ MenuBox::MenuBox(int type)
|
|||||||
: Widget(type)
|
: Widget(type)
|
||||||
, m_base(NULL)
|
, m_base(NULL)
|
||||||
{
|
{
|
||||||
jwidget_focusrest(this, true);
|
this->setFocusStop(true);
|
||||||
initTheme();
|
initTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ void Menu::showPopup(int x, int y)
|
|||||||
|
|
||||||
// Set the focus to the new menubox
|
// Set the focus to the new menubox
|
||||||
jmanager_set_focus(menubox);
|
jmanager_set_focus(menubox);
|
||||||
jwidget_magnetic(menubox, true);
|
menubox->setFocusMagnet(true);
|
||||||
|
|
||||||
// Open the window
|
// Open the window
|
||||||
window->open_window_fg();
|
window->open_window_fg();
|
||||||
@ -785,7 +785,7 @@ bool MenuItem::onProcessMessage(Message* msg)
|
|||||||
jrect_free(pos);
|
jrect_free(pos);
|
||||||
|
|
||||||
// Set the focus to the new menubox
|
// Set the focus to the new menubox
|
||||||
jwidget_magnetic(menubox, true);
|
menubox->setFocusMagnet(true);
|
||||||
|
|
||||||
// Setup the highlight of the new menubox
|
// Setup the highlight of the new menubox
|
||||||
if (select_first) {
|
if (select_first) {
|
||||||
|
@ -29,7 +29,7 @@ Slider::Slider(int min, int max, int value)
|
|||||||
m_max = max;
|
m_max = max;
|
||||||
m_value = MID(min, value, max);
|
m_value = MID(min, value, max);
|
||||||
|
|
||||||
jwidget_focusrest(this, true);
|
this->setFocusStop(true);
|
||||||
initTheme();
|
initTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ JWidget jtextbox_new(const char *text, int align)
|
|||||||
Widget* widget = new Widget(JI_TEXTBOX);
|
Widget* widget = new Widget(JI_TEXTBOX);
|
||||||
|
|
||||||
jwidget_add_hook(widget, JI_TEXTBOX, textbox_msg_proc, NULL);
|
jwidget_add_hook(widget, JI_TEXTBOX, textbox_msg_proc, NULL);
|
||||||
jwidget_focusrest(widget, true);
|
widget->setFocusStop(true);
|
||||||
widget->setAlign(align);
|
widget->setAlign(align);
|
||||||
widget->setText(text);
|
widget->setText(text);
|
||||||
widget->initTheme();
|
widget->initTheme();
|
||||||
|
@ -28,7 +28,7 @@ View::View()
|
|||||||
{
|
{
|
||||||
m_hasBars = true;
|
m_hasBars = true;
|
||||||
|
|
||||||
jwidget_focusrest(this, true);
|
this->setFocusStop(true);
|
||||||
addChild(&m_viewport);
|
addChild(&m_viewport);
|
||||||
setScrollableSize(Size(0, 0));
|
setScrollableSize(Size(0, 0));
|
||||||
|
|
||||||
|
@ -311,79 +311,9 @@ void Widget::setTheme(Theme* theme)
|
|||||||
setFont(m_theme ? m_theme->default_font: NULL);
|
setFont(m_theme ? m_theme->default_font: NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************/
|
// ===============================================================
|
||||||
/* behavior properties */
|
// COMMON PROPERTIES
|
||||||
|
// ===============================================================
|
||||||
void jwidget_magnetic(JWidget widget, bool state)
|
|
||||||
{
|
|
||||||
ASSERT_VALID_WIDGET(widget);
|
|
||||||
|
|
||||||
if (state)
|
|
||||||
widget->flags |= JI_MAGNETIC;
|
|
||||||
else
|
|
||||||
widget->flags &= ~JI_MAGNETIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
void jwidget_expansive(JWidget widget, bool state)
|
|
||||||
{
|
|
||||||
ASSERT_VALID_WIDGET(widget);
|
|
||||||
|
|
||||||
if (state)
|
|
||||||
widget->flags |= JI_EXPANSIVE;
|
|
||||||
else
|
|
||||||
widget->flags &= ~JI_EXPANSIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void jwidget_decorative(JWidget widget, bool state)
|
|
||||||
{
|
|
||||||
ASSERT_VALID_WIDGET(widget);
|
|
||||||
|
|
||||||
if (state)
|
|
||||||
widget->flags |= JI_DECORATIVE;
|
|
||||||
else
|
|
||||||
widget->flags &= ~JI_DECORATIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void jwidget_focusrest(JWidget widget, bool state)
|
|
||||||
{
|
|
||||||
ASSERT_VALID_WIDGET(widget);
|
|
||||||
|
|
||||||
if (state)
|
|
||||||
widget->flags |= JI_FOCUSREST;
|
|
||||||
else
|
|
||||||
widget->flags &= ~JI_FOCUSREST;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool jwidget_is_magnetic(JWidget widget)
|
|
||||||
{
|
|
||||||
ASSERT_VALID_WIDGET(widget);
|
|
||||||
|
|
||||||
return (widget->flags & JI_MAGNETIC) ? true: false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool jwidget_is_expansive(JWidget widget)
|
|
||||||
{
|
|
||||||
ASSERT_VALID_WIDGET(widget);
|
|
||||||
|
|
||||||
return (widget->flags & JI_EXPANSIVE) ? true: false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool jwidget_is_decorative(JWidget widget)
|
|
||||||
{
|
|
||||||
ASSERT_VALID_WIDGET(widget);
|
|
||||||
|
|
||||||
return (widget->flags & JI_DECORATIVE) ? true: false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool jwidget_is_focusrest(JWidget widget)
|
|
||||||
{
|
|
||||||
ASSERT_VALID_WIDGET(widget);
|
|
||||||
|
|
||||||
return (widget->flags & JI_FOCUSREST) ? true: false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************/
|
|
||||||
/* status properties */
|
|
||||||
|
|
||||||
void Widget::setVisible(bool state)
|
void Widget::setVisible(bool state)
|
||||||
{
|
{
|
||||||
@ -447,6 +377,38 @@ void Widget::setSelected(bool state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::setExpansive(bool state)
|
||||||
|
{
|
||||||
|
if (state)
|
||||||
|
this->flags |= JI_EXPANSIVE;
|
||||||
|
else
|
||||||
|
this->flags &= ~JI_EXPANSIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::setDecorative(bool state)
|
||||||
|
{
|
||||||
|
if (state)
|
||||||
|
this->flags |= JI_DECORATIVE;
|
||||||
|
else
|
||||||
|
this->flags &= ~JI_DECORATIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::setFocusStop(bool state)
|
||||||
|
{
|
||||||
|
if (state)
|
||||||
|
this->flags |= JI_FOCUSSTOP;
|
||||||
|
else
|
||||||
|
this->flags &= ~JI_FOCUSSTOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::setFocusMagnet(bool state)
|
||||||
|
{
|
||||||
|
if (state)
|
||||||
|
this->flags |= JI_FOCUSMAGNET;
|
||||||
|
else
|
||||||
|
this->flags &= ~JI_FOCUSMAGNET;
|
||||||
|
}
|
||||||
|
|
||||||
bool Widget::isVisible() const
|
bool Widget::isVisible() const
|
||||||
{
|
{
|
||||||
const Widget* widget = this;
|
const Widget* widget = this;
|
||||||
@ -480,6 +442,26 @@ bool Widget::isSelected() const
|
|||||||
return (this->flags & JI_SELECTED) ? true: false;
|
return (this->flags & JI_SELECTED) ? true: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Widget::isExpansive() const
|
||||||
|
{
|
||||||
|
return (this->flags & JI_EXPANSIVE) ? true: false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Widget::isDecorative() const
|
||||||
|
{
|
||||||
|
return (this->flags & JI_DECORATIVE) ? true: false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Widget::isFocusStop() const
|
||||||
|
{
|
||||||
|
return (this->flags & JI_FOCUSSTOP) ? true: false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Widget::isFocusMagnet() const
|
||||||
|
{
|
||||||
|
return (this->flags & JI_FOCUSMAGNET) ? true: false;
|
||||||
|
}
|
||||||
|
|
||||||
// ===============================================================
|
// ===============================================================
|
||||||
// PARENTS & CHILDREN
|
// PARENTS & CHILDREN
|
||||||
// ===============================================================
|
// ===============================================================
|
||||||
|
@ -44,18 +44,6 @@ void jwidget_add_hook(JWidget widget, int type,
|
|||||||
JHook jwidget_get_hook(JWidget widget, int type);
|
JHook jwidget_get_hook(JWidget widget, int type);
|
||||||
void *jwidget_get_data(JWidget widget, int type);
|
void *jwidget_get_data(JWidget widget, int type);
|
||||||
|
|
||||||
/* behavior properties */
|
|
||||||
|
|
||||||
void jwidget_magnetic(JWidget widget, bool state);
|
|
||||||
void jwidget_expansive(JWidget widget, bool state);
|
|
||||||
void jwidget_decorative(JWidget widget, bool state);
|
|
||||||
void jwidget_focusrest(JWidget widget, bool state);
|
|
||||||
|
|
||||||
bool jwidget_is_magnetic(JWidget widget);
|
|
||||||
bool jwidget_is_expansive(JWidget widget);
|
|
||||||
bool jwidget_is_decorative(JWidget widget);
|
|
||||||
bool jwidget_is_focusrest(JWidget widget);
|
|
||||||
|
|
||||||
/* position and geometry */
|
/* position and geometry */
|
||||||
|
|
||||||
JRect jwidget_get_rect(JWidget widget);
|
JRect jwidget_get_rect(JWidget widget);
|
||||||
@ -169,15 +157,39 @@ public:
|
|||||||
// COMMON PROPERTIES
|
// COMMON PROPERTIES
|
||||||
// ===============================================================
|
// ===============================================================
|
||||||
|
|
||||||
|
// True if this widget and all its ancestors are visible.
|
||||||
bool isVisible() const;
|
bool isVisible() const;
|
||||||
void setVisible(bool state);
|
void setVisible(bool state);
|
||||||
|
|
||||||
|
// True if this widget can receive user input (is not disabled).
|
||||||
bool isEnabled() const;
|
bool isEnabled() const;
|
||||||
void setEnabled(bool state);
|
void setEnabled(bool state);
|
||||||
|
|
||||||
|
// True if this widget is selected (pushed in case of a button, or
|
||||||
|
// checked in the case of a check-box).
|
||||||
bool isSelected() const;
|
bool isSelected() const;
|
||||||
void setSelected(bool state);
|
void setSelected(bool state);
|
||||||
|
|
||||||
|
// True if this widget wants more space when it's inside a Box
|
||||||
|
// parent.
|
||||||
|
bool isExpansive() const;
|
||||||
|
void setExpansive(bool state);
|
||||||
|
|
||||||
|
// True if this is a decorative widget created by the current
|
||||||
|
// theme. Decorative widgets are arranged by the theme instead that
|
||||||
|
// the parent's widget.
|
||||||
|
bool isDecorative() const;
|
||||||
|
void setDecorative(bool state);
|
||||||
|
|
||||||
|
// True if this widget can receive the keyboard focus.
|
||||||
|
bool isFocusStop() const;
|
||||||
|
void setFocusStop(bool state);
|
||||||
|
|
||||||
|
// True if this widget wants the focus by default when it's shown by
|
||||||
|
// first time (e.g. when its parent window is opened).
|
||||||
|
void setFocusMagnet(bool state);
|
||||||
|
bool isFocusMagnet() const;
|
||||||
|
|
||||||
// ===============================================================
|
// ===============================================================
|
||||||
// LOOK & FEEL
|
// LOOK & FEEL
|
||||||
// ===============================================================
|
// ===============================================================
|
||||||
|
@ -425,8 +425,8 @@ void split_editor(Editor* editor, int align)
|
|||||||
new_editor->setZoom(editor->getZoom());
|
new_editor->setZoom(editor->getZoom());
|
||||||
|
|
||||||
// Expansive widgets.
|
// Expansive widgets.
|
||||||
jwidget_expansive(new_panel, true);
|
new_panel->setExpansive(true);
|
||||||
jwidget_expansive(new_view, true);
|
new_view->setExpansive(true);
|
||||||
|
|
||||||
// Append both views to the "new_panel".
|
// Append both views to the "new_panel".
|
||||||
new_panel->addChild(view);
|
new_panel->addChild(view);
|
||||||
@ -613,7 +613,7 @@ static void create_mini_editor_frame()
|
|||||||
|
|
||||||
// Create the new for the mini editor
|
// Create the new for the mini editor
|
||||||
View* newView = new EditorView(EditorView::AlwaysSelected);
|
View* newView = new EditorView(EditorView::AlwaysSelected);
|
||||||
jwidget_expansive(newView, true);
|
newView->setExpansive(true);
|
||||||
|
|
||||||
// Create mini editor
|
// Create mini editor
|
||||||
mini_editor = new MiniEditor();
|
mini_editor = new MiniEditor();
|
||||||
|
@ -654,7 +654,7 @@ void SkinTheme::init_widget(JWidget widget)
|
|||||||
setup_bevels(button, 0, 0, 0, 0);
|
setup_bevels(button, 0, 0, 0, 0);
|
||||||
jwidget_add_hook(button, JI_WIDGET,
|
jwidget_add_hook(button, JI_WIDGET,
|
||||||
&SkinTheme::theme_frame_button_msg_proc, NULL);
|
&SkinTheme::theme_frame_button_msg_proc, NULL);
|
||||||
jwidget_decorative(button, true);
|
button->setDecorative(true);
|
||||||
widget->addChild(button);
|
widget->addChild(button);
|
||||||
button->setName("theme_close_button");
|
button->setName("theme_close_button");
|
||||||
button->Click.connect(Bind<void>(&Frame::closeWindow, (Frame*)widget, button));
|
button->Click.connect(Bind<void>(&Frame::closeWindow, (Frame*)widget, button));
|
||||||
@ -1652,7 +1652,7 @@ void SkinTheme::paintTooltip(PaintEvent& ev)
|
|||||||
int SkinTheme::get_bg_color(JWidget widget)
|
int SkinTheme::get_bg_color(JWidget widget)
|
||||||
{
|
{
|
||||||
int c = jwidget_get_bg_color(widget);
|
int c = jwidget_get_bg_color(widget);
|
||||||
int decorative = jwidget_is_decorative(widget);
|
bool decorative = widget->isDecorative();
|
||||||
|
|
||||||
return c >= 0 ? c: (decorative ? COLOR_SELECTED:
|
return c >= 0 ? c: (decorative ? COLOR_SELECTED:
|
||||||
COLOR_FACE);
|
COLOR_FACE);
|
||||||
|
@ -98,7 +98,7 @@ ColorBar::ColorBar(int align)
|
|||||||
|
|
||||||
jwidget_set_min_size(&m_scrollableView, w, 0);
|
jwidget_set_min_size(&m_scrollableView, w, 0);
|
||||||
|
|
||||||
jwidget_expansive(&m_scrollableView, true);
|
m_scrollableView.setExpansive(true);
|
||||||
|
|
||||||
addChild(&m_paletteButton);
|
addChild(&m_paletteButton);
|
||||||
addChild(&m_scrollableView);
|
addChild(&m_scrollableView);
|
||||||
|
@ -49,7 +49,7 @@ ColorButton::ColorButton(const Color& color, PixelFormat pixelFormat)
|
|||||||
, m_pixelFormat(pixelFormat)
|
, m_pixelFormat(pixelFormat)
|
||||||
, m_frame(NULL)
|
, m_frame(NULL)
|
||||||
{
|
{
|
||||||
jwidget_focusrest(this, true);
|
this->setFocusStop(true);
|
||||||
|
|
||||||
setFont(static_cast<SkinTheme*>(getTheme())->getMiniFont());
|
setFont(static_cast<SkinTheme*>(getTheme())->getMiniFont());
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ ColorSelector::ColorSelector()
|
|||||||
m_colorPalette.setBoxSize(6*jguiscale());
|
m_colorPalette.setBoxSize(6*jguiscale());
|
||||||
m_colorPaletteContainer.attachToView(&m_colorPalette);
|
m_colorPaletteContainer.attachToView(&m_colorPalette);
|
||||||
|
|
||||||
jwidget_expansive(&m_colorPaletteContainer, true);
|
m_colorPaletteContainer.setExpansive(true);
|
||||||
|
|
||||||
setup_mini_look(&m_indexButton);
|
setup_mini_look(&m_indexButton);
|
||||||
setup_mini_look(&m_rgbButton);
|
setup_mini_look(&m_rgbButton);
|
||||||
|
@ -147,7 +147,7 @@ Editor::Editor()
|
|||||||
m_mask_timer_id = jmanager_add_timer(this, 100);
|
m_mask_timer_id = jmanager_add_timer(this, 100);
|
||||||
m_offset_count = 0;
|
m_offset_count = 0;
|
||||||
|
|
||||||
jwidget_focusrest(this, true);
|
this->setFocusStop(true);
|
||||||
|
|
||||||
m_currentToolChangeSlot =
|
m_currentToolChangeSlot =
|
||||||
App::instance()->CurrentToolChange.connect(&Editor::onCurrentToolChange, this);
|
App::instance()->CurrentToolChange.connect(&Editor::onCurrentToolChange, this);
|
||||||
|
@ -107,7 +107,7 @@ JWidget fileview_new(IFileItem* start_folder, const base::string& exts)
|
|||||||
|
|
||||||
jwidget_add_hook(widget, fileview_type(),
|
jwidget_add_hook(widget, fileview_type(),
|
||||||
fileview_msg_proc, fileview);
|
fileview_msg_proc, fileview);
|
||||||
jwidget_focusrest(widget, true);
|
widget->setFocusStop(true);
|
||||||
|
|
||||||
fileview->current_folder = start_folder;
|
fileview->current_folder = start_folder;
|
||||||
fileview->req_valid = false;
|
fileview->req_valid = false;
|
||||||
|
@ -58,7 +58,7 @@ PaletteView::PaletteView(bool editable)
|
|||||||
m_columns = 16;
|
m_columns = 16;
|
||||||
m_boxsize = 6;
|
m_boxsize = 6;
|
||||||
|
|
||||||
jwidget_focusrest(this, true);
|
this->setFocusStop(true);
|
||||||
|
|
||||||
this->border_width.l = this->border_width.r = 1 * jguiscale();
|
this->border_width.l = this->border_width.r = 1 * jguiscale();
|
||||||
this->border_width.t = this->border_width.b = 1 * jguiscale();
|
this->border_width.t = this->border_width.b = 1 * jguiscale();
|
||||||
|
@ -125,7 +125,7 @@ StatusBar::StatusBar()
|
|||||||
set_gfxicon_to_button((name), icon, icon##_SELECTED, icon##_DISABLED, JI_CENTER | JI_MIDDLE); \
|
set_gfxicon_to_button((name), icon, icon##_SELECTED, icon##_DISABLED, JI_CENTER | JI_MIDDLE); \
|
||||||
}
|
}
|
||||||
|
|
||||||
jwidget_focusrest(this, true);
|
this->setFocusStop(true);
|
||||||
|
|
||||||
m_timeout = 0;
|
m_timeout = 0;
|
||||||
m_state = SHOW_TEXT;
|
m_state = SHOW_TEXT;
|
||||||
@ -164,7 +164,7 @@ StatusBar::StatusBar()
|
|||||||
jwidget_set_border(box1, 2*jguiscale(), 1*jguiscale(), 2*jguiscale(), 2*jguiscale());
|
jwidget_set_border(box1, 2*jguiscale(), 1*jguiscale(), 2*jguiscale(), 2*jguiscale());
|
||||||
jwidget_noborders(box2);
|
jwidget_noborders(box2);
|
||||||
jwidget_noborders(box3);
|
jwidget_noborders(box3);
|
||||||
jwidget_expansive(box3, true);
|
box3->setExpansive(true);
|
||||||
|
|
||||||
box4->addChild(m_currentFrame);
|
box4->addChild(m_currentFrame);
|
||||||
box4->addChild(m_newFrame);
|
box4->addChild(m_newFrame);
|
||||||
@ -190,7 +190,7 @@ StatusBar::StatusBar()
|
|||||||
|
|
||||||
jwidget_set_border(box1, 2*jguiscale(), 1*jguiscale(), 2*jguiscale(), 2*jguiscale());
|
jwidget_set_border(box1, 2*jguiscale(), 1*jguiscale(), 2*jguiscale(), 2*jguiscale());
|
||||||
jwidget_noborders(box2);
|
jwidget_noborders(box2);
|
||||||
jwidget_expansive(box2, true);
|
box2->setExpansive(true);
|
||||||
|
|
||||||
m_linkLabel = new LinkLabel((std::string(WEBSITE) + "donate/").c_str(), "Support This Project");
|
m_linkLabel = new LinkLabel((std::string(WEBSITE) + "donate/").c_str(), "Support This Project");
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ StatusBar::StatusBar()
|
|||||||
// Construct move-pixels box
|
// Construct move-pixels box
|
||||||
{
|
{
|
||||||
Box* filler = new Box(JI_HORIZONTAL);
|
Box* filler = new Box(JI_HORIZONTAL);
|
||||||
jwidget_expansive(filler, true);
|
filler->setExpansive(true);
|
||||||
|
|
||||||
m_movePixelsBox = new Box(JI_HORIZONTAL);
|
m_movePixelsBox = new Box(JI_HORIZONTAL);
|
||||||
m_transparentLabel = new Label("Transparent Color:");
|
m_transparentLabel = new Label("Transparent Color:");
|
||||||
|
@ -66,8 +66,8 @@ Tabs::Tabs(TabsDelegate* delegate)
|
|||||||
setup_bevels(m_button_left, 2, 0, 2, 0);
|
setup_bevels(m_button_left, 2, 0, 2, 0);
|
||||||
setup_bevels(m_button_right, 0, 2, 0, 2);
|
setup_bevels(m_button_right, 0, 2, 0, 2);
|
||||||
|
|
||||||
jwidget_focusrest(m_button_left, false);
|
m_button_left->setFocusStop(false);
|
||||||
jwidget_focusrest(m_button_right, false);
|
m_button_right->setFocusStop(false);
|
||||||
|
|
||||||
set_gfxicon_to_button(m_button_left,
|
set_gfxicon_to_button(m_button_left,
|
||||||
PART_COMBOBOX_ARROW_LEFT,
|
PART_COMBOBOX_ARROW_LEFT,
|
||||||
|
@ -363,10 +363,10 @@ static Widget* convert_xmlelement_to_widget(TiXmlElement* elem, Widget* root)
|
|||||||
widget->setEnabled(false);
|
widget->setEnabled(false);
|
||||||
|
|
||||||
if (expansive)
|
if (expansive)
|
||||||
jwidget_expansive(widget, true);
|
widget->setExpansive(true);
|
||||||
|
|
||||||
if (magnetic)
|
if (magnetic)
|
||||||
jwidget_magnetic(widget, true);
|
widget->setFocusMagnet(true);
|
||||||
|
|
||||||
if (noborders)
|
if (noborders)
|
||||||
jwidget_noborders(widget);
|
jwidget_noborders(widget);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user