[DEVELOPMENT ENVIRONMENT]

* BUG: Fix procedure list crash.

[GB.IMAGE]
* NEW: Color merge algorithm has changed. Instead of using the middle of 
  RGB values, now it uses the middle of HSV values. It changes the value of
  Color.LightForeground and the color used for drawing Workspace default
  background.

[GB.QT4]
* BUG: Separator and plain borders now use the same color.
* BUG: ShowPopup() now works correctly if used on the same window several 
  times.


git-svn-id: svn://localhost/gambas/trunk@3217 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2010-09-15 01:49:26 +00:00
parent 25882dd409
commit 2fa5d15318
16 changed files with 125 additions and 143 deletions

View file

@ -447,7 +447,7 @@ msgstr ""
msgid "System information"
msgstr ""
#: FAbout.class:622 FList.class:308 FMain.class:2502
#: FAbout.class:622 FList.class:308 FMain.class:2501
msgid "&Copy"
msgstr ""
@ -586,7 +586,7 @@ msgid ""
"You must resolve the conflict in order to use the file."
msgstr ""
#: FConflict.class:25 FMain.class:2475
#: FConflict.class:25 FMain.class:2474
msgid "&Edit"
msgstr ""
@ -917,7 +917,7 @@ msgstr ""
msgid "New file"
msgstr ""
#: FCreateFile.class:582 FMain.class:2380
#: FCreateFile.class:582 FMain.class:2379
msgid "New"
msgstr ""
@ -1195,7 +1195,7 @@ msgstr ""
msgid "Remove current expression"
msgstr ""
#: FDebugInfo.class:1086 FMain.class:2589 FMakeInstall.class:1605
#: FDebugInfo.class:1086 FMain.class:2588 FMakeInstall.class:1605
#: FOption.class:1579 FPropertyProject.class:1879
msgid "&Remove"
msgstr ""
@ -1263,7 +1263,7 @@ msgstr ""
msgid "Open form"
msgstr ""
#: FEditor.class:3297 FForm.class:3477 FMain.class:2542
#: FEditor.class:3297 FForm.class:3477 FMain.class:2541
msgid "&Startup class"
msgstr ""
@ -1351,7 +1351,7 @@ msgstr ""
msgid "Watch expression"
msgstr ""
#: FEditor.class:3661
#: FEditor.class:3662
msgid "Procedure list"
msgstr ""
@ -1968,7 +1968,7 @@ msgstr ""
msgid "Cl&ear"
msgstr ""
#: FList.class:314 FMain.class:2509
#: FList.class:314 FMain.class:2508
msgid "&Paste"
msgstr ""
@ -2220,83 +2220,83 @@ msgstr ""
msgid "&Preferences..."
msgstr ""
#: FMain.class:2384
#: FMain.class:2383
msgid "&Directory"
msgstr ""
#: FMain.class:2390
#: FMain.class:2389
msgid "&Project link..."
msgstr ""
#: FMain.class:2400
#: FMain.class:2399
msgid "&Module..."
msgstr ""
#: FMain.class:2408
#: FMain.class:2407
msgid "&Class..."
msgstr ""
#: FMain.class:2416
#: FMain.class:2415
msgid "&Form..."
msgstr ""
#: FMain.class:2424
#: FMain.class:2423
msgid "&WebPage..."
msgstr ""
#: FMain.class:2432
#: FMain.class:2431
msgid "&Report..."
msgstr ""
#: FMain.class:2443
#: FMain.class:2442
msgid "&Image..."
msgstr ""
#: FMain.class:2450
#: FMain.class:2449
msgid "&HTML file..."
msgstr ""
#: FMain.class:2457
#: FMain.class:2456
msgid "&Style sheet..."
msgstr ""
#: FMain.class:2465
#: FMain.class:2464
msgid "&Other..."
msgstr ""
#: FMain.class:2480
#: FMain.class:2479
msgid "Edit &code"
msgstr ""
#: FMain.class:2484
#: FMain.class:2483
msgid "Edit with"
msgstr ""
#: FMain.class:2495
#: FMain.class:2494
msgid "&Cut"
msgstr ""
#: FMain.class:2516
#: FMain.class:2515
msgid "&Rename..."
msgstr ""
#: FMain.class:2523
#: FMain.class:2522
msgid "&Delete..."
msgstr ""
#: FMain.class:2533
#: FMain.class:2532
msgid "Copy file pat&h"
msgstr ""
#: FMain.class:2550
#: FMain.class:2549
msgid "&Add to repository"
msgstr ""
#: FMain.class:2575
#: FMain.class:2574
msgid "&New connection..."
msgstr ""
#: FMain.class:2583
#: FMain.class:2582
msgid "&Open"
msgstr ""

View file

@ -340,6 +340,7 @@
}
{ btnProc ToolButton
MoveScaled(65,0,46,4)
Mouse = Mouse.Pointing
Action = ".proc"
Text = ("Procedure list")
Picture = Picture["img/16/procedure.png"]

View file

@ -100,7 +100,7 @@ Public Sub gvwProc_KeyPress()
End
Public Sub Form_Open()
gvwProc.SetFocus
End

View file

@ -2,6 +2,7 @@
{ Form Form
MoveScaled(0,0,37,47)
Persistent = True
Resizable = False
Arrangement = Arrange.Fill
{ panProc Panel

View file

@ -277,7 +277,6 @@
}
{ mnuPopup Menu
Enabled = False
Visible = False
{ mnuNew Menu
Text = ("New")
{ mnuAddDirectory Menu
@ -475,6 +474,7 @@
}
}
{ mnuMenu Menu
Visible = False
{ mnuFile2 Menu
Text = ("&File")
}

View file

@ -225,28 +225,13 @@ gColor gDesktop::selbgColor()
gColor gDesktop::lightbgColor()
{
int h, s, v;
int h2, s2, v2;
int r, g, b;
gt_color_to_rgb(gDesktop::selbgColor(), &r, &g, &b);
gt_rgb_to_hsv(r, g, b, &h, &s, &v);
gt_color_to_rgb(gDesktop::textbgColor(), &r, &g, &b);
gt_rgb_to_hsv(r, g, b, &h2, &s2, &v2);
gt_hsv_to_rgb(h, (s2 * 3 + s) / 4, (v2 * 3 + v) / 4, &r, &g, &b);
return gt_rgb_to_color(r, g, b);
uint col = IMAGE.MergeColor(gDesktop::selbgColor(), gDesktop::selfgColor(), 0.2);
return col;
}
gColor gDesktop::lightfgColor()
{
uint col;
col = IMAGE.MergeColor(gDesktop::bgColor(), gDesktop::fgColor(), 0.5);
col = IMAGE.LighterColor(col);
uint col = IMAGE.MergeColor(gDesktop::bgColor(), gDesktop::fgColor(), 0.2);
return col;
}

View file

@ -31,13 +31,14 @@
#include "CWidget.h"
#include "CColor.h"
static int _h = 0;
static int _s = 0;
static int _v = 0;
QColor CCOLOR_merge(const QColor &colorA, const QColor &colorB, int factor)
QColor CCOLOR_merge(const QColor &colorA, const QColor &colorB, double factor)
{
return QColor(IMAGE.MergeColor(colorA.rgba(), colorB.rgba(), factor / 100.0));
return QColor(IMAGE.MergeColor(colorA.rgba(), colorB.rgba(), factor));
}
QColor CCOLOR_light_foreground()
{
return CCOLOR_merge(qApp->palette().color(QPalette::Window), qApp->palette().color(QPalette::WindowText), 0.2);
}
QColor CCOLOR_make(GB_COLOR color)
@ -50,21 +51,6 @@ QColor CCOLOR_make(GB_COLOR color)
return QColor(r, g, b, a);
}
static void get_hsv(int col)
{
static int last = 0;
if (last == col)
return;
QColor c(col);
c.getHsv(&_h, &_s, &_v);
if (_h < 0)
_h = 0;
last = col;
}
static void return_color(QPalette::ColorRole role)
{
GB.ReturnInteger(QApplication::palette().color(role).rgb() & 0xFFFFFF);
@ -100,22 +86,6 @@ BEGIN_PROPERTY(CCOLOR_selected_background)
END_PROPERTY
BEGIN_PROPERTY(CCOLOR_light_background)
QColor col;
int h, s, v;
get_hsv(QApplication::palette().color(QPalette::Highlight).rgb() & 0xFFFFFF);
h = _h; s = _s; v = _v;
get_hsv(QApplication::palette().color(QPalette::Base).rgb() & 0xFFFFFF);
col = QColor::fromHsv(h, (_s * 3 + s) / 4, (_v * 3 + v) / 4);
GB.ReturnInteger((uint)col.rgb() & 0xFFFFFF);
END_PROPERTY
BEGIN_PROPERTY(CCOLOR_selected_foreground)
return_color(QPalette::HighlightedText);
@ -134,13 +104,16 @@ BEGIN_PROPERTY(CCOLOR_button_foreground)
END_PROPERTY
BEGIN_PROPERTY(CCOLOR_light_foreground)
BEGIN_PROPERTY(Color_LightBackground)
uint col;
col = IMAGE.MergeColor(qApp->palette().color(QPalette::Window).rgb() & 0xFFFFFF, qApp->palette().color(QPalette::WindowText).rgb() & 0xFFFFFF, 0.5);
col = IMAGE.LighterColor(col);
uint col = IMAGE.MergeColor(qApp->palette().color(QPalette::Base).rgb() & 0xFFFFFF, qApp->palette().color(QPalette::Highlight).rgb() & 0xFFFFFF, 0.5);
GB.ReturnInteger(col);
END_PROPERTY
BEGIN_PROPERTY(Color_LightForeground)
uint col = IMAGE.MergeColor(qApp->palette().color(QPalette::Window).rgb() & 0xFFFFFF, qApp->palette().color(QPalette::WindowText).rgb() & 0xFFFFFF, 0.3);
GB.ReturnInteger(col);
END_PROPERTY
@ -151,12 +124,12 @@ GB_DESC CColorDesc[] =
GB_STATIC_PROPERTY("Background", "i", CCOLOR_background),
GB_STATIC_PROPERTY("SelectedBackground", "i", CCOLOR_selected_background),
GB_STATIC_PROPERTY("LightBackground", "i", CCOLOR_light_background),
GB_STATIC_PROPERTY("LightBackground", "i", Color_LightBackground),
GB_STATIC_PROPERTY("TextBackground", "i", CCOLOR_text_background),
GB_STATIC_PROPERTY("ButtonBackground", "i", CCOLOR_button_background),
GB_STATIC_PROPERTY("Foreground", "i", CCOLOR_foreground),
GB_STATIC_PROPERTY("LightForeground", "i", CCOLOR_light_foreground),
GB_STATIC_PROPERTY("LightForeground", "i", Color_LightForeground),
GB_STATIC_PROPERTY("SelectedForeground", "i", CCOLOR_selected_foreground),
GB_STATIC_PROPERTY("TextForeground", "i", CCOLOR_text_foreground),
GB_STATIC_PROPERTY("ButtonForeground", "i", CCOLOR_button_foreground),

View file

@ -30,7 +30,8 @@
extern GB_DESC CColorDesc[];
#endif
QColor CCOLOR_merge(const QColor &colorA, const QColor &colorB, int factor = 50);
QColor CCOLOR_merge(const QColor &colorA, const QColor &colorB, double factor = 0.5);
QColor CCOLOR_make(GB_COLOR color);
QColor CCOLOR_light_foreground();
#endif

View file

@ -556,7 +556,7 @@ void CCONTAINER_draw_frame(QPainter *p, int frame, QStyleOptionFrame &opt, QWidg
switch (frame)
{
case BORDER_PLAIN:
qDrawPlainRect(p, opt.rect, CCOLOR_merge(opt.palette.color(QPalette::Window), opt.palette.color(QPalette::WindowText)).lighter(), 1);
qDrawPlainRect(p, opt.rect, CCOLOR_light_foreground());
//p->setPen(opt.palette.windowText().color());
break;

View file

@ -383,7 +383,7 @@ void MySeparator::paintEvent( QPaintEvent * )
//if (width() == 1 || height() == 1)
{
p.setPen(CCOLOR_merge(palette().color(QPalette::Window), palette().color(QPalette::WindowText)).lighter());
p.setPen(CCOLOR_light_foreground());
if (width() >= height())
p.drawLine(0, height() / 2, width() - 1, height() / 2);
else

View file

@ -365,8 +365,8 @@ BEGIN_PROPERTY(CMENU_text)
else
{
QString text = QSTRING_PROP();
ACTION->setSeparator(text.isNull());
ACTION->setText(text);
ACTION->setSeparator(text.isNull());
refresh_menubar(THIS);
}

View file

@ -1549,8 +1549,8 @@ BEGIN_PROPERTY(CWIDGET_scrollbar)
END_PROPERTY
BEGIN_METHOD_VOID(Control_Grab)
void CWIDGET_grab(CWIDGET *_object)
{
QEventLoop eventLoop;
QEventLoop *old;
@ -1570,6 +1570,12 @@ BEGIN_METHOD_VOID(Control_Grab)
WIDGET->releaseKeyboard();
THIS->flag.grab = false;
}
BEGIN_METHOD_VOID(Control_Grab)
CWIDGET_grab(THIS);
END_METHOD

View file

@ -181,7 +181,7 @@ int CWIDGET_get_foreground(CWIDGET *_object);
void *CWIDGET_get_parent(void *_object);
void CWIDGET_set_visible(CWIDGET *_object, bool v);
void CWIDGET_check_hovered();
void CWIDGET_grab(CWIDGET *_object);
void CWIDGET_move(void *_object, int x, int y);
void CWIDGET_resize(void *_object, int w, int h);
void CWIDGET_move_resize(void *_object, int x, int y, int w, int h);

View file

@ -83,7 +83,6 @@ enum
};
#endif
//#define DEBUG_WINDOW 1
DECLARE_EVENT(EVENT_Open);
@ -624,8 +623,6 @@ static bool do_close(CWINDOW *_object, int ret, bool destroyed = false)
if (closed)
THIS->ret = ret;
//qDebug("CWINDOW_close: ret = %d", THIS->ret);
return (!closed);
}
@ -1549,6 +1546,7 @@ MyMainWindow::MyMainWindow(QWidget *parent, const char *name, bool embedded) :
mustCenter = false;
_deleted = false;
_type = _NET_WM_WINDOW_TYPE_NORMAL;
_enterLoop = false;
setAttribute(Qt::WA_KeyCompression, true);
setAttribute(Qt::WA_InputMethodEnabled, true);
@ -1620,6 +1618,13 @@ void MyMainWindow::showEvent(QShowEvent *e)
}
}
void MyMainWindow::hideEvent(QHideEvent *e)
{
if (isModal() && _enterLoop)
MyApplication::eventLoop->exit();
}
void MyMainWindow::initProperties()
{
#ifndef NO_X_WINDOW
@ -1659,6 +1664,9 @@ void MyMainWindow::showActivate(QWidget *transient)
// Reparent the window if, for example, there is an already modal window displayed
setWindowFlags(Qt::Window);
setWindowModality(Qt::NonModal);
if (CWINDOW_Current && THIS != CWINDOW_Current)
{
newParentWidget = CWINDOW_Current->widget.widget;
@ -1778,6 +1786,7 @@ void MyMainWindow::showModal(void)
X11_set_transient_for(winId(), CWINDOW_Active->widget.widget->winId());
#endif
setWindowFlags(Qt::Window);
setWindowModality(Qt::ApplicationModal);
if (_resizable && _border)
@ -1786,7 +1795,7 @@ void MyMainWindow::showModal(void)
setSizeGrip(true);
}
THIS->enterLoop = false; // Do not call exitLoop() if we do not entered the loop yet!
_enterLoop = false; // Do not call exitLoop() if we do not entered the loop yet!
show();
afterShow();
@ -1794,7 +1803,7 @@ void MyMainWindow::showModal(void)
THIS->loopLevel++;
CWINDOW_Current = THIS;
THIS->enterLoop = true;
_enterLoop = true;
eventLoop.exec();
//eventLoop.processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::DeferredDeletion, 0);
@ -1817,35 +1826,25 @@ void MyMainWindow::showPopup(QPoint &pos)
CWIDGET *_object = CWidget::get(this);
bool persistent = CWIDGET_test_flag(THIS, WF_PERSISTENT);
CWINDOW *save = CWINDOW_Current;
QEventLoop *old;
QEventLoop eventLoop;
//if (isModal())
//return;
old = MyApplication::eventLoop;
MyApplication::eventLoop = &eventLoop;
#ifndef NO_X_WINDOW
if (CWINDOW_Active)
X11_set_transient_for(winId(), CWINDOW_Active->widget.widget->winId());
//setAttribute(Qt::WA_X11NetWmWindowTypePopupMenu, true);
#endif
if (isModal())
return;
setWindowFlags(Qt::Popup);
setWindowModality(Qt::ApplicationModal);
if (_resizable && _border)
/*if (_resizable && _border)
{
setMinimumSize(THIS->minw, THIS->minh);
setSizeGrip(true);
}
}*/
THIS->enterLoop = false; // Do not call exitLoop() if we do not entered the loop yet!
_enterLoop = false; // Do not call exitLoop() if we do not entered the loop yet!
move(0, 0);
move(pos);
show();
raise();
if (THIS->focus)
handle_focus(THIS);
else
@ -1859,19 +1858,35 @@ void MyMainWindow::showPopup(QPoint &pos)
//handle_focus(THIS);
//activateWindow();
THIS->enterLoop = true;
_enterLoop = true;
QEventLoop eventLoop;
QEventLoop *old;
old = MyApplication::eventLoop;
MyApplication::eventLoop = &eventLoop;
eventLoop.exec();
MyApplication::eventLoop = old;
//eventLoop.exec();
//eventLoop.processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::DeferredDeletion, 0);
MyApplication::eventLoop = old;
CWINDOW_Current = save;
if (persistent)
{
setSizeGrip(false);
QRect g = geometry();
//setSizeGrip(false);
setWindowModality(Qt::NonModal);
setWindowFlags(flags);
/*setGeometry(0,0,1,1);
//setWindowFlags(Qt::Window);
THIS->opened = true;
show();
THIS->opened = false;
hide();
setGeometry(g.x(), g.y(), g.width(), g.height());*/
//setWindowFlags(Qt::Window);
//THIS->hidden = true;
//doReparent(parentWidget(), flags, this->pos());
//#ifndef NO_X_WINDOW
//setAttribute(Qt::WA_X11NetWmWindowTypePopupMenu, false);
//#endif
@ -2215,7 +2230,9 @@ void MyMainWindow::closeEvent(QCloseEvent *e)
e->ignore();
//qDebug("closeEvent: CWINDOW_Current = %p / %d <-> %p / %d", CWINDOW_Current, CWINDOW_Current ? CWINDOW_Current->loopLevel : -1, THIS, THIS->loopLevel);
#if DEBUG_WINDOW
qDebug("closeEvent: CWINDOW_Current = %p / %d <-> %p / %d", CWINDOW_Current, CWINDOW_Current ? CWINDOW_Current->loopLevel : -1, THIS, THIS->loopLevel);
#endif
if (THIS->opened)
{
@ -2270,16 +2287,11 @@ void MyMainWindow::closeEvent(QCloseEvent *e)
CWINDOW_LastActive = NULL;
//qDebug("CWINDOW_LastActive = 0");
}
//qDebug("THIS->opened <- false: %p: %s", THIS, GB.GetClassName(THIS));
#if DEBUG_WINDOW
qDebug("THIS->opened <- false: %p: %s", THIS, GB.GetClassName(THIS));
#endif
THIS->opened = false;
//qDebug("THIS->enterLoop = %d", THIS->enterLoop);
if (modal && THIS->enterLoop)
{
//qDebug("exitLoop: %p", THIS);
MyApplication::eventLoop->exit();
}
return;
IGNORE:
@ -2399,7 +2411,6 @@ void MyMainWindow::configure()
{
CWINDOW *_object = (CWINDOW *)CWidget::get(this);
QMenuBar *menuBar = THIS->menuBar;
int h;
//qDebug("THIS->menuBar = %p menuBar() = %p", THIS->menuBar, menuBar());

View file

@ -78,7 +78,6 @@ typedef
unsigned scale : 1;
unsigned minsize : 1;
unsigned title : 1;
unsigned enterLoop : 1;
unsigned stateChange : 1;
//unsigned opening : 1;
unsigned closing : 1;
@ -161,6 +160,7 @@ private:
bool _border;
bool _resizable;
bool _deleted;
bool _enterLoop;
int _type;
void doReparent(QWidget *, Qt::WFlags, const QPoint &);
@ -168,7 +168,7 @@ private:
protected:
virtual void showEvent(QShowEvent *);
//void hideEvent(QHideEvent *);
virtual void hideEvent(QHideEvent *);
virtual void resizeEvent(QResizeEvent *);
virtual void moveEvent(QMoveEvent *);
virtual void keyPressEvent(QKeyEvent *);

View file

@ -182,7 +182,9 @@ void COLOR_hsv_to_rgb(int h, int s, int v, int *R, int *G, int *B)
GB_COLOR COLOR_merge(GB_COLOR col1, GB_COLOR col2, double weight)
{
int a, r, g, b;
int r, g, b;
int h1, s1, v1, a1;
int h2, s2, v2, a2;
if (weight == 0.0)
return col1;
@ -190,14 +192,16 @@ GB_COLOR COLOR_merge(GB_COLOR col1, GB_COLOR col2, double weight)
return col2;
else
{
#define MIX_COLOR(_shift) (int)((((col2 >> _shift) & 0xFF) * weight + ((col1 >> _shift) & 0xFF) * (1 - weight)) + 0.5)
gt_color_to_rgba(col1, &r, &g, &b, &a1);
COLOR_rgb_to_hsv(r, g, b, &h1, &s1, &v1);
gt_color_to_rgba(col2, &r, &g, &b, &a2);
COLOR_rgb_to_hsv(r, g, b, &h2, &s2, &v2);
a = MIX_COLOR(24);
r = MIX_COLOR(16);
g = MIX_COLOR(8);
b = MIX_COLOR(0);
#define MIX(_val1, _val2) ((int)((_val1) * (1 - weight) + (_val2) * weight + 0.5))
return gt_rgba_to_color(r, g, b, a);
COLOR_hsv_to_rgb(MIX(h1, h2), MIX(s1, s2), MIX(v1, v2), &r, &g, &b);
return gt_rgba_to_color(r, g, b, MIX(a1, a2));
}
}