woelper vor 4 Jahren
Ursprung
Commit
d031ce46f5
3 geänderte Dateien mit 28 neuen und 16 gelöschten Zeilen
  1. 4 4
      sampler.ini
  2. 14 8
      src/base.rs
  3. 10 4
      src/support_ogl/mod.rs

+ 4 - 4
sampler.ini

@@ -9,7 +9,7 @@ Size=300,100
 Collapsed=0
 
 [Window][sources]
-Pos=419,266
+Pos=400,140
 Size=361,711
 Collapsed=0
 
@@ -34,7 +34,7 @@ Size=354,269
 Collapsed=0
 
 [Window][tracks]
-Pos=761,787
+Pos=740,548
 Size=300,160
 Collapsed=0
 
@@ -46,10 +46,10 @@ Collapsed=0
 [Window][patterns]
 Pos=400,140
 Size=324,183
-Collapsed=0
+Collapsed=1
 
 [Window][settings]
-Pos=986,236
+Pos=740,236
 Size=300,160
 Collapsed=0
 

+ 14 - 8
src/base.rs

@@ -156,7 +156,7 @@ where
 
 fn de_snds<'de, D>(deserializer: D) -> Result<HashMap<(usize, usize), Sound>, D::Error>
 where
-    D: serde::de::Deserializer<'de>,
+D: serde::de::Deserializer<'de>,
 {
     // TODO err checking
     let s: HashMap<String, Sound> = serde::de::Deserialize::deserialize(deserializer)?;
@@ -165,7 +165,9 @@ where
     Ok(x)
 }
 
+
 #[derive(Serialize, Deserialize, Clone, Debug)]
+/// A pattern. This holds a matrix of sounds - defined by a length and several tracks.
 pub struct Pattern {
     pub name: String,
     pub repeat: i32,
@@ -176,6 +178,7 @@ pub struct Pattern {
     pub sounds: HashMap<(usize, usize), Sound>,
 }
 
+/// Some basic defaults for a pattern.
 impl Default for Pattern {
     fn default() -> Pattern {
         Pattern {
@@ -205,6 +208,7 @@ impl Pattern {
         }
     }
 
+    /// Deserialize a pattern from a file.
     pub fn load(file: &Path) -> Result<Pattern, String> {
         match File::open(file) {
             Ok(f) => {
@@ -215,6 +219,9 @@ impl Pattern {
             Err(e) => Err(e.to_string())
         }
     }
+
+    /// Replace all souds in a row by a new sound.
+    /// This only replaces the source, leaving other settings intact.
     pub fn replace_sounds(&mut self, new_sound: &Sound, row: usize) {
         for x in 0..self.xsize {
             if let Some(snd) = self.sounds.get_mut(&(x, row)) {
@@ -225,6 +232,7 @@ impl Pattern {
         }
     }
 
+    /// Guess the name from the most commpn sound in a pattern.
     pub fn name_from_row(&self, row: usize) -> String {
         let mut names: HashMap<String, usize> = HashMap::new();
 
@@ -252,6 +260,7 @@ impl Pattern {
         s
     }
 
+    /// Clear all sound in a pattern row
     pub fn clear_sounds(&mut self, row: usize) {
         for x in 0..self.xsize {
             if let Some(_) = self.sounds.get(&(x, row)) {
@@ -260,27 +269,24 @@ impl Pattern {
         }
     }
 
+    /// Clear all sounds in a pattern.
     pub fn clear_all_sounds(&mut self) {
         self.sounds.clear();
     }
 
+    /// Reload all sounds in a pattern
     pub fn reload_sounds(&mut self) -> Pattern {
-        // let mut newp = self.clone();
         for x in 0..self.xsize {
             for y in 0..self.ysize {
                 if let Some(snd) = self.sounds.get_mut(&(x,y)) {
-                    println!("RELOAD {:?}", &snd.name);
-
-                    // snd.data = snd.updated_drom_source().unwrap().data;
+                    // println!("RELOAD {:?}", &snd.name);
                     match snd.updated_drom_source() {
                         Ok(newdata) => snd.data = newdata.data,
-                        Err(e) => println!("ERROR LOADING {:?}", e)
+                        Err(e) => println!("ERROR LOADING SND {:?} {:?}", e, snd.location)
                     }
-
                 }
             }
         }
-        // newp.clone()
         self.clone()
     }
 

+ 10 - 4
src/support_ogl/mod.rs

@@ -32,7 +32,16 @@ pub fn init(title: &str) -> System {
         let mut platform = WinitPlatform::init(&mut imgui);
         
     let render_sys = RenderSystem::init(&mut imgui, builder, &events_loop);
-    let dpi = render_sys.window().get_hidpi_factor();
+    let mut dpi = render_sys.window().get_hidpi_factor();
+    if cfg!(windows) {
+        if dpi  ==  1.5 {
+            dpi = 0.95;
+        }
+        if dpi  >  1.5 {
+            dpi = 1.1;
+        }
+    }
+
     // let hidpi_factor = platform.hidpi_factor();
     // dbg!(hidpi_factor);
     let font_size = (16.0 * dpi) as f32;
@@ -136,14 +145,12 @@ impl System {
     }
 }
 
-// #[cfg(feature = "opengl")]
 mod types {
     pub type Device = gfx_device_gl::Device;
     pub type Factory = gfx_device_gl::Factory;
     pub type Resources = gfx_device_gl::Resources;
 }
 
-// #[cfg(feature = "opengl")]
 pub struct RenderSystem {
     pub renderer: Renderer<ColorFormat, types::Resources>,
     pub windowed_context: glutin::WindowedContext<glutin::PossiblyCurrent>,
@@ -153,7 +160,6 @@ pub struct RenderSystem {
     pub main_depth: gfx::handle::DepthStencilView<types::Resources, gfx::format::DepthStencil>,
 }
 
-// #[cfg(feature = "opengl")]
 impl RenderSystem {
     pub fn init(
         imgui: &mut Context,