Fixed Ctrl/Shift buttons not lowering when clicked

This commit is contained in:
Sergii Pylypenko
2014-03-20 20:07:41 +02:00
parent 8602c3f8f8
commit dac6ac71da
2 changed files with 18 additions and 24 deletions

View File

@@ -1339,7 +1339,7 @@ public:
*/
bool IsButton(WidgetType type) const
{
return type == WWT_IMGBTN || type == WWT_IMGBTN_2 || type == WWT_PUSHIMGBTN;
return type == WWT_IMGBTN || type == WWT_IMGBTN_2 || type == WWT_PUSHIMGBTN || type == WWT_PUSHTXTBTN || type == WWT_TEXTBTN;
}
void SetupSmallestSize(Window *w, bool init_array)
@@ -1482,6 +1482,19 @@ public:
class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
/* virtual */ const byte *GetButtonArrangement(uint &width, uint &arrangable_count, uint &button_count, uint &spacer_count) const
{
#ifdef __ANDROID__
static const byte arrange_android[] = {
0, 1, 2, 4, 5, 6, 7, 8, 9, 14, 21, 22, 23, 24, 25, 19, 20, 29, 30, 31, 32,
0, 1, 3, 4, 5, 6, 7, 12, 15, 16, 17, 18, 26, 27, 28, 19, 20, 29, 30, 31, 32,
};
button_count = arrangable_count = lengthof(arrange_android) / 2;
spacer_count = this->spacers;
return &arrange_android[((_toolbar_mode == TB_LOWER) ? button_count : 0)];
#else
static const uint SMALLEST_ARRANGEMENT = 14;
static const uint BIGGEST_ARRANGEMENT = 20;
static const byte arrange14[] = {
@@ -1516,17 +1529,6 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
};
#ifdef __ANDROID__
static const byte arrange_android[] = {
0, 1, 2, 4, 5, 6, 7, 8, 9, 14, 21, 22, 23, 24, 25, 19, 20, 29, 30, 31, 32,
0, 1, 3, 4, 5, 6, 7, 12, 15, 16, 17, 18, 26, 27, 28, 19, 20, 29, 30, 31, 32,
};
button_count = arrangable_count = lengthof(arrange_android) / 2;
spacer_count = this->spacers;
return &arrange_android[((_toolbar_mode == TB_LOWER) ? button_count : 0)];
#else
/* If at least BIGGEST_ARRANGEMENT fit, just spread all the buttons nicely */
uint full_buttons = max(CeilDiv(width, this->smallest_x), SMALLEST_ARRANGEMENT);
@@ -1542,16 +1544,9 @@ class NWidgetMainToolbarContainer : public NWidgetToolbarContainer {
button_count = arrangable_count = full_buttons;
spacer_count = this->spacers;
return arrangements[full_buttons - SMALLEST_ARRANGEMENT] + ((_toolbar_mode == TB_LOWER) ? full_buttons : 0);
#endif
}
public:
int getWidgetCount() const
{
int count = 0;
for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next)
count++;
return count;
}
};
/** Container for the scenario editor's toolbar */
@@ -1938,9 +1933,9 @@ static NWidgetBase *MakeMainToolbar(int *biggest_index)
}
hor->Add(new NWidgetSpacer(0, 0));
hor->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TN_CTRL, STR_TABLET_CTRL, STR_TABLET_CTRL_TOOLTIP));
hor->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TN_SHIFT, STR_TABLET_SHIFT, STR_TABLET_SHIFT_TOOLTIP));
hor->Add(new NWidgetLeaf(WWT_TEXTBTN, COLOUR_GREY, WID_TN_DELETE, STR_TABLET_CLOSE, STR_TABLET_CLOSE_TOOLTIP));
hor->Add(new NWidgetLeaf(WWT_TEXTBTN, COLOUR_GREY, WID_TN_CTRL, STR_TABLET_CTRL, STR_TABLET_CTRL_TOOLTIP));
hor->Add(new NWidgetLeaf(WWT_TEXTBTN, COLOUR_GREY, WID_TN_SHIFT, STR_TABLET_SHIFT, STR_TABLET_SHIFT_TOOLTIP));
hor->Add(new NWidgetLeaf(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TN_DELETE, STR_TABLET_CLOSE, STR_TABLET_CLOSE_TOOLTIP));
*biggest_index = max<int>(*biggest_index, WID_TN_DELETE);
return hor;