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

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

[Wesnoth-cvs-commits] wesnoth/src/widgets file_chooser.cpp file_choos...


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src/widgets file_chooser.cpp file_choos...
Date: Thu, 18 Nov 2004 15:32:24 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    04/11/18 20:26:34

Modified files:
        src/widgets    : file_chooser.cpp file_chooser.hpp 

Log message:
        Hi-level is good; let's remove direct font drawing to simplify code.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/file_chooser.cpp.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/file_chooser.hpp.diff?tr1=1.9&tr2=1.10&r1=text&r2=text

Patches:
Index: wesnoth/src/widgets/file_chooser.cpp
diff -u wesnoth/src/widgets/file_chooser.cpp:1.16 
wesnoth/src/widgets/file_chooser.cpp:1.17
--- wesnoth/src/widgets/file_chooser.cpp:1.16   Thu Nov 18 20:14:45 2004
+++ wesnoth/src/widgets/file_chooser.cpp        Thu Nov 18 20:26:34 2004
@@ -33,7 +33,8 @@
        : widget(disp), delete_button_(disp, _("Delete File")),
          path_delim_('/'), current_dir_(get_path(start_file)),
          chosen_file_(start_file), file_list_(disp, files_in_current_dir_, 
false),
-         filename_textbox_(disp, 100, start_file, true), choice_made_(false),
+         filename_textbox_(disp, 100, start_file, true),
+         current_path_label_(disp, current_dir_), choice_made_(false),
          last_selection_(-1) {
        // If the start file is not a file or directory, use the root.
        if(!file_exists(chosen_file_) && !is_directory(chosen_file_)
@@ -44,6 +45,7 @@
        // Set sizes to some default values.
        set_measurements(400, 500);
        update_file_lists();
+       display_chosen_file();
 }
 
 void file_chooser::display_current_files() {
@@ -76,7 +78,8 @@
        file_list_.set_items(to_show);
        // This will prevent the "box" with filenames from changing size on
        // every redisplay, it looks better when it's static.
-       file_list_.set_width(width());  
+       file_list_.set_width(width());
+       current_path_label_.set_text(current_dir_);
 }
 
 void file_chooser::display_chosen_file() {
@@ -90,12 +93,6 @@
        }
 }
 
-void file_chooser::draw_contents() {
-       font::draw_text(&disp(), current_path_rect_, font::SIZE_NORMAL, 
font::NORMAL_COLOUR,
-                                       current_dir_, current_path_rect_.x, 
current_path_rect_.y,
-                                       disp().video().getSurface());
-}
-
 void file_chooser::process_event() {
        CKey key;
        int mousex, mousey;
@@ -217,12 +214,7 @@
 }
 
 void file_chooser::update_location(SDL_Rect const &rect) {
-       const int current_path_y = rect.y;
-       current_path_rect_.y = current_path_y;
-       current_path_rect_.w = rect.w;
-       current_path_rect_.x = rect.x;
-       current_path_rect_.h = 18;
-       const int file_list_y = current_path_y + current_path_rect_.h + 10;
+       const int file_list_y = rect.y + current_path_label_.height() + 10;
        const int filename_textbox_y = rect.y + rect.h - 
filename_textbox_.height();
        const int file_list_height = filename_textbox_y  - file_list_y - 10 - 
32;
 
@@ -230,9 +222,11 @@
        const int delete_button_y = file_list_y + file_list_height + 5;
        delete_button_.set_location(delete_button_x, delete_button_y);
 
+       current_path_label_.set_width(rect.w);
        file_list_.set_width(rect.w);
        filename_textbox_.set_width(rect.w);
 
+       current_path_label_.set_location(rect.x, rect.y);
        file_list_.set_location(rect.x, file_list_y);
        filename_textbox_.set_location(rect.x, filename_textbox_y);
 
Index: wesnoth/src/widgets/file_chooser.hpp
diff -u wesnoth/src/widgets/file_chooser.hpp:1.9 
wesnoth/src/widgets/file_chooser.hpp:1.10
--- wesnoth/src/widgets/file_chooser.hpp:1.9    Thu Nov 18 20:14:45 2004
+++ wesnoth/src/widgets/file_chooser.hpp        Thu Nov 18 20:26:34 2004
@@ -13,6 +13,7 @@
 #ifndef FILE_CHOOSER_H_INCLUDED
 #define FILE_CHOOSER_H_INCLUDED
 
+#include "label.hpp"
 #include "menu.hpp"
 #include "textbox.hpp"
 #include "widget.hpp"
@@ -37,7 +38,6 @@
        virtual void update_location(SDL_Rect const &rect);
        virtual void handle_event(const SDL_Event& event);
        virtual void process_event();
-       virtual void draw_contents();
 
 private:
        /// If file_or_dir is a file, return the directory the file is in,
@@ -90,7 +90,7 @@
        std::vector<std::string> files_in_current_dir_, dirs_in_current_dir_;
        menu file_list_;
        textbox filename_textbox_;
-       SDL_Rect current_path_rect_;
+       label current_path_label_;
        bool choice_made_;
        int last_selection_;
 };




reply via email to

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