summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2006-10-05 01:43:49 +0000
committerbelugas <belugas@openttd.org>2006-10-05 01:43:49 +0000
commitad4ed70cf3fd1d34016f9212f6942d6ff8846440 (patch)
tree01128b2f1574643c630fdbdd0b66ec5701cacd4b
parentaab046946496f5d7cdf50bb1c0f81bbb42199cf4 (diff)
downloadopenttd-ad4ed70cf3fd1d34016f9212f6942d6ff8846440.tar.xz
(svn r6643) -Fix(r6631): Adjust proper disabled and lowered states of removal button on railtoolbar
-rw-r--r--rail_gui.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/rail_gui.c b/rail_gui.c
index c7114b88a..5eba3abbd 100644
--- a/rail_gui.c
+++ b/rail_gui.c
@@ -403,16 +403,33 @@ static const uint16 _rail_keycodes[] = {
static void UpdateRemoveWidgetStatus(Window *w, int clicked_widget)
{
+ /* If it is the removal button that has been clicked, do nothing,
+ * as it is up to the other buttons to drive removal status */
+ if (clicked_widget == 16) return;
+
switch (clicked_widget) {
- case 4: case 5: case 6: case 7: case 8: case 11: case 12: case 13: EnableWindowWidget(w, 16); break;
- default: DisableWindowWidget(w, 16); LowerWindowWidget(w, 16); break;
+ case 4: case 5: case 6: case 7: case 8: case 11: case 12: case 13:
+ /* Removal button is enabled only if the rail/signal/waypoint/station
+ * button is still lowered. Once raised, it has to be disabled */
+ SetWindowWidgetDisabledState(w, 16, !IsWindowWidgetLowered(w, clicked_widget));
+ break;
+
+ default:
+ /* When any other buttons than rail/signal/waypoint/station, raise and
+ * disable the removal button*/
+ DisableWindowWidget(w, 16);
+ RaiseWindowWidget(w, 16);
+ break;
}
}
static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
+ case WE_CREATE: DisableWindowWidget(w, 16); break;
+
case WE_PAINT: DrawWindowWidgets(w); break;
+
case WE_CLICK:
if (e->we.click.widget >= 4) {
_remove_button_clicked = false;