mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-28 18:32:50 +00:00
Refactor jmanager to gui::Manager class.
This commit is contained in:
parent
1f787e0dcb
commit
7d0bed8341
14
src/app.cpp
14
src/app.cpp
@ -178,7 +178,7 @@ int App::run()
|
|||||||
|
|
||||||
// Setup the GUI screen
|
// Setup the GUI screen
|
||||||
jmouse_set_cursor(JI_CURSOR_NORMAL);
|
jmouse_set_cursor(JI_CURSOR_NORMAL);
|
||||||
jmanager_refresh_screen();
|
gui::Manager::getDefault()->invalidate();
|
||||||
|
|
||||||
// Load main window
|
// Load main window
|
||||||
top_window = static_cast<Frame*>(load_widget("main_window.xml", "main_window"));
|
top_window = static_cast<Frame*>(load_widget("main_window.xml", "main_window"));
|
||||||
@ -230,14 +230,14 @@ int App::run()
|
|||||||
app_rebuild_documents_tabs();
|
app_rebuild_documents_tabs();
|
||||||
app_rebuild_recent_list();
|
app_rebuild_recent_list();
|
||||||
|
|
||||||
/* set current editor */
|
// Set current editor
|
||||||
set_current_editor(editor);
|
set_current_editor(editor);
|
||||||
|
|
||||||
/* open the window */
|
// Open the window
|
||||||
top_window->open_window();
|
top_window->open_window();
|
||||||
|
|
||||||
/* refresh the screen */
|
// Redraw the whole screen.
|
||||||
jmanager_refresh_screen();
|
gui::Manager::getDefault()->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set background mode for non-GUI modes */
|
/* set background mode for non-GUI modes */
|
||||||
@ -386,8 +386,8 @@ void app_refresh_screen(const Document* document)
|
|||||||
else
|
else
|
||||||
set_current_palette(NULL, false);
|
set_current_palette(NULL, false);
|
||||||
|
|
||||||
// redraw the screen
|
// Invalidate the whole screen.
|
||||||
jmanager_refresh_screen();
|
gui::Manager::getDefault()->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +67,7 @@ void EyedropperCommand::onLoadParams(Params* params)
|
|||||||
|
|
||||||
void EyedropperCommand::onExecute(Context* context)
|
void EyedropperCommand::onExecute(Context* context)
|
||||||
{
|
{
|
||||||
JWidget widget = jmanager_get_mouse();
|
Widget* widget = gui::Manager::getDefault()->getMouse();
|
||||||
if (!widget || widget->type != editor_type())
|
if (!widget || widget->type != editor_type())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -768,7 +768,7 @@ void PaletteEntryEditor::setNewPalette(Palette* palette, const char* operationNa
|
|||||||
updateCurrentSpritePalette(operationName);
|
updateCurrentSpritePalette(operationName);
|
||||||
|
|
||||||
// Redraw the entire screen
|
// Redraw the entire screen
|
||||||
jmanager_refresh_screen();
|
gui::Manager::getDefault()->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaletteEntryEditor::updateCurrentSpritePalette(const char* operationName)
|
void PaletteEntryEditor::updateCurrentSpritePalette(const char* operationName)
|
||||||
|
@ -145,7 +145,7 @@ void PlayAnimationCommand::onExecute(Context* context)
|
|||||||
/* refresh all */
|
/* refresh all */
|
||||||
newpal = sprite->getPalette(sprite->getCurrentFrame());
|
newpal = sprite->getPalette(sprite->getCurrentFrame());
|
||||||
set_current_palette(newpal, true);
|
set_current_palette(newpal, true);
|
||||||
jmanager_refresh_screen();
|
gui::Manager::getDefault()->invalidate();
|
||||||
gui_feedback();
|
gui_feedback();
|
||||||
|
|
||||||
while (mouse_b)
|
while (mouse_b)
|
||||||
|
@ -91,7 +91,7 @@ void PreviewCommand::onExecute(Context* context)
|
|||||||
TiledMode tiled = context->getSettings()->getTiledMode();
|
TiledMode tiled = context->getSettings()->getTiledMode();
|
||||||
|
|
||||||
// Free mouse
|
// Free mouse
|
||||||
jmanager_free_mouse();
|
editor->getManager()->freeMouse();
|
||||||
|
|
||||||
// Clear extras (e.g. pen preview)
|
// Clear extras (e.g. pen preview)
|
||||||
document->destroyExtraCel();
|
document->destroyExtraCel();
|
||||||
@ -240,7 +240,7 @@ void PreviewCommand::onExecute(Context* context)
|
|||||||
jmouse_set_position(old_mouse_x, old_mouse_y);
|
jmouse_set_position(old_mouse_x, old_mouse_y);
|
||||||
jmouse_set_cursor(JI_CURSOR_NORMAL);
|
jmouse_set_cursor(JI_CURSOR_NORMAL);
|
||||||
|
|
||||||
jmanager_refresh_screen();
|
gui::Manager::getDefault()->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -119,7 +119,7 @@ void Console::printf(const char *format, ...)
|
|||||||
// Open the window
|
// Open the window
|
||||||
if (!wid_console->isVisible()) {
|
if (!wid_console->isVisible()) {
|
||||||
wid_console->open_window();
|
wid_console->open_window();
|
||||||
jmanager_refresh_screen();
|
gui::Manager::getDefault()->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the textbox */
|
/* update the textbox */
|
||||||
|
@ -584,7 +584,7 @@ static bool fileview_msg_proc(Widget* widget, Message* msg)
|
|||||||
IFileItem* fileitem = fileview_get_selected(widget);
|
IFileItem* fileitem = fileview_get_selected(widget);
|
||||||
|
|
||||||
if (!fileitem->isFolder()) {
|
if (!fileitem->isFolder()) {
|
||||||
Frame* window = static_cast<Frame*>(widget->getRoot());
|
Frame* window = widget->getRoot();
|
||||||
Widget* entry = window->findChild("filename");
|
Widget* entry = window->findChild("filename");
|
||||||
base::string filename = base::get_file_name(fileitem->getFileName());
|
base::string filename = base::get_file_name(fileitem->getFileName());
|
||||||
|
|
||||||
@ -601,7 +601,7 @@ static bool fileview_msg_proc(Widget* widget, Message* msg)
|
|||||||
|
|
||||||
/* when the current folder change */
|
/* when the current folder change */
|
||||||
case SIGNAL_FILEVIEW_CURRENT_FOLDER_CHANGED: {
|
case SIGNAL_FILEVIEW_CURRENT_FOLDER_CHANGED: {
|
||||||
Frame* window = static_cast<Frame*>(widget->getRoot());
|
Frame* window = widget->getRoot();
|
||||||
|
|
||||||
if (!navigation_locked)
|
if (!navigation_locked)
|
||||||
add_in_navigation_history(fileview_get_current_folder(widget));
|
add_in_navigation_history(fileview_get_current_folder(widget));
|
||||||
@ -645,7 +645,7 @@ static bool location_msg_proc(Widget* widget, Message* msg)
|
|||||||
|
|
||||||
// Refocus the 'fileview' (the focus in that widget is more
|
// Refocus the 'fileview' (the focus in that widget is more
|
||||||
// useful for the user)
|
// useful for the user)
|
||||||
jmanager_set_focus(fileview);
|
widget->getManager()->setFocus(fileview);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -667,7 +667,7 @@ static bool filetype_msg_proc(Widget* widget, Message* msg)
|
|||||||
// change the file-extension in the 'filename' entry widget
|
// change the file-extension in the 'filename' entry widget
|
||||||
case JI_SIGNAL_COMBOBOX_SELECT: {
|
case JI_SIGNAL_COMBOBOX_SELECT: {
|
||||||
std::string ext = combobox->getItemText(combobox->getSelectedItem());
|
std::string ext = combobox->getItemText(combobox->getSelectedItem());
|
||||||
Frame* window = static_cast<Frame*>(combobox->getRoot());
|
Frame* window = combobox->getRoot();
|
||||||
Entry* entry = window->findChildT<Entry>("filename");
|
Entry* entry = window->findChildT<Entry>("filename");
|
||||||
char buf[MAX_PATH];
|
char buf[MAX_PATH];
|
||||||
char* p;
|
char* p;
|
||||||
|
@ -75,7 +75,7 @@ void check_for_dropped_files()
|
|||||||
|
|
||||||
// If the main window is not the current foreground one. We discard
|
// If the main window is not the current foreground one. We discard
|
||||||
// the drop-files event.
|
// the drop-files event.
|
||||||
if (jmanager_get_foreground_window() != app_get_top_window())
|
if (gui::Manager::getDefault()->getForegroundFrame() != app_get_top_window())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ScopedLock lock(*dropped_files_mutex);
|
ScopedLock lock(*dropped_files_mutex);
|
||||||
|
@ -78,7 +78,7 @@ bool GfxMode::setGfxMode() const
|
|||||||
// Redraw top window
|
// Redraw top window
|
||||||
if (app_get_top_window()) {
|
if (app_get_top_window()) {
|
||||||
app_get_top_window()->remap_window();
|
app_get_top_window()->remap_window();
|
||||||
jmanager_refresh_screen();
|
gui::Manager::getDefault()->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -113,11 +113,11 @@ bool ButtonBase::onProcessMessage(Message* msg)
|
|||||||
else if (this->isFocusMagnet() &&
|
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);
|
getManager()->setFocus(this);
|
||||||
|
|
||||||
/* dispatch focus movement messages (because the buttons
|
// Dispatch focus movement messages (because the buttons
|
||||||
process them) */
|
// process them)
|
||||||
jmanager_dispatch_messages(ji_get_default_manager());
|
getManager()->dispatchMessages();
|
||||||
|
|
||||||
this->setSelected(true);
|
this->setSelected(true);
|
||||||
return true;
|
return true;
|
||||||
|
@ -353,7 +353,7 @@ static bool combobox_entry_msg_proc(JWidget widget, Message* msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (combobox->isEditable()) {
|
if (combobox->isEditable()) {
|
||||||
jmanager_set_focus(widget);
|
widget->getManager()->setFocus(widget);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
@ -475,10 +475,10 @@ void ComboBox::openListBox()
|
|||||||
m_window->position_window(rc->x1, rc->y1);
|
m_window->position_window(rc->x1, rc->y1);
|
||||||
jrect_free(rc);
|
jrect_free(rc);
|
||||||
|
|
||||||
jmanager_add_msg_filter(JM_BUTTONPRESSED, this);
|
getManager()->addMessageFilter(JM_BUTTONPRESSED, this);
|
||||||
|
|
||||||
m_window->open_window_bg();
|
m_window->open_window_bg();
|
||||||
jmanager_set_focus(m_listbox);
|
getManager()->setFocus(m_listbox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,8 +489,8 @@ void ComboBox::closeListBox()
|
|||||||
delete m_window; // window, frame
|
delete m_window; // window, frame
|
||||||
m_window = NULL;
|
m_window = NULL;
|
||||||
|
|
||||||
jmanager_remove_msg_filter(JM_BUTTONPRESSED, this);
|
getManager()->removeMessageFilter(JM_BUTTONPRESSED, this);
|
||||||
jmanager_set_focus(m_entry);
|
getManager()->setFocus(m_entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ Frame::Frame(bool desktop, const char* text)
|
|||||||
|
|
||||||
Frame::~Frame()
|
Frame::~Frame()
|
||||||
{
|
{
|
||||||
_jmanager_close_window(getManager(), this, false);
|
getManager()->_closeWindow(this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget* Frame::get_killer()
|
Widget* Frame::get_killer()
|
||||||
@ -218,7 +218,7 @@ void Frame::open_window()
|
|||||||
if (m_is_autoremap)
|
if (m_is_autoremap)
|
||||||
center_window();
|
center_window();
|
||||||
|
|
||||||
_jmanager_open_window(ji_get_default_manager(), this);
|
gui::Manager::getDefault()->_openWindow(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,13 +226,13 @@ void Frame::open_window_fg()
|
|||||||
{
|
{
|
||||||
open_window();
|
open_window();
|
||||||
|
|
||||||
JWidget manager = getManager();
|
gui::Manager* manager = getManager();
|
||||||
|
|
||||||
m_is_foreground = true;
|
m_is_foreground = true;
|
||||||
|
|
||||||
while (!(this->flags & JI_HIDDEN)) {
|
while (!(this->flags & JI_HIDDEN)) {
|
||||||
if (jmanager_generate_messages(manager))
|
if (manager->generateMessages())
|
||||||
jmanager_dispatch_messages(manager);
|
manager->dispatchMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_is_foreground = false;
|
m_is_foreground = false;
|
||||||
@ -247,7 +247,7 @@ void Frame::closeWindow(Widget* killer)
|
|||||||
{
|
{
|
||||||
m_killer = killer;
|
m_killer = killer;
|
||||||
|
|
||||||
_jmanager_close_window(getManager(), this, true);
|
getManager()->_closeWindow(this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Frame::is_toplevel()
|
bool Frame::is_toplevel()
|
||||||
@ -550,7 +550,7 @@ void Frame::move_window(JRect rect, bool use_blit)
|
|||||||
{
|
{
|
||||||
#define FLAGS JI_GDR_CUTTOPWINDOWS | JI_GDR_USECHILDAREA
|
#define FLAGS JI_GDR_CUTTOPWINDOWS | JI_GDR_USECHILDAREA
|
||||||
|
|
||||||
JWidget manager = getManager();
|
gui::Manager* manager = getManager();
|
||||||
JRegion old_drawable_region;
|
JRegion old_drawable_region;
|
||||||
JRegion new_drawable_region;
|
JRegion new_drawable_region;
|
||||||
JRegion manager_refresh_region;
|
JRegion manager_refresh_region;
|
||||||
@ -559,7 +559,7 @@ void Frame::move_window(JRect rect, bool use_blit)
|
|||||||
JRect man_pos;
|
JRect man_pos;
|
||||||
Message* msg;
|
Message* msg;
|
||||||
|
|
||||||
jmanager_dispatch_messages(manager);
|
manager->dispatchMessages();
|
||||||
|
|
||||||
/* get the window's current position */
|
/* get the window's current position */
|
||||||
old_pos = jrect_new_copy(this->rc);
|
old_pos = jrect_new_copy(this->rc);
|
||||||
@ -570,7 +570,7 @@ void Frame::move_window(JRect rect, bool use_blit)
|
|||||||
/* sent a JM_WINMOVE message to the window */
|
/* sent a JM_WINMOVE message to the window */
|
||||||
msg = jmessage_new(JM_WINMOVE);
|
msg = jmessage_new(JM_WINMOVE);
|
||||||
jmessage_add_dest(msg, this);
|
jmessage_add_dest(msg, this);
|
||||||
jmanager_enqueue_message(msg);
|
manager->enqueueMessage(msg);
|
||||||
|
|
||||||
/* get the region & the drawable region of the window */
|
/* get the region & the drawable region of the window */
|
||||||
old_drawable_region = jwidget_get_drawable_region(this, FLAGS);
|
old_drawable_region = jwidget_get_drawable_region(this, FLAGS);
|
||||||
@ -650,8 +650,8 @@ void Frame::move_window(JRect rect, bool use_blit)
|
|||||||
jregion_free(moveable_region);
|
jregion_free(moveable_region);
|
||||||
}
|
}
|
||||||
|
|
||||||
jmanager_invalidate_region(manager, manager_refresh_region);
|
manager->invalidateDisplayRegion(manager_refresh_region);
|
||||||
this->invalidateRegion(window_refresh_region);
|
invalidateRegion(window_refresh_region);
|
||||||
|
|
||||||
jregion_free(old_drawable_region);
|
jregion_free(old_drawable_region);
|
||||||
jregion_free(new_drawable_region);
|
jregion_free(new_drawable_region);
|
||||||
|
@ -116,6 +116,6 @@ void _ji_reinit_theme_in_all_widgets()
|
|||||||
static_cast<Frame*>((*widgets)[c])->remap_window();
|
static_cast<Frame*>((*widgets)[c])->remap_window();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh the screen
|
// Redraw the whole screen
|
||||||
jmanager_refresh_screen();
|
gui::Manager::getDefault()->invalidate();
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,6 @@ void _ji_reinit_theme_in_all_widgets();
|
|||||||
|
|
||||||
bool _jwindow_is_moving();
|
bool _jwindow_is_moving();
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
// jmanager.c
|
|
||||||
|
|
||||||
void _jmanager_open_window(JWidget manager, Frame* frame);
|
|
||||||
void _jmanager_close_window(JWidget manager, Frame* frame, bool redraw_background);
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// theme.cpp
|
// theme.cpp
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -7,50 +7,87 @@
|
|||||||
#ifndef GUI_MANAGER_H_INCLUDED
|
#ifndef GUI_MANAGER_H_INCLUDED
|
||||||
#define GUI_MANAGER_H_INCLUDED
|
#define GUI_MANAGER_H_INCLUDED
|
||||||
|
|
||||||
#include "gui/base.h"
|
#include "base/compiler_specific.h"
|
||||||
|
#include "gui/widget.h"
|
||||||
|
|
||||||
namespace gui { class Timer; }
|
class Frame;
|
||||||
|
|
||||||
JWidget ji_get_default_manager();
|
namespace gui {
|
||||||
|
|
||||||
JWidget jmanager_new();
|
class Timer;
|
||||||
void jmanager_free(JWidget manager);
|
|
||||||
|
|
||||||
void jmanager_run(JWidget manager);
|
class Manager : public Widget
|
||||||
bool jmanager_generate_messages(JWidget manager);
|
{
|
||||||
void jmanager_dispatch_messages(JWidget manager);
|
public:
|
||||||
|
static Manager* getDefault();
|
||||||
|
|
||||||
void jmanager_add_to_garbage(Widget* widget);
|
Manager();
|
||||||
|
~Manager();
|
||||||
|
|
||||||
/* routines that uses the ji_get_default_manager() */
|
void run();
|
||||||
|
|
||||||
void jmanager_enqueue_message(Message* msg);
|
// Returns true if there are messages in the queue to be
|
||||||
|
// distpatched through jmanager_dispatch_messages().
|
||||||
|
bool generateMessages();
|
||||||
|
|
||||||
JWidget jmanager_get_top_window();
|
void dispatchMessages();
|
||||||
JWidget jmanager_get_foreground_window();
|
|
||||||
|
|
||||||
JWidget jmanager_get_focus();
|
void addToGarbage(Widget* widget);
|
||||||
JWidget jmanager_get_mouse();
|
|
||||||
JWidget jmanager_get_capture();
|
|
||||||
|
|
||||||
void jmanager_set_focus(JWidget widget);
|
void enqueueMessage(Message* msg);
|
||||||
void jmanager_set_mouse(JWidget widget);
|
|
||||||
void jmanager_set_capture(JWidget widget);
|
|
||||||
void jmanager_attract_focus(JWidget widget);
|
|
||||||
void jmanager_focus_first_child(JWidget widget);
|
|
||||||
void jmanager_free_focus();
|
|
||||||
void jmanager_free_mouse();
|
|
||||||
void jmanager_free_capture();
|
|
||||||
void jmanager_free_widget(JWidget widget);
|
|
||||||
void jmanager_remove_message(Message* msg);
|
|
||||||
void jmanager_remove_messages_for(JWidget widget);
|
|
||||||
void jmanager_remove_messages_for_timer(gui::Timer* timer);
|
|
||||||
void jmanager_refresh_screen();
|
|
||||||
|
|
||||||
void jmanager_add_msg_filter(int message, JWidget widget);
|
Frame* getTopFrame();
|
||||||
void jmanager_remove_msg_filter(int message, JWidget widget);
|
Frame* getForegroundFrame();
|
||||||
void jmanager_remove_msg_filter_for(JWidget widget);
|
|
||||||
|
|
||||||
void jmanager_invalidate_region(JWidget widget, JRegion region);
|
Widget* getFocus();
|
||||||
|
Widget* getMouse();
|
||||||
|
Widget* getCapture();
|
||||||
|
|
||||||
|
void setFocus(Widget* widget);
|
||||||
|
void setMouse(Widget* widget);
|
||||||
|
void setCapture(Widget* widget);
|
||||||
|
void attractFocus(Widget* widget);
|
||||||
|
void focusFirstChild(Widget* widget);
|
||||||
|
void freeFocus();
|
||||||
|
void freeMouse();
|
||||||
|
void freeCapture();
|
||||||
|
void freeWidget(Widget* widget);
|
||||||
|
void removeMessage(Message* msg);
|
||||||
|
void removeMessagesFor(Widget* widget);
|
||||||
|
void removeMessagesForTimer(gui::Timer* timer);
|
||||||
|
|
||||||
|
void addMessageFilter(int message, Widget* widget);
|
||||||
|
void removeMessageFilter(int message, Widget* widget);
|
||||||
|
void removeMessageFilterFor(Widget* widget);
|
||||||
|
|
||||||
|
void invalidateDisplayRegion(const JRegion region);
|
||||||
|
|
||||||
|
void _openWindow(Frame* window);
|
||||||
|
void _closeWindow(Frame* frame, bool redraw_background);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool onProcessMessage(Message* msg) OVERRIDE;
|
||||||
|
void onPreferredSize(PreferredSizeEvent& ev) OVERRIDE;
|
||||||
|
void onBroadcastMouseMessage(WidgetsList& targets) OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void layoutManager(JRect rect);
|
||||||
|
void pumpQueue();
|
||||||
|
void collectGarbage();
|
||||||
|
void generateSetCursorMessage();
|
||||||
|
static void removeWidgetFromDests(Widget* widget, Message* msg);
|
||||||
|
static bool someParentIsFocusStop(Widget* widget);
|
||||||
|
static Widget* findMagneticWidget(Widget* widget);
|
||||||
|
static Message* newMouseMessage(int type, Widget* destination);
|
||||||
|
void broadcastKeyMsg(Message* msg);
|
||||||
|
|
||||||
|
static Manager* m_defaultManager;
|
||||||
|
|
||||||
|
WidgetsList m_garbage;
|
||||||
|
};
|
||||||
|
|
||||||
|
void InvalidateRegion(Widget* widget, JRegion region);
|
||||||
|
|
||||||
|
} // namespace gui
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -112,7 +112,7 @@ MenuBox::~MenuBox()
|
|||||||
{
|
{
|
||||||
if (m_base && m_base->is_filtering) {
|
if (m_base && m_base->is_filtering) {
|
||||||
m_base->is_filtering = false;
|
m_base->is_filtering = false;
|
||||||
jmanager_remove_msg_filter(JM_BUTTONPRESSED, this);
|
gui::Manager::getDefault()->removeMessageFilter(JM_BUTTONPRESSED, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete m_base;
|
delete m_base;
|
||||||
@ -236,7 +236,7 @@ void Menu::showPopup(int x, int y)
|
|||||||
MenuBaseData* base = menubox->createBase();
|
MenuBaseData* base = menubox->createBase();
|
||||||
base->was_clicked = true;
|
base->was_clicked = true;
|
||||||
base->is_filtering = true;
|
base->is_filtering = true;
|
||||||
jmanager_add_msg_filter(JM_BUTTONPRESSED, menubox);
|
gui::Manager::getDefault()->addMessageFilter(JM_BUTTONPRESSED, menubox);
|
||||||
|
|
||||||
window->set_moveable(false); // Can't move the window
|
window->set_moveable(false); // Can't move the window
|
||||||
|
|
||||||
@ -251,14 +251,14 @@ void Menu::showPopup(int x, int y)
|
|||||||
MID(0, y, JI_SCREEN_H-jrect_h(window->rc)));
|
MID(0, y, JI_SCREEN_H-jrect_h(window->rc)));
|
||||||
|
|
||||||
// Set the focus to the new menubox
|
// Set the focus to the new menubox
|
||||||
jmanager_set_focus(menubox);
|
gui::Manager::getDefault()->setFocus(menubox);
|
||||||
menubox->setFocusMagnet(true);
|
menubox->setFocusMagnet(true);
|
||||||
|
|
||||||
// Open the window
|
// Open the window
|
||||||
window->open_window_fg();
|
window->open_window_fg();
|
||||||
|
|
||||||
// Free the keyboard focus
|
// Free the keyboard focus
|
||||||
jmanager_free_focus();
|
gui::Manager::getDefault()->freeFocus();
|
||||||
|
|
||||||
// Fetch the "menu" so it isn't destroyed
|
// Fetch the "menu" so it isn't destroyed
|
||||||
menubox->setMenu(NULL);
|
menubox->setMenu(NULL);
|
||||||
@ -375,7 +375,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
|||||||
// popuped menu-box) to detect if the user press outside of
|
// popuped menu-box) to detect if the user press outside of
|
||||||
// the widget
|
// the widget
|
||||||
if (msg->type == JM_BUTTONPRESSED && m_base != NULL) {
|
if (msg->type == JM_BUTTONPRESSED && m_base != NULL) {
|
||||||
Widget* picked = ji_get_default_manager()->pick(msg->mouse.x, msg->mouse.y);
|
Widget* picked = getManager()->pick(msg->mouse.x, msg->mouse.y);
|
||||||
|
|
||||||
// If one of these conditions are accomplished we have to
|
// If one of these conditions are accomplished we have to
|
||||||
// close all menus (back to menu-bar or close the popuped
|
// close all menus (back to menu-bar or close the popuped
|
||||||
@ -637,8 +637,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
if (msg->type == JM_CLOSE_POPUP) {
|
if (msg->type == JM_CLOSE_POPUP) {
|
||||||
_jmanager_close_window(this->getManager(),
|
this->getManager()->_closeWindow(this->getRoot(), true);
|
||||||
static_cast<Frame*>(this->getRoot()), true);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -837,9 +836,9 @@ bool MenuItem::onProcessMessage(Message* msg)
|
|||||||
|
|
||||||
// Set the focus to this menu-box of this menu-item
|
// Set the focus to this menu-box of this menu-item
|
||||||
if (base->close_all)
|
if (base->close_all)
|
||||||
jmanager_free_focus();
|
getManager()->freeFocus();
|
||||||
else
|
else
|
||||||
jmanager_set_focus(this->parent->parent);
|
getManager()->setFocus(this->parent->parent);
|
||||||
|
|
||||||
// Is not necessary to free this window because it's
|
// Is not necessary to free this window because it's
|
||||||
// automatically destroyed by the manager
|
// automatically destroyed by the manager
|
||||||
@ -1061,7 +1060,7 @@ void MenuItem::openSubmenu(bool select_first)
|
|||||||
msg = jmessage_new(JM_OPEN_MENUITEM);
|
msg = jmessage_new(JM_OPEN_MENUITEM);
|
||||||
msg->user.a = select_first;
|
msg->user.a = select_first;
|
||||||
jmessage_add_dest(msg, this);
|
jmessage_add_dest(msg, this);
|
||||||
jmanager_enqueue_message(msg);
|
gui::Manager::getDefault()->enqueueMessage(msg);
|
||||||
|
|
||||||
// Get the 'base'
|
// Get the 'base'
|
||||||
MenuBaseData* base = get_base(this);
|
MenuBaseData* base = get_base(this);
|
||||||
@ -1078,7 +1077,7 @@ void MenuItem::openSubmenu(bool select_first)
|
|||||||
// popuped menu-box
|
// popuped menu-box
|
||||||
if (!base->is_filtering) {
|
if (!base->is_filtering) {
|
||||||
base->is_filtering = true;
|
base->is_filtering = true;
|
||||||
jmanager_add_msg_filter(JM_BUTTONPRESSED, get_base_menubox(this));
|
gui::Manager::getDefault()->addMessageFilter(JM_BUTTONPRESSED, get_base_menubox(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1108,7 +1107,7 @@ void MenuItem::closeSubmenu(bool last_of_close_chain)
|
|||||||
msg = jmessage_new(JM_CLOSE_MENUITEM);
|
msg = jmessage_new(JM_CLOSE_MENUITEM);
|
||||||
msg->user.a = last_of_close_chain;
|
msg->user.a = last_of_close_chain;
|
||||||
jmessage_add_dest(msg, this);
|
jmessage_add_dest(msg, this);
|
||||||
jmanager_enqueue_message(msg);
|
gui::Manager::getDefault()->enqueueMessage(msg);
|
||||||
|
|
||||||
// If this is the last message of the chain, here we have the
|
// If this is the last message of the chain, here we have the
|
||||||
// responsibility to set is_processing flag to true.
|
// responsibility to set is_processing flag to true.
|
||||||
@ -1153,7 +1152,7 @@ void Menu::closeAll()
|
|||||||
base->was_clicked = false;
|
base->was_clicked = false;
|
||||||
if (base->is_filtering) {
|
if (base->is_filtering) {
|
||||||
base->is_filtering = false;
|
base->is_filtering = false;
|
||||||
jmanager_remove_msg_filter(JM_BUTTONPRESSED, base_menubox);
|
gui::Manager::getDefault()->removeMessageFilter(JM_BUTTONPRESSED, base_menubox);
|
||||||
}
|
}
|
||||||
|
|
||||||
menu->unhighlightItem();
|
menu->unhighlightItem();
|
||||||
@ -1184,7 +1183,7 @@ void MenuBox::closePopup()
|
|||||||
{
|
{
|
||||||
Message* msg = jmessage_new(JM_CLOSE_POPUP);
|
Message* msg = jmessage_new(JM_CLOSE_POPUP);
|
||||||
jmessage_add_dest(msg, this);
|
jmessage_add_dest(msg, this);
|
||||||
jmanager_enqueue_message(msg);
|
gui::Manager::getDefault()->enqueueMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuBox::cancelMenuLoop()
|
void MenuBox::cancelMenuLoop()
|
||||||
@ -1194,7 +1193,7 @@ void MenuBox::cancelMenuLoop()
|
|||||||
menu->closeAll();
|
menu->closeAll();
|
||||||
|
|
||||||
// Lost focus
|
// Lost focus
|
||||||
jmanager_free_focus();
|
gui::Manager::getDefault()->freeFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuItem::executeClick()
|
void MenuItem::executeClick()
|
||||||
@ -1202,7 +1201,7 @@ void MenuItem::executeClick()
|
|||||||
// Send the message
|
// Send the message
|
||||||
Message* msg = jmessage_new(JM_EXE_MENUITEM);
|
Message* msg = jmessage_new(JM_EXE_MENUITEM);
|
||||||
jmessage_add_dest(msg, this);
|
jmessage_add_dest(msg, this);
|
||||||
jmanager_enqueue_message(msg);
|
gui::Manager::getDefault()->enqueueMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool window_msg_proc(Widget* widget, Message* msg)
|
static bool window_msg_proc(Widget* widget, Message* msg)
|
||||||
|
@ -131,7 +131,7 @@ bool PopupFrame::onProcessMessage(Message* msg)
|
|||||||
case JM_MOTION:
|
case JM_MOTION:
|
||||||
if (!is_moveable() &&
|
if (!is_moveable() &&
|
||||||
m_hot_region != NULL &&
|
m_hot_region != NULL &&
|
||||||
jmanager_get_capture() == NULL) {
|
getManager()->getCapture() == NULL) {
|
||||||
struct jrect box;
|
struct jrect box;
|
||||||
|
|
||||||
// If the mouse is outside the hot-region we have to close the
|
// If the mouse is outside the hot-region we have to close the
|
||||||
@ -200,9 +200,11 @@ void PopupFrame::startFilteringMessages()
|
|||||||
{
|
{
|
||||||
if (!m_filtering) {
|
if (!m_filtering) {
|
||||||
m_filtering = true;
|
m_filtering = true;
|
||||||
jmanager_add_msg_filter(JM_MOTION, this);
|
|
||||||
jmanager_add_msg_filter(JM_BUTTONPRESSED, this);
|
gui::Manager* manager = gui::Manager::getDefault();
|
||||||
jmanager_add_msg_filter(JM_KEYPRESSED, this);
|
manager->addMessageFilter(JM_MOTION, this);
|
||||||
|
manager->addMessageFilter(JM_BUTTONPRESSED, this);
|
||||||
|
manager->addMessageFilter(JM_KEYPRESSED, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,8 +212,10 @@ void PopupFrame::stopFilteringMessages()
|
|||||||
{
|
{
|
||||||
if (m_filtering) {
|
if (m_filtering) {
|
||||||
m_filtering = false;
|
m_filtering = false;
|
||||||
jmanager_remove_msg_filter(JM_MOTION, this);
|
|
||||||
jmanager_remove_msg_filter(JM_BUTTONPRESSED, this);
|
gui::Manager* manager = gui::Manager::getDefault();
|
||||||
jmanager_remove_msg_filter(JM_KEYPRESSED, this);
|
manager->removeMessageFilter(JM_MOTION, this);
|
||||||
|
manager->removeMessageFilter(JM_BUTTONPRESSED, this);
|
||||||
|
manager->removeMessageFilter(JM_KEYPRESSED, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ void ji_set_screen(BITMAP *bmp, int width, int height)
|
|||||||
ji_screen_h = height;
|
ji_screen_h = height;
|
||||||
|
|
||||||
if (ji_screen != NULL) {
|
if (ji_screen != NULL) {
|
||||||
JWidget manager = ji_get_default_manager();
|
gui::Manager* manager = gui::Manager::getDefault();
|
||||||
|
|
||||||
/* update default-manager size */
|
/* update default-manager size */
|
||||||
if (manager && (jrect_w(manager->rc) != JI_SCREEN_W ||
|
if (manager && (jrect_w(manager->rc) != JI_SCREEN_W ||
|
||||||
@ -443,7 +443,7 @@ static void update_mouse_position()
|
|||||||
if (!PtInRect(&rc, pt)) {
|
if (!PtInRect(&rc, pt)) {
|
||||||
/* if the mouse is free we can hide the cursor putting the
|
/* if the mouse is free we can hide the cursor putting the
|
||||||
mouse outside the screen (right-bottom corder) */
|
mouse outside the screen (right-bottom corder) */
|
||||||
if (!jmanager_get_capture()) {
|
if (!gui::Manager::getDefault()->getCapture()) {
|
||||||
m_x[0] = JI_SCREEN_W+focus_x;
|
m_x[0] = JI_SCREEN_W+focus_x;
|
||||||
m_y[0] = JI_SCREEN_H+focus_y;
|
m_y[0] = JI_SCREEN_H+focus_y;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ void CurrentTheme::set(Theme* theme)
|
|||||||
if (current_theme) {
|
if (current_theme) {
|
||||||
current_theme->regenerate();
|
current_theme->regenerate();
|
||||||
|
|
||||||
Widget* manager = ji_get_default_manager();
|
gui::Manager* manager = gui::Manager::getDefault();
|
||||||
if (manager && !manager->getTheme())
|
if (manager && !manager->getTheme())
|
||||||
manager->setTheme(theme);
|
manager->setTheme(theme);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ Timer::~Timer()
|
|||||||
timers.erase(it);
|
timers.erase(it);
|
||||||
|
|
||||||
// Remove messages of this timer in the queue
|
// Remove messages of this timer in the queue
|
||||||
jmanager_remove_messages_for_timer(this);
|
Manager::getDefault()->removeMessagesForTimer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Timer::isRunning() const
|
bool Timer::isRunning() const
|
||||||
@ -99,7 +99,7 @@ void Timer::pollTimers()
|
|||||||
msg->timer.count = count;
|
msg->timer.count = count;
|
||||||
msg->timer.timer = timers[c];
|
msg->timer.timer = timers[c];
|
||||||
jmessage_add_dest(msg, timers[c]->m_owner);
|
jmessage_add_dest(msg, timers[c]->m_owner);
|
||||||
jmanager_enqueue_message(msg);
|
Manager::getDefault()->enqueueMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,9 +192,9 @@ TipWindow::~TipWindow()
|
|||||||
{
|
{
|
||||||
if (m_filtering) {
|
if (m_filtering) {
|
||||||
m_filtering = false;
|
m_filtering = false;
|
||||||
jmanager_remove_msg_filter(JM_MOTION, this);
|
getManager()->removeMessageFilter(JM_MOTION, this);
|
||||||
jmanager_remove_msg_filter(JM_BUTTONPRESSED, this);
|
getManager()->removeMessageFilter(JM_BUTTONPRESSED, this);
|
||||||
jmanager_remove_msg_filter(JM_KEYPRESSED, this);
|
getManager()->removeMessageFilter(JM_KEYPRESSED, this);
|
||||||
}
|
}
|
||||||
if (m_hot_region != NULL) {
|
if (m_hot_region != NULL) {
|
||||||
jregion_free(m_hot_region);
|
jregion_free(m_hot_region);
|
||||||
@ -214,9 +214,9 @@ void TipWindow::set_hotregion(JRegion region)
|
|||||||
|
|
||||||
if (!m_filtering) {
|
if (!m_filtering) {
|
||||||
m_filtering = true;
|
m_filtering = true;
|
||||||
jmanager_add_msg_filter(JM_MOTION, this);
|
getManager()->addMessageFilter(JM_MOTION, this);
|
||||||
jmanager_add_msg_filter(JM_BUTTONPRESSED, this);
|
getManager()->addMessageFilter(JM_BUTTONPRESSED, this);
|
||||||
jmanager_add_msg_filter(JM_KEYPRESSED, this);
|
getManager()->addMessageFilter(JM_KEYPRESSED, this);
|
||||||
}
|
}
|
||||||
m_hot_region = region;
|
m_hot_region = region;
|
||||||
}
|
}
|
||||||
@ -238,9 +238,9 @@ bool TipWindow::onProcessMessage(Message* msg)
|
|||||||
case JM_CLOSE:
|
case JM_CLOSE:
|
||||||
if (m_filtering) {
|
if (m_filtering) {
|
||||||
m_filtering = false;
|
m_filtering = false;
|
||||||
jmanager_remove_msg_filter(JM_MOTION, this);
|
getManager()->removeMessageFilter(JM_MOTION, this);
|
||||||
jmanager_remove_msg_filter(JM_BUTTONPRESSED, this);
|
getManager()->removeMessageFilter(JM_BUTTONPRESSED, this);
|
||||||
jmanager_remove_msg_filter(JM_KEYPRESSED, this);
|
getManager()->removeMessageFilter(JM_KEYPRESSED, this);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ bool TipWindow::onProcessMessage(Message* msg)
|
|||||||
|
|
||||||
case JM_MOTION:
|
case JM_MOTION:
|
||||||
if (m_hot_region != NULL &&
|
if (m_hot_region != NULL &&
|
||||||
jmanager_get_capture() == NULL) {
|
getManager()->getCapture() == NULL) {
|
||||||
struct jrect box;
|
struct jrect box;
|
||||||
|
|
||||||
/* if the mouse is outside the hot-region we have to close the window */
|
/* if the mouse is outside the hot-region we have to close the window */
|
||||||
|
@ -101,12 +101,15 @@ Widget::~Widget()
|
|||||||
sendMessage(msg);
|
sendMessage(msg);
|
||||||
jmessage_free(msg);
|
jmessage_free(msg);
|
||||||
|
|
||||||
/* break relationship with the manager */
|
// Break relationship with the manager.
|
||||||
jmanager_free_widget(this);
|
if (this->type != JI_MANAGER) {
|
||||||
jmanager_remove_messages_for(this);
|
gui::Manager* manager = getManager();
|
||||||
jmanager_remove_msg_filter_for(this);
|
manager->freeWidget(this);
|
||||||
|
manager->removeMessagesFor(this);
|
||||||
|
manager->removeMessageFilterFor(this);
|
||||||
|
}
|
||||||
|
|
||||||
/* remove from parent */
|
// Remove from parent
|
||||||
if (this->parent)
|
if (this->parent)
|
||||||
this->parent->removeChild(this);
|
this->parent->removeChild(this);
|
||||||
|
|
||||||
@ -141,7 +144,7 @@ Widget::~Widget()
|
|||||||
|
|
||||||
void Widget::deferDelete()
|
void Widget::deferDelete()
|
||||||
{
|
{
|
||||||
jmanager_add_to_garbage(this);
|
getManager()->addToGarbage(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::initTheme()
|
void Widget::initTheme()
|
||||||
@ -327,7 +330,7 @@ void Widget::setVisible(bool state)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!(this->flags & JI_HIDDEN)) {
|
if (!(this->flags & JI_HIDDEN)) {
|
||||||
jmanager_free_widget(this); // Free from manager
|
getManager()->freeWidget(this); // Free from manager
|
||||||
|
|
||||||
this->flags |= JI_HIDDEN;
|
this->flags |= JI_HIDDEN;
|
||||||
jwidget_emit_signal(this, JI_SIGNAL_HIDE);
|
jwidget_emit_signal(this, JI_SIGNAL_HIDE);
|
||||||
@ -347,7 +350,7 @@ void Widget::setEnabled(bool state)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!(this->flags & JI_DISABLED)) {
|
if (!(this->flags & JI_DISABLED)) {
|
||||||
jmanager_free_widget(this); // Free from the manager
|
getManager()->freeWidget(this); // Free from the manager
|
||||||
|
|
||||||
this->flags |= JI_DISABLED;
|
this->flags |= JI_DISABLED;
|
||||||
invalidate();
|
invalidate();
|
||||||
@ -466,13 +469,13 @@ bool Widget::isFocusMagnet() const
|
|||||||
// PARENTS & CHILDREN
|
// PARENTS & CHILDREN
|
||||||
// ===============================================================
|
// ===============================================================
|
||||||
|
|
||||||
Widget* Widget::getRoot()
|
Frame* Widget::getRoot()
|
||||||
{
|
{
|
||||||
Widget* widget = this;
|
Widget* widget = this;
|
||||||
|
|
||||||
while (widget) {
|
while (widget) {
|
||||||
if (widget->type == JI_FRAME)
|
if (widget->type == JI_FRAME)
|
||||||
return widget;
|
return dynamic_cast<Frame*>(widget);
|
||||||
|
|
||||||
widget = widget->parent;
|
widget = widget->parent;
|
||||||
}
|
}
|
||||||
@ -485,18 +488,18 @@ Widget* Widget::getParent()
|
|||||||
return this->parent;
|
return this->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget* Widget::getManager()
|
gui::Manager* Widget::getManager()
|
||||||
{
|
{
|
||||||
Widget* widget = this;
|
Widget* widget = this;
|
||||||
|
|
||||||
while (widget) {
|
while (widget) {
|
||||||
if (widget->type == JI_MANAGER)
|
if (widget->type == JI_MANAGER)
|
||||||
return widget;
|
return static_cast<gui::Manager*>(widget);
|
||||||
|
|
||||||
widget = widget->parent;
|
widget = widget->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ji_get_default_manager();
|
return gui::Manager::getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
JList Widget::getParents(bool ascendant)
|
JList Widget::getParents(bool ascendant)
|
||||||
@ -1099,7 +1102,7 @@ void Widget::flushRedraw()
|
|||||||
jmessage_add_dest(msg, widget);
|
jmessage_add_dest(msg, widget);
|
||||||
|
|
||||||
/* enqueue the draw message */
|
/* enqueue the draw message */
|
||||||
jmanager_enqueue_message(msg);
|
getManager()->enqueueMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
jregion_empty(widget->m_update_region);
|
jregion_empty(widget->m_update_region);
|
||||||
@ -1153,26 +1156,7 @@ void Widget::invalidateRect(const JRect rect)
|
|||||||
|
|
||||||
void Widget::invalidateRegion(const JRegion region)
|
void Widget::invalidateRegion(const JRegion region)
|
||||||
{
|
{
|
||||||
if (isVisible() &&
|
onInvalidateRegion(region);
|
||||||
jregion_rect_in(region, this->rc) != JI_RGNOUT) {
|
|
||||||
JRegion reg1 = jregion_new(NULL, 0);
|
|
||||||
JRegion reg2 = jwidget_get_drawable_region(this,
|
|
||||||
JI_GDR_CUTTOPWINDOWS);
|
|
||||||
JLink link;
|
|
||||||
|
|
||||||
jregion_union(reg1, this->m_update_region, region);
|
|
||||||
jregion_intersect(this->m_update_region, reg1, reg2);
|
|
||||||
jregion_free(reg2);
|
|
||||||
|
|
||||||
jregion_subtract(reg1, region, this->m_update_region);
|
|
||||||
|
|
||||||
mark_dirty_flag(this);
|
|
||||||
|
|
||||||
JI_LIST_FOR_EACH(this->children, link)
|
|
||||||
reinterpret_cast<JWidget>(link->data)->invalidateRegion(reg1);
|
|
||||||
|
|
||||||
jregion_free(reg1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::scrollRegion(JRegion region, int dx, int dy)
|
void Widget::scrollRegion(JRegion region, int dx, int dy)
|
||||||
@ -1241,7 +1225,7 @@ bool jwidget_emit_signal(JWidget widget, int signal_num)
|
|||||||
|
|
||||||
/* send the signal to the window too */
|
/* send the signal to the window too */
|
||||||
if (!ret && widget->type != JI_FRAME) {
|
if (!ret && widget->type != JI_FRAME) {
|
||||||
Widget* window = widget->getRoot();
|
Frame* window = widget->getRoot();
|
||||||
if (window)
|
if (window)
|
||||||
ret = window->sendMessage(msg);
|
ret = window->sendMessage(msg);
|
||||||
}
|
}
|
||||||
@ -1281,7 +1265,7 @@ bool Widget::sendMessage(Message* msg)
|
|||||||
|
|
||||||
void Widget::closeWindow()
|
void Widget::closeWindow()
|
||||||
{
|
{
|
||||||
if (Frame* frame = static_cast<Frame*>(getRoot()))
|
if (Frame* frame = getRoot())
|
||||||
frame->closeWindow(this);
|
frame->closeWindow(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1373,13 +1357,13 @@ void Widget::setPreferredSize(int fixedWidth, int fixedHeight)
|
|||||||
|
|
||||||
void Widget::requestFocus()
|
void Widget::requestFocus()
|
||||||
{
|
{
|
||||||
jmanager_set_focus(this);
|
getManager()->setFocus(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::releaseFocus()
|
void Widget::releaseFocus()
|
||||||
{
|
{
|
||||||
if (hasFocus())
|
if (hasFocus())
|
||||||
jmanager_free_focus();
|
getManager()->freeFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1388,8 +1372,8 @@ void Widget::releaseFocus()
|
|||||||
*/
|
*/
|
||||||
void Widget::captureMouse()
|
void Widget::captureMouse()
|
||||||
{
|
{
|
||||||
if (!jmanager_get_capture()) {
|
if (!getManager()->getCapture()) {
|
||||||
jmanager_set_capture(this);
|
getManager()->setCapture(this);
|
||||||
jmouse_capture();
|
jmouse_capture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1399,8 +1383,8 @@ void Widget::captureMouse()
|
|||||||
*/
|
*/
|
||||||
void Widget::releaseMouse()
|
void Widget::releaseMouse()
|
||||||
{
|
{
|
||||||
if (jmanager_get_capture() == this) {
|
if (getManager()->getCapture() == this) {
|
||||||
jmanager_free_capture();
|
getManager()->freeCapture();
|
||||||
jmouse_release();
|
jmouse_release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1589,6 +1573,30 @@ bool Widget::onProcessMessage(Message* msg)
|
|||||||
// EVENTS
|
// EVENTS
|
||||||
// ===============================================================
|
// ===============================================================
|
||||||
|
|
||||||
|
void Widget::onInvalidateRegion(const JRegion region)
|
||||||
|
{
|
||||||
|
if (isVisible() &&
|
||||||
|
jregion_rect_in(region, this->rc) != JI_RGNOUT) {
|
||||||
|
JRegion reg1 = jregion_new(NULL, 0);
|
||||||
|
JRegion reg2 = jwidget_get_drawable_region(this,
|
||||||
|
JI_GDR_CUTTOPWINDOWS);
|
||||||
|
JLink link;
|
||||||
|
|
||||||
|
jregion_union(reg1, this->m_update_region, region);
|
||||||
|
jregion_intersect(this->m_update_region, reg1, reg2);
|
||||||
|
jregion_free(reg2);
|
||||||
|
|
||||||
|
jregion_subtract(reg1, region, this->m_update_region);
|
||||||
|
|
||||||
|
mark_dirty_flag(this);
|
||||||
|
|
||||||
|
JI_LIST_FOR_EACH(this->children, link)
|
||||||
|
reinterpret_cast<JWidget>(link->data)->invalidateRegion(reg1);
|
||||||
|
|
||||||
|
jregion_free(reg1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Calculates the preferred size for the widget.
|
Calculates the preferred size for the widget.
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
class PaintEvent;
|
class PaintEvent;
|
||||||
class PreferredSizeEvent;
|
class PreferredSizeEvent;
|
||||||
|
namespace gui { class Manager; }
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include "gui/intern.h"
|
#include "gui/intern.h"
|
||||||
@ -31,6 +32,8 @@ class PreferredSizeEvent;
|
|||||||
struct FONT;
|
struct FONT;
|
||||||
struct BITMAP;
|
struct BITMAP;
|
||||||
|
|
||||||
|
class Frame;
|
||||||
|
|
||||||
typedef std::vector<Widget*> WidgetsList;
|
typedef std::vector<Widget*> WidgetsList;
|
||||||
|
|
||||||
int ji_register_widget_type();
|
int ji_register_widget_type();
|
||||||
@ -219,9 +222,9 @@ public:
|
|||||||
// PARENTS & CHILDREN
|
// PARENTS & CHILDREN
|
||||||
// ===============================================================
|
// ===============================================================
|
||||||
|
|
||||||
Widget* getRoot();
|
Frame* getRoot();
|
||||||
Widget* getParent();
|
Widget* getParent();
|
||||||
Widget* getManager();
|
gui::Manager* getManager();
|
||||||
|
|
||||||
// Returns a list of parents (you must free the list), if
|
// Returns a list of parents (you must free the list), if
|
||||||
// "ascendant" is true the list is build from child to parents, else
|
// "ascendant" is true the list is build from child to parents, else
|
||||||
@ -330,6 +333,7 @@ protected:
|
|||||||
// EVENTS
|
// EVENTS
|
||||||
// ===============================================================
|
// ===============================================================
|
||||||
|
|
||||||
|
virtual void onInvalidateRegion(const JRegion region);
|
||||||
virtual void onPreferredSize(PreferredSizeEvent& ev);
|
virtual void onPreferredSize(PreferredSizeEvent& ev);
|
||||||
virtual void onPaint(PaintEvent& ev);
|
virtual void onPaint(PaintEvent& ev);
|
||||||
virtual void onBroadcastMouseMessage(WidgetsList& targets);
|
virtual void onBroadcastMouseMessage(WidgetsList& targets);
|
||||||
|
@ -140,7 +140,7 @@ struct Monitor
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static JWidget manager = NULL;
|
static gui::Manager* manager = NULL;
|
||||||
static Theme* ase_theme = NULL;
|
static Theme* ase_theme = NULL;
|
||||||
|
|
||||||
static UniquePtr<gui::Timer> monitor_timer;
|
static UniquePtr<gui::Timer> monitor_timer;
|
||||||
@ -296,7 +296,7 @@ int init_module_gui()
|
|||||||
gfx_done:;
|
gfx_done:;
|
||||||
|
|
||||||
// Create the default-manager
|
// Create the default-manager
|
||||||
manager = jmanager_new();
|
manager = new gui::Manager();
|
||||||
jwidget_add_hook(manager, JI_WIDGET, manager_msg_proc, NULL);
|
jwidget_add_hook(manager, JI_WIDGET, manager_msg_proc, NULL);
|
||||||
|
|
||||||
// Setup the GUI theme for all widgets
|
// Setup the GUI theme for all widgets
|
||||||
@ -364,7 +364,7 @@ void exit_module_gui()
|
|||||||
ji_screen_created = false;
|
ji_screen_created = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
jmanager_free(manager);
|
delete manager;
|
||||||
|
|
||||||
// Now we can destroy theme
|
// Now we can destroy theme
|
||||||
CurrentTheme::set(NULL);
|
CurrentTheme::set(NULL);
|
||||||
@ -450,7 +450,7 @@ void update_screen_for_document(const Document* document)
|
|||||||
// Well, change to the default palette.
|
// Well, change to the default palette.
|
||||||
if (set_current_palette(NULL, false)) {
|
if (set_current_palette(NULL, false)) {
|
||||||
// If the palette changes, refresh the whole screen.
|
// If the palette changes, refresh the whole screen.
|
||||||
jmanager_refresh_screen();
|
gui::Manager::getDefault()->invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// With a document.
|
// With a document.
|
||||||
@ -459,8 +459,9 @@ void update_screen_for_document(const Document* document)
|
|||||||
|
|
||||||
// Select the palette of the sprite.
|
// Select the palette of the sprite.
|
||||||
if (set_current_palette(sprite->getPalette(sprite->getCurrentFrame()), false)) {
|
if (set_current_palette(sprite->getPalette(sprite->getCurrentFrame()), false)) {
|
||||||
// If the palette changes, refresh the whole screen.
|
// If the palette changes, invalidate the whole screen, we've to
|
||||||
jmanager_refresh_screen();
|
// redraw it.
|
||||||
|
gui::Manager::getDefault()->invalidate();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If it's the same palette update only the editors with the sprite.
|
// If it's the same palette update only the editors with the sprite.
|
||||||
@ -474,7 +475,7 @@ void update_screen_for_document(const Document* document)
|
|||||||
|
|
||||||
void gui_run()
|
void gui_run()
|
||||||
{
|
{
|
||||||
jmanager_run(manager);
|
manager->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_feedback()
|
void gui_feedback()
|
||||||
@ -488,7 +489,7 @@ void gui_feedback()
|
|||||||
|
|
||||||
gui_setup_screen(false);
|
gui_setup_screen(false);
|
||||||
app_get_top_window()->remap_window();
|
app_get_top_window()->remap_window();
|
||||||
jmanager_refresh_screen();
|
gui::Manager::getDefault()->invalidate();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1197,7 +1198,7 @@ static bool manager_msg_proc(JWidget widget, Message* msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case JM_KEYPRESSED: {
|
case JM_KEYPRESSED: {
|
||||||
Frame* toplevel_frame = dynamic_cast<Frame*>(jmanager_get_top_window());
|
Frame* toplevel_frame = widget->getManager()->getTopFrame();
|
||||||
|
|
||||||
// If there is a foreground window as top level...
|
// If there is a foreground window as top level...
|
||||||
if (toplevel_frame &&
|
if (toplevel_frame &&
|
||||||
|
@ -123,7 +123,7 @@ bool ColorButton::onProcessMessage(Message* msg)
|
|||||||
|
|
||||||
case JM_MOTION:
|
case JM_MOTION:
|
||||||
if (hasCapture()) {
|
if (hasCapture()) {
|
||||||
Widget* picked = ji_get_default_manager()->pick(msg->mouse.x, msg->mouse.y);
|
Widget* picked = getManager()->pick(msg->mouse.x, msg->mouse.y);
|
||||||
Color color = m_color;
|
Color color = m_color;
|
||||||
|
|
||||||
if (picked && picked != this) {
|
if (picked && picked != this) {
|
||||||
@ -248,7 +248,7 @@ void ColorButton::openSelectorDialog()
|
|||||||
|
|
||||||
m_frame->position_window(x, y);
|
m_frame->position_window(x, y);
|
||||||
|
|
||||||
jmanager_dispatch_messages(m_frame->getManager());
|
m_frame->getManager()->dispatchMessages();
|
||||||
m_frame->layout();
|
m_frame->layout();
|
||||||
|
|
||||||
/* setup the hot-region */
|
/* setup the hot-region */
|
||||||
|
@ -87,8 +87,8 @@ MovingPixelsState::MovingPixelsState(Editor* editor, Message* msg, PixelsMovemen
|
|||||||
// Add the current editor as filter for key message of the manager
|
// Add the current editor as filter for key message of the manager
|
||||||
// so we can catch the Enter key, and avoid to execute the
|
// so we can catch the Enter key, and avoid to execute the
|
||||||
// PlayAnimation command.
|
// PlayAnimation command.
|
||||||
jmanager_add_msg_filter(JM_KEYPRESSED, m_currentEditor);
|
m_currentEditor->getManager()->addMessageFilter(JM_KEYPRESSED, m_currentEditor);
|
||||||
jmanager_add_msg_filter(JM_KEYRELEASED, m_currentEditor);
|
m_currentEditor->getManager()->addMessageFilter(JM_KEYRELEASED, m_currentEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
MovingPixelsState::~MovingPixelsState()
|
MovingPixelsState::~MovingPixelsState()
|
||||||
@ -98,8 +98,8 @@ MovingPixelsState::~MovingPixelsState()
|
|||||||
|
|
||||||
delete m_pixelsMovement;
|
delete m_pixelsMovement;
|
||||||
|
|
||||||
jmanager_remove_msg_filter(JM_KEYPRESSED, m_currentEditor);
|
m_currentEditor->getManager()->removeMessageFilter(JM_KEYPRESSED, m_currentEditor);
|
||||||
jmanager_remove_msg_filter(JM_KEYRELEASED, m_currentEditor);
|
m_currentEditor->getManager()->removeMessageFilter(JM_KEYRELEASED, m_currentEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorState::BeforeChangeAction MovingPixelsState::onBeforeChangeState(Editor* editor, EditorState* newState)
|
EditorState::BeforeChangeAction MovingPixelsState::onBeforeChangeState(Editor* editor, EditorState* newState)
|
||||||
|
@ -780,9 +780,9 @@ bool StatusBar::onProcessMessage(Message* msg)
|
|||||||
if (hasChild(m_commandsBox)) {
|
if (hasChild(m_commandsBox)) {
|
||||||
// If we want restore the state-bar and the slider doesn't have
|
// If we want restore the state-bar and the slider doesn't have
|
||||||
// the capture...
|
// the capture...
|
||||||
if (jmanager_get_capture() != m_slider) {
|
if (getManager()->getCapture() != m_slider) {
|
||||||
// ...exit from command mode
|
// ...exit from command mode
|
||||||
jmanager_free_focus(); // TODO Review this code
|
getManager()->freeFocus(); // TODO Review this code
|
||||||
|
|
||||||
removeChild(m_commandsBox);
|
removeChild(m_commandsBox);
|
||||||
invalidate();
|
invalidate();
|
||||||
|
@ -382,7 +382,7 @@ bool Tabs::onProcessMessage(Message* msg)
|
|||||||
// Do nothing
|
// Do nothing
|
||||||
break;
|
break;
|
||||||
case ANI_SCROLL: {
|
case ANI_SCROLL: {
|
||||||
int dir = jmanager_get_capture() == m_button_left ? -1: 1;
|
int dir = (getManager()->getCapture() == m_button_left ? -1: 1);
|
||||||
setScrollX(m_scrollX + dir*8*msg->timer.count);
|
setScrollX(m_scrollX + dir*8*msg->timer.count);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -460,12 +460,12 @@ void ToolBar::openPopupFrame(int group_index, ToolGroup* tool_group)
|
|||||||
// Redraw the overlapped area and save it to use it in the ToolStrip::onProcessMessage(JM_DRAW)
|
// Redraw the overlapped area and save it to use it in the ToolStrip::onProcessMessage(JM_DRAW)
|
||||||
{
|
{
|
||||||
JRect rcTemp = jrect_new(rc.x, rc.y, rc.x+rc.w, rc.y+rc.h);
|
JRect rcTemp = jrect_new(rc.x, rc.y, rc.x+rc.w, rc.y+rc.h);
|
||||||
ji_get_default_manager()->invalidateRect(rcTemp);
|
getManager()->invalidateRect(rcTemp);
|
||||||
jrect_free(rcTemp);
|
jrect_free(rcTemp);
|
||||||
|
|
||||||
// Flush JM_DRAW messages and send them
|
// Flush JM_DRAW messages and send them
|
||||||
ji_get_default_manager()->flushRedraw();
|
getManager()->flushRedraw();
|
||||||
jmanager_dispatch_messages(ji_get_default_manager());
|
getManager()->dispatchMessages();
|
||||||
|
|
||||||
// Save the area
|
// Save the area
|
||||||
toolstrip->saveOverlappedArea(rc);
|
toolstrip->saveOverlappedArea(rc);
|
||||||
@ -604,8 +604,8 @@ void ToolBar::closeTipWindow()
|
|||||||
m_tipWindow = NULL;
|
m_tipWindow = NULL;
|
||||||
|
|
||||||
// Flush JM_DRAW messages and send them
|
// Flush JM_DRAW messages and send them
|
||||||
ji_get_default_manager()->flushRedraw();
|
getManager()->flushRedraw();
|
||||||
jmanager_dispatch_messages(ji_get_default_manager());
|
getManager()->dispatchMessages();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user