~ubuntu-branches/ubuntu/vivid/fbreader/vivid-proposed

« back to all changes in this revision

Viewing changes to fbreader/src/optionsDialog/ScrollingOptionsPage.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2008-01-23 16:51:07 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080123165107-5q19etahzd72c33a
Tags: 0.8.12-3
* Add libzlui-maemo which allows using fbreader on the maemo platform, on
  Debian. Thanks, Riku Voipio. Closes: #462299
* makefiles/arch/maemo.mk: Don't build with -thumb. (Riku)
* Loosen dependency versions some more, so it only depends on the current
  upstream version or higher, ignoring the Debian revision.
* Use binary:Version instead of deprecated Source-Version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * FBReader -- electronic book reader
3
 
 * Copyright (C) 2004-2007 Nikolay Pultsin <geometer@mawhrin.net>
4
 
 * Copyright (C) 2005 Mikhail Sobolev <mss@mawhrin.net>
 
2
 * Copyright (C) 2004-2008 Geometer Plus <contact@geometerplus.com>
5
3
 *
6
4
 * This program is free software; you can redistribute it and/or modify
7
5
 * it under the terms of the GNU General Public License as published by
41
39
        std::string myLargeScrollingString;
42
40
        std::string mySmallScrollingString;
43
41
        std::string myMouseScrollingString;
44
 
        std::string myFingerTapScrollingString;
 
42
        std::string myTapScrollingString;
45
43
 
46
44
private:
47
45
        const ZLResource &myResource;
64
62
        static ZLTextView::ScrollingMode codeByName(const std::string &name);
65
63
        
66
64
public:
67
 
        ScrollingModeEntry(FBReader &fbreader, ScrollingOptionsPage::ScrollingEntries &entries, ZLIntegerOption &option, bool isFingerTapOption);
 
65
        ScrollingModeEntry(FBReader &fbreader, ScrollingOptionsPage::ScrollingEntries &entries, ZLIntegerOption &option, bool isTapOption);
68
66
 
69
67
        const std::string &initialValue() const;
70
68
        const std::vector<std::string> &values() const;
78
76
        ZLIntegerOption &myOption;
79
77
        std::vector<std::string> myValues;
80
78
        int myCurrentIndex;
81
 
        bool myIsFingerTapOption;
 
79
        bool myIsTapOption;
82
80
};
83
81
 
84
82
ScrollingTypeEntry::ScrollingTypeEntry(const ZLResource &resource, FBReader &fbreader, ScrollingOptionsPage &page) : myResource(resource), myFBReader(fbreader), myPage(page) {
85
83
        myLargeScrollingString = resource["large"].value();
86
84
        mySmallScrollingString = resource["small"].value();
87
85
        myMouseScrollingString = resource["mouse"].value();
88
 
        myFingerTapScrollingString = resource["finger"].value();
 
86
        myTapScrollingString = resource["tap"].value();
89
87
 
90
88
        myValues.push_back(myLargeScrollingString);
91
89
        myValues.push_back(mySmallScrollingString);
92
 
        if (myFBReader.isMousePresented()) {
 
90
 
 
91
        const bool isMousePresented = 
 
92
                ZLBooleanOption(ZLCategoryKey::EMPTY, ZLOption::PLATFORM_GROUP, ZLOption::MOUSE_PRESENTED, false).value();
 
93
        const bool hasTouchScreen = 
 
94
                ZLBooleanOption(ZLCategoryKey::EMPTY, ZLOption::PLATFORM_GROUP, ZLOption::TOUCHSCREEN_PRESENTED, false).value();
 
95
 
 
96
        if (isMousePresented) {
93
97
                myValues.push_back(myMouseScrollingString);
94
98
        }
95
 
        if (myFBReader.isFingerTapEventSupported()) {
96
 
                myValues.push_back(myFingerTapScrollingString);
 
99
        if (hasTouchScreen) {
 
100
                myValues.push_back(myTapScrollingString);
97
101
        }
98
102
}
99
103
 
112
116
        const std::string &selectedValue = values()[index];
113
117
        myPage.myLargeScrollingEntries.show(selectedValue == myLargeScrollingString);
114
118
        myPage.mySmallScrollingEntries.show(selectedValue == mySmallScrollingString);
115
 
        if (myFBReader.isMousePresented()) {
 
119
 
 
120
        const bool isMousePresented = 
 
121
                ZLBooleanOption(ZLCategoryKey::EMPTY, ZLOption::PLATFORM_GROUP, ZLOption::MOUSE_PRESENTED, false).value();
 
122
        const bool hasTouchScreen = 
 
123
                ZLBooleanOption(ZLCategoryKey::EMPTY, ZLOption::PLATFORM_GROUP, ZLOption::TOUCHSCREEN_PRESENTED, false).value();
 
124
 
 
125
        if (isMousePresented) {
116
126
                myPage.myMouseScrollingEntries.show(selectedValue == myMouseScrollingString);
117
127
        }
118
 
        if (myFBReader.isFingerTapEventSupported()) {
119
 
                myPage.myFingerTapScrollingEntries.show(selectedValue == myFingerTapScrollingString);
 
128
        if (hasTouchScreen) {
 
129
                myPage.myTapScrollingEntries.show(selectedValue == myTapScrollingString);
120
130
        }
121
131
}
122
132
 
152
162
        return ZLTextView::NO_OVERLAPPING;
153
163
}
154
164
 
155
 
ScrollingModeEntry::ScrollingModeEntry(FBReader &fbreader, ScrollingOptionsPage::ScrollingEntries &page, ZLIntegerOption &option, bool isFingerTapOption) : myFBReader(fbreader), myEntries(page), myOption(option), myIsFingerTapOption(isFingerTapOption) {
 
165
ScrollingModeEntry::ScrollingModeEntry(FBReader &fbreader, ScrollingOptionsPage::ScrollingEntries &page, ZLIntegerOption &option, bool isTapOption) : myFBReader(fbreader), myEntries(page), myOption(option), myIsTapOption(isTapOption) {
156
166
        myValues.push_back(ourNoOverlappingString);
157
167
        myValues.push_back(ourKeepLinesString);
158
168
        myValues.push_back(ourScrollLinesString);
159
169
        myValues.push_back(ourScrollPercentageString);
160
 
        if (myIsFingerTapOption) {
 
170
        if (myIsTapOption) {
161
171
                myValues.push_back(ourDisableString);
162
172
        }
163
173
}
164
174
 
165
175
const std::string &ScrollingModeEntry::initialValue() const {
166
 
        if (myIsFingerTapOption && !myFBReader.EnableFingerScrollingOption.value()) {
 
176
        if (myIsTapOption && !myFBReader.EnableTapScrollingOption.value()) {
167
177
                return ourDisableString;
168
178
        }
169
179
        return nameByCode(myOption.value());
174
184
}
175
185
 
176
186
void ScrollingModeEntry::onAccept(const std::string &text) {
177
 
        if (myIsFingerTapOption && (text == ourDisableString)) {
178
 
                myFBReader.EnableFingerScrollingOption.setValue(false);
 
187
        if (myIsTapOption && (text == ourDisableString)) {
 
188
                myFBReader.EnableTapScrollingOption.setValue(false);
179
189
        } else {
180
 
                myFBReader.EnableFingerScrollingOption.setValue(true);
 
190
                myFBReader.EnableTapScrollingOption.setValue(true);
181
191
                myOption.setValue(codeByName(text));
182
192
        }
183
193
}
189
199
void ScrollingModeEntry::onValueSelected(int index) {
190
200
        myCurrentIndex = index;
191
201
        const std::string &selectedValue = values()[index];
 
202
        if (myEntries.myFingerOnlyEntry != 0) {
 
203
                myEntries.myFingerOnlyEntry->setVisible(selectedValue != ourDisableString);
 
204
        }
192
205
        myEntries.myDelayEntry->setVisible(selectedValue != ourDisableString);
193
206
        myEntries.myLinesToKeepEntry->setVisible(selectedValue == ourKeepLinesString);
194
207
        myEntries.myLinesToScrollEntry->setVisible(selectedValue == ourScrollLinesString);
200
213
static const ZLResourceKey linesToKeepKey("linesToKeep");
201
214
static const ZLResourceKey linesToScrollKey("linesToScroll");
202
215
static const ZLResourceKey percentToScrollKey("percentToScroll");
 
216
static const ZLResourceKey fingerOnlyKey("fingerOnly");
203
217
 
204
218
void ScrollingOptionsPage::ScrollingEntries::init(FBReader &fbreader, FBReader::ScrollingOptions &options) {
 
219
        const bool isTapOption = &options == &fbreader.TapScrollingOptions;
 
220
        const bool isFingerTapDetectionSupported = 
 
221
                ZLBooleanOption(ZLCategoryKey::EMPTY, ZLOption::PLATFORM_GROUP, ZLOption::FINGER_TAP_DETECTABLE, false).value();
 
222
        if (isTapOption && isFingerTapDetectionSupported) {
 
223
                myFingerOnlyEntry = new ZLSimpleBooleanOptionEntry(fbreader.TapScrollingOnFingerOnlyOption);
 
224
        } else {
 
225
                myFingerOnlyEntry = 0;
 
226
        }
205
227
        myDelayEntry = new ZLSimpleSpinOptionEntry(options.DelayOption, 50);
206
 
        myModeEntry = new ScrollingModeEntry(fbreader, *this, options.ModeOption, &options == &fbreader.FingerTapScrollingOptions);
 
228
        myModeEntry = new ScrollingModeEntry(fbreader, *this, options.ModeOption, isTapOption);
207
229
        myLinesToKeepEntry = new ZLSimpleSpinOptionEntry(options.LinesToKeepOption, 1);
208
230
        myLinesToScrollEntry = new ZLSimpleSpinOptionEntry(options.LinesToScrollOption, 1);
209
231
        myPercentToScrollEntry = new ZLSimpleSpinOptionEntry(options.PercentToScrollOption, 5);
216
238
        dialogTab.addOption(linesToKeepKey, myLinesToKeepEntry);
217
239
        dialogTab.addOption(linesToScrollKey, myLinesToScrollEntry);
218
240
        dialogTab.addOption(percentToScrollKey, myPercentToScrollEntry);
 
241
        if (myFingerOnlyEntry != 0) {
 
242
                dialogTab.addOption(fingerOnlyKey, myFingerOnlyEntry);
 
243
        }
219
244
}
220
245
 
221
246
void ScrollingOptionsPage::ScrollingEntries::show(bool visible) {
222
247
        if (myDelayEntry != 0) {
 
248
                if (myFingerOnlyEntry != 0) {
 
249
                        myFingerOnlyEntry->setVisible(visible);
 
250
                }
223
251
                myDelayEntry->setVisible(visible);
224
252
                myModeEntry->setVisible(visible);
225
253
                if (visible) {
246
274
 
247
275
        myLargeScrollingEntries.init(fbreader, fbreader.LargeScrollingOptions);
248
276
        mySmallScrollingEntries.init(fbreader, fbreader.SmallScrollingOptions);
249
 
        if (fbreader.isMousePresented()) {
 
277
 
 
278
        const bool isMousePresented = 
 
279
                ZLBooleanOption(ZLCategoryKey::EMPTY, ZLOption::PLATFORM_GROUP, ZLOption::MOUSE_PRESENTED, false).value();
 
280
        const bool hasTouchScreen = 
 
281
                ZLBooleanOption(ZLCategoryKey::EMPTY, ZLOption::PLATFORM_GROUP, ZLOption::TOUCHSCREEN_PRESENTED, false).value();
 
282
 
 
283
        if (isMousePresented) {
250
284
                myMouseScrollingEntries.init(fbreader, fbreader.MouseScrollingOptions);
251
285
        }
252
 
        if (fbreader.isFingerTapEventSupported()) {
253
 
                myFingerTapScrollingEntries.init(fbreader, fbreader.FingerTapScrollingOptions);
 
286
        if (hasTouchScreen) {
 
287
                myTapScrollingEntries.init(fbreader, fbreader.TapScrollingOptions);
254
288
        }
255
289
 
256
290
        mainEntry->onStringValueSelected(mainEntry->initialValue());
257
291
 
258
292
        myLargeScrollingEntries.connect(dialogTab);
259
293
        mySmallScrollingEntries.connect(dialogTab);
260
 
        if (fbreader.isMousePresented()) {
 
294
        if (isMousePresented) {
261
295
                myMouseScrollingEntries.connect(dialogTab);
262
296
        }
263
 
        if (fbreader.isFingerTapEventSupported()) {
264
 
                myFingerTapScrollingEntries.connect(dialogTab);
 
297
        if (hasTouchScreen) {
 
298
                myTapScrollingEntries.connect(dialogTab);
265
299
        }
266
300
}