wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src Makefile.am preferences.cpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src Makefile.am preferences.cpp
Date: Sat, 06 Nov 2004 17:02:37 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    04/11/06 21:53:38

Modified files:
        src            : Makefile.am preferences.cpp 

Log message:
        Switch to labels to fix the gamma label behavior. Clean indentation, 
remove unused variable, factor code.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/Makefile.am.diff?tr1=1.59&tr2=1.60&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/preferences.cpp.diff?tr1=1.121&tr2=1.122&r1=text&r2=text

Patches:
Index: wesnoth/src/Makefile.am
diff -u wesnoth/src/Makefile.am:1.59 wesnoth/src/Makefile.am:1.60
--- wesnoth/src/Makefile.am:1.59        Sat Nov  6 09:19:27 2004
+++ wesnoth/src/Makefile.am     Sat Nov  6 21:53:38 2004
@@ -177,6 +177,7 @@
                  widgets/label.hpp \
                  widgets/menu.hpp \
                  widgets/progressbar.hpp \
+                 widgets/scrollarea.hpp \
                  widgets/scrollbar.hpp \
                  widgets/scrollpane.hpp \
                  widgets/slider.hpp \
@@ -249,6 +250,7 @@
                         video.cpp \
                         widgets/button.cpp \
                         widgets/file_chooser.cpp \
+                        widgets/label.cpp \
                         widgets/menu.cpp \
                         widgets/progressbar.cpp \
                         widgets/textbox.cpp \
@@ -321,9 +323,11 @@
                         video.hpp \
                         widgets/button.hpp \
                         widgets/file_chooser.hpp \
+                        widgets/label.hpp \
                         widgets/menu.hpp \
                         widgets/progressbar.hpp \
                         widgets/textbox.hpp \
+                        widgets/scrollarea.h \
                         widgets/scrollbar.hpp \
                         widgets/slider.hpp \
                         widgets/widget.hpp \
Index: wesnoth/src/preferences.cpp
diff -u wesnoth/src/preferences.cpp:1.121 wesnoth/src/preferences.cpp:1.122
--- wesnoth/src/preferences.cpp:1.121   Sat Nov  6 13:13:15 2004
+++ wesnoth/src/preferences.cpp Sat Nov  6 21:53:38 2004
@@ -1,4 +1,4 @@
-/* $Id: preferences.cpp,v 1.121 2004/11/06 13:13:15 silene Exp $ */
+/* $Id: preferences.cpp,v 1.122 2004/11/06 21:53:38 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -25,14 +25,15 @@
 #include "sound.hpp"
 #include "util.hpp"
 #include "widgets/button.hpp"
-#include "widgets/slider.hpp"
+#include "widgets/label.hpp"
 #include "widgets/menu.hpp"
+#include "widgets/slider.hpp"
 #include "wesconfig.h"
 
 #include <cstdlib>
 #include <iostream>
-#include <sstream>
 #include <iterator>
+#include <sstream>
 
 namespace {
 
@@ -632,7 +633,6 @@
 
 private:
 
-       void draw_contents();
        void process_event();
        bool left_side() const { return false; }
        void set_selection(int index);
@@ -641,10 +641,10 @@
        gui::slider music_slider_, sound_slider_, scroll_slider_, gamma_slider_;
        gui::button fullscreen_button_, turbo_button_, show_ai_moves_button_,
                    show_grid_button_, show_floating_labels_button_, 
turn_dialog_button_,
-                               turn_bell_button_, show_team_colours_button_, 
show_colour_cursors_button_,
-                               show_haloing_button_, video_mode_button_, 
hotkeys_button_, gamma_button_;
-       std::string music_label_, sound_label_, scroll_label_, gamma_label_;
-       size_t slider_label_width_;
+                   turn_bell_button_, show_team_colours_button_, 
show_colour_cursors_button_,
+                   show_haloing_button_, video_mode_button_, hotkeys_button_, 
gamma_button_;
+       gui::label music_label_, sound_label_, scroll_label_, gamma_label_;
+       unsigned slider_label_width_;
 
        enum TAB { GENERAL_TAB, DISPLAY_TAB, SOUND_TAB };
        TAB tab_;
@@ -654,29 +654,29 @@
        : gui::preview_pane(disp),
          music_slider_(disp), sound_slider_(disp),
          scroll_slider_(disp), gamma_slider_(disp),
-fullscreen_button_(disp,_("Full Screen"),gui::button::TYPE_CHECK),
-turbo_button_(disp,_("Accelerated Speed"),gui::button::TYPE_CHECK),
-show_ai_moves_button_(disp,_("Skip AI Moves"),gui::button::TYPE_CHECK),
-show_grid_button_(disp,_("Show Grid"),gui::button::TYPE_CHECK),
-show_floating_labels_button_(disp,_("Show Floating 
Labels"),gui::button::TYPE_CHECK),
-turn_dialog_button_(disp,_("Turn Dialog"),gui::button::TYPE_CHECK),
-turn_bell_button_(disp,_("Turn Bell"),gui::button::TYPE_CHECK),
-show_team_colours_button_(disp,_("Show Team Colors"),gui::button::TYPE_CHECK),
-show_colour_cursors_button_(disp,_("Show Color 
Cursors"),gui::button::TYPE_CHECK),
-show_haloing_button_(disp,_("Show Haloing Effects"),gui::button::TYPE_CHECK),
-video_mode_button_(disp,_("Video Mode")),
-hotkeys_button_(disp,_("Hotkeys")),
-gamma_button_(disp,_("Adjust Gamma"),gui::button::TYPE_CHECK),
-music_label_(_("Music Volume:")), sound_label_(_("SFX Volume:")),
-scroll_label_(_("Scroll Speed:")), gamma_label_(_("Gamma:")),
-slider_label_width_(0), tab_(GENERAL_TAB)
-{
-       set_width(400);
-       set_height(400);
-
-       slider_label_width_ = 
maximum<size_t>(font::text_area(music_label_,font::SIZE_NORMAL).w,
-                             
maximum<size_t>(font::text_area(sound_label_,font::SIZE_NORMAL).w,
-                                                 
maximum<size_t>(font::text_area(scroll_label_,font::SIZE_NORMAL).w,font::text_area(gamma_label_,font::SIZE_NORMAL).w)));
+         fullscreen_button_(disp, _("Full Screen"), gui::button::TYPE_CHECK),
+         turbo_button_(disp, _("Accelerated Speed"), gui::button::TYPE_CHECK),
+         show_ai_moves_button_(disp, _("Skip AI Moves"), 
gui::button::TYPE_CHECK),
+         show_grid_button_(disp, _("Show Grid"), gui::button::TYPE_CHECK),
+         show_floating_labels_button_(disp, _("Show Floating Labels"), 
gui::button::TYPE_CHECK),
+         turn_dialog_button_(disp, _("Turn Dialog"), gui::button::TYPE_CHECK),
+         turn_bell_button_(disp, _("Turn Bell"), gui::button::TYPE_CHECK),
+         show_team_colours_button_(disp, _("Show Team Colors"), 
gui::button::TYPE_CHECK),
+         show_colour_cursors_button_(disp, _("Show Color Cursors"), 
gui::button::TYPE_CHECK),
+         show_haloing_button_(disp, _("Show Haloing Effects"), 
gui::button::TYPE_CHECK),
+         video_mode_button_(disp, _("Video Mode")),
+         hotkeys_button_(disp, _("Hotkeys")),
+         gamma_button_(disp, _("Adjust Gamma"), gui::button::TYPE_CHECK),
+         music_label_(disp, _("Music Volume:")), sound_label_(disp, _("SFX 
Volume:")),
+         scroll_label_(disp, _("Scroll Speed:")), gamma_label_(disp, 
_("Gamma:")),
+         slider_label_width_(0), tab_(GENERAL_TAB)
+{
+       set_measurements(400, 400);
+
+       slider_label_width_ = maximum<unsigned>(music_label_.width(),
+                             maximum<unsigned>(sound_label_.width(),
+                             maximum<unsigned>(scroll_label_.width(),
+                                               gamma_label_.width())));
 
        sound_slider_.set_min(1);
        sound_slider_.set_max(100);
@@ -743,6 +743,7 @@
 
        // General tab
        int ypos = rect.y;
+       scroll_label_.set_location(rect.x, ypos);
        SDL_Rect scroll_rect = { rect.x + slider_label_width_, ypos,
                                 rect.w - slider_label_width_ - border, 0 };
        scroll_slider_.set_location(scroll_rect);
@@ -758,6 +759,7 @@
        ypos = rect.y;
        gamma_button_.set_location(rect.x, ypos);
        ypos += 50;
+       gamma_label_.set_location(rect.x, ypos);
        SDL_Rect gamma_rect = { rect.x + slider_label_width_, ypos,
                                rect.w - slider_label_width_ - border, 0 };
        gamma_slider_.set_location(gamma_rect);
@@ -769,10 +771,12 @@
 
        // Sound tab
        ypos = rect.y;
+       music_label_.set_location(rect.x, ypos);
        SDL_Rect music_rect = { rect.x + slider_label_width_, ypos,
                                rect.w - slider_label_width_ - border, 0 };
        music_slider_.set_location(music_rect);
        ypos += 50;
+       sound_label_.set_location(rect.x, ypos);
        SDL_Rect sound_rect = { rect.x + slider_label_width_, ypos,
                                rect.w - slider_label_width_ - border, 0 };
        sound_slider_.set_location(sound_rect);
@@ -810,8 +814,9 @@
                set_show_haloes(show_haloing_button_.checked());
        if (gamma_button_.pressed()) {
                set_adjust_gamma(gamma_button_.checked());
-               gamma_slider_.hide(!adjust_gamma());
-               // we need a textlabel widget so that we can deal with the 
"gamma" text
+               bool hide_gamma = !adjust_gamma();
+               gamma_slider_.hide(hide_gamma);
+               gamma_label_.hide(hide_gamma);
        }
        set_sound_volume(sound_slider_.value());
        set_music_volume(music_slider_.value());
@@ -819,44 +824,38 @@
        set_gamma(gamma_slider_.value());
 }
 
-void preferences_dialog::draw_contents()
-{
-       SDL_Rect const &loc = location();
-       if (tab_ == GENERAL_TAB) {
-               font::draw_text(&disp(), loc, font::SIZE_NORMAL, 
font::NORMAL_COLOUR, scroll_label_, loc.x, loc.y);
-       } else if (tab_ == DISPLAY_TAB && adjust_gamma()) {
-               font::draw_text(&disp(), loc, font::SIZE_NORMAL, 
font::NORMAL_COLOUR, gamma_label_, loc.x, loc.y + 50);
-       } else if(tab_ == SOUND_TAB) {
-               font::draw_text(&disp(), loc, font::SIZE_NORMAL, 
font::NORMAL_COLOUR, music_label_, loc.x, loc.y);
-               font::draw_text(&disp(), loc, font::SIZE_NORMAL, 
font::NORMAL_COLOUR, sound_label_, loc.x, loc.y + 50);
-       }
-}
-
 void preferences_dialog::set_selection(int index)
 {
        tab_ = TAB(index);
        set_dirty();
        bg_restore();
 
-       scroll_slider_.hide(tab_ != GENERAL_TAB);
-       turbo_button_.hide(tab_ != GENERAL_TAB);
-       show_ai_moves_button_.hide(tab_ != GENERAL_TAB);
-       turn_dialog_button_.hide(tab_ != GENERAL_TAB);
-       turn_bell_button_.hide(tab_ != GENERAL_TAB);
-       hotkeys_button_.hide(tab_ != GENERAL_TAB);
-       show_team_colours_button_.hide(tab_ != GENERAL_TAB);
-       show_grid_button_.hide(tab_ != GENERAL_TAB);
-
-       gamma_slider_.hide(tab_ != DISPLAY_TAB || !adjust_gamma());
-       gamma_button_.hide(tab_ != DISPLAY_TAB);
-       show_floating_labels_button_.hide(tab_ != DISPLAY_TAB);
-       show_colour_cursors_button_.hide(tab_ != DISPLAY_TAB);
-       show_haloing_button_.hide(tab_ != DISPLAY_TAB);
-       fullscreen_button_.hide(tab_ != DISPLAY_TAB);
-       video_mode_button_.hide(tab_ != DISPLAY_TAB);
-
-       music_slider_.hide(tab_ != SOUND_TAB);
-       sound_slider_.hide(tab_ != SOUND_TAB);
+       bool hide_general = tab_ != GENERAL_TAB;
+       scroll_label_.hide(hide_general);
+       scroll_slider_.hide(hide_general);
+       turbo_button_.hide(hide_general);
+       show_ai_moves_button_.hide(hide_general);
+       turn_dialog_button_.hide(hide_general);
+       turn_bell_button_.hide(hide_general);
+       hotkeys_button_.hide(hide_general);
+       show_team_colours_button_.hide(hide_general);
+       show_grid_button_.hide(hide_general);
+
+       bool hide_display = tab_ != DISPLAY_TAB, hide_gamma = hide_display || 
!adjust_gamma();
+       gamma_label_.hide(hide_gamma);
+       gamma_slider_.hide(hide_gamma);
+       gamma_button_.hide(hide_display);
+       show_floating_labels_button_.hide(hide_display);
+       show_colour_cursors_button_.hide(hide_display);
+       show_haloing_button_.hide(hide_display);
+       fullscreen_button_.hide(hide_display);
+       video_mode_button_.hide(hide_display);
+
+       bool hide_sound = tab_ != SOUND_TAB;
+       music_label_.hide(hide_sound);
+       music_slider_.hide(hide_sound);
+       sound_label_.hide(hide_sound);
+       sound_slider_.hide(hide_sound);
 }
 
 }
@@ -1036,7 +1035,6 @@
                        event.type = 0;
                        int key=0; //just to avoid warning
                        int mod=0;
-                       bool used = false;
                        while (event.type!=SDL_KEYDOWN) SDL_PollEvent(&event);
                        do {
                                if (event.type==SDL_KEYDOWN)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]