From 1c40d127cda402e9f46f2a42baa326ca88bb99f8 Mon Sep 17 00:00:00 2001 From: chrox Date: Sun, 3 Feb 2013 11:26:14 +0800 Subject: [PATCH] add icon option items in config dialog --- frontend/document/koptinterface.lua | 18 ++++- frontend/ui/config.lua | 68 +++++++++++++++++- resources/icons/appbar.align.auto.png | Bin 0 -> 154 bytes resources/icons/appbar.align.center.png | Bin 0 -> 186 bytes resources/icons/appbar.align.justify.png | Bin 0 -> 156 bytes resources/icons/appbar.align.left.png | Bin 0 -> 178 bytes resources/icons/appbar.align.right.png | Bin 0 -> 188 bytes resources/icons/appbar.column.one.png | Bin 0 -> 156 bytes resources/icons/appbar.column.three.png | Bin 0 -> 157 bytes resources/icons/appbar.column.two.large.png | Bin 565 -> 160 bytes resources/icons/appbar.column.two.png | Bin 0 -> 157 bytes resources/icons/src/appbar.align.center.xaml | 9 +++ resources/icons/src/appbar.align.justify.xaml | 9 +++ resources/icons/src/appbar.align.left.xaml | 9 +++ resources/icons/src/appbar.align.right.xaml | 9 +++ 15 files changed, 118 insertions(+), 4 deletions(-) create mode 100644 resources/icons/appbar.align.auto.png create mode 100644 resources/icons/appbar.align.center.png create mode 100644 resources/icons/appbar.align.justify.png create mode 100644 resources/icons/appbar.align.left.png create mode 100644 resources/icons/appbar.align.right.png create mode 100644 resources/icons/appbar.column.one.png create mode 100644 resources/icons/appbar.column.three.png create mode 100644 resources/icons/appbar.column.two.png create mode 100644 resources/icons/src/appbar.align.center.xaml create mode 100644 resources/icons/src/appbar.align.justify.xaml create mode 100644 resources/icons/src/appbar.align.left.xaml create mode 100644 resources/icons/src/appbar.align.right.xaml diff --git a/frontend/document/koptinterface.lua b/frontend/document/koptinterface.lua index 95742f2fc..b7ee5b29c 100644 --- a/frontend/document/koptinterface.lua +++ b/frontend/document/koptinterface.lua @@ -64,14 +64,26 @@ KoptOptions = { { name = "max_columns", name_text = "Columns", - item_text = {"1","2","3","4"}, + --item_text = {"1","2","3","4"}, + item_icons = { + "resources/icons/appbar.column.one.png", + "resources/icons/appbar.column.two.png", + "resources/icons/appbar.column.three.png", + }, values = {1,2,3,4}, default_value = 2, }, { name = "justification", - name_text = "Justification", - item_text = {"auto","left","center","right","full"}, + name_text = "Text Align", + --item_text = {"auto","left","center","right","full"}, + item_icons = { + "resources/icons/appbar.align.auto.png", + "resources/icons/appbar.align.left.png", + "resources/icons/appbar.align.center.png", + "resources/icons/appbar.align.right.png", + "resources/icons/appbar.align.justify.png", + }, values = {-1,0,1,2,3}, default_value = -1, }, diff --git a/frontend/ui/config.lua b/frontend/ui/config.lua index d0eb3777b..af8939de1 100644 --- a/frontend/ui/config.lua +++ b/frontend/ui/config.lua @@ -99,6 +99,48 @@ function OptionTextItem:onTapSelect() return true end +OptionIconItem = InputContainer:new{} +function OptionIconItem:init() + self.dimen = self.icon:getSize() + self[1] = UnderlineContainer:new{ + self.icon, + padding = self.padding, + color = self.color, + } + -- we need this table per-instance, so we declare it here + if Device:isTouchDevice() then + self.ges_events = { + TapSelect = { + GestureRange:new{ + ges = "tap", + range = self.dimen, + }, + doc = "Select Option Item", + }, + } + end +end + +function OptionIconItem:onTapSelect() + for _, item in pairs(self.items) do + --item[1][1].invert = false + item[1].color = 0 + end + --self[1][1].invert = true + self[1].color = 15 + local option_value = nil + local option_arg = nil + if type(self.values) == "table" then + option_value = self.values[self.current_item] + self.config:onConfigChoice(self.name, option_value, self.event) + elseif type(self.args) == "table" then + option_arg = self.args[self.current_item] + self.config:onConfigChoice(self.name, option_arg, self.event) + end + UIManager.repaint_all = true + return true +end + --[[ Dummy Widget that reserves vertical and horizontal space ]] @@ -265,7 +307,7 @@ function ConfigOption:init() local default_item_font_size = math.floor(16*mag_ratio) local default_items_spacing = math.floor(30*mag_ratio) local default_option_height = math.floor(50*mag_ratio) - local default_option_padding = math.floor(30*mag_ratio) + local default_option_padding = math.floor(15*mag_ratio) local vertical_group = VerticalGroup:new{} table.insert(vertical_group, VerticalSpan:new{ width = default_option_padding }) for c = 1, #self.options do @@ -381,6 +423,30 @@ function ConfigOption:init() end end + if self.options[c].item_icons then + for d = 1, #self.options[c].item_icons do + local option_item = OptionIconItem:new{ + icon = ImageWidget:new{ + file = self.options[c].item_icons[d] + }, + padding = -2, + color = d == current_item and 15 or 0, + } + option_items[d] = option_item + option_item.items = option_items + option_item.name = self.options[c].name + option_item.values = self.options[c].values + option_item.args = self.options[c].args + option_item.event = self.options[c].event + option_item.current_item = d + option_item.config = self.config + table.insert(option_items_group, option_item) + if d ~= #self.options[c].item_icons then + table.insert(option_items_group, items_spacing) + end + end + end + if self.options[c].toggle then local switch = ToggleSwitch:new{ name = self.options[c].name, diff --git a/resources/icons/appbar.align.auto.png b/resources/icons/appbar.align.auto.png new file mode 100644 index 0000000000000000000000000000000000000000..5d63b396598ca49599b6a342397e53f8b60ec771 GIT binary patch literal 154 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDH3?y^UWFG-iYymzYt_(~J|Nj4Rzw{j>%~{|P zSq#*19fTR3G-g)-1=&kHeO=k_GBGo=SQ_iC>H-R>d%8G=NL)_-!OzBXB*0!mLgGzf tfQHt8g9g@(L0`;fRq!s^Eyc~s@M+GLi>BQ73V~V}JYD@<);T3K0RSYwDsBJ( literal 0 HcmV?d00001 diff --git a/resources/icons/appbar.align.center.png b/resources/icons/appbar.align.center.png new file mode 100644 index 0000000000000000000000000000000000000000..6db64f3253805f88a46e09ec8e679ceb82cc8718 GIT binary patch literal 186 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDH3?y^UWFG-iYymzYt_(~J|Nj4Rzw{j>&6wov z?!wT)D(eB{a29w(76Y|k2Vq7hjoB4ILG}_)Usv|KOw7y-!aYBiMF54YJY5_^BrYfa z;Ai7G5@0VO@uV&6wov z?!wT)D(eB{a29w(76Y|k2Vq7hjoB4ILG}_)Usv|KOw7!TD!TDTVn87oPZ!4!iOb19 t_}O?|0_r6i4#-)%t~;feYhuR5uW6M^a&JYD@<);T3K0RWYMCjS5c literal 0 HcmV?d00001 diff --git a/resources/icons/appbar.align.left.png b/resources/icons/appbar.align.left.png new file mode 100644 index 0000000000000000000000000000000000000000..d6acd7568b8cb3e3074b90b9b9e7831aed598426 GIT binary patch literal 178 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDH3?y^UWFG-iYymzYt_(~JfB*k+o#L4Z6k$yA zc6VXuV3qX%aySb-B8!3AuY)k7lg8`{pdfpRr>`sfT_$E`CJp{0y8nPeMxHK?ArhC9 zfAF*MxCGQoNJzXX449!MSr}l^d(1U)Rmz6reh*D%$+Nc}eNpvB`sfT_$E`W(5hBDZM};8&4O<5Q)pl zKls^rjs(<8NJzXX3|OHht4u;aT8`HkSvLmV=>5kq@vzsz6@SRL&S3j3^P6&6wov z?!wT)D(eB{a29w(76Y|k2Vq7hjoB4ILG}_)Usv|KOw3HCV(|&T!hk|Do-U3d5|@*I t@U!u_1k_739FVhiU3W?`*TjsAVcYLDKQl!%CIZzlc)I$ztaD0e0s!EJC|>{o literal 0 HcmV?d00001 diff --git a/resources/icons/appbar.column.three.png b/resources/icons/appbar.column.three.png new file mode 100644 index 0000000000000000000000000000000000000000..a66eaeb6f95bbeae67b32faf24b005da282163b5 GIT binary patch literal 157 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDH3?y^UWFG-iYymzYt_+L}|Nj4BDC&Ix6k$yA zc6VXuV3qX%aySb-B8wRqxP?KOkzv*x37{Z*iKnkC`&}kxCIj=lIyqmUkgTVRV~E7% wKCCYf!W^8^7#j!z0000b3+9Oc000JJOGiWi{{a60|De66laW9kf7}cV3kESQ z-)s;700F{DL_t(&-tC&bio!q?h2y&ZpeceF5ClzUC8X0Xjh)z;(nqngw6nCZNRbDy zQ1A(~QG5f-prC?6EHoAYNwa}H;}Wx+sV)qBW1M=uUM`n^oc2P8$i1;``^Cv*GB9T{nS@*+Gw|UV zXfzryx>zg*Ik(#lz-%^y(Ymg`>gjYU^0No~00k&O0SZvyzY077S#D^dcG$bZ P00000NkvXXu0mjfP|EAY diff --git a/resources/icons/appbar.column.two.png b/resources/icons/appbar.column.two.png new file mode 100644 index 0000000000000000000000000000000000000000..222d33c2ad6923bdde6e0883f18d2ae02f0c17e9 GIT binary patch literal 157 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDH3?y^UWFG-iYymzYt_(~J|Nj4Rzw{j>&6wov z?!wT)D(eB{a29w(76Y|k2Vq7hjoB4ILG}_)Usv|KOw3H?T27Wvf`LM^o-U3d5|@*I u@U!u_1k_7NNK3rg82n_F%q6$v#S9DWcM7V+-tGq~WbkzLb6Mw<&;$Sh&?wCS literal 0 HcmV?d00001 diff --git a/resources/icons/src/appbar.align.center.xaml b/resources/icons/src/appbar.align.center.xaml new file mode 100644 index 000000000..52e696825 --- /dev/null +++ b/resources/icons/src/appbar.align.center.xaml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/resources/icons/src/appbar.align.justify.xaml b/resources/icons/src/appbar.align.justify.xaml new file mode 100644 index 000000000..1a929c590 --- /dev/null +++ b/resources/icons/src/appbar.align.justify.xaml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/resources/icons/src/appbar.align.left.xaml b/resources/icons/src/appbar.align.left.xaml new file mode 100644 index 000000000..d7e0e0c7d --- /dev/null +++ b/resources/icons/src/appbar.align.left.xaml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/resources/icons/src/appbar.align.right.xaml b/resources/icons/src/appbar.align.right.xaml new file mode 100644 index 000000000..08a86c4cb --- /dev/null +++ b/resources/icons/src/appbar.align.right.xaml @@ -0,0 +1,9 @@ + + + + + + + + +