summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ai/ai_gui.cpp38
-rw-r--r--src/airport_gui.cpp4
-rw-r--r--src/autoreplace_gui.cpp2
-rw-r--r--src/bridge_gui.cpp2
-rw-r--r--src/build_vehicle_gui.cpp11
-rw-r--r--src/cheat_gui.cpp2
-rw-r--r--src/company_gui.cpp10
-rw-r--r--src/date_gui.cpp2
-rw-r--r--src/depot_gui.cpp2
-rw-r--r--src/dock_gui.cpp6
-rw-r--r--src/engine_gui.cpp2
-rw-r--r--src/genworld_gui.cpp6
-rw-r--r--src/graph_gui.cpp12
-rw-r--r--src/group_gui.cpp2
-rw-r--r--src/highscore_gui.cpp2
-rw-r--r--src/industry_gui.cpp13
-rw-r--r--src/intro_gui.cpp2
-rw-r--r--src/misc_gui.cpp6
-rw-r--r--src/music_gui.cpp4
-rw-r--r--src/network/network_chat_gui.cpp2
-rw-r--r--src/network/network_content_gui.cpp15
-rw-r--r--src/network/network_gui.cpp37
-rw-r--r--src/newgrf_gui.cpp19
-rw-r--r--src/news_gui.cpp6
-rw-r--r--src/order_gui.cpp2
-rw-r--r--src/osk_gui.cpp6
-rw-r--r--src/rail_gui.cpp10
-rw-r--r--src/road_gui.cpp6
-rw-r--r--src/settings_gui.cpp8
-rw-r--r--src/signs_gui.cpp4
-rw-r--r--src/smallmap_gui.cpp2
-rw-r--r--src/station_gui.cpp6
-rw-r--r--src/statusbar_gui.cpp2
-rw-r--r--src/subsidy_gui.cpp2
-rw-r--r--src/terraform_gui.cpp4
-rw-r--r--src/timetable_gui.cpp2
-rw-r--r--src/toolbar_gui.cpp4
-rw-r--r--src/town_gui.cpp13
-rw-r--r--src/transparency_gui.cpp2
-rw-r--r--src/tree_gui.cpp2
-rw-r--r--src/vehicle_gui.cpp18
-rw-r--r--src/viewport_gui.cpp2
-rw-r--r--src/waypoint_gui.cpp2
-rw-r--r--src/widgets/dropdown.cpp2
-rw-r--r--src/window.cpp148
-rw-r--r--src/window_gui.h10
46 files changed, 191 insertions, 273 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index cb1381a36..33286f500 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -149,7 +149,7 @@ struct AIListWindow : public Window {
SetWindowDirty(WC_GAME_OPTIONS, 0);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case AIL_WIDGET_LIST: { // Select one of the AIs
@@ -157,6 +157,10 @@ struct AIListWindow : public Window {
if (sel < (int)this->ai_info_list->size()) {
this->selected = sel;
this->SetDirty();
+ if (click_count > 1) {
+ this->ChangeAI();
+ delete this;
+ }
}
break;
}
@@ -173,21 +177,6 @@ struct AIListWindow : public Window {
}
}
- virtual void OnDoubleClick(Point pt, int widget)
- {
- switch (widget) {
- case AIL_WIDGET_LIST: {
- int sel = (pt.y - this->GetWidget<NWidgetBase>(AIL_WIDGET_LIST)->pos_y) / this->line_height + this->vscroll.GetPosition() - 1;
- if (sel < (int)this->ai_info_list->size()) {
- this->selected = sel;
- this->ChangeAI();
- delete this;
- }
- break;
- }
- }
- }
-
virtual void OnResize()
{
NWidgetCore *nwi = this->GetWidget<NWidgetCore>(AIL_WIDGET_LIST);
@@ -332,7 +321,7 @@ struct AISettingsWindow : public Window {
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case AIS_WIDGET_BACKGROUND: {
@@ -588,7 +577,7 @@ struct AIConfigWindow : public Window {
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case AIC_WIDGET_DECREASE:
@@ -607,6 +596,7 @@ struct AIConfigWindow : public Window {
case AIC_WIDGET_LIST: { // Select a slot
this->selected_slot = (CompanyID)((pt.y - this->GetWidget<NWidgetBase>(widget)->pos_y) / this->line_height + this->vscroll.GetPosition());
this->InvalidateData();
+ if (click_count > 1 && this->selected_slot != INVALID_COMPANY) ShowAIListWindow((CompanyID)this->selected_slot);
break;
}
@@ -652,16 +642,6 @@ struct AIConfigWindow : public Window {
}
}
- virtual void OnDoubleClick(Point pt, int widget)
- {
- switch (widget) {
- case AIC_WIDGET_LIST:
- this->OnClick(pt, widget);
- if (this->selected_slot != INVALID_COMPANY) ShowAIListWindow((CompanyID)this->selected_slot);
- break;
- }
- }
-
virtual void OnInvalidateData(int data)
{
if (this->selected_slot == 0 || this->selected_slot > _settings_newgame.difficulty.max_no_competitors) {
@@ -911,7 +891,7 @@ struct AIDebugWindow : public Window {
DeleteWindowByClass(WC_AI_SETTINGS);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
/* Check which button is clicked */
if (IsInsideMM(widget, AID_WIDGET_COMPANY_BUTTON_START, AID_WIDGET_COMPANY_BUTTON_END + 1)) {
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index 6c036dd21..e3a9b4755 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -90,7 +90,7 @@ struct BuildAirToolbarWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (!IsInsideBS(widget, ATW_AIRPORT, lengthof(_build_air_button_proc))) return;
@@ -257,7 +257,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case BAW_SMALL_AIRPORT: case BAW_CITY_AIRPORT: case BAW_HELIPORT: case BAW_METRO_AIRPORT:
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index e318fe7c0..091ac854b 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -399,7 +399,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case RVW_WIDGET_TRAIN_ENGINEWAGON_TOGGLE:
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index 6ea3396d1..3df90abe0 100644
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -243,7 +243,7 @@ public:
return ES_NOT_HANDLED;
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
default: break;
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index a68ab9f23..0693d84e9 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -1002,7 +1002,7 @@ struct BuildVehicleWindow : Window {
this->eng_list.RebuildDone();
}
- void OnClick(Point pt, int widget)
+ void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING:
@@ -1017,6 +1017,7 @@ struct BuildVehicleWindow : Window {
size_t num_items = this->eng_list.Length();
this->sel_engine = (i < num_items) ? this->eng_list[i] : INVALID_ENGINE;
this->SetDirty();
+ if (click_count > 1) this->OnClick(pt, BUILD_VEHICLE_WIDGET_BUILD, 1);
break;
}
@@ -1128,14 +1129,6 @@ struct BuildVehicleWindow : Window {
}
}
- virtual void OnDoubleClick(Point pt, int widget)
- {
- if (widget == BUILD_VEHICLE_WIDGET_LIST) {
- /* When double clicking, we want to buy a vehicle */
- this->OnClick(pt, BUILD_VEHICLE_WIDGET_BUILD);
- }
- }
-
virtual void OnQueryTextFinished(char *str)
{
if (str == NULL) return;
diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp
index 23e8cc7f7..78dbf4906 100644
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -271,7 +271,7 @@ struct CheatWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(CW_PANEL);
uint btn = (pt.y - wid->pos_y - WD_FRAMERECT_TOP - this->header_height) / (FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL);
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index 786c7ff4c..04795a512 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -433,7 +433,7 @@ struct CompanyFinancesWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case CFW_TOGGLE_SIZE: // toggle size
@@ -729,7 +729,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
/* Livery Class buttons */
@@ -1393,7 +1393,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
/* Toggle size, advanced/simple face selection */
@@ -1916,7 +1916,7 @@ struct CompanyWindow : Window
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case CW_WIDGET_NEW_FACE: DoSelectCompanyManagerFace(this); break;
@@ -2115,7 +2115,7 @@ struct BuyCompanyWindow : Window {
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case BCW_NO:
diff --git a/src/date_gui.cpp b/src/date_gui.cpp
index 749b15c62..22fbc2085 100644
--- a/src/date_gui.cpp
+++ b/src/date_gui.cpp
@@ -151,7 +151,7 @@ struct SetDateWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case SDW_DAY:
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index ee413dd59..6a5d53592 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -711,7 +711,7 @@ struct DepotWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case DEPOT_WIDGET_MATRIX: { // List
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index bdbb12c1f..1b2336ef8 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -181,7 +181,7 @@ struct BuildDocksToolbarWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget >= DTW_BUTTONS_BEGIN) _build_docks_button_proc[widget - DTW_BUTTONS_BEGIN](this);
}
@@ -372,7 +372,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case BDSW_LT_OFF:
@@ -457,7 +457,7 @@ public:
DrawShipDepotSprite(this->GetWidget<NWidgetBase>(BDDW_Y)->pos_x + 64, this->GetWidget<NWidgetBase>(BDDW_Y)->pos_y + 34, 3);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case BDDW_X:
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index 5ca6e873a..d8dc95695 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -106,7 +106,7 @@ struct EnginePreviewWindow : Window {
DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, r.bottom, GetEngineInfoString(engine), TC_FROMSTRING, SA_CENTER);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case EPW_YES:
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 672936e31..5efbe7271 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -519,7 +519,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
this->DrawEditBox(GLAND_RANDOM_EDITBOX);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case GLAND_TEMPERATE:
@@ -921,7 +921,7 @@ struct CreateScenarioWindow : public Window
size->height += padding.height;
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case CSCEN_TEMPERATE:
@@ -1161,7 +1161,7 @@ struct GenerateProgressWindow : public Window {
this->InitNested(&_generate_progress_desc);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case GPWW_ABORT:
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 5f07a2b45..25be17634 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -81,7 +81,7 @@ struct GraphLegendWindow : Window {
DrawString(r.left + (rtl ? WD_FRAMERECT_LEFT : 19), r.right - (rtl ? 19 : WD_FRAMERECT_RIGHT), r.top + WD_FRAMERECT_TOP, STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (!IsInsideMM(widget, GLW_FIRST_COMPANY, MAX_COMPANIES + GLW_FIRST_COMPANY)) return;
@@ -513,7 +513,7 @@ public:
return INVALID_DATAPOINT;
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
/* Clicked on legend? */
if (widget == BGW_KEY_BUTTON) ShowGraphLegend();
@@ -725,10 +725,10 @@ struct PerformanceHistoryGraphWindow : BaseGraphWindow {
return c->old_economy[j].performance_history;
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget == PHW_DETAILED_PERFORMANCE) ShowPerformanceRatingDetail();
- this->BaseGraphWindow::OnClick(pt, widget);
+ this->BaseGraphWindow::OnClick(pt, widget, click_count);
}
};
@@ -874,7 +874,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
DrawString(rtl ? r.left : x + 14 + clk_dif, (rtl ? r.right - 14 + clk_dif : r.right), y + clk_dif, STR_GRAPH_CARGO_PAYMENT_CARGO);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget >= CPW_CARGO_FIRST) {
int i = 0;
@@ -1330,7 +1330,7 @@ struct PerformanceRatingDetailWindow : Window {
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
/* Check which button is clicked */
if (IsInsideMM(widget, PRW_COMPANY_FIRST, PRW_COMPANY_LAST + 1)) {
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index d5f54826b..3e5a30e9d 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -421,7 +421,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case GRP_WIDGET_SORT_BY_ORDER: // Flip sorting method ascending/descending
diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp
index c65a5eaf8..94486a4f2 100644
--- a/src/highscore_gui.cpp
+++ b/src/highscore_gui.cpp
@@ -59,7 +59,7 @@ struct EndGameHighScoreBaseWindow : Window {
return pt;
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
delete this;
}
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 97b238037..e5902c490 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -391,13 +391,7 @@ public:
this->DrawWidgets();
}
- virtual void OnDoubleClick(Point pt, int widget)
- {
- if (widget != DPIW_MATRIX_WIDGET) return;
- this->OnClick(pt, DPIW_FUND_WIDGET);
- }
-
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case DPIW_MATRIX_WIDGET: {
@@ -419,6 +413,7 @@ public:
}
this->SetWidgetDisabledState(DPIW_FUND_WIDGET, !this->enabled[this->selected_index]);
+ if (this->enabled[this->selected_index] && click_count > 1) this->OnClick(pt, DPIW_FUND_WIDGET, 1);
}
} break;
@@ -703,7 +698,7 @@ public:
if (widget == IVW_INFO) size->height = this->info_height;
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
Industry *i;
@@ -1105,7 +1100,7 @@ public:
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case IDW_DROPDOWN_ORDER:
diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp
index a643257fa..863ab6b37 100644
--- a/src/intro_gui.cpp
+++ b/src/intro_gui.cpp
@@ -97,7 +97,7 @@ struct SelectGameWindow : public Window {
*size = maxdim(*size, textdim);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
#ifdef ENABLE_NETWORK
/* Do not create a network server when you (just) have closed one of the game
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 6ecfe45b5..e9a33c015 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -1285,7 +1285,7 @@ struct QueryStringWindow : public QueryStringBaseWindow
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case QUERY_STR_WIDGET_DEFAULT:
@@ -1450,7 +1450,7 @@ struct QueryWindow : public Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case QUERY_WIDGET_YES: {
@@ -1802,7 +1802,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case SLWW_SORT_BYNAME: // Sort save names by name
diff --git a/src/music_gui.cpp b/src/music_gui.cpp
index 333e40e33..4ede5801e 100644
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -397,7 +397,7 @@ struct MusicTrackSelectionWindow : public Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case MTSW_LIST_LEFT: { // add to playlist
@@ -643,7 +643,7 @@ struct MusicWindow : public Window {
this->SetDirty();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case MW_PREV: // skip to prev
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index f10d51a2b..e9f92b784 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -480,7 +480,7 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, this->dest_string, TC_BLACK, SA_RIGHT);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
/* Send */
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index e4209d0e5..bb77aea6d 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -164,7 +164,7 @@ public:
DrawStringMultiLine(r.left + 2, r.right - 2, y, y + FONT_HEIGHT_NORMAL * 2, str, TC_FROMSTRING, SA_CENTER);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget == NCDSWW_CANCELOK) {
if (this->downloaded_bytes != this->total_bytes) _network_content_client.Close();
@@ -583,16 +583,7 @@ public:
}
}
- virtual void OnDoubleClick(Point pt, int widget)
- {
- /* Double clicking on a line in the matrix toggles the state of the checkbox */
- if (widget != NCLWW_MATRIX) return;
-
- pt.x = this->GetWidget<NWidgetBase>(NCLWW_CHECKBOX)->pos_x;
- this->OnClick(pt, widget);
- }
-
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case NCLWW_MATRIX: {
@@ -607,7 +598,7 @@ public:
this->list_pos = id_v;
const NWidgetBase *checkbox = this->GetWidget<NWidgetBase>(NCLWW_CHECKBOX);
- if (IsInsideBS(pt.x, checkbox->pos_x, checkbox->current_x)) {
+ if (click_count > 1 || IsInsideBS(pt.x, checkbox->pos_x, checkbox->current_x)) {
_network_content_client.ToggleSelectedState(this->selected);
this->content.ForceResort();
}
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index d8c8dd390..d14657b5a 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -658,7 +658,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
this->field = widget;
switch (widget) {
@@ -697,6 +697,9 @@ public:
this->server = (id_v < this->servers.Length()) ? this->servers[id_v] : NULL;
this->list_pos = (server == NULL) ? SLP_INVALID : id_v;
this->SetDirty();
+
+ /* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
+ if (!this->IsWidgetDisabled(NGWW_JOIN)) this->OnClick(pt, NGWW_JOIN, 1);
} break;
case NGWW_LASTJOINED: {
@@ -713,6 +716,9 @@ public:
}
this->ScrollToSelectedServer();
this->SetDirty();
+
+ /* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
+ if (!this->IsWidgetDisabled(NGWW_JOIN)) this->OnClick(pt, NGWW_JOIN, 1);
}
} break;
@@ -755,14 +761,6 @@ public:
}
}
- virtual void OnDoubleClick(Point pt, int widget)
- {
- if (widget == NGWW_MATRIX || widget == NGWW_LASTJOINED) {
- /* is the Join button enabled? */
- if (!this->IsWidgetDisabled(NGWW_JOIN)) this->OnClick(pt, NGWW_JOIN);
- }
- }
-
virtual void OnDropdownSelect(int widget, int index)
{
switch (widget) {
@@ -1157,7 +1155,7 @@ struct NetworkStartServerWindow : public QueryStringBaseWindow {
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
this->field = widget;
switch (widget) {
@@ -1621,7 +1619,7 @@ struct NetworkLobbyWindow : public Window {
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_NETWORK_GAME_LOBBY_PLAYERS); // players
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case NLWW_CANCEL: // Cancel button
@@ -1636,6 +1634,9 @@ struct NetworkLobbyWindow : public Window {
id_v += this->vscroll.GetPosition();
this->company = (id_v >= this->server->info.companies_on) ? INVALID_COMPANY : NetworkLobbyFindCompanyIndex(id_v);
this->SetDirty();
+
+ /* FIXME the disabling should go into some InvalidateData, which is called instead of the SetDirty */
+ if (!this->IsWidgetDisabled(NLWW_JOIN)) this->OnClick(pt, NLWW_JOIN, 1);
} break;
case NLWW_JOIN: // Join company
@@ -1660,14 +1661,6 @@ struct NetworkLobbyWindow : public Window {
}
}
- virtual void OnDoubleClick(Point pt, int widget)
- {
- if (widget == NLWW_MATRIX) {
- /* is the Join button enabled? */
- if (!this->IsWidgetDisabled(NLWW_JOIN)) this->OnClick(pt, NLWW_JOIN);
- }
- }
-
virtual void OnResize()
{
this->vscroll.SetCapacityFromWidget(this, NLWW_MATRIX);
@@ -2085,7 +2078,7 @@ struct NetworkClientListWindow : Window {
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
/* Show the popup with option */
if (this->selected_item != -1) {
@@ -2218,7 +2211,7 @@ struct NetworkJoinStatusWindow : Window {
size->width = width + WD_FRAMERECT_LEFT + WD_FRAMERECT_BOTTOM + 10;
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget == NJSW_CANCELOK) { // Disconnect button
NetworkDisconnect();
@@ -2304,7 +2297,7 @@ struct NetworkCompanyPasswordWindow : public QueryStringBaseWindow {
this->DrawEditBox(NCPWW_PASSWORD);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case NCPWW_OK:
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 333bde04e..8f32e7bcf 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -344,12 +344,7 @@ public:
}
}
- virtual void OnDoubleClick(Point pt, int widget)
- {
- if (widget == ANGRFW_GRF_LIST) this->OnClick(pt, ANGRFW_ADD);
- }
-
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case ANGRFW_GRF_LIST: {
@@ -364,9 +359,9 @@ public:
this->sel_pos = -1;
}
this->InvalidateData(1);
- break;
+ if (click_count == 1) break;
}
-
+ /* FALL THROUGH */
case ANGRFW_ADD: // Add selection to list
if (this->sel != NULL) {
const GRFConfig *src = this->sel;
@@ -705,12 +700,7 @@ struct NewGRFWindow : public Window {
}
}
- virtual void OnDoubleClick(Point pt, int widget)
- {
- if (widget == SNGRFS_FILE_LIST) this->OnClick(pt, SNGRFS_SET_PARAMETERS);
- }
-
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case SNGRFS_PRESET_LIST: {
@@ -821,6 +811,7 @@ struct NewGRFWindow : public Window {
this->sel = c;
this->InvalidateData();
+ if (click_count > 1) this->OnClick(pt, SNGRFS_SET_PARAMETERS, 1);
break;
}
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 753271b46..b959d52fd 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -444,7 +444,7 @@ struct NewsWindow : Window {
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case NTW_CLOSEBOX:
@@ -988,7 +988,7 @@ struct MessageHistoryWindow : Window {
this->vscroll.SetCount(_total_news);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget == MHW_BACKGROUND) {
NewsItem *ni = _latest_news;
@@ -1163,7 +1163,7 @@ struct MessageOptionsWindow : Window {
this->SetWidgetLoweredState(WIDGET_NEWSOPT_SOUNDTICKER, _news_ticker_sound);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case WIDGET_NEWSOPT_DROP_SUMMARY: // Dropdown menu for all settings
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 71c483401..cac20acd9 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -985,7 +985,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case ORDER_WIDGET_ORDER_LIST: {
diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp
index 8d7c13c2a..fdd9fd1f7 100644
--- a/src/osk_gui.cpp
+++ b/src/osk_gui.cpp
@@ -142,7 +142,7 @@ struct OskWindow : public Window {
this->qs->DrawEditBox(this, OSK_WIDGET_TEXT);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
/* clicked a letter */
if (widget >= OSK_WIDGET_LETTERS) {
@@ -207,7 +207,7 @@ struct OskWindow : public Window {
if (this->qs->orig == NULL || strcmp(this->qs->text.buf, this->qs->orig) != 0) {
/* pass information by simulating a button press on parent window */
if (this->ok_btn != 0) {
- this->parent->OnClick(pt, this->ok_btn);
+ this->parent->OnClick(pt, this->ok_btn, 1);
/* Window gets deleted when the parent window removes itself. */
return;
}
@@ -217,7 +217,7 @@ struct OskWindow : public Window {
case OSK_WIDGET_CANCEL:
if (this->cancel_btn != 0) { // pass a cancel event to the parent window
- this->parent->OnClick(pt, this->cancel_btn);
+ this->parent->OnClick(pt, this->cancel_btn, 1);
/* Window gets deleted when the parent window removes itself. */
return;
} else { // or reset to original string
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 0aa4d1c44..1b187f85b 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -694,7 +694,7 @@ struct BuildRailToolbarWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget >= RTW_BUILD_NS) {
_remove_button_clicked = false;
@@ -1165,7 +1165,7 @@ public:
if (widget == BRSW_NEWST_DROPDOWN) SetDParam(0, GetStationClassName(_railstation.station_class));
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case BRSW_PLATFORM_DIR_X:
@@ -1587,7 +1587,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case BSW_SEMAPHORE_NORM:
@@ -1723,7 +1723,7 @@ struct BuildRailDepotWindow : public PickerWindowBase {
DrawTrainDepotSprite(r.left - 1, r.top, widget - BRDW_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case BRDW_DEPOT_NE:
@@ -1826,7 +1826,7 @@ struct BuildRailWaypointWindow : PickerWindowBase {
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case BRWW_WAYPOINT_1:
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 6cd517f2f..f42b78aa9 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -483,7 +483,7 @@ struct BuildRoadToolbarWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget >= RTW_ROAD_X) {
_remove_button_clicked = false;
@@ -787,7 +787,7 @@ struct BuildRoadDepotWindow : public PickerWindowBase {
DrawRoadDepotSprite(r.left - 1, r.top, (DiagDirection)(widget - BRDW_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case BRDW_DEPOT_NW:
@@ -929,7 +929,7 @@ struct BuildRoadStationWindow : public PickerWindowBase {
StationPickerDrawSprite(r.left + TILE_PIXELS, r.bottom - TILE_PIXELS, st, INVALID_RAILTYPE, widget < BRSW_STATION_X ? ROADTYPE_ROAD : _cur_roadtype, widget - BRSW_STATION_NE);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case BRSW_STATION_NE:
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 7de747066..ac8846f34 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -277,7 +277,7 @@ struct GameOptionsWindow : Window {
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case GOW_CURRENCY_DROPDOWN: // Setup currencies dropdown
@@ -625,7 +625,7 @@ public:
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget >= GDW_OPTIONS_START) {
widget -= GDW_OPTIONS_START;
@@ -1539,7 +1539,7 @@ struct GameSettingsWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget != SETTINGSEL_OPTIONSPANEL) return;
@@ -1826,7 +1826,7 @@ struct CustomCurrencyWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
int line = 0;
int len = 0;
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 5d86e90f9..5597a1202 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -143,7 +143,7 @@ struct SignListWindow : Window, SignList {
if (widget == SLW_CAPTION) SetDParam(0, this->vscroll.GetCount());
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget == SLW_LIST) {
uint id_v = (pt.y - this->GetWidget<NWidgetBase>(SLW_LIST)->pos_y - WD_FRAMERECT_TOP) / this->resize.step_height;
@@ -328,7 +328,7 @@ struct SignWindow : QueryStringBaseWindow, SignList {
if (!this->IsShaded()) this->DrawEditBox(QUERY_EDIT_SIGN_WIDGET_TEXT);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case QUERY_EDIT_SIGN_WIDGET_PREVIOUS:
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 1d9767efe..2532b7594 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -898,7 +898,7 @@ public:
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case SM_WIDGET_MAP: { // Map window
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 377642b86..ccbea9c0f 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -532,7 +532,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case SLW_LIST: {
@@ -1136,7 +1136,7 @@ struct StationViewWindow : public Window {
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case SVW_WAITING:
@@ -1421,7 +1421,7 @@ struct SelectStationWindow : Window {
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget != JSW_PANEL) return;
diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp
index c4566e44c..f8d853937 100644
--- a/src/statusbar_gui.cpp
+++ b/src/statusbar_gui.cpp
@@ -200,7 +200,7 @@ struct StatusBarWindow : Window {
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case SBW_MIDDLE: ShowLastNewsMessage(); break;
diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp
index 1204b216e..0528ea146 100644
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -37,7 +37,7 @@ struct SubsidyListWindow : Window {
this->OnInvalidateData(0);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget != SLW_PANEL) return;
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index 8684f287e..60e505045 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -241,7 +241,7 @@ struct TerraformToolbarWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget >= TTW_BUTTONS_START) _terraform_button_proc[widget - TTW_BUTTONS_START](this);
}
@@ -673,7 +673,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
return ES_NOT_HANDLED;
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (IsInsideMM(widget, ETTW_BUTTONS_START, ETTW_BUTTONS_END)) {
_editor_terraform_button_proc[widget - ETTW_BUTTONS_START](this);
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index 09338c202..f84982d87 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -497,7 +497,7 @@ struct TimetableWindow : Window {
return v->index | (order_number << 16) | (is_journey << 24);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
const Vehicle *v = this->vehicle;
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index fa708d507..33deeca78 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -1233,7 +1233,7 @@ struct MainToolbarWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (_game_mode != GM_MENU && !this->IsWidgetDisabled(widget)) _toolbar_button_procs[widget](this);
}
@@ -1470,7 +1470,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (_game_mode == GM_MENU) return;
_scen_toolbar_button_procs[widget](this);
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index d70872b04..2f6bae453 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -251,10 +251,7 @@ public:
}
}
- virtual void OnDoubleClick(Point pt, int widget) { HandleClick(pt, widget, true); }
- virtual void OnClick(Point pt, int widget) { HandleClick(pt, widget, false); }
-
- void HandleClick(Point pt, int widget, bool double_click)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case TWA_COMMAND_LIST: {
@@ -268,7 +265,7 @@ public:
this->SetDirty();
}
/* Fall through to clicking in case we are double-clicked */
- if (!double_click || y < 0) break;
+ if (click_count == 1 || y < 0) break;
}
case TWA_EXECUTE:
@@ -435,7 +432,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case TVW_CENTERVIEW: // scroll to location
@@ -797,7 +794,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case TDW_SORTNAME: // Sort by Name ascending/descending
@@ -1073,7 +1070,7 @@ public:
if (!this->IsShaded()) this->DrawEditBox(TSEW_TOWNNAME_EDITBOX);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case TSEW_NEWTOWN:
diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp
index 69f8defaf..038782678 100644
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -82,7 +82,7 @@ public:
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget >= TTW_WIDGET_BEGIN && widget < TTW_WIDGET_END) {
if (_ctrl_pressed) {
diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp
index bfd2f89db..7d8a04c6d 100644
--- a/src/tree_gui.cpp
+++ b/src/tree_gui.cpp
@@ -96,7 +96,7 @@ public:
DrawSprite(tree_sprites[i].sprite, tree_sprites[i].pal, (r.left + r.right) / 2, r.bottom - 7);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case BTW_TYPE_11: case BTW_TYPE_12: case BTW_TYPE_13: case BTW_TYPE_14:
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index dba4e05eb..cb1c2c51b 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -438,12 +438,7 @@ struct RefitWindow : public Window {
}
}
- virtual void OnDoubleClick(Point pt, int widget)
- {
- if (widget == VRW_MATRIX) this->OnClick(pt, VRW_REFITBUTTON);
- }
-
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case VRW_MATRIX: { // listbox
@@ -452,9 +447,10 @@ struct RefitWindow : public Window {
this->sel = (y / (int)this->resize.step_height) + this->vscroll.GetPosition();
this->SetDirty();
}
- break;
+ /* FIXME We need to call some InvalidateData to make this->cargo valid */
+ if (click_count == 1) break;
}
-
+ /* FALL THROUGH */
case VRW_REFITBUTTON: // refit button
if (this->cargo != NULL) {
const Vehicle *v = Vehicle::Get(this->window_number);
@@ -1116,7 +1112,7 @@ public:
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case VLW_WIDGET_SORT_ORDER: // Flip sorting method ascending/descending
@@ -1611,7 +1607,7 @@ struct VehicleDetailsWindow : Window {
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case VLD_WIDGET_RENAME_VEHICLE: { // rename
@@ -2041,7 +2037,7 @@ public:
DrawString(r.left + WD_FRAMERECT_LEFT + 6, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, str, TC_FROMSTRING, SA_CENTER);
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
const Vehicle *v = Vehicle::Get(this->window_number);
diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp
index 794c8341a..83b662385 100644
--- a/src/viewport_gui.cpp
+++ b/src/viewport_gui.cpp
@@ -101,7 +101,7 @@ public:
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case EVW_ZOOMIN: DoZoomInOutWindow(ZOOM_IN, this); break;
diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp
index 2b96f910f..0a6d10a10 100644
--- a/src/waypoint_gui.cpp
+++ b/src/waypoint_gui.cpp
@@ -75,7 +75,7 @@ public:
this->DrawWidgets();
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case WAYPVW_CENTERVIEW: // scroll to location
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index e32cf4151..bf91dc841 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -247,7 +247,7 @@ struct DropdownWindow : Window {
}
}
- virtual void OnClick(Point pt, int widget)
+ virtual void OnClick(Point pt, int widget, int click_count)
{
if (widget != DDM_ITEMS) return;
int item;
diff --git a/src/window.cpp b/src/window.cpp
index f89c0abe1..110836e4a 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -253,9 +253,9 @@ static void StartWindowSizing(Window *w, bool to_left);
* @param w Window to dispatch event in
* @param x X coordinate of the click
* @param y Y coordinate of the click
- * @param double_click Was it a double click?
+ * @param click_count Number of fast consecutive clicks at same position
*/
-static void DispatchLeftClickEvent(Window *w, int x, int y, bool double_click)
+static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count)
{
const NWidgetCore *nw = w->nested_root->GetWidgetFromPos(x, y);
WidgetType widget_type = (nw != NULL) ? nw->type : WWT_EMPTY;
@@ -283,96 +283,88 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, bool double_click)
int widget_index = nw->index; ///< Index of the widget
- /* Process special buttons (only single clicks) */
- if (!double_click) {
- /* Clicked on a widget that is not disabled.
- * So unless the clicked widget is the caption bar, change focus to this widget */
- if (widget_type != WWT_CAPTION) {
- /* Close the OSK window if a edit box loses focus */
- if (w->nested_focus != NULL && w->nested_focus->type == WWT_EDITBOX && w->nested_focus != nw && w->window_class != WC_OSK) {
- DeleteWindowById(WC_OSK, 0);
- }
-
- /* focused_widget_changed is 'now' only true if the window this widget
- * is in gained focus. In that case it must remain true, also if the
- * local widget focus did not change. As such it's the logical-or of
- * both changed states.
- *
- * If this is not preserved, then the OSK window would be opened when
- * a user has the edit box focused and then click on another window and
- * then back again on the edit box (to type some text).
- */
- focused_widget_changed |= w->SetFocusedWidget(widget_index);
+ /* Clicked on a widget that is not disabled.
+ * So unless the clicked widget is the caption bar, change focus to this widget */
+ if (widget_type != WWT_CAPTION) {
+ /* Close the OSK window if a edit box loses focus */
+ if (w->nested_focus != NULL && w->nested_focus->type == WWT_EDITBOX && w->nested_focus != nw && w->window_class != WC_OSK) {
+ DeleteWindowById(WC_OSK, 0);
}
- /* Close any child drop down menus. If the button pressed was the drop down
- * list's own button, then we should not process the click any further. */
- if (HideDropDownMenu(w) == widget_index && widget_index >= 0) return;
-
- switch (widget_type) {
- /* special widget handling for buttons*/
- case WWT_PANEL | WWB_PUSHBUTTON: // WWT_PUSHBTN
- case WWT_IMGBTN | WWB_PUSHBUTTON: // WWT_PUSHIMGBTN
- case WWT_TEXTBTN | WWB_PUSHBUTTON: // WWT_PUSHTXTBTN
- w->HandleButtonClick(widget_index);
- break;
+ /* focused_widget_changed is 'now' only true if the window this widget
+ * is in gained focus. In that case it must remain true, also if the
+ * local widget focus did not change. As such it's the logical-or of
+ * both changed states.
+ *
+ * If this is not preserved, then the OSK window would be opened when
+ * a user has the edit box focused and then click on another window and
+ * then back again on the edit box (to type some text).
+ */
+ focused_widget_changed |= w->SetFocusedWidget(widget_index);
+ }
+
+ /* Close any child drop down menus. If the button pressed was the drop down
+ * list's own button, then we should not process the click any further. */
+ if (HideDropDownMenu(w) == widget_index && widget_index >= 0) return;
+
+ switch (widget_type) {
+ /* special widget handling for buttons*/
+ case WWT_PANEL | WWB_PUSHBUTTON: // WWT_PUSHBTN
+ case WWT_IMGBTN | WWB_PUSHBUTTON: // WWT_PUSHIMGBTN
+ case WWT_TEXTBTN | WWB_PUSHBUTTON: // WWT_PUSHTXTBTN
+ w->HandleButtonClick(widget_index);
+ break;
- case WWT_SCROLLBAR:
- case WWT_SCROLL2BAR:
- case WWT_HSCROLLBAR:
- ScrollbarClickHandler(w, nw, x, y);
- break;
+ case WWT_SCROLLBAR:
+ case WWT_SCROLL2BAR:
+ case WWT_HSCROLLBAR:
+ ScrollbarClickHandler(w, nw, x, y);
+ break;
- case WWT_EDITBOX:
- if (!focused_widget_changed) { // Only open the OSK window if clicking on an already focused edit box
- /* Open the OSK window if clicked on an edit box */
- QueryStringBaseWindow *qs = dynamic_cast<QueryStringBaseWindow *>(w);
- if (qs != NULL) {
- qs->OnOpenOSKWindow(widget_index);
- }
+ case WWT_EDITBOX:
+ if (!focused_widget_changed) { // Only open the OSK window if clicking on an already focused edit box
+ /* Open the OSK window if clicked on an edit box */
+ QueryStringBaseWindow *qs = dynamic_cast<QueryStringBaseWindow *>(w);
+ if (qs != NULL) {
+ qs->OnOpenOSKWindow(widget_index);
}
- break;
+ }
+ break;
- case WWT_CLOSEBOX: // 'X'
- delete w;
- return;
+ case WWT_CLOSEBOX: // 'X'
+ delete w;
+ return;
- case WWT_CAPTION: // 'Title bar'
- StartWindowDrag(w);
- return;
+ case WWT_CAPTION: // 'Title bar'
+ StartWindowDrag(w);
+ return;
- case WWT_RESIZEBOX:
- /* When the resize widget is on the left size of the window
- * we assume that that button is used to resize to the left. */
- StartWindowSizing(w, (int)nw->pos_x < (w->width / 2));
- nw->SetDirty(w);
- return;
+ case WWT_RESIZEBOX:
+ /* When the resize widget is on the left size of the window
+ * we assume that that button is used to resize to the left. */
+ StartWindowSizing(w, (int)nw->pos_x < (w->width / 2));
+ nw->SetDirty(w);
+ return;
- case WWT_SHADEBOX:
- nw->SetDirty(w);
- w->SetShaded(!w->IsShaded());
- return;
+ case WWT_SHADEBOX:
+ nw->SetDirty(w);
+ w->SetShaded(!w->IsShaded());
+ return;
- case WWT_STICKYBOX:
- w->flags4 ^= WF_STICKY;
- nw->SetDirty(w);
- return;
+ case WWT_STICKYBOX:
+ w->flags4 ^= WF_STICKY;
+ nw->SetDirty(w);
+ return;
- default:
- break;
- }
+ default:
+ break;
}
/* Widget has no index, so the window is not interested in it. */
if (widget_index < 0) return;
Point pt = { x, y };
-
- if (double_click) {
- w->OnDoubleClick(pt, widget_index);
- } else {
- w->OnClick(pt, widget_index);
- }
+ w->OnClick(pt, widget_index, click_count);
}
/**
@@ -2127,11 +2119,7 @@ static void MouseLoop(MouseClick click, int mousewheel)
switch (click) {
case MC_LEFT:
case MC_DOUBLE_LEFT:
- DispatchLeftClickEvent(w, x - w->left, y - w->top, false);
- if (click == MC_DOUBLE_LEFT && _mouseover_last_w != NULL) {
- /* Issue the doubleclick, if the window was not removed */
- DispatchLeftClickEvent(w, x - w->left, y - w->top, true);
- }
+ DispatchLeftClickEvent(w, x - w->left, y - w->top, click == MC_DOUBLE_LEFT ? 2 : 1);
break;
default:
diff --git a/src/window_gui.h b/src/window_gui.h
index dccabc09a..2956b7eab 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -638,15 +638,9 @@ public:
* A click with the left mouse button has been made on the window.
* @param pt the point inside the window that has been clicked.
* @param widget the clicked widget.
+ * @param click_count Number of fast consecutive clicks at same position
*/
- virtual void OnClick(Point pt, int widget) {}
-
- /**
- * A double click with the left mouse button has been made on the window.
- * @param pt the point inside the window that has been clicked.
- * @param widget the clicked widget.
- */
- virtual void OnDoubleClick(Point pt, int widget) {}
+ virtual void OnClick(Point pt, int widget, int click_count) {}
/**
* A click with the right mouse button has been made on the window.