Skip to content

Commit

Permalink
Codechange: Move dropdown and slider out of widgets directory. (#12403)
Browse files Browse the repository at this point in the history
Also shuffle headers to place widget includes near end.

This leaves the widgets directory solely for defining Widget IDs.
  • Loading branch information
PeterN committed Mar 31, 2024
1 parent d5e28a9 commit d683ec0
Show file tree
Hide file tree
Showing 41 changed files with 96 additions and 87 deletions.
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ add_files(
dock_gui.cpp
driver.cpp
driver.h
dropdown.cpp
dropdown_func.h
dropdown_type.h
economy.cpp
economy_base.h
economy_cmd.h
Expand Down Expand Up @@ -393,6 +396,8 @@ add_files(
signs_func.h
signs_gui.cpp
signs_type.h
slider.cpp
slider_func.h
slope_func.h
slope_type.h
smallmap_gui.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/airport_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "station_type.h"
#include "newgrf_airport.h"
#include "newgrf_callbacks.h"
#include "widgets/dropdown_type.h"
#include "dropdown_type.h"
#include "core/geometry_func.hpp"
#include "hotkeys.h"
#include "vehicle_func.h"
Expand Down
2 changes: 1 addition & 1 deletion src/autoreplace_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "core/geometry_func.hpp"
#include "rail_gui.h"
#include "road_gui.h"
#include "widgets/dropdown_func.h"
#include "dropdown_func.h"
#include "autoreplace_cmd.h"
#include "group_cmd.h"
#include "settings_cmd.h"
Expand Down
2 changes: 1 addition & 1 deletion src/bridge_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "gfx_func.h"
#include "tunnelbridge.h"
#include "sortlist_type.h"
#include "widgets/dropdown_func.h"
#include "dropdown_func.h"
#include "core/geometry_func.hpp"
#include "tunnelbridge_map.h"
#include "road_gui.h"
Expand Down
2 changes: 1 addition & 1 deletion src/build_vehicle_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "window_func.h"
#include "timer/timer_game_calendar.h"
#include "vehicle_func.h"
#include "widgets/dropdown_func.h"
#include "dropdown_func.h"
#include "engine_gui.h"
#include "cargotype.h"
#include "core/geometry_func.hpp"
Expand Down
3 changes: 2 additions & 1 deletion src/company_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
#include "game/game.hpp"
#include "goal_base.h"
#include "story_base.h"
#include "widgets/statusbar_widget.h"
#include "company_cmd.h"
#include "timer/timer.h"
#include "timer/timer_game_economy.h"
#include "timer/timer_game_tick.h"

#include "widgets/statusbar_widget.h"

#include "table/strings.h"

#include "safeguards.h"
Expand Down
2 changes: 1 addition & 1 deletion src/company_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "company_manager_face.h"
#include "strings_func.h"
#include "timer/timer_game_economy.h"
#include "widgets/dropdown_type.h"
#include "dropdown_type.h"
#include "tilehighlight_func.h"
#include "company_base.h"
#include "core/geometry_func.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/date_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include "window_gui.h"
#include "date_gui.h"
#include "core/geometry_func.hpp"
#include "dropdown_type.h"

#include "widgets/dropdown_type.h"
#include "widgets/date_widget.h"

#include "safeguards.h"
Expand Down
19 changes: 9 additions & 10 deletions src/widgets/dropdown.cpp → src/dropdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@

/** @file dropdown.cpp Implementation of the dropdown widget. */

#include "../stdafx.h"
#include "../window_gui.h"
#include "../string_func.h"
#include "../strings_func.h"
#include "../window_func.h"
#include "../zoom_func.h"
#include "../timer/timer.h"
#include "../timer/timer_window.h"
#include "stdafx.h"
#include "dropdown_type.h"
#include "strings_func.h"
#include "timer/timer.h"
#include "timer/timer_window.h"
#include "window_gui.h"
#include "window_func.h"
#include "zoom_func.h"

#include "dropdown_widget.h"
#include "widgets/dropdown_widget.h"

#include "../safeguards.h"
#include "safeguards.h"


static constexpr NWidgetPart _nested_dropdown_menu_widgets[] = {
Expand Down
8 changes: 4 additions & 4 deletions src/widgets/dropdown_func.h → src/dropdown_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

/** @file dropdown_func.h Functions related to the drop down widget. */

#ifndef WIDGETS_DROPDOWN_FUNC_H
#define WIDGETS_DROPDOWN_FUNC_H
#ifndef DROPDOWN_FUNC_H
#define DROPDOWN_FUNC_H

#include "../window_gui.h"
#include "window_gui.h"

/* Show drop down menu containing a fixed list of strings */
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width = 0);

#endif /* WIDGETS_DROPDOWN_FUNC_H */
#endif /* DROPDOWN_FUNC_H */
24 changes: 12 additions & 12 deletions src/widgets/dropdown_type.h → src/dropdown_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

/** @file dropdown_type.h Types related to the drop down widget. */

#ifndef WIDGETS_DROPDOWN_TYPE_H
#define WIDGETS_DROPDOWN_TYPE_H

#include "../window_type.h"
#include "../gfx_func.h"
#include "../gfx_type.h"
#include "../palette_func.h"
#include "../string_func.h"
#include "../strings_func.h"
#include "../table/strings.h"
#include "../window_gui.h"
#ifndef DROPDOWN_TYPE_H
#define DROPDOWN_TYPE_H

#include "window_type.h"
#include "gfx_func.h"
#include "gfx_type.h"
#include "palette_func.h"
#include "string_func.h"
#include "strings_func.h"
#include "table/strings.h"
#include "window_gui.h"

/**
* Base list item class from which others are derived.
Expand Down Expand Up @@ -217,4 +217,4 @@ Dimension GetDropDownListDimension(const DropDownList &list);

void ReplaceDropDownList(Window *parent, DropDownList &&list);

#endif /* WIDGETS_DROPDOWN_TYPE_H */
#endif /* DROPDOWN_TYPE_H */
2 changes: 1 addition & 1 deletion src/game/game_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "../window_func.h"
#include "../network/network.h"
#include "../network/network_content.h"
#include "../widgets/dropdown_func.h"
#include "../dropdown_func.h"
#include "../timer/timer.h"
#include "../timer/timer_window.h"

Expand Down
4 changes: 2 additions & 2 deletions src/genworld_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include "sound_func.h"
#include "fios.h"
#include "string_func.h"
#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
#include "dropdown_type.h"
#include "dropdown_func.h"
#include "querystring_gui.h"
#include "town.h"
#include "core/geometry_func.hpp"
Expand Down
1 change: 1 addition & 0 deletions src/ground_vehicle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "vehicle_gui.h"
#include "landscape.h"
#include "window_func.h"

#include "widgets/vehicle_widget.h"

/** What is the status of our acceleration? */
Expand Down
2 changes: 1 addition & 1 deletion src/group_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "vehicle_func.h"
#include "autoreplace_gui.h"
#include "company_func.h"
#include "widgets/dropdown_func.h"
#include "dropdown_func.h"
#include "tilehighlight_func.h"
#include "vehicle_gui_base.h"
#include "core/geometry_func.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/help_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "table/control_codes.h"
#include "string_func.h"
#include "openttd.h"

#include "help_gui.h"

#include "widgets/help_widget.h"
#include "widgets/misc_widget.h"

Expand Down
7 changes: 4 additions & 3 deletions src/industry_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@
#include "tilehighlight_func.h"
#include "string_func.h"
#include "sortlist_type.h"
#include "widgets/dropdown_func.h"
#include "dropdown_func.h"
#include "company_base.h"
#include "core/geometry_func.hpp"
#include "core/random_func.hpp"
#include "core/backup_type.hpp"
#include "genworld.h"
#include "smallmap_gui.h"
#include "widgets/dropdown_type.h"
#include "widgets/industry_widget.h"
#include "dropdown_type.h"
#include "clear_map.h"
#include "zoom_func.h"
#include "industry_cmd.h"
Expand All @@ -46,6 +45,8 @@
#include "timer/timer_window.h"
#include "hotkeys.h"

#include "widgets/industry_widget.h"

#include "table/strings.h"

#include <bitset>
Expand Down
3 changes: 2 additions & 1 deletion src/league_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include "stdafx.h"
#include "league_gui.h"

#include "company_base.h"
#include "company_gui.h"
#include "gui.h"
Expand All @@ -22,7 +21,9 @@
#include "town.h"
#include "viewport_func.h"
#include "window_gui.h"

#include "widgets/league_widget.h"

#include "table/strings.h"
#include "table/sprites.h"

Expand Down
6 changes: 3 additions & 3 deletions src/music_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include "string_func.h"
#include "settings_type.h"
#include "settings_gui.h"
#include "widgets/dropdown_func.h"
#include "widgets/dropdown_type.h"
#include "widgets/slider_func.h"
#include "dropdown_func.h"
#include "dropdown_type.h"
#include "slider_func.h"
#include "mixer.h"

#include "widgets/music_widget.h"
Expand Down
4 changes: 2 additions & 2 deletions src/network/network_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#include "network_udp.h"
#include "../window_func.h"
#include "../gfx_func.h"
#include "../widgets/dropdown_type.h"
#include "../widgets/dropdown_func.h"
#include "../dropdown_type.h"
#include "../dropdown_func.h"
#include "../querystring_gui.h"
#include "../sortlist_type.h"
#include "../company_func.h"
Expand Down
4 changes: 2 additions & 2 deletions src/newgrf_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include "gamelog.h"
#include "settings_type.h"
#include "settings_func.h"
#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
#include "dropdown_type.h"
#include "dropdown_func.h"
#include "network/network.h"
#include "network/network_content.h"
#include "sortlist_type.h"
Expand Down
2 changes: 1 addition & 1 deletion src/news_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "town.h"
#include "sound_func.h"
#include "string_func.h"
#include "widgets/dropdown_func.h"
#include "dropdown_func.h"
#include "statusbar_gui.h"
#include "company_manager_face.h"
#include "company_func.h"
Expand Down
4 changes: 2 additions & 2 deletions src/order_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "timetable.h"
#include "strings_func.h"
#include "company_func.h"
#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
#include "dropdown_type.h"
#include "dropdown_func.h"
#include "textbuf_gui.h"
#include "string_func.h"
#include "tilehighlight_func.h"
Expand Down
2 changes: 1 addition & 1 deletion src/rail_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "window_func.h"
#include "sound_func.h"
#include "company_func.h"
#include "widgets/dropdown_type.h"
#include "dropdown_type.h"
#include "tunnelbridge.h"
#include "tilehighlight_func.h"
#include "spritecache.h"
Expand Down
2 changes: 1 addition & 1 deletion src/rail_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define RAIL_GUI_H

#include "rail_type.h"
#include "widgets/dropdown_type.h"
#include "dropdown_type.h"

struct Window *ShowBuildRailToolbar(RailType railtype);
void ReinitGuiAfterToggleElrail(bool disable);
Expand Down
2 changes: 1 addition & 1 deletion src/road_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "road_type.h"
#include "tile_type.h"
#include "direction_type.h"
#include "widgets/dropdown_type.h"
#include "dropdown_type.h"

struct Window *ShowBuildRoadToolbar(RoadType roadtype);
struct Window *ShowBuildRoadScenToolbar(RoadType roadtype);
Expand Down
6 changes: 5 additions & 1 deletion src/screenshot_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@
#include "window_func.h"
#include "window_gui.h"
#include "screenshot.h"
#include "gfx_func.h"

#include "widgets/screenshot_widget.h"

#include "table/strings.h"
#include "gfx_func.h"

#include "safeguards.h"

struct ScreenshotWindow : Window {
ScreenshotWindow(WindowDesc *desc) : Window(desc)
Expand Down
2 changes: 1 addition & 1 deletion src/script/script_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "../company_gui.h"
#include "../window_func.h"
#include "../network/network.h"
#include "../widgets/dropdown_func.h"
#include "../dropdown_func.h"
#include "../hotkeys.h"
#include "../company_cmd.h"
#include "../misc_cmd.h"
Expand Down
6 changes: 3 additions & 3 deletions src/settings_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include "strings_func.h"
#include "window_func.h"
#include "string_func.h"
#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
#include "widgets/slider_func.h"
#include "dropdown_type.h"
#include "dropdown_func.h"
#include "slider_func.h"
#include "highscore.h"
#include "base_media_base.h"
#include "company_base.h"
Expand Down
2 changes: 1 addition & 1 deletion src/settings_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define SETTING_GUI_H

#include "gfx_type.h"
#include "widgets/dropdown_type.h"
#include "dropdown_type.h"

/** Width of setting buttons */
#define SETTING_BUTTON_WIDTH ((int)NWidgetScrollbar::GetHorizontalDimension().width * 2)
Expand Down

0 comments on commit d683ec0

Please sign in to comment.