Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
68f2d425
Commit
68f2d425
authored
Aug 11, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resize list of stylesheets to fit available space
parent
75db21c2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
2 deletions
+32
-2
src/gui/control/package_list.cpp
src/gui/control/package_list.cpp
+4
-0
src/gui/control/package_list.hpp
src/gui/control/package_list.hpp
+6
-2
src/gui/set/style_panel.cpp
src/gui/set/style_panel.cpp
+18
-0
src/gui/set/style_panel.hpp
src/gui/set/style_panel.hpp
+4
-0
No files found.
src/gui/control/package_list.cpp
View file @
68f2d425
...
...
@@ -100,3 +100,7 @@ void PackageList::select(const String& name, bool send_event) {
update
();
return
;
}
int
PackageList
::
requiredWidth
()
const
{
return
(
item_size
.
x
+
SPACING
)
*
(
int
)
itemCount
();
}
src/gui/control/package_list.hpp
View file @
68f2d425
...
...
@@ -48,11 +48,15 @@ class PackageList : public GalleryList {
/// Select the package with the given name, if it is not found, selects nothing
void
select
(
const
String
&
name
,
bool
send_event
=
true
);
/// Required width to show all items
int
requiredWidth
()
const
;
using
GalleryList
::
column_count
;
protected:
/// Return how many items there are in the list
virtual
size_t
itemCount
()
const
;
/// Draw an item
virtual
void
drawItem
(
DC
&
dc
,
int
x
,
int
y
,
size_t
item
);
/// Return how many items there are in the list
virtual
size_t
itemCount
()
const
;
private:
// The default icon to use
...
...
src/gui/set/style_panel.cpp
View file @
68f2d425
...
...
@@ -8,6 +8,7 @@
#include <util/prec.hpp>
#include <gui/set/style_panel.hpp>
#include <gui/set/window.hpp>
#include <gui/control/package_list.hpp>
#include <gui/control/card_viewer.hpp>
#include <gui/control/native_look_editor.hpp>
...
...
@@ -47,6 +48,23 @@ StylePanel::StylePanel(Window* parent, int id)
s
->
SetSizeHints
(
this
);
SetSizer
(
s
);
}
void
StylePanel
::
updateListSize
()
{
// how many columns fit?
size_t
fit_columns
=
(
size_t
)((
GetSize
().
y
-
400
)
/
152
);
// we only need enough columns to show all items
int
x_room
=
GetSize
().
x
-
editor
->
GetBestSize
().
x
-
6
;
size_t
need_columns
=
(
size_t
)
ceil
(
list
->
requiredWidth
()
/
(
double
)
x_room
);
size_t
column_count
=
max
(
1u
,
min
(
fit_columns
,
need_columns
));
// change count
if
(
column_count
!=
list
->
column_count
)
{
list
->
column_count
=
column_count
;
static_cast
<
SetWindow
*>
(
GetParent
())
->
fixMinWindowSize
();
}
}
bool
StylePanel
::
Layout
()
{
updateListSize
();
return
SetWindowPanel
::
Layout
();
}
void
StylePanel
::
onChangeSet
()
{
list
->
showData
<
StyleSheet
>
(
set
->
game
->
name
()
+
_
(
"-*"
));
...
...
src/gui/set/style_panel.hpp
View file @
68f2d425
...
...
@@ -50,6 +50,10 @@ class StylePanel : public SetWindowPanel {
void
onStyleSelect
(
wxCommandEvent
&
);
void
onUseForAll
(
wxCommandEvent
&
);
void
onUseCustom
(
wxCommandEvent
&
);
/// Determine the best size for the list of stylesheets based on available space
void
updateListSize
();
virtual
bool
Layout
();
};
// ----------------------------------------------------------------------------- : EOF
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment